+
+static LIST_HEAD(plugins);
+
+static const struct rpc_daemon_ops ops = {
+ .access = rpc_session_access,
+ .exec = rpc_exec,
+};
+
+static int
+rpc_plugin_register_library(struct ubus_context *ctx, const char *path)
+{
+ struct rpc_plugin *p;
+ void *dlh;
+
+ dlh = dlopen(path, RTLD_LAZY | RTLD_GLOBAL);
+
+ if (!dlh)
+ return UBUS_STATUS_UNKNOWN_ERROR;
+
+ p = dlsym(dlh, "rpc_plugin");
+
+ if (!p)
+ return UBUS_STATUS_NOT_FOUND;
+
+ list_add(&p->list, &plugins);
+
+ return p->init(&ops, ctx);
+}
+