Commit Graph

441 Commits

Author SHA1 Message Date
msaitoh bbc956a9be Add SIOCGETHERCAP ioctl.
There was no way to know the setting of ec_capabilities and ec_capenable
other than grepping the source.

See http://mail-index.netbsd.org/tech-kern/2010/07/28/msg008613.html
2012-10-31 10:17:34 +00:00
christos 54abeff8fd don't define RUMP_ACTION if MKRUMP = no 2012-08-08 14:10:38 +00:00
christos c583007244 PR/43141: Tobias Nygren: Print an error on unknown interfaces. 2012-03-17 02:25:08 +00:00
mbalmer 28c55e99d7 When ifconfig is invoked without any arguments, display the list of
all network interfaces (equivalent to ifconfig -a), instead of displaying
the usage.  (This is consistent with the behaviour on FreeBSD and OpenBSD.)
2012-01-28 15:01:44 +00:00
joerg baa8e84b6f Use __dead 2011-08-29 14:34:58 +00:00
christos f5bc231029 use memcpy to avoid strict aliasing warnings 2011-08-14 12:15:15 +00:00
mrg c111245a78 apply some -Wno-error and/or -fno-strict-aliasing.
all of this should be looked at closer, but some of them are not
very trivial.
2011-06-22 02:49:41 +00:00
riastradh 63cdfaffb6 Fix typo: `symbolically' takes three l's, not two. 2011-05-31 16:17:30 +00:00
joerg b1162954df Don't use address strings as format string. 2011-05-24 11:38:56 +00:00
pooka 72e657672d A few weeks ago when i added "linkstr" support I didn't know that
the string parser gives a proplib object which isn't a terminated
string.  Fix that mistake now.
2010-12-14 10:51:51 +00:00
pooka 67a4f392d8 use crunchops for crunchables 2010-12-13 21:48:01 +00:00
njoly 6c19f9ea7b op_read return value is a ssize_t, not an int. 2010-12-13 19:17:20 +00:00
pooka a415ef09e9 Convert from the .ifdef RUMP_ACTION stuff to RUMPPRG. 2010-12-13 17:35:08 +00:00
pooka 6f2301fb3c Implement ifconfig linkstr as proposed on tech-net. 2010-11-15 22:42:36 +00:00
pooka 2ddc760fc7 Need getifaddrs() for the rump client since it executes sysctl(2) 2010-11-05 16:23:56 +00:00
pooka 7d1c54af24 adapt to new rumpclient_init() signature 2010-11-05 13:52:41 +00:00
pooka 23c2b7b527 Update RUMP_ACTION to use the newstyle rump client. 2010-11-04 23:31:12 +00:00
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 de51d12924 Apparently, -g belongs in the DBG variable, not in CFLAGS. Make it so
on a line that is commented-out in this makefile.
2010-07-01 16:28:21 +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
plunky a5a749a5f7 C99 says that offsetof() expands to a constant expresssion, so we
can't use variable array index in there. Do the calculation manually
for C99 compilers (pcc)
2010-04-20 21:25:25 +00:00
is c41a4b460e Use getnameinfo() for printing AppleTalk addresses. While here, fix
printing of broadcast for this address family (AT broadcast is fixed
node 255 on the local net).
2010-01-30 18:30:33 +00:00
dyoung 6abb73d262 Compare a pointer with NULL instead of testing its "truth." 2010-01-22 23:50:07 +00:00
tsutsui aa68f4ed1a - no space needed between -I and dir per gcc(1)
- it's still better to use ${NETBSDSRCDIR} per other existing Makefiles
2009-09-16 15:08:29 +00:00
tsutsui d60368466f Add comments that Makefile.inc should have shared stuff with
src/distrib/utils/x_ifconfig for install media.
2009-09-16 14:59:45 +00:00
he ad8225c04b Move the addition of pfsync.c from Makefile.inc to Makefile,
so that this part doesn't get included in install media versions
of ifconfig, as per comments on source-changes@ from Izumi Tsutsui.
Also re-instate the use of ${.CURDIR} when setting up the include path.
2009-09-15 09:22:07 +00:00
he 4cf3355067 Change from using ${.CURDIR} to ${NETBSDSRCDIR} because this file
may be included by different parts of the source tree, in particular
deep down in the distrib/ tree, where ../.. isn't sufficient to "climb"
up to the top of the tree.  Fixes the build at least for our arc port.
2009-09-14 15:12:21 +00:00
degroote 2d48ac808c Import pfsync support from OpenBSD 4.2
Pfsync interface exposes change in the pf(4) over a pseudo-interface, and can
be used to synchronise different pf.

This work was part of my 2009 GSoC

No objection on tech-net@
2009-09-14 10:36:48 +00:00
dyoung 230fd8c662 This should fix 'carpdev <ifname>' or, at least, not break it more
badly than before.
2009-09-11 23:22:28 +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 fcabb0789a Describe the -N flag. 2009-08-07 20:13:12 +00:00
dyoung ae9b1bdb85 Use getnameinfo(3) instead of inet_ntoa(3) to convert IPv4 addresses
to names.
2009-08-07 19:35:55 +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
hubertf 270beabd82 Add "MAC" keyword to the corresponding example. 2009-07-29 21:47:11 +00:00
dyoung 854940045a Don't require a "vlan" argument with "-vlanif". "ifconfig vlan0
-vlanif" works as one would expect, now.
2009-07-28 18:22:33 +00:00
dyoung 183dffe7f4 Both carp.c and vlan.c expect for a keyword with a KW_T_STR-type
value to put a prop_string_t into the environment, but the keyword
parser put a prop_data_t into the environment, instead.  That broke
the -vlanif and -carpdev keywords and defied developer expectations.
Let's put a prop_string_t into the environment.

Thanks to Arnaud Degroote for reporting the problem.
2009-07-28 18:21:06 +00:00
dyoung 9044aa4f92 Use the keyword 'MAC' so that people looking for a way to change
their MAC address can find the example.
2009-07-02 18:43:47 +00:00
dyoung 53e43e1e70 Deprecate wiconfig's -r, -g, -m options. Note that equivalent
options are available in ifconfig(8).
2009-07-02 17:45:25 +00:00
pooka bd085b2b32 If RUMP_ACTION, treat close() as a rump syscall. 2009-06-02 23:41:35 +00:00
pooka 355dcf3a3b Install agr ioctl header and stop putting our hand under the sys skirt
in ifconfig.
2009-05-26 21:58:31 +00:00
pooka 162ca8ac83 Add compile mode which executes rump system calls. This is useful
when figuring out Where In The Kernel Is Carmen Sandiego's ioctl
for an ifconfig command line, since we can simply single-step into
the kernel.

Activated by "make RUMP_ACTION=1".  No changes to normal case.
2009-05-26 16:03:24 +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
dyoung ce947d8aa0 Cosmetic: add some whitespace for my ease of reading. 2009-04-21 22:13:10 +00:00
dyoung 5785e48164 There's no use casting a socket address to sockaddr_dl, only to cast it
back to sockaddr, so don't do it.
2009-04-21 21:57:14 +00:00
dyoung 5cd12bc44e 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.
2009-04-21 21:42:35 +00:00
dyoung 4590553b36 Fix indentation: change spaces to tabs. 2009-04-21 18:00:25 +00:00
lukem ef685eeea9 Enable WARNS=4 by default except for:
dump  dump_lfs  fsck_ffs  fsck_lfs  fsdb  mount_smbfs
	newfs_ext2fs  newfs_lfs  resize_lfs  setkey
2009-04-11 07:58:11 +00:00
joerg f2aa054fbc Remove physical markup. Remove incorrect keep, .Bk is not callable, but
used as such. It doesn't seem to serve any purpose at the point either.
2009-04-08 14:32:05 +00:00
plunky bb505f700b Because the IFF_NOARP flag is a negative option it needs to be negated
when being applied from the "arp" option which itself is positive.

problem demonstrated by

# ifconfig tap3 create
# ifconfig tap3
tap3: flags=8802<BROADCAST,SIMPLEX,MULTICAST> mtu 1500
	address: f2:0b:a4:7f:44:03
	media: Ethernet autoselect
# ifconfig tap3 arp
# ifconfig tap3
tap3: flags=8882<BROADCAST,NOARP,SIMPLEX,MULTICAST> mtu 1500
	address: f2:0b:a4:7f:44:03
	media: Ethernet autoselect
# ifconfig tap3 -arp
# ifconfig tap3
tap3: flags=8802<BROADCAST,SIMPLEX,MULTICAST> mtu 1500
	address: f2:0b:a4:7f:44:03
	media: Ethernet autoselect
# ifconfig tap3 destroy
#
2009-04-04 17:10:19 +00:00
reed b7b9ab25b1 Point to ifmedia(4) more. And refer to -m flag to (for media). 2009-03-27 19:33:22 +00:00
uebayasi a6533b8fed Comment out CFLAGS+=-g. 2009-02-13 16:02:05 +00:00
lukem c6144e484f fix -Wsign-compare issues 2009-01-18 00:24:29 +00:00
tsutsui 09275f2b8b Specify -fno-loop-optimize on m68000 as workaround for gcc -O1 codegen bug
mentioned in PR bin/40036 and PR toolchain/40066.
2008-11-29 15:28:49 +00:00
tsutsui da5d5a9f1c Add RCS Id. XXX why separate Makefile.inc? 2008-11-29 15:23:32 +00:00
wiz 0247fc12f6 Bump date for previous. Remove trailing whitespace.
New sentence, new line. Capitalize Ethernet.
2008-09-30 09:41:41 +00:00
dyoung 7abd58c82d Do not mention the 'ns' address family any longer, since that
support was removed quite a while ago.

Mention the 'link' address family.  Describe the 'active' keyword.
Add examples for adding and activating a link-layer address.
2008-09-29 17:28:07 +00:00
dyoung 83dfe33e66 is@ pointed out that I set the phase and range of a sockaddr_at
without subsequently doing anything with it, so commit_address()
works with an address with phase == 0.  phase == 0 is not allowed,
hence

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

Solution: copy the new sockaddr_at to a temporary input environment,
and pass that environment to commit_address().  I may as well copy
the new sockaddr_at to the output environment, while I am at it.
2008-08-01 22:44:17 +00:00
dyoung 10b425b514 Extract common code. Create subroutine paddr_prefix_size(). 2008-08-01 22:29:13 +00:00
dyoung 4668b21b50 Always initialize the union of sockaddrs. I used to initialize it
only in the AF_UNSPEC/AF_INET/AF_INET6 cases.  Maybe this will fix
the AF_APPLETALK problem that is@ reports:

random84# ifconfig nfe0 atalk 3.14
ifconfig: SIOCAIFADDR: Invalid argument
2008-08-01 18:05:56 +00:00
lukem 6543a91fea Remove the \n and tabs from the __COPYRIGHT() strings.
(Tweak some to use a consistent format.)
2008-07-20 01:20:21 +00:00
dyoung 723da104d6 Cosmetic: s/xenv/oenv/ 2008-07-15 21:27:58 +00:00
dyoung 95a02c3401 Make usage() static. 2008-07-15 21:19:24 +00:00
dyoung 3e89e7b09b Only describe flags -L and -m in the usage if they are available.
That helps me get rid of some conditional compilation (INET6) in
ifconfig.

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

Write usage information for carp(4) options.
2008-07-15 20:56:13 +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 d46fe4da98 Remove one more struct afswtch.af_getprefix() remnant. 2008-06-03 21:03:27 +00:00
dyoung 31a7bcb871 Remove remnants of struct afswtch.af_getprefix(). 2008-06-03 21:02:49 +00:00
dyoung 89ef65cc34 *Always* pass the prefix mask specified on the command line, even
on an IFF_POINTOPOINT interface.  Patch tested by John Klos and
found to fix the bug he reported on tech-net@, "Subject: Can't use
gif in -current".
2008-06-03 04:59:30 +00:00
dyoung 480fc38f3c Cosmetic: add missing /*FALLTHROUGH*/. 2008-06-02 23:19:16 +00:00
dyoung 5035ceab3b Fix kern/38775, "ifconfig inet delete fails". 2008-05-28 17:17:14 +00:00
dyoung aa10084492 Fix two bugs:
1 Let us associate a keyword with either a signed or an unsigned
  number.  Associate the '-chan' keyword with an unsigned number.
  This fixes the defect that crashed 'ifconfig wi0 -chan', reported
  by Michael van Elst.

2 Do not try to interpret names as ISO addresses unless the ISO
  address family was specified.  iso_addr(3) does not report errors,
  so it appears to interpret *everything* as an ISO address.  This
  is a stopgap fix for the defect in 'ifconfig lo0 inet6' on a
  !INET6 kernel that deletes the first IPv4 address on lo0.
  (Reported by Scott Ellis.)
2008-05-19 18:00:31 +00:00
dyoung 3ebe24aa36 Apply netmasks to !(IFF_BROADCAST|IFF_POINTOPOINT) interfaces as
well as to IFF_BROADCAST interfaces.  Fixes the bug reported by
Markus W Kilbinger,

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

results in the wrong configuration,

	stf0: flags=1<UP> mtu 1280
		inet6 2002:xxxx:76ec:1::1 prefixlen 64
2008-05-16 20:57:42 +00:00
dyoung 4a04a80d10 The key 'vlantag' activates the 'vlanif' keyword, not the key
'vlan'.  Should fix this bug reported by Pierre Pronchery,

# ifconfig vlan0 vlan 1 vlanif hme0
ifconfig: SIOCAIFADDR: Address family not supported by protocol family
2008-05-16 20:53:35 +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 3361a66d0a Per discussion at
<http://mail-index.netbsd.org/tech-net/2008/04/08/msg000371.html>,
let us add, delete, and activate link-layer addresses with ifconfig:

# ifconfig sip0 link 02:00:00:00:00:01                   [add address]
# ifconfig sip0 link 02:00:00:00:00:02                   [add address]
# ifconfig sip0 link 02:00:00:00:00:02 active            [activate address]
# ifconfig sip0 link 02:00:00:00:00:01 delete            [remove address]
2008-05-12 22:06:13 +00:00
dyoung af8202a3c2 Apply the right copyright notice. 2008-05-12 22:01:32 +00:00
dyoung 85a29f7ecc Fix link-layer address parsing. Add debug statements.
Cosmetic: fix copyright whitespace.
2008-05-12 21:54:51 +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 47bfdf8c0e Make prototype and definition of in_alias() agree: it's static. 2008-05-12 20:59:13 +00:00
dyoung b312223d4e Retire in6_addreq and in6_ridreq, which we do not use in the
commit_address() regime.
2008-05-12 20:58:16 +00:00
dyoung 3f2ce08bf8 Initialize IPv6 addresses and ifreqs with more rigor. Fixes this
bug reported by Matthias Scheler,

# ifconfig sip0 inet6 fdb4:542d:dc11:ec20::1
ifconfig: SIOCAIFADDR_IN6: Invalid argument
# ifconfig sip0 inet6 fdb4:542d:dc11:ec20::1 prefixlen 64
2008-05-12 15:35:50 +00:00
dyoung 0f6386183c setifipdst() is gone, so delete the prototype. #include nothing
(XXX).
2008-05-12 00:40:40 +00:00
dyoung 4279a83897 Add code for parsing link-layer addresses of the form xx:xx:...:xx. 2008-05-12 00:39:18 +00:00
dyoung d3c42f50ae Start to adapt the AppleTalk module to use commit_address(). 2008-05-11 23:28:40 +00:00
dyoung ed29145620 Get rid of sec2str() altogether. 2008-05-11 23:27:32 +00:00
dyoung 50a22265be Don't export in_alias(). Pass in_alias() a more useful template.
Misc. cosmetic changes.  Delete dead code.  Treat the address
preference as int16_t, since that is its real type.
2008-05-11 23:25:46 +00:00
dyoung 42c94b7768 In in6_alias(), instead of repeating the memset()/estrlcpy()/sockaddr_in6
assignment-dance, copy creq to ifr6 before each ioctl().
2008-05-11 22:30:07 +00:00
dyoung 16f748ab9d Delete unused array sin6tab[]. Delete unnecessary casts. 2008-05-11 22:18:20 +00:00
dyoung 3df1d7792b Delete dead code in sec2str(). 2008-05-11 22:16:29 +00:00
dyoung 8ae5a779c6 Retire some code that in6_commit_address() replaces. 2008-05-11 22:12:04 +00:00
dyoung 503d41a97f Let the address family modules zero initialize their own ifreqs,
instead of zeroing them in commit_address().

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

Temporarily add some debugging code to setia6eui64_impl().
2008-05-11 22:07:23 +00:00
dyoung a00439c7f3 In address, integer, string parsers, gracefully handle a missing
token.
2008-05-09 20:48:59 +00:00
dyoung 19f3f9a2f3 Repair agr(4) syntax. Should fix PR bin/38600. 2008-05-09 20:45:09 +00:00
dyoung de7ae11c56 Use the correct key. Spotted by NONAKA Kimihiro. 2008-05-09 04:46:50 +00:00
dyoung 44e2875450 Move IPv4/IPv6-specific code from commit_address() to in_commit_address()
and in6_commit_address().  Fixes the USE_INET6=no build.
2008-05-08 07:13:20 +00:00
dyoung cbb2531719 Delete #if 0'd code. 2008-05-08 07:11:03 +00:00
dyoung 43545a233c Don't use -pedantic, it stops af_atalk.c and af_iso.c from building
if INET_ONLY is #defined.
2008-05-08 07:09:18 +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 db80154181 Remove CPPFLAGS that are redundant when WARNS=4. 2008-05-07 22:07:24 +00:00