X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fnetifd.git;a=blobdiff_plain;f=interface.c;h=7b18cef58a47d8aed15c0e568652a54b1d8d2ae7;hp=26383426ea56ff61e41dc38ed12015c576ddf5b1;hb=b998775b925330725e547af8d33394db0d638f7a;hpb=245527193e90906451be35c2b8e972b8712ea6ab diff --git a/interface.c b/interface.c index 2638342..7b18cef 100644 --- a/interface.c +++ b/interface.c @@ -75,6 +75,8 @@ const struct uci_blob_param_list interface_attr_list = { static void set_config_state(struct interface *iface, enum interface_config_state s); +static void +interface_event(struct interface *iface, enum interface_event ev); static void interface_error_flush(struct interface *iface) @@ -187,6 +189,9 @@ interface_add_data(struct interface *iface, const struct blob_attr *data) } n = calloc(1, sizeof(*n) + len); + if (!n) + return UBUS_STATUS_UNKNOWN_ERROR; + memcpy(n->data, data, len); n->node.key = blobmsg_name(n->data); avl_insert(&iface->data, &n->node); @@ -195,6 +200,25 @@ interface_add_data(struct interface *iface, const struct blob_attr *data) return 0; } +int interface_parse_data(struct interface *iface, const struct blob_attr *attr) +{ + struct blob_attr *cur; + int rem, ret; + + iface->updated = 0; + + blob_for_each_attr(cur, attr, rem) { + ret = interface_add_data(iface, cur); + if (ret) + return ret; + } + + if (iface->updated && iface->state == IFS_UP) + interface_event(iface, IFEV_UPDATE); + + return 0; +} + static void interface_event(struct interface *iface, enum interface_event ev) {