proto: move the dns search option handling to the core
authorFelix Fietkau <nbd@openwrt.org>
Sun, 26 Feb 2012 16:20:00 +0000 (17:20 +0100)
committerFelix Fietkau <nbd@openwrt.org>
Sun, 26 Feb 2012 16:20:00 +0000 (17:20 +0100)
proto-shell.c
proto.c

index f0738a9..7aecf84 100644 (file)
@@ -234,7 +234,6 @@ enum {
        NOTIFY_ADDR_EXT,
        NOTIFY_ROUTES,
        NOTIFY_ROUTES6,
-       NOTIFY_DNS_SEARCH,
        __NOTIFY_LAST
 };
 
@@ -250,13 +249,11 @@ static const struct blobmsg_policy notify_attr[__NOTIFY_LAST] = {
        [NOTIFY_ADDR_EXT] = { .name = "address-external", .type = BLOBMSG_TYPE_BOOL },
        [NOTIFY_ROUTES] = { .name = "routes", .type = BLOBMSG_TYPE_ARRAY },
        [NOTIFY_ROUTES6] = { .name = "routes6", .type = BLOBMSG_TYPE_ARRAY },
-       [NOTIFY_DNS_SEARCH] = { .name = "dns_search", .type = BLOBMSG_TYPE_ARRAY },
 };
 
 static int
 proto_shell_update_link(struct proto_shell_state *state, struct blob_attr *data, struct blob_attr **tb)
 {
-       struct interface_ip_settings *ip;
        struct interface *iface = state->proto.iface;
        struct blob_attr *cur;
        int dev_create = 1;
@@ -291,7 +288,6 @@ proto_shell_update_link(struct proto_shell_state *state, struct blob_attr *data,
                device_claim(&state->l3_dev);
        }
 
-       ip = &iface->proto_ip;
        interface_update_start(iface);
        proto_apply_ip_settings(iface, data, addr_ext);
 
@@ -301,9 +297,6 @@ proto_shell_update_link(struct proto_shell_state *state, struct blob_attr *data,
        if ((cur = tb[NOTIFY_ROUTES6]) != NULL)
                proto_shell_parse_route_list(state->proto.iface, cur, true);
 
-       if ((cur = tb[NOTIFY_DNS_SEARCH]) != NULL)
-               interface_add_dns_search_list(ip, cur);
-
        interface_update_complete(state->proto.iface);
 
        state->proto.proto_event(&state->proto, IFPEV_UP);
diff --git a/proto.c b/proto.c
index ce56a66..29dd429 100644 (file)
--- 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] = {
@@ -224,6 +226,9 @@ proto_apply_ip_settings(struct interface *iface, struct blob_attr *attr, bool ex
        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: