Commit Graph

15 Commits

Author SHA1 Message Date
dyoung aa9db6efb2 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'.
2010-07-01 16:44:05 +00:00
dyoung 83fdd687cf Change a > to a >= to avoid writing to the character after the end of
the buffer passed to get_string().
2010-07-01 16:12:23 +00:00
dyoung c5d5f7697a 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).
2009-09-11 22:06:29 +00:00
dyoung ab7c5957a9 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.
2009-08-07 18:53:37 +00:00
dyoung 46db29bcf1 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.
2009-04-27 20:10:49 +00:00
dyoung 740c7b59d2 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.
2009-04-21 22:46:39 +00:00
lukem c6144e484f fix -Wsign-compare issues 2009-01-18 00:24:29 +00:00
dyoung d75414adf5 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.
2008-07-02 07:44:13 +00:00
dyoung 76766729c4 Use an AF_LINK socket to add/delete/get link-layer addresses. 2008-05-13 18:10:17 +00:00
dyoung 8c56a7ef60 Cosmetic: fix copyright whitespace. 2008-05-12 21:53:32 +00:00
dyoung cd86d94cd8 We cannot create an AF_LINK socket. If AF_LINK is requested, create
an AF_INET socket, instead.
2008-05-12 21:52:29 +00:00
dyoung 8c460289fe Factor out common code, creating direct_ioctl() and indirect_ioctl()
for the two most prevalent styles of ioctl(2) calls in ifconfig(8).
2008-05-07 23:55:06 +00:00
dyoung e4942eb316 Interpret 'prefixlen 0' as the maximum prefix length, as ifconfig
has always done.
2008-05-07 18:17:42 +00:00
dyoung e51773dc79 Add a license. 2008-05-06 16:09:18 +00:00
dyoung 7b01455a0e 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.
2008-05-06 04:33:42 +00:00