MFC: ipfw2.c 1.114
ipfw.8 1.209 Use an explicit argument to format table args as IP addresses.
This commit is contained in:
parent
429cad3e68
commit
91515fa1c7
@ -210,6 +210,11 @@ Do not ask for confirmation for commands that can cause problems
|
||||
if misused,
|
||||
.No i.e. Cm flush .
|
||||
If there is no tty associated with the process, this is implied.
|
||||
.It Fl i
|
||||
While listing a table (see the
|
||||
.Sx LOOKUP TABLES
|
||||
section below for more information on lookup tables), format values
|
||||
as IP addresses. By default, values are shown as integers.
|
||||
.It Fl n
|
||||
Only check syntax of the command strings, without actually passing
|
||||
them to the kernel.
|
||||
|
@ -62,6 +62,7 @@
|
||||
#include <arpa/inet.h>
|
||||
|
||||
int
|
||||
do_value_as_ip, /* show table value as IP */
|
||||
do_resolv, /* Would try to resolve all */
|
||||
do_time, /* Show time stamps */
|
||||
do_quiet, /* Be quiet in add and flush */
|
||||
@ -5024,22 +5025,20 @@ table_handler(int ac, char *av[])
|
||||
if (do_cmd(IP_FW_TABLE_LIST, tbl, (uintptr_t)&l) < 0)
|
||||
err(EX_OSERR, "getsockopt(IP_FW_TABLE_LIST)");
|
||||
for (a = 0; a < tbl->cnt; a++) {
|
||||
/* Heuristic to print it the right way */
|
||||
/* values < 64k are printed as numbers */
|
||||
unsigned int tval;
|
||||
tval = tbl->ent[a].value;
|
||||
if (tval > 0xffff) {
|
||||
if (do_value_as_ip) {
|
||||
char tbuf[128];
|
||||
strncpy(tbuf, inet_ntoa(*(struct in_addr *)
|
||||
&tbl->ent[a].addr), 127);
|
||||
/* inet_ntoa expects host order */
|
||||
/* inet_ntoa expects network order */
|
||||
tval = htonl(tval);
|
||||
printf("%s/%u %s\n", tbuf, tbl->ent[a].masklen,
|
||||
inet_ntoa(*(struct in_addr *)&tval));
|
||||
} else {
|
||||
printf("%s/%u %u\n",
|
||||
inet_ntoa(*(struct in_addr *)&tbl->ent[a].addr),
|
||||
tbl->ent[a].masklen, tbl->ent[a].value);
|
||||
tbl->ent[a].masklen, tval);
|
||||
}
|
||||
}
|
||||
} else
|
||||
@ -5148,7 +5147,7 @@ ipfw_main(int oldac, char **oldav)
|
||||
save_av = av;
|
||||
|
||||
optind = optreset = 0;
|
||||
while ((ch = getopt(ac, av, "abcdefhnNqs:STtv")) != -1)
|
||||
while ((ch = getopt(ac, av, "abcdefhinNqs:STtv")) != -1)
|
||||
switch (ch) {
|
||||
case 'a':
|
||||
do_acct = 1;
|
||||
@ -5180,6 +5179,10 @@ ipfw_main(int oldac, char **oldav)
|
||||
help();
|
||||
break; /* NOTREACHED */
|
||||
|
||||
case 'i':
|
||||
do_value_as_ip = 1;
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
test_only = 1;
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user