AM263Px MCU+ SDK: yang_db_runtime.h Source File

| AM263Px MCU+ SDK 26.00.00 |

yang_db_runtime.h
Go to the documentation of this file.
1 /*
2 * Copyright (c) 2023 Texas Instruments Incorporated
3 * Copyright (c) 2023 Excelfore Corporation (https://excelfore.com)
4 *
5 * All rights reserved not granted herein.
6 * Limited License.
7 *
8 * Texas Instruments Incorporated grants a world-wide, royalty-free,
9 * non-exclusive license under copyrights and patents it now or hereafter
10 * owns or controls to make, have made, use, import, offer to sell and sell ("Utilize")
11 * this software subject to the terms herein. With respect to the foregoing patent
12 * license, such license is granted solely to the extent that any such patent is necessary
13 * to Utilize the software alone. The patent license shall not apply to any combinations which
14 * include this software, other than combinations with devices manufactured by or for TI ("TI Devices").
15 * No hardware patent is licensed hereunder.
16 *
17 * Redistributions must preserve existing copyright notices and reproduce this license (including the
18 * above copyright notice and the disclaimer and (if applicable) source code license limitations below)
19 * in the documentation and/or other materials provided with the distribution
20 *
21 * Redistribution and use in binary form, without modification, are permitted provided that the following
22 * conditions are met:
23 *
24 * * No reverse engineering, decompilation, or disassembly of this software is permitted with respect to any
25 * software provided in binary form.
26 * * any redistribution and use are licensed by TI for use only with TI Devices.
27 * * Nothing shall obligate TI to provide you with source code for the software licensed and provided to you in object code.
28 *
29 * If software source code is provided to you, modification and redistribution of the source code are permitted
30 * provided that the following conditions are met:
31 *
32 * * any redistribution and use of the source code, including any resulting derivative works, are licensed by
33 * TI for use only with TI Devices.
34 * * any redistribution and use of any object code compiled from the source code and any resulting derivative
35 * works, are licensed by TI for use only with TI Devices.
36 *
37 * Neither the name of Texas Instruments Incorporated nor the names of its suppliers may be used to endorse or
38 * promote products derived from this software without specific prior written permission.
39 *
40 * DISCLAIMER.
41 *
42 * THIS SOFTWARE IS PROVIDED BY TI AND TI"S LICENSORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
43 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
44 * IN NO EVENT SHALL TI AND TI"S LICENSORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
45 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
46 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
47 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
48 * POSSIBILITY OF SUCH DAMAGE.
49 */
50 #ifndef YANG_DB_RUNTIME_H_
51 #define YANG_DB_RUNTIME_H_
52
53 #include "../uc_dbal.h"
54 #include "../hal/uc_hwal.h"
55 #include "../uc_notice.h"
56 #include "yang_db_access.h"
57
58 #ifdef __cplusplus
59 extern "C" {
60 #endif
61
62 #define YANG_DB_LINE_BUF_SIZE 512u
63
64 typedef struct yang_db_runtime_data yang_db_runtime_dataq_t;
65
66 yang_db_runtime_dataq_t *yang_db_runtime_init(uc_dbald *dbald, uc_hwald *hwald);
67
68 void yang_db_runtime_close(yang_db_runtime_dataq_t *ydrd);
69
73 void yang_db_runtime_set_hwadl(yang_db_runtime_dataq_t *ydrd, uc_hwald *hwald);
74
75
82 int yang_db_runtime_readfile(yang_db_runtime_dataq_t *ydrd, const char* fname);
83
90 int yang_db_runtime_read_conffile(uc_dbald *dbald, const char* fname);
91
96 int yang_db_runtime_get_vtype(uc_dbald *dbald, uint8_t *aps);
97
106 int yang_db_runtime_put_oneline(yang_db_runtime_dataq_t *ydrd,
107 char *kstr, char *vstr, uint8_t onhw);
108
116 int yang_db_runtime_askaction(yang_db_runtime_dataq_t *ydrd,
117 uc_notice_data_t *ucntd);
118
119
130 uc_range *yang_db_runtime_range_fromline(yang_db_runtime_dataq_t *ydrd,
131 const char* line, void **kvs, uint8_t *kss,
132 bool status);
133
143 int yang_db_runtime_get_oneline(yang_db_runtime_dataq_t *ydrd,
144 const char* line, void **value, uint32_t *vsize);
145
146 /*
147 * 'uc_nc_notice_register' is called by creating key from 'line'
148 * 'semname' must be a unique name.
149 */
150 int yang_db_runtime_notice_register(yang_db_runtime_dataq_t *ydrd, uc_notice_data_t *ucntd,
151 const char* line, char *semname, UC_NOTICE_SIG_T **sem);
152
156 uint8_t yang_db_runtime_getvknum(uc_dbald *dbald, uint8_t *aps);
157
163 int yang_db_runtime_getvkvtype(uc_dbald *dbald, uint8_t *aps, uint8_t vkindex,
164 uint8_t *vkey, uint8_t *vtype);
165
171 int yang_db_runtime_getvkstr(uc_dbald *dbald,
172 uint8_t *aps, uint8_t vkindex, char **rstr);
173
184 int yang_db_runtime_waititem(yang_db_runtime_dataq_t *ydrd, const char* witem,
185 void *waitv, uint32_t wvsize, int tout_ms);
186
196 int yang_db_runtime_apkv2keyvkstr(uc_dbald *dbald, uint8_t *aps,
197 kvs_t *kvs, uint8_t *kss, char **rstr);
202 int yang_db_runtime_getkeyvkstr(uc_dbald *dbald,
203 void *key, uint32_t ksize, char **rstr);
204
212 int yang_db_runtime_proc_nodestring(yang_db_runtime_dataq_t *ydrd, bool reset,
213 char *kstr, char *vstr);
214
219 int yang_db_runtime_state_keyvkstr(yang_db_runtime_dataq_t *ydrd, char **rstr);
220
221 // functions in convxml2conf.c
229 const char *convxml2conf_getconf(yang_db_runtime_dataq_t *ydrd, const char *ifname,
230 const char *ofname);
231
232 bool yang_db_runtime_needaction(yang_db_runtime_dataq_t *ydrd);
233
244 int yang_db_runtime_nodestr2apkv(yang_db_runtime_dataq_t *ydrd,
245 const char* line, uint8_t *aps, void **kvs, uint8_t *kss);
246
256 void yang_db_runtime_readdb_log(bool consoleprint, uc_dbald *dbald, const char *headmsg,
257 uint8_t aps[], void *kvs[], uint8_t kss[]);
258
274 int yang_db_runtime_iterate_fromline(yang_db_runtime_dataq_t *ydrd, uc_range **range,
275 const char* line, void *kvs[], uint8_t kss[],
276 bool status, void **value,
277 uint32_t *vsize, char **qstr);
278
283 int yang_db_runtime_cache_fromline(yang_db_runtime_dataq_t *ydrd,
284 const char* line, bool status,
285 char **rvalue, int *rvsize);
286
290 void yang_db_runtime_cache_fromline_release(char *rvalue);
291
292
293 #ifdef __cplusplus
294 }
295 #endif
296
297 #endif
yang_db_runtime_get_oneline
int yang_db_runtime_get_oneline(yang_db_runtime_dataq_t *ydrd, const char *line, void **value, uint32_t *vsize)
get one node db data by a string line
yang_db_runtime_nodestr2apkv
int yang_db_runtime_nodestr2apkv(yang_db_runtime_dataq_t *ydrd, const char *line, uint8_t *aps, void **kvs, uint8_t *kss)
convert yang key string to aps,kvs,kss,,, in ydrd
yang_db_runtime_put_oneline
int yang_db_runtime_put_oneline(yang_db_runtime_dataq_t *ydrd, char *kstr, char *vstr, uint8_t onhw)
write one node db data by a string line
yang_db_runtime_range_fromline
uc_range * yang_db_runtime_range_fromline(yang_db_runtime_dataq_t *ydrd, const char *line, void **kvs, uint8_t *kss, bool status)
get a range from line
yang_db_runtime_notice_register
int yang_db_runtime_notice_register(yang_db_runtime_dataq_t *ydrd, uc_notice_data_t *ucntd, const char *line, char *semname, UC_NOTICE_SIG_T **sem)
yang_db_runtime_read_conffile
int yang_db_runtime_read_conffile(uc_dbald *dbald, const char *fname)
internally create ydrd and then call "yang_db_runtime_readfile"
yang_db_runtime_getkeyvkstr
int yang_db_runtime_getkeyvkstr(uc_dbald *dbald, void *key, uint32_t ksize, char **rstr)
'key node string' and 'value key node string' of key
yang_db_runtime_askaction
int yang_db_runtime_askaction(yang_db_runtime_dataq_t *ydrd, uc_notice_data_t *ucntd)
ask to call 'uc_nc_askaction_push'
yang_db_runtime_iterate_fromline
int yang_db_runtime_iterate_fromline(yang_db_runtime_dataq_t *ydrd, uc_range **range, const char *line, void *kvs[], uint8_t kss[], bool status, void **value, uint32_t *vsize, char **qstr)
get a range from line, then iterate the contents
yang_db_runtime_readfile
int yang_db_runtime_readfile(yang_db_runtime_dataq_t *ydrd, const char *fname)
read from a config file, and set data.
convxml2conf_getconf
const char * convxml2conf_getconf(yang_db_runtime_dataq_t *ydrd, const char *ifname, const char *ofname)
convert xml format config file to Excelfore format config file
yang_db_runtime_waititem
int yang_db_runtime_waititem(yang_db_runtime_dataq_t *ydrd, const char *witem, void *waitv, uint32_t wvsize, int tout_ms)
wait witem, if waitv!=NULL wait unitl the value matches. if waitv==NULL wait appearance of witem.
yang_db_runtime_proc_nodestring
int yang_db_runtime_proc_nodestring(yang_db_runtime_dataq_t *ydrd, bool reset, char *kstr, char *vstr)
yang_db_runtime_getvknum
uint8_t yang_db_runtime_getvknum(uc_dbald *dbald, uint8_t *aps)
yang_db_runtime_needaction
bool yang_db_runtime_needaction(yang_db_runtime_dataq_t *ydrd)
yang_db_runtime_close
void yang_db_runtime_close(yang_db_runtime_dataq_t *ydrd)
yang_db_runtime_init
yang_db_runtime_dataq_t * yang_db_runtime_init(uc_dbald *dbald, uc_hwald *hwald)
yang_db_runtime_cache_fromline
int yang_db_runtime_cache_fromline(yang_db_runtime_dataq_t *ydrd, const char *line, bool status, char **rvalue, int *rvsize)
call 'yang_db_runtime_iterate_fromline' internally and cache (qstr, vstr) into 'rvalue'.
yang_db_runtime_cache_fromline_release
void yang_db_runtime_cache_fromline_release(char *rvalue)
release the reserved memory in 'yang_db_runtime_cache_fromline'
yang_db_runtime_getvkvtype
int yang_db_runtime_getvkvtype(uc_dbald *dbald, uint8_t *aps, uint8_t vkindex, uint8_t *vkey, uint8_t *vtype)
yang_db_runtime_state_keyvkstr
int yang_db_runtime_state_keyvkstr(yang_db_runtime_dataq_t *ydrd, char **rstr)
call yang_db_runtime_getkeyvkstr with the internal ydrd state
yang_db_runtime_readdb_log
void yang_db_runtime_readdb_log(bool consoleprint, uc_dbald *dbald, const char *headmsg, uint8_t aps[], void *kvs[], uint8_t kss[])
read from the DB, and print into the log file, optionally print on console.
yang_db_runtime_dataq_t
struct yang_db_runtime_data yang_db_runtime_dataq_t
Definition: yang_db_runtime.h:64
yang_db_runtime_set_hwadl
void yang_db_runtime_set_hwadl(yang_db_runtime_dataq_t *ydrd, uc_hwald *hwald)
hwald is set with yang_db_runtime_init, this function sets/resets later.
yang_db_runtime_get_vtype
int yang_db_runtime_get_vtype(uc_dbald *dbald, uint8_t *aps)
get value type of 'aps' leaf
yang_db_runtime_apkv2keyvkstr
int yang_db_runtime_apkv2keyvkstr(uc_dbald *dbald, uint8_t *aps, kvs_t *kvs, uint8_t *kss, char **rstr)
'key node string' and 'value key node string' of (aps,kvs,kss)
yang_db_runtime_getvkstr
int yang_db_runtime_getvkstr(uc_dbald *dbald, uint8_t *aps, uint8_t vkindex, char **rstr)