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

Function table_show_value

tools/ipfw/tables.c:1781–1867  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1779}
1780
1781static void
1782table_show_value(char *buf, size_t bufsize, ipfw_table_value *v,
1783 uint32_t vmask, int print_ip)
1784{
1785 char abuf[INET6_ADDRSTRLEN + IF_NAMESIZE + 2];
1786 struct sockaddr_in6 sa6;
1787 uint32_t flag, i, l;
1788 size_t sz;
1789 struct in_addr a4;
1790
1791 sz = bufsize;
1792
1793 /*
1794 * Some shorthands for printing values:
1795 * legacy assumes all values are equal, so keep the first one.
1796 */
1797 if (vmask == IPFW_VTYPE_LEGACY) {
1798 if (print_ip != 0) {
1799 flag = htonl(v->tag);
1800 inet_ntop(AF_INET, &flag, buf, sz);
1801 } else
1802 snprintf(buf, sz, "%u", v->tag);
1803 return;
1804 }
1805
1806 for (i = 1; i < (1u << 31); i *= 2) {
1807 if ((flag = (vmask & i)) == 0)
1808 continue;
1809 l = 0;
1810
1811 switch (flag) {
1812 case IPFW_VTYPE_TAG:
1813 l = snprintf(buf, sz, "%u,", v->tag);
1814 break;
1815 case IPFW_VTYPE_PIPE:
1816 l = snprintf(buf, sz, "%u,", v->pipe);
1817 break;
1818 case IPFW_VTYPE_DIVERT:
1819 l = snprintf(buf, sz, "%d,", v->divert);
1820 break;
1821 case IPFW_VTYPE_SKIPTO:
1822 l = snprintf(buf, sz, "%d,", v->skipto);
1823 break;
1824 case IPFW_VTYPE_NETGRAPH:
1825 l = snprintf(buf, sz, "%u,", v->netgraph);
1826 break;
1827 case IPFW_VTYPE_FIB:
1828 l = snprintf(buf, sz, "%u,", v->fib);
1829 break;
1830 case IPFW_VTYPE_NAT:
1831 l = snprintf(buf, sz, "%u,", v->nat);
1832 break;
1833 case IPFW_VTYPE_LIMIT:
1834 l = snprintf(buf, sz, "%u,", v->limit);
1835 break;
1836 case IPFW_VTYPE_NH4:
1837 a4.s_addr = htonl(v->nh4);
1838 inet_ntop(AF_INET, &a4, abuf, sizeof(abuf));

Callers 2

table_show_entryFunction · 0.85
ipfw_list_valuesFunction · 0.85

Calls 2

inet_ntopFunction · 0.85
snprintfFunction · 0.85

Tested by

no test coverage detected