summaryrefslogtreecommitdiffstats
path: root/sbin
diff options
context:
space:
mode:
authorae <ae@FreeBSD.org>2015-11-03 10:21:53 +0000
committerae <ae@FreeBSD.org>2015-11-03 10:21:53 +0000
commit750b62ddbe83065a7addaeebf7b25c178265dc35 (patch)
treea2573899214f447b2413410ae4bf368561c93709 /sbin
parentcc94c225159ae5c3b4aff8e6744dd028dc0542db (diff)
downloadFreeBSD-src-750b62ddbe83065a7addaeebf7b25c178265dc35.zip
FreeBSD-src-750b62ddbe83065a7addaeebf7b25c178265dc35.tar.gz
Implement `ipfw internal olist` command to list named objects.
Reviewed by: melifaro Obtained from: Yandex LLC Sponsored by: Yandex LLC
Diffstat (limited to 'sbin')
-rw-r--r--sbin/ipfw/ipfw2.c41
-rw-r--r--sbin/ipfw/ipfw2.h1
2 files changed, 42 insertions, 0 deletions
diff --git a/sbin/ipfw/ipfw2.c b/sbin/ipfw/ipfw2.c
index bc8af9f..366f77f 100644
--- a/sbin/ipfw/ipfw2.c
+++ b/sbin/ipfw/ipfw2.c
@@ -4983,10 +4983,48 @@ ipfw_flush(int force)
static struct _s_x intcmds[] = {
{ "talist", TOK_TALIST },
{ "iflist", TOK_IFLIST },
+ { "olist", TOK_OLIST },
{ "vlist", TOK_VLIST },
{ NULL, 0 }
};
+static void
+ipfw_list_objects(int ac, char *av[])
+{
+ ipfw_obj_lheader req, *olh;
+ ipfw_obj_ntlv *ntlv;
+ size_t sz;
+ int i;
+
+ memset(&req, 0, sizeof(req));
+ sz = sizeof(req);
+ if (do_get3(IP_FW_DUMP_SRVOBJECTS, &req.opheader, &sz) != 0)
+ if (errno != ENOMEM)
+ return;
+
+ sz = req.size;
+ if ((olh = calloc(1, sz)) == NULL)
+ return;
+
+ olh->size = sz;
+ if (do_get3(IP_FW_DUMP_SRVOBJECTS, &olh->opheader, &sz) != 0) {
+ free(olh);
+ return;
+ }
+
+ if (olh->count > 0)
+ printf("Objects list:\n");
+ else
+ printf("There are no objects\n");
+ ntlv = (ipfw_obj_ntlv *)(olh + 1);
+ for (i = 0; i < olh->count; i++) {
+ printf(" kidx: %4d\ttype: %2d\tname: %s\n", ntlv->idx,
+ ntlv->head.type, ntlv->name);
+ ntlv++;
+ }
+ free(olh);
+}
+
void
ipfw_internal_handler(int ac, char *av[])
{
@@ -5005,6 +5043,9 @@ ipfw_internal_handler(int ac, char *av[])
case TOK_TALIST:
ipfw_list_ta(ac, av);
break;
+ case TOK_OLIST:
+ ipfw_list_objects(ac, av);
+ break;
case TOK_VLIST:
ipfw_list_values(ac, av);
break;
diff --git a/sbin/ipfw/ipfw2.h b/sbin/ipfw/ipfw2.h
index 5a08321..86f2a41 100644
--- a/sbin/ipfw/ipfw2.h
+++ b/sbin/ipfw/ipfw2.h
@@ -227,6 +227,7 @@ enum tokens {
TOK_LOCK,
TOK_UNLOCK,
TOK_VLIST,
+ TOK_OLIST,
};
/*
OpenPOWER on IntegriCloud