ubus: fix blob_buf initialization
[project/uhttpd.git] / ubus.c
1 /*
2 * uhttpd - Tiny single-threaded httpd
3 *
4 * Copyright (C) 2010-2013 Jo-Philipp Wich <xm@subsignal.org>
5 * Copyright (C) 2013 Felix Fietkau <nbd@openwrt.org>
6 *
7 * Permission to use, copy, modify, and/or distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
10 *
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 */
19
20 #include <libubox/blobmsg.h>
21 #include <libubox/blobmsg_json.h>
22 #include <libubox/avl.h>
23 #include <libubox/avl-cmp.h>
24 #include <stdio.h>
25 #include <poll.h>
26
27 #include "uhttpd.h"
28 #include "plugin.h"
29
30 static const struct uhttpd_ops *ops;
31 static struct config *_conf;
32 #define conf (*_conf)
33
34 static struct ubus_context *ctx;
35 static struct blob_buf buf;
36
37 #define UH_UBUS_MAX_POST_SIZE 65536
38 #define UH_UBUS_DEFAULT_SID "00000000000000000000000000000000"
39
40 enum {
41 RPC_JSONRPC,
42 RPC_METHOD,
43 RPC_PARAMS,
44 RPC_ID,
45 __RPC_MAX,
46 };
47
48 static const struct blobmsg_policy rpc_policy[__RPC_MAX] = {
49 [RPC_JSONRPC] = { .name = "jsonrpc", .type = BLOBMSG_TYPE_STRING },
50 [RPC_METHOD] = { .name = "method", .type = BLOBMSG_TYPE_STRING },
51 [RPC_PARAMS] = { .name = "params", .type = BLOBMSG_TYPE_UNSPEC },
52 [RPC_ID] = { .name = "id", .type = BLOBMSG_TYPE_UNSPEC },
53 };
54
55 enum {
56 SES_ACCESS,
57 __SES_MAX,
58 };
59
60 static const struct blobmsg_policy ses_policy[__SES_MAX] = {
61 [SES_ACCESS] = { .name = "access", .type = BLOBMSG_TYPE_BOOL },
62 };
63
64 struct rpc_data {
65 struct blob_attr *id;
66 const char *sid;
67 const char *method;
68 const char *object;
69 const char *function;
70 struct blob_attr *data;
71 struct blob_attr *params;
72 };
73
74 struct list_data {
75 bool verbose;
76 struct blob_buf *buf;
77 };
78
79 enum rpc_error {
80 ERROR_PARSE,
81 ERROR_REQUEST,
82 ERROR_METHOD,
83 ERROR_PARAMS,
84 ERROR_INTERNAL,
85 ERROR_OBJECT,
86 ERROR_SESSION,
87 ERROR_ACCESS,
88 ERROR_TIMEOUT,
89 __ERROR_MAX
90 };
91
92 static const struct {
93 int code;
94 const char *msg;
95 } json_errors[__ERROR_MAX] = {
96 [ERROR_PARSE] = { -32700, "Parse error" },
97 [ERROR_REQUEST] = { -32600, "Invalid request" },
98 [ERROR_METHOD] = { -32601, "Method not found" },
99 [ERROR_PARAMS] = { -32602, "Invalid parameters" },
100 [ERROR_INTERNAL] = { -32603, "Internal error" },
101 [ERROR_OBJECT] = { -32000, "Object not found" },
102 [ERROR_SESSION] = { -32001, "Session not found" },
103 [ERROR_ACCESS] = { -32002, "Access denied" },
104 [ERROR_TIMEOUT] = { -32003, "ubus request timed out" },
105 };
106
107 enum cors_hdr {
108 HDR_ORIGIN,
109 HDR_ACCESS_CONTROL_REQUEST_METHOD,
110 HDR_ACCESS_CONTROL_REQUEST_HEADERS,
111 __HDR_MAX
112 };
113
114 static void __uh_ubus_next_batched_request(struct uloop_timeout *timeout);
115
116 static void uh_ubus_next_batched_request(struct client *cl)
117 {
118 struct dispatch_ubus *du = &cl->dispatch.ubus;
119
120 du->timeout.cb = __uh_ubus_next_batched_request;
121 uloop_timeout_set(&du->timeout, 1);
122 }
123
124 static void uh_ubus_add_cors_headers(struct client *cl)
125 {
126 struct blob_attr *tb[__HDR_MAX];
127 static const struct blobmsg_policy hdr_policy[__HDR_MAX] = {
128 [HDR_ORIGIN] = { "origin", BLOBMSG_TYPE_STRING },
129 [HDR_ACCESS_CONTROL_REQUEST_METHOD] = { "access-control-request-method", BLOBMSG_TYPE_STRING },
130 [HDR_ACCESS_CONTROL_REQUEST_HEADERS] = { "access-control-request-headers", BLOBMSG_TYPE_STRING },
131 };
132
133 blobmsg_parse(hdr_policy, __HDR_MAX, tb, blob_data(cl->hdr.head), blob_len(cl->hdr.head));
134
135 if (!tb[HDR_ORIGIN])
136 return;
137
138 if (tb[HDR_ACCESS_CONTROL_REQUEST_METHOD])
139 {
140 char *hdr = (char *) blobmsg_data(tb[HDR_ACCESS_CONTROL_REQUEST_METHOD]);
141
142 if (strcmp(hdr, "POST") && strcmp(hdr, "OPTIONS"))
143 return;
144 }
145
146 ustream_printf(cl->us, "Access-Control-Allow-Origin: %s\r\n",
147 blobmsg_get_string(tb[HDR_ORIGIN]));
148
149 if (tb[HDR_ACCESS_CONTROL_REQUEST_HEADERS])
150 ustream_printf(cl->us, "Access-Control-Allow-Headers: %s\r\n",
151 blobmsg_get_string(tb[HDR_ACCESS_CONTROL_REQUEST_HEADERS]));
152
153 ustream_printf(cl->us, "Access-Control-Allow-Methods: POST, OPTIONS\r\n");
154 ustream_printf(cl->us, "Access-Control-Allow-Credentials: true\r\n");
155 }
156
157 static void uh_ubus_send_header(struct client *cl)
158 {
159 ops->http_header(cl, 200, "OK");
160
161 if (conf.ubus_cors)
162 uh_ubus_add_cors_headers(cl);
163
164 ustream_printf(cl->us, "Content-Type: application/json\r\n");
165
166 if (cl->request.method == UH_HTTP_MSG_OPTIONS)
167 ustream_printf(cl->us, "Content-Length: 0\r\n");
168
169 ustream_printf(cl->us, "\r\n");
170 }
171
172 static void uh_ubus_send_response(struct client *cl, struct blob_buf *buf)
173 {
174 struct dispatch_ubus *du = &cl->dispatch.ubus;
175 const char *sep = "";
176 char *str;
177
178 if (du->array && du->array_idx > 1)
179 sep = ",";
180
181 str = blobmsg_format_json(buf->head, true);
182 ops->chunk_printf(cl, "%s%s", sep, str);
183 free(str);
184
185 du->jsobj_cur = NULL;
186 if (du->array)
187 uh_ubus_next_batched_request(cl);
188 else
189 return ops->request_done(cl);
190 }
191
192 static void uh_ubus_init_json_rpc_response(struct client *cl, struct blob_buf *buf)
193 {
194 struct dispatch_ubus *du = &cl->dispatch.ubus;
195 struct json_object *obj = du->jsobj_cur, *obj2 = NULL;
196
197 blobmsg_add_string(buf, "jsonrpc", "2.0");
198
199 if (obj)
200 json_object_object_get_ex(obj, "id", &obj2);
201
202 if (obj2)
203 blobmsg_add_json_element(buf, "id", obj2);
204 else
205 blobmsg_add_field(buf, BLOBMSG_TYPE_UNSPEC, "id", NULL, 0);
206 }
207
208 static void uh_ubus_json_rpc_error(struct client *cl, enum rpc_error type)
209 {
210 void *c;
211
212 blob_buf_init(&buf, 0);
213
214 uh_ubus_init_json_rpc_response(cl, &buf);
215 c = blobmsg_open_table(&buf, "error");
216 blobmsg_add_u32(&buf, "code", json_errors[type].code);
217 blobmsg_add_string(&buf, "message", json_errors[type].msg);
218 blobmsg_close_table(&buf, c);
219 uh_ubus_send_response(cl, &buf);
220 }
221
222 static void
223 uh_ubus_request_data_cb(struct ubus_request *req, int type, struct blob_attr *msg)
224 {
225 struct dispatch_ubus *du = container_of(req, struct dispatch_ubus, req);
226
227 blobmsg_add_field(&du->buf, BLOBMSG_TYPE_TABLE, "", blob_data(msg), blob_len(msg));
228 }
229
230 static void
231 uh_ubus_request_cb(struct ubus_request *req, int ret)
232 {
233 struct dispatch_ubus *du = container_of(req, struct dispatch_ubus, req);
234 struct client *cl = container_of(du, struct client, dispatch.ubus);
235 struct blob_attr *cur;
236 void *r;
237 int rem;
238
239 blob_buf_init(&buf, 0);
240
241 uloop_timeout_cancel(&du->timeout);
242 uh_ubus_init_json_rpc_response(cl, &buf);
243 r = blobmsg_open_array(&buf, "result");
244 blobmsg_add_u32(&buf, "", ret);
245 blob_for_each_attr(cur, du->buf.head, rem)
246 blobmsg_add_blob(&buf, cur);
247 blobmsg_close_array(&buf, r);
248 uh_ubus_send_response(cl, &buf);
249 }
250
251 static void
252 uh_ubus_timeout_cb(struct uloop_timeout *timeout)
253 {
254 struct dispatch_ubus *du = container_of(timeout, struct dispatch_ubus, timeout);
255 struct client *cl = container_of(du, struct client, dispatch.ubus);
256
257 ubus_abort_request(ctx, &du->req);
258 uh_ubus_json_rpc_error(cl, ERROR_TIMEOUT);
259 }
260
261 static void uh_ubus_close_fds(struct client *cl)
262 {
263 if (ctx->sock.fd < 0)
264 return;
265
266 close(ctx->sock.fd);
267 ctx->sock.fd = -1;
268 }
269
270 static void uh_ubus_request_free(struct client *cl)
271 {
272 struct dispatch_ubus *du = &cl->dispatch.ubus;
273
274 blob_buf_free(&du->buf);
275 uloop_timeout_cancel(&du->timeout);
276
277 if (du->jsobj)
278 json_object_put(du->jsobj);
279
280 if (du->jstok)
281 json_tokener_free(du->jstok);
282
283 if (du->req_pending)
284 ubus_abort_request(ctx, &du->req);
285 }
286
287 static void uh_ubus_single_error(struct client *cl, enum rpc_error type)
288 {
289 uh_ubus_send_header(cl);
290 uh_ubus_json_rpc_error(cl, type);
291 ops->request_done(cl);
292 }
293
294 static void uh_ubus_send_request(struct client *cl, const char *sid, struct blob_attr *args)
295 {
296 struct dispatch *d = &cl->dispatch;
297 struct dispatch_ubus *du = &d->ubus;
298 struct blob_attr *cur;
299 static struct blob_buf req;
300 int ret, rem;
301
302 blob_buf_init(&req, 0);
303 blobmsg_for_each_attr(cur, args, rem) {
304 if (!strcmp(blobmsg_name(cur), "ubus_rpc_session"))
305 return uh_ubus_json_rpc_error(cl, ERROR_PARAMS);
306 blobmsg_add_blob(&req, cur);
307 }
308
309 blobmsg_add_string(&req, "ubus_rpc_session", sid);
310
311 blob_buf_init(&du->buf, 0);
312 memset(&du->req, 0, sizeof(du->req));
313 ret = ubus_invoke_async(ctx, du->obj, du->func, req.head, &du->req);
314 if (ret)
315 return uh_ubus_json_rpc_error(cl, ERROR_INTERNAL);
316
317 du->req.data_cb = uh_ubus_request_data_cb;
318 du->req.complete_cb = uh_ubus_request_cb;
319 ubus_complete_request_async(ctx, &du->req);
320
321 du->timeout.cb = uh_ubus_timeout_cb;
322 uloop_timeout_set(&du->timeout, conf.script_timeout * 1000);
323
324 du->req_pending = true;
325 }
326
327 static void uh_ubus_list_cb(struct ubus_context *ctx, struct ubus_object_data *obj, void *priv)
328 {
329 struct blob_attr *sig, *attr;
330 struct list_data *data = priv;
331 int rem, rem2;
332 void *t, *o;
333
334 if (!data->verbose) {
335 blobmsg_add_string(data->buf, NULL, obj->path);
336 return;
337 }
338
339 if (!obj->signature)
340 return;
341
342 o = blobmsg_open_table(data->buf, obj->path);
343 blob_for_each_attr(sig, obj->signature, rem) {
344 t = blobmsg_open_table(data->buf, blobmsg_name(sig));
345 rem2 = blobmsg_data_len(sig);
346 __blob_for_each_attr(attr, blobmsg_data(sig), rem2) {
347 if (blob_id(attr) != BLOBMSG_TYPE_INT32)
348 continue;
349
350 switch (blobmsg_get_u32(attr)) {
351 case BLOBMSG_TYPE_INT8:
352 blobmsg_add_string(data->buf, blobmsg_name(attr), "boolean");
353 break;
354 case BLOBMSG_TYPE_INT32:
355 blobmsg_add_string(data->buf, blobmsg_name(attr), "number");
356 break;
357 case BLOBMSG_TYPE_STRING:
358 blobmsg_add_string(data->buf, blobmsg_name(attr), "string");
359 break;
360 case BLOBMSG_TYPE_ARRAY:
361 blobmsg_add_string(data->buf, blobmsg_name(attr), "array");
362 break;
363 case BLOBMSG_TYPE_TABLE:
364 blobmsg_add_string(data->buf, blobmsg_name(attr), "object");
365 break;
366 default:
367 blobmsg_add_string(data->buf, blobmsg_name(attr), "unknown");
368 break;
369 }
370 }
371 blobmsg_close_table(data->buf, t);
372 }
373 blobmsg_close_table(data->buf, o);
374 }
375
376 static void uh_ubus_send_list(struct client *cl, struct blob_attr *params)
377 {
378 struct blob_attr *cur, *dup;
379 struct list_data data = { .buf = &cl->dispatch.ubus.buf, .verbose = false };
380 void *r;
381 int rem;
382
383 blob_buf_init(data.buf, 0);
384
385 uh_client_ref(cl);
386
387 if (!params || blob_id(params) != BLOBMSG_TYPE_ARRAY) {
388 r = blobmsg_open_array(data.buf, "result");
389 ubus_lookup(ctx, NULL, uh_ubus_list_cb, &data);
390 blobmsg_close_array(data.buf, r);
391 }
392 else {
393 r = blobmsg_open_table(data.buf, "result");
394 dup = blob_memdup(params);
395 if (dup)
396 {
397 rem = blobmsg_data_len(dup);
398 data.verbose = true;
399 __blob_for_each_attr(cur, blobmsg_data(dup), rem)
400 ubus_lookup(ctx, blobmsg_data(cur), uh_ubus_list_cb, &data);
401 free(dup);
402 }
403 blobmsg_close_table(data.buf, r);
404 }
405
406 uh_client_unref(cl);
407
408 blob_buf_init(&buf, 0);
409 uh_ubus_init_json_rpc_response(cl, &buf);
410 blobmsg_add_blob(&buf, blob_data(data.buf->head));
411 uh_ubus_send_response(cl, &buf);
412 }
413
414 static bool parse_json_rpc(struct rpc_data *d, struct blob_attr *data)
415 {
416 struct blob_attr *tb[__RPC_MAX];
417 struct blob_attr *cur;
418
419 blobmsg_parse(rpc_policy, __RPC_MAX, tb, blob_data(data), blob_len(data));
420
421 cur = tb[RPC_JSONRPC];
422 if (!cur || strcmp(blobmsg_data(cur), "2.0") != 0)
423 return false;
424
425 cur = tb[RPC_METHOD];
426 if (!cur)
427 return false;
428
429 d->id = tb[RPC_ID];
430 d->method = blobmsg_data(cur);
431
432 cur = tb[RPC_PARAMS];
433 if (!cur)
434 return true;
435
436 d->params = blob_memdup(cur);
437 if (!d->params)
438 return false;
439
440 return true;
441 }
442
443 static void parse_call_params(struct rpc_data *d)
444 {
445 const struct blobmsg_policy data_policy[] = {
446 { .type = BLOBMSG_TYPE_STRING },
447 { .type = BLOBMSG_TYPE_STRING },
448 { .type = BLOBMSG_TYPE_STRING },
449 { .type = BLOBMSG_TYPE_TABLE },
450 };
451 struct blob_attr *tb[4];
452
453 if (!d->params || blobmsg_type(d->params) != BLOBMSG_TYPE_ARRAY)
454 return;
455
456 blobmsg_parse_array(data_policy, ARRAY_SIZE(data_policy), tb,
457 blobmsg_data(d->params), blobmsg_data_len(d->params));
458
459 if (tb[0])
460 d->sid = blobmsg_data(tb[0]);
461
462 if (conf.ubus_noauth && (!d->sid || !*d->sid))
463 d->sid = UH_UBUS_DEFAULT_SID;
464
465 if (tb[1])
466 d->object = blobmsg_data(tb[1]);
467
468 if (tb[2])
469 d->function = blobmsg_data(tb[2]);
470
471 d->data = tb[3];
472 }
473
474 static void uh_ubus_init_batch(struct client *cl)
475 {
476 struct dispatch_ubus *du = &cl->dispatch.ubus;
477
478 du->array = true;
479 uh_ubus_send_header(cl);
480 ops->chunk_printf(cl, "[");
481 }
482
483 static void uh_ubus_complete_batch(struct client *cl)
484 {
485 ops->chunk_printf(cl, "]");
486 ops->request_done(cl);
487 }
488
489 static void uh_ubus_allowed_cb(struct ubus_request *req, int type, struct blob_attr *msg)
490 {
491 struct blob_attr *tb[__SES_MAX];
492 bool *allow = (bool *)req->priv;
493
494 if (!msg)
495 return;
496
497 blobmsg_parse(ses_policy, __SES_MAX, tb, blob_data(msg), blob_len(msg));
498
499 if (tb[SES_ACCESS])
500 *allow = blobmsg_get_bool(tb[SES_ACCESS]);
501 }
502
503 static bool uh_ubus_allowed(const char *sid, const char *obj, const char *fun)
504 {
505 uint32_t id;
506 bool allow = false;
507 static struct blob_buf req;
508
509 if (ubus_lookup_id(ctx, "session", &id))
510 return false;
511
512 blob_buf_init(&req, 0);
513 blobmsg_add_string(&req, "ubus_rpc_session", sid);
514 blobmsg_add_string(&req, "object", obj);
515 blobmsg_add_string(&req, "function", fun);
516
517 ubus_invoke(ctx, id, "access", req.head, uh_ubus_allowed_cb, &allow, conf.script_timeout * 500);
518
519 return allow;
520 }
521
522 static void uh_ubus_handle_request_object(struct client *cl, struct json_object *obj)
523 {
524 struct dispatch_ubus *du = &cl->dispatch.ubus;
525 struct rpc_data data = {};
526 enum rpc_error err = ERROR_PARSE;
527 static struct blob_buf req;
528
529 uh_client_ref(cl);
530
531 if (json_object_get_type(obj) != json_type_object)
532 goto error;
533
534 du->jsobj_cur = obj;
535 blob_buf_init(&req, 0);
536 if (!blobmsg_add_object(&req, obj))
537 goto error;
538
539 if (!parse_json_rpc(&data, req.head))
540 goto error;
541
542 if (!strcmp(data.method, "call")) {
543 parse_call_params(&data);
544
545 if (!data.sid || !data.object || !data.function || !data.data)
546 goto error;
547
548 du->func = data.function;
549 if (ubus_lookup_id(ctx, data.object, &du->obj)) {
550 err = ERROR_OBJECT;
551 goto error;
552 }
553
554 if (!conf.ubus_noauth && !uh_ubus_allowed(data.sid, data.object, data.function)) {
555 err = ERROR_ACCESS;
556 goto error;
557 }
558
559 uh_ubus_send_request(cl, data.sid, data.data);
560 goto out;
561 }
562 else if (!strcmp(data.method, "list")) {
563 uh_ubus_send_list(cl, data.params);
564 goto out;
565 }
566 else {
567 err = ERROR_METHOD;
568 goto error;
569 }
570
571 error:
572 uh_ubus_json_rpc_error(cl, err);
573 out:
574 if (data.params)
575 free(data.params);
576
577 uh_client_unref(cl);
578 }
579
580 static void __uh_ubus_next_batched_request(struct uloop_timeout *timeout)
581 {
582 struct dispatch_ubus *du = container_of(timeout, struct dispatch_ubus, timeout);
583 struct client *cl = container_of(du, struct client, dispatch.ubus);
584 struct json_object *obj = du->jsobj;
585 int len;
586
587 len = json_object_array_length(obj);
588 if (du->array_idx >= len)
589 return uh_ubus_complete_batch(cl);
590
591 obj = json_object_array_get_idx(obj, du->array_idx++);
592 uh_ubus_handle_request_object(cl, obj);
593 }
594
595 static void uh_ubus_data_done(struct client *cl)
596 {
597 struct dispatch_ubus *du = &cl->dispatch.ubus;
598 struct json_object *obj = du->jsobj;
599
600 switch (obj ? json_object_get_type(obj) : json_type_null) {
601 case json_type_object:
602 uh_ubus_send_header(cl);
603 return uh_ubus_handle_request_object(cl, obj);
604 case json_type_array:
605 uh_ubus_init_batch(cl);
606 return uh_ubus_next_batched_request(cl);
607 default:
608 return uh_ubus_single_error(cl, ERROR_PARSE);
609 }
610 }
611
612 static int uh_ubus_data_send(struct client *cl, const char *data, int len)
613 {
614 struct dispatch_ubus *du = &cl->dispatch.ubus;
615
616 if (du->jsobj || !du->jstok)
617 goto error;
618
619 du->post_len += len;
620 if (du->post_len > UH_UBUS_MAX_POST_SIZE)
621 goto error;
622
623 du->jsobj = json_tokener_parse_ex(du->jstok, data, len);
624 return len;
625
626 error:
627 uh_ubus_single_error(cl, ERROR_PARSE);
628 return 0;
629 }
630
631 static void uh_ubus_handle_request(struct client *cl, char *url, struct path_info *pi)
632 {
633 struct dispatch *d = &cl->dispatch;
634
635 switch (cl->request.method)
636 {
637 case UH_HTTP_MSG_POST:
638 d->data_send = uh_ubus_data_send;
639 d->data_done = uh_ubus_data_done;
640 d->close_fds = uh_ubus_close_fds;
641 d->free = uh_ubus_request_free;
642 d->ubus.jstok = json_tokener_new();
643 break;
644
645 case UH_HTTP_MSG_OPTIONS:
646 uh_ubus_send_header(cl);
647 ops->request_done(cl);
648 break;
649
650 default:
651 ops->client_error(cl, 400, "Bad Request", "Invalid Request");
652 }
653 }
654
655 static bool
656 uh_ubus_check_url(const char *url)
657 {
658 return ops->path_match(conf.ubus_prefix, url);
659 }
660
661 static int
662 uh_ubus_init(void)
663 {
664 static struct dispatch_handler ubus_dispatch = {
665 .check_url = uh_ubus_check_url,
666 .handle_request = uh_ubus_handle_request,
667 };
668
669 ctx = ubus_connect(conf.ubus_socket);
670 if (!ctx) {
671 fprintf(stderr, "Unable to connect to ubus socket\n");
672 exit(1);
673 }
674
675 ops->dispatch_add(&ubus_dispatch);
676
677 uloop_done();
678 return 0;
679 }
680
681
682 static int uh_ubus_plugin_init(const struct uhttpd_ops *o, struct config *c)
683 {
684 ops = o;
685 _conf = c;
686 return uh_ubus_init();
687 }
688
689 static void uh_ubus_post_init(void)
690 {
691 ubus_add_uloop(ctx);
692 }
693
694 struct uhttpd_plugin uhttpd_plugin = {
695 .init = uh_ubus_plugin_init,
696 .post_init = uh_ubus_post_init,
697 };