X-Git-Url: https://git.archive.openwrt.org/?p=project%2Fnetifd.git;a=blobdiff_plain;f=ubus.c;h=af5ba6815d5c5dca60d65cff5a7072a97de47720;hp=ce82a520c94417263b4d44fb179e7090dce4d809;hb=4bdcb2edfecd9a955d1eed9fcf8d620dbd5cebf8;hpb=1b48b50c9669ecf3fdd3f50d662fbfd18b971014 diff --git a/ubus.c b/ubus.c index ce82a52..af5ba68 100644 --- a/ubus.c +++ b/ubus.c @@ -380,10 +380,32 @@ netifd_iface_remove(struct ubus_context *ctx, struct ubus_object *obj, return 0; } +static int +netifd_handle_iface_prepare(struct ubus_context *ctx, struct ubus_object *obj, + struct ubus_request_data *req, const char *method, + struct blob_attr *msg) +{ + struct interface *iface; + struct device *dev; + const struct device_hotplug_ops *ops; + + iface = container_of(obj, struct interface, ubus); + dev = iface->main_dev.dev; + if (!dev) + return 0; + + ops = dev->hotplug_ops; + if (!ops) + return 0; + + return ops->prepare(dev); +} + static struct ubus_method iface_object_methods[] = { { .name = "up", .handler = netifd_handle_up }, { .name = "down", .handler = netifd_handle_down }, { .name = "status", .handler = netifd_handle_status }, + { .name = "prepare", .handler = netifd_handle_iface_prepare }, UBUS_METHOD("add_device", netifd_iface_handle_device, dev_policy ), UBUS_METHOD("remove_device", netifd_iface_handle_device, dev_policy ), { .name = "notify_proto", .handler = netifd_iface_notify_proto },