C-style update: Unified comment, retvals in order, remove trailing spaces
Changed function name for `clicon_debug` functions
This commit is contained in:
parent
6e314dd96f
commit
62348fc9c7
204 changed files with 6047 additions and 4904 deletions
|
|
@ -97,10 +97,10 @@ snmp_common_handler(netsnmp_mib_handler *handler,
|
|||
clicon_err(OE_UNIX, errno, "cbuf_new");
|
||||
goto done;
|
||||
}
|
||||
oid_cbuf(cb, (*shp)->sh_oid, (*shp)->sh_oidlen);
|
||||
oid_cbuf(cb, (*shp)->sh_oid, (*shp)->sh_oidlen);
|
||||
if (oid_eq(requestvb->name, requestvb->name_length,
|
||||
(*shp)->sh_oid, (*shp)->sh_oidlen) == 0){ /* equal */
|
||||
clicon_debug(1, "%s \"%s\" %s inclusive:%d %s", __FUNCTION__,
|
||||
clixon_debug(CLIXON_DBG_DEFAULT, "%s \"%s\" %s inclusive:%d %s", __FUNCTION__,
|
||||
cbuf_get(cb),
|
||||
snmp_msg_int2str(reqinfo->mode),
|
||||
request->inclusive, tablehandler?"table":"scalar");
|
||||
|
|
@ -110,7 +110,7 @@ snmp_common_handler(netsnmp_mib_handler *handler,
|
|||
oid_cbuf(cb, requestvb->name, requestvb->name_length);
|
||||
cprintf(cb, ")");
|
||||
// nhreg->rootoid same as shp
|
||||
clicon_debug(1, "%s \"%s\" %s inclusive:%d %s", __FUNCTION__,
|
||||
clixon_debug(CLIXON_DBG_DEFAULT, "%s \"%s\" %s inclusive:%d %s", __FUNCTION__,
|
||||
cbuf_get(cb),
|
||||
snmp_msg_int2str(reqinfo->mode),
|
||||
request->inclusive, tablehandler?"table":"scalar");
|
||||
|
|
@ -122,7 +122,8 @@ snmp_common_handler(netsnmp_mib_handler *handler,
|
|||
return retval;
|
||||
}
|
||||
|
||||
/*!
|
||||
/*! scalar return
|
||||
*
|
||||
* @param[in] reqinfo Agent transaction request structure
|
||||
* @param[in] request The netsnmp request info structure.
|
||||
* @retval 0 OK
|
||||
|
|
@ -138,7 +139,7 @@ snmp_scalar_return(cxobj *xs,
|
|||
{
|
||||
int retval = -1;
|
||||
int asn1type;
|
||||
char *xmlstr = NULL;
|
||||
char *xmlstr = NULL;
|
||||
char *defaultval = NULL;
|
||||
u_char *snmpval = NULL;
|
||||
size_t snmplen = 0;
|
||||
|
|
@ -180,7 +181,7 @@ snmp_scalar_return(cxobj *xs,
|
|||
if ((ret = type_xml2snmp(xmlstr, &asn1type, &snmpval, &snmplen, &reason)) < 0)
|
||||
goto done;
|
||||
if (ret == 0){
|
||||
clicon_debug(1, "%s %s", __FUNCTION__, reason);
|
||||
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");
|
||||
goto done;
|
||||
|
|
@ -210,15 +211,16 @@ snmp_scalar_return(cxobj *xs,
|
|||
}
|
||||
|
||||
/*! Scalar handler, set a value to clixon
|
||||
*
|
||||
* get xpath: see yang2api_path_fmt / api_path2xpath
|
||||
* @param[in] h Clixon handle
|
||||
* @param[in] ys Yang node
|
||||
* @param[in] cvk Vector of index/Key variables, if any
|
||||
* @param[in] defaultval Default value
|
||||
* @param[in] reqinfo Agent transaction request structure
|
||||
* @param[in] request The netsnmp request info structure.
|
||||
* @param[in] request The netsnmp request info structure.
|
||||
* @retval 0 OK
|
||||
* @retval -1 Error
|
||||
* @retval -1 Error
|
||||
*/
|
||||
static int
|
||||
snmp_scalar_get(clicon_handle h,
|
||||
|
|
@ -244,7 +246,7 @@ snmp_scalar_get(clicon_handle h,
|
|||
cxobj *xcache = NULL;
|
||||
char *body = NULL;
|
||||
|
||||
clicon_debug(1, "%s", __FUNCTION__);
|
||||
clixon_debug(CLIXON_DBG_DEFAULT, "%s", __FUNCTION__);
|
||||
/* Prepare backend call by constructing namespace context */
|
||||
if (xml_nsctx_yang(ys, &nsc) < 0)
|
||||
goto done;
|
||||
|
|
@ -266,7 +268,7 @@ snmp_scalar_get(clicon_handle h,
|
|||
}
|
||||
x = xpath_first(xt, nsc, "%s", xpath);
|
||||
}
|
||||
/*
|
||||
/*
|
||||
* The xml to snmp value conversion is done in two steps:
|
||||
* 1. From XML to SNMP string, there is a special case for enumeration, and for default value
|
||||
* 2. From SNMP string to SNMP binary value which invloves parsing
|
||||
|
|
@ -298,7 +300,7 @@ snmp_scalar_get(clicon_handle h,
|
|||
if ((ret = type_xml2snmp(xmlstr, &asn1type, &snmpval, &snmplen, &reason)) < 0)
|
||||
goto done;
|
||||
if (ret == 0){
|
||||
clicon_debug(1, "%s %s", __FUNCTION__, reason);
|
||||
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");
|
||||
goto done;
|
||||
|
|
@ -344,7 +346,7 @@ snmp_yang2xml(cxobj *xtop,
|
|||
int i;
|
||||
int ret;
|
||||
yang_stmt *yspec;
|
||||
|
||||
|
||||
yspec = ys_spec(ys);
|
||||
if (yang2api_path_fmt(ys, 0, &api_path_fmt) < 0)
|
||||
goto done;
|
||||
|
|
@ -374,15 +376,16 @@ snmp_yang2xml(cxobj *xtop,
|
|||
return retval;
|
||||
}
|
||||
|
||||
/*! Scalar handler, get a value from clixon
|
||||
/*! Scalar handler, get a value from clixon
|
||||
*
|
||||
* @param[in] h Clixon handle
|
||||
* @param[in] ys Yang node
|
||||
* @param[in] cvk Vector of index/Key variables, if any
|
||||
* @param[in] valstr0 Pre-set value string, ignore requestvb
|
||||
* @param[in] reqinfo Agent transaction request structure
|
||||
* @param[in] request The netsnmp request info structure.
|
||||
* @param[in] request The netsnmp request info structure.
|
||||
* @retval 0 OK
|
||||
* @retval -1 Error
|
||||
* @retval -1 Error
|
||||
* @note contains special logic for rowstatus handling
|
||||
*/
|
||||
static int
|
||||
|
|
@ -404,13 +407,13 @@ snmp_scalar_set(clicon_handle h,
|
|||
int asn1_type;
|
||||
enum operation_type op = OP_MERGE;
|
||||
|
||||
clicon_debug(1, "%s", __FUNCTION__);
|
||||
clixon_debug(CLIXON_DBG_DEFAULT, "%s", __FUNCTION__);
|
||||
if ((xtop = xml_new(NETCONF_INPUT_CONFIG, NULL, CX_ELMNT)) == NULL)
|
||||
goto done;
|
||||
if (snmp_yang2xml(xtop, ys, cvk, &xbot) < 0)
|
||||
goto done;
|
||||
if ((xb = xml_new("body", xbot, CX_BODY)) == NULL)
|
||||
goto done;
|
||||
goto done;
|
||||
/* Extended */
|
||||
if (type_yang2asn1(ys, &asn1_type, 1) < 0)
|
||||
goto done;
|
||||
|
|
@ -473,7 +476,7 @@ snmp_cache_row_op(clicon_handle h,
|
|||
cxobj *xbot = NULL;
|
||||
cxobj *xa;
|
||||
cxobj *xcache;
|
||||
|
||||
|
||||
if (xml_nsctx_yang(yp, &nsc) < 0)
|
||||
goto done;
|
||||
/* Create xpath from yang */
|
||||
|
|
@ -499,7 +502,7 @@ snmp_cache_row_op(clicon_handle h,
|
|||
if ((cb = cbuf_new()) == NULL){
|
||||
clicon_err(OE_UNIX, errno, "cbuf_new");
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
if (clixon_xml2cbuf(cb, xtop, 0, 0, NULL, -1, 0) < 0)
|
||||
goto done;
|
||||
if (clicon_rpc_edit_config(h, "candidate", OP_NONE, cbuf_get(cb)) < 0)
|
||||
|
|
@ -552,8 +555,8 @@ snmp_cache_set(clicon_handle h,
|
|||
yang_stmt *yspec;
|
||||
int isrowstatus = 0;
|
||||
cxobj *xcache = NULL;
|
||||
|
||||
clicon_debug(1, "%s", __FUNCTION__);
|
||||
|
||||
clixon_debug(CLIXON_DBG_DEFAULT, "%s", __FUNCTION__);
|
||||
if ((yspec = clicon_dbspec_yang(h)) == NULL){
|
||||
clicon_err(OE_FATAL, 0, "No DB_SPEC");
|
||||
goto done;
|
||||
|
|
@ -563,7 +566,7 @@ snmp_cache_set(clicon_handle h,
|
|||
if (snmp_yang2xml(xtop, ys, cvk, &xbot) < 0)
|
||||
goto done;
|
||||
if ((xb = xml_new("body", xbot, CX_BODY)) == NULL)
|
||||
goto done;
|
||||
goto done;
|
||||
/* Extended */
|
||||
if (type_yang2asn1(ys, &asn1_type, 1) < 0)
|
||||
goto done;
|
||||
|
|
@ -596,8 +599,8 @@ snmp_cache_set(clicon_handle h,
|
|||
if (snmp_cache_row_op(h, yang_parent_get(ys), cvk, "merge", 1) < 0)
|
||||
goto done;
|
||||
}
|
||||
else if (strcmp(valstr, "destroy") == 0){
|
||||
clicon_debug(1, "%s %d", __FUNCTION__, rowstatus);
|
||||
else if (strcmp(valstr, "destroy") == 0){
|
||||
clixon_debug(CLIXON_DBG_DEFAULT, "%s %d", __FUNCTION__, rowstatus);
|
||||
/* Dont send delete to backend if notInService(2) */
|
||||
if (snmp_cache_row_op(h, yang_parent_get(ys), cvk, "delete", rowstatus!=2) < 0)
|
||||
goto done;
|
||||
|
|
@ -640,7 +643,7 @@ snmp_cache_set(clicon_handle h,
|
|||
* @param[in] cvk Vector of index/Key variables, if any
|
||||
* @param[out] rowstatus Enmu rowstatus: 0 invalid, 1 active, etc
|
||||
* @retval 0 OK
|
||||
* @retval -1 Error
|
||||
* @retval -1 Error
|
||||
*/
|
||||
static int
|
||||
snmp_table_rowstatus_get(clicon_handle h,
|
||||
|
|
@ -658,8 +661,8 @@ snmp_table_rowstatus_get(clicon_handle h,
|
|||
char *body;
|
||||
char *intstr;
|
||||
char *reason = NULL;
|
||||
|
||||
clicon_debug(1, "%s", __FUNCTION__);
|
||||
|
||||
clixon_debug(CLIXON_DBG_DEFAULT, "%s", __FUNCTION__);
|
||||
/* Prepare backend call by constructing namespace context */
|
||||
if (xml_nsctx_yang(ys, &nsc) < 0)
|
||||
goto done;
|
||||
|
|
@ -672,14 +675,14 @@ snmp_table_rowstatus_get(clicon_handle h,
|
|||
if ((ret = yang_enum2valstr(yrestype, body, &intstr)) < 0)
|
||||
goto done;
|
||||
if (ret == 0){
|
||||
clicon_debug(1, "%s %s invalid or not found", __FUNCTION__, body);
|
||||
clixon_debug(CLIXON_DBG_DEFAULT, "%s %s invalid or not found", __FUNCTION__, body);
|
||||
*rowstatus = 0;
|
||||
}
|
||||
else {
|
||||
if ((ret = parse_int32(intstr, rowstatus, &reason)) < 0)
|
||||
goto done;
|
||||
if (ret == 0){
|
||||
clicon_debug(1, "%s parse_int32: %s", __FUNCTION__, reason);
|
||||
clixon_debug(CLIXON_DBG_DEFAULT, "%s parse_int32: %s", __FUNCTION__, reason);
|
||||
*rowstatus = 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -718,7 +721,7 @@ clixon_snmp_scalar_handler1(netsnmp_mib_handler *handler,
|
|||
netsnmp_variable_list *requestvb = request->requestvb;
|
||||
int ret;
|
||||
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s", __FUNCTION__);
|
||||
clixon_debug(CLIXON_DBG_DETAIL, "%s", __FUNCTION__);
|
||||
if (snmp_common_handler(handler, nhreg, reqinfo, request, 0, &sh) < 0)
|
||||
goto done;
|
||||
/* see net-snmp/agent/snmp_agent.h / net-snmp/library/snmp.h */
|
||||
|
|
@ -740,7 +743,7 @@ clixon_snmp_scalar_handler1(netsnmp_mib_handler *handler,
|
|||
if (type_yang2asn1(sh->sh_ys, &asn1_type, 0) < 0)
|
||||
goto done;
|
||||
if (requestvb->type != asn1_type){
|
||||
clicon_debug(1, "%s Expected type:%d, got: %d", __FUNCTION__, 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");
|
||||
goto ok;
|
||||
|
|
@ -753,7 +756,7 @@ clixon_snmp_scalar_handler1(netsnmp_mib_handler *handler,
|
|||
if (snmp_scalar_set(sh->sh_h, sh->sh_ys, NULL, NULL, reqinfo, request) < 0)
|
||||
goto done;
|
||||
/*
|
||||
* There does not seem to be a separate validation action and commit does not
|
||||
* There does not seem to be a separate validation action and commit does not
|
||||
* return an error.
|
||||
* Therefore validation is done here directly as well as discard if it fails.
|
||||
*/
|
||||
|
|
@ -781,13 +784,13 @@ clixon_snmp_scalar_handler1(netsnmp_mib_handler *handler,
|
|||
break;
|
||||
case MODE_SET_UNDO: /* 5 */
|
||||
if (clicon_rpc_discard_changes(sh->sh_h) < 0)
|
||||
goto done;
|
||||
goto done;
|
||||
break;
|
||||
}
|
||||
ok:
|
||||
retval = SNMP_ERR_NOERROR;
|
||||
done:
|
||||
clicon_debug(1, "%s retval:%d", __FUNCTION__, retval);
|
||||
clixon_debug(CLIXON_DBG_DEFAULT, "%s retval:%d", __FUNCTION__, retval);
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
|
@ -797,6 +800,8 @@ clixon_snmp_scalar_handler1(netsnmp_mib_handler *handler,
|
|||
* @param[in] nhreg Root registration info.
|
||||
* @param[in] reqinfo Agent transaction request structure
|
||||
* @param[in] requests The netsnmp request info structure.
|
||||
* @retval SNMP_ERR_NOERROR OK
|
||||
* @retval -1 Error
|
||||
* @see clixon_snmp_table_handler
|
||||
*/
|
||||
int
|
||||
|
|
@ -809,7 +814,7 @@ clixon_snmp_scalar_handler(netsnmp_mib_handler *handler,
|
|||
netsnmp_request_info *req;
|
||||
int ret;
|
||||
|
||||
clicon_debug(1, "%s", __FUNCTION__);
|
||||
clixon_debug(CLIXON_DBG_DEFAULT, "%s", __FUNCTION__);
|
||||
for (req = requests; req; req = req->next){
|
||||
ret = clixon_snmp_scalar_handler1(handler, nhreg, reqinfo, req);
|
||||
if (ret != SNMP_ERR_NOERROR){
|
||||
|
|
@ -836,9 +841,9 @@ clixon_snmp_scalar_handler(netsnmp_mib_handler *handler,
|
|||
* @param[in] oidslen OID length of scalar
|
||||
* @param[in] reqinfo Agent transaction request structure
|
||||
* @param[in] request The netsnmp request info structure.
|
||||
* @retval -1 Error
|
||||
* @retval 0 Object not found
|
||||
* @retval 1 OK
|
||||
* @retval 0 Object not found
|
||||
* @retval -1 Error
|
||||
*/
|
||||
static int
|
||||
snmp_table_get(clicon_handle h,
|
||||
|
|
@ -889,7 +894,7 @@ snmp_table_get(clicon_handle h,
|
|||
*/
|
||||
if (yang_extension_value_opt(ys, "smiv2:defval", NULL, &defaultval) < 0)
|
||||
goto done;
|
||||
|
||||
|
||||
/* Create xpath with right keys from later part of OID
|
||||
* Inverse of snmp_str2oid
|
||||
*/
|
||||
|
|
@ -906,12 +911,12 @@ snmp_table_get(clicon_handle h,
|
|||
oidi = oids+oidtlen+1;
|
||||
/* Add keys */
|
||||
for (i=0; i<cvec_len(cvk_val); i++){
|
||||
cv = cvec_i(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));
|
||||
goto done;
|
||||
}
|
||||
if (snmp_oid2str(&oidi, &oidilen, yk, cv) < 0)
|
||||
if (snmp_oid2str(&oidi, &oidilen, yk, cv) < 0)
|
||||
goto done;
|
||||
}
|
||||
if (oidilen != 0){
|
||||
|
|
@ -938,6 +943,7 @@ snmp_table_get(clicon_handle h,
|
|||
}
|
||||
|
||||
/*! Set value in table
|
||||
*
|
||||
* Get yang of leaf from first part of OID
|
||||
* Create xpath with right keys from later part of OID
|
||||
* Query clixon if object exists, if so return value
|
||||
|
|
@ -948,9 +954,9 @@ snmp_table_get(clicon_handle h,
|
|||
* @param[in] reqinfo Agent transaction request structure
|
||||
* @param[in] request The netsnmp request info structure.
|
||||
* @param[out] err Error code if failed (retval = 0)
|
||||
* @retval -1 Error
|
||||
* @retval 0 Failed, err set
|
||||
* @retval 1 OK
|
||||
* @retval 0 Failed, err set
|
||||
* @retval -1 Error
|
||||
*/
|
||||
static int
|
||||
snmp_table_set(clicon_handle h,
|
||||
|
|
@ -1047,7 +1053,7 @@ snmp_table_set(clicon_handle h,
|
|||
goto done;
|
||||
requestvb = request->requestvb;
|
||||
if (requestvb->type != asn1_type){
|
||||
clicon_debug(1, "%s Expected type:%d, got: %d", __FUNCTION__, 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");
|
||||
goto ok;
|
||||
|
|
@ -1069,12 +1075,12 @@ snmp_table_set(clicon_handle h,
|
|||
oidi = oids+oidtlen+1;
|
||||
/* Add keys */
|
||||
for (i=0; i<cvec_len(cvk_val); i++){
|
||||
cv = cvec_i(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));
|
||||
goto done;
|
||||
}
|
||||
if (snmp_oid2str(&oidi, &oidilen, yk, cv) < 0)
|
||||
if (snmp_oid2str(&oidi, &oidilen, yk, cv) < 0)
|
||||
goto done;
|
||||
}
|
||||
if (oidilen != 0){
|
||||
|
|
@ -1090,7 +1096,7 @@ snmp_table_set(clicon_handle h,
|
|||
cvk_val,
|
||||
&rowstatus)) < 0)
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
else{
|
||||
/* If no rowstatus object, default to active */
|
||||
rowstatus = 1;
|
||||
|
|
@ -1152,6 +1158,7 @@ snmp_table_set(clicon_handle h,
|
|||
}
|
||||
|
||||
/*! Find "next" object from oids minus key and return that.
|
||||
*
|
||||
* @param[in] h Clixon handle
|
||||
* @param[in] ylist Yang of table (of list type)
|
||||
* @param[in] oids OID of ultimate scalar value
|
||||
|
|
@ -1189,12 +1196,12 @@ snmp_table_getnext(clicon_handle h,
|
|||
size_t oidklen = MAX_OID_LEN;
|
||||
oid oidnext[MAX_OID_LEN] = {0x7fffffff,}; /* Next oid: start with high value */
|
||||
size_t oidnextlen = MAX_OID_LEN;
|
||||
int found = 0;
|
||||
int found = 0;
|
||||
cxobj *xnext = NULL;
|
||||
yang_stmt *ynext = NULL;
|
||||
cbuf *cb = NULL;
|
||||
|
||||
clicon_debug(1, "%s", __FUNCTION__);
|
||||
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");
|
||||
|
|
@ -1256,7 +1263,7 @@ snmp_table_getnext(clicon_handle h,
|
|||
goto done;
|
||||
}
|
||||
oid_cbuf(cb, oidnext, oidnextlen);
|
||||
clicon_debug(1, "%s next: %s", __FUNCTION__, cbuf_get(cb));
|
||||
clixon_debug(CLIXON_DBG_DEFAULT, "%s next: %s", __FUNCTION__, cbuf_get(cb));
|
||||
}
|
||||
retval = found;
|
||||
done:
|
||||
|
|
@ -1267,7 +1274,7 @@ snmp_table_getnext(clicon_handle h,
|
|||
if (xt)
|
||||
xml_free(xt);
|
||||
if (nsc)
|
||||
xml_nsctx_free(nsc);
|
||||
xml_nsctx_free(nsc);
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
|
@ -1277,6 +1284,8 @@ snmp_table_getnext(clicon_handle h,
|
|||
* @param[in] nhreg Root registration info.
|
||||
* @param[in] reqinfo Agent transaction request structure
|
||||
* @param[in] request The netsnmp request info structure.
|
||||
* @retval 0 OK
|
||||
* @retval -1 Error
|
||||
*/
|
||||
static int
|
||||
clixon_snmp_table_handler1(netsnmp_mib_handler *handler,
|
||||
|
|
@ -1292,12 +1301,12 @@ clixon_snmp_table_handler1(netsnmp_mib_handler *handler,
|
|||
int ret;
|
||||
netsnmp_variable_list *requestvb;
|
||||
int err = 0;
|
||||
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s", __FUNCTION__);
|
||||
|
||||
clixon_debug(CLIXON_DBG_DETAIL, "%s", __FUNCTION__);
|
||||
if ((ret = snmp_common_handler(handler, nhreg, reqinfo, request, 1, &sh)) < 0)
|
||||
goto done;
|
||||
if (sh->sh_ys == NULL){
|
||||
clicon_debug(1, "%s Error table not registered", __FUNCTION__);
|
||||
clixon_debug(CLIXON_DBG_DEFAULT, "%s Error table not registered", __FUNCTION__);
|
||||
goto ok;
|
||||
}
|
||||
requestvb = request->requestvb;
|
||||
|
|
@ -1306,7 +1315,7 @@ clixon_snmp_table_handler1(netsnmp_mib_handler *handler,
|
|||
/* Create xpath from YANG table OID + 1 + n + cvk/key = requestvb->name
|
||||
*/
|
||||
if ((ret = snmp_table_get(sh->sh_h, sh->sh_ys,
|
||||
sh->sh_oid2, sh->sh_oid2len,
|
||||
sh->sh_oid2, sh->sh_oid2len,
|
||||
requestvb->name, requestvb->name_length,
|
||||
reqinfo, request)) < 0)
|
||||
goto done;
|
||||
|
|
@ -1315,7 +1324,7 @@ clixon_snmp_table_handler1(netsnmp_mib_handler *handler,
|
|||
clicon_err(OE_SNMP, ret, "netsnmp_request_set_error");
|
||||
goto done;
|
||||
}
|
||||
clicon_debug(1, "%s Nosuchinstance", __FUNCTION__);
|
||||
clixon_debug(CLIXON_DBG_DEFAULT, "%s Nosuchinstance", __FUNCTION__);
|
||||
}
|
||||
break;
|
||||
case MODE_GETNEXT: // 161
|
||||
|
|
@ -1330,13 +1339,13 @@ clixon_snmp_table_handler1(netsnmp_mib_handler *handler,
|
|||
clicon_err(OE_SNMP, ret, "netsnmp_request_set_error");
|
||||
goto done;
|
||||
}
|
||||
clicon_debug(1, "%s No such object", __FUNCTION__);
|
||||
clixon_debug(CLIXON_DBG_DEFAULT, "%s No such object", __FUNCTION__);
|
||||
}
|
||||
break;
|
||||
case MODE_SET_RESERVE1: // 0
|
||||
if (!yang_config_ancestor(sh->sh_ys)){
|
||||
netsnmp_request_set_error(request, SNMP_ERR_NOTWRITABLE);
|
||||
goto done;;
|
||||
goto done;
|
||||
}
|
||||
// Check types: compare type in requestvb to yang type (or do later)
|
||||
break;
|
||||
|
|
@ -1352,7 +1361,7 @@ clixon_snmp_table_handler1(netsnmp_mib_handler *handler,
|
|||
clicon_err(OE_SNMP, ret, "netsnmp_request_set_error");
|
||||
goto done;
|
||||
}
|
||||
clicon_debug(1, "%s Nosuchinstance", __FUNCTION__);
|
||||
clixon_debug(CLIXON_DBG_DEFAULT, "%s Nosuchinstance", __FUNCTION__);
|
||||
}
|
||||
/*
|
||||
* There does not seem to be a separate validation action and commit does not
|
||||
|
|
@ -1380,7 +1389,7 @@ clixon_snmp_table_handler1(netsnmp_mib_handler *handler,
|
|||
break;
|
||||
case MODE_SET_UNDO : // 5
|
||||
if (clicon_rpc_discard_changes(sh->sh_h) < 0)
|
||||
goto done;
|
||||
goto done;
|
||||
break;
|
||||
}
|
||||
ok:
|
||||
|
|
@ -1401,6 +1410,8 @@ clixon_snmp_table_handler1(netsnmp_mib_handler *handler,
|
|||
* @param[in] nhreg Root registration info.
|
||||
* @param[in] reqinfo Agent transaction request structure
|
||||
* @param[in] requests The netsnmp request info structure.
|
||||
* @retval 0 OK
|
||||
* @retval -1 Error
|
||||
* @see clixon_snmp_scalar_handler
|
||||
*/
|
||||
int
|
||||
|
|
@ -1413,7 +1424,7 @@ clixon_snmp_table_handler(netsnmp_mib_handler *handler,
|
|||
netsnmp_request_info *req;
|
||||
int ret;
|
||||
|
||||
clicon_debug(1, "%s", __FUNCTION__);
|
||||
clixon_debug(CLIXON_DBG_DEFAULT, "%s", __FUNCTION__);
|
||||
for (req = requests; req; req = req->next){
|
||||
ret = clixon_snmp_table_handler1(handler, nhreg, reqinfo, req);
|
||||
if (ret != SNMP_ERR_NOERROR){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue