Added restconf handle specialization to implement restconf parameters

This commit is contained in:
Olof hagsand 2020-06-22 12:47:43 +02:00
parent 1597bd303c
commit 73bbcded87
22 changed files with 351 additions and 162 deletions

View file

@ -93,13 +93,10 @@ clicon_data_get(clicon_handle h,
{
clicon_hash_t *cdat = clicon_data(h);
if (val == NULL){
clicon_err(OE_CFG, EINVAL, "%s val is NULL", __FUNCTION__);
return -1;
}
if (clicon_hash_lookup(cdat, (char*)name) == NULL)
return -1;
*val = clicon_hash_value(cdat, (char*)name, NULL);
if (val)
*val = clicon_hash_value(cdat, (char*)name, NULL);
return 0;
}
@ -716,4 +713,3 @@ clicon_session_id_set(clicon_handle h,
clicon_hash_add(cdat, "session-id", &id, sizeof(uint32_t));
return 0;
}

View file

@ -2,7 +2,9 @@
*
***** BEGIN LICENSE BLOCK *****
Copyright (C) 2009-2019 Olof Hagsand and Benny Holmgren
Copyright (C) 2009-2016 Olof Hagsand and Benny Holmgren
Copyright (C) 2017-2019 Olof Hagsand
Copyright (C) 2020 Olof Hagsand and Rubicon Communications, LLC(Netgate)
This file is part of CLIXON.
@ -81,6 +83,7 @@
* XXX: put ch_stream under ch_data
* @see struct cli_handle
* @see struct backend_handle
* @see struct restconf_handle
*/
struct clicon_handle {
int ch_magic; /* magic (HDR) */
@ -157,7 +160,6 @@ clicon_handle_exit(clicon_handle h)
clicon_hash_free(ha);
if ((ha = clicon_data(h)) != NULL)
clicon_hash_free(ha);
if ((ha = clicon_db_elmnt(h)) != NULL)
clicon_hash_free(ha);
stream_delete_all(h, 1);

View file

@ -129,10 +129,11 @@ clicon_hash_init(void)
/*! Free hash table.
*
* @param[in] hash Hash table
* @retval void
* @param[in] hash Hash table
* @retval 0 OK
* @retval -1 Error
*/
void
int
clicon_hash_free(clicon_hash_t *hash)
{
int i;
@ -147,6 +148,7 @@ clicon_hash_free(clicon_hash_t *hash)
}
}
free(hash);
return 0;
}
/*! Find hash key.
@ -189,6 +191,10 @@ clicon_hash_value(clicon_hash_t *hash,
{
clicon_hash_t h;
if (hash == NULL){
clicon_err(OE_UNIX, EINVAL, "hash is NULL");
return NULL;
}
h = clicon_hash_lookup(hash, key);
if (h == NULL)
return NULL; /* OK, key not found */
@ -218,6 +224,10 @@ clicon_hash_add(clicon_hash_t *hash,
clicon_hash_t h;
clicon_hash_t new = NULL;
if (hash == NULL){
clicon_err(OE_UNIX, EINVAL, "hash is NULL");
return NULL;
}
/* Check NULL case */
if ((val == NULL && vlen != 0) ||
(val != NULL && vlen == 0)){
@ -288,6 +298,10 @@ clicon_hash_del(clicon_hash_t *hash,
{
clicon_hash_t h;
if (hash == NULL){
clicon_err(OE_UNIX, EINVAL, "hash is NULL");
return -1;
}
h = clicon_hash_lookup(hash, key);
if (h == NULL)
return -1;
@ -321,6 +335,10 @@ clicon_hash_keys(clicon_hash_t *hash,
char **tmp;
char **keys = NULL;
if (hash == NULL){
clicon_err(OE_UNIX, EINVAL, "hash is NULL");
return -1;
}
*nkeys = 0;
for (bkt = 0; bkt < HASH_SIZE; bkt++) {
h = hash[bkt];