+void __hidden ubus_process_obj_msg(struct ubus_context *ctx, struct ubus_msghdr_buf *buf)
+{
+ void (*cb)(struct ubus_context *, struct ubus_msghdr *,
+ struct ubus_object *, struct blob_attr **);
+ struct ubus_msghdr *hdr = &buf->hdr;
+ struct blob_attr **attrbuf;
+ struct ubus_object *obj;
+ uint32_t objid;
+ void *prev_data = NULL;
+
+ attrbuf = ubus_parse_msg(buf->data);
+ if (!attrbuf[UBUS_ATTR_OBJID])
+ return;
+
+ objid = blob_get_u32(attrbuf[UBUS_ATTR_OBJID]);
+ obj = avl_find_element(&ctx->objects, &objid, obj, avl);
+
+ switch (hdr->type) {
+ case UBUS_MSG_INVOKE:
+ cb = ubus_process_invoke;
+ break;
+ case UBUS_MSG_UNSUBSCRIBE:
+ cb = ubus_process_unsubscribe;
+ break;
+ case UBUS_MSG_NOTIFY:
+ cb = ubus_process_notify;
+ break;
+ default:
+ return;
+ }
+
+ if (buf == &ctx->msgbuf) {
+ prev_data = buf->data;
+ buf->data = NULL;
+ }
+
+ cb(ctx, hdr, obj, attrbuf);
+
+ if (prev_data) {
+ if (buf->data)
+ free(prev_data);
+ else
+ buf->data = prev_data;
+ }
+}
+