proto-shell: add dns server support
authorFelix Fietkau <nbd@openwrt.org>
Thu, 13 Oct 2011 13:03:29 +0000 (15:03 +0200)
committerFelix Fietkau <nbd@openwrt.org>
Thu, 13 Oct 2011 13:03:29 +0000 (15:03 +0200)
dummy/netifd-proto.sh
dummy/proto/ppp.sh
interface-ip.c
proto-shell.c

index c50d776a6b0f4fa7d8a036709a0a9dcfc1e0a074..ae05b9c71c4a58d5c22401269720d6d735f53f4e 100755 (executable)
@@ -53,6 +53,12 @@ proto_init_update() {
        [ -n "$3" ] && json_add_boolean "address-external" "$external"
 }
 
+proto_add_dns_server() {
+       local address="$1"
+
+       jshn_append PROTO_DNS "$address"
+}
+
 proto_add_ipv4_address() {
        local address="$1"
        local mask="$2"
@@ -125,6 +131,7 @@ proto_send_update() {
        _proto_push_array "ip6addr" "$PROTO_IP6ADDR" _proto_push_ip
        _proto_push_array "route" "$PROTO_ROUTE" _proto_push_route
        _proto_push_array "route6" "$PROTO_ROUTE6" _proto_push_route
+       _proto_push_array "dns" "$PROTO_DNS" _proto_push_ip
        _proto_notify
 }
 
index 13c4ebb2023351bebb447d14c925dcda048265fa..e7b9839332aaed005f2ca1e2c1a574680efa1fb3 100755 (executable)
@@ -38,6 +38,7 @@ pppoe_setup() {
        echo "pppoe_setup($1, $2), username=$username, password=$password"
        proto_init_update ppp0 1
        proto_add_ipv4_address "192.168.2.1" 32
+       proto_add_dns_server "192.168.2.2"
        proto_send_update "$1"
        proto_run_command sleep 10
 }
index c0a1bb961665033c700e0659159f726f3fd72411..8dae80d1883189c838193b09bab33a1f05007d3e 100644 (file)
@@ -97,6 +97,8 @@ interface_add_dns_server(struct interface *iface, const char *str)
        return;
 
 add:
+       D(INTERFACE, "Add IPv%c DNS server: %s\n",
+         s->af == AF_INET6 ? '6' : '4', str);
        list_add_tail(&s->list, &iface->proto_dns_servers);
 }
 
index 32a30161f7ff5d9473398af475f6eee0e17d6ee3..3ed4b8e738de79d965a0f70d1201460dbbc0d405 100644 (file)
@@ -303,6 +303,7 @@ enum {
        NOTIFY_IP6ADDR,
        NOTIFY_ROUTES,
        NOTIFY_ROUTES6,
+       NOTIFY_DNS,
        __NOTIFY_LAST
 };
 
@@ -316,6 +317,7 @@ static const struct blobmsg_policy notify_attr[__NOTIFY_LAST] = {
        [NOTIFY_IP6ADDR] = { .name = "ip6addr", .type = BLOBMSG_TYPE_ARRAY },
        [NOTIFY_ROUTES] = { .name = "routes", .type = BLOBMSG_TYPE_ARRAY },
        [NOTIFY_ROUTES6] = { .name = "routes6", .type = BLOBMSG_TYPE_ARRAY },
+       [NOTIFY_DNS] = { .name = "dns", .type = BLOBMSG_TYPE_ARRAY },
 };
 
 static int
@@ -359,6 +361,9 @@ proto_shell_update_link(struct proto_shell_state *state, struct blob_attr **tb)
        if ((cur = tb[NOTIFY_ROUTES6]) != NULL)
                proto_shell_parse_route_list(state->proto.iface, cur, true);
 
+       if ((cur = tb[NOTIFY_DNS]) != NULL)
+               interface_add_dns_server_list(state->proto.iface, cur);
+
        return 0;
 }