| 1867 | } |
| 1868 | |
| 1869 | static void |
| 1870 | table_show_entry(ipfw_xtable_info *i, ipfw_obj_tentry *tent) |
| 1871 | { |
| 1872 | char tbuf[128], pval[128]; |
| 1873 | const char *comma; |
| 1874 | void *paddr; |
| 1875 | struct tflow_entry *tfe; |
| 1876 | |
| 1877 | table_show_value(pval, sizeof(pval), &tent->v.value, i->vmask, |
| 1878 | g_co.do_value_as_ip); |
| 1879 | |
| 1880 | switch (i->type) { |
| 1881 | case IPFW_TABLE_ADDR: |
| 1882 | /* IPv4 or IPv6 prefixes */ |
| 1883 | inet_ntop(tent->subtype, &tent->k, tbuf, sizeof(tbuf)); |
| 1884 | printf("%s/%u %s\n", tbuf, tent->masklen, pval); |
| 1885 | break; |
| 1886 | case IPFW_TABLE_INTERFACE: |
| 1887 | /* Interface names */ |
| 1888 | printf("%s %s\n", tent->k.iface, pval); |
| 1889 | break; |
| 1890 | case IPFW_TABLE_NUMBER: |
| 1891 | /* numbers */ |
| 1892 | printf("%u %s\n", tent->k.key, pval); |
| 1893 | break; |
| 1894 | case IPFW_TABLE_FLOW: |
| 1895 | /* flows */ |
| 1896 | tfe = &tent->k.flow; |
| 1897 | comma = ""; |
| 1898 | |
| 1899 | if ((i->tflags & IPFW_TFFLAG_SRCIP) != 0) { |
| 1900 | if (tfe->af == AF_INET) |
| 1901 | paddr = &tfe->a.a4.sip; |
| 1902 | else |
| 1903 | paddr = &tfe->a.a6.sip6; |
| 1904 | |
| 1905 | inet_ntop(tfe->af, paddr, tbuf, sizeof(tbuf)); |
| 1906 | printf("%s%s", comma, tbuf); |
| 1907 | comma = ","; |
| 1908 | } |
| 1909 | |
| 1910 | if ((i->tflags & IPFW_TFFLAG_PROTO) != 0) { |
| 1911 | printf("%s%d", comma, tfe->proto); |
| 1912 | comma = ","; |
| 1913 | } |
| 1914 | |
| 1915 | if ((i->tflags & IPFW_TFFLAG_SRCPORT) != 0) { |
| 1916 | printf("%s%d", comma, ntohs(tfe->sport)); |
| 1917 | comma = ","; |
| 1918 | } |
| 1919 | if ((i->tflags & IPFW_TFFLAG_DSTIP) != 0) { |
| 1920 | if (tfe->af == AF_INET) |
| 1921 | paddr = &tfe->a.a4.dip; |
| 1922 | else |
| 1923 | paddr = &tfe->a.a6.dip6; |
| 1924 | |
| 1925 | inet_ntop(tfe->af, paddr, tbuf, sizeof(tbuf)); |
| 1926 | printf("%s%s", comma, tbuf); |
no test coverage detected