Lines Matching refs:oh

42 static void table_modify_record(ipfw_obj_header *oh, int ac, char *av[],
44 static int table_flush(ipfw_obj_header *oh);
45 static int table_destroy(ipfw_obj_header *oh);
46 static int table_do_create(ipfw_obj_header *oh, ipfw_xtable_info *i);
47 static int table_do_modify(ipfw_obj_header *oh, ipfw_xtable_info *i);
48 static int table_do_swap(ipfw_obj_header *oh, char *second);
49 static void table_create(ipfw_obj_header *oh, int ac, char *av[]);
50 static void table_modify(ipfw_obj_header *oh, int ac, char *av[]);
51 static void table_lookup(ipfw_obj_header *oh, int ac, char *av[]);
52 static void table_lock(ipfw_obj_header *oh, int lock);
53 static int table_swap(ipfw_obj_header *oh, char *second);
54 static int table_get_info(ipfw_obj_header *oh, ipfw_xtable_info *i);
61 static void table_show_list(ipfw_obj_header *oh, int need_header);
64 static void tentry_fill_key(ipfw_obj_header *oh, ipfw_obj_tentry *tent,
66 static void tentry_fill_value(ipfw_obj_header *oh, ipfw_obj_tentry *tent,
164 ipfw_obj_header oh;
169 memset(&oh, 0, sizeof(oh));
181 table_fill_ntlv(&oh.ntlv, *av, set, 1);
182 oh.idx = 1;
225 table_modify_record(&oh, ac, av, do_add, co.do_quiet,
230 table_create(&oh, ac, av);
234 table_modify(&oh, ac, av);
238 if (table_destroy(&oh) == 0)
247 error = tables_foreach(table_destroy_one, &oh, 1);
255 if ((error = table_flush(&oh)) == 0)
265 error = tables_foreach(table_flush_one, &oh, 1);
274 table_swap(&oh, *av);
278 table_lock(&oh, (tcmd == TOK_LOCK));
284 if ((error = table_get_info(&oh, &i)) != 0)
297 if ((error = table_get_info(&oh, &i)) != 0)
308 table_lookup(&oh, ac, av);
326 table_fill_objheader(ipfw_obj_header *oh, ipfw_xtable_info *i)
329 oh->idx = 1;
330 table_fill_ntlv(&oh->ntlv, i->tablename, i->set, 1);
406 table_create(ipfw_obj_header *oh, int ac, char *av[])
493 error = table_do_create(oh, &xi);
502 if (table_get_info(oh, &xie) != 0)
513 if (orflush != 0 && table_flush(oh) != 0)
525 table_do_create(ipfw_obj_header *oh, ipfw_xtable_info *i)
530 memcpy(tbuf, oh, sizeof(*oh));
531 memcpy(tbuf + sizeof(*oh), i, sizeof(*i));
532 oh = (ipfw_obj_header *)tbuf;
534 error = do_set3(IP_FW_TABLE_XCREATE, &oh->opheader, sizeof(tbuf));
545 table_modify(ipfw_obj_header *oh, int ac, char *av[])
568 if (table_do_modify(oh, &xi) != 0)
580 table_do_modify(ipfw_obj_header *oh, ipfw_xtable_info *i)
585 memcpy(tbuf, oh, sizeof(*oh));
586 memcpy(tbuf + sizeof(*oh), i, sizeof(*i));
587 oh = (ipfw_obj_header *)tbuf;
589 error = do_set3(IP_FW_TABLE_XMODIFY, &oh->opheader, sizeof(tbuf));
598 table_lock(ipfw_obj_header *oh, int lock)
607 if (table_do_modify(oh, &xi) != 0)
612 * Destroys given table specified by @oh->ntlv.
616 table_destroy(ipfw_obj_header *oh)
619 if (do_set3(IP_FW_TABLE_XDESTROY, &oh->opheader, sizeof(*oh)) != 0)
628 ipfw_obj_header *oh;
630 oh = (ipfw_obj_header *)arg;
631 table_fill_ntlv(&oh->ntlv, i->tablename, i->set, 1);
632 if (table_destroy(oh) != 0) {
642 * Flushes given table specified by @oh->ntlv.
646 table_flush(ipfw_obj_header *oh)
649 if (do_set3(IP_FW_TABLE_XFLUSH, &oh->opheader, sizeof(*oh)) != 0)
656 table_do_swap(ipfw_obj_header *oh, char *second)
662 memcpy(tbuf, oh, sizeof(*oh));
663 oh = (ipfw_obj_header *)tbuf;
664 table_fill_ntlv((ipfw_obj_ntlv *)(oh + 1), second, oh->ntlv.set, 1);
666 error = do_set3(IP_FW_TABLE_XSWAP, &oh->opheader, sizeof(tbuf));
675 table_swap(ipfw_obj_header *oh, char *second)
681 if (table_do_swap(oh, second) == 0)
696 * Retrieves table in given table specified by @oh->ntlv.
701 table_get_info(ipfw_obj_header *oh, ipfw_xtable_info *i)
708 memcpy(tbuf, oh, sizeof(*oh));
709 oh = (ipfw_obj_header *)tbuf;
711 if (do_get3(IP_FW_TABLE_XINFO, &oh->opheader, &sz) != 0)
717 *i = *(ipfw_xtable_info *)(oh + 1);
867 ipfw_obj_header *oh;
873 if ((error = table_do_get_list(i, &oh)) != 0) {
878 table_show_list(oh, is_all);
880 free(oh);
887 ipfw_obj_header *oh;
889 oh = (ipfw_obj_header *)arg;
891 table_fill_ntlv(&oh->ntlv, i->tablename, i->set, 1);
893 return (table_flush(oh));
897 table_do_modify_record(int cmd, ipfw_obj_header *oh,
903 char xbuf[sizeof(*oh) + sizeof(ipfw_obj_ctlv) + sizeof(*tent)];
912 if ((pbuf = calloc(1, sizeof(*oh) + sz)) == NULL)
916 memcpy(pbuf, oh, sizeof(*oh));
917 oh = (ipfw_obj_header *)pbuf;
918 oh->opheader.version = 1;
920 ctlv = (ipfw_obj_ctlv *)(oh + 1);
931 tent->idx = oh->idx;
934 sz += sizeof(*oh);
935 error = do_get3(cmd, &oh->opheader, &sz);
949 table_modify_record(ipfw_obj_header *oh, int ac, char *av[], int add,
993 tentry_fill_key(oh, ptent, *av, add, &type, &vmask, &xi);
1001 strlcpy(xi.tablename, oh->ntlv.name,
1007 table_do_create(oh, &xi);
1010 oh->ntlv.type = type;
1014 tentry_fill_value(oh, ptent, *av, type, vmask);
1025 error = table_do_modify_record(cmd, oh, tent_buf, count, atomic);
1120 table_do_lookup(ipfw_obj_header *oh, char *key, ipfw_xtable_info *xi,
1129 memcpy(xbuf, oh, sizeof(*oh));
1130 oh = (ipfw_obj_header *)xbuf;
1131 tent = (ipfw_obj_tentry *)(oh + 1);
1137 tentry_fill_key(oh, tent, key, 0, &type, &vmask, xi);
1138 oh->ntlv.type = type;
1141 if (do_get3(IP_FW_TABLE_XFIND, &oh->opheader, &sz) != 0)
1153 table_lookup(ipfw_obj_header *oh, int ac, char *av[])
1166 error = table_do_lookup(oh, key, &xi, &xtent);
1172 errx(EX_UNAVAILABLE, "Table %s not found", oh->ntlv.name);
1177 "\"lookup\" method", oh->ntlv.name);
1436 tentry_fill_key(ipfw_obj_header *oh, ipfw_obj_tentry *tent, char *key,
1448 error = table_get_info(oh, xi);
1474 oh->ntlv.name);
1477 oh->ntlv.name);
1485 "key '%s' type", oh->ntlv.name, key);
1513 tentry_fill_value(ipfw_obj_header *oh, ipfw_obj_tentry *tent, char *arg,
1730 ipfw_obj_header *oh;
1735 oh = NULL;
1739 if (oh != NULL)
1740 free(oh);
1741 if ((oh = calloc(1, sz)) == NULL)
1743 table_fill_objheader(oh, i);
1744 oh->opheader.version = 1; /* Current version */
1745 if (do_get3(IP_FW_TABLE_XLIST, &oh->opheader, &sz) == 0) {
1746 *poh = oh;
1753 free(oh);
1759 * Shows all entries from @oh in human-readable format
1762 table_show_list(ipfw_obj_header *oh, int need_header)
1768 i = (ipfw_xtable_info *)(oh + 1);