Newer
Older
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
* Author: Imen Bhiri <imen.bhiri@pivasoftware.com>
* Author: Feten Besbes <feten.besbes@pivasoftware.com>
* Author: Mohamed Kallel <mohamed.kallel@pivasoftware.com>
* Author: Anis Ellouze <anis.ellouze@pivasoftware.com>
*/
#ifndef __UBUS_H
#define __UBUS_H
#include <libubox/list.h>
#include <libubox/blobmsg_json.h>
#include <json-c/json.h>
#define UBUS_ARGS (struct ubus_arg[])
#define SIMPLE_OUTPUT -1
#define INDENT_OUTPUT 0
#define JSON_OUTPUT SIMPLE_OUTPUT
struct dmubus_ctx {
struct list_head obj_head;
};
struct ubus_obj {
struct list_head list;
struct list_head method_head;
char *name;
};
struct ubus_meth {
struct list_head list;
struct list_head msg_head;
char *name;
json_object *res;
};
struct ubus_msg {
struct list_head list;
struct ubus_arg *ug; // ubus method param
int ug_size;
json_object *res;
};
struct ubus_arg{
char *key;
char *val;
int type;
};
enum ubus_args_enum {
String,
Integer,
};
extern struct dmubus_ctx dmubus_ctx;
extern struct ubus_context *ubus_ctx;
int dmubus_get_timeout();
void dmubus_set_timeout(int time);
#define dm_ubus_get_value(jobj,ARGC,args...) \
dmjson_get_value(jobj, ARGC, ##args)
int dmubus_call(char *obj, char *method, struct ubus_arg u_args[], int u_args_size, json_object **req_res);
int dmubus_call_set(char *obj, char *method, struct ubus_arg u_args[], int u_args_size);
void dmubus_ctx_free(struct dmubus_ctx *ctx);
#endif