Bump ubus to version: 2017.01.22
This commit is contained in:
2
src/3P/ubus/.gitignore
vendored
2
src/3P/ubus/.gitignore
vendored
@@ -7,4 +7,6 @@ CMakeFiles
|
||||
*.dylib
|
||||
examples/server
|
||||
examples/client
|
||||
ubusd
|
||||
ubus
|
||||
install_manifest.txt
|
||||
|
||||
@@ -13,11 +13,6 @@ SET(UBUS_MAX_MSGLEN 1048576)
|
||||
ADD_DEFINITIONS( -DUBUS_UNIX_SOCKET="${UBUS_UNIX_SOCKET}")
|
||||
ADD_DEFINITIONS( -DUBUS_MAX_MSGLEN=${UBUS_MAX_MSGLEN})
|
||||
|
||||
IF(APPLE)
|
||||
INCLUDE_DIRECTORIES(/opt/local/include)
|
||||
LINK_DIRECTORIES(/opt/local/lib)
|
||||
ENDIF()
|
||||
|
||||
IF(BUILD_STATIC)
|
||||
FIND_LIBRARY(ubox_library NAMES ubox.a)
|
||||
FIND_LIBRARY(blob_library NAMES blobmsg_json.a)
|
||||
|
||||
@@ -293,17 +293,20 @@ static int ubus_cli_wait_for(struct ubus_context *ctx, int argc, char **argv)
|
||||
uloop_init();
|
||||
ubus_add_uloop(ctx);
|
||||
|
||||
ret = ubus_lookup(ctx, NULL, wait_list_cb, &data);
|
||||
ret = ubus_register_event_handler(ctx, &data.ev, "ubus.object.add");
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (!data.n_pending)
|
||||
return ret;
|
||||
|
||||
ret = ubus_register_event_handler(ctx, &data.ev, "ubus.object.add");
|
||||
ret = ubus_lookup(ctx, NULL, wait_list_cb, &data);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (!data.n_pending)
|
||||
return ret;
|
||||
|
||||
uloop_timeout_set(&data.timeout, timeout * 1000);
|
||||
uloop_run();
|
||||
uloop_done();
|
||||
|
||||
@@ -24,7 +24,9 @@ int ubus_send_msg(struct ubus_context *ctx, uint32_t seq,
|
||||
void ubus_process_msg(struct ubus_context *ctx, struct ubus_msghdr_buf *buf, int fd);
|
||||
int __hidden ubus_start_request(struct ubus_context *ctx, struct ubus_request *req,
|
||||
struct blob_attr *msg, int cmd, uint32_t peer);
|
||||
void ubus_process_obj_msg(struct ubus_context *ctx, struct ubus_msghdr_buf *buf);
|
||||
int __hidden __ubus_start_request(struct ubus_context *ctx, struct ubus_request *req,
|
||||
struct blob_attr *msg, int cmd, uint32_t peer);
|
||||
void ubus_process_obj_msg(struct ubus_context *ctx, struct ubus_msghdr_buf *buf, int fd);
|
||||
void ubus_process_req_msg(struct ubus_context *ctx, struct ubus_msghdr_buf *buf, int fd);
|
||||
void __hidden ubus_poll_data(struct ubus_context *ctx, int timeout);
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
//#define _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#include <sys/types.h>
|
||||
#include <sys/uio.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
@@ -11,12 +11,13 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include "libubus.h"
|
||||
#include "libubus-internal.h"
|
||||
|
||||
static void
|
||||
ubus_process_unsubscribe(struct ubus_context *ctx, struct ubus_msghdr *hdr,
|
||||
struct ubus_object *obj, struct blob_attr **attrbuf)
|
||||
struct ubus_object *obj, struct blob_attr **attrbuf, int fd)
|
||||
{
|
||||
struct ubus_subscriber *s;
|
||||
|
||||
@@ -29,11 +30,13 @@ ubus_process_unsubscribe(struct ubus_context *ctx, struct ubus_msghdr *hdr,
|
||||
s = container_of(obj, struct ubus_subscriber, obj);
|
||||
if (s->remove_cb)
|
||||
s->remove_cb(ctx, s, blob_get_u32(attrbuf[UBUS_ATTR_TARGET]));
|
||||
|
||||
close(fd);
|
||||
}
|
||||
|
||||
static void
|
||||
ubus_process_notify(struct ubus_context *ctx, struct ubus_msghdr *hdr,
|
||||
struct ubus_object *obj, struct blob_attr **attrbuf)
|
||||
struct ubus_object *obj, struct blob_attr **attrbuf, int fd)
|
||||
{
|
||||
if (!obj || !attrbuf[UBUS_ATTR_ACTIVE])
|
||||
return;
|
||||
@@ -41,14 +44,18 @@ ubus_process_notify(struct ubus_context *ctx, struct ubus_msghdr *hdr,
|
||||
obj->has_subscribers = blob_get_u8(attrbuf[UBUS_ATTR_ACTIVE]);
|
||||
if (obj->subscribe_cb)
|
||||
obj->subscribe_cb(ctx, obj);
|
||||
|
||||
close(fd);
|
||||
}
|
||||
static void
|
||||
ubus_process_invoke(struct ubus_context *ctx, struct ubus_msghdr *hdr,
|
||||
struct ubus_object *obj, struct blob_attr **attrbuf)
|
||||
struct ubus_object *obj, struct blob_attr **attrbuf, int fd)
|
||||
{
|
||||
struct ubus_request_data req = {
|
||||
.fd = -1,
|
||||
.req_fd = fd,
|
||||
};
|
||||
|
||||
int method;
|
||||
int ret;
|
||||
bool no_reply = false;
|
||||
@@ -65,7 +72,7 @@ ubus_process_invoke(struct ubus_context *ctx, struct ubus_msghdr *hdr,
|
||||
|
||||
if (attrbuf[UBUS_ATTR_NO_REPLY])
|
||||
no_reply = blob_get_int8(attrbuf[UBUS_ATTR_NO_REPLY]);
|
||||
|
||||
|
||||
req.peer = hdr->peer;
|
||||
req.seq = hdr->seq;
|
||||
req.object = obj->id;
|
||||
@@ -88,6 +95,7 @@ found:
|
||||
ret = obj->methods[method].handler(ctx, obj, &req,
|
||||
blob_data(attrbuf[UBUS_ATTR_METHOD]),
|
||||
attrbuf[UBUS_ATTR_DATA]);
|
||||
close(req.req_fd);
|
||||
if (req.deferred || no_reply)
|
||||
return;
|
||||
|
||||
@@ -95,16 +103,16 @@ send:
|
||||
ubus_complete_deferred_request(ctx, &req, ret);
|
||||
}
|
||||
|
||||
void __hidden ubus_process_obj_msg(struct ubus_context *ctx, struct ubus_msghdr_buf *buf)
|
||||
|
||||
void __hidden ubus_process_obj_msg(struct ubus_context *ctx, struct ubus_msghdr_buf *buf, int fd)
|
||||
{
|
||||
void (*cb)(struct ubus_context *, struct ubus_msghdr *,
|
||||
struct ubus_object *, struct blob_attr **);
|
||||
struct ubus_object *, struct blob_attr **, int fd);
|
||||
struct ubus_msghdr *hdr = &buf->hdr;
|
||||
struct blob_attr **attrbuf;
|
||||
struct ubus_object *obj;
|
||||
uint32_t objid;
|
||||
void *prev_data = NULL;
|
||||
|
||||
attrbuf = ubus_parse_msg(buf->data);
|
||||
if (!attrbuf[UBUS_ATTR_OBJID])
|
||||
return;
|
||||
@@ -131,7 +139,7 @@ void __hidden ubus_process_obj_msg(struct ubus_context *ctx, struct ubus_msghdr_
|
||||
buf->data = NULL;
|
||||
}
|
||||
|
||||
cb(ctx, hdr, obj, attrbuf);
|
||||
cb(ctx, hdr, obj, attrbuf, fd);
|
||||
|
||||
if (prev_data) {
|
||||
if (buf->data)
|
||||
|
||||
@@ -49,10 +49,9 @@ static void __ubus_process_req_data(struct ubus_request *req)
|
||||
}
|
||||
}
|
||||
|
||||
int __hidden ubus_start_request(struct ubus_context *ctx, struct ubus_request *req,
|
||||
int __hidden __ubus_start_request(struct ubus_context *ctx, struct ubus_request *req,
|
||||
struct blob_attr *msg, int cmd, uint32_t peer)
|
||||
{
|
||||
memset(req, 0, sizeof(*req));
|
||||
|
||||
if (msg && blob_pad_len(msg) > UBUS_MAX_MSGLEN)
|
||||
return -1;
|
||||
@@ -62,9 +61,21 @@ int __hidden ubus_start_request(struct ubus_context *ctx, struct ubus_request *r
|
||||
req->ctx = ctx;
|
||||
req->peer = peer;
|
||||
req->seq = ++ctx->request_seq;
|
||||
return ubus_send_msg(ctx, req->seq, msg, cmd, peer, -1);
|
||||
|
||||
return ubus_send_msg(ctx, req->seq, msg, cmd, peer, req->fd);
|
||||
}
|
||||
|
||||
int __hidden ubus_start_request(struct ubus_context *ctx, struct ubus_request *req,
|
||||
struct blob_attr *msg, int cmd, uint32_t peer)
|
||||
{
|
||||
memset(req, 0, sizeof(*req));
|
||||
|
||||
req->fd = -1;
|
||||
|
||||
return __ubus_start_request(ctx, req, msg, cmd, peer);
|
||||
}
|
||||
|
||||
|
||||
void ubus_abort_request(struct ubus_context *ctx, struct ubus_request *req)
|
||||
{
|
||||
if (list_empty(&req->list))
|
||||
@@ -129,15 +140,9 @@ int ubus_complete_request(struct ubus_context *ctx, struct ubus_request *req,
|
||||
int req_timeout)
|
||||
{
|
||||
ubus_complete_handler_t complete_cb = req->complete_cb;
|
||||
bool registered = ctx->sock.registered;
|
||||
int status = UBUS_STATUS_NO_DATA;
|
||||
int64_t timeout = 0, time_end = 0;
|
||||
|
||||
if (!registered) {
|
||||
uloop_init();
|
||||
ubus_add_uloop(ctx);
|
||||
}
|
||||
|
||||
if (req_timeout)
|
||||
time_end = get_time_msec() + req_timeout;
|
||||
|
||||
@@ -176,12 +181,8 @@ int ubus_complete_request(struct ubus_context *ctx, struct ubus_request *req,
|
||||
if (req->complete_cb)
|
||||
req->complete_cb(req, status);
|
||||
|
||||
if (!registered) {
|
||||
uloop_fd_delete(&ctx->sock);
|
||||
|
||||
if (!ctx->stack_depth)
|
||||
ctx->pending_timer.cb(&ctx->pending_timer);
|
||||
}
|
||||
if (!ctx->stack_depth && !ctx->sock.registered)
|
||||
ctx->pending_timer.cb(&ctx->pending_timer);
|
||||
|
||||
return status;
|
||||
}
|
||||
@@ -209,8 +210,9 @@ int ubus_send_reply(struct ubus_context *ctx, struct ubus_request_data *req,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ubus_invoke_async(struct ubus_context *ctx, uint32_t obj, const char *method,
|
||||
struct blob_attr *msg, struct ubus_request *req)
|
||||
int ubus_invoke_async_fd(struct ubus_context *ctx, uint32_t obj,
|
||||
const char *method, struct blob_attr *msg,
|
||||
struct ubus_request *req, int fd)
|
||||
{
|
||||
blob_buf_init(&b, 0);
|
||||
blob_put_int32(&b, UBUS_ATTR_OBJID, obj);
|
||||
@@ -218,20 +220,21 @@ int ubus_invoke_async(struct ubus_context *ctx, uint32_t obj, const char *method
|
||||
if (msg)
|
||||
blob_put(&b, UBUS_ATTR_DATA, blob_data(msg), blob_len(msg));
|
||||
|
||||
if (ubus_start_request(ctx, req, b.head, UBUS_MSG_INVOKE, obj) < 0)
|
||||
memset(req, 0, sizeof(*req));
|
||||
req->fd = fd;
|
||||
if (__ubus_start_request(ctx, req, b.head, UBUS_MSG_INVOKE, obj) < 0)
|
||||
return UBUS_STATUS_INVALID_ARGUMENT;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ubus_invoke(struct ubus_context *ctx, uint32_t obj, const char *method,
|
||||
struct blob_attr *msg, ubus_data_handler_t cb, void *priv,
|
||||
int timeout)
|
||||
int ubus_invoke_fd(struct ubus_context *ctx, uint32_t obj, const char *method,
|
||||
struct blob_attr *msg, ubus_data_handler_t cb, void *priv,
|
||||
int timeout, int fd)
|
||||
{
|
||||
struct ubus_request req;
|
||||
int rc;
|
||||
|
||||
rc = ubus_invoke_async(ctx, obj, method, msg, &req);
|
||||
rc = ubus_invoke_async_fd(ctx, obj, method, msg, &req, fd);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ ubus_process_msg(struct ubus_context *ctx, struct ubus_msghdr_buf *buf, int fd)
|
||||
break;
|
||||
}
|
||||
|
||||
ubus_process_obj_msg(ctx, buf);
|
||||
ubus_process_obj_msg(ctx, buf, fd);
|
||||
break;
|
||||
case UBUS_MSG_MONITOR:
|
||||
if (ctx->monitor_cb)
|
||||
@@ -196,8 +196,7 @@ int ubus_lookup_id(struct ubus_context *ctx, const char *path, uint32_t *id)
|
||||
req.raw_data_cb = ubus_lookup_id_cb;
|
||||
req.priv = id;
|
||||
|
||||
// Awox Remomve infinite timeout: return ubus_complete_request(ctx, &req, 0);
|
||||
return ubus_complete_request(ctx, &req, 5000);
|
||||
return ubus_complete_request(ctx, &req, 0);
|
||||
}
|
||||
|
||||
static int ubus_event_cb(struct ubus_context *ctx, struct ubus_object *obj,
|
||||
@@ -278,6 +277,7 @@ static void ubus_default_connection_lost(struct ubus_context *ctx)
|
||||
|
||||
int ubus_connect_ctx(struct ubus_context *ctx, const char *path)
|
||||
{
|
||||
uloop_init();
|
||||
memset(ctx, 0, sizeof(*ctx));
|
||||
|
||||
ctx->sock.fd = -1;
|
||||
@@ -363,6 +363,7 @@ void ubus_shutdown(struct ubus_context *ctx)
|
||||
if (!ctx)
|
||||
return;
|
||||
close(ctx->sock.fd);
|
||||
uloop_timeout_cancel(&ctx->pending_timer);
|
||||
free(ctx->msgbuf.data);
|
||||
}
|
||||
|
||||
|
||||
@@ -143,7 +143,6 @@ struct ubus_event_handler {
|
||||
struct ubus_object obj;
|
||||
|
||||
ubus_event_handler_t cb;
|
||||
void *priv; // Awox Addon
|
||||
};
|
||||
|
||||
struct ubus_context {
|
||||
@@ -189,6 +188,7 @@ struct ubus_request_data {
|
||||
/* internal use */
|
||||
bool deferred;
|
||||
int fd;
|
||||
int req_fd; /* fd received from the initial request */
|
||||
};
|
||||
|
||||
struct ubus_request {
|
||||
@@ -209,6 +209,8 @@ struct ubus_request {
|
||||
ubus_fd_handler_t fd_cb;
|
||||
ubus_complete_handler_t complete_cb;
|
||||
|
||||
int fd;
|
||||
|
||||
struct ubus_context *ctx;
|
||||
void *priv;
|
||||
};
|
||||
@@ -329,13 +331,26 @@ int ubus_register_acl(struct ubus_context *ctx);
|
||||
/* ----------- rpc ----------- */
|
||||
|
||||
/* invoke a method on a specific object */
|
||||
int ubus_invoke(struct ubus_context *ctx, uint32_t obj, const char *method,
|
||||
int ubus_invoke_fd(struct ubus_context *ctx, uint32_t obj, const char *method,
|
||||
struct blob_attr *msg, ubus_data_handler_t cb, void *priv,
|
||||
int timeout);
|
||||
int timeout, int fd);
|
||||
static inline int
|
||||
ubus_invoke(struct ubus_context *ctx, uint32_t obj, const char *method,
|
||||
struct blob_attr *msg, ubus_data_handler_t cb, void *priv,
|
||||
int timeout)
|
||||
{
|
||||
return ubus_invoke_fd(ctx, obj, method, msg, cb, priv, timeout, -1);
|
||||
}
|
||||
|
||||
/* asynchronous version of ubus_invoke() */
|
||||
int ubus_invoke_async(struct ubus_context *ctx, uint32_t obj, const char *method,
|
||||
struct blob_attr *msg, struct ubus_request *req);
|
||||
int ubus_invoke_async_fd(struct ubus_context *ctx, uint32_t obj, const char *method,
|
||||
struct blob_attr *msg, struct ubus_request *req, int fd);
|
||||
static inline int
|
||||
ubus_invoke_async(struct ubus_context *ctx, uint32_t obj, const char *method,
|
||||
struct blob_attr *msg, struct ubus_request *req)
|
||||
{
|
||||
return ubus_invoke_async_fd(ctx, obj, method, msg, req, -1);
|
||||
}
|
||||
|
||||
/* send a reply to an incoming object method call */
|
||||
int ubus_send_reply(struct ubus_context *ctx, struct ubus_request_data *req,
|
||||
@@ -357,6 +372,14 @@ static inline void ubus_request_set_fd(struct ubus_context *ctx,
|
||||
req->fd = fd;
|
||||
}
|
||||
|
||||
static inline int ubus_request_get_caller_fd(struct ubus_request_data *req)
|
||||
{
|
||||
int fd = req->req_fd;
|
||||
req->req_fd = -1;
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
void ubus_complete_deferred_request(struct ubus_context *ctx,
|
||||
struct ubus_request_data *req, int ret);
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
_*
|
||||
0
src/3P/ubus/lua/publisher.lua
Normal file → Executable file
0
src/3P/ubus/lua/publisher.lua
Normal file → Executable file
0
src/3P/ubus/lua/subscriber.lua
Normal file → Executable file
0
src/3P/ubus/lua/subscriber.lua
Normal file → Executable file
@@ -34,6 +34,18 @@ local my_method = {
|
||||
conn:reply(req, {message="foo2"});
|
||||
print("Call to function 'hello1'")
|
||||
end, {id = ubus.INT32, msg = ubus.STRING }
|
||||
},
|
||||
deferred = {
|
||||
function(req)
|
||||
conn:reply(req, {message="wait for it"})
|
||||
local def_req = conn:defer_request(req)
|
||||
uloop.timer(function()
|
||||
conn:reply(def_req, {message="done"})
|
||||
conn:complete_deferred_request(def_req, 0)
|
||||
print("Deferred request complete")
|
||||
end, 2000)
|
||||
print("Call to function 'deferred'")
|
||||
end, {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -352,6 +352,26 @@ static int ubus_lua_reply(lua_State *L)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ubus_lua_defer_request(lua_State *L)
|
||||
{
|
||||
struct ubus_lua_connection *c = luaL_checkudata(L, 1, METANAME);
|
||||
struct ubus_request_data *req = lua_touserdata(L, 2);
|
||||
struct ubus_request_data *new_req = lua_newuserdata(L, sizeof(struct ubus_request_data));
|
||||
ubus_defer_request(c->ctx, req, new_req);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int ubus_lua_complete_deferred_request(lua_State *L)
|
||||
{
|
||||
struct ubus_lua_connection *c = luaL_checkudata(L, 1, METANAME);
|
||||
struct ubus_request_data *req = lua_touserdata(L, 2);
|
||||
int ret = luaL_checkinteger(L, 3);
|
||||
ubus_complete_deferred_request(c->ctx, req, ret);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ubus_lua_load_methods(lua_State *L, struct ubus_method *m)
|
||||
{
|
||||
struct blobmsg_policy *p;
|
||||
@@ -920,6 +940,8 @@ static const luaL_Reg ubus[] = {
|
||||
{ "add", ubus_lua_add },
|
||||
{ "notify", ubus_lua_notify },
|
||||
{ "reply", ubus_lua_reply },
|
||||
{ "defer_request", ubus_lua_defer_request },
|
||||
{ "complete_deferred_request", ubus_lua_complete_deferred_request },
|
||||
{ "signatures", ubus_lua_signatures },
|
||||
{ "call", ubus_lua_call },
|
||||
{ "close", ubus_lua__gc },
|
||||
|
||||
@@ -148,12 +148,13 @@ void ubus_msg_send(struct ubus_client *cl, struct ubus_msg_buf *ub, bool free)
|
||||
|
||||
if (!cl->tx_queue[cl->txq_cur]) {
|
||||
written = ubus_msg_writev(cl->sock.fd, ub, 0);
|
||||
if (written >= ub->len + sizeof(ub->hdr))
|
||||
goto out;
|
||||
|
||||
if (written < 0)
|
||||
written = 0;
|
||||
|
||||
if (written >= ub->len + sizeof(ub->hdr))
|
||||
goto out;
|
||||
|
||||
cl->txq_ofs = written;
|
||||
|
||||
/* get an event once we can write to the socket again */
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
//#define _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
@@ -101,7 +101,7 @@ ubusd_acl_check(struct ubus_client *cl, const char *obj,
|
||||
struct blob_attr *cur;
|
||||
int rem;
|
||||
|
||||
if (!cl->uid)
|
||||
if (!cl->uid || !obj)
|
||||
return 0;
|
||||
|
||||
acl = avl_find_ge_element(&ubusd_acls, obj, acl, avl);
|
||||
@@ -434,7 +434,7 @@ ubusd_reply_add(struct ubus_object *obj)
|
||||
if (!acl->priv)
|
||||
continue;
|
||||
|
||||
if (!ubusd_acl_match_path(obj->path.key, acl->avl.key, NULL))
|
||||
if (ubusd_acl_match_path(obj->path.key, acl->avl.key, NULL))
|
||||
continue;
|
||||
|
||||
c = blobmsg_open_table(&b, NULL);
|
||||
|
||||
@@ -80,11 +80,15 @@ void
|
||||
ubus_proto_send_msg_from_blob(struct ubus_client *cl, struct ubus_msg_buf *ub,
|
||||
uint8_t type)
|
||||
{
|
||||
/* keep the fd to be passed if it is UBUS_MSG_INVOKE */
|
||||
int fd = ub->fd;
|
||||
ub = ubus_reply_from_blob(ub, true);
|
||||
if (!ub)
|
||||
return;
|
||||
|
||||
ub->hdr.type = type;
|
||||
ub->fd = fd;
|
||||
|
||||
ubus_msg_send(cl, ub, true);
|
||||
}
|
||||
|
||||
@@ -130,8 +134,8 @@ static int ubusd_handle_remove_object(struct ubus_client *cl, struct ubus_msg_bu
|
||||
if (obj->type && obj->type->refcount == 1)
|
||||
blob_put_int32(&b, UBUS_ATTR_OBJTYPE, obj->type->id.id);
|
||||
|
||||
ubusd_free_object(obj);
|
||||
ubus_proto_send_msg_from_blob(cl, ub, UBUS_MSG_DATA);
|
||||
ubusd_free_object(obj);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -146,7 +150,7 @@ static int ubusd_handle_add_object(struct ubus_client *cl, struct ubus_msg_buf *
|
||||
|
||||
blob_buf_init(&b, 0);
|
||||
blob_put_int32(&b, UBUS_ATTR_OBJID, obj->id.id);
|
||||
if (attr[UBUS_ATTR_SIGNATURE])
|
||||
if (attr[UBUS_ATTR_SIGNATURE] && obj->type)
|
||||
blob_put_int32(&b, UBUS_ATTR_OBJTYPE, obj->type->id.id);
|
||||
|
||||
ubus_proto_send_msg_from_blob(cl, ub, UBUS_MSG_DATA);
|
||||
@@ -156,9 +160,12 @@ static int ubusd_handle_add_object(struct ubus_client *cl, struct ubus_msg_buf *
|
||||
static void ubusd_send_obj(struct ubus_client *cl, struct ubus_msg_buf *ub, struct ubus_object *obj)
|
||||
{
|
||||
struct ubus_method *m;
|
||||
int cnt = 0;
|
||||
int all_cnt = 0, cnt = 0;
|
||||
void *s;
|
||||
|
||||
if (!obj->type)
|
||||
return;
|
||||
|
||||
blob_buf_init(&b, 0);
|
||||
|
||||
blob_put_string(&b, UBUS_ATTR_OBJPATH, obj->path.key);
|
||||
@@ -167,6 +174,7 @@ static void ubusd_send_obj(struct ubus_client *cl, struct ubus_msg_buf *ub, stru
|
||||
|
||||
s = blob_nest_start(&b, UBUS_ATTR_SIGNATURE);
|
||||
list_for_each_entry(m, &obj->type->methods, list) {
|
||||
all_cnt++;
|
||||
if (!ubusd_acl_check(cl, obj->path.key, blobmsg_name(m->data), UBUS_ACL_ACCESS)) {
|
||||
blobmsg_add_blob(&b, m->data);
|
||||
cnt++;
|
||||
@@ -174,7 +182,7 @@ static void ubusd_send_obj(struct ubus_client *cl, struct ubus_msg_buf *ub, stru
|
||||
}
|
||||
blob_nest_end(&b, s);
|
||||
|
||||
if (cnt)
|
||||
if (cnt || !all_cnt)
|
||||
ubus_proto_send_msg_from_blob(cl, ub, UBUS_MSG_DATA);
|
||||
}
|
||||
|
||||
@@ -374,7 +382,7 @@ static int ubusd_handle_add_watch(struct ubus_client *cl, struct ubus_msg_buf *u
|
||||
return UBUS_STATUS_INVALID_ARGUMENT;
|
||||
|
||||
target = ubusd_find_object(blob_get_u32(attr[UBUS_ATTR_TARGET]));
|
||||
if (!target)
|
||||
if (!target || !target->client)
|
||||
return UBUS_STATUS_NOT_FOUND;
|
||||
|
||||
if (cl == target->client)
|
||||
@@ -443,7 +451,7 @@ void ubusd_proto_receive_message(struct ubus_client *cl, struct ubus_msg_buf *ub
|
||||
if (ub->hdr.type < __UBUS_MSG_LAST)
|
||||
cb = handlers[ub->hdr.type];
|
||||
|
||||
if (ub->hdr.type != UBUS_MSG_STATUS)
|
||||
if (ub->hdr.type != UBUS_MSG_STATUS && ub->hdr.type != UBUS_MSG_INVOKE)
|
||||
ubus_msg_close_fd(ub);
|
||||
|
||||
if (cb)
|
||||
|
||||
@@ -19,8 +19,7 @@
|
||||
|
||||
#define __packetdata __attribute__((packed)) __attribute__((__aligned__(4)))
|
||||
|
||||
//AWOX REDUCE SIZE. #define UBUS_MSG_CHUNK_SIZE 65536
|
||||
#define UBUS_MSG_CHUNK_SIZE 16384
|
||||
#define UBUS_MSG_CHUNK_SIZE 65536
|
||||
|
||||
#define UBUS_SYSTEM_OBJECT_EVENT 1
|
||||
#define UBUS_SYSTEM_OBJECT_ACL 2
|
||||
|
||||
Reference in New Issue
Block a user