Home | History | Annotate | Download | only in ifconfig
History log of /src/sbin/ifconfig/util.c
RevisionDateAuthorComments
 1.20  11-Oct-2020  roy ifconfig: if SIOCGLIFADDR fails, continue to the next address
 1.19  01-Oct-2019  kardel PR/54513 ifconfig exits on newly created carp interfaces
downgrade from err(EXIT_FAILURE, ... ) to warn() if ioctl(SIOCGLIFADDR) fails.
ifconfig now survives freshly created carp interfaces.
 1.18  16-Aug-2019  msaitoh Whitespace fix.
 1.17  19-Oct-2013  christos branches: 1.17.26;
use the new scopeid functions
 1.16  13-Dec-2010  pooka branches: 1.16.6; 1.16.12;
Convert from the .ifdef RUMP_ACTION stuff to RUMPPRG.
 1.15  01-Jul-2010  dyoung Add to the string parse object (pstr), and its constructors, a flag that
tells whether it should detect and convert to binary a hexadecimal octet
string of the form 0x0123ABab, or leave those strings undecoded.

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

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

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

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

In support of the changes above,

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.17.26.1  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411

RSS XML Feed