summaryrefslogtreecommitdiffstats
path: root/sbin/ipfw
diff options
context:
space:
mode:
authorae <ae@FreeBSD.org>2016-05-17 11:22:08 +0000
committerae <ae@FreeBSD.org>2016-05-17 11:22:08 +0000
commitee940751c30a0127c0a5dc187754fddaae8ca982 (patch)
treec02f6deb843b11a20079f7ac319b36a2e1b376c2 /sbin/ipfw
parent3397aa77757ffdca348184a150cef5b85eeae641 (diff)
downloadFreeBSD-src-ee940751c30a0127c0a5dc187754fddaae8ca982.zip
FreeBSD-src-ee940751c30a0127c0a5dc187754fddaae8ca982.tar.gz
Make `ipfw internal olist` output more user friendly.
Print object type as string for known types. Obtained from: Yandex LLC Sponsored by: Yandex LLC
Diffstat (limited to 'sbin/ipfw')
-rw-r--r--sbin/ipfw/ipfw2.c37
1 files changed, 35 insertions, 2 deletions
diff --git a/sbin/ipfw/ipfw2.c b/sbin/ipfw/ipfw2.c
index 42d321d..b2fbf35 100644
--- a/sbin/ipfw/ipfw2.c
+++ b/sbin/ipfw/ipfw2.c
@@ -5131,11 +5131,35 @@ static struct _s_x intcmds[] = {
{ NULL, 0 }
};
+static struct _s_x otypes[] = {
+ { "EACTION", IPFW_TLV_EACTION },
+ { NULL, 0 }
+};
+
+static const char*
+lookup_eaction_name(ipfw_obj_ntlv *ntlv, int cnt, uint16_t type)
+{
+ const char *name;
+ int i;
+
+ name = NULL;
+ for (i = 0; i < cnt; i++) {
+ if (ntlv[i].head.type != IPFW_TLV_EACTION)
+ continue;
+ if (IPFW_TLV_EACTION_NAME(ntlv[i].idx) != type)
+ continue;
+ name = ntlv[i].name;
+ break;
+ }
+ return (name);
+}
+
static void
ipfw_list_objects(int ac, char *av[])
{
ipfw_obj_lheader req, *olh;
ipfw_obj_ntlv *ntlv;
+ const char *name;
size_t sz;
int i;
@@ -5161,8 +5185,17 @@ ipfw_list_objects(int ac, char *av[])
printf("There are no objects\n");
ntlv = (ipfw_obj_ntlv *)(olh + 1);
for (i = 0; i < olh->count; i++) {
- printf(" kidx: %4d\ttype: %6d\tname: %s\n", ntlv->idx,
- ntlv->head.type, ntlv->name);
+ name = match_value(otypes, ntlv->head.type);
+ if (name == NULL)
+ name = lookup_eaction_name(
+ (ipfw_obj_ntlv *)(olh + 1), olh->count,
+ ntlv->head.type);
+ if (name == NULL)
+ printf(" kidx: %4d\ttype: %10d\tname: %s\n",
+ ntlv->idx, ntlv->head.type, ntlv->name);
+ else
+ printf(" kidx: %4d\ttype: %10s\tname: %s\n",
+ ntlv->idx, name, ntlv->name);
ntlv++;
}
free(olh);
OpenPOWER on IntegriCloud