Consolidate and unify argument order for functions
authorJo-Philipp Wich <jow@openwrt.org>
Thu, 14 Mar 2013 15:07:41 +0000 (16:07 +0100)
committerJo-Philipp Wich <jow@openwrt.org>
Thu, 14 Mar 2013 15:09:37 +0000 (16:09 +0100)
defaults.c
defaults.h
forwards.c
forwards.h
main.c
redirects.c
redirects.h
rules.c
rules.h
zones.c
zones.h

index bde4644a5de1b303145ce92eb40b00a497feaa75..10b11637c81482e0018d1ae68609161ea2425413 100644 (file)
@@ -135,8 +135,8 @@ fw3_load_defaults(struct fw3_state *state, struct uci_package *p)
 }
 
 void
-fw3_print_default_chains(enum fw3_table table, enum fw3_family family,
-                         bool reload, struct fw3_state *state)
+fw3_print_default_chains(struct fw3_state *state, enum fw3_family family,
+                         enum fw3_table table, bool reload)
 {
        bool rv;
        struct fw3_defaults *defs = &state->defaults;
@@ -173,8 +173,8 @@ fw3_print_default_chains(enum fw3_table table, enum fw3_family family,
 }
 
 void
-fw3_print_default_head_rules(enum fw3_table table, enum fw3_family family,
-                             bool reload, struct fw3_state *state)
+fw3_print_default_head_rules(struct fw3_state *state, enum fw3_family family,
+                             enum fw3_table table, bool reload)
 {
        int i;
        struct fw3_defaults *defs = &state->defaults;
@@ -248,8 +248,8 @@ fw3_print_default_head_rules(enum fw3_table table, enum fw3_family family,
 }
 
 void
-fw3_print_default_tail_rules(enum fw3_table table, enum fw3_family family,
-                             bool reload, struct fw3_state *state)
+fw3_print_default_tail_rules(struct fw3_state *state, enum fw3_family family,
+                             enum fw3_table table, bool reload)
 {
        struct fw3_defaults *defs = &state->defaults;
 
@@ -306,8 +306,8 @@ reset_policy(enum fw3_table table, enum fw3_flag policy)
 }
 
 void
-fw3_flush_rules(enum fw3_table table, enum fw3_family family,
-                bool pass2, bool reload, struct fw3_state *state)
+fw3_flush_rules(struct fw3_state *state, enum fw3_family family,
+                enum fw3_table table, bool reload, bool pass2)
 {
        struct fw3_defaults *defs = &state->defaults;
        uint32_t custom_mask = ~0;
index f448034930577d17187516db49a1134cbe96735b..1c1a6a0455c5797fa86df3a1a9e910bcc143e372 100644 (file)
@@ -25,19 +25,21 @@ extern const struct fw3_option fw3_flag_opts[];
 
 void fw3_load_defaults(struct fw3_state *state, struct uci_package *p);
 
-void fw3_print_default_chains(enum fw3_table table, enum fw3_family family,
-                              bool reload, struct fw3_state *state);
+void fw3_print_default_chains(struct fw3_state *state, enum fw3_family family,
+                              enum fw3_table table, bool reload);
 
-void fw3_print_default_head_rules(enum fw3_table table, enum fw3_family family,
-                                  bool reload, struct fw3_state *state);
+void fw3_print_default_head_rules(struct fw3_state *state,
+                                  enum fw3_family family, enum fw3_table table,
+                                  bool reload);
 
-void fw3_print_default_tail_rules(enum fw3_table table, enum fw3_family family,
-                                  bool reload, struct fw3_state *state);
+void fw3_print_default_tail_rules(struct fw3_state *state,
+                                  enum fw3_family family, enum fw3_table table,
+                                  bool reload);
 
 void fw3_set_defaults(struct fw3_state *state);
 
-void fw3_flush_rules(enum fw3_table table, enum fw3_family family,
-                     bool pass2, bool reload, struct fw3_state *state);
+void fw3_flush_rules(struct fw3_state *state, enum fw3_family family,
+                     enum fw3_table table, bool reload, bool pass2);
 
 void fw3_flush_all(enum fw3_table table);
 
index 81e734ec6d0464a2bf9c193f838aa8886acb7841..fad347e1a73e6cacfc5199705f10134da49b81a9 100644 (file)
@@ -123,8 +123,8 @@ static void print_target(struct fw3_forward *forward)
 }
 
 static void
-print_forward(enum fw3_table table, enum fw3_family family,
-              struct fw3_forward *forward)
+print_forward(struct fw3_forward *forward, enum fw3_family family,
+              enum fw3_table table)
 {
        const char *s, *d;
 
@@ -152,11 +152,11 @@ print_forward(enum fw3_table table, enum fw3_family family,
 }
 
 void
-fw3_print_forwards(enum fw3_table table, enum fw3_family family,
-                   struct fw3_state *state)
+fw3_print_forwards(struct fw3_state *state, enum fw3_family family,
+                   enum fw3_table table)
 {
        struct fw3_forward *forward;
 
        list_for_each_entry(forward, &state->forwards, list)
-               print_forward(table, family, forward);
+               print_forward(forward, family, table);
 }
index f512bb11e115345f47e8e9f0fb6bf85abb19f7ab..b8784bcfafd22080fc8cc26514699b9dd48c3f96 100644 (file)
@@ -26,8 +26,8 @@
 extern const struct fw3_option fw3_forward_opts[];
 
 void fw3_load_forwards(struct fw3_state *state, struct uci_package *p);
-void fw3_print_forwards(enum fw3_table table, enum fw3_family family,
-                        struct fw3_state *state);
+void fw3_print_forwards(struct fw3_state *state, enum fw3_family family,
+                        enum fw3_table table);
 
 #define fw3_free_forward(forward) \
        fw3_free_object(forward, fw3_forward_opts)
diff --git a/main.c b/main.c
index 8b1649deb31413705869970cdc61fd8fd437aa4c..d4d7b7b6aa577539faaa8859158170ac38ac0884 100644 (file)
--- a/main.c
+++ b/main.c
@@ -172,7 +172,7 @@ stop(struct fw3_state *state, bool complete, bool reload)
        }
 
        if (!print_rules)
-               fw3_hotplug_zones(false, state);
+               fw3_hotplug_zones(state, false);
 
        for (family = FW3_FAMILY_V4; family <= FW3_FAMILY_V6; family++)
        {
@@ -199,12 +199,12 @@ stop(struct fw3_state *state, bool complete, bool reload)
                        else
                        {
                                /* pass 1 */
-                               fw3_flush_rules(table, family, false, reload, state);
-                               fw3_flush_zones(table, family, false, reload, state);
+                               fw3_flush_rules(state, family, table, reload, false);
+                               fw3_flush_zones(state, family, table, reload, false);
 
                                /* pass 2 */
-                               fw3_flush_rules(table, family, true, reload, state);
-                               fw3_flush_zones(table, family, true, reload, state);
+                               fw3_flush_rules(state, family, table, reload, true);
+                               fw3_flush_zones(state, family, table, reload, true);
                        }
 
                        fw3_pr("COMMIT\n");
@@ -282,14 +282,14 @@ start(struct fw3_state *state, bool reload)
                             fw3_flag_names[family], fw3_flag_names[table]);
 
                        fw3_pr("*%s\n", fw3_flag_names[table]);
-                       fw3_print_default_chains(table, family, reload, state);
-                       fw3_print_zone_chains(table, family, reload, state);
-                       fw3_print_default_head_rules(table, family, reload, state);
-                       fw3_print_rules(table, family, state);
-                       fw3_print_redirects(table, family, state);
-                       fw3_print_forwards(table, family, state);
-                       fw3_print_zone_rules(table, family, reload, state);
-                       fw3_print_default_tail_rules(table, family, reload, state);
+                       fw3_print_default_chains(state, family, table, reload);
+                       fw3_print_zone_chains(state, family, table, reload);
+                       fw3_print_default_head_rules(state, family, table, reload);
+                       fw3_print_rules(state, family, table);
+                       fw3_print_redirects(state, family, table);
+                       fw3_print_forwards(state, family, table);
+                       fw3_print_zone_rules(state, family, table, reload);
+                       fw3_print_default_tail_rules(state, family, table, reload);
                        fw3_pr("COMMIT\n");
                }
 
@@ -308,7 +308,7 @@ start(struct fw3_state *state, bool reload)
                if (!print_rules)
                {
                        fw3_run_includes(state, reload);
-                       fw3_hotplug_zones(true, state);
+                       fw3_hotplug_zones(state, true);
                        fw3_write_statefile(state);
                }
        }
index b42201f91f79b868308e1b1e8aec3233590bf45f..3e6902d5583acd28bffe820e8761338ff9d0448a 100644 (file)
@@ -322,8 +322,8 @@ print_target_filter(struct fw3_redirect *redir)
 }
 
 static void
-print_redirect(enum fw3_table table, enum fw3_family family,
-               struct fw3_redirect *redir, int num)
+print_redirect(struct fw3_state *state, enum fw3_family family,
+               enum fw3_table table, struct fw3_redirect *redir, int num)
 {
        struct list_head *ext_addrs, *int_addrs;
        struct fw3_address *ext_addr, *int_addr, ref_addr;
@@ -482,8 +482,8 @@ print_redirect(enum fw3_table table, enum fw3_family family,
 }
 
 void
-fw3_print_redirects(enum fw3_table table, enum fw3_family family,
-                    struct fw3_state *state)
+fw3_print_redirects(struct fw3_state *state, enum fw3_family family,
+                    enum fw3_table table)
 {
        int num = 0;
        struct fw3_redirect *redir;
@@ -495,5 +495,5 @@ fw3_print_redirects(enum fw3_table table, enum fw3_family family,
                return;
 
        list_for_each_entry(redir, &state->redirects, list)
-               print_redirect(table, family, redir, num++);
+               print_redirect(state, family, table, redir, num++);
 }
index 4436f52ffb15b72d97cd3f0b217d81ff62fa0984..14f90bb6d01748554b16c94d2a83a75619995078 100644 (file)
@@ -27,8 +27,8 @@
 extern const struct fw3_option fw3_redirect_opts[];
 
 void fw3_load_redirects(struct fw3_state *state, struct uci_package *p);
-void fw3_print_redirects(enum fw3_table table, enum fw3_family family,
-                         struct fw3_state *state);
+void fw3_print_redirects(struct fw3_state *state, enum fw3_family family,
+                         enum fw3_table table);
 
 #define fw3_free_redirect(redir) \
        fw3_free_object(redir, fw3_redirect_opts)
diff --git a/rules.c b/rules.c
index 8452a402a7e740b432819b98c3dd585b1a5db789..e6af62e4d9d87452bccda1f4bc4ea8e11b99befa 100644 (file)
--- a/rules.c
+++ b/rules.c
@@ -238,8 +238,9 @@ static void print_target(struct fw3_rule *rule)
 }
 
 static void
-print_rule(enum fw3_table table, enum fw3_family family,
-           struct fw3_rule *rule, struct fw3_protocol *proto,
+print_rule(struct fw3_state *state, enum fw3_family family,
+           enum fw3_table table, struct fw3_rule *rule,
+           struct fw3_protocol *proto,
            struct fw3_address *sip, struct fw3_address *dip,
            struct fw3_port *sport, struct fw3_port *dport,
            struct fw3_mac *mac, struct fw3_icmptype *icmptype)
@@ -271,8 +272,8 @@ print_rule(enum fw3_table table, enum fw3_family family,
 }
 
 static void
-expand_rule(enum fw3_table table, enum fw3_family family,
-            struct fw3_rule *rule, int num)
+expand_rule(struct fw3_state *state, enum fw3_family family,
+            enum fw3_table table, struct fw3_rule *rule, int num)
 {
        struct fw3_protocol *proto;
        struct fw3_address *sip;
@@ -341,18 +342,18 @@ expand_rule(enum fw3_table table, enum fw3_family family,
                fw3_foreach(dport, dports)
                fw3_foreach(mac, &rule->mac_src)
                fw3_foreach(icmptype, icmptypes)
-                       print_rule(table, family, rule, proto, sip, dip, sport, dport,
-                                  mac, icmptype);
+                       print_rule(state, family, table, rule, proto, sip, dip,
+                                  sport, dport, mac, icmptype);
        }
 }
 
 void
-fw3_print_rules(enum fw3_table table, enum fw3_family family,
-                struct fw3_state *state)
+fw3_print_rules(struct fw3_state *state, enum fw3_family family,
+                enum fw3_table table)
 {
        int num = 0;
        struct fw3_rule *rule;
 
        list_for_each_entry(rule, &state->rules, list)
-               expand_rule(table, family, rule, num++);
+               expand_rule(state, family, table, rule, num++);
 }
diff --git a/rules.h b/rules.h
index 38d0df748155792ff886d17eb8bfcb2a1e67fc70..44a40f21cfe794709fba5fd86c048ffc2899929c 100644 (file)
--- a/rules.h
+++ b/rules.h
@@ -27,8 +27,8 @@
 extern const struct fw3_option fw3_rule_opts[];
 
 void fw3_load_rules(struct fw3_state *state, struct uci_package *p);
-void fw3_print_rules(enum fw3_table table, enum fw3_family family,
-                     struct fw3_state *state);
+void fw3_print_rules(struct fw3_state *state, enum fw3_family family,
+                     enum fw3_table table);
 
 #define fw3_free_rule(rule) \
        fw3_free_object(rule, fw3_rule_opts)
diff --git a/zones.c b/zones.c
index 846e43015d7b41e8980f2139dd1589236fb32d61..2a230c579e4c2bb6de50f93553bd62f58350f5be 100644 (file)
--- a/zones.c
+++ b/zones.c
@@ -243,8 +243,8 @@ fw3_load_zones(struct fw3_state *state, struct uci_package *p)
 
 
 static void
-print_zone_chain(enum fw3_table table, enum fw3_family family,
-                 struct fw3_zone *zone, bool reload, struct fw3_state *state)
+print_zone_chain(struct fw3_state *state, enum fw3_family family,
+                 enum fw3_table table, bool reload, struct fw3_zone *zone)
 {
        bool c, r;
        uint32_t custom_mask = ~0;
@@ -280,10 +280,12 @@ print_zone_chain(enum fw3_table table, enum fw3_family family,
 }
 
 static void
-print_interface_rule(enum fw3_table table, enum fw3_family family,
-                     struct fw3_zone *zone, struct fw3_device *dev,
-                     struct fw3_address *sub, bool reload, bool disable_notrack)
+print_interface_rule(struct fw3_state *state, enum fw3_family family,
+                     enum fw3_table table, bool reload, struct fw3_zone *zone,
+                     struct fw3_device *dev, struct fw3_address *sub)
 {
+       bool disable_notrack = state->defaults.drop_invalid;
+
        enum fw3_flag t;
 
 #define jump_target(t) \
@@ -388,8 +390,8 @@ print_interface_rule(enum fw3_table table, enum fw3_family family,
 }
 
 static void
-print_interface_rules(enum fw3_table table, enum fw3_family family,
-                      struct fw3_zone *zone, bool reload, bool disable_notrack)
+print_interface_rules(struct fw3_state *state, enum fw3_family family,
+                      enum fw3_table table, bool reload, struct fw3_zone *zone)
 {
        struct fw3_device *dev;
        struct fw3_address *sub;
@@ -403,13 +405,13 @@ print_interface_rules(enum fw3_table table, enum fw3_family family,
                if (!dev && !sub)
                        continue;
 
-               print_interface_rule(table, family, zone, dev, sub, reload, disable_notrack);
+               print_interface_rule(state, family, table, reload, zone, dev, sub);
        }
 }
 
 static void
-print_zone_rule(enum fw3_table table, enum fw3_family family,
-                struct fw3_zone *zone, bool reload, bool disable_notrack)
+print_zone_rule(struct fw3_state *state, enum fw3_family family,
+                enum fw3_table table, bool reload, struct fw3_zone *zone)
 {
        struct fw3_address *msrc;
        struct fw3_address *mdest;
@@ -472,32 +474,32 @@ print_zone_rule(enum fw3_table table, enum fw3_family family,
                break;
        }
 
-       print_interface_rules(table, family, zone, reload, disable_notrack);
+       print_interface_rules(state, family, table, reload, zone);
 }
 
 void
-fw3_print_zone_chains(enum fw3_table table, enum fw3_family family,
-                      bool reload, struct fw3_state *state)
+fw3_print_zone_chains(struct fw3_state *state, enum fw3_family family,
+                      enum fw3_table table, bool reload)
 {
        struct fw3_zone *zone;
 
        list_for_each_entry(zone, &state->zones, list)
-               print_zone_chain(table, family, zone, reload, state);
+               print_zone_chain(state, family, table, reload, zone);
 }
 
 void
-fw3_print_zone_rules(enum fw3_table table, enum fw3_family family,
-                     bool reload, struct fw3_state *state)
+fw3_print_zone_rules(struct fw3_state *state, enum fw3_family family,
+                     enum fw3_table table, bool reload)
 {
        struct fw3_zone *zone;
 
        list_for_each_entry(zone, &state->zones, list)
-               print_zone_rule(table, family, zone, reload, state->defaults.drop_invalid);
+               print_zone_rule(state, family, table, reload, zone);
 }
 
 void
-fw3_flush_zones(enum fw3_table table, enum fw3_family family,
-                           bool pass2, bool reload, struct fw3_state *state)
+fw3_flush_zones(struct fw3_state *state, enum fw3_family family,
+                               enum fw3_table table, bool reload, bool pass2)
 {
        struct fw3_zone *z, *tmp;
        uint32_t custom_mask = ~0;
@@ -515,14 +517,12 @@ fw3_flush_zones(enum fw3_table table, enum fw3_family family,
                                pass2 ? "-X %s\n" : "-F %s\n", z->name);
 
                if (pass2)
-               {
                        del(z->flags, family, table);
-               }
        }
 }
 
 void
-fw3_hotplug_zones(bool add, struct fw3_state *state)
+fw3_hotplug_zones(struct fw3_state *state, bool add)
 {
        struct fw3_zone *z;
        struct fw3_device *d;
diff --git a/zones.h b/zones.h
index bda96ab2873cb67ef1d15139d2faa7714b741093..63ed3a596ed5c8ae43f22b092ac4137bebdc469c 100644 (file)
--- a/zones.h
+++ b/zones.h
@@ -27,16 +27,16 @@ struct fw3_zone * fw3_alloc_zone(void);
 
 void fw3_load_zones(struct fw3_state *state, struct uci_package *p);
 
-void fw3_print_zone_chains(enum fw3_table table, enum fw3_family family,
-                           bool reload, struct fw3_state *state);
+void fw3_print_zone_chains(struct fw3_state *state, enum fw3_family family,
+                           enum fw3_table table, bool reload);
 
-void fw3_print_zone_rules(enum fw3_table table, enum fw3_family family,
-                          bool reload, struct fw3_state *state);
+void fw3_print_zone_rules(struct fw3_state *state, enum fw3_family family,
+                          enum fw3_table table, bool reload);
 
-void fw3_flush_zones(enum fw3_table table, enum fw3_family family,
-                     bool pass2, bool reload, struct fw3_state *state);
+void fw3_flush_zones(struct fw3_state *state, enum fw3_family family,
+                     enum fw3_table table, bool reload, bool pass2);
 
-void fw3_hotplug_zones(bool add, struct fw3_state *state);
+void fw3_hotplug_zones(struct fw3_state *state, bool add);
 
 struct fw3_zone * fw3_lookup_zone(struct fw3_state *state, const char *name,
                                   bool running);