option ipaddr 192.168.1.1
option netmask 255.255.255.0
option gateway 192.168.1.2
+ option dns '192.168.1.5 192.168.1.6'
config interface wan
option proto pppoe
}
}
+void
+interface_add_dns_server(struct interface *iface, const char *str)
+{
+ struct dns_server *s;
+
+ s = calloc(1, sizeof(*s));
+ s->af = AF_INET;
+ if (inet_pton(s->af, str, &s->addr.in))
+ goto add;
+
+ s->af = AF_INET6;
+ if (inet_pton(s->af, str, &s->addr.in))
+ goto add;
+
+ free(s);
+ return;
+
+add:
+ list_add_tail(&s->list, &iface->proto_dns_servers);
+}
+
+void
+interface_add_dns_server_list(struct interface *iface, struct blob_attr *list)
+{
+ struct blob_attr *cur;
+ int rem;
+
+ blobmsg_for_each_attr(cur, list, rem) {
+ if (blobmsg_type(cur) != BLOBMSG_TYPE_STRING)
+ continue;
+
+ if (!blobmsg_check_attr(cur, NULL))
+ continue;
+
+ interface_add_dns_server(iface, blobmsg_data(cur));
+ }
+}
+
static void
interface_clear_dns_servers(struct interface *iface)
{
};
void interface_ip_init(struct interface *iface);
+void interface_add_dns_server(struct interface *iface, const char *str);
+void interface_add_dns_server_list(struct interface *iface, struct blob_attr *list);
void interface_clear_dns(struct interface *iface);
void interface_write_resolv_conf(void);
OPT_NETMASK,
OPT_GATEWAY,
OPT_IP6GW,
+ OPT_DNS,
__OPT_MAX,
};
[OPT_NETMASK] = { .name = "netmask", .type = BLOBMSG_TYPE_STRING },
[OPT_GATEWAY] = { .name = "gateway", .type = BLOBMSG_TYPE_STRING },
[OPT_IP6GW] = { .name = "ip6gw", .type = BLOBMSG_TYPE_STRING },
+ [OPT_DNS] = { .name = "dns", .type = BLOBMSG_TYPE_ARRAY },
};
static const union config_param_info static_attr_info[__OPT_MAX] = {
[OPT_IPADDR] = { .type = BLOBMSG_TYPE_STRING },
[OPT_IP6ADDR] = { .type = BLOBMSG_TYPE_STRING },
+ [OPT_DNS] = { .type = BLOBMSG_TYPE_STRING },
};
static const struct config_param_list static_attr_list = {
goto out;
}
+ if (tb[OPT_DNS])
+ interface_add_dns_server_list(iface, tb[OPT_DNS]);
+
return 0;
error: