[LEDE-DEV] ubus: how to add an object with a 'catch' all method/signature

Delio Brignoli brignoli.delio at gmail.com
Tue Aug 23 07:15:18 PDT 2016


Hello Felix,

Is it possible to fill in struct ubus_object and struct ubus_object_type so that only one "catch all" method is defined and have the object available for lookup?

I can do:

struct ubus_method type_m = {
	.name = "_",
	.handler = NULL,
};

struct ubus_object_type obj_type = {
	.n_methods = 1,
	.methods = &type_m,
}

struct ubus_method obj_m = {
	.name = NULL,
	.handler = func,
};

struct ubus_object o = {
	.name = “path/to/obj”,
	.type = &obj_type;
	.n_methods = 1,
	.methods = &obj_m,
};

and libubus will be happy to call my handler for any method name as long as I define at least one method with a nonzero name length for the *type*. If (o.type == NULL) or (o.type->n_methods == 0) or (o.type->methods.name == NULL) or (o.type->methods.name == “") adding the object will succeed but the object cannot be looked up (its path does not appear when running `ubus list`).

Are objects with an empty signature not supported? If so, should adding such an object fail? If not, how can I setup a "catch all” (or empty) signature?

Thank you
—
Delio




More information about the Lede-dev mailing list