ubusd.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #ifndef __UBUSD_H
  2. #define __UBUSD_H
  3. #include <libubox/list.h>
  4. #include <libubox/uloop.h>
  5. #include <libubox/blobmsg.h>
  6. #include "ubus_common.h"
  7. #include "ubusd_id.h"
  8. #include "ubusd_obj.h"
  9. #include "ubusmsg.h"
  10. #define UBUSD_CLIENT_BACKLOG 32
  11. #define UBUS_OBJ_HASH_BITS 4
  12. struct ubus_msg_buf {
  13. uint32_t refcount; /* ~0: uses external data buffer */
  14. struct ubus_msghdr hdr;
  15. struct blob_attr *data;
  16. int len;
  17. };
  18. struct ubus_client {
  19. struct ubus_id id;
  20. struct uloop_fd sock;
  21. struct list_head objects;
  22. struct ubus_msg_buf *tx_queue[UBUSD_CLIENT_BACKLOG];
  23. unsigned int txq_cur, txq_tail, txq_ofs;
  24. struct ubus_msg_buf *pending_msg;
  25. int pending_msg_offset;
  26. struct {
  27. struct ubus_msghdr hdr;
  28. struct blob_attr data;
  29. } hdrbuf;
  30. };
  31. struct ubus_path {
  32. struct list_head list;
  33. const char name[];
  34. };
  35. struct ubus_msg_buf *ubus_msg_new(void *data, int len, bool shared);
  36. void ubus_msg_send(struct ubus_client *cl, struct ubus_msg_buf *ub, bool free);
  37. struct ubus_msg_buf *ubus_msg_ref(struct ubus_msg_buf *ub);
  38. void ubus_msg_free(struct ubus_msg_buf *ub);
  39. struct ubus_client *ubusd_get_client_by_id(uint32_t id);
  40. void ubusd_receive_message(struct ubus_client *cl, struct ubus_msg_buf *ub);
  41. bool ubusd_send_hello(struct ubus_client *cl);
  42. struct blob_attr **ubus_parse_msg(struct blob_attr *msg);
  43. void ubusd_event_init(void);
  44. void ubusd_event_cleanup_object(struct ubus_object *obj);
  45. #endif