8 device_state_cb set_state;
12 tunnel_set_state(struct device *dev, bool up)
14 struct tunnel *tun = container_of(dev, struct tunnel, dev);
18 ret = system_add_ip_tunnel(dev->ifname, dev->config);
23 ret = tun->set_state(dev, up);
25 system_del_ip_tunnel(dev->ifname);
30 static struct device *
31 tunnel_create(const char *name, struct blob_attr *attr)
36 tun = calloc(1, sizeof(*tun));
38 device_init(dev, &tunnel_device_type, name);
39 tun->set_state = dev->set_state;
40 dev->set_state = tunnel_set_state;
41 device_set_present(dev, true);
47 tunnel_free(struct device *dev)
49 struct tunnel *tun = container_of(dev, struct tunnel, dev);
54 const struct device_type tunnel_device_type = {
56 .config_params = &tunnel_attr_list,
58 .create = tunnel_create,