diff options
author | Steven Barth <steven@midlink.org> | 2014-06-26 14:12:51 +0200 |
---|---|---|
committer | Steven Barth <steven@midlink.org> | 2014-06-26 14:12:51 +0200 |
commit | b99104d3ab99077cdce312e1c0a8e605844b525c (patch) | |
tree | 45a2369f57d08277aeff3c037d8f1c7a4f12edf4 | |
parent | e678dcbf0336c3ca10f9fe2fae8b19347b6c1d4d (diff) | |
download | firewall3-b99104d3ab99077cdce312e1c0a8e605844b525c.tar.gz |
Add fw3 zone call to list devices in a zone
Signed-off-by: Steven Barth <steven@midlink.org>
-rw-r--r-- | main.c | 34 |
1 files changed, 34 insertions, 0 deletions
@@ -449,12 +449,42 @@ lookup_device(const char *dev) } static int +lookup_zone(const char *zone, const char *device) +{ + struct fw3_zone *z; + struct fw3_device *d; + + list_for_each_entry(z, &cfg_state->zones, list) + { + if (strcmp(z->name, zone)) + continue; + + list_for_each_entry(d, &z->devices, list) + { + if (device && strcmp(device, d->name)) + continue; + + printf("%s\n", d->name); + + if (device) + return 0; + } + + if (!device) + return 0; + } + + return 1; +} + +static int usage(void) { fprintf(stderr, "fw3 [-4] [-6] [-q] print\n"); fprintf(stderr, "fw3 [-q] {start|stop|flush|reload|restart}\n"); fprintf(stderr, "fw3 [-q] network {net}\n"); fprintf(stderr, "fw3 [-q] device {dev}\n"); + fprintf(stderr, "fw3 [-q] zone {zone} [dev]\n"); return 1; } @@ -575,6 +605,10 @@ int main(int argc, char **argv) { rv = lookup_device(argv[optind + 1]); } + else if (!strcmp(argv[optind], "zone") && (optind + 1) < argc) + { + rv = lookup_zone(argv[optind + 1], argv[optind + 2]); + } else { rv = usage(); |