libubus: replace __init with __constructor
[project/ubus.git] / ubusmsg.h
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
14 #ifndef __UBUSMSG_H
15 #define __UBUSMSG_H
16
17 #include <stdint.h>
18 #include <libubox/blob.h>
19
20 #define __packetdata __attribute__((packed)) __attribute__((__aligned__(4)))
21
22 #define UBUS_MSG_CHUNK_SIZE 65536
23
24 #define UBUS_SYSTEM_OBJECT_EVENT 1
25 #define UBUS_SYSTEM_OBJECT_MAX 1024
26
27 struct ubus_msghdr {
28 uint8_t version;
29 uint8_t type;
30 uint16_t seq;
31 uint32_t peer;
32 } __packetdata;
33
34 enum ubus_msg_type {
35 /* initial server message */
36 UBUS_MSG_HELLO,
37
38 /* generic command response */
39 UBUS_MSG_STATUS,
40
41 /* data message response */
42 UBUS_MSG_DATA,
43
44 /* ping request */
45 UBUS_MSG_PING,
46
47 /* look up one or more objects */
48 UBUS_MSG_LOOKUP,
49
50 /* invoke a method on a single object */
51 UBUS_MSG_INVOKE,
52
53 UBUS_MSG_ADD_OBJECT,
54 UBUS_MSG_REMOVE_OBJECT,
55
56 /*
57 * subscribe/unsubscribe to object notifications
58 * The unsubscribe message is sent from ubusd when
59 * the object disappears
60 */
61 UBUS_MSG_SUBSCRIBE,
62 UBUS_MSG_UNSUBSCRIBE,
63
64 /*
65 * send a notification to all subscribers of an object.
66 * when sent from the server, it indicates a subscription
67 * status change
68 */
69 UBUS_MSG_NOTIFY,
70
71 /* must be last */
72 __UBUS_MSG_LAST,
73 };
74
75 enum ubus_msg_attr {
76 UBUS_ATTR_UNSPEC,
77
78 UBUS_ATTR_STATUS,
79
80 UBUS_ATTR_OBJPATH,
81 UBUS_ATTR_OBJID,
82 UBUS_ATTR_METHOD,
83
84 UBUS_ATTR_OBJTYPE,
85 UBUS_ATTR_SIGNATURE,
86
87 UBUS_ATTR_DATA,
88 UBUS_ATTR_TARGET,
89
90 UBUS_ATTR_ACTIVE,
91 UBUS_ATTR_NO_REPLY,
92
93 UBUS_ATTR_SUBSCRIBERS,
94
95 /* must be last */
96 UBUS_ATTR_MAX,
97 };
98
99 enum ubus_msg_status {
100 UBUS_STATUS_OK,
101 UBUS_STATUS_INVALID_COMMAND,
102 UBUS_STATUS_INVALID_ARGUMENT,
103 UBUS_STATUS_METHOD_NOT_FOUND,
104 UBUS_STATUS_NOT_FOUND,
105 UBUS_STATUS_NO_DATA,
106 UBUS_STATUS_PERMISSION_DENIED,
107 UBUS_STATUS_TIMEOUT,
108 UBUS_STATUS_NOT_SUPPORTED,
109 UBUS_STATUS_UNKNOWN_ERROR,
110 UBUS_STATUS_CONNECTION_FAILED,
111 __UBUS_STATUS_LAST
112 };
113
114 #endif