X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fnetifd.git;a=blobdiff_plain;f=tunnel.c;fp=tunnel.c;h=aa60019c18102046bc6cad4f1202aecf29b33701;hp=3ef5086b48395e71d04e9f6cbd867a4f2acb1a40;hb=e757e7d352a244e20a0c32fec96b35e5893d62ea;hpb=c397d2788ffd27904ab89e437432b481c6e7e806 diff --git a/tunnel.c b/tunnel.c index 3ef5086..aa60019 100644 --- a/tunnel.c +++ b/tunnel.c @@ -40,6 +40,27 @@ tunnel_set_state(struct device *dev, bool up) return ret; } +static enum dev_change_type +tunnel_reload(struct device *dev, struct blob_attr *attr) +{ + struct blob_attr *tb_dev[__DEV_ATTR_MAX]; + const struct uci_blob_param_list *cfg = dev->type->config_params; + + if (uci_blob_check_equal(dev->config, attr, cfg)) + return DEV_CONFIG_NO_CHANGE; + + if (attr) { + memset(tb_dev, 0, sizeof(tb_dev)); + + blobmsg_parse(device_attr_list.params, __DEV_ATTR_MAX, tb_dev, + blob_data(attr), blob_len(attr)); + } + + device_init_settings(dev, tb_dev); + + return DEV_CONFIG_RESTART; +} + static struct device * tunnel_create(const char *name, struct blob_attr *attr) { @@ -51,6 +72,7 @@ tunnel_create(const char *name, struct blob_attr *attr) device_init(dev, &tunnel_device_type, name); tun->set_state = dev->set_state; dev->set_state = tunnel_set_state; + device_set_config(dev, &tunnel_device_type, attr); device_set_present(dev, true); return dev; @@ -67,7 +89,7 @@ tunnel_free(struct device *dev) const struct device_type tunnel_device_type = { .name = "IP tunnel", .config_params = &tunnel_attr_list, - + .reload = tunnel_reload, .create = tunnel_create, .free = tunnel_free, };