X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fubus.git;a=blobdiff_plain;f=ubusd_obj.h;h=a21f47c54153c6b18e3e6b20c348cf5d13b1ff65;hp=2064084ca31c56e1d02801b147b0f7897ec4acad;hb=5db90dbc941da701c397b04ddce2515a231df59b;hpb=527d2523330cb41e23a435d89352680d108c789a;ds=sidebyside diff --git a/ubusd_obj.h b/ubusd_obj.h index 2064084..a21f47c 100644 --- a/ubusd_obj.h +++ b/ubusd_obj.h @@ -1,3 +1,16 @@ +/* + * Copyright (C) 2011 Felix Fietkau + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + #ifndef __UBUSD_OBJ_H #define __UBUSD_OBJ_H @@ -22,17 +35,49 @@ struct ubus_method { struct blob_attr data[]; }; +struct ubus_subscription { + struct list_head list, target_list; + struct ubus_object *subscriber, *target; +}; + struct ubus_object { struct ubus_id id; struct list_head list; + struct list_head events; + + struct list_head subscribers, target_list; + struct ubus_object_type *type; struct avl_node path; struct ubus_client *client; + int (*recv_msg)(struct ubus_client *client, const char *method, struct blob_attr *msg); + + int event_seen; + unsigned int invoke_seq; }; struct ubus_object *ubusd_create_object(struct ubus_client *cl, struct blob_attr **attr); +struct ubus_object *ubusd_create_object_internal(struct ubus_object_type *type, uint32_t id); void ubusd_free_object(struct ubus_object *obj); +static inline struct ubus_object *ubusd_find_object(uint32_t objid) +{ + struct ubus_object *obj; + struct ubus_id *id; + + id = ubus_find_id(&objects, objid); + if (!id) + return NULL; + + obj = container_of(id, struct ubus_object, id); + return obj; +} + +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); + #endif