-
Notifications
You must be signed in to change notification settings - Fork 19
/
wdmp-c.h
279 lines (243 loc) · 7.07 KB
/
wdmp-c.h
1
2
3
4
5
6
7
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
/**
* Copyright 2016 Comcast Cable Communications Management, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef __WDMP_C_H__
#define __WDMP_C_H__
#include <stdbool.h>
#include <stdint.h>
typedef enum
{
WDMP_STRING = 0,
WDMP_INT,
WDMP_UINT,
WDMP_BOOLEAN,
WDMP_DATETIME,
WDMP_BASE64,
WDMP_LONG,
WDMP_ULONG,
WDMP_FLOAT,
WDMP_DOUBLE,
WDMP_BYTE,
WDMP_NONE
} DATA_TYPE;
typedef enum
{
WDMP_TR181 = 0,
WDMP_SNMP
} PAYLOAD_TYPE;
typedef enum
{
WDMP_SUCCESS = 0, /**< Success. */
WDMP_FAILURE, /**< General Failure */
WDMP_ERR_TIMEOUT,
WDMP_ERR_NOT_EXIST,
WDMP_ERR_INVALID_PARAMETER_NAME,
WDMP_ERR_INVALID_PARAMETER_TYPE,
WDMP_ERR_INVALID_PARAMETER_VALUE,
WDMP_ERR_NOT_WRITABLE,
WDMP_ERR_SETATTRIBUTE_REJECTED,
WDMP_ERR_NAMESPACE_OVERLAP,
WDMP_ERR_UNKNOWN_COMPONENT,
WDMP_ERR_NAMESPACE_MISMATCH,
WDMP_ERR_UNSUPPORTED_NAMESPACE,
WDMP_ERR_DP_COMPONENT_VERSION_MISMATCH,
WDMP_ERR_INVALID_PARAM,
WDMP_ERR_UNSUPPORTED_DATATYPE,
WDMP_STATUS_RESOURCES,
WDMP_ERR_WIFI_BUSY,
WDMP_ERR_INVALID_ATTRIBUTES,
WDMP_ERR_WILDCARD_NOT_SUPPORTED,
WDMP_ERR_SET_OF_CMC_OR_CID_NOT_SUPPORTED,
WDMP_ERR_VALUE_IS_EMPTY,
WDMP_ERR_VALUE_IS_NULL,
WDMP_ERR_DATATYPE_IS_NULL,
WDMP_ERR_CMC_TEST_FAILED,
WDMP_ERR_NEW_CID_IS_MISSING,
WDMP_ERR_CID_TEST_FAILED,
WDMP_ERR_SETTING_CMC_OR_CID,
WDMP_ERR_INVALID_INPUT_PARAMETER,
WDMP_ERR_ATTRIBUTES_IS_NULL,
WDMP_ERR_NOTIFY_IS_NULL,
WDMP_ERR_INVALID_WIFI_INDEX,
WDMP_ERR_INVALID_RADIO_INDEX,
WDMP_ERR_ATOMIC_GET_SET_FAILED,
WDMP_ERR_METHOD_NOT_SUPPORTED
} WDMP_STATUS;
typedef struct
{
char *name;
char *value;
DATA_TYPE type;
} param_t;
typedef enum
{
GET = 0,
GET_ATTRIBUTES,
SET,
SET_ATTRIBUTES,
TEST_AND_SET,
REPLACE_ROWS,
ADD_ROWS,
DELETE_ROW
} REQ_TYPE;
typedef struct
{
char *paramNames[512];
size_t paramCnt;
} get_req_t;
typedef struct
{
param_t *param;
size_t paramCnt;
} set_req_t;
typedef struct
{
param_t *param;
char *newCid;
char *oldCid;
char *syncCmc;
size_t paramCnt;
} test_set_req_t;
typedef struct
{
size_t paramCnt;
char **names;
char **values;
} TableData;
typedef struct
{
char *objectName;
TableData *rows;
size_t rowCnt;
} table_req_t;
typedef struct {
REQ_TYPE reqType;
union {
get_req_t *getReq;
set_req_t *setReq;
table_req_t *tableReq;
test_set_req_t *testSetReq;
} u;
} req_struct;
typedef struct
{
char *name;
uint64_t start;
uint32_t duration;
} money_trace_span;
typedef struct
{
money_trace_span *spans;
size_t count;
} money_trace_spans;
typedef struct
{
char **paramNames;
size_t paramCnt;
param_t **params;
size_t *retParamCnt;
} get_res_t;
typedef struct
{
char *syncCMC;
char *syncCID;
param_t *params;
} param_res_t;
typedef struct
{
char *newObj;
} table_res_t;
typedef struct
{
REQ_TYPE reqType;
union {
get_res_t *getRes;
param_res_t *paramRes;
table_res_t *tableRes;
} u;
money_trace_spans *timeSpan;
WDMP_STATUS *retStatus;
size_t paramCnt;
} res_struct;
/*----------------------------------------------------------------------------*/
/* Macros */
/*----------------------------------------------------------------------------*/
/* none */
/*----------------------------------------------------------------------------*/
/* Data Structures */
/*----------------------------------------------------------------------------*/
/* none */
/*----------------------------------------------------------------------------*/
/* File Scoped Variables */
/*----------------------------------------------------------------------------*/
/* none */
/*----------------------------------------------------------------------------*/
/* Function Prototypes */
/*----------------------------------------------------------------------------*/
/* none */
/*----------------------------------------------------------------------------*/
/* External Functions */
/*----------------------------------------------------------------------------*/
/**
* To convert json string to struct
*
* @note If the reqObj returned is not NULL, the value pointed at by
* bytes must be freed using wdmp_free_req_struct() by the caller.
*
* @param payload [in] payload JSON string to be converted
* @param reqObj [out] the resulting req_struct structure if successful
*/
void wdmp_parse_request(char * payload, req_struct **reqObj);
/**
* To convert json string of a given payload_type to struct
*
* @note If the reqObj returned is not NULL, the value pointed at by
* bytes must be freed using wdmp_free_req_struct() by the caller.
*
* @param payload [in] payload JSON string to be converted
* @param payload_type [in] type of JSON payload - TR181 / SNMP /or any TBD type
* @param reqObj [out] the resulting structure if successful. structure depends on the payload_type
*/
void wdmp_parse_generic_request(char * payload, PAYLOAD_TYPE payload_type, req_struct **reqObj);
/**
* To convert response struct to json string
* @param resObj [in] the response structure to be converted
* @param payload [out] the resulting payload string if successful
*/
void wdmp_form_response(res_struct *resObj, char **payload);
/**
* Free the req_struct structure if allocated by the wdmp-c library.
*
* @note Do not call this function on the req_struct structure if the wdmp-c
* library did not create the structure!
*
* @param msg [in] the req_struct structure to free
*/
void wdmp_free_req_struct( req_struct *reqObj );
/**
* Free the res_struct structure if allocated by the wdmp-c library.
*
* @note Do not call this function on the res_struct structure if the wdmp-c
* library did not create the structure!
*
* @param msg [in] the res_struct structure to free
*/
void wdmp_free_res_struct( res_struct *resObj );
/*----------------------------------------------------------------------------*/
/* Internal functions */
/*----------------------------------------------------------------------------*/
/* none */
#endif