X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fnetifd.git;a=blobdiff_plain;f=proto.c;h=29dd4296dd367d84b1c9e5f6470ee8b311fb59d4;hp=dfdedcb028fb4a613ddc3d6ef919fac2bdfd7f96;hb=f5ca090c260a74fd3576f79ffb8799e8c20e3878;hpb=285039a8783654439d9c0e29aac16e3893e2444b diff --git a/proto.c b/proto.c index dfdedcb..29dd429 100644 --- a/proto.c +++ b/proto.c @@ -19,6 +19,7 @@ enum { OPT_GATEWAY, OPT_IP6GW, OPT_DNS, + OPT_DNS_SEARCH, __OPT_MAX, }; @@ -29,6 +30,7 @@ static const struct blobmsg_policy proto_ip_attributes[__OPT_MAX] = { [OPT_GATEWAY] = { .name = "gateway", .type = BLOBMSG_TYPE_STRING }, [OPT_IP6GW] = { .name = "ip6gw", .type = BLOBMSG_TYPE_STRING }, [OPT_DNS] = { .name = "dns", .type = BLOBMSG_TYPE_ARRAY }, + [OPT_DNS_SEARCH] = { .name = "dns_search", .type = BLOBMSG_TYPE_ARRAY }, }; static const union config_param_info proto_ip_attr_info[__OPT_MAX] = { @@ -121,7 +123,7 @@ proto_parse_ip_addr_string(const char *str, bool v6, int mask) } static bool -parse_addr(struct interface *iface, const char *str, bool v6, int mask) +parse_addr(struct interface *iface, const char *str, bool v6, int mask, bool ext) { struct device_addr *addr; @@ -130,20 +132,27 @@ parse_addr(struct interface *iface, const char *str, bool v6, int mask) interface_add_error(iface, "proto", "INVALID_ADDRESS", &str, 1); return false; } + + if (ext) + addr->flags |= DEVADDR_EXTERNAL; + vlist_add(&iface->proto_ip.addr, &addr->node); return true; } static int -parse_address_option(struct interface *iface, struct blob_attr *attr, bool v6, int netmask) +parse_address_option(struct interface *iface, struct blob_attr *attr, bool v6, int netmask, bool ext) { struct blob_attr *cur; int n_addr = 0; int rem; blobmsg_for_each_attr(cur, attr, rem) { + if (blobmsg_type(cur) != BLOBMSG_TYPE_STRING) + return -1; + n_addr++; - if (!parse_addr(iface, blobmsg_data(cur), v6, netmask)) + if (!parse_addr(iface, blobmsg_data(cur), v6, netmask, ext)) return -1; } @@ -173,7 +182,7 @@ parse_gateway_option(struct interface *iface, struct blob_attr *attr, bool v6) } int -proto_apply_ip_settings(struct interface *iface, struct blob_attr *attr) +proto_apply_ip_settings(struct interface *iface, struct blob_attr *attr, bool ext) { struct blob_attr *tb[__OPT_MAX]; const char *error; @@ -191,10 +200,10 @@ proto_apply_ip_settings(struct interface *iface, struct blob_attr *attr) } if (tb[OPT_IPADDR]) - n_v4 = parse_address_option(iface, tb[OPT_IPADDR], false, netmask); + n_v4 = parse_address_option(iface, tb[OPT_IPADDR], false, netmask, ext); if (tb[OPT_IP6ADDR]) - n_v6 = parse_address_option(iface, tb[OPT_IP6ADDR], true, netmask); + n_v6 = parse_address_option(iface, tb[OPT_IP6ADDR], true, netmask, ext); if (!n_v4 && !n_v6) { error = "NO_ADDRESS"; @@ -217,6 +226,9 @@ proto_apply_ip_settings(struct interface *iface, struct blob_attr *attr) if (tb[OPT_DNS]) interface_add_dns_server_list(&iface->proto_ip, tb[OPT_DNS]); + if (tb[OPT_DNS_SEARCH]) + interface_add_dns_search_list(&iface->proto_ip, tb[OPT_DNS_SEARCH]); + return 0; error: