Restructured error,debug anf log API

Renamed functions clicon->clixon, replaced global variables w access functions
Unified clicon_netconf_error with clixon_err()
This commit is contained in:
Olof hagsand 2023-11-13 10:12:52 +01:00
parent 261469be16
commit 24a4991ec8
199 changed files with 4668 additions and 4158 deletions

View file

@ -53,7 +53,7 @@
/* cligen */
#include <cligen/cligen.h>
/* clicon */
/* clixon */
#include <clixon/clixon.h>
#include "snmp_lib.h"
@ -85,16 +85,16 @@ snmp_common_handler(netsnmp_mib_handler *handler,
cbuf *cb = NULL;
if (request == NULL || shp == NULL){
clicon_err(OE_XML, EINVAL, "request or shp is null");
clixon_err(OE_XML, EINVAL, "request or shp is null");
goto done;
}
requestvb = request->requestvb;
if ((*shp = (clixon_snmp_handle*)handler->myvoid) == NULL){
clicon_err(OE_XML, 0, "No myvoid handler");
clixon_err(OE_XML, 0, "No myvoid handler");
goto done;
}
if ((cb = cbuf_new()) == NULL){
clicon_err(OE_UNIX, errno, "cbuf_new");
clixon_err(OE_UNIX, errno, "cbuf_new");
goto done;
}
oid_cbuf(cb, (*shp)->sh_oid, (*shp)->sh_oidlen);
@ -157,7 +157,7 @@ snmp_scalar_return(cxobj *xs,
goto done;
if (ret == 0){
if ((ret = netsnmp_request_set_error(request, SNMP_ERR_WRONGVALUE)) != SNMPERR_SUCCESS){
clicon_err(OE_SNMP, ret, "netsnmp_request_set_error");
clixon_err(OE_SNMP, ret, "netsnmp_request_set_error");
goto done;
}
goto ok;
@ -165,13 +165,13 @@ snmp_scalar_return(cxobj *xs,
}
else if (defaultval != NULL){
if ((xmlstr = strdup(defaultval)) == NULL){
clicon_err(OE_UNIX, errno, "strdup");
clixon_err(OE_UNIX, errno, "strdup");
goto done;
}
}
else{
if ((ret = netsnmp_request_set_error(request, SNMP_NOSUCHINSTANCE)) != SNMPERR_SUCCESS){
clicon_err(OE_SNMP, ret, "netsnmp_request_set_error");
clixon_err(OE_SNMP, ret, "netsnmp_request_set_error");
goto done;
}
goto ok;
@ -183,7 +183,7 @@ snmp_scalar_return(cxobj *xs,
if (ret == 0){
clixon_debug(CLIXON_DBG_DEFAULT, "%s %s", __FUNCTION__, reason);
if ((ret = netsnmp_request_set_error(request, SNMP_ERR_WRONGTYPE)) != SNMPERR_SUCCESS){
clicon_err(OE_SNMP, ret, "netsnmp_request_set_error");
clixon_err(OE_SNMP, ret, "netsnmp_request_set_error");
goto done;
}
goto ok;
@ -191,11 +191,11 @@ snmp_scalar_return(cxobj *xs,
/* see snmplib/snmp_client. somewhat indirect
*/
if ((ret = snmp_set_var_typed_value(requestvb, asn1type, snmpval, snmplen)) != SNMPERR_SUCCESS){
clicon_err(OE_SNMP, ret, "snmp_set_var_typed_value");
clixon_err(OE_SNMP, ret, "snmp_set_var_typed_value");
goto done;
}
if ((ret = snmp_set_var_objid(requestvb, oidc, oidclen)) != SNMPERR_SUCCESS){
clicon_err(OE_SNMP, ret, "snmp_set_var_objid");
clixon_err(OE_SNMP, ret, "snmp_set_var_objid");
goto done;
}
ok:
@ -223,7 +223,7 @@ snmp_scalar_return(cxobj *xs,
* @retval -1 Error
*/
static int
snmp_scalar_get(clicon_handle h,
snmp_scalar_get(clixon_handle h,
yang_stmt *ys,
cvec *cvk,
char *defaultval,
@ -263,7 +263,12 @@ snmp_scalar_get(clicon_handle h,
goto done;
/* Detect error XXX Error handling could improve */
if ((xerr = xpath_first(xt, NULL, "/rpc-error")) != NULL){
#if 1
if (clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Get configuration") < 0)
goto done;
#else
clixon_netconf_error(h, xerr, "clicon_rpc_get", NULL);
#endif
goto done;
}
x = xpath_first(xt, nsc, "%s", xpath);
@ -278,7 +283,7 @@ snmp_scalar_get(clicon_handle h,
goto done;
if (ret == 0){
if ((ret = netsnmp_request_set_error(request, SNMP_ERR_WRONGVALUE)) != SNMPERR_SUCCESS){
clicon_err(OE_SNMP, ret, "netsnmp_request_set_error");
clixon_err(OE_SNMP, ret, "netsnmp_request_set_error");
goto done;
}
goto ok;
@ -286,13 +291,13 @@ snmp_scalar_get(clicon_handle h,
}
else if (defaultval != NULL){
if ((xmlstr = strdup(defaultval)) == NULL){
clicon_err(OE_UNIX, errno, "strdup");
clixon_err(OE_UNIX, errno, "strdup");
goto done;
}
}
else{
if ((ret = netsnmp_request_set_error(request, SNMP_NOSUCHINSTANCE)) != SNMPERR_SUCCESS){
clicon_err(OE_SNMP, ret, "netsnmp_request_set_error");
clixon_err(OE_SNMP, ret, "netsnmp_request_set_error");
goto done;
}
goto ok;
@ -302,7 +307,7 @@ snmp_scalar_get(clicon_handle h,
if (ret == 0){
clixon_debug(CLIXON_DBG_DEFAULT, "%s %s", __FUNCTION__, reason);
if ((ret = netsnmp_request_set_error(request, SNMP_ERR_WRONGTYPE)) != SNMPERR_SUCCESS){
clicon_err(OE_SNMP, ret, "netsnmp_request_set_error");
clixon_err(OE_SNMP, ret, "netsnmp_request_set_error");
goto done;
}
goto ok;
@ -310,7 +315,7 @@ snmp_scalar_get(clicon_handle h,
/* see snmplib/snmp_client. somewhat indirect
*/
if ((ret = snmp_set_var_typed_value(requestvb, asn1type, snmpval, snmplen)) != SNMPERR_SUCCESS){
clicon_err(OE_SNMP, ret, "snmp_set_var_typed_value");
clixon_err(OE_SNMP, ret, "snmp_set_var_typed_value");
goto done;
}
ok:
@ -352,7 +357,7 @@ snmp_yang2xml(cxobj *xtop,
goto done;
/* Need to prepend an element to fit api_path_fmt2api_path cvv parameter */
if ((cvk1 = cvec_new(1)) == NULL){
clicon_err(OE_UNIX, errno, "cvec_new");
clixon_err(OE_UNIX, errno, "cvec_new");
goto done;
}
for (i=0; i<cvec_len(cvk); i++)
@ -362,7 +367,7 @@ snmp_yang2xml(cxobj *xtop,
if ((ret = api_path2xml(api_path, yspec, xtop, YC_DATANODE, 1, xbot, NULL, NULL)) < 0)
goto done;
if (ret == 0){
clicon_err(OE_XML, 0, "api_path2xml %s invalid", api_path);
clixon_err(OE_XML, 0, "api_path2xml %s invalid", api_path);
goto done;
}
retval = 0;
@ -389,7 +394,7 @@ snmp_yang2xml(cxobj *xtop,
* @note contains special logic for rowstatus handling
*/
static int
snmp_scalar_set(clicon_handle h,
snmp_scalar_set(clixon_handle h,
yang_stmt *ys,
cvec *cvk,
char *valstr0,
@ -430,7 +435,7 @@ snmp_scalar_set(clicon_handle h,
goto done;
}
if ((cb = cbuf_new()) == NULL){
clicon_err(OE_UNIX, errno, "cbuf_new");
clixon_err(OE_UNIX, errno, "cbuf_new");
goto done;
}
if (clixon_xml2cbuf(cb, xtop, 0, 0, NULL, -1, 0) < 0)
@ -461,7 +466,7 @@ snmp_scalar_set(clicon_handle h,
* @retval -1 Error
*/
static int
snmp_cache_row_op(clicon_handle h,
snmp_cache_row_op(clixon_handle h,
yang_stmt *yp,
cvec *cvk,
char *opstr,
@ -500,7 +505,7 @@ snmp_cache_row_op(clicon_handle h,
if (xml_addsub(xbot, xrow) < 0)
goto done;
if ((cb = cbuf_new()) == NULL){
clicon_err(OE_UNIX, errno, "cbuf_new");
clixon_err(OE_UNIX, errno, "cbuf_new");
goto done;
}
if (clixon_xml2cbuf(cb, xtop, 0, 0, NULL, -1, 0) < 0)
@ -537,7 +542,7 @@ snmp_cache_row_op(clicon_handle h,
* @retval -1 Error
*/
static int
snmp_cache_set(clicon_handle h,
snmp_cache_set(clixon_handle h,
yang_stmt *ys,
cvec *cvk,
int rowstatus,
@ -558,7 +563,7 @@ snmp_cache_set(clicon_handle h,
clixon_debug(CLIXON_DBG_DEFAULT, "%s", __FUNCTION__);
if ((yspec = clicon_dbspec_yang(h)) == NULL){
clicon_err(OE_FATAL, 0, "No DB_SPEC");
clixon_err(OE_FATAL, 0, "No DB_SPEC");
goto done;
}
if ((xtop = xml_new(NETCONF_INPUT_CONFIG, NULL, CX_ELMNT)) == NULL)
@ -583,14 +588,14 @@ snmp_cache_set(clicon_handle h,
if (strcmp(valstr, "createAndGo") == 0){
free(valstr);
if ((valstr = strdup("active")) == NULL){
clicon_err(OE_UNIX, errno, "strdup");
clixon_err(OE_UNIX, errno, "strdup");
goto done;
}
}
else if (strcmp(valstr, "createAndWait") == 0){
free(valstr);
if ((valstr = strdup("notInService")) == NULL){
clicon_err(OE_UNIX, errno, "strdup");
clixon_err(OE_UNIX, errno, "strdup");
goto done;
}
}
@ -646,7 +651,7 @@ snmp_cache_set(clicon_handle h,
* @retval -1 Error
*/
static int
snmp_table_rowstatus_get(clicon_handle h,
snmp_table_rowstatus_get(clixon_handle h,
yang_stmt *ys,
yang_stmt *yrestype,
cvec *cvk,
@ -745,7 +750,7 @@ clixon_snmp_scalar_handler1(netsnmp_mib_handler *handler,
if (requestvb->type != asn1_type){
clixon_debug(CLIXON_DBG_DEFAULT, "%s Expected type:%d, got: %d", __FUNCTION__, requestvb->type, asn1_type);
if ((ret = netsnmp_request_set_error(request, SNMP_ERR_WRONGTYPE)) != SNMPERR_SUCCESS){
clicon_err(OE_SNMP, ret, "netsnmp_request_set_error");
clixon_err(OE_SNMP, ret, "netsnmp_request_set_error");
goto ok;
}
}
@ -846,7 +851,7 @@ clixon_snmp_scalar_handler(netsnmp_mib_handler *handler,
* @retval -1 Error
*/
static int
snmp_table_get(clicon_handle h,
snmp_table_get(clixon_handle h,
yang_stmt *yt,
oid *oidt,
size_t oidtlen,
@ -899,11 +904,11 @@ snmp_table_get(clicon_handle h,
* Inverse of snmp_str2oid
*/
if ((cvk_orig = yang_cvec_get(yt)) == NULL){
clicon_err(OE_YANG, 0, "No keys");
clixon_err(OE_YANG, 0, "No keys");
goto done;
}
if ((cvk_val = cvec_dup(cvk_orig)) == NULL){
clicon_err(OE_UNIX, errno, "cvec_dup");
clixon_err(OE_UNIX, errno, "cvec_dup");
goto done;
}
/* read through keys and create cvk */
@ -913,14 +918,14 @@ snmp_table_get(clicon_handle h,
for (i=0; i<cvec_len(cvk_val); i++){
cv = cvec_i(cvk_val, i);
if ((yk = yang_find(yt, Y_LEAF, cv_string_get(cv))) == NULL){
clicon_err(OE_YANG, 0, "List key %s not found", cv_string_get(cv));
clixon_err(OE_YANG, 0, "List key %s not found", cv_string_get(cv));
goto done;
}
if (snmp_oid2str(&oidi, &oidilen, yk, cv) < 0)
goto done;
}
if (oidilen != 0){
clicon_err(OE_YANG, 0, "Expected oidlen 0 but is %zu", oidilen);
clixon_err(OE_YANG, 0, "Expected oidlen 0 but is %zu", oidilen);
goto fail;
}
/* Get scalar value */
@ -959,7 +964,7 @@ snmp_table_get(clicon_handle h,
* @retval -1 Error
*/
static int
snmp_table_set(clicon_handle h,
snmp_table_set(clixon_handle h,
yang_stmt *yt,
oid *oids,
size_t oidslen,
@ -1055,7 +1060,7 @@ snmp_table_set(clicon_handle h,
if (requestvb->type != asn1_type){
clixon_debug(CLIXON_DBG_DEFAULT, "%s Expected type:%d, got: %d", __FUNCTION__, requestvb->type, asn1_type);
if ((ret = netsnmp_request_set_error(request, SNMP_ERR_WRONGTYPE)) != SNMPERR_SUCCESS){
clicon_err(OE_SNMP, ret, "netsnmp_request_set_error");
clixon_err(OE_SNMP, ret, "netsnmp_request_set_error");
goto ok;
}
}
@ -1063,11 +1068,11 @@ snmp_table_set(clicon_handle h,
* Inverse of snmp_str2oid
*/
if ((cvk_orig = yang_cvec_get(yt)) == NULL){
clicon_err(OE_YANG, 0, "No keys");
clixon_err(OE_YANG, 0, "No keys");
goto done;
}
if ((cvk_val = cvec_dup(cvk_orig)) == NULL){
clicon_err(OE_UNIX, errno, "cvec_dup");
clixon_err(OE_UNIX, errno, "cvec_dup");
goto done;
}
/* read through keys and create cvk */
@ -1077,14 +1082,14 @@ snmp_table_set(clicon_handle h,
for (i=0; i<cvec_len(cvk_val); i++){
cv = cvec_i(cvk_val, i);
if ((yk = yang_find(yt, Y_LEAF, cv_string_get(cv))) == NULL){
clicon_err(OE_YANG, 0, "List key %s not found", cv_string_get(cv));
clixon_err(OE_YANG, 0, "List key %s not found", cv_string_get(cv));
goto done;
}
if (snmp_oid2str(&oidi, &oidilen, yk, cv) < 0)
goto done;
}
if (oidilen != 0){
clicon_err(OE_YANG, 0, "Expected oidlen 0 but is %zu", oidilen);
clixon_err(OE_YANG, 0, "Expected oidlen 0 but is %zu", oidilen);
*err = SNMP_NOSUCHOBJECT;
goto fail;
}
@ -1116,7 +1121,7 @@ snmp_table_set(clicon_handle h,
case 3: /* notReady */
case 6: /* destroy */
if ((ret = netsnmp_request_set_error(request, SNMP_ERR_INCONSISTENTVALUE)) != SNMPERR_SUCCESS){
clicon_err(OE_SNMP, ret, "netsnmp_request_set_error");
clixon_err(OE_SNMP, ret, "netsnmp_request_set_error");
goto ok;
}
break;
@ -1171,7 +1176,7 @@ snmp_table_set(clicon_handle h,
* XXX: merge with cache
*/
static int
snmp_table_getnext(clicon_handle h,
snmp_table_getnext(clixon_handle h,
yang_stmt *ylist,
oid *oids,
size_t oidslen,
@ -1204,7 +1209,7 @@ snmp_table_getnext(clicon_handle h,
clixon_debug(CLIXON_DBG_DEFAULT, "%s", __FUNCTION__);
if ((ys = yang_parent_get(ylist)) == NULL ||
yang_keyword_get(ys) != Y_CONTAINER){
clicon_err(OE_YANG, EINVAL, "ylist parent is not list");
clixon_err(OE_YANG, EINVAL, "ylist parent is not list");
goto done;
}
if (xml_nsctx_yang(ys, &nsc) < 0)
@ -1214,13 +1219,13 @@ snmp_table_getnext(clicon_handle h,
if (clicon_rpc_get(h, xpath, nsc, CONTENT_ALL, -1, NULL, &xt) < 0)
goto done;
if ((xerr = xpath_first(xt, NULL, "/rpc-error")) != NULL){
clixon_netconf_error(h, xerr, "clicon_rpc_get", NULL);
clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Get configuration");
goto done;
}
if ((xtable = xpath_first(xt, nsc, "%s", xpath)) != NULL) {
/* Make a clone of key-list, but replace names with values */
if ((cvk_name = yang_cvec_get(ylist)) == NULL){
clicon_err(OE_YANG, 0, "No keys");
clixon_err(OE_YANG, 0, "No keys");
goto done;
}
xrow = NULL;
@ -1259,7 +1264,7 @@ snmp_table_getnext(clicon_handle h,
if (snmp_scalar_return(xnext, ynext, oidnext, oidnextlen, reqinfo, request) < 0)
goto done;
if ((cb = cbuf_new()) == NULL){
clicon_err(OE_UNIX, errno, "cbuf_new");
clixon_err(OE_UNIX, errno, "cbuf_new");
goto done;
}
oid_cbuf(cb, oidnext, oidnextlen);
@ -1321,7 +1326,7 @@ clixon_snmp_table_handler1(netsnmp_mib_handler *handler,
goto done;
if (ret == 0){
if ((ret = netsnmp_request_set_error(request, SNMP_NOSUCHINSTANCE)) != SNMPERR_SUCCESS){
clicon_err(OE_SNMP, ret, "netsnmp_request_set_error");
clixon_err(OE_SNMP, ret, "netsnmp_request_set_error");
goto done;
}
clixon_debug(CLIXON_DBG_DEFAULT, "%s Nosuchinstance", __FUNCTION__);
@ -1336,7 +1341,7 @@ clixon_snmp_table_handler1(netsnmp_mib_handler *handler,
if (ret == 0){
if ((ret = netsnmp_request_set_error(request, SNMP_NOSUCHOBJECT)) != SNMPERR_SUCCESS){
clicon_err(OE_SNMP, ret, "netsnmp_request_set_error");
clixon_err(OE_SNMP, ret, "netsnmp_request_set_error");
goto done;
}
clixon_debug(CLIXON_DBG_DEFAULT, "%s No such object", __FUNCTION__);
@ -1358,7 +1363,7 @@ clixon_snmp_table_handler1(netsnmp_mib_handler *handler,
goto done;
if (ret == 0){
if ((ret = netsnmp_request_set_error(request, err)) != SNMPERR_SUCCESS){
clicon_err(OE_SNMP, ret, "netsnmp_request_set_error");
clixon_err(OE_SNMP, ret, "netsnmp_request_set_error");
goto done;
}
clixon_debug(CLIXON_DBG_DEFAULT, "%s Nosuchinstance", __FUNCTION__);

View file

@ -71,7 +71,7 @@
/* cligen */
#include <cligen/cligen.h>
/* clicon */
/* clixon */
#include <clixon/clixon.h>
#include "snmp_lib.h"
@ -277,7 +277,7 @@ oid_append(const oid *objid0,
dst = (void*)objid0;
dst += (*objid0len)*sizeof(*objid0);
if (memcpy(dst, objid1, objid1len*sizeof(*objid0)) < 0){
clicon_err(OE_UNIX, errno, "memcpy");
clixon_err(OE_UNIX, errno, "memcpy");
return -1;
}
*objid0len += objid1len;
@ -309,7 +309,7 @@ oid_print(FILE *f,
cbuf *cb;
if ((cb = cbuf_new()) == NULL){
clicon_err(OE_UNIX, errno, "cbuf_new");
clixon_err(OE_UNIX, errno, "cbuf_new");
goto done;
}
oid_cbuf(cb, objid, objidlen);
@ -351,13 +351,13 @@ snmp_yang_type_get(yang_stmt *ys,
restype2 = restype;
if (strcmp(restype2, "leafref")==0){
if ((ypath = yang_find(yrestype, Y_PATH, NULL)) == NULL){
clicon_err(OE_YANG, 0, "No path in leafref");
clixon_err(OE_YANG, 0, "No path in leafref");
goto done;
}
if (yang_path_arg(ys, yang_argument_get(ypath), &yref) < 0)
goto done;
if (yref == NULL){
clicon_err(OE_YANG, 0, "No referred YANG node found for leafref path %s", yang_argument_get(ypath));
clixon_err(OE_YANG, 0, "No referred YANG node found for leafref path %s", yang_argument_get(ypath));
goto done;
}
if (origtype){
@ -414,7 +414,7 @@ yang_extension_value_opt(yang_stmt *ys,
cg_var *cv;
if (ys == NULL){
clicon_err(OE_YANG, EINVAL, "ys is NULL");
clixon_err(OE_YANG, EINVAL, "ys is NULL");
goto done;
}
if (exist)
@ -474,7 +474,7 @@ yangext_oid_get(yang_stmt *yn,
goto fail;
}
if (snmp_parse_oid(oidstr, objid, objidlen) == NULL){
clicon_err(OE_XML, errno, "snmp_parse_oid");
clixon_err(OE_XML, errno, "snmp_parse_oid");
goto done;
}
if (objidstrp)
@ -525,13 +525,13 @@ snmp_handle_clone(void *arg)
if (sh0 == NULL)
return NULL;
if ((sh1 = malloc(sizeof(*sh1))) == NULL){
clicon_err(OE_UNIX, errno, "malloc");
clixon_err(OE_UNIX, errno, "malloc");
return NULL;
}
memset(sh1, 0, sizeof(*sh1));
if (sh0->sh_cvk_orig &&
(sh1->sh_cvk_orig = cvec_dup(sh0->sh_cvk_orig)) == NULL){
clicon_err(OE_UNIX, errno, "cvec_dup");
clixon_err(OE_UNIX, errno, "cvec_dup");
return NULL;
}
return (void*)sh1;
@ -594,7 +594,7 @@ type_yang2asn1(yang_stmt *ys,
}
/* Then try fully resolved type */
else if ((at = clicon_str2int(snmp_type_map, restype)) < 0){
clicon_err(OE_YANG, 0, "No snmp translation for YANG %s type:%s",
clixon_err(OE_YANG, 0, "No snmp translation for YANG %s type:%s",
yang_argument_get(ys), restype);
goto done;
}
@ -651,11 +651,11 @@ type_snmp2xml(yang_stmt *ys,
clixon_debug(CLIXON_DBG_DEFAULT, "%s", __FUNCTION__);
if (valstr == NULL){
clicon_err(OE_UNIX, EINVAL, "valstr is NULL");
clixon_err(OE_UNIX, EINVAL, "valstr is NULL");
goto done;
}
if ((cvstr = (char*)clicon_int2str(snmp_type_map, requestvb->type)) == NULL){
clicon_err(OE_XML, 0, "No mapping for snmp type %d", requestvb->type);
clixon_err(OE_XML, 0, "No mapping for snmp type %d", requestvb->type);
goto done;
}
/* Get yang type of leaf and trasnslate to ASN.1 */
@ -668,7 +668,7 @@ type_snmp2xml(yang_stmt *ys,
cvstr = "string";
cvtype = cv_str2type(cvstr);
if ((cv = cv_new(cvtype)) == NULL){
clicon_err(OE_UNIX, errno, "cv_new");
clixon_err(OE_UNIX, errno, "cv_new");
goto done;
}
switch (*asn1type){
@ -683,7 +683,7 @@ type_snmp2xml(yang_stmt *ys,
if (strcmp(restype, "enumeration") == 0){
if ((cb = cbuf_new()) == NULL){
clicon_err(OE_UNIX, errno, "cbuf_new");
clixon_err(OE_UNIX, errno, "cbuf_new");
goto done;
}
cprintf(cb, "%ld", *requestvb->val.integer);
@ -735,14 +735,14 @@ type_snmp2xml(yang_stmt *ys,
assert(0); // XXX
clixon_debug(CLIXON_DBG_DEFAULT, "%s %s not supported", __FUNCTION__, cv_type2str(cvtype));
if ((ret = netsnmp_request_set_error(request, SNMP_ERR_WRONGTYPE)) != SNMPERR_SUCCESS){
clicon_err(OE_SNMP, ret, "netsnmp_request_set_error");
clixon_err(OE_SNMP, ret, "netsnmp_request_set_error");
goto done;
}
goto fail;
break;
}
if ((*valstr = cv2str_dup(cv)) == NULL){
clicon_err(OE_UNIX, errno, "cv2str_dup");
clixon_err(OE_UNIX, errno, "cv2str_dup");
goto done;
}
retval = 1;
@ -784,7 +784,7 @@ type_xml2snmp_pre(char *xmlstr0,
cbuf *cb = NULL;
if (xmlstr0 == NULL || xmlstr1 == NULL){
clicon_err(OE_UNIX, EINVAL, "xmlstr0/1 is NULL");
clixon_err(OE_UNIX, EINVAL, "xmlstr0/1 is NULL");
goto done;
}
/* Get yang type of leaf and trasnslate to ASN.1 */
@ -814,7 +814,7 @@ type_xml2snmp_pre(char *xmlstr0,
int64_t num;
if ((cb = cbuf_new()) == NULL){
clicon_err(OE_UNIX, errno, "cbuf_new");
clixon_err(OE_UNIX, errno, "cbuf_new");
goto done;
}
if ((ret = parse_dec64(xmlstr0, cv_dec64_n_get(cv), &num, NULL)) < 0)
@ -831,7 +831,7 @@ type_xml2snmp_pre(char *xmlstr0,
str = xmlstr0;
}
if ((*xmlstr1 = strdup(str)) == NULL){
clicon_err(OE_UNIX, errno, "strdup");
clixon_err(OE_UNIX, errno, "strdup");
goto done;
}
retval = 1;
@ -869,7 +869,7 @@ type_xml2snmp(char *snmpstr,
int ret;
if (snmpval == NULL || snmplen == NULL){
clicon_err(OE_UNIX, EINVAL, "snmpval or snmplen is NULL");
clixon_err(OE_UNIX, EINVAL, "snmpval or snmplen is NULL");
goto done;
}
switch (*asn1type){
@ -879,7 +879,7 @@ type_xml2snmp(char *snmpstr,
case ASN_INTEGER: // 2
*snmplen = 4;
if ((*snmpval = malloc(*snmplen)) == NULL){
clicon_err(OE_UNIX, errno, "malloc");
clixon_err(OE_UNIX, errno, "malloc");
goto done;
}
if ((ret = parse_int32(snmpstr, (int32_t*)*snmpval, reason)) < 0)
@ -892,7 +892,7 @@ type_xml2snmp(char *snmpstr,
case ASN_GAUGE: // 0x42
*snmplen = 4;
if ((*snmpval = malloc(*snmplen)) == NULL){
clicon_err(OE_UNIX, errno, "malloc");
clixon_err(OE_UNIX, errno, "malloc");
goto done;
}
if ((ret = parse_uint32(snmpstr, (uint32_t*)*snmpval, reason)) < 0)
@ -910,7 +910,7 @@ type_xml2snmp(char *snmpstr,
}
*snmplen = sizeof(oid)*sz1;
if ((*snmpval = malloc(*snmplen)) == NULL){
clicon_err(OE_UNIX, errno, "malloc");
clixon_err(OE_UNIX, errno, "malloc");
goto done;
}
memcpy(*snmpval, oid1, *snmplen);
@ -919,7 +919,7 @@ type_xml2snmp(char *snmpstr,
case ASN_OCTET_STR: // 4
*snmplen = strlen(snmpstr)+1;
if ((*snmpval = (u_char*)strdup((snmpstr))) == NULL){
clicon_err(OE_UNIX, errno, "strdup");
clixon_err(OE_UNIX, errno, "strdup");
goto done;
}
break;
@ -928,7 +928,7 @@ type_xml2snmp(char *snmpstr,
struct counter64 *c64;
*snmplen = sizeof(struct counter64); // 16!
if ((*snmpval = malloc(*snmplen)) == NULL){
clicon_err(OE_UNIX, errno, "malloc");
clixon_err(OE_UNIX, errno, "malloc");
goto done;
}
memset(*snmpval, 0, *snmplen);
@ -945,7 +945,7 @@ type_xml2snmp(char *snmpstr,
in_addr_t saddr;
*snmplen = 4;
if ((*snmpval = malloc(*snmplen)) == NULL){
clicon_err(OE_UNIX, errno, "malloc");
clixon_err(OE_UNIX, errno, "malloc");
goto done;
}
saddr = (int32_t)inet_addr(snmpstr);
@ -956,7 +956,7 @@ type_xml2snmp(char *snmpstr,
struct ether_addr *eaddr;
*snmplen = sizeof(*eaddr);
if ((*snmpval = malloc(*snmplen + 1)) == NULL){
clicon_err(OE_UNIX, errno, "malloc");
clixon_err(OE_UNIX, errno, "malloc");
goto done;
}
memset(*snmpval, 0, *snmplen + 1);
@ -971,7 +971,7 @@ type_xml2snmp(char *snmpstr,
case CLIXON_ASN_FIXED_STRING: /* OCTET-STRING with decrement length */
*snmplen = strlen(snmpstr);
if ((*snmpval = (u_char*)strdup((snmpstr))) == NULL){
clicon_err(OE_UNIX, errno, "strdup");
clixon_err(OE_UNIX, errno, "strdup");
goto done;
}
*asn1type = ASN_OCTET_STR;
@ -1010,7 +1010,7 @@ snmp_yang2xpath_cb(yang_stmt *ys,
char *prefix = NULL;
if ((yp = yang_parent_get(ys)) == NULL){
clicon_err(OE_YANG, EINVAL, "yang expected parent %s", yang_argument_get(ys));
clixon_err(OE_YANG, EINVAL, "yang expected parent %s", yang_argument_get(ys));
goto done;
}
if (yp != NULL && /* XXX rm */
@ -1075,13 +1075,13 @@ snmp_yang2xpath(yang_stmt *ys,
cbuf *cb = NULL;
if ((cb = cbuf_new()) == NULL){
clicon_err(OE_UNIX, errno, "cbuf_new");
clixon_err(OE_UNIX, errno, "cbuf_new");
goto done;
}
if (snmp_yang2xpath_cb(ys, keyvec, cb) < 0)
goto done;
if (xpath && (*xpath = strdup(cbuf_get(cb))) == NULL){
clicon_err(OE_UNIX, errno, "strdup");
clixon_err(OE_UNIX, errno, "strdup");
goto done;
}
retval = 0;
@ -1167,7 +1167,7 @@ snmp_oid2str(oid **oidi,
if (type_yang2asn1(yk, &asn1_type, 1) < 0)
goto done;
if ((enc = cbuf_new()) == NULL){
clicon_err(OE_UNIX, errno, "cbuf_new");
clixon_err(OE_UNIX, errno, "cbuf_new");
goto done;
}
switch (asn1_type){
@ -1196,7 +1196,7 @@ snmp_oid2str(oid **oidi,
}
if (cbuf_len(enc)){
if (cv_string_set(cv, cbuf_get(enc)) < 0){
clicon_err(OE_UNIX, errno, "cv_string_set");
clixon_err(OE_UNIX, errno, "cv_string_set");
goto done;
}
}
@ -1296,12 +1296,12 @@ snmp_xmlkey2val_oid(cxobj *xentry,
if (*cvk_val){
cvec_free(*cvk_val);
if ((*cvk_val = cvec_dup(cvk_name)) == NULL){
clicon_err(OE_UNIX, errno, "cvec_dup");
clixon_err(OE_UNIX, errno, "cvec_dup");
goto done;
}
}
else if ((*cvk_val = cvec_dup(cvk_name)) == NULL){
clicon_err(OE_UNIX, errno, "cvec_dup");
clixon_err(OE_UNIX, errno, "cvec_dup");
goto done;
}
}
@ -1312,7 +1312,7 @@ snmp_xmlkey2val_oid(cxobj *xentry,
if (cvk_val){
cv = cvec_i(*cvk_val, i);
if (cv_string_set(cv, xml_body(xi)) < 0){
clicon_err(OE_UNIX, errno, "cv_string_set");
clixon_err(OE_UNIX, errno, "cv_string_set");
goto done;
}
}

View file

@ -65,7 +65,7 @@ extern "C" {
/* Userdata to pass around in netsmp callbacks
*/
struct clixon_snmp_handle {
clicon_handle sh_h;
clixon_handle sh_h;
yang_stmt *sh_ys; /* Leaf for scalar, list for table */
oid sh_oid[MAX_OID_LEN]; /* OID of registered table (list) */
size_t sh_oidlen;

View file

@ -63,7 +63,7 @@
/* cligen */
#include <cligen/cligen.h>
/* clicon */
/* clixon */
#include <clixon/clixon.h>
#include "snmp_lib.h"
@ -78,7 +78,7 @@ static int clixon_snmp_input_cb(int s, void *arg);
/*! Return (hardcoded) pid file
*/
static char*
clicon_snmp_pidfile(clicon_handle h)
clicon_snmp_pidfile(clixon_handle h)
{
return "/var/tmp/clixon_snmp.pid";
}
@ -90,7 +90,7 @@ clicon_snmp_pidfile(clicon_handle h)
static void
clixon_snmp_sig_term(int arg)
{
clicon_log(LOG_NOTICE, "%s: %s: pid: %u Signal %d",
clixon_log(NULL, LOG_NOTICE, "%s: %s: pid: %u Signal %d",
__PROGRAM__, __FUNCTION__, getpid(), arg);
/* This should ensure no more accepts or incoming packets are processed because next time eventloop
* is entered, it will terminate.
@ -105,7 +105,7 @@ clixon_snmp_sig_term(int arg)
* @param[in] h Clixon handle
*/
static int
snmp_terminate(clicon_handle h)
snmp_terminate(clixon_handle h)
{
yang_stmt *yspec;
cvec *nsctx;
@ -130,9 +130,9 @@ snmp_terminate(clicon_handle h)
xml_free(x);
xpath_optimize_exit();
clixon_event_exit();
clicon_handle_exit(h);
clixon_handle_exit(h);
clixon_err_exit();
clicon_log_exit();
clixon_log_exit();
if (pidfile)
unlink(pidfile);
return 0;
@ -151,7 +151,7 @@ snmp_terminate(clicon_handle h)
* @see clixon_snmp_input_cb
*/
static int
clixon_snmp_fdset_register(clicon_handle h,
clixon_snmp_fdset_register(clixon_handle h,
int regfd)
{
int retval = -1;
@ -164,7 +164,7 @@ clixon_snmp_fdset_register(clicon_handle h,
FD_ZERO(&readfds);
if ((nr = snmp_sess_select_info(NULL, &numfds, &readfds, &timeout, &block)) < 0){
clicon_err(OE_XML, errno, "snmp_select_error");
clixon_err(OE_XML, errno, "snmp_select_error");
goto done;
}
/* eg 4, 6, 8 */
@ -202,7 +202,7 @@ clixon_snmp_input_cb(int s,
{
int retval = -1;
fd_set readfds;
clicon_handle h = (clicon_handle)arg;
clixon_handle h = (clixon_handle)arg;
int ret;
clixon_debug(CLIXON_DBG_DETAIL, "%s %d", __FUNCTION__, s);
@ -211,7 +211,7 @@ clixon_snmp_input_cb(int s,
(void)snmp_read(&readfds);
if (clixon_event_poll(s) < 0){
if (errno == EBADF){
clicon_err_reset();
clixon_err_reset();
/* Close the active socket */
if (clixon_event_unreg_fd(s, clixon_snmp_input_cb) < 0)
goto done;
@ -220,7 +220,7 @@ clixon_snmp_input_cb(int s,
if (clixon_snmp_fdset_register(h, 0) < 0)
goto done;
if ((ret = snmp_close_sessions()) != 1){
clicon_err(OE_SNMP, ret, "snmp_close_sessions");
clixon_err(OE_SNMP, ret, "snmp_close_sessions");
goto done;
}
/* Signal normal exit to upper layers (=event handling)
@ -229,7 +229,7 @@ clixon_snmp_input_cb(int s,
clixon_exit_set(1);
}
else {
clicon_err(OE_UNIX, errno, "poll");
clixon_err(OE_UNIX, errno, "poll");
goto done;
}
}
@ -247,14 +247,14 @@ clixon_snmp_input_cb(int s,
* @see snmp_terminate
*/
static int
clixon_snmp_init_subagent(clicon_handle h,
clixon_snmp_init_subagent(clixon_handle h,
int logdst)
{
int retval = -1;
char *sockpath = NULL;
clixon_debug(CLIXON_DBG_DEFAULT, "%s", __FUNCTION__);
if (logdst == CLICON_LOG_SYSLOG)
if (logdst == CLIXON_LOG_SYSLOG)
snmp_enable_calllog();
else
snmp_enable_stderrlog();
@ -271,7 +271,7 @@ clixon_snmp_init_subagent(clicon_handle h,
netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID, NETSNMP_DS_AGENT_VERBOSE, 1);
if ((sockpath = clicon_option_str(h, "CLICON_SNMP_AGENT_SOCK")) == NULL){
clicon_err(OE_XML, 0, "CLICON_SNMP_AGENT_SOCK not set");
clixon_err(OE_XML, 0, "CLICON_SNMP_AGENT_SOCK not set");
goto done;
}
/* XXX: This should be configurable. */
@ -284,19 +284,19 @@ clixon_snmp_init_subagent(clicon_handle h,
init_snmp(__PROGRAM__);
if (!clixon_snmp_api_agent_check()){
clicon_err(OE_DAEMON, 0, "Connection to SNMP agent failed");
clixon_err(OE_DAEMON, 0, "Connection to SNMP agent failed");
goto done;
}
if (set_signal(SIGTERM, clixon_snmp_sig_term, NULL) < 0){
clicon_err(OE_DAEMON, errno, "Setting signal");
clixon_err(OE_DAEMON, errno, "Setting signal");
goto done;
}
if (set_signal(SIGINT, clixon_snmp_sig_term, NULL) < 0){
clicon_err(OE_DAEMON, errno, "Setting signal");
clixon_err(OE_DAEMON, errno, "Setting signal");
goto done;
}
if (set_signal(SIGPIPE, SIG_IGN, NULL) < 0){
clicon_err(OE_UNIX, errno, "Setting SIGPIPE signal");
clixon_err(OE_UNIX, errno, "Setting SIGPIPE signal");
goto done;
}
/* Workaround for netsnmps API use of fdset:s instead of sockets */
@ -313,7 +313,7 @@ clixon_snmp_init_subagent(clicon_handle h,
* @param[in] argv0 command line
*/
static void
usage(clicon_handle h,
usage(clixon_handle h,
char *argv0)
{
fprintf(stderr, "usage:%s\n"
@ -338,8 +338,8 @@ main(int argc,
int retval = -1;
int c;
char *argv0 = argv[0];
clicon_handle h;
int logdst = CLICON_LOG_STDERR;
clixon_handle h;
int logdst = CLIXON_LOG_STDERR;
struct passwd *pw;
yang_stmt *yspec = NULL;
char *str;
@ -357,14 +357,17 @@ main(int argc,
enum format_enum config_dump_format = FORMAT_XML;
/* Create handle */
if ((h = clicon_handle_init()) == NULL)
if ((h = clixon_handle_init()) == NULL)
return -1;
/* In the startup, logs to stderr & debug flag set later */
clicon_log_init(__PROGRAM__, LOG_INFO, logdst);
if (clixon_log_init(h, __PROGRAM__, LOG_INFO, logdst) < 0)
goto done;
if (clixon_err_init(h) < 0)
goto done;
/* Set username to clixon handle. Use in all communication to backend */
if ((pw = getpwuid(getuid())) == NULL){
clicon_err(OE_UNIX, errno, "getpwuid");
clixon_err(OE_UNIX, errno, "getpwuid");
goto done;
}
if (clicon_username_set(h, pw->pw_name) < 0)
@ -387,12 +390,12 @@ main(int argc,
usage(h, argv[0]);
clicon_option_str_set(h, "CLICON_CONFIGFILE", optarg);
break;
case 'l': /* Log destination: s|e|o */
if ((logdst = clicon_log_opt(optarg[0])) < 0)
case 'l': /* Log destination: s|e|o */
if ((logdst = clixon_log_opt(optarg[0])) < 0)
usage(h, argv[0]);
if (logdst == CLICON_LOG_FILE &&
if (logdst == CLIXON_LOG_FILE &&
strlen(optarg)>1 &&
clicon_log_file(optarg+1) < 0)
clixon_log_file(optarg+1) < 0)
goto done;
break;
}
@ -400,8 +403,8 @@ main(int argc,
/*
* Logs, error and debug to stderr or syslog, set debug level
*/
clicon_log_init(__PROGRAM__, dbg?LOG_DEBUG:LOG_INFO, logdst);
clixon_debug_init(dbg, NULL);
clixon_log_init(h, __PROGRAM__, dbg?LOG_DEBUG:LOG_INFO, logdst);
clixon_debug_init(h, dbg);
/* This is netsnmplib debugging which is quite extensive + only if compiled w debug */
if (dbg > 1)
snmp_set_do_debugging(1);
@ -458,7 +461,7 @@ main(int argc,
/* Check pid-file, if zap kill the old daemon, else return here */
if ((pidfile = clicon_snmp_pidfile(h)) == NULL){
clicon_err(OE_FATAL, 0, "pidfile not set");
clixon_err(OE_FATAL, 0, "pidfile not set");
goto done;
}
if (pidfile_get(pidfile, &pid) < 0)
@ -472,7 +475,7 @@ main(int argc,
exit(0); /* OK */
}
else if (pid){
clicon_err(OE_DAEMON, 0, "Clixon_snmp daemon already running with pid %d\n(Try killing it with %s -z)",
clixon_err(OE_DAEMON, 0, "Clixon_snmp daemon already running with pid %d\n(Try killing it with %s -z)",
pid, argv0);
return -1; /* goto done deletes pidfile */
}
@ -485,8 +488,8 @@ main(int argc,
cligen_bufthreshold = clicon_option_int(h, "CLICON_CLI_BUF_THRESHOLD");
cbuf_alloc_set(cligen_buflen, cligen_bufthreshold);
if ((sz = clicon_option_int(h, "CLICON_LOG_STRING_LIMIT")) != 0)
clicon_log_string_limit_set(sz);
if ((sz = clicon_option_int(h, "CLIXON_LOG_STRING_LIMIT")) != 0)
clixon_log_string_limit_set(sz);
/* Set default namespace according to CLICON_NAMESPACE_NETCONF_DEFAULT */
xml_nsctx_namespace_netconf_default(h);
@ -570,7 +573,7 @@ main(int argc,
retval = 0;
done:
snmp_terminate(h);
clicon_log_init(__PROGRAM__, LOG_INFO, 0); /* Log on syslog no stderr */
clicon_log(LOG_NOTICE, "%s: %u Terminated", __PROGRAM__, getpid());
clixon_log_init(h, __PROGRAM__, LOG_INFO, 0); /* Log on syslog no stderr */
clixon_log(h, LOG_NOTICE, "%s: %u Terminated", __PROGRAM__, getpid());
return retval;
}

View file

@ -72,7 +72,7 @@
/* cligen */
#include <cligen/cligen.h>
/* clicon */
/* clixon */
#include <clixon/clixon.h>
#include "snmp_lib.h"
@ -95,7 +95,7 @@
* netsnmp_subtree_find(oid1,sz1, 0, 0)
*/
static int
mibyang_leaf_register(clicon_handle h,
mibyang_leaf_register(clixon_handle h,
yang_stmt *ys,
cvec *cvk_val,
oid *oidk,
@ -115,7 +115,7 @@ mibyang_leaf_register(clicon_handle h,
cbuf *cboid = NULL;
if ((cboid = cbuf_new()) == NULL){
clicon_err(OE_UNIX, errno, "cbuf_new");
clixon_err(OE_UNIX, errno, "cbuf_new");
goto done;
}
if ((ret = yangext_oid_get(ys, oid1, &oid1len, NULL)) < 0)
@ -146,7 +146,7 @@ mibyang_leaf_register(clicon_handle h,
name = yang_argument_get(ys);
/* Stateless function, just returns ptr */
if ((handler = netsnmp_create_handler(name, clixon_snmp_scalar_handler)) == NULL){
clicon_err(OE_XML, errno, "netsnmp_create_handler");
clixon_err(OE_XML, errno, "netsnmp_create_handler");
goto done;
}
@ -154,7 +154,7 @@ mibyang_leaf_register(clicon_handle h,
* XXX: not deallocated
*/
if ((sh = malloc(sizeof(*sh))) == NULL){
clicon_err(OE_UNIX, errno, "malloc");
clixon_err(OE_UNIX, errno, "malloc");
goto done;
}
memset(sh, 0, sizeof(*sh));
@ -165,14 +165,14 @@ mibyang_leaf_register(clicon_handle h,
sh->sh_default = default_str;
if (cvk_val &&
(sh->sh_cvk_orig = cvec_dup(cvk_val)) == NULL){
clicon_err(OE_UNIX, errno, "cvec_dup");
clixon_err(OE_UNIX, errno, "cvec_dup");
goto done;
}
/* Stateless function, just returns ptr */
if ((nhreg = netsnmp_handler_registration_create(name, handler,
oid1, oid1len,
modes)) == NULL){
clicon_err(OE_XML, errno, "netsnmp_handler_registration_create");
clixon_err(OE_XML, errno, "netsnmp_handler_registration_create");
netsnmp_handler_free(handler);
goto done;
}
@ -186,7 +186,7 @@ mibyang_leaf_register(clicon_handle h,
*/
if ((ret = netsnmp_register_instance(nhreg)) != SNMPERR_SUCCESS){
/* Note MIB_ errors, not regular SNMPERR_ */
clicon_err(OE_SNMP, ret-CLIXON_ERR_SNMP_MIB, "netsnmp_register_instance");
clixon_err(OE_SNMP, ret-CLIXON_ERR_SNMP_MIB, "netsnmp_register_instance");
goto done;
}
oid_cbuf(cboid, oid1, oid1len);
@ -216,7 +216,7 @@ mibyang_leaf_register(clicon_handle h,
* @retval -1 Error
*/
static int
mibyang_table_register(clicon_handle h,
mibyang_table_register(clixon_handle h,
yang_stmt *ylist,
oid *oid1,
size_t oid1len,
@ -240,7 +240,7 @@ mibyang_table_register(clicon_handle h,
if ((ys = yang_parent_get(ylist)) == NULL ||
yang_keyword_get(ys) != Y_CONTAINER){
clicon_err(OE_YANG, EINVAL, "ylist parent is not list");
clixon_err(OE_YANG, EINVAL, "ylist parent is not list");
goto done;
}
/* Note: This is wrong for augmented nodes where name is the original list, not the
@ -253,7 +253,7 @@ mibyang_table_register(clicon_handle h,
* XXX: not deallocated
*/
if ((sh = malloc(sizeof(*sh))) == NULL){
clicon_err(OE_UNIX, errno, "malloc");
clixon_err(OE_UNIX, errno, "malloc");
goto done;
}
memset(sh, 0, sizeof(*sh));
@ -265,13 +265,13 @@ mibyang_table_register(clicon_handle h,
sh->sh_oid2len = oid2len;
if ((handler = netsnmp_create_handler(name, clixon_snmp_table_handler)) == NULL){
clicon_err(OE_XML, errno, "netsnmp_create_handler");
clixon_err(OE_XML, errno, "netsnmp_create_handler");
goto done;
}
if ((nhreg = netsnmp_handler_registration_create(name, handler,
oid1, oid1len,
HANDLER_CAN_RWRITE)) == NULL){
clicon_err(OE_XML, errno, "netsnmp_handler_registration_create");
clixon_err(OE_XML, errno, "netsnmp_handler_registration_create");
netsnmp_handler_free(handler);
goto done;
}
@ -282,12 +282,12 @@ mibyang_table_register(clicon_handle h,
/* See netsnmp_register_table_data_set */
if ((table_info = SNMP_MALLOC_TYPEDEF(netsnmp_table_registration_info)) == NULL){
clicon_err(OE_UNIX, errno, "SNMP_MALLOC_TYPEDEF");
clixon_err(OE_UNIX, errno, "SNMP_MALLOC_TYPEDEF");
goto done;
}
/* Keys, go through keys */
if ((cvk = yang_cvec_get(ylist)) == NULL){
clicon_err(OE_YANG, 0, "No keys");
clixon_err(OE_YANG, 0, "No keys");
goto done;
}
cvi = NULL;
@ -295,7 +295,7 @@ mibyang_table_register(clicon_handle h,
while ((cvi = cvec_each(cvk, cvi)) != NULL) {
keyname = cv_string_get(cvi);
if ((yleaf = yang_find(ylist, Y_LEAF, keyname)) == NULL){
clicon_err(OE_XML, 0, "List statement \"%s\" has no key leaf \"%s\"",
clixon_err(OE_XML, 0, "List statement \"%s\" has no key leaf \"%s\"",
yang_argument_get(ylist), keyname);
goto done;
}
@ -308,7 +308,7 @@ mibyang_table_register(clicon_handle h,
asn1type,
NULL, // value
0) == NULL){
clicon_err(OE_XML, errno, "snmp_varlist_add_variable");
clixon_err(OE_XML, errno, "snmp_varlist_add_variable");
goto done;
}
}
@ -323,7 +323,7 @@ mibyang_table_register(clicon_handle h,
table_info->max_column++;
}
if ((ret = netsnmp_register_table(nhreg, table_info)) != SNMPERR_SUCCESS){
clicon_err(OE_SNMP, ret, "netsnmp_register_table");
clixon_err(OE_SNMP, ret, "netsnmp_register_table");
goto done;
}
sh->sh_table_info = table_info; /* Keep to free at exit */
@ -350,7 +350,7 @@ mibyang_table_register(clicon_handle h,
* @see mibyang_augment_register
*/
static int
mibyang_list_register(clicon_handle h,
mibyang_list_register(clixon_handle h,
yang_stmt *ylist)
{
int retval = -1;
@ -364,7 +364,7 @@ mibyang_list_register(clicon_handle h,
if ((yc = yang_parent_get(ylist)) == NULL ||
yang_keyword_get(yc) != Y_CONTAINER){
clicon_err(OE_YANG, EINVAL, "ylist parent is not container");
clixon_err(OE_YANG, EINVAL, "ylist parent is not container");
goto done;
}
if ((ret = yangext_oid_get(ylist, oid2, &oid2len, NULL)) < 0)
@ -405,7 +405,7 @@ mibyang_list_register(clicon_handle h,
* @see mibyang_list_register
*/
static int
mibyang_augment_register(clicon_handle h,
mibyang_augment_register(clixon_handle h,
yang_stmt *yaug)
{
int retval = -1;
@ -459,7 +459,7 @@ mibyang_augment_register(clicon_handle h,
* @retval -1 Error
*/
int
mibyang_table_poll(clicon_handle h,
mibyang_table_poll(clixon_handle h,
yang_stmt *ylist)
{
int retval = -1;
@ -481,7 +481,7 @@ mibyang_table_poll(clicon_handle h,
clixon_debug(CLIXON_DBG_DEFAULT, "%s", __FUNCTION__);
if ((ys = yang_parent_get(ylist)) == NULL ||
yang_keyword_get(ys) != Y_CONTAINER){
clicon_err(OE_YANG, EINVAL, "ylist parent is not list");
clixon_err(OE_YANG, EINVAL, "ylist parent is not list");
goto done;
}
if (xml_nsctx_yang(ys, &nsc) < 0)
@ -491,13 +491,13 @@ mibyang_table_poll(clicon_handle h,
if (clicon_rpc_get(h, xpath, nsc, CONTENT_ALL, -1, NULL, &xt) < 0)
goto done;
if ((xerr = xpath_first(xt, NULL, "/rpc-error")) != NULL){
clixon_netconf_error(h, xerr, "clicon_rpc_get", NULL);
clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Get configuration");
goto done;
}
if ((xtable = xpath_first(xt, nsc, "%s", xpath)) != NULL) {
/* Make a clone of key-list, but replace names with values */
if ((cvk_name = yang_cvec_get(ylist)) == NULL){
clicon_err(OE_YANG, 0, "No keys");
clixon_err(OE_YANG, 0, "No keys");
goto done;
}
xrow = NULL;
@ -550,7 +550,7 @@ mibyang_table_poll(clicon_handle h,
* @retval -1 Error, aborted at first error encounter
*/
static int
mibyang_traverse(clicon_handle h,
mibyang_traverse(clixon_handle h,
yang_stmt *yn)
{
int retval = -1;
@ -611,7 +611,7 @@ mibyang_traverse(clicon_handle h,
* @retval -1 Error
*/
int
clixon_snmp_traverse_mibyangs(clicon_handle h)
clixon_snmp_traverse_mibyangs(clixon_handle h)
{
int retval = -1;
char *modname;
@ -620,7 +620,7 @@ clixon_snmp_traverse_mibyangs(clicon_handle h)
yang_stmt *ymod;
if ((yspec = clicon_dbspec_yang(h)) == NULL){
clicon_err(OE_FATAL, 0, "No DB_SPEC");
clixon_err(OE_FATAL, 0, "No DB_SPEC");
goto done;
}
/* Loop over clixon configuration file to find all CLICON_SNMP_MIB, and
@ -640,7 +640,7 @@ clixon_snmp_traverse_mibyangs(clicon_handle h)
* What happens if backend has not loaded it?
*/
if ((ymod = yang_find(yspec, Y_MODULE, modname)) == NULL){
clicon_err(OE_YANG, 0, "Mib-translated-yang %s not loaded", modname);
clixon_err(OE_YANG, 0, "Mib-translated-yang %s not loaded", modname);
goto done;
}
/* Recursively traverse the mib-yang to find extensions */

View file

@ -44,8 +44,8 @@ extern "C" {
/*
* Prototypes
*/
int mibyang_table_poll(clicon_handle h, yang_stmt *ylist);
int clixon_snmp_traverse_mibyangs(clicon_handle h);
int mibyang_table_poll(clixon_handle h, yang_stmt *ylist);
int clixon_snmp_traverse_mibyangs(clixon_handle h);
#endif /* _SNMP_REGISTER_H_ */