+ style (KNF).
. don't cast NULL
. white space clean up
+ use consistent format for error messages.
+ plug memory leaks and avoid malloc(0).
+ verbose message should display even when routing table is empty
(flushroutes).
family is unset. Either the destination or interface address socket address
family value is used. This change prevents the following sort of output:
RTM_NEWADDR: address being added to iface: len 60, metric 0, flags:<UP>
sockaddrs: <NETMASK,IFA,BRD>
(0) 00.00.ff.00.00 127.0.0.1 127.0.0.1
With this change the last line becomes:
255.0.0.0 127.0.0.1 127.0.0.1
Also make sure that when using a generated inet netmask the address family
is set. With this change a generated netmask will print appropriately
when using the verbose (-v) option.
like the following work as expected.
#!/bin/sh
if ! route -sn get default >/dev/null 2>&1; then
echo default gateway not set
exit 1
fi
echo default gateway set
Handle routing socket write(2) errors when they occur. This produces
better diagnostics by allowing for handling of the special route errno
values ESRCH, EBUSY, and ENOBUFS even with the quiet (-q) option or
when doing a get command.
routing socket, e.g. running route flush as non-root.
* When quiet (-q) don't append error string to a non-existent
diagnostic output (stdout). The error diagnostic is still written
to stderr. [from FreeBSD]
* Use warn(3) in place of perror(3).
netmask value of 0xffffffff (INADDR_NONE). Fix by using inet_aton(3).
Note it was possible to specify the same mask as the dotted quad
255.255.255.255 because of a later call to gethostbyname(3).
[From FreeBSD]
from the default CIDR (host/mask) interpretation. As discussed on
tech-net.
* Use errx() in place of fprintf() and exit(). Make the error message
formats consistent.
and sent in by Greg Hudson as seen in PR misc/3227. Basically what it
does is adds a flushall option which deletes all but localhost routes.
This is done by andoring in a flag called doall (1 means do all routes
including gateway, 0 means do a regular flush). I have seen some
platforms that do this. I tested it out on ipv4 only, it works as
advertised. Commit was approved by christos@.
muck up the routing tables. The patch was submitted by Quentin Garnier
<netbsd@quatriemek.com> and tweaked a little after it was reviewed
by Christos Zoulas <christos@netbsd.org>. Final change/commit approved
by Christos.