X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fodhcpd.git;a=blobdiff_plain;f=src%2Fconfig.c;h=835db13a7e5e09763bfe87660d8ef2936135b7d0;hp=35d8af7d23f7970d2a7aa10cbf653091a01a6e33;hb=de90ff1b27ef8e41c819d40d80f0fd6d8be86ded;hpb=3462b32b6e0e864acbe79e5c91b2c6a50742013f diff --git a/src/config.c b/src/config.c index 35d8af7..835db13 100644 --- a/src/config.c +++ b/src/config.c @@ -30,6 +30,7 @@ enum { IFACE_ATTR_DHCPV4, IFACE_ATTR_DHCPV6, IFACE_ATTR_NDP, + IFACE_ATTR_ROUTER, IFACE_ATTR_DNS, IFACE_ATTR_DOMAIN, IFACE_ATTR_FILTER_CLASS, @@ -42,6 +43,7 @@ enum { IFACE_ATTR_PD_CER, IFACE_ATTR_NDPROXY_ROUTING, IFACE_ATTR_NDPROXY_SLAVE, + IFACE_ATTR_NDPROXY_STATIC, IFACE_ATTR_MAX }; @@ -60,6 +62,7 @@ static const struct blobmsg_policy iface_attrs[IFACE_ATTR_MAX] = { [IFACE_ATTR_DHCPV4] = { .name = "dhcpv4", .type = BLOBMSG_TYPE_STRING }, [IFACE_ATTR_DHCPV6] = { .name = "dhcpv6", .type = BLOBMSG_TYPE_STRING }, [IFACE_ATTR_NDP] = { .name = "ndp", .type = BLOBMSG_TYPE_STRING }, + [IFACE_ATTR_ROUTER] = { .name = "router", .type = BLOBMSG_TYPE_ARRAY }, [IFACE_ATTR_DNS] = { .name = "dns", .type = BLOBMSG_TYPE_ARRAY }, [IFACE_ATTR_DOMAIN] = { .name = "domain", .type = BLOBMSG_TYPE_ARRAY }, [IFACE_ATTR_FILTER_CLASS] = { .name = "filter_class", .type = BLOBMSG_TYPE_STRING }, @@ -72,12 +75,14 @@ static const struct blobmsg_policy iface_attrs[IFACE_ATTR_MAX] = { [IFACE_ATTR_RA_PREFERENCE] = { .name = "ra_preference", .type = BLOBMSG_TYPE_STRING }, [IFACE_ATTR_NDPROXY_ROUTING] = { .name = "ndproxy_routing", .type = BLOBMSG_TYPE_BOOL }, [IFACE_ATTR_NDPROXY_SLAVE] = { .name = "ndproxy_slave", .type = BLOBMSG_TYPE_BOOL }, + [IFACE_ATTR_NDPROXY_STATIC] = { .name = "ndproxy_static", .type = BLOBMSG_TYPE_ARRAY }, }; static const struct uci_blob_param_info iface_attr_info[IFACE_ATTR_MAX] = { [IFACE_ATTR_UPSTREAM] = { .type = BLOBMSG_TYPE_STRING }, [IFACE_ATTR_DNS] = { .type = BLOBMSG_TYPE_STRING }, [IFACE_ATTR_DOMAIN] = { .type = BLOBMSG_TYPE_STRING }, + [IFACE_ATTR_NDPROXY_STATIC] = { .type = BLOBMSG_TYPE_STRING }, }; const struct uci_blob_param_list interface_attr_list = { @@ -148,6 +153,8 @@ static void clean_interface(struct interface *iface) free(iface->dns); free(iface->search); free(iface->upstream); + free(iface->static_ndp); + free(iface->dhcpv4_router); free(iface->dhcpv4_dns); free(iface->dhcpv6_raw); free(iface->filter_class); @@ -405,6 +412,28 @@ int config_parse_interface(void *data, size_t len, const char *name, bool overwr goto err; } + if ((c = tb[IFACE_ATTR_ROUTER])) { + struct blob_attr *cur; + unsigned rem; + + blobmsg_for_each_attr(cur, c, rem) { + if (blobmsg_type(cur) != BLOBMSG_TYPE_STRING || !blobmsg_check_attr(cur, NULL)) + continue; + + struct in_addr addr4; + if (inet_pton(AF_INET, blobmsg_get_string(cur), &addr4) == 1) { + iface->dhcpv4_router = realloc(iface->dhcpv4_router, + (++iface->dhcpv4_router_cnt) * sizeof(*iface->dhcpv4_router)); + if (!iface->dhcpv4_router) + goto err; + + iface->dhcpv4_router[iface->dhcpv4_router_cnt - 1] = addr4; + } else { + goto err; + } + } + } + if ((c = tb[IFACE_ATTR_DNS])) { struct blob_attr *cur; unsigned rem; @@ -515,6 +544,27 @@ int config_parse_interface(void *data, size_t len, const char *name, bool overwr if ((c = tb[IFACE_ATTR_NDPROXY_SLAVE])) iface->external = blobmsg_get_bool(c); + if ((c = tb[IFACE_ATTR_NDPROXY_STATIC])) { + struct blob_attr *cur; + unsigned rem; + + blobmsg_for_each_attr(cur, c, rem) { + if (blobmsg_type(cur) != BLOBMSG_TYPE_STRING || !blobmsg_check_attr(cur, NULL)) + continue; + + int len = blobmsg_data_len(cur); + iface->static_ndp = realloc(iface->static_ndp, iface->static_ndp_len + len); + if (!iface->static_ndp) + goto err; + + if (iface->static_ndp_len) + iface->static_ndp[iface->static_ndp_len - 1] = ' '; + + memcpy(&iface->static_ndp[iface->static_ndp_len], blobmsg_get_string(cur), len); + iface->static_ndp_len += len; + } + } + return 0; err: