X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fodhcpd.git;a=blobdiff_plain;f=src%2Fconfig.c;h=c3e2437901f7db340a8ca93d5eeec3382b2a7a68;hp=7e23eb28893ed8e1c9af4656261f539ff5e4592e;hb=HEAD;hpb=cf29925b29a4e4e38ab88573f12ec075eacb3d22 diff --git a/src/config.c b/src/config.c index 7e23eb2..c3e2437 100644 --- a/src/config.c +++ b/src/config.c @@ -62,6 +62,7 @@ enum { IFACE_ATTR_PD_CER, IFACE_ATTR_NDPROXY_ROUTING, IFACE_ATTR_NDPROXY_SLAVE, + IFACE_ATTR_PREFIX_FILTER, IFACE_ATTR_MAX }; @@ -104,6 +105,7 @@ static const struct blobmsg_policy iface_attrs[IFACE_ATTR_MAX] = { [IFACE_ATTR_RA_MTU] = { .name = "ra_mtu", .type = BLOBMSG_TYPE_INT32 }, [IFACE_ATTR_NDPROXY_ROUTING] = { .name = "ndproxy_routing", .type = BLOBMSG_TYPE_BOOL }, [IFACE_ATTR_NDPROXY_SLAVE] = { .name = "ndproxy_slave", .type = BLOBMSG_TYPE_BOOL }, + [IFACE_ATTR_PREFIX_FILTER] = { .name = "prefix_filter", .type = BLOBMSG_TYPE_STRING }, }; static const struct uci_blob_param_info iface_attr_info[IFACE_ATTR_MAX] = { @@ -184,7 +186,7 @@ static int mkdir_p(char *dir, mode_t mask) return 0; if (ret) - syslog(LOG_ERR, "mkdir(%s, %d) failed: %s\n", dir, mask, strerror(errno)); + syslog(LOG_ERR, "mkdir(%s, %d) failed: %m\n", dir, mask); return ret; } @@ -239,7 +241,9 @@ static void close_interface(struct interface *iface) router_setup_interface(iface, false); dhcpv6_setup_interface(iface, false); ndp_setup_interface(iface, false); +#ifdef DHCPV4_SUPPORT dhcpv4_setup_interface(iface, false); +#endif clean_interface(iface); free(iface->addr4); @@ -718,6 +722,23 @@ 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_PREFIX_FILTER])) { + const char *str = blobmsg_get_string(c); + char *astr = malloc(strlen(str) + 1); + char *delim; + int l; + if (!astr || !strcpy(astr, str) || + (delim = strchr(astr, '/')) == NULL || (*(delim++) = 0) || + sscanf(delim, "%i", &l) == 0 || l > 128 || + inet_pton(AF_INET6, astr, &iface->pio_filter_addr) == 0) { + iface->pio_filter_length = 0; + } else { + iface->pio_filter_length = l; + } + if (astr) + free(astr); + } + return 0; err: @@ -846,7 +867,9 @@ void odhcpd_reload(void) router_setup_interface(i, !i->ignore || i->ra != MODE_DISABLED); dhcpv6_setup_interface(i, !i->ignore || i->dhcpv6 != MODE_DISABLED); ndp_setup_interface(i, !i->ignore || i->ndp != MODE_DISABLED); +#ifdef DHCPV4_SUPPORT dhcpv4_setup_interface(i, !i->ignore || i->dhcpv4 != MODE_DISABLED); +#endif } else close_interface(i); }