]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
arptables-save: Merge into xtables_save_main()
authorPhil Sutter <phil@nwl.cc>
Mon, 22 Jul 2019 10:16:27 +0000 (12:16 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Tue, 23 Jul 2019 19:14:40 +0000 (21:14 +0200)
With all preparations in place, xtables_save_main() can replace it with
not further changes.

Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
iptables/xtables-save.c

index 980a80ff06f96ff8c28e7afe3726c776b0799055..0c294e056c7b585f171c32089fbb32cd087a966b 100644 (file)
@@ -372,65 +372,8 @@ int xtables_eb_save_main(int argc_, char *argv_[])
        return 0;
 }
 
-int xtables_arp_save_main(int argc, char **argv)
+int xtables_arp_save_main(int argc, char *argv[])
 {
-       struct nft_handle h = {
-               .family = NFPROTO_ARP,
-       };
-       time_t now;
-       int c;
-
-       xtables_globals.program_name = basename(*argv);;
-       c = xtables_init_all(&xtables_globals, h.family);
-       if (c < 0) {
-               fprintf(stderr, "%s/%s Failed to initialize xtables\n",
-                               xtables_globals.program_name,
-                               xtables_globals.program_version);
-               exit(1);
-       }
-
-       while ((c = getopt_long(argc, argv, arp_save_optstring, arp_save_options, NULL)) != -1) {
-               switch (c) {
-               case 'c':
-                       show_counters = true;
-                       break;
-               case 'M':
-                       xtables_modprobe_program = optarg;
-                       break;
-               case 'V':
-                       printf("%s v%s (nf_tables)\n", prog_name, prog_vers);
-                       exit(0);
-               default:
-                       fprintf(stderr,
-                               "Look at manual page `%s.8' for more information.\n",
-                               prog_name);
-                       exit(1);
-               }
-       }
-
-       if (nft_init(&h, xtables_arp) < 0) {
-               fprintf(stderr, "%s/%s Failed to initialize nft: %s\n",
-                               xtables_globals.program_name,
-                               xtables_globals.program_version,
-                               strerror(errno));
-               exit(EXIT_FAILURE);
-       }
-
-       if (!nft_table_find(&h, "filter"))
-               return 0;
-
-       if (!nft_is_table_compatible(&h, "filter")) {
-               printf("# Table `filter' is incompatible, use 'nft' tool.\n");
-               return 0;
-       }
-
-       printf("# Generated by %s v%s on %s", prog_name,
-              prog_vers, ctime(&now));
-       printf("*filter\n");
-       nft_chain_save(&h, nft_chain_list_get(&h, "filter"));
-       nft_rule_save(&h, "filter", show_counters ? 0 : FMT_NOCOUNTS);
-       now = time(NULL);
-       printf("# Completed on %s", ctime(&now));
-       nft_fini(&h);
-       return 0;
+       return xtables_save_main(NFPROTO_ARP, argc, argv,
+                                arp_save_optstring, arp_save_options);
 }