Discriminate APP debugging

This commit is contained in:
Philip Prindeville 2024-01-04 15:40:53 -07:00 committed by Olof Hagsand
parent 063c8d664f
commit 0ec1e0a686
36 changed files with 366 additions and 365 deletions

View file

@ -100,7 +100,7 @@ snmp_common_handler(netsnmp_mib_handler *handler,
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 */
clixon_debug(CLIXON_DBG_DEFAULT, "%s \"%s\" %s inclusive:%d %s", __FUNCTION__,
clixon_debug(CLIXON_DBG_CLIENT, "%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
clixon_debug(CLIXON_DBG_DEFAULT, "%s \"%s\" %s inclusive:%d %s", __FUNCTION__,
clixon_debug(CLIXON_DBG_CLIENT, "%s \"%s\" %s inclusive:%d %s", __FUNCTION__,
cbuf_get(cb),
snmp_msg_int2str(reqinfo->mode),
request->inclusive, tablehandler?"table":"scalar");
@ -181,7 +181,7 @@ snmp_scalar_return(cxobj *xs,
if ((ret = type_xml2snmp(xmlstr, &asn1type, &snmpval, &snmplen, &reason)) < 0)
goto done;
if (ret == 0){
clixon_debug(CLIXON_DBG_DEFAULT, "%s %s", __FUNCTION__, reason);
clixon_debug(CLIXON_DBG_CLIENT, "%s %s", __FUNCTION__, reason);
if ((ret = netsnmp_request_set_error(request, SNMP_ERR_WRONGTYPE)) != SNMPERR_SUCCESS){
clixon_err(OE_SNMP, ret, "netsnmp_request_set_error");
goto done;
@ -246,7 +246,7 @@ snmp_scalar_get(clixon_handle h,
cxobj *xcache = NULL;
char *body = NULL;
clixon_debug(CLIXON_DBG_DEFAULT, "%s", __FUNCTION__);
clixon_debug(CLIXON_DBG_CLIENT, "%s", __FUNCTION__);
/* Prepare backend call by constructing namespace context */
if (xml_nsctx_yang(ys, &nsc) < 0)
goto done;
@ -301,7 +301,7 @@ snmp_scalar_get(clixon_handle h,
if ((ret = type_xml2snmp(xmlstr, &asn1type, &snmpval, &snmplen, &reason)) < 0)
goto done;
if (ret == 0){
clixon_debug(CLIXON_DBG_DEFAULT, "%s %s", __FUNCTION__, reason);
clixon_debug(CLIXON_DBG_CLIENT, "%s %s", __FUNCTION__, reason);
if ((ret = netsnmp_request_set_error(request, SNMP_ERR_WRONGTYPE)) != SNMPERR_SUCCESS){
clixon_err(OE_SNMP, ret, "netsnmp_request_set_error");
goto done;
@ -408,7 +408,7 @@ snmp_scalar_set(clixon_handle h,
int asn1_type;
enum operation_type op = OP_MERGE;
clixon_debug(CLIXON_DBG_DEFAULT, "%s", __FUNCTION__);
clixon_debug(CLIXON_DBG_CLIENT, "%s", __FUNCTION__);
if ((xtop = xml_new(NETCONF_INPUT_CONFIG, NULL, CX_ELMNT)) == NULL)
goto done;
if (snmp_yang2xml(xtop, ys, cvk, &xbot) < 0)
@ -557,7 +557,7 @@ snmp_cache_set(clixon_handle h,
int isrowstatus = 0;
cxobj *xcache = NULL;
clixon_debug(CLIXON_DBG_DEFAULT, "%s", __FUNCTION__);
clixon_debug(CLIXON_DBG_CLIENT, "%s", __FUNCTION__);
if ((yspec = clicon_dbspec_yang(h)) == NULL){
clixon_err(OE_FATAL, 0, "No DB_SPEC");
goto done;
@ -601,7 +601,7 @@ snmp_cache_set(clixon_handle h,
goto done;
}
else if (strcmp(valstr, "destroy") == 0){
clixon_debug(CLIXON_DBG_DEFAULT, "%s %d", __FUNCTION__, rowstatus);
clixon_debug(CLIXON_DBG_CLIENT, "%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;
@ -663,7 +663,7 @@ snmp_table_rowstatus_get(clixon_handle h,
char *intstr;
char *reason = NULL;
clixon_debug(CLIXON_DBG_DEFAULT, "%s", __FUNCTION__);
clixon_debug(CLIXON_DBG_CLIENT, "%s", __FUNCTION__);
/* Prepare backend call by constructing namespace context */
if (xml_nsctx_yang(ys, &nsc) < 0)
goto done;
@ -676,14 +676,14 @@ snmp_table_rowstatus_get(clixon_handle h,
if ((ret = yang_enum2valstr(yrestype, body, &intstr)) < 0)
goto done;
if (ret == 0){
clixon_debug(CLIXON_DBG_DEFAULT, "%s %s invalid or not found", __FUNCTION__, body);
clixon_debug(CLIXON_DBG_CLIENT, "%s %s invalid or not found", __FUNCTION__, body);
*rowstatus = 0;
}
else {
if ((ret = parse_int32(intstr, rowstatus, &reason)) < 0)
goto done;
if (ret == 0){
clixon_debug(CLIXON_DBG_DEFAULT, "%s parse_int32: %s", __FUNCTION__, reason);
clixon_debug(CLIXON_DBG_CLIENT, "%s parse_int32: %s", __FUNCTION__, reason);
*rowstatus = 0;
}
}
@ -722,7 +722,7 @@ clixon_snmp_scalar_handler1(netsnmp_mib_handler *handler,
netsnmp_variable_list *requestvb = request->requestvb;
int ret;
clixon_debug(CLIXON_DBG_DEFAULT | CLIXON_DBG_DETAIL, "%s", __FUNCTION__);
clixon_debug(CLIXON_DBG_CLIENT | 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 */
@ -744,7 +744,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){
clixon_debug(CLIXON_DBG_DEFAULT, "%s Expected type:%d, got: %d", __FUNCTION__, requestvb->type, asn1_type);
clixon_debug(CLIXON_DBG_CLIENT, "%s Expected type:%d, got: %d", __FUNCTION__, requestvb->type, asn1_type);
if ((ret = netsnmp_request_set_error(request, SNMP_ERR_WRONGTYPE)) != SNMPERR_SUCCESS){
clixon_err(OE_SNMP, ret, "netsnmp_request_set_error");
goto ok;
@ -791,7 +791,7 @@ clixon_snmp_scalar_handler1(netsnmp_mib_handler *handler,
ok:
retval = SNMP_ERR_NOERROR;
done:
clixon_debug(CLIXON_DBG_DEFAULT, "%s retval:%d", __FUNCTION__, retval);
clixon_debug(CLIXON_DBG_CLIENT, "%s retval:%d", __FUNCTION__, retval);
return retval;
}
@ -815,7 +815,7 @@ clixon_snmp_scalar_handler(netsnmp_mib_handler *handler,
netsnmp_request_info *req;
int ret;
clixon_debug(CLIXON_DBG_DEFAULT, "%s", __FUNCTION__);
clixon_debug(CLIXON_DBG_CLIENT, "%s", __FUNCTION__);
for (req = requests; req; req = req->next){
ret = clixon_snmp_scalar_handler1(handler, nhreg, reqinfo, req);
if (ret != SNMP_ERR_NOERROR){
@ -1054,7 +1054,7 @@ snmp_table_set(clixon_handle h,
goto done;
requestvb = request->requestvb;
if (requestvb->type != asn1_type){
clixon_debug(CLIXON_DBG_DEFAULT, "%s Expected type:%d, got: %d", __FUNCTION__, requestvb->type, asn1_type);
clixon_debug(CLIXON_DBG_CLIENT, "%s Expected type:%d, got: %d", __FUNCTION__, requestvb->type, asn1_type);
if ((ret = netsnmp_request_set_error(request, SNMP_ERR_WRONGTYPE)) != SNMPERR_SUCCESS){
clixon_err(OE_SNMP, ret, "netsnmp_request_set_error");
goto ok;
@ -1202,7 +1202,7 @@ snmp_table_getnext(clixon_handle h,
yang_stmt *ynext = NULL;
cbuf *cb = NULL;
clixon_debug(CLIXON_DBG_DEFAULT, "%s", __FUNCTION__);
clixon_debug(CLIXON_DBG_CLIENT, "%s", __FUNCTION__);
if ((ys = yang_parent_get(ylist)) == NULL ||
yang_keyword_get(ys) != Y_CONTAINER){
clixon_err(OE_YANG, EINVAL, "ylist parent is not list");
@ -1264,7 +1264,7 @@ snmp_table_getnext(clixon_handle h,
goto done;
}
oid_cbuf(cb, oidnext, oidnextlen);
clixon_debug(CLIXON_DBG_DEFAULT, "%s next: %s", __FUNCTION__, cbuf_get(cb));
clixon_debug(CLIXON_DBG_CLIENT, "%s next: %s", __FUNCTION__, cbuf_get(cb));
}
retval = found;
done:
@ -1303,11 +1303,11 @@ clixon_snmp_table_handler1(netsnmp_mib_handler *handler,
netsnmp_variable_list *requestvb;
int err = 0;
clixon_debug(CLIXON_DBG_DEFAULT | CLIXON_DBG_DETAIL, "%s", __FUNCTION__);
clixon_debug(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, "%s", __FUNCTION__);
if ((ret = snmp_common_handler(handler, nhreg, reqinfo, request, 1, &sh)) < 0)
goto done;
if (sh->sh_ys == NULL){
clixon_debug(CLIXON_DBG_DEFAULT, "%s Error table not registered", __FUNCTION__);
clixon_debug(CLIXON_DBG_CLIENT, "%s Error table not registered", __FUNCTION__);
goto ok;
}
requestvb = request->requestvb;
@ -1325,7 +1325,7 @@ clixon_snmp_table_handler1(netsnmp_mib_handler *handler,
clixon_err(OE_SNMP, ret, "netsnmp_request_set_error");
goto done;
}
clixon_debug(CLIXON_DBG_DEFAULT, "%s Nosuchinstance", __FUNCTION__);
clixon_debug(CLIXON_DBG_CLIENT, "%s Nosuchinstance", __FUNCTION__);
}
break;
case MODE_GETNEXT: // 161
@ -1340,7 +1340,7 @@ clixon_snmp_table_handler1(netsnmp_mib_handler *handler,
clixon_err(OE_SNMP, ret, "netsnmp_request_set_error");
goto done;
}
clixon_debug(CLIXON_DBG_DEFAULT, "%s No such object", __FUNCTION__);
clixon_debug(CLIXON_DBG_CLIENT, "%s No such object", __FUNCTION__);
}
break;
case MODE_SET_RESERVE1: // 0
@ -1362,7 +1362,7 @@ clixon_snmp_table_handler1(netsnmp_mib_handler *handler,
clixon_err(OE_SNMP, ret, "netsnmp_request_set_error");
goto done;
}
clixon_debug(CLIXON_DBG_DEFAULT, "%s Nosuchinstance", __FUNCTION__);
clixon_debug(CLIXON_DBG_CLIENT, "%s Nosuchinstance", __FUNCTION__);
}
/*
* There does not seem to be a separate validation action and commit does not
@ -1425,7 +1425,7 @@ clixon_snmp_table_handler(netsnmp_mib_handler *handler,
netsnmp_request_info *req;
int ret;
clixon_debug(CLIXON_DBG_DEFAULT, "%s", __FUNCTION__);
clixon_debug(CLIXON_DBG_CLIENT, "%s", __FUNCTION__);
for (req = requests; req; req = req->next){
ret = clixon_snmp_table_handler1(handler, nhreg, reqinfo, req);
if (ret != SNMP_ERR_NOERROR){

View file

@ -470,7 +470,7 @@ yangext_oid_get(yang_stmt *yn,
if (yang_extension_value_opt(yref, "smiv2:oid", &exist, &oidstr) < 0)
goto done;
if (exist == 0 || oidstr == NULL){
clixon_debug(CLIXON_DBG_DEFAULT, "OID not found as SMIv2 yang extension of %s", yang_argument_get(yref));
clixon_debug(CLIXON_DBG_CLIENT, "OID not found as SMIv2 yang extension of %s", yang_argument_get(yref));
goto fail;
}
if (snmp_parse_oid(oidstr, objid, objidlen) == NULL){
@ -649,7 +649,7 @@ type_snmp2xml(yang_stmt *ys,
yang_stmt *yrestype = NULL;
int ret;
clixon_debug(CLIXON_DBG_DEFAULT, "%s", __FUNCTION__);
clixon_debug(CLIXON_DBG_CLIENT, "%s", __FUNCTION__);
if (valstr == NULL){
clixon_err(OE_UNIX, EINVAL, "valstr is NULL");
goto done;
@ -733,7 +733,7 @@ type_snmp2xml(yang_stmt *ys,
}
default:
assert(0); // XXX
clixon_debug(CLIXON_DBG_DEFAULT, "%s %s not supported", __FUNCTION__, cv_type2str(cvtype));
clixon_debug(CLIXON_DBG_CLIENT, "%s %s not supported", __FUNCTION__, cv_type2str(cvtype));
if ((ret = netsnmp_request_set_error(request, SNMP_ERR_WRONGTYPE)) != SNMPERR_SUCCESS){
clixon_err(OE_SNMP, ret, "netsnmp_request_set_error");
goto done;
@ -747,7 +747,7 @@ type_snmp2xml(yang_stmt *ys,
}
retval = 1;
done:
clixon_debug(CLIXON_DBG_DEFAULT | CLIXON_DBG_DETAIL, "%s %d", __FUNCTION__, retval);
clixon_debug(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, "%s %d", __FUNCTION__, retval);
if (origtype)
free(origtype);
if (cv)
@ -794,7 +794,7 @@ type_xml2snmp_pre(char *xmlstr0,
if ((ret = yang_enum2valstr(yrestype, xmlstr0, &str)) < 0)
goto done;
if (ret == 0){
clixon_debug(CLIXON_DBG_DEFAULT, "Invalid enum valstr %s", xmlstr0);
clixon_debug(CLIXON_DBG_CLIENT, "Invalid enum valstr %s", xmlstr0);
goto fail;
}
}
@ -820,7 +820,7 @@ type_xml2snmp_pre(char *xmlstr0,
if ((ret = parse_dec64(xmlstr0, cv_dec64_n_get(cv), &num, NULL)) < 0)
goto done;
if (ret == 0){
clixon_debug(CLIXON_DBG_DEFAULT, "Invalid decimal64 valstr %s", xmlstr0);
clixon_debug(CLIXON_DBG_CLIENT, "Invalid decimal64 valstr %s", xmlstr0);
goto fail;
}
cv_dec64_i_set(cv, num);
@ -836,7 +836,7 @@ type_xml2snmp_pre(char *xmlstr0,
}
retval = 1;
done:
clixon_debug(CLIXON_DBG_DEFAULT | CLIXON_DBG_DETAIL, "%s %d", __FUNCTION__, retval);
clixon_debug(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, "%s %d", __FUNCTION__, retval);
if (cb)
cbuf_free(cb);
return retval;
@ -905,7 +905,7 @@ type_xml2snmp(char *snmpstr,
oid oid1[MAX_OID_LEN] = {0,};
size_t sz1 = MAX_OID_LEN;
if (snmp_parse_oid(snmpstr, oid1, &sz1) == NULL){
clixon_debug(CLIXON_DBG_DEFAULT, "Failed to parse OID %s", snmpstr);
clixon_debug(CLIXON_DBG_CLIENT, "Failed to parse OID %s", snmpstr);
goto fail;
}
*snmplen = sizeof(oid)*sz1;
@ -961,7 +961,7 @@ type_xml2snmp(char *snmpstr,
}
memset(*snmpval, 0, *snmplen + 1);
if ((eaddr = ether_aton(snmpstr)) == NULL){
clixon_debug(CLIXON_DBG_DEFAULT, "ether_aton(%s)", snmpstr);
clixon_debug(CLIXON_DBG_CLIENT, "ether_aton(%s)", snmpstr);
goto fail;
}
memcpy(*snmpval, eaddr, sizeof(*eaddr));
@ -981,7 +981,7 @@ type_xml2snmp(char *snmpstr,
}
retval = 1;
done:
clixon_debug(CLIXON_DBG_DEFAULT | CLIXON_DBG_DETAIL, "%s %d", __FUNCTION__, retval);
clixon_debug(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, "%s %d", __FUNCTION__, retval);
return retval;
fail:
retval = 0;
@ -1232,7 +1232,7 @@ clixon_snmp_err_cb(void *handle,
{
const char *errstr;
clixon_debug(CLIXON_DBG_DEFAULT, "%s", __FUNCTION__);
clixon_debug(CLIXON_DBG_CLIENT, "%s", __FUNCTION__);
if (suberr < 0){
if (suberr < -CLIXON_ERR_SNMP_MIB){
switch (suberr+CLIXON_ERR_SNMP_MIB){

View file

@ -170,7 +170,7 @@ clixon_snmp_fdset_register(clixon_handle h,
/* eg 4, 6, 8 */
for (s=0; s<numfds; s++){
if (FD_ISSET(s, &readfds)){
clixon_debug(CLIXON_DBG_DEFAULT, "%s %d", __FUNCTION__, s);
clixon_debug(CLIXON_DBG_CLIENT, "%s %d", __FUNCTION__, s);
if (regfd){
if (clixon_event_reg_fd(s, clixon_snmp_input_cb, h, "snmp socket") < 0)
goto done;
@ -205,7 +205,7 @@ clixon_snmp_input_cb(int s,
clixon_handle h = (clixon_handle)arg;
int ret;
clixon_debug(CLIXON_DBG_DEFAULT | CLIXON_DBG_DETAIL, "%s %d", __FUNCTION__, s);
clixon_debug(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, "%s %d", __FUNCTION__, s);
FD_ZERO(&readfds);
FD_SET(s, &readfds);
(void)snmp_read(&readfds);
@ -253,7 +253,7 @@ clixon_snmp_init_subagent(clixon_handle h,
int retval = -1;
char *sockpath = NULL;
clixon_debug(CLIXON_DBG_DEFAULT, "%s", __FUNCTION__);
clixon_debug(CLIXON_DBG_CLIENT, "%s", __FUNCTION__);
if (logdst == CLIXON_LOG_SYSLOG)
snmp_enable_calllog();
else

View file

@ -190,7 +190,7 @@ mibyang_leaf_register(clixon_handle h,
goto done;
}
oid_cbuf(cboid, oid1, oid1len);
clixon_debug(CLIXON_DBG_DEFAULT, "%s register: %s %s", __FUNCTION__, name, cbuf_get(cboid));
clixon_debug(CLIXON_DBG_CLIENT, "%s register: %s %s", __FUNCTION__, name, cbuf_get(cboid));
ok:
retval = 0;
done:
@ -327,7 +327,7 @@ mibyang_table_register(clixon_handle h,
goto done;
}
sh->sh_table_info = table_info; /* Keep to free at exit */
clixon_debug(CLIXON_DBG_DEFAULT, "%s register: %s %s", __FUNCTION__, name, oidstr);
clixon_debug(CLIXON_DBG_CLIENT, "%s register: %s %s", __FUNCTION__, name, oidstr);
ok:
retval = 0;
done:
@ -478,7 +478,7 @@ mibyang_table_poll(clixon_handle h,
oid oidk[MAX_OID_LEN] = {0,};
size_t oidklen = MAX_OID_LEN;
clixon_debug(CLIXON_DBG_DEFAULT, "%s", __FUNCTION__);
clixon_debug(CLIXON_DBG_CLIENT, "%s", __FUNCTION__);
if ((ys = yang_parent_get(ylist)) == NULL ||
yang_keyword_get(ys) != Y_CONTAINER){
clixon_err(OE_YANG, EINVAL, "ylist parent is not list");
@ -559,7 +559,7 @@ mibyang_traverse(clixon_handle h,
int ret;
static oid zero_oid = 0;
clixon_debug(CLIXON_DBG_DEFAULT, "%s %s", __FUNCTION__, yang_argument_get(yn));
clixon_debug(CLIXON_DBG_CLIENT, "%s %s", __FUNCTION__, yang_argument_get(yn));
switch(yang_keyword_get(yn)){
case Y_AUGMENT:
if (mibyang_augment_register(h, yn) < 0)
@ -632,7 +632,7 @@ clixon_snmp_traverse_mibyangs(clixon_handle h)
continue;
if ((modname = xml_body(x)) == NULL)
continue;
clixon_debug(CLIXON_DBG_DEFAULT, "%s %s: \"%s\"", __FUNCTION__, xml_name(x), modname);
clixon_debug(CLIXON_DBG_CLIENT, "%s %s: \"%s\"", __FUNCTION__, xml_name(x), modname);
/* Note, here we assume the Yang is loaded by some other mechanism and
* error if it not found.
* Alternatively, that YANG could be loaded.