ubusmsg.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*
  2. * Copyright (C) 2011 Felix Fietkau <nbd@openwrt.org>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU Lesser General Public License version 2.1
  6. * as published by the Free Software Foundation
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. */
  13. #ifndef __UBUSMSG_H
  14. #define __UBUSMSG_H
  15. #include <stdint.h>
  16. #include <libubox/blob.h>
  17. #define __packetdata __attribute__((packed)) __attribute__((__aligned__(4)))
  18. #define UBUS_MSG_CHUNK_SIZE 65536
  19. #define UBUS_SYSTEM_OBJECT_EVENT 1
  20. #define UBUS_SYSTEM_OBJECT_ACL 2
  21. #define UBUS_SYSTEM_OBJECT_MONITOR 3
  22. #define UBUS_SYSTEM_OBJECT_MAX 1024
  23. struct ubus_msghdr {
  24. uint8_t version;
  25. uint8_t type;
  26. uint16_t seq;
  27. uint32_t peer;
  28. } __packetdata;
  29. enum ubus_msg_type {
  30. /* initial server message */
  31. UBUS_MSG_HELLO,
  32. /* generic command response */
  33. UBUS_MSG_STATUS,
  34. /* data message response */
  35. UBUS_MSG_DATA,
  36. /* ping request */
  37. UBUS_MSG_PING,
  38. /* look up one or more objects */
  39. UBUS_MSG_LOOKUP,
  40. /* invoke a method on a single object */
  41. UBUS_MSG_INVOKE,
  42. UBUS_MSG_ADD_OBJECT,
  43. UBUS_MSG_REMOVE_OBJECT,
  44. /*
  45. * subscribe/unsubscribe to object notifications
  46. * The unsubscribe message is sent from ubusd when
  47. * the object disappears
  48. */
  49. UBUS_MSG_SUBSCRIBE,
  50. UBUS_MSG_UNSUBSCRIBE,
  51. /*
  52. * send a notification to all subscribers of an object.
  53. * when sent from the server, it indicates a subscription
  54. * status change
  55. */
  56. UBUS_MSG_NOTIFY,
  57. UBUS_MSG_MONITOR,
  58. /* must be last */
  59. __UBUS_MSG_LAST,
  60. };
  61. enum ubus_msg_attr {
  62. UBUS_ATTR_UNSPEC,
  63. UBUS_ATTR_STATUS,
  64. UBUS_ATTR_OBJPATH,
  65. UBUS_ATTR_OBJID,
  66. UBUS_ATTR_METHOD,
  67. UBUS_ATTR_OBJTYPE,
  68. UBUS_ATTR_SIGNATURE,
  69. UBUS_ATTR_DATA,
  70. UBUS_ATTR_TARGET,
  71. UBUS_ATTR_ACTIVE,
  72. UBUS_ATTR_NO_REPLY,
  73. UBUS_ATTR_SUBSCRIBERS,
  74. UBUS_ATTR_USER,
  75. UBUS_ATTR_GROUP,
  76. /* must be last */
  77. UBUS_ATTR_MAX,
  78. };
  79. enum ubus_monitor_attr {
  80. UBUS_MONITOR_CLIENT,
  81. UBUS_MONITOR_PEER,
  82. UBUS_MONITOR_SEND,
  83. UBUS_MONITOR_SEQ,
  84. UBUS_MONITOR_TYPE,
  85. UBUS_MONITOR_DATA,
  86. /* must be last */
  87. UBUS_MONITOR_MAX,
  88. };
  89. enum ubus_msg_status {
  90. UBUS_STATUS_OK,
  91. UBUS_STATUS_INVALID_COMMAND,
  92. UBUS_STATUS_INVALID_ARGUMENT,
  93. UBUS_STATUS_METHOD_NOT_FOUND,
  94. UBUS_STATUS_NOT_FOUND,
  95. UBUS_STATUS_NO_DATA,
  96. UBUS_STATUS_PERMISSION_DENIED,
  97. UBUS_STATUS_TIMEOUT,
  98. UBUS_STATUS_NOT_SUPPORTED,
  99. UBUS_STATUS_UNKNOWN_ERROR,
  100. UBUS_STATUS_CONNECTION_FAILED,
  101. __UBUS_STATUS_LAST
  102. };
  103. #endif