blob: 50ab14f768962e37f9297c0f07b2dd177b9c5bd2 [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001#ifndef __CHL_AGT_UCI__
2#define __CHL_AGT_UCI__
3
4#include <chl.h>
5
6#define UCI_PKG_AGT "chl_agent"
7
8#define UCI_PDP_SEC "pdp_cfg"
9#define UCI_GLOBAL_SEC "global_cfg"
10
11#define UCI_OPT_PDP_ENABLE "pdp_enable"
12#define UCI_OPT_APN "apn"
13#define UCI_OPT_IP "ip_type"
14#define UCI_OPT_LTEDFLT "lte_default"
15#define UCI_OPT_DFLTGW "default_gw"
16#define UCI_OPT_ROUTE "route_dst"
17
18#define UCI_OPT_AGT_ACTIVE "agent_active"
19#define UCI_OPT_DATA_ENABLE "data_enable"
20#define UCI_OPT_HOST_IP "host_ip"
21#define UCI_OPT_DWNLNK "downlink_only"
22#define UCI_OPT_WIFI "wifi_enable"
23
24#define MAX_APN_STR 30
25#define MAX_IPV4_STR 16
26#define MAX_ROUTE_STR 16
27#define MAX_ROUTES 8
28#define MAX_PDPS 8
29
30#ifndef __maybe_unused
31#define __maybe_unused __attribute__((unused))
32#endif
33
34
35enum pdp_action {
36 ERR_VAL,
37 DO_NOTHING,
38 CLOSE_PDP,
39 OPEN_PDP,
40 CHECK_ROUTE,
41 CLOSE_OPEN_PDP
42};
43
44/******************************************************************************
45 * Structs
46 ******************************************************************************/
47
48struct agent_pdp {
49 /*parsed variables*/
50 bool pdp_enable;
51 char apn[MAX_APN_STR];
52 enum ip_type ip_type;
53 bool is_lte_default;
54 bool is_default_gw;
55 char route_dst[MAX_ROUTES][MAX_ROUTE_STR];
56 /*internal variables*/
57 int id;
58 enum chl_nw_status pdp_state;
59 enum pdp_action action;
60};
61
62struct global_conf {
63 bool agent_active;
64 bool data_enable;
65 char host_ip[MAX_IPV4_STR];
66 bool downlink_only;
67 bool wifi_enable;
68};
69
70struct agent_conf {
71 struct global_conf global_conf;
72 struct agent_pdp agent_pdps[MAX_PDPS];
73};
74
75/******************************************************************************
76 * Methods
77 ******************************************************************************/
78
79int agt_uci_init(struct uci_context **c, char *pname);
80void agt_uci_done(struct uci_context *c, bool commit, char *pname);
81int uci_SetPtr(struct uci_context * pCtx,
82 struct uci_package * p,
83 struct uci_section * uci_sec,
84 char * option,
85 void * pValue);
86int uci_DelPtr(struct uci_context * pCtx,
87 struct uci_package * p,
88 struct uci_section * uci_sec,
89 char * option,
90 void * pValue);
91int uci_AddListPtr(struct uci_context * pCtx,
92 struct uci_package * p,
93 struct uci_section * uci_sec,
94 char * option,
95 void * pValue);
96int uci_RenamePtr(struct uci_context * pCtx,
97 struct uci_package * p,
98 struct uci_section * uci_sec,
99 char * option,
100 void * pValue);
101int parse_ucifile(struct agent_conf *agent_conf);
102
103#endif