}
static int
-__ubus_subscribe_request(struct ubus_context *ctx, struct ubus_object *obj, uint32_t id, const char *method, int type)
+__ubus_subscribe_request(struct ubus_context *ctx, struct ubus_object *obj, uint32_t id, int type)
{
struct ubus_request req;
blob_buf_init(&b, 0);
blob_put_int32(&b, UBUS_ATTR_OBJID, obj->id);
blob_put_int32(&b, UBUS_ATTR_TARGET, id);
- if (method)
- blob_put_string(&b, UBUS_ATTR_METHOD, method);
if (ubus_start_request(ctx, &req, b.head, type, 0) < 0)
return UBUS_STATUS_INVALID_ARGUMENT;
int ubus_subscribe(struct ubus_context *ctx, struct ubus_subscriber *obj, uint32_t id)
{
- return __ubus_subscribe_request(ctx, &obj->obj, id, "event", UBUS_MSG_SUBSCRIBE);
+ return __ubus_subscribe_request(ctx, &obj->obj, id, UBUS_MSG_SUBSCRIBE);
}
int ubus_unsubscribe(struct ubus_context *ctx, struct ubus_subscriber *obj, uint32_t id)
{
- return __ubus_subscribe_request(ctx, &obj->obj, id, NULL, UBUS_MSG_UNSUBSCRIBE);
+ return __ubus_subscribe_request(ctx, &obj->obj, id, UBUS_MSG_UNSUBSCRIBE);
}
void __hidden ubus_process_unsubscribe(struct ubus_context *ctx, struct ubus_msghdr *hdr)
return NULL;
}
-void ubus_subscribe(struct ubus_object *obj, struct ubus_object *target, const char *method)
+void ubus_subscribe(struct ubus_object *obj, struct ubus_object *target)
{
struct ubus_subscription *s;
bool first = list_empty(&target->subscribers);
- s = calloc(1, sizeof(*s) + strlen(method) + 1);
+ s = calloc(1, sizeof(*s));
if (!s)
return;
s->target = target;
list_add(&s->list, &target->subscribers);
list_add(&s->target_list, &obj->target_list);
- strcpy(s->method, method);
if (first)
ubus_notify_subscription(target);
struct ubus_subscription {
struct list_head list, target_list;
struct ubus_object *subscriber, *target;
- char method[];
};
struct ubus_object {
return obj;
}
-void ubus_subscribe(struct ubus_object *obj, struct ubus_object *target, const char *method);
+void ubus_subscribe(struct ubus_object *obj, struct ubus_object *target);
void ubus_unsubscribe(struct ubus_subscription *s);
void ubus_notify_unsubscribe(struct ubus_subscription *s);
void ubus_notify_subscription(struct ubus_object *obj);
{
struct ubus_object *obj, *target;
- if (!attr[UBUS_ATTR_OBJID] || !attr[UBUS_ATTR_TARGET] ||
- !attr[UBUS_ATTR_METHOD]) {
+ if (!attr[UBUS_ATTR_OBJID] || !attr[UBUS_ATTR_TARGET])
return UBUS_STATUS_INVALID_ARGUMENT;
- }
obj = ubusd_find_object(blob_get_u32(attr[UBUS_ATTR_OBJID]));
if (!obj)
if (cl == target->client)
return UBUS_STATUS_INVALID_ARGUMENT;
- ubus_subscribe(obj, target, blob_data(attr[UBUS_ATTR_METHOD]));
+ ubus_subscribe(obj, target);
return 0;
}