Root/package/network/services/uhttpd/src/uhttpd-ubus.h

1/*
2 * uhttpd - Tiny single-threaded httpd - ubus header
3 *
4 * Copyright (C) 2012 Jo-Philipp Wich <xm@subsignal.org>
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19#ifndef _UHTTPD_UBUS_
20
21#include <time.h>
22
23#include <libubus.h>
24#include <libubox/avl.h>
25#include <libubox/blobmsg_json.h>
26#include <json/json.h>
27
28
29#define UH_UBUS_MAX_POST_SIZE 4096
30
31
32struct uh_ubus_state {
33    struct ubus_context *ctx;
34    struct ubus_object ubus;
35    struct blob_buf buf;
36    struct avl_tree sessions;
37    int timeout;
38};
39
40struct uh_ubus_request_data {
41    const char *sid;
42    const char *object;
43    const char *function;
44};
45
46struct uh_ubus_session {
47    char id[33];
48    int timeout;
49    struct avl_node avl;
50    struct avl_tree data;
51    struct avl_tree acls;
52    struct timespec touched;
53};
54
55struct uh_ubus_session_data {
56    struct avl_node avl;
57    struct blob_attr attr[];
58};
59
60struct uh_ubus_session_acl {
61    struct avl_node avl;
62    char *function;
63    char object[];
64};
65
66struct uh_ubus_state * uh_ubus_init(const struct config *conf);
67bool uh_ubus_request(struct client *cl, struct uh_ubus_state *state);
68void uh_ubus_close(struct uh_ubus_state *state);
69
70#endif
71

Archive Download this file



interactive