| 2715 | } |
| 2716 | |
| 2717 | void |
| 2718 | ipfw_list(int ac, char *av[], int show_counters) |
| 2719 | { |
| 2720 | ipfw_cfg_lheader *cfg; |
| 2721 | struct format_opts sfo; |
| 2722 | size_t sz; |
| 2723 | int error; |
| 2724 | int lac; |
| 2725 | char **lav; |
| 2726 | uint32_t rnum; |
| 2727 | char *endptr; |
| 2728 | |
| 2729 | if (g_co.test_only) { |
| 2730 | fprintf(stderr, "Testing only, list disabled\n"); |
| 2731 | return; |
| 2732 | } |
| 2733 | if (g_co.do_pipe) { |
| 2734 | #ifdef DUMMYNET |
| 2735 | dummynet_list(ac, av, show_counters); |
| 2736 | #else |
| 2737 | fprintf(stderr, "dummynet_list not supported\n"); |
| 2738 | #endif |
| 2739 | return; |
| 2740 | } |
| 2741 | |
| 2742 | ac--; |
| 2743 | av++; |
| 2744 | memset(&sfo, 0, sizeof(sfo)); |
| 2745 | |
| 2746 | /* Determine rule range to request */ |
| 2747 | if (ac > 0) { |
| 2748 | for (lac = ac, lav = av; lac != 0; lac--) { |
| 2749 | rnum = strtoul(*lav++, &endptr, 10); |
| 2750 | if (sfo.first == 0 || rnum < sfo.first) |
| 2751 | sfo.first = rnum; |
| 2752 | |
| 2753 | if (*endptr == '-') |
| 2754 | rnum = strtoul(endptr + 1, &endptr, 10); |
| 2755 | if (sfo.last == 0 || rnum > sfo.last) |
| 2756 | sfo.last = rnum; |
| 2757 | } |
| 2758 | } |
| 2759 | |
| 2760 | /* get configuraion from kernel */ |
| 2761 | cfg = NULL; |
| 2762 | sfo.show_counters = show_counters; |
| 2763 | sfo.show_time = g_co.do_time; |
| 2764 | if (g_co.do_dynamic != 2) |
| 2765 | sfo.flags |= IPFW_CFG_GET_STATIC; |
| 2766 | if (g_co.do_dynamic != 0) |
| 2767 | sfo.flags |= IPFW_CFG_GET_STATES; |
| 2768 | if ((sfo.show_counters | sfo.show_time) != 0) |
| 2769 | sfo.flags |= IPFW_CFG_GET_COUNTERS; |
| 2770 | if (ipfw_get_config(&g_co, &sfo, &cfg, &sz) != 0) |
| 2771 | err(EX_OSERR, "retrieving config failed"); |
| 2772 | |
| 2773 | error = ipfw_show_config(&g_co, &sfo, cfg, sz, ac, av); |
| 2774 |
no test coverage detected