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