Merge Ubus with the 2016.02.26 version.

This commit is contained in:
2016-02-26 23:57:13 +01:00
parent 7eac5c920a
commit 5ed9eb9715
23 changed files with 1282 additions and 97 deletions

View File

@@ -61,11 +61,11 @@ static void test_hello_reply(struct uloop_timeout *t)
{
struct hello_request *req = container_of(t, struct hello_request, timeout);
int fds[2];
blob_buf_init(&b, 0);
blobmsg_add_string(&b, "message", req->data);
ubus_send_reply(ctx, &req->req, b.head);
if (pipe(fds) == -1) {
fprintf(stderr, "Failed to create pipe\n");
return;
@@ -73,7 +73,7 @@ static void test_hello_reply(struct uloop_timeout *t)
ubus_request_set_fd(ctx, &req->req, fds[0]);
ubus_complete_deferred_request(ctx, &req->req, 0);
req->fd = fds[1];
req->timeout.cb = test_hello_fd_reply;
test_hello_fd_reply(t);
}
@@ -86,18 +86,21 @@ static int test_hello(struct ubus_context *ctx, struct ubus_object *obj,
struct blob_attr *tb[__HELLO_MAX];
const char *format = "%s received a message: %s";
const char *msgstr = "(unknown)";
blobmsg_parse(hello_policy, ARRAY_SIZE(hello_policy), tb, blob_data(msg), blob_len(msg));
if (tb[HELLO_MSG])
msgstr = blobmsg_data(tb[HELLO_MSG]);
hreq = calloc(1, sizeof(*hreq) + strlen(format) + strlen(obj->name) + strlen(msgstr) + 1);
if (!hreq)
return UBUS_STATUS_UNKNOWN_ERROR;
sprintf(hreq->data, format, obj->name, msgstr);
ubus_defer_request(ctx, req, &hreq->req);
hreq->timeout.cb = test_hello_reply;
uloop_timeout_set(&hreq->timeout, 1000);
return 0;
}
@@ -248,13 +251,13 @@ int main(int argc, char **argv)
fprintf(stderr, "Failed to connect to ubus\n");
return -1;
}
ubus_add_uloop(ctx);
server_main();
ubus_free(ctx);
uloop_done();
return 0;
}