From ab591095d650bc3e997bad12aa7662e49d5cd9d5 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Thu, 14 Mar 2013 16:07:41 +0100 Subject: [PATCH] Consolidate and unify argument order for functions --- defaults.c | 16 ++++++++-------- defaults.h | 18 ++++++++++-------- forwards.c | 10 +++++----- forwards.h | 4 ++-- main.c | 28 ++++++++++++++-------------- redirects.c | 10 +++++----- redirects.h | 4 ++-- rules.c | 19 ++++++++++--------- rules.h | 4 ++-- zones.c | 44 ++++++++++++++++++++++---------------------- zones.h | 14 +++++++------- 11 files changed, 87 insertions(+), 84 deletions(-) diff --git a/defaults.c b/defaults.c index bde4644..10b1163 100644 --- a/defaults.c +++ b/defaults.c @@ -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; diff --git a/defaults.h b/defaults.h index f448034..1c1a6a0 100644 --- a/defaults.h +++ b/defaults.h @@ -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); diff --git a/forwards.c b/forwards.c index 81e734e..fad347e 100644 --- a/forwards.c +++ b/forwards.c @@ -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); } diff --git a/forwards.h b/forwards.h index f512bb1..b8784bc 100644 --- a/forwards.h +++ b/forwards.h @@ -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 8b1649d..d4d7b7b 100644 --- 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); } } diff --git a/redirects.c b/redirects.c index b42201f..3e6902d 100644 --- a/redirects.c +++ b/redirects.c @@ -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++); } diff --git a/redirects.h b/redirects.h index 4436f52..14f90bb 100644 --- a/redirects.h +++ b/redirects.h @@ -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 8452a40..e6af62e 100644 --- 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 38d0df7..44a40f2 100644 --- 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 846e430..2a230c5 100644 --- 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 bda96ab..63ed3a5 100644 --- 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); -- 2.25.1