Initial support for "config nat" rules - this allows configuring zone-independant...
[project/firewall3.git] / redirects.c
index 81e93e3..a21998b 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * firewall3 - 3rd OpenWrt UCI firewall implementation
  *
- *   Copyright (C) 2013 Jo-Philipp Wich <jow@openwrt.org>
+ *   Copyright (C) 2013-2014 Jo-Philipp Wich <jow@openwrt.org>
  *
  * Permission to use, copy, modify, and/or distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -305,7 +305,7 @@ fw3_load_redirects(struct fw3_state *state, struct uci_package *p)
                        warn_elem(e, "has no target specified, defaulting to DNAT");
                        redir->target = FW3_FLAG_DNAT;
                }
-               else if (redir->target < FW3_FLAG_DNAT)
+               else if (redir->target < FW3_FLAG_DNAT || redir->target > FW3_FLAG_SNAT)
                {
                        warn_elem(e, "has invalid target specified, defaulting to DNAT");
                        redir->target = FW3_FLAG_DNAT;
@@ -427,34 +427,6 @@ set_target_nat(struct fw3_ipt_rule *r, struct fw3_redirect *redir)
                set_snat_dnat(r, redir->target, &redir->ip_dest, &redir->port_dest);
 }
 
-//static void
-//append_chain_filter(struct fw3_ipt_rule *r, struct fw3_redirect *redir)
-//{
-//     if (redir->target == FW3_FLAG_DNAT)
-//     {
-//             if (redir->local)
-//                     fw3_ipt_rule_append(r, "zone_%s_input", redir->src.name);
-//             else
-//                     fw3_ipt_rule_append(r, "zone_%s_forward", redir->src.name);
-//     }
-//     else
-//     {
-//             if (redir->src.set && !redir->src.any)
-//                     fw3_ipt_rule_append(r, "zone_%s_forward", redir->src.name);
-//             else
-//                     fw3_ipt_rule_append(r, "delegate_forward");
-//     }
-//}
-//
-//static void
-//set_target_filter(struct fw3_ipt_rule *r, struct fw3_redirect *redir)
-//{
-//     if (redir->local)
-//             fw3_ipt_rule_extra(r, "-m conntrack --ctstate DNAT");
-//
-//     fw3_ipt_rule_target(r, "ACCEPT");
-//}
-
 static void
 set_comment(struct fw3_ipt_rule *r, const char *name, int num, bool ref)
 {
@@ -510,25 +482,6 @@ print_redirect(struct fw3_ipt_handle *h, struct fw3_state *state,
                append_chain_nat(r, redir);
                break;
 
-       case FW3_TABLE_FILTER:
-               //src = &redir->ip_src;
-               //dst = &redir->ip_redir;
-               //spt = &redir->port_src;
-               //dpt = &redir->port_redir;
-               //
-               //r = fw3_ipt_rule_create(h, proto, NULL, NULL, src, dst);
-               //fw3_ipt_rule_sport_dport(r, spt, dpt);
-               //fw3_ipt_rule_mac(r, mac);
-               //fw3_ipt_rule_ipset(r, &redir->ipset);
-               //fw3_ipt_rule_limit(r, &redir->limit);
-               //fw3_ipt_rule_time(r, &redir->time);
-               //fw3_ipt_rule_mark(r, &redir->mark);
-               //set_target_filter(r, redir);
-               //fw3_ipt_rule_extra(r, redir->extra);
-               //set_comment(r, redir->name, num, false);
-               //append_chain_filter(r, redir);
-               break;
-
        default:
                break;
        }
@@ -562,16 +515,6 @@ print_reflection(struct fw3_ipt_handle *h, struct fw3_state *state,
                fw3_ipt_rule_replace(r, "zone_%s_postrouting", redir->dest.name);
                break;
 
-       //case FW3_TABLE_FILTER:
-       //      r = fw3_ipt_rule_create(h, proto, NULL, NULL, ia, &redir->ip_redir);
-       //      fw3_ipt_rule_sport_dport(r, NULL, &redir->port_redir);
-       //      fw3_ipt_rule_limit(r, &redir->limit);
-       //      fw3_ipt_rule_time(r, &redir->time);
-       //      set_comment(r, redir->name, num, true);
-       //      fw3_ipt_rule_target(r, "zone_%s_dest_ACCEPT", redir->dest.name);
-       //      fw3_ipt_rule_replace(r, "zone_%s_forward", redir->dest.name);
-       //      break;
-
        default:
                break;
        }