diff options
-rw-r--r-- | options.c | 19 | ||||
-rw-r--r-- | options.h | 2 | ||||
-rw-r--r-- | rules.c | 7 | ||||
-rw-r--r-- | snats.c | 7 |
4 files changed, 23 insertions, 12 deletions
@@ -981,7 +981,7 @@ fw3_parse_options(void *s, const struct fw3_option *opts, bool fw3_parse_blob_options(void *s, const struct fw3_option *opts, - struct blob_attr *a) + struct blob_attr *a, const char *name) { char *p, *v, buf[16]; bool known; @@ -1007,7 +1007,9 @@ fw3_parse_blob_options(void *s, const struct fw3_option *opts, { if (!opt->elem_size) { - fprintf(stderr, "%s must not be a list\n", opt->name); + fprintf(stderr, "%s: '%s' must not be a list\n", + name, opt->name); + valid = false; } else @@ -1025,7 +1027,8 @@ fw3_parse_blob_options(void *s, const struct fw3_option *opts, if (!opt->parse(dest, v, true)) { - fprintf(stderr, "%s has invalid value '%s'\n", opt->name, v); + fprintf(stderr, "%s: '%s' has invalid value '%s'\n", + name, opt->name, v); valid = false; continue; } @@ -1048,7 +1051,8 @@ fw3_parse_blob_options(void *s, const struct fw3_option *opts, { if (!opt->parse((char *)s + opt->offset, v, false)) { - fprintf(stderr, "%s has invalid value '%s'\n", opt->name, v); + fprintf(stderr, "%s: '%s' has invalid value '%s'\n", + name, opt->name, v); valid = false; } } @@ -1060,7 +1064,8 @@ fw3_parse_blob_options(void *s, const struct fw3_option *opts, { if (!opt->parse(dest, p, true)) { - fprintf(stderr, "%s has invalid value '%s'\n", opt->name, p); + fprintf(stderr, "%s: '%s' has invalid value '%s'\n", + name, opt->name, p); valid = false; continue; } @@ -1072,8 +1077,8 @@ fw3_parse_blob_options(void *s, const struct fw3_option *opts, break; } - if (!known) - fprintf(stderr, "%s is unknown\n", blobmsg_name(o)); + if (!known && strcmp(blobmsg_name(o), "type")) + fprintf(stderr, "%s: '%s' is unknown\n", name, blobmsg_name(o)); } return valid; @@ -561,7 +561,7 @@ bool fw3_parse_direction(void *ptr, const char *val, bool is_list); bool fw3_parse_options(void *s, const struct fw3_option *opts, struct uci_section *section); bool fw3_parse_blob_options(void *s, const struct fw3_option *opts, - struct blob_attr *a); + struct blob_attr *a, const char *name); const char * fw3_address_to_string(struct fw3_address *address, bool allow_invert, bool as_cidr); @@ -110,9 +110,12 @@ fw3_load_rules(struct fw3_state *state, struct uci_package *p, blob_for_each_attr(entry, a, rem) { const char *type = NULL; + const char *name = "ubus rule"; blobmsg_for_each_attr(opt, entry, 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, "rule")) continue; @@ -120,9 +123,9 @@ fw3_load_rules(struct fw3_state *state, struct uci_package *p, if (!(rule = alloc_rule(state))) continue; - if (!fw3_parse_blob_options(rule, fw3_rule_opts, entry)) + if (!fw3_parse_blob_options(rule, fw3_rule_opts, entry, name)) { - fprintf(stderr, "ubus section skipped due to invalid options\n"); + fprintf(stderr, "%s skipped due to invalid options\n", name); fw3_free_rule(rule); continue; } @@ -133,9 +133,12 @@ fw3_load_snats(struct fw3_state *state, struct uci_package *p, struct blob_attr blob_for_each_attr(rule, 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")) continue; @@ -143,9 +146,9 @@ fw3_load_snats(struct fw3_state *state, struct uci_package *p, struct blob_attr if (!(snat = alloc_snat(state))) continue; - if (!fw3_parse_blob_options(snat, fw3_snat_opts, rule)) + if (!fw3_parse_blob_options(snat, fw3_snat_opts, rule, name)) { - fprintf(stderr, "ubus section skipped due to invalid options\n"); + fprintf(stderr, "%s skipped due to invalid options\n", name); fw3_free_snat(snat); continue; } |