ubusd_obj.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #ifndef __UBUSD_OBJ_H
  2. #define __UBUSD_OBJ_H
  3. #include "ubusd_id.h"
  4. extern struct avl_tree obj_types;
  5. extern struct avl_tree objects;
  6. extern struct avl_tree path;
  7. struct ubus_client;
  8. struct ubus_msg_buf;
  9. struct ubus_object_type {
  10. struct ubus_id id;
  11. int refcount;
  12. struct list_head methods;
  13. };
  14. struct ubus_method {
  15. struct list_head list;
  16. const char *name;
  17. struct blob_attr data[];
  18. };
  19. struct ubus_object {
  20. struct ubus_id id;
  21. struct list_head list;
  22. struct list_head events;
  23. struct ubus_object_type *type;
  24. struct avl_node path;
  25. struct ubus_client *client;
  26. int (*recv_msg)(struct ubus_client *client, const char *method, struct blob_attr *msg);
  27. };
  28. struct ubus_object *ubusd_create_object(struct ubus_client *cl, struct blob_attr **attr);
  29. struct ubus_object *ubusd_create_object_internal(struct ubus_object_type *type, uint32_t id);
  30. void ubusd_free_object(struct ubus_object *obj);
  31. static inline struct ubus_object *ubusd_find_object(uint32_t objid)
  32. {
  33. struct ubus_object *obj;
  34. struct ubus_id *id;
  35. id = ubus_find_id(&objects, objid);
  36. if (!id)
  37. return NULL;
  38. obj = container_of(id, struct ubus_object, id);
  39. return obj;
  40. }
  41. #endif