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;
{
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
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;
}
{
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;
}
}
{
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;
}
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;
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);
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;
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;
}
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;
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;
}