2 * Copyright (C) 2011 Felix Fietkau <nbd@openwrt.org>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 2.1
6 * as published by the Free Software Foundation
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
14 #include <sys/types.h>
16 #include <sys/socket.h>
20 #include <libubox/blob.h>
21 #include <libubox/blobmsg.h>
22 #include <libubox/usock.h>
27 #define STATIC_IOV(_var) { .iov_base = (char *) &(_var), .iov_len = sizeof(_var) }
29 const char *__ubus_strerror
[__UBUS_STATUS_LAST
] = {
30 [UBUS_STATUS_OK
] = "Success",
31 [UBUS_STATUS_INVALID_COMMAND
] = "Invalid command",
32 [UBUS_STATUS_INVALID_ARGUMENT
] = "Invalid argument",
33 [UBUS_STATUS_METHOD_NOT_FOUND
] = "Method not found",
34 [UBUS_STATUS_NOT_FOUND
] = "Not found",
35 [UBUS_STATUS_NO_DATA
] = "No response",
36 [UBUS_STATUS_PERMISSION_DENIED
] = "Permission denied",
37 [UBUS_STATUS_TIMEOUT
] = "Request timed out",
40 static struct blob_buf b
;
42 static const struct blob_attr_info ubus_policy
[UBUS_ATTR_MAX
] = {
43 [UBUS_ATTR_STATUS
] = { .type
= BLOB_ATTR_INT32
},
44 [UBUS_ATTR_OBJID
] = { .type
= BLOB_ATTR_INT32
},
45 [UBUS_ATTR_OBJPATH
] = { .type
= BLOB_ATTR_STRING
},
46 [UBUS_ATTR_METHOD
] = { .type
= BLOB_ATTR_STRING
},
48 static struct blob_attr
*attrbuf
[UBUS_ATTR_MAX
];
50 struct ubus_pending_data
{
51 struct list_head list
;
53 struct blob_attr data
[];
56 static int ubus_cmp_id(const void *k1
, const void *k2
, void *ptr
)
58 const uint32_t *id1
= k1
, *id2
= k2
;
66 static struct blob_attr
**ubus_parse_msg(struct blob_attr
*msg
)
68 blob_parse(msg
, attrbuf
, ubus_policy
, UBUS_ATTR_MAX
);
72 const char *ubus_strerror(int error
)
76 if (error
< 0 || error
>= __UBUS_STATUS_LAST
)
79 if (!__ubus_strerror
[error
])
82 return __ubus_strerror
[error
];
85 sprintf(err
, "Unknown error: %d", error
);
89 static int writev_retry(int fd
, struct iovec
*iov
, int iov_len
)
94 int cur_len
= writev(fd
, iov
, iov_len
);
98 /* turn off non-blocking mode */
99 fcntl(fd
, F_SETFL
, fcntl(fd
, F_GETFL
) &
110 while (cur_len
>= iov
->iov_len
) {
111 cur_len
-= iov
->iov_len
;
114 if (!cur_len
|| !iov_len
)
117 iov
->iov_len
-= cur_len
;
121 static int ubus_send_msg(struct ubus_context
*ctx
, uint32_t seq
,
122 struct blob_attr
*msg
, int cmd
, uint32_t peer
)
124 struct ubus_msghdr hdr
;
125 struct iovec iov
[2] = {
135 blob_buf_init(&b
, 0);
139 iov
[1].iov_base
= (char *) msg
;
140 iov
[1].iov_len
= blob_raw_len(msg
);
142 return writev_retry(ctx
->sock
.fd
, iov
, ARRAY_SIZE(iov
));
145 static int ubus_start_request(struct ubus_context
*ctx
, struct ubus_request
*req
,
146 struct blob_attr
*msg
, int cmd
, uint32_t peer
)
148 memset(req
, 0, sizeof(*req
));
150 if (msg
&& blob_pad_len(msg
) > UBUS_MAX_MSGLEN
)
153 INIT_LIST_HEAD(&req
->list
);
154 INIT_LIST_HEAD(&req
->pending
);
157 req
->seq
= ++ctx
->request_seq
;
158 return ubus_send_msg(ctx
, req
->seq
, msg
, cmd
, peer
);
161 static bool recv_retry(int fd
, struct iovec
*iov
, bool wait
)
165 while (iov
->iov_len
> 0) {
166 bytes
= read(fd
, iov
->iov_base
, iov
->iov_len
);
181 iov
->iov_len
-= bytes
;
182 iov
->iov_base
+= bytes
;
188 static bool ubus_validate_hdr(struct ubus_msghdr
*hdr
)
190 if (hdr
->version
!= 0)
193 if (blob_raw_len(hdr
->data
) < sizeof(*hdr
->data
))
196 if (blob_pad_len(hdr
->data
) > UBUS_MAX_MSGLEN
)
202 static bool get_next_msg(struct ubus_context
*ctx
)
204 struct iovec iov
= STATIC_IOV(ctx
->msgbuf
.hdr
);
206 /* receive header + start attribute */
207 iov
.iov_len
+= sizeof(struct blob_attr
);
208 if (!recv_retry(ctx
->sock
.fd
, &iov
, false))
211 iov
.iov_len
= blob_len(ctx
->msgbuf
.hdr
.data
);
212 if (iov
.iov_len
> 0 && !recv_retry(ctx
->sock
.fd
, &iov
, true))
215 return ubus_validate_hdr(&ctx
->msgbuf
.hdr
);
218 static bool ubus_get_status(struct ubus_msghdr
*hdr
, int *ret
)
220 ubus_parse_msg(hdr
->data
);
222 if (!attrbuf
[UBUS_ATTR_STATUS
])
225 *ret
= blob_get_u32(attrbuf
[UBUS_ATTR_STATUS
]);
229 static void req_data_cb(struct ubus_request
*req
, int type
, struct blob_attr
*data
)
231 struct blob_attr
**attr
;
233 if (req
->raw_data_cb
)
234 req
->raw_data_cb(req
, type
, data
);
239 attr
= ubus_parse_msg(data
);
240 req
->data_cb(req
, type
, attr
[UBUS_ATTR_DATA
]);
243 static void ubus_process_req_data(struct ubus_request
*req
)
245 struct ubus_pending_data
*data
;
247 while (!list_empty(&req
->pending
)) {
248 data
= list_first_entry(&req
->pending
,
249 struct ubus_pending_data
, list
);
250 list_del(&data
->list
);
252 req_data_cb(req
, data
->type
, data
->data
);
257 static void ubus_req_complete_cb(struct ubus_request
*req
)
259 ubus_complete_handler_t cb
= req
->complete_cb
;
264 req
->complete_cb
= NULL
;
265 cb(req
, req
->status_code
);
268 static int ubus_process_req_status(struct ubus_request
*req
, struct ubus_msghdr
*hdr
)
270 int ret
= UBUS_STATUS_INVALID_ARGUMENT
;
272 if (!list_empty(&req
->list
))
273 list_del(&req
->list
);
275 ubus_get_status(hdr
, &ret
);
276 req
->peer
= hdr
->peer
;
277 req
->status_msg
= true;
278 req
->status_code
= ret
;
280 ubus_req_complete_cb(req
);
285 static void ubus_req_data(struct ubus_request
*req
, struct ubus_msghdr
*hdr
)
287 struct ubus_pending_data
*data
;
292 req_data_cb(req
, hdr
->type
, hdr
->data
);
293 ubus_process_req_data(req
);
294 req
->blocked
= false;
297 ubus_req_complete_cb(req
);
302 len
= blob_raw_len(hdr
->data
);
303 data
= calloc(1, sizeof(*data
) + len
);
307 data
->type
= hdr
->type
;
308 memcpy(data
->data
, hdr
->data
, len
);
309 list_add(&data
->list
, &req
->pending
);
312 static struct ubus_request
*ubus_find_request(struct ubus_context
*ctx
, uint32_t seq
, uint32_t peer
)
314 struct ubus_request
*req
;
316 list_for_each_entry(req
, &ctx
->requests
, list
) {
317 if (seq
!= req
->seq
|| peer
!= req
->peer
)
325 static void ubus_process_invoke(struct ubus_context
*ctx
, struct ubus_msghdr
*hdr
)
327 struct ubus_request_data req
;
328 struct ubus_object
*obj
;
333 ubus_parse_msg(hdr
->data
);
335 if (!attrbuf
[UBUS_ATTR_OBJID
])
338 objid
= blob_get_u32(attrbuf
[UBUS_ATTR_OBJID
]);
340 if (!attrbuf
[UBUS_ATTR_METHOD
]) {
341 ret
= UBUS_STATUS_INVALID_ARGUMENT
;
345 obj
= avl_find_element(&ctx
->objects
, &objid
, obj
, avl
);
347 ret
= UBUS_STATUS_NOT_FOUND
;
351 for (method
= 0; method
< obj
->n_methods
; method
++)
352 if (!obj
->methods
[method
].name
||
353 !strcmp(obj
->methods
[method
].name
,
354 blob_data(attrbuf
[UBUS_ATTR_METHOD
])))
358 ret
= UBUS_STATUS_METHOD_NOT_FOUND
;
363 req
.peer
= hdr
->peer
;
365 ret
= obj
->methods
[method
].handler(ctx
, obj
, &req
,
366 blob_data(attrbuf
[UBUS_ATTR_METHOD
]),
367 attrbuf
[UBUS_ATTR_DATA
]);
370 blob_buf_init(&b
, 0);
371 blob_put_int32(&b
, UBUS_ATTR_STATUS
, ret
);
372 blob_put_int32(&b
, UBUS_ATTR_OBJID
, objid
);
373 ubus_send_msg(ctx
, hdr
->seq
, b
.head
, UBUS_MSG_STATUS
, hdr
->peer
);
376 static void ubus_process_msg(struct ubus_context
*ctx
, struct ubus_msghdr
*hdr
)
378 struct ubus_request
*req
;
381 case UBUS_MSG_STATUS
:
382 req
= ubus_find_request(ctx
, hdr
->seq
, hdr
->peer
);
386 ubus_process_req_status(req
, hdr
);
390 req
= ubus_find_request(ctx
, hdr
->seq
, hdr
->peer
);
391 if (req
&& (req
->data_cb
|| req
->raw_data_cb
))
392 ubus_req_data(req
, hdr
);
395 case UBUS_MSG_INVOKE
:
396 ubus_process_invoke(ctx
, hdr
);
401 void ubus_abort_request(struct ubus_context
*ctx
, struct ubus_request
*req
)
403 if (!list_empty(&req
->list
))
406 req
->cancelled
= true;
407 ubus_process_req_data(req
);
408 list_del(&req
->list
);
411 void ubus_complete_request_async(struct ubus_context
*ctx
, struct ubus_request
*req
)
413 if (!list_empty(&req
->list
))
416 list_add(&req
->list
, &ctx
->requests
);
419 static void ubus_handle_data(struct uloop_fd
*u
, unsigned int events
)
421 struct ubus_context
*ctx
= container_of(u
, struct ubus_context
, sock
);
422 struct ubus_msghdr
*hdr
= &ctx
->msgbuf
.hdr
;
424 while (get_next_msg(ctx
)) {
425 ubus_process_msg(ctx
, hdr
);
431 ctx
->connection_lost(ctx
);
434 static void ubus_sync_req_cb(struct ubus_request
*req
, int ret
)
436 req
->status_msg
= true;
437 req
->status_code
= ret
;
441 struct ubus_sync_req_cb
{
442 struct uloop_timeout timeout
;
443 struct ubus_request
*req
;
446 static void ubus_sync_req_timeout_cb(struct uloop_timeout
*timeout
)
448 struct ubus_sync_req_cb
*cb
;
450 cb
= container_of(timeout
, struct ubus_sync_req_cb
, timeout
);
451 ubus_sync_req_cb(cb
->req
, UBUS_STATUS_TIMEOUT
);
454 int ubus_complete_request(struct ubus_context
*ctx
, struct ubus_request
*req
,
457 struct ubus_sync_req_cb cb
;
458 ubus_complete_handler_t complete_cb
= req
->complete_cb
;
459 bool registered
= ctx
->sock
.registered
;
460 bool cancelled
= uloop_cancelled
;
461 int status
= UBUS_STATUS_NO_DATA
;
469 memset(&cb
, 0, sizeof(cb
));
471 cb
.timeout
.cb
= ubus_sync_req_timeout_cb
;
472 uloop_timeout_set(&cb
.timeout
, timeout
);
475 ubus_complete_request_async(ctx
, req
);
476 req
->complete_cb
= ubus_sync_req_cb
;
481 uloop_timeout_cancel(&cb
.timeout
);
484 status
= req
->status_code
;
486 req
->complete_cb
= complete_cb
;
487 if (req
->complete_cb
)
488 req
->complete_cb(req
, status
);
490 uloop_cancelled
= cancelled
;
492 uloop_fd_delete(&ctx
->sock
);
497 struct ubus_lookup_request
{
498 struct ubus_request req
;
499 ubus_lookup_handler_t cb
;
502 static void ubus_lookup_cb(struct ubus_request
*ureq
, int type
, struct blob_attr
*msg
)
504 struct ubus_lookup_request
*req
;
505 struct ubus_object_data obj
;
506 struct blob_attr
**attr
;
508 req
= container_of(ureq
, struct ubus_lookup_request
, req
);
509 attr
= ubus_parse_msg(msg
);
511 if (!attr
[UBUS_ATTR_OBJID
] || !attr
[UBUS_ATTR_OBJPATH
] ||
512 !attr
[UBUS_ATTR_OBJTYPE
])
515 memset(&obj
, 0, sizeof(obj
));
516 obj
.id
= blob_get_u32(attr
[UBUS_ATTR_OBJID
]);
517 obj
.path
= blob_data(attr
[UBUS_ATTR_OBJPATH
]);
518 obj
.type_id
= blob_get_u32(attr
[UBUS_ATTR_OBJTYPE
]);
519 obj
.signature
= attr
[UBUS_ATTR_SIGNATURE
];
520 req
->cb(ureq
->ctx
, &obj
, ureq
->priv
);
523 int ubus_lookup(struct ubus_context
*ctx
, const char *path
,
524 ubus_lookup_handler_t cb
, void *priv
)
526 struct ubus_lookup_request lookup
;
528 blob_buf_init(&b
, 0);
530 blob_put_string(&b
, UBUS_ATTR_OBJPATH
, path
);
532 if (ubus_start_request(ctx
, &lookup
.req
, b
.head
, UBUS_MSG_LOOKUP
, 0) < 0)
533 return UBUS_STATUS_INVALID_ARGUMENT
;
535 lookup
.req
.raw_data_cb
= ubus_lookup_cb
;
536 lookup
.req
.priv
= priv
;
538 return ubus_complete_request(ctx
, &lookup
.req
, 0);
541 static void ubus_lookup_id_cb(struct ubus_request
*req
, int type
, struct blob_attr
*msg
)
543 struct blob_attr
**attr
;
544 uint32_t *id
= req
->priv
;
546 attr
= ubus_parse_msg(msg
);
548 if (!attr
[UBUS_ATTR_OBJID
])
551 *id
= blob_get_u32(attr
[UBUS_ATTR_OBJID
]);
554 int ubus_lookup_id(struct ubus_context
*ctx
, const char *path
, uint32_t *id
)
556 struct ubus_request req
;
558 blob_buf_init(&b
, 0);
560 blob_put_string(&b
, UBUS_ATTR_OBJPATH
, path
);
562 if (ubus_start_request(ctx
, &req
, b
.head
, UBUS_MSG_LOOKUP
, 0) < 0)
563 return UBUS_STATUS_INVALID_ARGUMENT
;
565 req
.raw_data_cb
= ubus_lookup_id_cb
;
568 return ubus_complete_request(ctx
, &req
, 0);
571 int ubus_send_reply(struct ubus_context
*ctx
, struct ubus_request_data
*req
,
572 struct blob_attr
*msg
)
576 blob_buf_init(&b
, 0);
577 blob_put_int32(&b
, UBUS_ATTR_OBJID
, req
->object
);
578 blob_put(&b
, UBUS_ATTR_DATA
, blob_data(msg
), blob_len(msg
));
579 ret
= ubus_send_msg(ctx
, req
->seq
, b
.head
, UBUS_MSG_DATA
, req
->peer
);
581 return UBUS_STATUS_NO_DATA
;
586 int ubus_invoke_async(struct ubus_context
*ctx
, uint32_t obj
, const char *method
,
587 struct blob_attr
*msg
, struct ubus_request
*req
)
589 blob_buf_init(&b
, 0);
590 blob_put_int32(&b
, UBUS_ATTR_OBJID
, obj
);
591 blob_put_string(&b
, UBUS_ATTR_METHOD
, method
);
593 blob_put(&b
, UBUS_ATTR_DATA
, blob_data(msg
), blob_len(msg
));
595 if (ubus_start_request(ctx
, req
, b
.head
, UBUS_MSG_INVOKE
, obj
) < 0)
596 return UBUS_STATUS_INVALID_ARGUMENT
;
601 int ubus_invoke(struct ubus_context
*ctx
, uint32_t obj
, const char *method
,
602 struct blob_attr
*msg
, ubus_data_handler_t cb
, void *priv
,
605 struct ubus_request req
;
607 ubus_invoke_async(ctx
, obj
, method
, msg
, &req
);
610 return ubus_complete_request(ctx
, &req
, timeout
);
613 static void ubus_add_object_cb(struct ubus_request
*req
, int type
, struct blob_attr
*msg
)
615 struct ubus_object
*obj
= req
->priv
;
619 if (!attrbuf
[UBUS_ATTR_OBJID
])
622 obj
->id
= blob_get_u32(attrbuf
[UBUS_ATTR_OBJID
]);
624 if (attrbuf
[UBUS_ATTR_OBJTYPE
])
625 obj
->type
->id
= blob_get_u32(attrbuf
[UBUS_ATTR_OBJTYPE
]);
627 obj
->avl
.key
= &obj
->id
;
628 avl_insert(&req
->ctx
->objects
, &obj
->avl
);
631 static void ubus_push_method_data(const struct ubus_method
*m
)
636 mtbl
= blobmsg_open_table(&b
, m
->name
);
638 for (i
= 0; i
< m
->n_policy
; i
++)
639 blobmsg_add_u32(&b
, m
->policy
[i
].name
, m
->policy
[i
].type
);
641 blobmsg_close_table(&b
, mtbl
);
644 static bool ubus_push_object_type(const struct ubus_object_type
*type
)
649 s
= blob_nest_start(&b
, UBUS_ATTR_SIGNATURE
);
651 for (i
= 0; i
< type
->n_methods
; i
++)
652 ubus_push_method_data(&type
->methods
[i
]);
654 blob_nest_end(&b
, s
);
659 static int __ubus_add_object(struct ubus_context
*ctx
, struct ubus_object
*obj
)
661 struct ubus_request req
;
664 blob_buf_init(&b
, 0);
666 if (obj
->name
&& obj
->type
) {
667 blob_put_string(&b
, UBUS_ATTR_OBJPATH
, obj
->name
);
670 blob_put_int32(&b
, UBUS_ATTR_OBJTYPE
, obj
->type
->id
);
671 else if (!ubus_push_object_type(obj
->type
))
672 return UBUS_STATUS_INVALID_ARGUMENT
;
675 if (ubus_start_request(ctx
, &req
, b
.head
, UBUS_MSG_ADD_OBJECT
, 0) < 0)
676 return UBUS_STATUS_INVALID_ARGUMENT
;
678 req
.raw_data_cb
= ubus_add_object_cb
;
680 ret
= ubus_complete_request(ctx
, &req
, 0);
685 return UBUS_STATUS_NO_DATA
;
690 int ubus_add_object(struct ubus_context
*ctx
, struct ubus_object
*obj
)
692 if (!obj
->name
|| !obj
->type
)
693 return UBUS_STATUS_INVALID_ARGUMENT
;
695 return __ubus_add_object(ctx
, obj
);
698 static void ubus_remove_object_cb(struct ubus_request
*req
, int type
, struct blob_attr
*msg
)
700 struct ubus_object
*obj
= req
->priv
;
704 if (!attrbuf
[UBUS_ATTR_OBJID
])
709 if (attrbuf
[UBUS_ATTR_OBJTYPE
] && obj
->type
)
712 avl_delete(&req
->ctx
->objects
, &obj
->avl
);
715 int ubus_remove_object(struct ubus_context
*ctx
, struct ubus_object
*obj
)
717 struct ubus_request req
;
720 blob_buf_init(&b
, 0);
721 blob_put_int32(&b
, UBUS_ATTR_OBJID
, obj
->id
);
723 if (ubus_start_request(ctx
, &req
, b
.head
, UBUS_MSG_REMOVE_OBJECT
, 0) < 0)
724 return UBUS_STATUS_INVALID_ARGUMENT
;
726 req
.raw_data_cb
= ubus_remove_object_cb
;
728 ret
= ubus_complete_request(ctx
, &req
, 0);
733 return UBUS_STATUS_NO_DATA
;
738 static int ubus_event_cb(struct ubus_context
*ctx
, struct ubus_object
*obj
,
739 struct ubus_request_data
*req
,
740 const char *method
, struct blob_attr
*msg
)
742 struct ubus_event_handler
*ev
;
744 ev
= container_of(obj
, struct ubus_event_handler
, obj
);
745 ev
->cb(ctx
, ev
, method
, msg
);
749 static const struct ubus_method event_method
= {
751 .handler
= ubus_event_cb
,
754 int ubus_register_event_handler(struct ubus_context
*ctx
,
755 struct ubus_event_handler
*ev
,
758 struct ubus_object
*obj
= &ev
->obj
;
763 obj
->methods
= &event_method
;
766 if (!!obj
->name
^ !!obj
->type
)
767 return UBUS_STATUS_INVALID_ARGUMENT
;
769 ret
= __ubus_add_object(ctx
, obj
);
774 /* use a second buffer, ubus_invoke() overwrites the primary one */
775 memset(&b2
, 0, sizeof(b2
));
776 blob_buf_init(&b2
, 0);
777 blobmsg_add_u32(&b2
, "object", obj
->id
);
779 blobmsg_add_string(&b2
, "pattern", pattern
);
781 return ubus_invoke(ctx
, UBUS_SYSTEM_OBJECT_EVENT
, "register", b2
.head
,
785 int ubus_send_event(struct ubus_context
*ctx
, const char *id
,
786 struct blob_attr
*data
)
788 struct ubus_request req
;
791 blob_buf_init(&b
, 0);
792 blob_put_int32(&b
, UBUS_ATTR_OBJID
, UBUS_SYSTEM_OBJECT_EVENT
);
793 blob_put_string(&b
, UBUS_ATTR_METHOD
, "send");
794 s
= blob_nest_start(&b
, UBUS_ATTR_DATA
);
795 blobmsg_add_string(&b
, "id", id
);
796 blobmsg_add_field(&b
, BLOBMSG_TYPE_TABLE
, "data", blob_data(data
), blob_len(data
));
797 blob_nest_end(&b
, s
);
799 if (ubus_start_request(ctx
, &req
, b
.head
, UBUS_MSG_INVOKE
, UBUS_SYSTEM_OBJECT_EVENT
) < 0)
800 return UBUS_STATUS_INVALID_ARGUMENT
;
802 return ubus_complete_request(ctx
, &req
, 0);
805 static void ubus_default_connection_lost(struct ubus_context
*ctx
)
807 if (ctx
->sock
.registered
)
811 struct ubus_context
*ubus_connect(const char *path
)
813 struct ubus_context
*ctx
;
815 struct ubus_msghdr hdr
;
816 struct blob_attr data
;
818 struct blob_attr
*buf
;
821 path
= UBUS_UNIX_SOCKET
;
823 ctx
= calloc(1, sizeof(*ctx
));
827 ctx
->sock
.fd
= usock(USOCK_UNIX
, path
, NULL
);
828 if (ctx
->sock
.fd
< 0)
831 ctx
->sock
.cb
= ubus_handle_data
;
833 if (read(ctx
->sock
.fd
, &hdr
, sizeof(hdr
)) != sizeof(hdr
))
836 if (!ubus_validate_hdr(&hdr
.hdr
))
839 if (hdr
.hdr
.type
!= UBUS_MSG_HELLO
)
842 buf
= calloc(1, blob_raw_len(&hdr
.data
));
846 memcpy(buf
, &hdr
.data
, sizeof(hdr
.data
));
847 if (read(ctx
->sock
.fd
, blob_data(buf
), blob_len(buf
)) != blob_len(buf
))
850 ctx
->local_id
= hdr
.hdr
.peer
;
853 ctx
->connection_lost
= ubus_default_connection_lost
;
855 INIT_LIST_HEAD(&ctx
->requests
);
856 avl_init(&ctx
->objects
, ubus_cmp_id
, false, NULL
);
873 void ubus_free(struct ubus_context
*ctx
)