Lines Matching defs: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, g_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)
296 if ((error = table_get_info(&oh, &i)) != 0)
307 table_lookup(&oh, ac, av);
325 table_fill_objheader(ipfw_obj_header *oh, ipfw_xtable_info *i)
328 oh->idx = 1;
329 table_fill_ntlv(&oh->ntlv, i->tablename, i->set, 1);
405 table_create(ipfw_obj_header *oh, int ac, char *av[])
492 error = table_do_create(oh, &xi);
501 if (table_get_info(oh, &xie) != 0)
512 if (orflush != 0 && table_flush(oh) != 0)
524 table_do_create(ipfw_obj_header *oh, ipfw_xtable_info *i)
529 memcpy(tbuf, oh, sizeof(*oh));
530 memcpy(tbuf + sizeof(*oh), i, sizeof(*i));
531 oh = (ipfw_obj_header *)tbuf;
533 error = do_set3(IP_FW_TABLE_XCREATE, &oh->opheader, sizeof(tbuf));
544 table_modify(ipfw_obj_header *oh, int ac, char *av[])
567 if (table_do_modify(oh, &xi) != 0)
579 table_do_modify(ipfw_obj_header *oh, ipfw_xtable_info *i)
584 memcpy(tbuf, oh, sizeof(*oh));
585 memcpy(tbuf + sizeof(*oh), i, sizeof(*i));
586 oh = (ipfw_obj_header *)tbuf;
588 error = do_set3(IP_FW_TABLE_XMODIFY, &oh->opheader, sizeof(tbuf));
597 table_lock(ipfw_obj_header *oh, int lock)
606 if (table_do_modify(oh, &xi) != 0)
611 * Destroys given table specified by @oh->ntlv.
615 table_destroy(ipfw_obj_header *oh)
618 if (do_set3(IP_FW_TABLE_XDESTROY, &oh->opheader, sizeof(*oh)) != 0)
627 ipfw_obj_header *oh;
629 oh = (ipfw_obj_header *)arg;
630 table_fill_ntlv(&oh->ntlv, i->tablename, i->set, 1);
631 if (table_destroy(oh) != 0) {
641 * Flushes given table specified by @oh->ntlv.
645 table_flush(ipfw_obj_header *oh)
648 if (do_set3(IP_FW_TABLE_XFLUSH, &oh->opheader, sizeof(*oh)) != 0)
655 table_do_swap(ipfw_obj_header *oh, char *second)
661 memcpy(tbuf, oh, sizeof(*oh));
662 oh = (ipfw_obj_header *)tbuf;
663 table_fill_ntlv((ipfw_obj_ntlv *)(oh + 1), second, oh->ntlv.set, 1);
665 error = do_set3(IP_FW_TABLE_XSWAP, &oh->opheader, sizeof(tbuf));
674 table_swap(ipfw_obj_header *oh, char *second)
680 if (table_do_swap(oh, second) == 0)
695 * Retrieves table in given table specified by @oh->ntlv.
700 table_get_info(ipfw_obj_header *oh, ipfw_xtable_info *i)
707 memcpy(tbuf, oh, sizeof(*oh));
708 oh = (ipfw_obj_header *)tbuf;
710 if (do_get3(IP_FW_TABLE_XINFO, &oh->opheader, &sz) != 0)
716 *i = *(ipfw_xtable_info *)(oh + 1);
866 ipfw_obj_header *oh = NULL;
872 if ((error = table_do_get_list(i, &oh)) != 0) {
877 table_show_list(oh, is_all);
879 free(oh);
886 ipfw_obj_header *oh;
888 oh = (ipfw_obj_header *)arg;
890 table_fill_ntlv(&oh->ntlv, i->tablename, i->set, 1);
892 return (table_flush(oh));
896 table_do_modify_record(int cmd, ipfw_obj_header *oh,
902 char xbuf[sizeof(*oh) + sizeof(ipfw_obj_ctlv) + sizeof(*tent)];
911 if ((pbuf = calloc(1, sizeof(*oh) + sz)) == NULL)
915 memcpy(pbuf, oh, sizeof(*oh));
916 oh = (ipfw_obj_header *)pbuf;
917 oh->opheader.version = 1;
919 ctlv = (ipfw_obj_ctlv *)(oh + 1);
930 tent->idx = oh->idx;
933 sz += sizeof(*oh);
934 error = do_get3(cmd, &oh->opheader, &sz);
948 table_modify_record(ipfw_obj_header *oh, int ac, char *av[], int add,
992 tentry_fill_key(oh, ptent, *av, add, &type, &vmask, &xi);
1000 strlcpy(xi.tablename, oh->ntlv.name,
1006 table_do_create(oh, &xi);
1009 oh->ntlv.type = type;
1013 tentry_fill_value(oh, ptent, *av, type, vmask);
1024 error = table_do_modify_record(cmd, oh, tent_buf, count, atomic);
1119 table_do_lookup(ipfw_obj_header *oh, char *key, ipfw_xtable_info *xi,
1128 memcpy(xbuf, oh, sizeof(*oh));
1129 oh = (ipfw_obj_header *)xbuf;
1130 tent = (ipfw_obj_tentry *)(oh + 1);
1136 tentry_fill_key(oh, tent, key, 0, &type, &vmask, xi);
1137 oh->ntlv.type = type;
1140 if (do_get3(IP_FW_TABLE_XFIND, &oh->opheader, &sz) != 0)
1152 table_lookup(ipfw_obj_header *oh, int ac, char *av[])
1165 error = table_do_lookup(oh, key, &xi, &xtent);
1171 errx(EX_UNAVAILABLE, "Table %s not found", oh->ntlv.name);
1176 "\"lookup\" method", oh->ntlv.name);
1435 tentry_fill_key(ipfw_obj_header *oh, ipfw_obj_tentry *tent, char *key,
1447 error = table_get_info(oh, xi);
1473 oh->ntlv.name);
1476 oh->ntlv.name);
1484 "key '%s' type", oh->ntlv.name, key);
1512 tentry_fill_value(ipfw_obj_header *oh __unused, ipfw_obj_tentry *tent,
1734 ipfw_obj_header *oh;
1739 oh = NULL;
1743 if (oh != NULL)
1744 free(oh);
1745 if ((oh = calloc(1, sz)) == NULL)
1747 table_fill_objheader(oh, i);
1748 oh->opheader.version = 1; /* Current version */
1749 if (do_get3(IP_FW_TABLE_XLIST, &oh->opheader, &sz) == 0) {
1750 *poh = oh;
1757 free(oh);
1763 * Shows all entries from @oh in human-readable format
1766 table_show_list(ipfw_obj_header *oh, int need_header)
1772 i = (ipfw_xtable_info *)(oh + 1);