Lines Matching refs:oh

48 static void table_modify_record(ipfw_obj_header *oh, int ac, char *av[],
50 static int table_flush(ipfw_obj_header *oh);
51 static int table_destroy(ipfw_obj_header *oh);
52 static int table_do_create(ipfw_obj_header *oh, ipfw_xtable_info *i);
53 static int table_do_modify(ipfw_obj_header *oh, ipfw_xtable_info *i);
54 static int table_do_swap(ipfw_obj_header *oh, char *second);
55 static void table_create(ipfw_obj_header *oh, int ac, char *av[]);
56 static void table_modify(ipfw_obj_header *oh, int ac, char *av[]);
57 static void table_lookup(ipfw_obj_header *oh, int ac, char *av[]);
58 static void table_lock(ipfw_obj_header *oh, int lock);
59 static int table_swap(ipfw_obj_header *oh, char *second);
60 static int table_get_info(ipfw_obj_header *oh, ipfw_xtable_info *i);
67 static void table_show_list(ipfw_obj_header *oh, int need_header);
70 static void tentry_fill_key(ipfw_obj_header *oh, ipfw_obj_tentry *tent,
72 static void tentry_fill_value(ipfw_obj_header *oh, ipfw_obj_tentry *tent,
165 ipfw_obj_header oh; in ipfw_table_handler() local
170 memset(&oh, 0, sizeof(oh)); in ipfw_table_handler()
182 table_fill_ntlv(&oh.ntlv, *av, set, 1); in ipfw_table_handler()
183 oh.idx = 1; in ipfw_table_handler()
226 table_modify_record(&oh, ac, av, do_add, g_co.do_quiet, in ipfw_table_handler()
231 table_create(&oh, ac, av); in ipfw_table_handler()
235 table_modify(&oh, ac, av); in ipfw_table_handler()
239 if (table_destroy(&oh) == 0) in ipfw_table_handler()
248 error = tables_foreach(table_destroy_one, &oh, 1); in ipfw_table_handler()
256 if ((error = table_flush(&oh)) == 0) in ipfw_table_handler()
266 error = tables_foreach(table_flush_one, &oh, 1); in ipfw_table_handler()
275 table_swap(&oh, *av); in ipfw_table_handler()
279 table_lock(&oh, (tcmd == TOK_LOCK)); in ipfw_table_handler()
285 if ((error = table_get_info(&oh, &i)) != 0) in ipfw_table_handler()
297 if ((error = table_get_info(&oh, &i)) != 0) in ipfw_table_handler()
308 table_lookup(&oh, ac, av); in ipfw_table_handler()
326 table_fill_objheader(ipfw_obj_header *oh, ipfw_xtable_info *i) in table_fill_objheader() argument
329 oh->idx = 1; in table_fill_objheader()
330 table_fill_ntlv(&oh->ntlv, i->tablename, i->set, 1); in table_fill_objheader()
406 table_create(ipfw_obj_header *oh, int ac, char *av[]) in table_create() argument
486 error = table_do_create(oh, &xi); in table_create()
495 if (table_get_info(oh, &xie) != 0) in table_create()
506 if (orflush != 0 && table_flush(oh) != 0) in table_create()
518 table_do_create(ipfw_obj_header *oh, ipfw_xtable_info *i) in table_do_create() argument
523 memcpy(tbuf, oh, sizeof(*oh)); in table_do_create()
524 memcpy(tbuf + sizeof(*oh), i, sizeof(*i)); in table_do_create()
525 oh = (ipfw_obj_header *)tbuf; in table_do_create()
527 error = do_set3(IP_FW_TABLE_XCREATE, &oh->opheader, sizeof(tbuf)); in table_do_create()
538 table_modify(ipfw_obj_header *oh, int ac, char *av[]) in table_modify() argument
561 if (table_do_modify(oh, &xi) != 0) in table_modify()
573 table_do_modify(ipfw_obj_header *oh, ipfw_xtable_info *i) in table_do_modify() argument
578 memcpy(tbuf, oh, sizeof(*oh)); in table_do_modify()
579 memcpy(tbuf + sizeof(*oh), i, sizeof(*i)); in table_do_modify()
580 oh = (ipfw_obj_header *)tbuf; in table_do_modify()
582 error = do_set3(IP_FW_TABLE_XMODIFY, &oh->opheader, sizeof(tbuf)); in table_do_modify()
591 table_lock(ipfw_obj_header *oh, int lock) in table_lock() argument
600 if (table_do_modify(oh, &xi) != 0) in table_lock()
609 table_destroy(ipfw_obj_header *oh) in table_destroy() argument
612 if (do_set3(IP_FW_TABLE_XDESTROY, &oh->opheader, sizeof(*oh)) != 0) in table_destroy()
621 ipfw_obj_header *oh; in table_destroy_one() local
623 oh = (ipfw_obj_header *)arg; in table_destroy_one()
624 table_fill_ntlv(&oh->ntlv, i->tablename, i->set, 1); in table_destroy_one()
625 if (table_destroy(oh) != 0) { in table_destroy_one()
639 table_flush(ipfw_obj_header *oh) in table_flush() argument
642 if (do_set3(IP_FW_TABLE_XFLUSH, &oh->opheader, sizeof(*oh)) != 0) in table_flush()
649 table_do_swap(ipfw_obj_header *oh, char *second) in table_do_swap() argument
655 memcpy(tbuf, oh, sizeof(*oh)); in table_do_swap()
656 oh = (ipfw_obj_header *)tbuf; in table_do_swap()
657 table_fill_ntlv((ipfw_obj_ntlv *)(oh + 1), second, oh->ntlv.set, 1); in table_do_swap()
659 error = do_set3(IP_FW_TABLE_XSWAP, &oh->opheader, sizeof(tbuf)); in table_do_swap()
668 table_swap(ipfw_obj_header *oh, char *second) in table_swap() argument
674 if (table_do_swap(oh, second) == 0) in table_swap()
694 table_get_info(ipfw_obj_header *oh, ipfw_xtable_info *i) in table_get_info() argument
701 memcpy(tbuf, oh, sizeof(*oh)); in table_get_info()
702 oh = (ipfw_obj_header *)tbuf; in table_get_info()
704 if (do_get3(IP_FW_TABLE_XINFO, &oh->opheader, &sz) != 0) in table_get_info()
710 *i = *(ipfw_xtable_info *)(oh + 1); in table_get_info()
860 ipfw_obj_header *oh = NULL; in table_show_one() local
866 if ((error = table_do_get_list(i, &oh)) != 0) { in table_show_one()
871 table_show_list(oh, is_all); in table_show_one()
873 free(oh); in table_show_one()
880 ipfw_obj_header *oh; in table_flush_one() local
882 oh = (ipfw_obj_header *)arg; in table_flush_one()
884 table_fill_ntlv(&oh->ntlv, i->tablename, i->set, 1); in table_flush_one()
886 return (table_flush(oh)); in table_flush_one()
890 table_do_modify_record(int cmd, ipfw_obj_header *oh, in table_do_modify_record() argument
896 char xbuf[sizeof(*oh) + sizeof(ipfw_obj_ctlv) + sizeof(*tent)]; in table_do_modify_record()
905 if ((pbuf = calloc(1, sizeof(*oh) + sz)) == NULL) in table_do_modify_record()
909 memcpy(pbuf, oh, sizeof(*oh)); in table_do_modify_record()
910 oh = (ipfw_obj_header *)pbuf; in table_do_modify_record()
911 oh->opheader.version = 1; in table_do_modify_record()
913 ctlv = (ipfw_obj_ctlv *)(oh + 1); in table_do_modify_record()
924 tent->idx = oh->idx; in table_do_modify_record()
927 sz += sizeof(*oh); in table_do_modify_record()
928 error = do_get3(cmd, &oh->opheader, &sz); in table_do_modify_record()
942 table_modify_record(ipfw_obj_header *oh, int ac, char *av[], int add, in table_modify_record() argument
986 tentry_fill_key(oh, ptent, *av, add, &type, &vmask, &xi); in table_modify_record()
994 strlcpy(xi.tablename, oh->ntlv.name, in table_modify_record()
1000 table_do_create(oh, &xi); in table_modify_record()
1003 oh->ntlv.type = type; in table_modify_record()
1007 tentry_fill_value(oh, ptent, *av, type, vmask); in table_modify_record()
1018 error = table_do_modify_record(cmd, oh, tent_buf, count, atomic); in table_modify_record()
1113 table_do_lookup(ipfw_obj_header *oh, char *key, ipfw_xtable_info *xi, in table_do_lookup() argument
1122 memcpy(xbuf, oh, sizeof(*oh)); in table_do_lookup()
1123 oh = (ipfw_obj_header *)xbuf; in table_do_lookup()
1124 tent = (ipfw_obj_tentry *)(oh + 1); in table_do_lookup()
1130 tentry_fill_key(oh, tent, key, 0, &type, &vmask, xi); in table_do_lookup()
1131 oh->ntlv.type = type; in table_do_lookup()
1134 if (do_get3(IP_FW_TABLE_XFIND, &oh->opheader, &sz) != 0) in table_do_lookup()
1146 table_lookup(ipfw_obj_header *oh, int ac, char *av[]) in table_lookup() argument
1159 error = table_do_lookup(oh, key, &xi, &xtent); in table_lookup()
1165 errx(EX_UNAVAILABLE, "Table %s not found", oh->ntlv.name); in table_lookup()
1170 "\"lookup\" method", oh->ntlv.name); in table_lookup()
1429 tentry_fill_key(ipfw_obj_header *oh, ipfw_obj_tentry *tent, char *key, in tentry_fill_key() argument
1441 error = table_get_info(oh, xi); in tentry_fill_key()
1467 oh->ntlv.name); in tentry_fill_key()
1470 oh->ntlv.name); in tentry_fill_key()
1478 "key '%s' type", oh->ntlv.name, key); in tentry_fill_key()
1506 tentry_fill_value(ipfw_obj_header *oh __unused, ipfw_obj_tentry *tent, in tentry_fill_value()
1729 ipfw_obj_header *oh; in table_do_get_list() local
1734 oh = NULL; in table_do_get_list()
1738 if (oh != NULL) in table_do_get_list()
1739 free(oh); in table_do_get_list()
1740 if ((oh = calloc(1, sz)) == NULL) in table_do_get_list()
1742 table_fill_objheader(oh, i); in table_do_get_list()
1743 oh->opheader.version = 1; /* Current version */ in table_do_get_list()
1744 if (do_get3(IP_FW_TABLE_XLIST, &oh->opheader, &sz) == 0) { in table_do_get_list()
1745 *poh = oh; in table_do_get_list()
1752 free(oh); in table_do_get_list()
1761 table_show_list(ipfw_obj_header *oh, int need_header) in table_show_list() argument
1767 i = (ipfw_xtable_info *)(oh + 1); in table_show_list()