AM261x MCU+ SDK: yang_db_runtime.h File Reference

| AM261x MCU+ SDK 26.00.00 |

Macros | Typedefs | Functions
yang_db_runtime.h File Reference

Go to the source code of this file.

## Macros
#define | YANG_DB_LINE_BUF_SIZE 512u

## Typedefs
typedef struct yang_db_runtime_data | yang_db_runtime_dataq_t

## Functions
yang_db_runtime_dataq_t * | yang_db_runtime_init (uc_dbald *dbald, uc_hwald *hwald)
void | yang_db_runtime_close (yang_db_runtime_dataq_t *ydrd)
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. More...
int | yang_db_runtime_readfile (yang_db_runtime_dataq_t *ydrd, const char *fname)
| read from a config file, and set data. More...
int | yang_db_runtime_read_conffile (uc_dbald *dbald, const char *fname)
| internally create ydrd and then call "yang_db_runtime_readfile" More...
int | yang_db_runtime_get_vtype (uc_dbald *dbald, uint8_t *aps)
| get value type of 'aps' leaf More...
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 More...
int | yang_db_runtime_askaction (yang_db_runtime_dataq_t *ydrd, uc_notice_data_t *ucntd)
| ask to call 'uc_nc_askaction_push' More...
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 More...
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 More...
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)
uint8_t | yang_db_runtime_getvknum (uc_dbald *dbald, uint8_t *aps)
int | yang_db_runtime_getvkvtype (uc_dbald *dbald, uint8_t *aps, uint8_t vkindex, uint8_t *vkey, uint8_t *vtype)
int | yang_db_runtime_getvkstr (uc_dbald *dbald, uint8_t *aps, uint8_t vkindex, char **rstr)
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. More...
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) More...
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 More...
int | yang_db_runtime_proc_nodestring (yang_db_runtime_dataq_t *ydrd, bool reset, char *kstr, char *vstr)
int | yang_db_runtime_state_keyvkstr (yang_db_runtime_dataq_t *ydrd, char **rstr)
| call yang_db_runtime_getkeyvkstr with the internal ydrd state More...
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 More...
bool | yang_db_runtime_needaction (yang_db_runtime_dataq_t *ydrd)
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 More...
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. More...
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 More...
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'. More...
void | yang_db_runtime_cache_fromline_release (char *rvalue)
| release the reserved memory in 'yang_db_runtime_cache_fromline' More...

## Macro Definition Documentation

## ◆ YANG_DB_LINE_BUF_SIZE

#define YANG_DB_LINE_BUF_SIZE 512u

## Typedef Documentation

## ◆ yang_db_runtime_dataq_t

typedef struct yang_db_runtime_data yang_db_runtime_dataq_t

## Function Documentation

## ◆ yang_db_runtime_init()

yang_db_runtime_dataq_t* yang_db_runtime_init | ( | uc_dbald * | dbald,
|  | uc_hwald * | hwald
| ) |  |

## ◆ yang_db_runtime_close()

void yang_db_runtime_close | ( | yang_db_runtime_dataq_t * | ydrd | ) |

## ◆ 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_readfile()

int yang_db_runtime_readfile | ( | yang_db_runtime_dataq_t * | ydrd,
|  | const char * | fname
| ) |  |

read from a config file, and set data.

Parameters

  ydrd | yang_db_runtime_dataq_t
  fname | config file name

Returns
  -1:error, 0:success

## ◆ 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"

Parameters

  dbald | uc_dbald
  fname | config file name

Returns
  -1:error, 0:success

## ◆ yang_db_runtime_get_vtype()

int yang_db_runtime_get_vtype | ( | uc_dbald * | dbald,
|  | uint8_t * | aps
| ) |  |

get value type of 'aps' leaf

Returns
  >=0:vtype, -1:error

## ◆ 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

Parameters

  ydrd | yang_db_runtime_dataq_t
  kstr | key string
  vstr | value string
  onhw | action on hardware

Returns
  -1:error, 0:success

## ◆ 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'

Parameters

  ydrd | yang_db_runtime_dataq_t
  ucntd | uc_notice_data_t

Returns
  -1:error, 0:success

Note
  ydrd->aps,kvs,kss must be set already to call this function.

## ◆ 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

Parameters

  ydrd | yang_db_runtime_dataq_t
  line | key string
  kvs | return value keys, it must have MAX_KV_DEPTH+1 of void pointer space
  kss | return value key sizes, it must have MAX_KV_DEPTH of uint8_t space
  status | true:get range from status('ro') area, false: get from config('rw') area

Returns
  ragne object:success, NULL:error

Note
  returned ranage object must be released by calling uc_get_range_release

## ◆ 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

Parameters

  ydrd | yang_db_runtime_dataq_t
  line | key string
  value | value pointer to return read value. it is reallocated inside the function. it must be NULL or allocated address.
  vsize | value size

Returns
  -1:error, vtype>=0:success

## ◆ 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_getvknum()

uint8_t yang_db_runtime_getvknum | ( | uc_dbald * | dbald,
|  | uint8_t * | aps
| ) |  |

Returns
  number of value keys on aps node.

## ◆ yang_db_runtime_getvkvtype()

int yang_db_runtime_getvkvtype | ( | uc_dbald * | dbald,
|  | uint8_t * | aps,
|  | uint8_t | vkindex,
|  | uint8_t * | vkey,
|  | uint8_t * | vtype
| ) |  |

Returns
  vtype of vkindex's key on aps node. return -1: error return 0: vkey, vtype(yang_vtype_enum_t) is set

## ◆ yang_db_runtime_getvkstr()

int yang_db_runtime_getvkstr | ( | uc_dbald * | dbald,
|  | uint8_t * | aps,
|  | uint8_t | vkindex,
|  | char ** | rstr
| ) |  |

Returns
  value key node string of vkindex's key on aps node. return -1: error return 0: the result str in '*rst', the caller must call UB_SD_RELMEM to release.

## ◆ 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.

Parameters

  ydrd | yang_db_runtime_dataq_t
  witem | wait item
  waitv | wait value
  wvsize | wait value size
  tout_ms | wait timeout (ms)

Returns
  return 0:got the waitv, 1:timed out, -1:error

## ◆ 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)

Parameters

  dbald | uc_dbald
  aps | node keys, must be terminated with 255
  kvs | value keys
  kss | size of value keys
  rstr | data out

Returns
  -1: error, 0: the result str in '*rst', the caller must call UB_SD_RELMEM to release.

## ◆ 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

Returns
  -1: error, 0: the result str in '*rst', the caller must call UB_SD_RELMEM to release.

## ◆ yang_db_runtime_proc_nodestring()

int yang_db_runtime_proc_nodestring | ( | yang_db_runtime_dataq_t * | ydrd,
|  | bool | reset,
|  | char * | kstr,
|  | char * | vstr
| ) |  |

Returns
  N>=0:set node and need N value keys, -1:set one value key, -2:pass leaf, -3:error

Parameters

  ydrd | yang_db_runtime_dataq_t
  reset | reset ydrd->api to start over
  kstr | key stting
  vstr | value string, if this is NULL, kstr should be node

## ◆ 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

Returns
  0: the result str in '*rst', the caller must call UB_SD_RELMEM to release.

## ◆ 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

Parameters

  ydrd | yang_db_runtime_dataq_t
  ifname | input xml format filename
  ofname | output Excelfore format filename. if NULL, use a default temp file

Returns
  'converted filename': success, NULL:fail

## ◆ yang_db_runtime_needaction()

bool yang_db_runtime_needaction | ( | yang_db_runtime_dataq_t * | ydrd | ) |

## ◆ 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

Parameters

  ydrd | yang_db_runtime_dataq_t
  line | key string
  aps | return node keys, it must have UC_MAX_AP_DEPTH of uint8_t space
  kvs | return value keys, it must have UC_MAX_KV_DEPTH+1 of void pointer space
  kss | return value key sizes, it must have UC_MAX_KV_DEPTH of uint8_t space

Returns
  -1:error, vtype>=0:success

Note
  returned aps is terminated with 255, kvs with NULL, and kss with 0

## ◆ 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.

Parameters

  consoleprint | true:priont on console
  dbald | uc_dbald
  headmsg | prefix of message log
  aps | node keys
  kvs | value keys
  kss | value key sizes

## ◆ 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

Parameters

  ydrd | yang_db_runtime_dataq_t
  range | when the iteration stops at the middle(stop with return 0 status) needs to be released by uc_get_range_release. when it comes to the end it is internally called, and no need to release 'range'
  line | key string, value keys can be wildcard without value part
  kvs | return value keys, it must have MAX_KV_DEPTH+1 of void pointer space
  kss | return value key sizes, it must have MAX_KV_DEPTH of uint8_t space
  status | true:get range from status('ro') area, false: get from config('rw') area
  value | value of the iterated key
  vsize | value size
  qstr | data out

Returns
  >=0:vtype, -1:error or comes to the end

## ◆ 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'