diff options
author | Felix Fietkau <nbd@openwrt.org> | 2011-10-13 14:58:51 +0200 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2011-10-13 14:58:51 +0200 |
commit | 5e5cd11724f6cf86edc5796e6b805573c767f757 (patch) | |
tree | 165d7208a39bb38c27884efbfddc70462eb57f59 /interface-ip.c | |
parent | 545f0fad20b68957e245b3b05ace935cd1089726 (diff) |
add functions for adding dns servers to the proto list, hook them up in proto-static.c
Diffstat (limited to 'interface-ip.c')
-rw-r--r-- | interface-ip.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/interface-ip.c b/interface-ip.c index d2e1461..c0a1bb9 100644 --- a/interface-ip.c +++ b/interface-ip.c @@ -79,6 +79,44 @@ interface_update_proto_route(struct vlist_tree *tree, } } +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) { |