From b99104d3ab99077cdce312e1c0a8e605844b525c Mon Sep 17 00:00:00 2001 From: Steven Barth Date: Thu, 26 Jun 2014 14:12:51 +0200 Subject: [PATCH] Add fw3 zone call to list devices in a zone Signed-off-by: Steven Barth --- main.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/main.c b/main.c index 27d5298..17d71d1 100644 --- a/main.c +++ b/main.c @@ -448,6 +448,35 @@ lookup_device(const char *dev) return 1; } +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) { @@ -455,6 +484,7 @@ usage(void) 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(); -- 2.25.1