X-Git-Url: http://git.openwrt.org/?a=blobdiff_plain;f=snats.c;h=e392e08692e884019094707a39182fa4c8728c17;hb=d44f4189b6a6eb5e943f11dfff0246d3ac0e9087;hp=0f7d851bc8e3153512d1a9bc9cbfda4c3918af11;hpb=1d0bd45db042c9dd916f15a5f4e3e5a2f63d0616;p=project%2Ffirewall3.git diff --git a/snats.c b/snats.c index 0f7d851..e392e08 100644 --- a/snats.c +++ b/snats.c @@ -1,7 +1,7 @@ /* * firewall3 - 3rd OpenWrt UCI firewall implementation * - * Copyright (C) 2014 Jo-Philipp Wich + * Copyright (C) 2014 Jo-Philipp Wich * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -126,21 +126,19 @@ fw3_load_snats(struct fw3_state *state, struct uci_package *p, struct blob_attr struct uci_section *s; struct uci_element *e; struct fw3_snat *snat, *n; - struct blob_attr *rule, *opt; + struct blob_attr *entry, *opt; unsigned rem, orem; INIT_LIST_HEAD(&state->snats); - blob_for_each_attr(rule, a, rem) { + blob_for_each_attr(entry, a, rem) { const char *type = NULL; const char *name = "ubus rule"; - blobmsg_for_each_attr(opt, rule, orem) - if (!strcmp(blobmsg_name(opt), "type")) - type = blobmsg_get_string(opt); - else if (!strcmp(blobmsg_name(opt), "name")) - name = blobmsg_get_string(opt); - if (!type || strcmp(type, "nat")) + if (!fw3_attr_parse_name_type(entry, &name, &type)) + continue; + + if (strcmp(type, "nat")) continue; if (!(snat = alloc_snat(state))) @@ -148,7 +146,7 @@ fw3_load_snats(struct fw3_state *state, struct uci_package *p, struct blob_attr if (!fw3_parse_blob_options(snat, fw3_snat_opts, rule, name)) { - fprintf(stderr, "%s skipped due to invalid options\n", name); + warn_section("nat", snat, NULL, "skipped due to invalid options"); fw3_free_snat(snat); continue; } @@ -252,10 +250,7 @@ fw3_load_snats(struct fw3_state *state, struct uci_package *p, struct blob_attr } if (snat->_src) - { set(snat->_src->flags, FW3_FAMILY_V4, FW3_FLAG_SNAT); - snat->_src->conntrack = true; - } } } @@ -265,7 +260,7 @@ append_chain(struct fw3_ipt_rule *r, struct fw3_snat *snat) if (snat->_src) fw3_ipt_rule_append(r, "zone_%s_postrouting", snat->src.name); else - fw3_ipt_rule_append(r, "delegate_postrouting"); + fw3_ipt_rule_append(r, "POSTROUTING"); } static void