Lines Matching full:oh

41 static void table_modify_record(ipfw_obj_header *oh, int ac, char *av[],
43 static int table_flush(ipfw_obj_header *oh);
44 static int table_destroy(ipfw_obj_header *oh);
45 static int table_do_create(ipfw_obj_header *oh, ipfw_xtable_info *i);
46 static int table_do_modify(ipfw_obj_header *oh, ipfw_xtable_info *i);
47 static int table_do_swap(ipfw_obj_header *oh, char *second);
48 static void table_create(ipfw_obj_header *oh, int ac, char *av[]);
49 static void table_modify(ipfw_obj_header *oh, int ac, char *av[]);
50 static void table_lookup(ipfw_obj_header *oh, int ac, char *av[]);
51 static void table_lock(ipfw_obj_header *oh, int lock);
52 static int table_swap(ipfw_obj_header *oh, char *second);
53 static int table_get_info(ipfw_obj_header *oh, ipfw_xtable_info *i);
60 static void table_show_list(ipfw_obj_header *oh, int need_header);
63 static void tentry_fill_key(ipfw_obj_header *oh, ipfw_obj_tentry *tent,
65 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
493 error = table_do_create(oh, &xi); in table_create()
502 if (table_get_info(oh, &xie) != 0) in table_create()
513 if (orflush != 0 && table_flush(oh) != 0) in table_create()
525 table_do_create(ipfw_obj_header *oh, ipfw_xtable_info *i) in table_do_create() argument
530 memcpy(tbuf, oh, sizeof(*oh)); in table_do_create()
531 memcpy(tbuf + sizeof(*oh), i, sizeof(*i)); in table_do_create()
532 oh = (ipfw_obj_header *)tbuf; in table_do_create()
534 error = do_set3(IP_FW_TABLE_XCREATE, &oh->opheader, sizeof(tbuf)); in table_do_create()
545 table_modify(ipfw_obj_header *oh, int ac, char *av[]) in table_modify() argument
568 if (table_do_modify(oh, &xi) != 0) in table_modify()
580 table_do_modify(ipfw_obj_header *oh, ipfw_xtable_info *i) in table_do_modify() argument
585 memcpy(tbuf, oh, sizeof(*oh)); in table_do_modify()
586 memcpy(tbuf + sizeof(*oh), i, sizeof(*i)); in table_do_modify()
587 oh = (ipfw_obj_header *)tbuf; in table_do_modify()
589 error = do_set3(IP_FW_TABLE_XMODIFY, &oh->opheader, sizeof(tbuf)); in table_do_modify()
598 table_lock(ipfw_obj_header *oh, int lock) in table_lock() argument
607 if (table_do_modify(oh, &xi) != 0) in table_lock()
612 * Destroys given table specified by @oh->ntlv.
616 table_destroy(ipfw_obj_header *oh) in table_destroy() argument
619 if (do_set3(IP_FW_TABLE_XDESTROY, &oh->opheader, sizeof(*oh)) != 0) in table_destroy()
628 ipfw_obj_header *oh; in table_destroy_one() local
630 oh = (ipfw_obj_header *)arg; in table_destroy_one()
631 table_fill_ntlv(&oh->ntlv, i->tablename, i->set, 1); in table_destroy_one()
632 if (table_destroy(oh) != 0) { in table_destroy_one()
642 * Flushes given table specified by @oh->ntlv.
646 table_flush(ipfw_obj_header *oh) in table_flush() argument
649 if (do_set3(IP_FW_TABLE_XFLUSH, &oh->opheader, sizeof(*oh)) != 0) in table_flush()
656 table_do_swap(ipfw_obj_header *oh, char *second) in table_do_swap() argument
662 memcpy(tbuf, oh, sizeof(*oh)); in table_do_swap()
663 oh = (ipfw_obj_header *)tbuf; in table_do_swap()
664 table_fill_ntlv((ipfw_obj_ntlv *)(oh + 1), second, oh->ntlv.set, 1); in table_do_swap()
666 error = do_set3(IP_FW_TABLE_XSWAP, &oh->opheader, sizeof(tbuf)); in table_do_swap()
675 table_swap(ipfw_obj_header *oh, char *second) in table_swap() argument
681 if (table_do_swap(oh, second) == 0) in table_swap()
696 * Retrieves table in given table specified by @oh->ntlv.
701 table_get_info(ipfw_obj_header *oh, ipfw_xtable_info *i) in table_get_info() argument
708 memcpy(tbuf, oh, sizeof(*oh)); in table_get_info()
709 oh = (ipfw_obj_header *)tbuf; in table_get_info()
711 if (do_get3(IP_FW_TABLE_XINFO, &oh->opheader, &sz) != 0) in table_get_info()
717 *i = *(ipfw_xtable_info *)(oh + 1); in table_get_info()
867 ipfw_obj_header *oh = NULL; in table_show_one() local
873 if ((error = table_do_get_list(i, &oh)) != 0) { in table_show_one()
878 table_show_list(oh, is_all); in table_show_one()
880 free(oh); in table_show_one()
887 ipfw_obj_header *oh; in table_flush_one() local
889 oh = (ipfw_obj_header *)arg; in table_flush_one()
891 table_fill_ntlv(&oh->ntlv, i->tablename, i->set, 1); in table_flush_one()
893 return (table_flush(oh)); in table_flush_one()
897 table_do_modify_record(int cmd, ipfw_obj_header *oh, in table_do_modify_record() argument
903 char xbuf[sizeof(*oh) + sizeof(ipfw_obj_ctlv) + sizeof(*tent)]; in table_do_modify_record()
912 if ((pbuf = calloc(1, sizeof(*oh) + sz)) == NULL) in table_do_modify_record()
916 memcpy(pbuf, oh, sizeof(*oh)); in table_do_modify_record()
917 oh = (ipfw_obj_header *)pbuf; in table_do_modify_record()
918 oh->opheader.version = 1; /* Current version */ in table_do_modify_record()
920 ctlv = (ipfw_obj_ctlv *)(oh + 1); in table_do_modify_record()
931 tent->idx = oh->idx; in table_do_modify_record()
934 sz += sizeof(*oh); in table_do_modify_record()
935 error = do_get3(cmd, &oh->opheader, &sz); in table_do_modify_record()
949 table_modify_record(ipfw_obj_header *oh, int ac, char *av[], int add, in table_modify_record() argument
993 tentry_fill_key(oh, ptent, *av, add, &type, &vmask, &xi); in table_modify_record()
1001 strlcpy(xi.tablename, oh->ntlv.name, in table_modify_record()
1007 table_do_create(oh, &xi); in table_modify_record()
1010 oh->ntlv.type = type; in table_modify_record()
1014 tentry_fill_value(oh, ptent, *av, type, vmask); in table_modify_record()
1025 error = table_do_modify_record(cmd, oh, tent_buf, count, atomic); in table_modify_record()
1118 table_do_lookup(ipfw_obj_header *oh, char *key, ipfw_xtable_info *xi, in table_do_lookup() argument
1127 memcpy(xbuf, oh, sizeof(*oh)); in table_do_lookup()
1128 oh = (ipfw_obj_header *)xbuf; in table_do_lookup()
1129 tent = (ipfw_obj_tentry *)(oh + 1); in table_do_lookup()
1135 tentry_fill_key(oh, tent, key, 0, &type, &vmask, xi); in table_do_lookup()
1136 oh->ntlv.type = type; in table_do_lookup()
1139 if (do_get3(IP_FW_TABLE_XFIND, &oh->opheader, &sz) != 0) in table_do_lookup()
1151 table_lookup(ipfw_obj_header *oh, int ac, char *av[]) in table_lookup() argument
1164 error = table_do_lookup(oh, key, &xi, &xtent); in table_lookup()
1170 errx(EX_UNAVAILABLE, "Table %s not found", oh->ntlv.name); in table_lookup()
1175 "\"lookup\" method", oh->ntlv.name); in table_lookup()
1452 tentry_fill_key(ipfw_obj_header *oh, ipfw_obj_tentry *tent, char *key, in tentry_fill_key() argument
1464 error = table_get_info(oh, xi); in tentry_fill_key()
1490 oh->ntlv.name); in tentry_fill_key()
1493 oh->ntlv.name); in tentry_fill_key()
1501 "key '%s' type", oh->ntlv.name, key); in tentry_fill_key()
1529 tentry_fill_value(ipfw_obj_header *oh __unused, ipfw_obj_tentry *tent, in tentry_fill_value()
1755 ipfw_obj_header *oh; in table_do_get_list() local
1760 oh = NULL; in table_do_get_list()
1764 if (oh != NULL) in table_do_get_list()
1765 free(oh); in table_do_get_list()
1766 if ((oh = calloc(1, sz)) == NULL) in table_do_get_list()
1768 table_fill_objheader(oh, i); in table_do_get_list()
1769 oh->opheader.version = 1; /* Current version */ in table_do_get_list()
1770 if (do_get3(IP_FW_TABLE_XLIST, &oh->opheader, &sz) == 0) { in table_do_get_list()
1771 *poh = oh; in table_do_get_list()
1778 free(oh); in table_do_get_list()
1784 * Shows all entries from @oh in human-readable format
1787 table_show_list(ipfw_obj_header *oh, int need_header) in table_show_list() argument
1793 i = (ipfw_xtable_info *)(oh + 1); in table_show_list()