MCPcopy Create free account
hub / github.com/F-Stack/f-stack / table_show_info

Function table_show_info

tools/ipfw/tables.c:783–849  ·  view source on GitHub ↗

* Prints table info struct @i in human-readable form. */

Source from the content-addressed store, hash-verified

781 * Prints table info struct @i in human-readable form.
782 */
783static int
784table_show_info(ipfw_xtable_info *i, void *arg)
785{
786 const char *vtype;
787 ipfw_ta_tinfo *tainfo;
788 int afdata, afitem;
789 struct ta_cldata d;
790 char ttype[64], tvtype[64];
791
792 table_print_type(ttype, sizeof(ttype), i->type, i->tflags);
793 table_print_valheader(tvtype, sizeof(tvtype), i->vmask);
794
795 printf("--- table(%s), set(%u) ---\n", i->tablename, i->set);
796 if ((i->flags & IPFW_TGFLAGS_LOCKED) != 0)
797 printf(" kindex: %d, type: %s, locked\n", i->kidx, ttype);
798 else
799 printf(" kindex: %d, type: %s\n", i->kidx, ttype);
800 printf(" references: %u, valtype: %s\n", i->refcnt, tvtype);
801 printf(" algorithm: %s\n", i->algoname);
802 printf(" items: %u, size: %u\n", i->count, i->size);
803 if (i->limit > 0)
804 printf(" limit: %u\n", i->limit);
805
806 /* Print algo-specific info if requested & set */
807 if (arg == NULL)
808 return (0);
809
810 if ((i->ta_info.flags & IPFW_TATFLAGS_DATA) == 0)
811 return (0);
812 tainfo = &i->ta_info;
813
814 afdata = 0;
815 afitem = 0;
816 if (tainfo->flags & IPFW_TATFLAGS_AFDATA)
817 afdata = 1;
818 if (tainfo->flags & IPFW_TATFLAGS_AFITEM)
819 afitem = 1;
820
821 memset(&d, 0, sizeof(d));
822 d.taclass = tainfo->taclass4;
823 d.size = tainfo->size4;
824 d.count = tainfo->count4;
825 d.itemsize = tainfo->itemsize4;
826 if (afdata == 0 && afitem != 0)
827 d.itemsize6 = tainfo->itemsize6;
828 else
829 d.itemsize6 = d.itemsize;
830 if ((vtype = match_value(tablealgoclass, d.taclass)) == NULL)
831 vtype = "unknown";
832
833 if (afdata == 0) {
834 table_show_tainfo(i, &d, "", vtype);
835 } else {
836 table_show_tainfo(i, &d, "IPv4 ", vtype);
837 memset(&d, 0, sizeof(d));
838 d.taclass = tainfo->taclass6;
839 if ((vtype = match_value(tablealgoclass, d.taclass)) == NULL)
840 vtype = "unknown";

Callers 1

ipfw_table_handlerFunction · 0.85

Calls 6

table_print_typeFunction · 0.85
table_print_valheaderFunction · 0.85
memsetFunction · 0.85
match_valueFunction · 0.85
table_show_tainfoFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected