summaryrefslogtreecommitdiffstats
path: root/sbin/ipfw/tables.c
diff options
context:
space:
mode:
authormelifaro <melifaro@FreeBSD.org>2014-06-15 13:40:27 +0000
committermelifaro <melifaro@FreeBSD.org>2014-06-15 13:40:27 +0000
commitb06860b3e2dfa15bb7123a320ebcc231cbd33939 (patch)
treea981eebcb35692226ba2d9f655bbbba4e67f1ccd /sbin/ipfw/tables.c
parentfe9646e6ff1b3a57a7e6178adbd24217fe42d8a1 (diff)
downloadFreeBSD-src-b06860b3e2dfa15bb7123a320ebcc231cbd33939.zip
FreeBSD-src-b06860b3e2dfa15bb7123a320ebcc231cbd33939.tar.gz
Simplify opcode handling.
* Use one u16 from op3 header to implement opcode versioning. * IP_FW_TABLE_XLIST has now 2 handlers, for ver.0 (old) and ver.1 (current). * Every getsockopt request is now handled in ip_fw_table.c * Rename new opcodes: IP_FW_OBJ_DEL -> IP_FW_TABLE_XDESTROY IP_FW_OBJ_LISTSIZE -> IP_FW_TABLES_XGETSIZE IP_FW_OBJ_LIST -> IP_FW_TABLES_XLIST IP_FW_OBJ_INFO -> IP_FW_TABLE_XINFO IP_FW_OBJ_INFO -> IP_FW_TABLE_XFLUSH * Add some docs about using given opcodes. * Group some legacy opcode/handlers.
Diffstat (limited to 'sbin/ipfw/tables.c')
-rw-r--r--sbin/ipfw/tables.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/sbin/ipfw/tables.c b/sbin/ipfw/tables.c
index 0d16bec7..491ac86 100644
--- a/sbin/ipfw/tables.c
+++ b/sbin/ipfw/tables.c
@@ -317,7 +317,6 @@ table_fill_objheader(ipfw_obj_header *oh, ipfw_xtable_info *i)
oh->set = i->set;
oh->idx = 1;
- oh->objtype = IPFW_OBJTYPE_TABLE;
table_fill_ntlv(&oh->ntlv, i->tablename, 1);
}
@@ -332,9 +331,8 @@ table_destroy(char *name, uint32_t set)
memset(&oh, 0, sizeof(oh));
oh.idx = 1;
- oh.objtype = IPFW_OBJTYPE_TABLE;
table_fill_ntlv(&oh.ntlv, name, 1);
- if (do_set3(IP_FW_OBJ_DEL, &oh.opheader, sizeof(oh)) != 0)
+ if (do_set3(IP_FW_TABLE_XDESTROY, &oh.opheader, sizeof(oh)) != 0)
return (-1);
return (0);
@@ -351,9 +349,8 @@ table_flush(char *name, uint32_t set)
memset(&oh, 0, sizeof(oh));
oh.idx = 1;
- oh.objtype = IPFW_OBJTYPE_TABLE;
table_fill_ntlv(&oh.ntlv, name, 1);
- if (do_set3(IP_FW_OBJ_FLUSH, &oh.opheader, sizeof(oh)) != 0)
+ if (do_set3(IP_FW_TABLE_XFLUSH, &oh.opheader, sizeof(oh)) != 0)
return (-1);
return (0);
@@ -380,7 +377,7 @@ table_get_info(char *name, uint32_t set, ipfw_xtable_info *i)
table_fill_objheader(oh, i);
- if (do_get3(IP_FW_OBJ_INFO, &oh->opheader, &sz) < 0)
+ if (do_get3(IP_FW_TABLE_XINFO, &oh->opheader, &sz) < 0)
return (-1);
if (sz < sizeof(tbuf))
@@ -486,17 +483,15 @@ tables_foreach(table_cb_t *f, void *arg, int sort)
memset(&req, 0, sizeof(req));
sz = sizeof(req);
- req.objtype = IPFW_OBJTYPE_TABLE;
- if ((error = do_get3(IP_FW_OBJ_LISTSIZE, &req.opheader, &sz)) != 0)
+ if ((error = do_get3(IP_FW_TABLES_XGETSIZE, &req.opheader, &sz)) != 0)
return (errno);
sz = req.size;
if ((olh = calloc(1, sz)) == NULL)
return (ENOMEM);
- olh->objtype = IPFW_OBJTYPE_TABLE;
olh->size = sz;
- if ((error = do_get3(IP_FW_OBJ_LIST, &olh->opheader, &sz)) != 0) {
+ if ((error = do_get3(IP_FW_TABLES_XLIST, &olh->opheader, &sz)) != 0) {
free(olh);
return (errno);
}
@@ -517,7 +512,8 @@ tables_foreach(table_cb_t *f, void *arg, int sort)
/*
* Retrieves all entries for given table @i in
- * eXtended format, returning pointer vi @ooh.
+ * eXtended format. Assumes buffer of size
+ * @i->size has already been allocated by caller.
*
* Returns 0 on success.
*/
@@ -530,7 +526,9 @@ table_get_list(ipfw_xtable_info *i, ipfw_obj_header *oh)
table_fill_objheader(oh, i);
sz = i->size;
- if ((error = do_get3(IP_FW_OBJ_DUMP, &oh->opheader, &sz)) != 0)
+ oh->opheader.version = 1; /* Current version */
+
+ if ((error = do_get3(IP_FW_TABLE_XLIST, &oh->opheader, &sz)) != 0)
return (errno);
return (0);
OpenPOWER on IntegriCloud