Symbolic and combined debug names in cmd-line of all applications

New debug levels: BACKEND, CLI, NETCONF,RESTCONF, SNMP, STREAM
This commit is contained in:
Olof hagsand 2024-02-02 11:47:01 +01:00
parent 86f251f343
commit 4e3bd6fbdd
39 changed files with 564 additions and 416 deletions

View file

@ -13,6 +13,11 @@ Expected: February 2024
### Minor features ### Minor features
* New command-line debug mechanism
* Separation between subject-area and details
* Multiple subject-areas
* Symbolic and combined debug names, example: `-D debug -D detail`
* See https://clixon-docs.readthedocs.io/en/latest/errors.html#customized-errors for more info
* Made coverity analysis and fixed most of them * Made coverity analysis and fixed most of them
* Some were ignored being for generated code (eg lex) or not applicable * Some were ignored being for generated code (eg lex) or not applicable
* Feature: [Add support for -V option to give version](https://github.com/clicon/clixon/issues/472) * Feature: [Add support for -V option to give version](https://github.com/clicon/clixon/issues/472)

View file

@ -146,7 +146,7 @@ ce_event_cb(clixon_handle h,
struct client_entry *ce = (struct client_entry *)arg; struct client_entry *ce = (struct client_entry *)arg;
cbuf *cbce = NULL; cbuf *cbce = NULL;
clixon_debug(CLIXON_DBG_CLIENT, "op:%d", op); clixon_debug(CLIXON_DBG_BACKEND, "op:%d", op);
switch (op){ switch (op){
case 1: case 1:
/* Risk of recursion here */ /* Risk of recursion here */
@ -282,7 +282,7 @@ backend_monitoring_state_get(clixon_handle h,
goto fail; goto fail;
retval = 1; retval = 1;
done: done:
clixon_debug(CLIXON_DBG_CLIENT, "retval:%d", retval); clixon_debug(CLIXON_DBG_BACKEND, "retval:%d", retval);
if (cb) if (cb)
cbuf_free(cb); cbuf_free(cb);
return retval; return retval;
@ -321,10 +321,10 @@ backend_client_rm(clixon_handle h,
if (if_feature(yspec, "ietf-netconf", "confirmed-commit")) { if (if_feature(yspec, "ietf-netconf", "confirmed-commit")) {
if (confirmed_commit_state_get(h) == EPHEMERAL) { if (confirmed_commit_state_get(h) == EPHEMERAL) {
/* See if this client is the origin */ /* See if this client is the origin */
clixon_debug(CLIXON_DBG_CLIENT, "session_id: %u, confirmed_commit.session_id: %u", ce->ce_id, confirmed_commit_session_id_get(h)); clixon_debug(CLIXON_DBG_BACKEND, "session_id: %u, confirmed_commit.session_id: %u", ce->ce_id, confirmed_commit_session_id_get(h));
if (myid == confirmed_commit_session_id_get(h)) { if (myid == confirmed_commit_session_id_get(h)) {
clixon_debug(CLIXON_DBG_CLIENT, "ok, rolling back"); clixon_debug(CLIXON_DBG_BACKEND, "ok, rolling back");
clixon_log(h, LOG_NOTICE, "a client with an active ephemeral confirmed-commit has disconnected; rolling back"); clixon_log(h, LOG_NOTICE, "a client with an active ephemeral confirmed-commit has disconnected; rolling back");
/* do_rollback errors are logged internally and there is no client to report errors to, so errors are /* do_rollback errors are logged internally and there is no client to report errors to, so errors are
@ -336,7 +336,7 @@ backend_client_rm(clixon_handle h,
} }
} }
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_BACKEND, "");
/* for all streams: XXX better to do it top-level? */ /* for all streams: XXX better to do it top-level? */
stream_ss_delete_all(h, ce_event_cb, (void*)ce); stream_ss_delete_all(h, ce_event_cb, (void*)ce);
c0 = backend_client_list(h); c0 = backend_client_list(h);
@ -378,7 +378,7 @@ clixon_stats_datastore_get(clixon_handle h,
size_t sz = 0; size_t sz = 0;
cxobj *xn = NULL; cxobj *xn = NULL;
clixon_debug(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, "%s", dbname); clixon_debug(CLIXON_DBG_BACKEND | CLIXON_DBG_DETAIL, "%s", dbname);
/* This is the db cache */ /* This is the db cache */
if ((xt = xmldb_cache_get(h, dbname)) == NULL){ if ((xt = xmldb_cache_get(h, dbname)) == NULL){
/* Trigger cache if no exist (trick to ensure cache is present) */ /* Trigger cache if no exist (trick to ensure cache is present) */
@ -655,7 +655,7 @@ from_client_edit_config(clixon_handle h,
xml_free(xret); xml_free(xret);
if (cbx) if (cbx)
cbuf_free(cbx); cbuf_free(cbx);
clixon_debug(CLIXON_DBG_CLIENT, "done cbret:%s", cbuf_get(cbret)); clixon_debug(CLIXON_DBG_BACKEND, "done cbret:%s", cbuf_get(cbret));
return retval; return retval;
} /* from_client_edit_config */ } /* from_client_edit_config */
@ -1584,7 +1584,7 @@ from_client_msg(clixon_handle h,
int nr = 0; int nr = 0;
cbuf *cbce = NULL; cbuf *cbce = NULL;
clixon_debug(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, ""); clixon_debug(CLIXON_DBG_BACKEND | CLIXON_DBG_DETAIL, "");
yspec = clicon_dbspec_yang(h); yspec = clicon_dbspec_yang(h);
/* Return netconf message. Should be filled in by the dispatch(sub) functions /* Return netconf message. Should be filled in by the dispatch(sub) functions
* as wither rpc-error or by positive response. * as wither rpc-error or by positive response.
@ -1633,7 +1633,7 @@ from_client_msg(clixon_handle h,
if (op_id != 0 && ce->ce_id != op_id && strcmp(rpcname, "create-subscription")){ if (op_id != 0 && ce->ce_id != op_id && strcmp(rpcname, "create-subscription")){
client_entry *ce0; client_entry *ce0;
clixon_debug(CLIXON_DBG_CLIENT, "Warning: incoming session-id:%u does not match ce_id:%u on socket: %d", op_id, ce->ce_id, ce->ce_s); clixon_debug(CLIXON_DBG_BACKEND, "Warning: incoming session-id:%u does not match ce_id:%u on socket: %d", op_id, ce->ce_id, ce->ce_s);
/* Copy transport from orig client-entry */ /* Copy transport from orig client-entry */
if (ce->ce_transport == NULL && if (ce->ce_transport == NULL &&
(ce0 = ce_find_byid(backend_client_list(h), op_id)) != NULL && (ce0 = ce_find_byid(backend_client_list(h), op_id)) != NULL &&
@ -1720,7 +1720,7 @@ from_client_msg(clixon_handle h,
goto done; goto done;
} }
module = yang_argument_get(ymod); module = yang_argument_get(ymod);
clixon_debug(CLIXON_DBG_CLIENT, "module:%s rpc:%s ce_id:%u s:%d", module, clixon_debug(CLIXON_DBG_BACKEND, "module:%s rpc:%s ce_id:%u s:%d", module,
rpc, ce->ce_id, ce->ce_s); rpc, ce->ce_id, ce->ce_s);
/* Pre-NACM access step */ /* Pre-NACM access step */
xnacm = NULL; xnacm = NULL;
@ -1812,7 +1812,7 @@ from_client_msg(clixon_handle h,
// ok: // ok:
retval = 0; retval = 0;
done: done:
clixon_debug(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, "retval:%d", retval); clixon_debug(CLIXON_DBG_BACKEND | CLIXON_DBG_DETAIL, "retval:%d", retval);
if (xnacm){ if (xnacm){
xml_free(xnacm); xml_free(xnacm);
if (clicon_nacm_cache_set(h, NULL) < 0) if (clicon_nacm_cache_set(h, NULL) < 0)
@ -1830,7 +1830,7 @@ from_client_msg(clixon_handle h,
if (retval < 0 && clixon_err_category() < 0) if (retval < 0 && clixon_err_category() < 0)
clixon_log(h, LOG_NOTICE, "%s: Internal error: No clixon_err call on RPC error (message: %s)", clixon_log(h, LOG_NOTICE, "%s: Internal error: No clixon_err call on RPC error (message: %s)",
__FUNCTION__, rpc?rpc:""); __FUNCTION__, rpc?rpc:"");
// clixon_debug(CLIXON_DBG_CLIENT, "retval:%d", retval); // clixon_debug(CLIXON_DBG_BACKEND, "retval:%d", retval);
return retval;// -1 here terminates backend return retval;// -1 here terminates backend
} }
@ -1853,7 +1853,7 @@ from_client(int s,
int eof = 0; int eof = 0;
cbuf *cbce = NULL; cbuf *cbce = NULL;
clixon_debug(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, ""); clixon_debug(CLIXON_DBG_BACKEND | CLIXON_DBG_DETAIL, "");
if (s != ce->ce_s){ if (s != ce->ce_s){
clixon_err(OE_NETCONF, EINVAL, "Internal error: s != ce->ce_s"); clixon_err(OE_NETCONF, EINVAL, "Internal error: s != ce->ce_s");
goto done; goto done;
@ -1871,7 +1871,7 @@ from_client(int s,
goto done; goto done;
retval = 0; retval = 0;
done: done:
clixon_debug(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, "retval:%d", retval); clixon_debug(CLIXON_DBG_BACKEND | CLIXON_DBG_DETAIL, "retval:%d", retval);
if (cbce) if (cbce)
cbuf_free(cbce); cbuf_free(cbce);
if (msg) if (msg)

View file

@ -178,7 +178,7 @@ startup_common(clixon_handle h,
if (clicon_option_bool(h, "CLICON_XMLDB_MODSTATE")) if (clicon_option_bool(h, "CLICON_XMLDB_MODSTATE"))
if ((msdiff = modstate_diff_new()) == NULL) if ((msdiff = modstate_diff_new()) == NULL)
goto done; goto done;
clixon_debug(CLIXON_DBG_CLIENT, "Reading initial config from %s", db); clixon_debug(CLIXON_DBG_BACKEND, "Reading initial config from %s", db);
/* Get the startup datastore WITHOUT binding to YANG, sorting and default setting. /* Get the startup datastore WITHOUT binding to YANG, sorting and default setting.
* It is done below, later in this function * It is done below, later in this function
*/ */
@ -203,7 +203,7 @@ startup_common(clixon_handle h,
if (xmldb_get0(h, db, YB_NONE, NULL, "/", 0, 0, &xt, msdiff, &xerr) < 0) if (xmldb_get0(h, db, YB_NONE, NULL, "/", 0, 0, &xt, msdiff, &xerr) < 0)
goto done; goto done;
} }
clixon_debug_xml(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, xt, "startup"); clixon_debug_xml(CLIXON_DBG_BACKEND | CLIXON_DBG_DETAIL, xt, "startup");
if (msdiff && msdiff->md_status == 0){ // Possibly check for CLICON_XMLDB_MODSTATE if (msdiff && msdiff->md_status == 0){ // Possibly check for CLICON_XMLDB_MODSTATE
clixon_log(h, LOG_WARNING, "Modstate expected in startup datastore but not found\n" clixon_log(h, LOG_WARNING, "Modstate expected in startup datastore but not found\n"
"This may indicate that the datastore is not initialized corrrectly, such as copy/pasted.\n" "This may indicate that the datastore is not initialized corrrectly, such as copy/pasted.\n"
@ -213,7 +213,7 @@ startup_common(clixon_handle h,
clixon_err(OE_YANG, 0, "Yang spec not set"); clixon_err(OE_YANG, 0, "Yang spec not set");
goto done; goto done;
} }
clixon_debug(CLIXON_DBG_CLIENT, "Reading startup config done"); clixon_debug(CLIXON_DBG_BACKEND, "Reading startup config done");
/* Clear flags xpath for get */ /* Clear flags xpath for get */
xml_apply0(xt, CX_ELMNT, (xml_applyfn_t*)xml_flag_reset, xml_apply0(xt, CX_ELMNT, (xml_applyfn_t*)xml_flag_reset,
(void*)(XML_FLAG_MARK|XML_FLAG_CHANGE)); (void*)(XML_FLAG_MARK|XML_FLAG_CHANGE));
@ -302,7 +302,7 @@ startup_common(clixon_handle h,
/* 5. Make generic validation on all new or changed data. /* 5. Make generic validation on all new or changed data.
Note this is only call that uses 3-values */ Note this is only call that uses 3-values */
clixon_debug(CLIXON_DBG_CLIENT, "Validating startup %s", db); clixon_debug(CLIXON_DBG_BACKEND, "Validating startup %s", db);
if ((ret = generic_validate(h, yspec, td, &xret)) < 0) if ((ret = generic_validate(h, yspec, td, &xret)) < 0)
goto done; goto done;
if (ret == 0){ if (ret == 0){
@ -584,7 +584,7 @@ candidate_validate(clixon_handle h,
cxobj *xret = NULL; cxobj *xret = NULL;
int ret; int ret;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_BACKEND, "");
if (db == NULL || cbret == NULL){ if (db == NULL || cbret == NULL){
clixon_err(OE_CFG, EINVAL, "db or cbret is NULL"); clixon_err(OE_CFG, EINVAL, "db or cbret is NULL");
goto done; goto done;
@ -801,14 +801,14 @@ from_client_commit(clixon_handle h,
goto ok; goto ok;
} }
if ((ret = candidate_commit(h, xe, "candidate", myid, 0, cbret)) < 0){ /* Assume validation fail, nofatal */ if ((ret = candidate_commit(h, xe, "candidate", myid, 0, cbret)) < 0){ /* Assume validation fail, nofatal */
clixon_debug(CLIXON_DBG_CLIENT, "Commit candidate failed"); clixon_debug(CLIXON_DBG_BACKEND, "Commit candidate failed");
if (ret < 0) if (ret < 0)
if (netconf_operation_failed(cbret, "application", clixon_err_reason())< 0) if (netconf_operation_failed(cbret, "application", clixon_err_reason())< 0)
goto done; goto done;
goto ok; goto ok;
} }
if (ret == 0) if (ret == 0)
clixon_debug(CLIXON_DBG_CLIENT, "Commit candidate failed"); clixon_debug(CLIXON_DBG_BACKEND, "Commit candidate failed");
else else
cprintf(cbret, "<rpc-reply xmlns=\"%s\"><ok/></rpc-reply>", NETCONF_BASE_NAMESPACE); cprintf(cbret, "<rpc-reply xmlns=\"%s\"><ok/></rpc-reply>", NETCONF_BASE_NAMESPACE);
ok: ok:
@ -892,7 +892,7 @@ from_client_validate(clixon_handle h,
int ret; int ret;
char *db; char *db;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_BACKEND, "");
if ((db = netconf_db_find(xe, "source")) == NULL){ if ((db = netconf_db_find(xe, "source")) == NULL){
if (netconf_missing_element(cbret, "protocol", "source", NULL) < 0) if (netconf_missing_element(cbret, "protocol", "source", NULL) < 0)
goto done; goto done;
@ -938,7 +938,7 @@ from_client_restart_one(clixon_handle h,
if (clixon_resource_check(h, &wh, clixon_plugin_name_get(cp), __FUNCTION__) < 0) if (clixon_resource_check(h, &wh, clixon_plugin_name_get(cp), __FUNCTION__) < 0)
goto done; goto done;
if ((retval = resetfn(h, db)) < 0) { if ((retval = resetfn(h, db)) < 0) {
clixon_debug(CLIXON_DBG_CLIENT, "plugin_start() failed"); clixon_debug(CLIXON_DBG_BACKEND, "plugin_start() failed");
goto done; goto done;
} }
if (clixon_resource_check(h, &wh, clixon_plugin_name_get(cp), __FUNCTION__) < 0) if (clixon_resource_check(h, &wh, clixon_plugin_name_get(cp), __FUNCTION__) < 0)

View file

@ -455,7 +455,7 @@ check_valid_confirming_commit(clixon_handle h,
"not issued on the same session as the confirmed-commit"); "not issued on the same session as the confirmed-commit");
goto invalid; goto invalid;
default: default:
clixon_debug(CLIXON_DBG_CLIENT, "commit-confirmed state !? %d", confirmed_commit_state_get(h)); clixon_debug(CLIXON_DBG_BACKEND, "commit-confirmed state !? %d", confirmed_commit_state_get(h));
goto invalid; goto invalid;
} }
retval = 1; // valid retval = 1; // valid

View file

@ -207,7 +207,7 @@ get_statedata(clixon_handle h,
cbuf *cb = NULL; cbuf *cb = NULL;
cxobj *xerr = NULL; cxobj *xerr = NULL;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_BACKEND, "");
if ((yspec = clicon_dbspec_yang(h)) == NULL){ if ((yspec = clicon_dbspec_yang(h)) == NULL){
clixon_err(OE_YANG, ENOENT, "No yang spec"); clixon_err(OE_YANG, ENOENT, "No yang spec");
goto done; goto done;
@ -312,7 +312,7 @@ get_statedata(clixon_handle h,
goto fail; goto fail;
retval = 1; /* OK */ retval = 1; /* OK */
done: done:
clixon_debug(CLIXON_DBG_CLIENT, "retval:%d", retval); clixon_debug(CLIXON_DBG_BACKEND, "retval:%d", retval);
if (xerr) if (xerr)
xml_free(xerr); xml_free(xerr);
if (x1) if (x1)
@ -709,7 +709,7 @@ get_list_pagination(clixon_handle h,
if ((ret = xml_bind_yang(h, xret, YB_MODULE, yspec, &xerr)) < 0) if ((ret = xml_bind_yang(h, xret, YB_MODULE, yspec, &xerr)) < 0)
goto done; goto done;
if (ret == 0){ if (ret == 0){
clixon_debug_xml(CLIXON_DBG_CLIENT, xret, "Yang bind pagination state"); clixon_debug_xml(CLIXON_DBG_BACKEND, xret, "Yang bind pagination state");
if (clixon_netconf_internal_error(xerr, if (clixon_netconf_internal_error(xerr,
". Internal error, state callback returned invalid XML", ". Internal error, state callback returned invalid XML",
NULL) < 0) NULL) < 0)
@ -812,7 +812,7 @@ get_common(clixon_handle h,
char *wdefstr; char *wdefstr;
wdef = WITHDEFAULTS_EXPLICIT; wdef = WITHDEFAULTS_EXPLICIT;
clixon_debug(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, ""); clixon_debug(CLIXON_DBG_BACKEND | CLIXON_DBG_DETAIL, "");
username = clicon_username_get(h); username = clicon_username_get(h);
if ((yspec = clicon_dbspec_yang(h)) == NULL){ if ((yspec = clicon_dbspec_yang(h)) == NULL){
clixon_err(OE_YANG, ENOENT, "No yang spec9"); clixon_err(OE_YANG, ENOENT, "No yang spec9");
@ -965,7 +965,7 @@ get_common(clixon_handle h,
(ret = xml_yang_validate_add(h, xret, &xerr)) < 0) (ret = xml_yang_validate_add(h, xret, &xerr)) < 0)
goto done; goto done;
if (ret == 0){ if (ret == 0){
clixon_debug_xml(CLIXON_DBG_CLIENT, xret, "VALIDATE_STATE"); clixon_debug_xml(CLIXON_DBG_BACKEND, xret, "VALIDATE_STATE");
if (clixon_netconf_internal_error(xerr, if (clixon_netconf_internal_error(xerr,
". Internal error, state callback returned invalid XML", ". Internal error, state callback returned invalid XML",
NULL) < 0) NULL) < 0)
@ -996,7 +996,7 @@ get_common(clixon_handle h,
ok: ok:
retval = 0; retval = 0;
done: done:
clixon_debug(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, "retval:%d", retval); clixon_debug(CLIXON_DBG_BACKEND | CLIXON_DBG_DETAIL, "retval:%d", retval);
if (xvec) if (xvec)
free(xvec); free(xvec);
if (xret) if (xret)

View file

@ -100,7 +100,7 @@ backend_terminate(clixon_handle h)
int ss; int ss;
cvec *nsctx; cvec *nsctx;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_BACKEND, "");
if ((ss = clicon_socket_get(h)) != -1) if ((ss = clicon_socket_get(h)) != -1)
close(ss); close(ss);
/* Disconnect datastore */ /* Disconnect datastore */
@ -142,7 +142,7 @@ backend_terminate(clixon_handle h)
if (sockfamily==AF_UNIX && lstat(sockpath, &st) == 0) if (sockfamily==AF_UNIX && lstat(sockpath, &st) == 0)
unlink(sockpath); unlink(sockpath);
clixon_event_exit(); clixon_event_exit();
clixon_debug(CLIXON_DBG_CLIENT, "done"); clixon_debug(CLIXON_DBG_BACKEND, "done");
clixon_err_exit(); clixon_err_exit();
clixon_log_exit(); clixon_log_exit();
backend_handle_exit(h); /* Also deletes streams. Cannot use h after this. */ backend_handle_exit(h); /* Also deletes streams. Cannot use h after this. */
@ -172,7 +172,7 @@ backend_sig_term(int arg)
static void static void
backend_sig_child(int arg) backend_sig_child(int arg)
{ {
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_BACKEND, "");
clicon_sig_child_set(1); clicon_sig_child_set(1);
} }
@ -428,7 +428,7 @@ backend_timer_setup(int fd,
struct timeval t; struct timeval t;
struct timeval t1 = {10, 0}; struct timeval t1 = {10, 0};
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_BACKEND, "");
gettimeofday(&now, NULL); gettimeofday(&now, NULL);
backend_client_print(h, stderr); backend_client_print(h, stderr);
@ -463,7 +463,7 @@ usage(clixon_handle h,
"where options are\n" "where options are\n"
"\t-h\t\tHelp\n" "\t-h\t\tHelp\n"
"\t-V \t\tPrint version and exit\n" "\t-V \t\tPrint version and exit\n"
"\t-D <level>\tDebug level\n" "\t-D <level>\tDebug level (see available levels below)\n"
"\t-f <file>\tClixon config file\n" "\t-f <file>\tClixon config file\n"
"\t-E <dir> \tExtra configuration file directory\n" "\t-E <dir> \tExtra configuration file directory\n"
"\t-l <s|e|o|n|f<file>> \tLog on (s)yslog, std(e)rr, std(o)ut, (n)one or (f)ile (syslog is default)\n" "\t-l <s|e|o|n|f<file>> \tLog on (s)yslog, std(e)rr, std(o)ut, (n)one or (f)ile (syslog is default)\n"
@ -491,6 +491,9 @@ usage(clixon_handle h,
confpid ? confpid : "none", confpid ? confpid : "none",
group ? group : "none" group ? group : "none"
); );
fprintf(stderr, "Debug keys: ");
clixon_debug_key_dump(stderr);
fprintf(stderr, "\n");
exit(-1); exit(-1);
} }
@ -569,10 +572,16 @@ main(int argc,
cligen_output(stdout, "Clixon version %s\n", CLIXON_VERSION_STRING); cligen_output(stdout, "Clixon version %s\n", CLIXON_VERSION_STRING);
print_version++; /* plugins may also print versions w ca-version callback */ print_version++; /* plugins may also print versions w ca-version callback */
break; break;
case 'D' : /* debug */ case 'D' : { /* debug */
if (sscanf(optarg, "%d", &dbg) != 1) int d = 0;
/* Try first symbolic, then numeric match */
if ((d = clixon_debug_str2key(optarg)) < 0 &&
sscanf(optarg, "%d", &d) != 1){
usage(h, argv[0]); usage(h, argv[0]);
}
dbg |= d;
break; break;
}
case 'f': /* config file */ case 'f': /* config file */
if (!strlen(optarg)) if (!strlen(optarg))
usage(h, argv[0]); usage(h, argv[0]);

View file

@ -117,7 +117,7 @@ clixon_plugin_reset_all(clixon_handle h,
int retval = -1; int retval = -1;
clixon_plugin_t *cp = NULL; clixon_plugin_t *cp = NULL;
clixon_debug(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, ""); clixon_debug(CLIXON_DBG_BACKEND | CLIXON_DBG_DETAIL, "");
/* Loop through all plugins, call callbacks in each */ /* Loop through all plugins, call callbacks in each */
while ((cp = clixon_plugin_each(h, cp)) != NULL) { while ((cp = clixon_plugin_each(h, cp)) != NULL) {
if (clixon_plugin_reset_one(cp, h, db) < 0) if (clixon_plugin_reset_one(cp, h, db) < 0)
@ -179,7 +179,7 @@ clixon_plugin_pre_daemon_all(clixon_handle h)
int retval = -1; int retval = -1;
clixon_plugin_t *cp = NULL; clixon_plugin_t *cp = NULL;
clixon_debug(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, ""); clixon_debug(CLIXON_DBG_BACKEND | CLIXON_DBG_DETAIL, "");
/* Loop through all plugins, call callbacks in each */ /* Loop through all plugins, call callbacks in each */
while ((cp = clixon_plugin_each(h, cp)) != NULL) { while ((cp = clixon_plugin_each(h, cp)) != NULL) {
if (clixon_plugin_pre_daemon_one(cp, h) < 0) if (clixon_plugin_pre_daemon_one(cp, h) < 0)
@ -242,7 +242,7 @@ clixon_plugin_daemon_all(clixon_handle h)
int retval = -1; int retval = -1;
clixon_plugin_t *cp = NULL; clixon_plugin_t *cp = NULL;
clixon_debug(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, ""); clixon_debug(CLIXON_DBG_BACKEND | CLIXON_DBG_DETAIL, "");
/* Loop through all plugins, call callbacks in each */ /* Loop through all plugins, call callbacks in each */
while ((cp = clixon_plugin_each(h, cp)) != NULL) { while ((cp = clixon_plugin_each(h, cp)) != NULL) {
if (clixon_plugin_daemon_one(cp, h) < 0) if (clixon_plugin_daemon_one(cp, h) < 0)
@ -346,7 +346,7 @@ clixon_plugin_statedata_all(clixon_handle h,
cbuf *cberr = NULL; cbuf *cberr = NULL;
cxobj *xerr = NULL; cxobj *xerr = NULL;
clixon_debug(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, ""); clixon_debug(CLIXON_DBG_BACKEND | CLIXON_DBG_DETAIL, "");
while ((cp = clixon_plugin_each(h, cp)) != NULL) { while ((cp = clixon_plugin_each(h, cp)) != NULL) {
if ((ret = clixon_plugin_statedata_one(cp, h, nsc, xpath, &x)) < 0) if ((ret = clixon_plugin_statedata_one(cp, h, nsc, xpath, &x)) < 0)
goto done; goto done;
@ -372,7 +372,7 @@ clixon_plugin_statedata_all(clixon_handle h,
x = NULL; x = NULL;
continue; continue;
} }
clixon_debug_xml(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, x, "%s STATE:", clixon_plugin_name_get(cp)); clixon_debug_xml(CLIXON_DBG_BACKEND | CLIXON_DBG_DETAIL, x, "%s STATE:", clixon_plugin_name_get(cp));
/* XXX: ret == 0 invalid yang binding should be handled as internal error */ /* XXX: ret == 0 invalid yang binding should be handled as internal error */
if ((ret = xml_bind_yang(h, x, YB_MODULE, yspec, &xerr)) < 0) if ((ret = xml_bind_yang(h, x, YB_MODULE, yspec, &xerr)) < 0)
goto done; goto done;
@ -472,7 +472,7 @@ clixon_plugin_lockdb_all(clixon_handle h,
int retval = -1; int retval = -1;
clixon_plugin_t *cp = NULL; clixon_plugin_t *cp = NULL;
clixon_debug(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, ""); clixon_debug(CLIXON_DBG_BACKEND | CLIXON_DBG_DETAIL, "");
while ((cp = clixon_plugin_each(h, cp)) != NULL) { while ((cp = clixon_plugin_each(h, cp)) != NULL) {
if (clixon_plugin_lockdb_one(cp, h, db, lock, id) < 0) if (clixon_plugin_lockdb_one(cp, h, db, lock, id) < 0)
goto done; goto done;
@ -656,7 +656,7 @@ plugin_transaction_begin_all(clixon_handle h,
int retval = -1; int retval = -1;
clixon_plugin_t *cp = NULL; clixon_plugin_t *cp = NULL;
clixon_debug(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, ""); clixon_debug(CLIXON_DBG_BACKEND | CLIXON_DBG_DETAIL, "");
while ((cp = clixon_plugin_each(h, cp)) != NULL) { while ((cp = clixon_plugin_each(h, cp)) != NULL) {
if (plugin_transaction_begin_one(cp, h, td) < 0) if (plugin_transaction_begin_one(cp, h, td) < 0)
goto done; goto done;
@ -1002,7 +1002,7 @@ plugin_transaction_end_all(clixon_handle h,
int retval = -1; int retval = -1;
clixon_plugin_t *cp = NULL; clixon_plugin_t *cp = NULL;
clixon_debug(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, ""); clixon_debug(CLIXON_DBG_BACKEND | CLIXON_DBG_DETAIL, "");
while ((cp = clixon_plugin_each(h, cp)) != NULL) { while ((cp = clixon_plugin_each(h, cp)) != NULL) {
if (plugin_transaction_end_one(cp, h, td) < 0) if (plugin_transaction_end_one(cp, h, td) < 0)
goto done; goto done;
@ -1055,7 +1055,7 @@ plugin_transaction_abort_all(clixon_handle h,
int retval = -1; int retval = -1;
clixon_plugin_t *cp = NULL; clixon_plugin_t *cp = NULL;
clixon_debug(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, ""); clixon_debug(CLIXON_DBG_BACKEND | CLIXON_DBG_DETAIL, "");
while ((cp = clixon_plugin_each(h, cp)) != NULL) { while ((cp = clixon_plugin_each(h, cp)) != NULL) {
if (plugin_transaction_abort_one(cp, h, td) < 0) if (plugin_transaction_abort_one(cp, h, td) < 0)
; /* dont abort on error */ ; /* dont abort on error */

View file

@ -154,7 +154,7 @@ restconf_pseudo_set_inline(clixon_handle h,
cxobj *xrestconf; cxobj *xrestconf;
cbuf *cb = NULL; cbuf *cb = NULL;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_BACKEND, "");
if (clixon_process_argv_get(h, RESTCONF_PROCESS, &argv, &argc) < 0) if (clixon_process_argv_get(h, RESTCONF_PROCESS, &argv, &argc) < 0)
goto done; goto done;
if ((xrestconf = xpath_first(xt, NULL, "restconf")) != NULL) if ((xrestconf = xpath_first(xt, NULL, "restconf")) != NULL)
@ -174,7 +174,7 @@ restconf_pseudo_set_inline(clixon_handle h,
clixon_err(OE_XML, errno, "stdup"); clixon_err(OE_XML, errno, "stdup");
goto done; goto done;
} }
clixon_debug(CLIXON_DBG_CLIENT, "str:%s", str); clixon_debug(CLIXON_DBG_BACKEND, "str:%s", str);
if (argv[i+1]) if (argv[i+1])
free(argv[i+1]); free(argv[i+1]);
argv[i+1] = str; argv[i+1] = str;
@ -203,7 +203,7 @@ restconf_rpc_wrapper(clixon_handle h,
int retval = -1; int retval = -1;
cxobj *xt = NULL; cxobj *xt = NULL;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_BACKEND, "");
switch (*operation){ switch (*operation){
case PROC_OP_STOP: case PROC_OP_STOP:
/* if RPC op is stop, stop the service */ /* if RPC op is stop, stop the service */
@ -283,24 +283,24 @@ restconf_pseudo_process_control(clixon_handle h)
cprintf(cb, "%s/clixon_restconf", dir0); cprintf(cb, "%s/clixon_restconf", dir0);
pgm = cbuf_get(cb); pgm = cbuf_get(cb);
if (stat(pgm, &fstat) == 0){ /* Sanity check: program exists */ if (stat(pgm, &fstat) == 0){ /* Sanity check: program exists */
clixon_debug(CLIXON_DBG_CLIENT, "Found %s", pgm); clixon_debug(CLIXON_DBG_BACKEND, "Found %s", pgm);
found++; found++;
} }
else else
clixon_debug(CLIXON_DBG_CLIENT, "Not found: %s", pgm); clixon_debug(CLIXON_DBG_BACKEND, "Not found: %s", pgm);
} }
if (!found && if (!found &&
(dir1 = CLIXON_CONFIG_SBINDIR) != NULL){ (dir1 = CLIXON_CONFIG_SBINDIR) != NULL){
cbuf_reset(cb); cbuf_reset(cb);
cprintf(cb, "%s/clixon_restconf", dir1); cprintf(cb, "%s/clixon_restconf", dir1);
pgm = cbuf_get(cb); pgm = cbuf_get(cb);
clixon_debug(CLIXON_DBG_CLIENT, "Looking for %s", pgm); clixon_debug(CLIXON_DBG_BACKEND, "Looking for %s", pgm);
if (stat(pgm, &fstat) == 0){ /* Sanity check: program exists */ if (stat(pgm, &fstat) == 0){ /* Sanity check: program exists */
clixon_debug(CLIXON_DBG_CLIENT, "Found %s", pgm); clixon_debug(CLIXON_DBG_BACKEND, "Found %s", pgm);
found++; found++;
} }
else else
clixon_debug(CLIXON_DBG_CLIENT, "Not found: %s", pgm); clixon_debug(CLIXON_DBG_BACKEND, "Not found: %s", pgm);
} }
if (!found){ if (!found){
clixon_err(OE_RESTCONF, 0, "clixon_restconf not found in neither CLICON_RESTCONF_INSTALLDIR(%s) nor CLIXON_CONFIG_SBINDIR(%s). Try overriding with CLICON_RESTCONF_INSTALLDIR", clixon_err(OE_RESTCONF, 0, "clixon_restconf not found in neither CLICON_RESTCONF_INSTALLDIR(%s) nor CLIXON_CONFIG_SBINDIR(%s). Try overriding with CLICON_RESTCONF_INSTALLDIR",
@ -349,7 +349,7 @@ restconf_pseudo_process_validate(clixon_handle h,
int retval = -1; int retval = -1;
cxobj *xtarget; cxobj *xtarget;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_BACKEND, "");
xtarget = transaction_target(td); xtarget = transaction_target(td);
/* If ssl-enable is true and (at least a) socket has ssl, /* If ssl-enable is true and (at least a) socket has ssl,
* then server-cert-path and server-key-path must exist */ * then server-cert-path and server-key-path must exist */
@ -381,7 +381,7 @@ restconf_pseudo_process_commit(clixon_handle h,
cxobj *cx; cxobj *cx;
int enabled = 0; int enabled = 0;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_BACKEND, "");
xtarget = transaction_target(td); xtarget = transaction_target(td);
xsource = transaction_src(td); xsource = transaction_src(td);
if (xpath_first(xtarget, NULL, "/restconf[enable='true']") != NULL) if (xpath_first(xtarget, NULL, "/restconf[enable='true']") != NULL)

View file

@ -111,7 +111,7 @@ config_socket_init_ipv4(clixon_handle h,
clixon_err(OE_UNIX, errno, "bind"); clixon_err(OE_UNIX, errno, "bind");
goto err; goto err;
} }
clixon_debug(CLIXON_DBG_CLIENT, "Listen on server socket at %s:%hu", dst, port); clixon_debug(CLIXON_DBG_BACKEND, "Listen on server socket at %s:%hu", dst, port);
if (listen(s, 5) < 0){ if (listen(s, 5) < 0){
clixon_err(OE_UNIX, errno, "listen"); clixon_err(OE_UNIX, errno, "listen");
goto err; goto err;
@ -178,7 +178,7 @@ config_socket_init_unix(clixon_handle h,
clixon_err(OE_UNIX, errno, "lchown(%s, %s)", sock, config_group); clixon_err(OE_UNIX, errno, "lchown(%s, %s)", sock, config_group);
goto err; goto err;
} }
clixon_debug(CLIXON_DBG_CLIENT, "Listen on server socket at %s", addr.sun_path); clixon_debug(CLIXON_DBG_BACKEND, "Listen on server socket at %s", addr.sun_path);
if (listen(s, 5) < 0){ if (listen(s, 5) < 0){
clixon_err(OE_UNIX, errno, "listen"); clixon_err(OE_UNIX, errno, "listen");
goto err; goto err;
@ -245,7 +245,7 @@ backend_accept_client(int fd,
uid_t guid; uid_t guid;
#endif #endif
clixon_debug(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, ""); clixon_debug(CLIXON_DBG_BACKEND | CLIXON_DBG_DETAIL, "");
len = sizeof(from); len = sizeof(from);
if ((s = accept(fd, &from, &len)) < 0){ if ((s = accept(fd, &from, &len)) < 0){
clixon_err(OE_UNIX, errno, "accept"); clixon_err(OE_UNIX, errno, "accept");

View file

@ -137,7 +137,7 @@ cli_auto_edit(clixon_handle h,
str = cv_string_get(cvec_i(argv, argc++)); str = cv_string_get(cvec_i(argv, argc++));
if (str && strncmp(str, "mtpoint:", strlen("mtpoint:")) == 0){ if (str && strncmp(str, "mtpoint:", strlen("mtpoint:")) == 0){
mtpoint = str + strlen("mtpoint:"); mtpoint = str + strlen("mtpoint:");
clixon_debug(CLIXON_DBG_CLIENT, "mtpoint:%s", mtpoint); clixon_debug(CLIXON_DBG_CLI, "mtpoint:%s", mtpoint);
treename = cv_string_get(cvec_i(argv, argc++)); treename = cv_string_get(cvec_i(argv, argc++));
} }
else else

View file

@ -884,7 +884,7 @@ cli_commit(clixon_handle h,
cancel = (cvec_find_str(cvv, "cancel") != NULL); cancel = (cvec_find_str(cvv, "cancel") != NULL);
if ((timeout_var = cvec_find(cvv, "timeout")) != NULL) { if ((timeout_var = cvec_find(cvv, "timeout")) != NULL) {
timeout = cv_uint32_get(timeout_var); timeout = cv_uint32_get(timeout_var);
clixon_debug(CLIXON_DBG_CLIENT, "commit confirmed with timeout %ul", timeout); clixon_debug(CLIXON_DBG_CLI, "commit confirmed with timeout %ul", timeout);
} }
persist = cvec_find_str(cvv, "persist-val"); persist = cvec_find_str(cvv, "persist-val");
persist_id = cvec_find_str(cvv, "persist-id-val"); persist_id = cvec_find_str(cvv, "persist-id-val");

View file

@ -1266,11 +1266,11 @@ yang2cli_stmt(clixon_handle h,
goto done; goto done;
} }
if (yang_find(ys, Y_STATUS, "obsolete") != NULL){ if (yang_find(ys, Y_STATUS, "obsolete") != NULL){
clixon_debug(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, "obsolete: %s %s, skipped", yang_argument_get(ys), yang_argument_get(ys_module(ys))); clixon_debug(CLIXON_DBG_CLI | CLIXON_DBG_DETAIL, "obsolete: %s %s, skipped", yang_argument_get(ys), yang_argument_get(ys_module(ys)));
goto ok; goto ok;
} }
if (yang_find(ys, Y_STATUS, "deprecated") != NULL){ if (yang_find(ys, Y_STATUS, "deprecated") != NULL){
clixon_debug(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, "deprecated: %s %s", yang_argument_get(ys), yang_argument_get(ys_module(ys))); clixon_debug(CLIXON_DBG_CLI | CLIXON_DBG_DETAIL, "deprecated: %s %s", yang_argument_get(ys), yang_argument_get(ys_module(ys)));
} }
/* Check if autocli skip */ /* Check if autocli skip */
if (yang_extension_value(ys, "skip", CLIXON_AUTOCLI_NS, &extvalue, NULL) < 0) if (yang_extension_value(ys, "skip", CLIXON_AUTOCLI_NS, &extvalue, NULL) < 0)
@ -1543,11 +1543,11 @@ yang2cli_grouping(clixon_handle h,
} }
/* Traverse YANG, loop through all modules and generate CLI, inline of yang2cli_stmt */ /* Traverse YANG, loop through all modules and generate CLI, inline of yang2cli_stmt */
if (yang_find(ys, Y_STATUS, "obsolete") != NULL){ if (yang_find(ys, Y_STATUS, "obsolete") != NULL){
clixon_debug(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, "obsolete: %s %s, skipped", yang_argument_get(ys), yang_argument_get(ys_module(ys))); clixon_debug(CLIXON_DBG_CLI | CLIXON_DBG_DETAIL, "obsolete: %s %s, skipped", yang_argument_get(ys), yang_argument_get(ys_module(ys)));
goto empty; goto empty;
} }
if (yang_find(ys, Y_STATUS, "deprecated") != NULL){ if (yang_find(ys, Y_STATUS, "deprecated") != NULL){
clixon_debug(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, "deprecated: %s %s", yang_argument_get(ys), yang_argument_get(ys_module(ys))); clixon_debug(CLIXON_DBG_CLI | CLIXON_DBG_DETAIL, "deprecated: %s %s", yang_argument_get(ys), yang_argument_get(ys_module(ys)));
} }
/* Only produce autocli for YANG non-config only if autocli-treeref-state is true */ /* Only produce autocli for YANG non-config only if autocli-treeref-state is true */
if (autocli_treeref_state(h, &treeref_state) < 0) if (autocli_treeref_state(h, &treeref_state) < 0)
@ -1576,12 +1576,12 @@ yang2cli_grouping(clixon_handle h,
fprintf(stderr, "%s\n", cbuf_get(cb)); fprintf(stderr, "%s\n", cbuf_get(cb));
goto done; goto done;
} }
clixon_debug(CLIXON_DBG_CLIENT, "Generated auto-cli for grouping:%s", clixon_debug(CLIXON_DBG_CLI, "Generated auto-cli for grouping:%s",
yang_argument_get(ys)); yang_argument_get(ys));
/* Add prefix: assume new are appended */ /* Add prefix: assume new are appended */
for (i=0; i<pt_len_get(pt); i++){ for (i=0; i<pt_len_get(pt); i++){
if ((co = pt_vec_i_get(pt, i)) != NULL){ if ((co = pt_vec_i_get(pt, i)) != NULL){
clixon_debug(CLIXON_DBG_CLIENT, "command: %s", clixon_debug(CLIXON_DBG_CLI, "command: %s",
co->co_command); co->co_command);
co_prefix_set(co, prefix); co_prefix_set(co, prefix);
} }
@ -1599,7 +1599,7 @@ yang2cli_grouping(clixon_handle h,
clixon_log(h, LOG_NOTICE, "%s: Top-level cli-spec %s:\n%s", clixon_log(h, LOG_NOTICE, "%s: Top-level cli-spec %s:\n%s",
__FUNCTION__, treename, cbuf_get(cb)); __FUNCTION__, treename, cbuf_get(cb));
else else
clixon_debug(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, "Top-level cli-spec %s:\n%s", clixon_debug(CLIXON_DBG_CLI | CLIXON_DBG_DETAIL, "Top-level cli-spec %s:\n%s",
treename, cbuf_get(cb)); treename, cbuf_get(cb));
if (cligen_parsetree_merge(pt0, NULL, pt) < 0){ if (cligen_parsetree_merge(pt0, NULL, pt) < 0){
clixon_err(OE_YANG, errno, "cligen_parsetree_merge"); clixon_err(OE_YANG, errno, "cligen_parsetree_merge");
@ -1706,12 +1706,12 @@ yang2cli_yspec(clixon_handle h,
fprintf(stderr, "%s\n", cbuf_get(cb)); fprintf(stderr, "%s\n", cbuf_get(cb));
goto done; goto done;
} }
clixon_debug(CLIXON_DBG_CLIENT, "Generated auto-cli for module:%s", clixon_debug(CLIXON_DBG_CLI, "Generated auto-cli for module:%s",
yang_argument_get(ymod)); yang_argument_get(ymod));
/* Add prefix: assume new are appended */ /* Add prefix: assume new are appended */
for (i=0; i<pt_len_get(pt); i++){ for (i=0; i<pt_len_get(pt); i++){
if ((co = pt_vec_i_get(pt, i)) != NULL){ if ((co = pt_vec_i_get(pt, i)) != NULL){
clixon_debug(CLIXON_DBG_CLIENT, "command: %s", clixon_debug(CLIXON_DBG_CLI, "command: %s",
co->co_command); co->co_command);
co_prefix_set(co, prefix); co_prefix_set(co, prefix);
} }
@ -1730,7 +1730,7 @@ yang2cli_yspec(clixon_handle h,
clixon_log(h, LOG_NOTICE, "%s: Top-level cli-spec %s:\n%s", clixon_log(h, LOG_NOTICE, "%s: Top-level cli-spec %s:\n%s",
__FUNCTION__, treename, cbuf_get(cb)); __FUNCTION__, treename, cbuf_get(cb));
else else
clixon_debug(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, "Top-level cli-spec %s:\n%s", clixon_debug(CLIXON_DBG_CLI | CLIXON_DBG_DETAIL, "Top-level cli-spec %s:\n%s",
treename, cbuf_get(cb)); treename, cbuf_get(cb));
if (cligen_parsetree_merge(pt0, NULL, pt) < 0){ if (cligen_parsetree_merge(pt0, NULL, pt) < 0){
clixon_err(OE_YANG, errno, "cligen_parsetree_merge"); clixon_err(OE_YANG, errno, "cligen_parsetree_merge");

View file

@ -391,7 +391,7 @@ autocli_start(clixon_handle h)
yang_stmt *yspec; yang_stmt *yspec;
int enable = 0; int enable = 0;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_CLI, "");
/* There is no single "enable-autocli" flag, /* There is no single "enable-autocli" flag,
* but set * but set
* <module-default>false</module-default> * <module-default>false</module-default>
@ -402,7 +402,7 @@ autocli_start(clixon_handle h)
if (autocli_module(h, NULL, &enable) < 0) if (autocli_module(h, NULL, &enable) < 0)
goto done; goto done;
if (!enable){ if (!enable){
clixon_debug(CLIXON_DBG_CLIENT, "Autocli not enabled (clixon-autocli)"); clixon_debug(CLIXON_DBG_CLI, "Autocli not enabled (clixon-autocli)");
goto ok; goto ok;
} }
/* Init yang2cli */ /* Init yang2cli */
@ -481,7 +481,7 @@ usage(clixon_handle h,
"where options are\n" "where options are\n"
"\t-h \t\tHelp\n" "\t-h \t\tHelp\n"
"\t-V \t\tPrint version and exit\n" "\t-V \t\tPrint version and exit\n"
"\t-D <level> \tDebug level\n" "\t-D <level> \tDebug level (see available levels below)\n"
"\t-f <file> \tConfig-file (mandatory)\n" "\t-f <file> \tConfig-file (mandatory)\n"
"\t-E <dir> \tExtra configuration file directory\n" "\t-E <dir> \tExtra configuration file directory\n"
"\t-l <s|e|o|n|f<file>> \tLog on (s)yslog, std(e)rr, std(o)ut, (n)one or (f)ile (stderr is default)\n" "\t-l <s|e|o|n|f<file>> \tLog on (s)yslog, std(e)rr, std(o)ut, (n)one or (f)ile (stderr is default)\n"
@ -496,7 +496,6 @@ usage(clixon_handle h,
"\t-p <dir>\tYang directory path (see CLICON_YANG_DIR)\n" "\t-p <dir>\tYang directory path (see CLICON_YANG_DIR)\n"
"\t-G \t\tPrint auto-cli CLI syntax generated from YANG\n" "\t-G \t\tPrint auto-cli CLI syntax generated from YANG\n"
"\t-L \t\tDebug print dynamic CLI syntax including completions and expansions\n" "\t-L \t\tDebug print dynamic CLI syntax including completions and expansions\n"
"\t-y <file>\tOverride yang spec file (dont include .yang suffix)\n" "\t-y <file>\tOverride yang spec file (dont include .yang suffix)\n"
"\t-c <file>\tSpecify cli spec file.\n" "\t-c <file>\tSpecify cli spec file.\n"
"\t-U <user>\tOver-ride unix user with a pseudo user for NACM.\n" "\t-U <user>\tOver-ride unix user with a pseudo user for NACM.\n"
@ -504,6 +503,9 @@ usage(clixon_handle h,
argv0, argv0,
plgdir ? plgdir : "none" plgdir ? plgdir : "none"
); );
fprintf(stderr, "Debug keys: ");
clixon_debug_key_dump(stderr);
fprintf(stderr, "\n");
exit(1); exit(1);
} }
@ -581,10 +583,16 @@ main(int argc,
cligen_output(stdout, "Clixon version %s\n", CLIXON_VERSION_STRING); cligen_output(stdout, "Clixon version %s\n", CLIXON_VERSION_STRING);
print_version++; /* plugins may also print versions w ca-version callback */ print_version++; /* plugins may also print versions w ca-version callback */
break; break;
case 'D' : /* debug */ case 'D' : { /* debug */
if (sscanf(optarg, "%d", &dbg) != 1) int d = 0;
/* Try first symbolic, then numeric match */
if ((d = clixon_debug_str2key(optarg)) < 0 &&
sscanf(optarg, "%d", &d) != 1){
usage(h, argv[0]); usage(h, argv[0]);
}
dbg |= d;
break; break;
}
case 'f': /* config file */ case 'f': /* config file */
if (!strlen(optarg)) if (!strlen(optarg))
usage(h, argv[0]); usage(h, argv[0]);

View file

@ -417,7 +417,7 @@ clispec_load(clixon_handle h)
goto done; goto done;
/* Load the syntax parse trees into cli_syntax stx structure */ /* Load the syntax parse trees into cli_syntax stx structure */
for (i = 0; i < ndp; i++) { for (i = 0; i < ndp; i++) {
clixon_debug(CLIXON_DBG_CLIENT, "Loading clispec syntax: '%s/%s'", clixon_debug(CLIXON_DBG_CLI, "Loading clispec syntax: '%s/%s'",
clispec_dir, dp[i].d_name); clispec_dir, dp[i].d_name);
if (clispec_load_file(h, dp[i].d_name, clispec_dir, ptall, modes) < 0) if (clispec_load_file(h, dp[i].d_name, clispec_dir, ptall, modes) < 0)
goto done; goto done;
@ -555,7 +555,7 @@ clicon_parse(clixon_handle h,
if (cliread_parse(ch, cmd, pt, &match_obj, &cvv, result, &reason) < 0) if (cliread_parse(ch, cmd, pt, &match_obj, &cvv, result, &reason) < 0)
goto done; goto done;
/* Debug command and result code */ /* Debug command and result code */
clixon_debug(CLIXON_DBG_CLIENT, "result:%d command: \"%s\"", *result, cmd); clixon_debug(CLIXON_DBG_CLI, "result:%d command: \"%s\"", *result, cmd);
switch (*result) { switch (*result) {
case CG_EOF: /* eof */ case CG_EOF: /* eof */
case CG_ERROR: case CG_ERROR:

View file

@ -159,7 +159,7 @@ netconf_hello_msg(clixon_handle h,
int foundbase_11 = 0; int foundbase_11 = 0;
char *body; char *body;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_NETCONF, "");
_netconf_hello_nr++; _netconf_hello_nr++;
if (xml_find_type(xn, NULL, "session-id", CX_ELMNT) != NULL) { if (xml_find_type(xn, NULL, "session-id", CX_ELMNT) != NULL) {
clixon_err(OE_XML, errno, "Server received hello with session-id from client, terminating (see RFC 6241 Sec 8.1"); clixon_err(OE_XML, errno, "Server received hello with session-id from client, terminating (see RFC 6241 Sec 8.1");
@ -179,12 +179,12 @@ netconf_hello_msg(clixon_handle h,
* event any parameters are encoded at the end of the URI string. */ * event any parameters are encoded at the end of the URI string. */
if (strncmp(body, NETCONF_BASE_CAPABILITY_1_0, strlen(NETCONF_BASE_CAPABILITY_1_0)) == 0){ /* RFC 4741 */ if (strncmp(body, NETCONF_BASE_CAPABILITY_1_0, strlen(NETCONF_BASE_CAPABILITY_1_0)) == 0){ /* RFC 4741 */
foundbase_10++; foundbase_10++;
clixon_debug(CLIXON_DBG_CLIENT, "foundbase10"); clixon_debug(CLIXON_DBG_NETCONF, "foundbase10");
} }
else if (strncmp(body, NETCONF_BASE_CAPABILITY_1_1, strlen(NETCONF_BASE_CAPABILITY_1_1)) == 0 && else if (strncmp(body, NETCONF_BASE_CAPABILITY_1_1, strlen(NETCONF_BASE_CAPABILITY_1_1)) == 0 &&
clicon_option_int(h, "CLICON_NETCONF_BASE_CAPABILITY") > 0){ /* RFC 6241 */ clicon_option_int(h, "CLICON_NETCONF_BASE_CAPABILITY") > 0){ /* RFC 6241 */
foundbase_11++; foundbase_11++;
clixon_debug(CLIXON_DBG_CLIENT, "foundbase11"); clixon_debug(CLIXON_DBG_NETCONF, "foundbase11");
clicon_data_int_set(h, NETCONF_FRAMING_TYPE, NETCONF_SSH_CHUNKED); /* enable chunked enc */ clicon_data_int_set(h, NETCONF_FRAMING_TYPE, NETCONF_SSH_CHUNKED); /* enable chunked enc */
} }
} }
@ -334,8 +334,8 @@ netconf_input_packet(clixon_handle h,
cxobj *xret = NULL; cxobj *xret = NULL;
netconf_framing_type framing; netconf_framing_type framing;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_NETCONF, "");
clixon_debug_xml(CLIXON_DBG_CLIENT, xreq, ""); clixon_debug_xml(CLIXON_DBG_NETCONF, xreq, "");
rpcname = xml_name(xreq); rpcname = xml_name(xreq);
rpcprefix = xml_prefix(xreq); rpcprefix = xml_prefix(xreq);
framing = clicon_data_int_get(h, NETCONF_FRAMING_TYPE); framing = clicon_data_int_get(h, NETCONF_FRAMING_TYPE);
@ -469,7 +469,7 @@ netconf_input_cb(int s,
&eom) < 0) &eom) < 0)
goto done; goto done;
if (eom == 0){ /* frame not complete */ if (eom == 0){ /* frame not complete */
clixon_debug(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, "frame: %lu", cbuf_len(cbmsg)); clixon_debug(CLIXON_DBG_NETCONF | CLIXON_DBG_DETAIL, "frame: %lu", cbuf_len(cbmsg));
/* Extra data to read, save data and continue on next round */ /* Extra data to read, save data and continue on next round */
if (clicon_hash_add(cdat, NETCONF_FRAME_MSG, &cbmsg, sizeof(cbmsg)) == NULL) if (clicon_hash_add(cdat, NETCONF_FRAME_MSG, &cbmsg, sizeof(cbmsg)) == NULL)
goto done; goto done;
@ -511,7 +511,7 @@ netconf_input_cb(int s,
} }
} }
if (eof){ /* socket closed / read returns 0 */ if (eof){ /* socket closed / read returns 0 */
clixon_debug(CLIXON_DBG_CLIENT, "len==0, closing"); clixon_debug(CLIXON_DBG_NETCONF, "len==0, closing");
clixon_event_unreg_fd(s, netconf_input_cb); clixon_event_unreg_fd(s, netconf_input_cb);
close(s); close(s);
clixon_exit_set(1); clixon_exit_set(1);
@ -637,7 +637,7 @@ usage(clixon_handle h,
"where options are\n" "where options are\n"
"\t-h\t\tHelp\n" "\t-h\t\tHelp\n"
"\t-V \t\tPrint version and exit\n" "\t-V \t\tPrint version and exit\n"
"\t-D <level>\tDebug level\n" "\t-D <level>\tDebug level (see available levels below)\n"
"\t-f <file>\tConfiguration file (mandatory)\n" "\t-f <file>\tConfiguration file (mandatory)\n"
"\t-E <dir> \tExtra configuration file directory\n" "\t-E <dir> \tExtra configuration file directory\n"
"\t-l <s|e|o|n|f<file>> \tLog on (s)yslog, std(e)rr, std(o)ut, (n)one or (f)ile (syslog is default)\n" "\t-l <s|e|o|n|f<file>> \tLog on (s)yslog, std(e)rr, std(o)ut, (n)one or (f)ile (syslog is default)\n"
@ -657,6 +657,9 @@ usage(clixon_handle h,
argv0, argv0,
clicon_netconf_dir(h) clicon_netconf_dir(h)
); );
fprintf(stderr, "Debug keys: ");
clixon_debug_key_dump(stderr);
fprintf(stderr, "\n");
exit(0); exit(0);
} }
@ -709,10 +712,16 @@ main(int argc,
cligen_output(stdout, "Clixon version %s\n", CLIXON_VERSION_STRING); cligen_output(stdout, "Clixon version %s\n", CLIXON_VERSION_STRING);
print_version++; /* plugins may also print versions w ca-version callback */ print_version++; /* plugins may also print versions w ca-version callback */
break; break;
case 'D' : /* debug */ case 'D' : { /* debug */
if (sscanf(optarg, "%d", &dbg) != 1) int d = 0;
/* Try first symbolic, then numeric match */
if ((d = clixon_debug_str2key(optarg)) < 0 &&
sscanf(optarg, "%d", &d) != 1){
usage(h, argv[0]); usage(h, argv[0]);
}
dbg |= d;
break; break;
}
case 'f': /* override config file */ case 'f': /* override config file */
if (!strlen(optarg)) if (!strlen(optarg))
usage(h, argv[0]); usage(h, argv[0]);

View file

@ -459,7 +459,7 @@ netconf_notification_cb(int s,
int ret; int ret;
cxobj *xerr = NULL; cxobj *xerr = NULL;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_NETCONF, "");
/* get msg (this is the reason this function is called) */ /* get msg (this is the reason this function is called) */
if (clicon_msg_rcv(s, NULL, 0, &reply, &eof) < 0) if (clicon_msg_rcv(s, NULL, 0, &reply, &eof) < 0)
goto done; goto done;
@ -504,7 +504,7 @@ netconf_notification_cb(int s,
ok: ok:
retval = 0; retval = 0;
done: done:
clixon_debug(CLIXON_DBG_CLIENT, "retval:%d", retval); clixon_debug(CLIXON_DBG_NETCONF, "retval:%d", retval);
if (cb) if (cb)
cbuf_free(cb); cbuf_free(cb);
if (nsc) if (nsc)

View file

@ -131,7 +131,7 @@ api_http_data_err(clixon_handle h,
int retval = -1; int retval = -1;
cbuf *cb = NULL; cbuf *cb = NULL;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_RESTCONF, "");
if ((cb = cbuf_new()) == NULL){ if ((cb = cbuf_new()) == NULL){
clixon_err(OE_UNIX, errno, "cbuf_new"); clixon_err(OE_UNIX, errno, "cbuf_new");
goto done; goto done;
@ -153,7 +153,7 @@ api_http_data_err(clixon_handle h,
// ok: // ok:
retval = 0; retval = 0;
done: done:
clixon_debug(CLIXON_DBG_CLIENT, "retval:%d", retval); clixon_debug(CLIXON_DBG_RESTCONF, "retval:%d", retval);
if (cb) if (cb)
cbuf_free(cb); cbuf_free(cb);
return retval; return retval;
@ -192,7 +192,7 @@ http_data_check_file_path(clixon_handle h,
goto done; goto done;
} }
p = cbuf_get(cbpath); p = cbuf_get(cbpath);
clixon_debug(CLIXON_DBG_CLIENT, "%s", p); clixon_debug(CLIXON_DBG_RESTCONF, "%s", p);
if (strncmp(prefix, p, strlen(prefix)) != 0){ if (strncmp(prefix, p, strlen(prefix)) != 0){
clixon_err(OE_UNIX, EINVAL, "prefix is not prefix of cbpath"); clixon_err(OE_UNIX, EINVAL, "prefix is not prefix of cbpath");
goto done; goto done;
@ -202,31 +202,31 @@ http_data_check_file_path(clixon_handle h,
p[i] = '\0'; p[i] = '\0';
/* Ensure not soft link */ /* Ensure not soft link */
if (lstat(p, &fstat) < 0){ if (lstat(p, &fstat) < 0){
clixon_debug(CLIXON_DBG_CLIENT, "Error lstat(%s):%s", p, strerror(errno)); clixon_debug(CLIXON_DBG_RESTCONF, "Error lstat(%s):%s", p, strerror(errno));
code = 404; code = 404;
goto invalid; goto invalid;
} }
if (!S_ISDIR(fstat.st_mode)){ if (!S_ISDIR(fstat.st_mode)){
clixon_debug(CLIXON_DBG_CLIENT, "Error lstat(%s): Not dir", p); clixon_debug(CLIXON_DBG_RESTCONF, "Error lstat(%s): Not dir", p);
code = 403; code = 403;
goto invalid; goto invalid;
} }
p[i] = '/'; p[i] = '/';
} }
else if (p[i] == '~'){ else if (p[i] == '~'){
clixon_debug(CLIXON_DBG_CLIENT, "Error lstat(%s): ~ not allowed in file path", p); clixon_debug(CLIXON_DBG_RESTCONF, "Error lstat(%s): ~ not allowed in file path", p);
code = 403; code = 403;
goto invalid; goto invalid;
} }
else if (p[i] == '.' && i>strlen(prefix) && p[i-1] == '.'){ else if (p[i] == '.' && i>strlen(prefix) && p[i-1] == '.'){
clixon_debug(CLIXON_DBG_CLIENT, "Error lstat(%s): .. not allowed in file path", p); clixon_debug(CLIXON_DBG_RESTCONF, "Error lstat(%s): .. not allowed in file path", p);
code = 403; code = 403;
goto invalid; goto invalid;
} }
} }
/* Resulting file (ensure not soft link) */ /* Resulting file (ensure not soft link) */
if (lstat(p, &fstat) < 0){ if (lstat(p, &fstat) < 0){
clixon_debug(CLIXON_DBG_CLIENT, "Error lstat(%s):%s", p, strerror(errno)); clixon_debug(CLIXON_DBG_RESTCONF, "Error lstat(%s):%s", p, strerror(errno));
code = 404; code = 404;
goto invalid; goto invalid;
} }
@ -235,22 +235,22 @@ http_data_check_file_path(clixon_handle h,
if (S_ISDIR(fstat.st_mode)){ if (S_ISDIR(fstat.st_mode)){
cprintf(cbpath, "/%s", HTTP_DATA_INTERNAL_REDIRECT); cprintf(cbpath, "/%s", HTTP_DATA_INTERNAL_REDIRECT);
p = cbuf_get(cbpath); p = cbuf_get(cbpath);
clixon_debug(CLIXON_DBG_CLIENT, "internal redirect: %s", p); clixon_debug(CLIXON_DBG_RESTCONF, "internal redirect: %s", p);
if (lstat(p, &fstat) < 0){ if (lstat(p, &fstat) < 0){
clixon_debug(CLIXON_DBG_CLIENT, "Error lstat(%s):%s", p, strerror(errno)); clixon_debug(CLIXON_DBG_RESTCONF, "Error lstat(%s):%s", p, strerror(errno));
code = 404; code = 404;
goto invalid; goto invalid;
} }
} }
#endif #endif
if (!S_ISREG(fstat.st_mode)){ if (!S_ISREG(fstat.st_mode)){
clixon_debug(CLIXON_DBG_CLIENT, "Error lstat(%s): Not regular file", p); clixon_debug(CLIXON_DBG_RESTCONF, "Error lstat(%s): Not regular file", p);
code = 403; code = 403;
goto invalid; goto invalid;
} }
*fsz = fstat.st_size; *fsz = fstat.st_size;
if ((f = fopen(p, "rb")) == NULL){ if ((f = fopen(p, "rb")) == NULL){
clixon_debug(CLIXON_DBG_CLIENT, "Error fopen(%s) %s", p, strerror(errno)); clixon_debug(CLIXON_DBG_RESTCONF, "Error fopen(%s) %s", p, strerror(errno));
code = 403; code = 403;
goto invalid; goto invalid;
} }
@ -296,7 +296,7 @@ api_http_data_file(clixon_handle h,
char *buf = NULL; char *buf = NULL;
size_t sz; size_t sz;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_RESTCONF, "");
if ((cbfile = cbuf_new()) == NULL){ if ((cbfile = cbuf_new()) == NULL){
clixon_err(OE_UNIX, errno, "cbuf_new"); clixon_err(OE_UNIX, errno, "cbuf_new");
goto done; goto done;
@ -309,7 +309,7 @@ api_http_data_file(clixon_handle h,
cprintf(cbfile, "%s", www_data_root); cprintf(cbfile, "%s", www_data_root);
if (pathname){ if (pathname){
if (strlen(pathname) && pathname[0] != '/'){ if (strlen(pathname) && pathname[0] != '/'){
clixon_debug(CLIXON_DBG_CLIENT, "Error fopen(%s) pathname not prefixed with /", clixon_debug(CLIXON_DBG_RESTCONF, "Error fopen(%s) pathname not prefixed with /",
pathname); pathname);
if (api_http_data_err(h, req, 404) < 0) if (api_http_data_err(h, req, 404) < 0)
goto done; goto done;
@ -338,7 +338,7 @@ api_http_data_file(clixon_handle h,
fsize = ftell(f); fsize = ftell(f);
/* Extra sanity check, had some problems with wrong file types */ /* Extra sanity check, had some problems with wrong file types */
if (fsz != fsize){ if (fsz != fsize){
clixon_debug(CLIXON_DBG_CLIENT, "Error file %s size mismatch sz:%zu vs %li", clixon_debug(CLIXON_DBG_RESTCONF, "Error file %s size mismatch sz:%zu vs %li",
filename, (size_t)fsz, fsize); filename, (size_t)fsz, fsize);
if (api_http_data_err(h, req, 500) < 0) /* Internal error? */ if (api_http_data_err(h, req, 500) < 0) /* Internal error? */
goto done; goto done;
@ -362,7 +362,7 @@ api_http_data_file(clixon_handle h,
} }
sz = (size_t)ret; sz = (size_t)ret;
if (sz != 1){ if (sz != 1){
clixon_debug(CLIXON_DBG_CLIENT, "Error fread(%s) sz:%zu", filename, sz); clixon_debug(CLIXON_DBG_RESTCONF, "Error fread(%s) sz:%zu", filename, sz);
if (api_http_data_err(h, req, 500) < 0) /* Internal error? */ if (api_http_data_err(h, req, 500) < 0) /* Internal error? */
goto done; goto done;
goto ok; goto ok;
@ -376,7 +376,7 @@ api_http_data_file(clixon_handle h,
if (restconf_reply_send(req, 200, cbdata, head) < 0) if (restconf_reply_send(req, 200, cbdata, head) < 0)
goto done; goto done;
cbdata = NULL; /* consumed by reply-send */ cbdata = NULL; /* consumed by reply-send */
clixon_debug(CLIXON_DBG_CLIENT, "Read %s OK", filename); clixon_debug(CLIXON_DBG_RESTCONF, "Read %s OK", filename);
ok: ok:
retval = 0; retval = 0;
done: done:
@ -423,7 +423,7 @@ api_http_data(clixon_handle h,
cbuf *indata = NULL; cbuf *indata = NULL;
char *path = NULL; char *path = NULL;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_RESTCONF, "");
if (req == NULL){ if (req == NULL){
errno = EINVAL; errno = EINVAL;
goto done; goto done;
@ -498,6 +498,6 @@ api_http_data(clixon_handle h,
done: done:
if (path) if (path)
free(path); free(path);
clixon_debug(CLIXON_DBG_CLIENT, "retval:%d", retval); clixon_debug(CLIXON_DBG_RESTCONF, "retval:%d", retval);
return retval; return retval;
} }

View file

@ -86,7 +86,7 @@ restconf_reply_header(void *req0,
char *value = NULL; char *value = NULL;
va_list ap; va_list ap;
clixon_debug(CLIXON_DBG_CLIENT, "%s", name); clixon_debug(CLIXON_DBG_RESTCONF, "%s", name);
if (sd == NULL || name == NULL || vfmt == NULL){ if (sd == NULL || name == NULL || vfmt == NULL){
clixon_err(OE_CFG, EINVAL, "sd, name or value is NULL"); clixon_err(OE_CFG, EINVAL, "sd, name or value is NULL");
goto done; goto done;
@ -142,7 +142,7 @@ restconf_reply_send(void *req0,
int retval = -1; int retval = -1;
restconf_stream_data *sd = (restconf_stream_data *)req0; restconf_stream_data *sd = (restconf_stream_data *)req0;
clixon_debug(CLIXON_DBG_CLIENT, "code:%d", code); clixon_debug(CLIXON_DBG_RESTCONF, "code:%d", code);
if (sd == NULL){ if (sd == NULL){
clixon_err(OE_CFG, EINVAL, "sd is NULL"); clixon_err(OE_CFG, EINVAL, "sd is NULL");
goto done; goto done;

View file

@ -218,7 +218,7 @@ api_return_err(clixon_handle h,
cxobj *xmsg; cxobj *xmsg;
char *mb; char *mb;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_RESTCONF, "");
if ((cb = cbuf_new()) == NULL){ if ((cb = cbuf_new()) == NULL){
clixon_err(OE_UNIX, errno, "cbuf_new"); clixon_err(OE_UNIX, errno, "cbuf_new");
goto done; goto done;
@ -249,7 +249,7 @@ api_return_err(clixon_handle h,
} }
} }
#if 1 #if 1
clixon_debug_xml(CLIXON_DBG_CLIENT, xerr, "Send error:"); clixon_debug_xml(CLIXON_DBG_RESTCONF, xerr, "Send error:");
#endif #endif
if (xml_name_set(xerr, "error") < 0) if (xml_name_set(xerr, "error") < 0)
goto done; goto done;
@ -286,7 +286,7 @@ api_return_err(clixon_handle h,
case YANG_DATA_XML: case YANG_DATA_XML:
case YANG_PATCH_XML: case YANG_PATCH_XML:
case YANG_PAGINATION_XML: case YANG_PAGINATION_XML:
clixon_debug(CLIXON_DBG_CLIENT, "code:%d", code); clixon_debug(CLIXON_DBG_RESTCONF, "code:%d", code);
if (pretty){ if (pretty){
cprintf(cb, " <errors xmlns=\"urn:ietf:params:xml:ns:yang:ietf-restconf\">\n"); cprintf(cb, " <errors xmlns=\"urn:ietf:params:xml:ns:yang:ietf-restconf\">\n");
if (clixon_xml2cbuf(cb, xerr, 2, pretty, NULL, -1, 0) < 0) if (clixon_xml2cbuf(cb, xerr, 2, pretty, NULL, -1, 0) < 0)
@ -302,7 +302,7 @@ api_return_err(clixon_handle h,
break; break;
case YANG_DATA_JSON: case YANG_DATA_JSON:
case YANG_PATCH_JSON: case YANG_PATCH_JSON:
clixon_debug(CLIXON_DBG_CLIENT, "code:%d", code); clixon_debug(CLIXON_DBG_RESTCONF, "code:%d", code);
if (pretty){ if (pretty){
cprintf(cb, "{\n\"ietf-restconf:errors\" : "); cprintf(cb, "{\n\"ietf-restconf:errors\" : ");
if (clixon_json2cbuf(cb, xerr, pretty, 0, 0) < 0) if (clixon_json2cbuf(cb, xerr, pretty, 0, 0) < 0)
@ -329,7 +329,7 @@ api_return_err(clixon_handle h,
// ok: // ok:
retval = 0; retval = 0;
done: done:
clixon_debug(CLIXON_DBG_CLIENT, "retval:%d", retval); clixon_debug(CLIXON_DBG_RESTCONF, "retval:%d", retval);
if (cb) if (cb)
cbuf_free(cb); cbuf_free(cb);
if (cberr) if (cberr)

View file

@ -160,7 +160,7 @@ restconf_param_set(clixon_handle h,
{ {
struct restconf_handle *rh = handle(h); struct restconf_handle *rh = handle(h);
clixon_debug(CLIXON_DBG_CLIENT, "%s=%s", param, val); clixon_debug(CLIXON_DBG_RESTCONF, "%s=%s", param, val);
if (rh->rh_params == NULL) if (rh->rh_params == NULL)
if ((rh->rh_params = clicon_hash_init()) == NULL) if ((rh->rh_params = clicon_hash_init()) == NULL)
return -1; return -1;

View file

@ -90,7 +90,7 @@ _http1_parse(clixon_handle h,
clixon_http1_yacc hy = {0,}; clixon_http1_yacc hy = {0,};
int ret; int ret;
clixon_debug(CLIXON_DBG_CLIENT, "\n%s", str); clixon_debug(CLIXON_DBG_RESTCONF, "\n%s", str);
if (strlen(str) == 0) if (strlen(str) == 0)
goto ok; goto ok;
hy.hy_parse_string = str; hy.hy_parse_string = str;
@ -119,7 +119,7 @@ _http1_parse(clixon_handle h,
ok: ok:
retval = 0; retval = 0;
done: done:
clixon_debug(CLIXON_DBG_CLIENT, "retval:%d", retval); clixon_debug(CLIXON_DBG_RESTCONF, "retval:%d", retval);
return retval; return retval;
} }
@ -147,7 +147,7 @@ clixon_http1_parse_file(clixon_handle h,
int len = 0; int len = 0;
int oldbuflen; int oldbuflen;
clixon_debug(CLIXON_DBG_CLIENT, "%s", filename); clixon_debug(CLIXON_DBG_RESTCONF, "%s", filename);
if (f == NULL){ if (f == NULL){
clixon_err(OE_RESTCONF, EINVAL, "f is NULL"); clixon_err(OE_RESTCONF, EINVAL, "f is NULL");
goto done; goto done;
@ -302,7 +302,7 @@ restconf_http1_reply(restconf_conn *rc,
int retval = -1; int retval = -1;
cg_var *cv; cg_var *cv;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_RESTCONF, "");
/* If body, add a content-length header /* If body, add a content-length header
* A server MUST NOT send a Content-Length header field in any response * A server MUST NOT send a Content-Length header field in any response
* with a status code of 1xx (Informational) or 204 (No Content). A * with a status code of 1xx (Informational) or 204 (No Content). A
@ -365,7 +365,7 @@ restconf_http1_path_root(clixon_handle h,
int ret; int ret;
#endif #endif
clixon_debug(CLIXON_DBG_CLIENT, "------------"); clixon_debug(CLIXON_DBG_RESTCONF, "------------");
pretty = restconf_pretty_get(h); pretty = restconf_pretty_get(h);
if ((sd = restconf_stream_find(rc, 0)) == NULL){ if ((sd = restconf_stream_find(rc, 0)) == NULL){
clixon_err(OE_RESTCONF, EINVAL, "No stream_data"); clixon_err(OE_RESTCONF, EINVAL, "No stream_data");
@ -463,7 +463,7 @@ restconf_http1_path_root(clixon_handle h,
goto done; goto done;
retval = 0; retval = 0;
done: done:
clixon_debug(CLIXON_DBG_CLIENT, "retval:%d", retval); clixon_debug(CLIXON_DBG_RESTCONF, "retval:%d", retval);
if (subject) if (subject)
free(subject); free(subject);
if (xerr) if (xerr)

View file

@ -360,7 +360,7 @@ restconf_terminate(clixon_handle h)
cxobj *x; cxobj *x;
int fs; /* fgcx socket */ int fs; /* fgcx socket */
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_RESTCONF, "");
if ((fs = clicon_socket_get(h)) != -1) if ((fs = clicon_socket_get(h)) != -1)
close(fs); close(fs);
/* Delete all plugins, and RPC callbacks */ /* Delete all plugins, and RPC callbacks */
@ -378,7 +378,7 @@ restconf_terminate(clixon_handle h)
xpath_optimize_exit(); xpath_optimize_exit();
restconf_handle_exit(h); restconf_handle_exit(h);
clixon_err_exit(); clixon_err_exit();
clixon_debug(CLIXON_DBG_CLIENT, "pid:%u done", getpid()); clixon_debug(CLIXON_DBG_RESTCONF, "pid:%u done", getpid());
clixon_log_exit(); /* Must be after last clixon_debug */ clixon_log_exit(); /* Must be after last clixon_debug */
return 0; return 0;
} }
@ -524,7 +524,7 @@ restconf_main_extension_cb(clixon_handle h,
extname = yang_argument_get(yext); extname = yang_argument_get(yext);
if (strcmp(modname, "ietf-restconf") != 0 || strcmp(extname, "yang-data") != 0) if (strcmp(modname, "ietf-restconf") != 0 || strcmp(extname, "yang-data") != 0)
goto ok; goto ok;
clixon_debug(CLIXON_DBG_CLIENT, "Enabled extension:%s:%s", modname, extname); clixon_debug(CLIXON_DBG_RESTCONF, "Enabled extension:%s:%s", modname, extname);
if ((yc = yang_find(ys, 0, NULL)) == NULL) if ((yc = yang_find(ys, 0, NULL)) == NULL)
goto ok; goto ok;
if ((yn = ys_dup(yc)) == NULL) if ((yn = ys_dup(yc)) == NULL)
@ -584,7 +584,7 @@ restconf_drop_privileges(clixon_handle h)
char *user; char *user;
enum priv_mode_t priv_mode = PM_NONE; enum priv_mode_t priv_mode = PM_NONE;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_RESTCONF, "");
/* Sanity check: backend group exists */ /* Sanity check: backend group exists */
if ((group = clicon_sock_group(h)) == NULL){ if ((group = clicon_sock_group(h)) == NULL){
clixon_err(OE_FATAL, 0, "clicon_sock_group option not set"); clixon_err(OE_FATAL, 0, "clicon_sock_group option not set");
@ -639,7 +639,7 @@ restconf_drop_privileges(clixon_handle h)
case PM_NONE: case PM_NONE:
break; /* catched above */ break; /* catched above */
} }
clixon_debug(CLIXON_DBG_CLIENT, "dropped privileges from root to %s(%d)", clixon_debug(CLIXON_DBG_RESTCONF, "dropped privileges from root to %s(%d)",
user, newuid); user, newuid);
ok: ok:
retval = 0; retval = 0;
@ -673,7 +673,7 @@ restconf_authentication_cb(clixon_handle h,
char *anonymous = NULL; char *anonymous = NULL;
auth_type = restconf_auth_type_get(h); auth_type = restconf_auth_type_get(h);
clixon_debug(CLIXON_DBG_CLIENT, "auth-type:%s", clixon_auth_type_int2str(auth_type)); clixon_debug(CLIXON_DBG_RESTCONF, "auth-type:%s", clixon_auth_type_int2str(auth_type));
ret = 0; ret = 0;
authenticated = 0; authenticated = 0;
/* ret: -1 Error, 0: Ignore/not handled, 1: OK see authenticated parameter */ /* ret: -1 Error, 0: Ignore/not handled, 1: OK see authenticated parameter */
@ -725,7 +725,7 @@ restconf_authentication_cb(clixon_handle h,
/* If set but no user, set a dummy user */ /* If set but no user, set a dummy user */
retval = 1; retval = 1;
done: done:
clixon_debug(CLIXON_DBG_CLIENT, "retval:%d authenticated:%d user:%s", clixon_debug(CLIXON_DBG_RESTCONF, "retval:%d authenticated:%d user:%s",
retval, authenticated, clicon_username_get(h)); retval, authenticated, clicon_username_get(h));
if (username) if (username)
free(username); free(username);
@ -768,7 +768,7 @@ restconf_config_init(clixon_handle h,
if ((x = xpath_first(xrestconf, nsc, "enable")) != NULL && if ((x = xpath_first(xrestconf, nsc, "enable")) != NULL &&
(enable = xml_body(x)) != NULL){ (enable = xml_body(x)) != NULL){
if (strcmp(enable, "false") == 0){ if (strcmp(enable, "false") == 0){
clixon_debug(CLIXON_DBG_CLIENT, "restconf disabled"); clixon_debug(CLIXON_DBG_RESTCONF, "restconf disabled");
goto disable; goto disable;
} }
} }
@ -848,7 +848,7 @@ restconf_socket_init(const char *netns0,
size_t sa_len; size_t sa_len;
const char *netns; const char *netns;
clixon_debug(CLIXON_DBG_CLIENT, "%s %s %s %hu", netns0, addrtype, addrstr, port); clixon_debug(CLIXON_DBG_RESTCONF, "%s %s %s %hu", netns0, addrtype, addrstr, port);
/* netns default -> NULL */ /* netns default -> NULL */
if (netns0 != NULL && strcmp(netns0, RESTCONF_NETNS_DEFAULT)==0) if (netns0 != NULL && strcmp(netns0, RESTCONF_NETNS_DEFAULT)==0)
netns = NULL; netns = NULL;
@ -858,10 +858,10 @@ restconf_socket_init(const char *netns0,
goto done; goto done;
if (clixon_netns_socket(netns, sa, sa_len, backlog, flags, addrstr, ss) < 0) if (clixon_netns_socket(netns, sa, sa_len, backlog, flags, addrstr, ss) < 0)
goto done; goto done;
clixon_debug(CLIXON_DBG_CLIENT, "ss=%d", *ss); clixon_debug(CLIXON_DBG_RESTCONF, "ss=%d", *ss);
retval = 0; retval = 0;
done: done:
clixon_debug(CLIXON_DBG_CLIENT, "retval:%d", retval); clixon_debug(CLIXON_DBG_RESTCONF, "retval:%d", retval);
return retval; return retval;
} }

View file

@ -107,7 +107,7 @@ fcgi_params_set(clixon_handle h,
char *param = NULL; char *param = NULL;
char *val = NULL; char *val = NULL;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_RESTCONF, "");
for (i = 0; envp[i] != NULL; i++){ /* on the form <param>=<value> */ for (i = 0; envp[i] != NULL; i++){ /* on the form <param>=<value> */
if (clixon_strsplit(envp[i], '=', &param, &val) < 0) if (clixon_strsplit(envp[i], '=', &param, &val) < 0)
goto done; goto done;
@ -124,7 +124,7 @@ fcgi_params_set(clixon_handle h,
} }
retval = 0; retval = 0;
done: done:
clixon_debug(CLIXON_DBG_CLIENT, "retval:%d", retval); clixon_debug(CLIXON_DBG_RESTCONF, "retval:%d", retval);
return retval; return retval;
} }
@ -147,7 +147,7 @@ restconf_main_config(clixon_handle h,
/* 1. try inline configure option */ /* 1. try inline configure option */
if (inline_config != NULL && strlen(inline_config)){ if (inline_config != NULL && strlen(inline_config)){
clixon_debug(CLIXON_DBG_CLIENT, "restconf_main_fcgi using restconf inline config"); clixon_debug(CLIXON_DBG_RESTCONF, "restconf_main_fcgi using restconf inline config");
if ((ret = clixon_xml_parse_string(inline_config, YB_MODULE, yspec, &xrestconf, &xerr)) < 0) if ((ret = clixon_xml_parse_string(inline_config, YB_MODULE, yspec, &xrestconf, &xerr)) < 0)
goto done; goto done;
if (ret == 0){ if (ret == 0){
@ -228,12 +228,12 @@ restconf_sig_term(int arg)
{ {
static int i=0; static int i=0;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_RESTCONF, "");
if (i++ == 0) if (i++ == 0)
clixon_log(NULL, LOG_NOTICE, "%s: %s: pid: %u Signal %d", clixon_log(NULL, LOG_NOTICE, "%s: %s: pid: %u Signal %d",
__PROGRAM__, __FUNCTION__, getpid(), arg); __PROGRAM__, __FUNCTION__, getpid(), arg);
else{ else{
clixon_debug(CLIXON_DBG_CLIENT, "done"); clixon_debug(CLIXON_DBG_RESTCONF, "done");
exit(-1); exit(-1);
} }
@ -272,7 +272,7 @@ usage(clixon_handle h,
"where options are\n" "where options are\n"
"\t-h \t\t Help\n" "\t-h \t\t Help\n"
"\t-V \t\tPrint version and exit\n" "\t-V \t\tPrint version and exit\n"
"\t-D <level>\t Debug level\n" "\t-D <level>\tDebug level (see available levels below)\n"
"\t-f <file>\t Configuration file (mandatory)\n" "\t-f <file>\t Configuration file (mandatory)\n"
"\t-E <dir> \t Extra configuration file directory\n" "\t-E <dir> \t Extra configuration file directory\n"
"\t-l <s|e|o|n|f<file>> \tLog on (s)yslog, std(e)rr, std(o)ut, (n)one or (f)ile (syslog is default)\n" "\t-l <s|e|o|n|f<file>> \tLog on (s)yslog, std(e)rr, std(o)ut, (n)one or (f)ile (syslog is default)\n"
@ -288,6 +288,9 @@ usage(clixon_handle h,
"\t-o \"<option>=<value>\" Give configuration option overriding config file (see clixon-config.yang)\n", "\t-o \"<option>=<value>\" Give configuration option overriding config file (see clixon-config.yang)\n",
argv0 argv0
); );
fprintf(stderr, "Debug keys: ");
clixon_debug_key_dump(stderr);
fprintf(stderr, "\n");
exit(0); exit(0);
} }
@ -345,10 +348,16 @@ main(int argc,
cligen_output(stdout, "Clixon version %s\n", CLIXON_VERSION_STRING); cligen_output(stdout, "Clixon version %s\n", CLIXON_VERSION_STRING);
print_version++; /* plugins may also print versions w ca-version callback */ print_version++; /* plugins may also print versions w ca-version callback */
break; break;
case 'D' : /* debug */ case 'D' : { /* debug */
if (sscanf(optarg, "%d", &dbg) != 1) int d = 0;
/* Try first symbolic, then numeric match */
if ((d = clixon_debug_str2key(optarg)) < 0 &&
sscanf(optarg, "%d", &d) != 1){
usage(h, argv[0]); usage(h, argv[0]);
}
dbg |= d;
break; break;
}
case 'f': /* override config file */ case 'f': /* override config file */
if (!strlen(optarg)) if (!strlen(optarg))
usage(h, argv[0]); usage(h, argv[0]);
@ -582,7 +591,7 @@ main(int argc,
clixon_err(OE_CFG, errno, "FCGX_Init"); clixon_err(OE_CFG, errno, "FCGX_Init");
goto done; goto done;
} }
clixon_debug(CLIXON_DBG_CLIENT, "restconf_main: Opening FCGX socket: %s", sockpath); clixon_debug(CLIXON_DBG_RESTCONF, "restconf_main: Opening FCGX socket: %s", sockpath);
if ((sock = FCGX_OpenSocket(sockpath, 10)) < 0){ if ((sock = FCGX_OpenSocket(sockpath, 10)) < 0){
clixon_err(OE_CFG, errno, "FCGX_OpenSocket"); clixon_err(OE_CFG, errno, "FCGX_OpenSocket");
goto done; goto done;
@ -629,7 +638,7 @@ main(int argc,
clixon_err(OE_CFG, errno, "FCGX_Accept_r"); clixon_err(OE_CFG, errno, "FCGX_Accept_r");
goto done; goto done;
} }
clixon_debug(CLIXON_DBG_CLIENT, "------------"); clixon_debug(CLIXON_DBG_RESTCONF, "------------");
/* Translate from FCGI parameter form to Clixon runtime data /* Translate from FCGI parameter form to Clixon runtime data
* XXX: potential name collision? * XXX: potential name collision?
@ -637,7 +646,7 @@ main(int argc,
if (fcgi_params_set(h, req->envp) < 0) if (fcgi_params_set(h, req->envp) < 0)
goto done; goto done;
if ((path = restconf_param_get(h, "REQUEST_URI")) == NULL){ if ((path = restconf_param_get(h, "REQUEST_URI")) == NULL){
clixon_debug(CLIXON_DBG_CLIENT, "NULL URI"); clixon_debug(CLIXON_DBG_RESTCONF, "NULL URI");
} }
else { else {
/* Matching algorithm: /* Matching algorithm:
@ -669,7 +678,7 @@ main(int argc,
(void)api_stream(h, req, qvec, &finish); (void)api_stream(h, req, qvec, &finish);
} }
else{ else{
clixon_debug(CLIXON_DBG_CLIENT, "top-level %s not found", path); clixon_debug(CLIXON_DBG_RESTCONF, "top-level %s not found", path);
if (netconf_invalid_value_xml(&xerr, "protocol", "Top-level path not found") < 0) if (netconf_invalid_value_xml(&xerr, "protocol", "Top-level path not found") < 0)
goto done; goto done;
if (api_return_err0(h, req, xerr, 1, YANG_DATA_JSON, 0) < 0) if (api_return_err0(h, req, xerr, 1, YANG_DATA_JSON, 0) < 0)

View file

@ -217,7 +217,7 @@ clixon_openssl_log_cb(void *handle,
int suberr, int suberr,
cbuf *cb) cbuf *cb)
{ {
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_RESTCONF, "");
ERR_print_errors_cb(print_cb, cb); ERR_print_errors_cb(print_cb, cb);
return 0; return 0;
} }
@ -266,17 +266,17 @@ restconf_verify_certs(int preverify_ok,
depth = X509_STORE_CTX_get_error_depth(store); depth = X509_STORE_CTX_get_error_depth(store);
// ssl = X509_STORE_CTX_get_ex_data(store, SSL_get_ex_data_X509_STORE_CTX_idx()); // ssl = X509_STORE_CTX_get_ex_data(store, SSL_get_ex_data_X509_STORE_CTX_idx());
clixon_debug(CLIXON_DBG_CLIENT, "preverify_ok:%d err:%d depth:%d", preverify_ok, err, depth); clixon_debug(CLIXON_DBG_RESTCONF, "preverify_ok:%d err:%d depth:%d", preverify_ok, err, depth);
X509_NAME_oneline(X509_get_subject_name(err_cert), buf, 256); X509_NAME_oneline(X509_get_subject_name(err_cert), buf, 256);
switch (err){ switch (err){
case X509_V_ERR_HOSTNAME_MISMATCH: case X509_V_ERR_HOSTNAME_MISMATCH:
clixon_debug(CLIXON_DBG_CLIENT, "X509_V_ERR_HOSTNAME_MISMATCH"); clixon_debug(CLIXON_DBG_RESTCONF, "X509_V_ERR_HOSTNAME_MISMATCH");
break; break;
case X509_V_ERR_CERT_HAS_EXPIRED: case X509_V_ERR_CERT_HAS_EXPIRED:
clixon_debug(CLIXON_DBG_CLIENT, "X509_V_ERR_CERT_HAS_EXPIRED"); clixon_debug(CLIXON_DBG_RESTCONF, "X509_V_ERR_CERT_HAS_EXPIRED");
break; break;
case X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT: case X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT:
clixon_debug(CLIXON_DBG_CLIENT, "X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT"); clixon_debug(CLIXON_DBG_RESTCONF, "X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT");
break; break;
} }
/* Catch a too long certificate chain. should be +1 in SSL_CTX_set_verify_depth() */ /* Catch a too long certificate chain. should be +1 in SSL_CTX_set_verify_depth() */
@ -305,7 +305,7 @@ alpn_proto_dump(const char *label,
const char *inp, const char *inp,
unsigned len) unsigned len)
{ {
clixon_debug(CLIXON_DBG_CLIENT, "%s %.*s", label, (int)len, inp); clixon_debug(CLIXON_DBG_RESTCONF, "%s %.*s", label, (int)len, inp);
return 0; return 0;
} }
@ -327,7 +327,7 @@ alpn_select_proto_cb(SSL *ssl,
unsigned char len; unsigned char len;
int pref = 0; int pref = 0;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_RESTCONF, "");
/* select http/1.1 */ /* select http/1.1 */
inp = (unsigned char*)in; inp = (unsigned char*)in;
while ((inp-in) < inlen) { while ((inp-in) < inlen) {
@ -456,18 +456,18 @@ restconf_listcerts(SSL *ssl)
X509 *cert; X509 *cert;
char *line; char *line;
clixon_debug(CLIXON_DBG_CLIENT, "get peer certificates:"); clixon_debug(CLIXON_DBG_RESTCONF, "get peer certificates:");
if ((cert = SSL_get_peer_certificate(ssl)) != NULL) { /* Get certificates (if available) */ if ((cert = SSL_get_peer_certificate(ssl)) != NULL) { /* Get certificates (if available) */
if ((line = X509_NAME_oneline(X509_get_subject_name(cert), 0, 0)) != NULL){ if ((line = X509_NAME_oneline(X509_get_subject_name(cert), 0, 0)) != NULL){
clixon_debug(CLIXON_DBG_CLIENT, "Subject: %s", line); clixon_debug(CLIXON_DBG_RESTCONF, "Subject: %s", line);
free(line); free(line);
} }
if ((line = X509_NAME_oneline(X509_get_issuer_name(cert), 0, 0)) != NULL){ if ((line = X509_NAME_oneline(X509_get_issuer_name(cert), 0, 0)) != NULL){
clixon_debug(CLIXON_DBG_CLIENT, "Issuer: %s", line); clixon_debug(CLIXON_DBG_RESTCONF, "Issuer: %s", line);
free(line); free(line);
} }
if ((line = X509_NAME_oneline(X509_get_subject_name(cert), 0, 0)) != NULL){ if ((line = X509_NAME_oneline(X509_get_subject_name(cert), 0, 0)) != NULL){
clixon_debug(CLIXON_DBG_CLIENT, "Subject: %s", line); clixon_debug(CLIXON_DBG_RESTCONF, "Subject: %s", line);
free(line); free(line);
} }
X509_free(cert); X509_free(cert);
@ -534,7 +534,7 @@ restconf_accept_client(int fd,
char *name = NULL; char *name = NULL;
void *addr; void *addr;
clixon_debug(CLIXON_DBG_CLIENT, "%d", fd); clixon_debug(CLIXON_DBG_RESTCONF, "%d", fd);
if ((rsock = (restconf_socket *)arg) == NULL){ if ((rsock = (restconf_socket *)arg) == NULL){
clixon_err(OE_YANG, EINVAL, "rsock is NULL"); clixon_err(OE_YANG, EINVAL, "rsock is NULL");
goto done; goto done;
@ -570,7 +570,7 @@ restconf_accept_client(int fd,
} }
if (inet_ntop(from.sa_family, addr, rsock->rs_from_addr, INET6_ADDRSTRLEN) < 0) if (inet_ntop(from.sa_family, addr, rsock->rs_from_addr, INET6_ADDRSTRLEN) < 0)
goto done; goto done;
clixon_debug(CLIXON_DBG_CLIENT, "type:%s from:%s, dest:%s port:%hu", clixon_debug(CLIXON_DBG_RESTCONF, "type:%s from:%s, dest:%s port:%hu",
rsock->rs_addrtype, rsock->rs_addrtype,
rsock->rs_from_addr, rsock->rs_from_addr,
rsock->rs_addrstr, rsock->rs_addrstr,
@ -581,7 +581,7 @@ restconf_accept_client(int fd,
goto done; goto done;
retval = 0; retval = 0;
done: done:
clixon_debug(CLIXON_DBG_CLIENT, "retval:%d", retval); clixon_debug(CLIXON_DBG_RESTCONF, "retval:%d", retval);
if (name) if (name)
free(name); free(name);
return retval; return retval;
@ -596,7 +596,7 @@ restconf_native_terminate(clixon_handle h)
restconf_socket *rsock; restconf_socket *rsock;
restconf_conn *rc; restconf_conn *rc;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_RESTCONF, "");
if ((rn = restconf_native_handle_get(h)) != NULL){ if ((rn = restconf_native_handle_get(h)) != NULL){
while ((rsock = rn->rn_sockets) != NULL){ while ((rsock = rn->rn_sockets) != NULL){
while ((rc = rsock->rs_conns) != NULL){ while ((rc = rsock->rs_conns) != NULL){
@ -728,7 +728,7 @@ openssl_init_socket(clixon_handle h,
restconf_socket *rsock = NULL; /* openssl per socket struct */ restconf_socket *rsock = NULL; /* openssl per socket struct */
struct timeval now; struct timeval now;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_RESTCONF, "");
/* /*
* Create per-socket openssl handle * Create per-socket openssl handle
* See restconf_native_terminate for freeing * See restconf_native_terminate for freeing
@ -825,7 +825,7 @@ restconf_openssl_init(clixon_handle h,
size_t veclen; size_t veclen;
int i; int i;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_RESTCONF, "");
/* flag used for sanity of certs */ /* flag used for sanity of certs */
ssl_enable = xpath_first(xrestconf, nsc, "socket[ssl='true']") != NULL; ssl_enable = xpath_first(xrestconf, nsc, "socket[ssl='true']") != NULL;
/* Auth type set in config */ /* Auth type set in config */
@ -1022,7 +1022,7 @@ restconf_clixon_init(clixon_handle h,
if (clicon_nsctx_global_set(h, nsctx_global) < 0) if (clicon_nsctx_global_set(h, nsctx_global) < 0)
goto done; goto done;
if (inline_config != NULL && strlen(inline_config)){ if (inline_config != NULL && strlen(inline_config)){
clixon_debug(CLIXON_DBG_CLIENT, "reading from inline config"); clixon_debug(CLIXON_DBG_RESTCONF, "reading from inline config");
if ((ret = clixon_xml_parse_string(inline_config, YB_MODULE, yspec, &xrestconf, &xerr)) < 0) if ((ret = clixon_xml_parse_string(inline_config, YB_MODULE, yspec, &xrestconf, &xerr)) < 0)
goto done; goto done;
if (ret == 0){ if (ret == 0){
@ -1044,7 +1044,7 @@ restconf_clixon_init(clixon_handle h,
goto done; goto done;
} }
else if (clicon_option_bool(h, "CLICON_BACKEND_RESTCONF_PROCESS") == 0){ else if (clicon_option_bool(h, "CLICON_BACKEND_RESTCONF_PROCESS") == 0){
clixon_debug(CLIXON_DBG_CLIENT, "reading from clixon config"); clixon_debug(CLIXON_DBG_RESTCONF, "reading from clixon config");
/* If not read from backend, try to get restconf config from local config-file */ /* If not read from backend, try to get restconf config from local config-file */
if ((xrestconf = clicon_conf_restconf(h)) != NULL){ if ((xrestconf = clicon_conf_restconf(h)) != NULL){
/* Basic config init, set auth-type, pretty, etc ret 0 means disabled */ /* Basic config init, set auth-type, pretty, etc ret 0 means disabled */
@ -1062,7 +1062,7 @@ restconf_clixon_init(clixon_handle h,
/* If no local config, or it is disabled, try to query backend of config. /* If no local config, or it is disabled, try to query backend of config.
*/ */
else { else {
clixon_debug(CLIXON_DBG_CLIENT, "reading from backend datastore config"); clixon_debug(CLIXON_DBG_RESTCONF, "reading from backend datastore config");
if ((ret = restconf_clixon_backend(h, xrestconfp)) < 0) if ((ret = restconf_clixon_backend(h, xrestconfp)) < 0)
goto done; goto done;
if (ret == 0) if (ret == 0)
@ -1111,7 +1111,7 @@ usage(clixon_handle h,
"where options are\n" "where options are\n"
"\t-h \t\t Help\n" "\t-h \t\t Help\n"
"\t-V \t\tPrint version and exit\n" "\t-V \t\tPrint version and exit\n"
"\t-D <level>\t Debug level, overrides any config debug setting\n" "\t-D <level>\tDebug level (see available levels below)\n"
"\t-f <file>\t Configuration file (mandatory)\n" "\t-f <file>\t Configuration file (mandatory)\n"
"\t-E <dir> \t Extra configuration file directory\n" "\t-E <dir> \t Extra configuration file directory\n"
"\t-l <s|e|o|n|f<file>> \tLog on (s)yslog, std(e)rr, std(o)ut, (n)one or (f)ile (syslog is default)\n" "\t-l <s|e|o|n|f<file>> \tLog on (s)yslog, std(e)rr, std(o)ut, (n)one or (f)ile (syslog is default)\n"
@ -1127,6 +1127,9 @@ usage(clixon_handle h,
, ,
argv0 argv0
); );
fprintf(stderr, "Debug keys: ");
clixon_debug_key_dump(stderr);
fprintf(stderr, "\n");
exit(0); exit(0);
} }
@ -1168,9 +1171,17 @@ main(int argc,
cligen_output(stdout, "Clixon version %s\n", CLIXON_VERSION_STRING); cligen_output(stdout, "Clixon version %s\n", CLIXON_VERSION_STRING);
print_version++; /* plugins may also print versions w ca-version callback */ print_version++; /* plugins may also print versions w ca-version callback */
break; break;
case 'D' : /* debug. Note this overrides any setting in the config */ case 'D' : { /* debug. Note this overrides any setting in the config */
if (sscanf(optarg, "%d", &dbg) != 1) int d = 0;
usage(h, argv0); /* Try first symbolic, then numeric match */
if ((d = clixon_debug_str2key(optarg)) < 0 &&
sscanf(optarg, "%d", &d) != 1){
usage(h, argv[0]);
}
dbg |= d;
break;
}
break; break;
case 'f': /* override config file */ case 'f': /* override config file */
if (!strlen(optarg)) if (!strlen(optarg))
@ -1352,7 +1363,7 @@ main(int argc,
ok: ok:
retval = 0; retval = 0;
done: done:
clixon_debug(CLIXON_DBG_CLIENT, "restconf_main_openssl done"); clixon_debug(CLIXON_DBG_RESTCONF, "restconf_main_openssl done");
if (xrestconf) if (xrestconf)
xml_free(xrestconf); xml_free(xrestconf);
restconf_native_terminate(h); restconf_native_terminate(h);

View file

@ -98,7 +98,7 @@ api_data_options(clixon_handle h,
{ {
int retval = -1; int retval = -1;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_RESTCONF, "");
if (restconf_reply_header(req, "Allow", "OPTIONS,HEAD,GET,POST,PUT,PATCH,DELETE") < 0) if (restconf_reply_header(req, "Allow", "OPTIONS,HEAD,GET,POST,PUT,PATCH,DELETE") < 0)
goto done; goto done;
if (restconf_reply_header(req, "Accept-Patch", "application/yang-data+xml,application/yang-data+json") < 0) if (restconf_reply_header(req, "Accept-Patch", "application/yang-data+xml,application/yang-data+json") < 0)
@ -142,7 +142,7 @@ match_list_keys(yang_stmt *y,
char *key1; char *key1;
char *key2; char *key2;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_RESTCONF, "");
switch (yang_keyword_get(y)){ switch (yang_keyword_get(y)){
case Y_LIST: case Y_LIST:
if ((cvk = yang_cvec_get(y)) == NULL) /* Use Y_LIST cache, see ys_populate_list() */ if ((cvk = yang_cvec_get(y)) == NULL) /* Use Y_LIST cache, see ys_populate_list() */
@ -176,7 +176,7 @@ match_list_keys(yang_stmt *y,
ok: ok:
retval = 0; retval = 0;
done: done:
clixon_debug(CLIXON_DBG_CLIENT, "retval:%d", retval); clixon_debug(CLIXON_DBG_RESTCONF, "retval:%d", retval);
return retval; return retval;
} }
@ -236,8 +236,8 @@ api_data_write(clixon_handle h,
char *xpath = NULL; char *xpath = NULL;
char *attr; char *attr;
clixon_debug(CLIXON_DBG_CLIENT, "api_path:\"%s\"", api_path0); clixon_debug(CLIXON_DBG_RESTCONF, "api_path:\"%s\"", api_path0);
clixon_debug(CLIXON_DBG_CLIENT, "data:\"%s\"", data); clixon_debug(CLIXON_DBG_RESTCONF, "data:\"%s\"", data);
if ((yspec = clicon_dbspec_yang(h)) == NULL){ if ((yspec = clicon_dbspec_yang(h)) == NULL){
clixon_err(OE_FATAL, 0, "No DB_SPEC"); clixon_err(OE_FATAL, 0, "No DB_SPEC");
goto done; goto done;
@ -427,7 +427,7 @@ api_data_write(clixon_handle h,
/* There is an api-path that defines an element in the datastore tree. /* There is an api-path that defines an element in the datastore tree.
* Not top-of-tree. * Not top-of-tree.
*/ */
clixon_debug(CLIXON_DBG_CLIENT, "Comparing bottom-of api-path (%s) with top-of-data (%s)", xml_name(xbot), dname); clixon_debug(CLIXON_DBG_RESTCONF, "Comparing bottom-of api-path (%s) with top-of-data (%s)", xml_name(xbot), dname);
/* Check same symbol in api-path as data */ /* Check same symbol in api-path as data */
if (strcmp(dname, xml_name(xbot))){ if (strcmp(dname, xml_name(xbot))){
@ -492,11 +492,11 @@ api_data_write(clixon_handle h,
/* If we already have that default namespace, remove it in child */ /* If we already have that default namespace, remove it in child */
if ((xa = xml_find_type(xdata, NULL, "xmlns", CX_ATTR)) != NULL){ if ((xa = xml_find_type(xdata, NULL, "xmlns", CX_ATTR)) != NULL){
if (xml2ns(xparent, NULL, &namespace) < 0){ if (xml2ns(xparent, NULL, &namespace) < 0){
clixon_debug(CLIXON_DBG_CLIENT, "G done"); clixon_debug(CLIXON_DBG_RESTCONF, "G done");
goto done; goto done;
} }
if (namespace == NULL){ if (namespace == NULL){
clixon_debug_xml(CLIXON_DBG_CLIENT, xparent, "xparent:"); clixon_debug_xml(CLIXON_DBG_RESTCONF, xparent, "xparent:");
/* XXX */ /* XXX */
} }
/* Set xmlns="" default namespace attribute (if diff from default) */ /* Set xmlns="" default namespace attribute (if diff from default) */
@ -540,7 +540,7 @@ api_data_write(clixon_handle h,
if (clixon_xml2cbuf(cbx, xtop, 0, 0, NULL, -1, 0) < 0) if (clixon_xml2cbuf(cbx, xtop, 0, 0, NULL, -1, 0) < 0)
goto done; goto done;
cprintf(cbx, "</edit-config></rpc>"); cprintf(cbx, "</edit-config></rpc>");
clixon_debug(CLIXON_DBG_CLIENT, "xml: %s api_path:%s", cbuf_get(cbx), api_path); clixon_debug(CLIXON_DBG_RESTCONF, "xml: %s api_path:%s", cbuf_get(cbx), api_path);
if (clicon_rpc_netconf(h, cbuf_get(cbx), &xret, NULL) < 0) if (clicon_rpc_netconf(h, cbuf_get(cbx), &xret, NULL) < 0)
goto done; goto done;
if ((xe = xpath_first(xret, NULL, "//rpc-error")) != NULL){ if ((xe = xpath_first(xret, NULL, "//rpc-error")) != NULL){
@ -560,7 +560,7 @@ api_data_write(clixon_handle h,
ok: ok:
retval = 0; retval = 0;
done: done:
clixon_debug(CLIXON_DBG_CLIENT, "retval:%d", retval); clixon_debug(CLIXON_DBG_RESTCONF, "retval:%d", retval);
if (xpath) if (xpath)
free(xpath); free(xpath);
if (nsc) if (nsc)
@ -737,7 +737,7 @@ api_data_delete(clixon_handle h,
int ret; int ret;
cxobj *xe; /* xml error, no free */ cxobj *xe; /* xml error, no free */
clixon_debug(CLIXON_DBG_CLIENT, "api_path:%s", api_path); clixon_debug(CLIXON_DBG_RESTCONF, "api_path:%s", api_path);
if ((yspec = clicon_dbspec_yang(h)) == NULL){ if ((yspec = clicon_dbspec_yang(h)) == NULL){
clixon_err(OE_FATAL, 0, "No DB_SPEC"); clixon_err(OE_FATAL, 0, "No DB_SPEC");
goto done; goto done;
@ -821,7 +821,7 @@ api_data_delete(clixon_handle h,
xml_free(xretdis); xml_free(xretdis);
if (xtop) if (xtop)
xml_free(xtop); xml_free(xtop);
clixon_debug(CLIXON_DBG_CLIENT, "retval:%d", retval); clixon_debug(CLIXON_DBG_RESTCONF, "retval:%d", retval);
return retval; return retval;
} }

View file

@ -128,7 +128,7 @@ api_data_get2(clixon_handle h,
char *defaults = NULL; char *defaults = NULL;
cvec *nscd = NULL; cvec *nscd = NULL;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_RESTCONF, "");
if ((yspec = clicon_dbspec_yang(h)) == NULL){ if ((yspec = clicon_dbspec_yang(h)) == NULL){
clixon_err(OE_FATAL, 0, "No DB_SPEC"); clixon_err(OE_FATAL, 0, "No DB_SPEC");
goto done; goto done;
@ -168,7 +168,7 @@ api_data_get2(clixon_handle h,
} }
/* Check for content attribute */ /* Check for content attribute */
if ((attr = cvec_find_str(qvec, "content")) != NULL){ if ((attr = cvec_find_str(qvec, "content")) != NULL){
clixon_debug(CLIXON_DBG_CLIENT, "content=%s", attr); clixon_debug(CLIXON_DBG_RESTCONF, "content=%s", attr);
if ((int)(content = netconf_content_str2int(attr)) == -1){ if ((int)(content = netconf_content_str2int(attr)) == -1){
if (netconf_bad_attribute_xml(&xerr, "application", if (netconf_bad_attribute_xml(&xerr, "application",
"content", "Unrecognized value of content attribute") < 0) "content", "Unrecognized value of content attribute") < 0)
@ -180,7 +180,7 @@ api_data_get2(clixon_handle h,
} }
/* Check for depth attribute */ /* Check for depth attribute */
if ((attr = cvec_find_str(qvec, "depth")) != NULL){ if ((attr = cvec_find_str(qvec, "depth")) != NULL){
clixon_debug(CLIXON_DBG_CLIENT, "depth=%s", attr); clixon_debug(CLIXON_DBG_RESTCONF, "depth=%s", attr);
if (strcmp(attr, "unbounded") != 0){ if (strcmp(attr, "unbounded") != 0){
char *reason = NULL; char *reason = NULL;
if ((ret = parse_int32(attr, &depth, &reason)) < 0){ if ((ret = parse_int32(attr, &depth, &reason)) < 0){
@ -198,11 +198,11 @@ api_data_get2(clixon_handle h,
} }
} }
if ((attr = cvec_find_str(qvec, "with-defaults")) != NULL){ if ((attr = cvec_find_str(qvec, "with-defaults")) != NULL){
clixon_debug(CLIXON_DBG_CLIENT, "with_defaults=%s", attr); clixon_debug(CLIXON_DBG_RESTCONF, "with_defaults=%s", attr);
defaults = attr; defaults = attr;
} }
clixon_debug(CLIXON_DBG_CLIENT, "path:%s", xpath); clixon_debug(CLIXON_DBG_RESTCONF, "path:%s", xpath);
ret = clicon_rpc_get(h, xpath, nsc, content, depth, defaults, &xret); ret = clicon_rpc_get(h, xpath, nsc, content, depth, defaults, &xret);
if (ret < 0){ if (ret < 0){
@ -217,7 +217,7 @@ api_data_get2(clixon_handle h,
*/ */
#if 0 /* DEBUG */ #if 0 /* DEBUG */
if (clixon_debug_get()) if (clixon_debug_get())
clixon_debug_xml(CLIXON_DBG_CLIENT, xret, "xret:"); clixon_debug_xml(CLIXON_DBG_RESTCONF, xret, "xret:");
#endif #endif
/* Check if error return */ /* Check if error return */
if ((xe = xpath_first(xret, NULL, "//rpc-error")) != NULL){ if ((xe = xpath_first(xret, NULL, "//rpc-error")) != NULL){
@ -292,7 +292,7 @@ api_data_get2(clixon_handle h,
break; break;
} }
} }
clixon_debug(CLIXON_DBG_CLIENT, "cbuf:%s", cbuf_get(cbx)); clixon_debug(CLIXON_DBG_RESTCONF, "cbuf:%s", cbuf_get(cbx));
if (restconf_reply_header(req, "Content-Type", "%s", restconf_media_int2str(media_out)) < 0) if (restconf_reply_header(req, "Content-Type", "%s", restconf_media_int2str(media_out)) < 0)
goto done; goto done;
if (restconf_reply_header(req, "Cache-Control", "no-cache") < 0) if (restconf_reply_header(req, "Cache-Control", "no-cache") < 0)
@ -303,7 +303,7 @@ api_data_get2(clixon_handle h,
ok: ok:
retval = 0; retval = 0;
done: done:
clixon_debug(CLIXON_DBG_CLIENT, "retval:%d", retval); clixon_debug(CLIXON_DBG_RESTCONF, "retval:%d", retval);
if (xpath) if (xpath)
free(xpath); free(xpath);
if (nscd) if (nscd)
@ -380,7 +380,7 @@ api_data_pagination(clixon_handle h,
char *where; char *where;
char *ns; char *ns;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_RESTCONF, "");
if ((yspec = clicon_dbspec_yang(h)) == NULL){ if ((yspec = clicon_dbspec_yang(h)) == NULL){
clixon_err(OE_FATAL, 0, "No DB_SPEC"); clixon_err(OE_FATAL, 0, "No DB_SPEC");
goto done; goto done;
@ -429,7 +429,7 @@ api_data_pagination(clixon_handle h,
/* Check for content attribute */ /* Check for content attribute */
if ((attr = cvec_find_str(qvec, "content")) != NULL){ if ((attr = cvec_find_str(qvec, "content")) != NULL){
clixon_debug(CLIXON_DBG_CLIENT, "content=%s", attr); clixon_debug(CLIXON_DBG_RESTCONF, "content=%s", attr);
if ((int)(content = netconf_content_str2int(attr)) == -1){ if ((int)(content = netconf_content_str2int(attr)) == -1){
if (netconf_bad_attribute_xml(&xerr, "application", if (netconf_bad_attribute_xml(&xerr, "application",
"content", "Unrecognized value of content attribute") < 0) "content", "Unrecognized value of content attribute") < 0)
@ -443,7 +443,7 @@ api_data_pagination(clixon_handle h,
goto ok; goto ok;
} }
} }
clixon_debug(CLIXON_DBG_CLIENT, "path:%s", xpath); clixon_debug(CLIXON_DBG_RESTCONF, "path:%s", xpath);
if (content != CONTENT_CONFIG && content != CONTENT_NONCONFIG && content != CONTENT_ALL){ if (content != CONTENT_CONFIG && content != CONTENT_NONCONFIG && content != CONTENT_ALL){
clixon_err(OE_XML, EINVAL, "Invalid content attribute %d", content); clixon_err(OE_XML, EINVAL, "Invalid content attribute %d", content);
goto done; goto done;
@ -451,7 +451,7 @@ api_data_pagination(clixon_handle h,
/* Clixon extensions and collection attributes */ /* Clixon extensions and collection attributes */
/* Check for depth attribute */ /* Check for depth attribute */
if ((attr = cvec_find_str(qvec, "depth")) != NULL){ if ((attr = cvec_find_str(qvec, "depth")) != NULL){
clixon_debug(CLIXON_DBG_CLIENT, "depth=%s", attr); clixon_debug(CLIXON_DBG_RESTCONF, "depth=%s", attr);
if (strcmp(attr, "unbounded") != 0){ if (strcmp(attr, "unbounded") != 0){
char *reason = NULL; char *reason = NULL;
if ((ret = parse_int32(attr, &depth, &reason)) < 0){ if ((ret = parse_int32(attr, &depth, &reason)) < 0){
@ -506,7 +506,7 @@ api_data_pagination(clixon_handle h,
* We need to cut that tree to only the object. * We need to cut that tree to only the object.
*/ */
#if 0 /* DEBUG */ #if 0 /* DEBUG */
clixon_debug_xml(CLIXON_DBG_CLIENT, xret, "xret:"); clixon_debug_xml(CLIXON_DBG_RESTCONF, xret, "xret:");
#endif #endif
/* Check if error return */ /* Check if error return */
if ((xe = xpath_first(xret, NULL, "//rpc-error")) != NULL){ if ((xe = xpath_first(xret, NULL, "//rpc-error")) != NULL){
@ -555,7 +555,7 @@ api_data_pagination(clixon_handle h,
default: default:
break; break;
} }
clixon_debug(CLIXON_DBG_CLIENT, "cbuf:%s", cbuf_get(cbx)); clixon_debug(CLIXON_DBG_RESTCONF, "cbuf:%s", cbuf_get(cbx));
if (restconf_reply_header(req, "Content-Type", "%s", restconf_media_int2str(media_out)) < 0) if (restconf_reply_header(req, "Content-Type", "%s", restconf_media_int2str(media_out)) < 0)
goto done; goto done;
if (restconf_reply_header(req, "Cache-Control", "no-cache") < 0) if (restconf_reply_header(req, "Cache-Control", "no-cache") < 0)
@ -566,7 +566,7 @@ api_data_pagination(clixon_handle h,
ok: ok:
retval = 0; retval = 0;
done: done:
clixon_debug(CLIXON_DBG_CLIENT, "retval:%d", retval); clixon_debug(CLIXON_DBG_RESTCONF, "retval:%d", retval);
if (xpath) if (xpath)
free(xpath); free(xpath);
if (nsc) if (nsc)
@ -718,7 +718,7 @@ api_operations_get(clixon_handle h,
cxobj *xt = NULL; cxobj *xt = NULL;
int i; int i;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_RESTCONF, "");
yspec = clicon_dbspec_yang(h); yspec = clicon_dbspec_yang(h);
if ((cbx = cbuf_new()) == NULL) if ((cbx = cbuf_new()) == NULL)
goto done; goto done;
@ -786,7 +786,7 @@ api_operations_get(clixon_handle h,
// ok: // ok:
retval = 0; retval = 0;
done: done:
clixon_debug(CLIXON_DBG_CLIENT, "retval:%d", retval); clixon_debug(CLIXON_DBG_RESTCONF, "retval:%d", retval);
if (cbx) if (cbx)
cbuf_free(cbx); cbuf_free(cbx);
if (xt) if (xt)

View file

@ -635,7 +635,7 @@ yang_patch_do_edit(clixon_handle h,
yang_stmt *ybot = NULL; yang_stmt *ybot = NULL;
yang_stmt *ymod; yang_stmt *ymod;
clixon_debug_xml(CLIXON_DBG_CLIENT, xn, "%d xn:", __LINE__); clixon_debug_xml(CLIXON_DBG_RESTCONF, xn, "%d xn:", __LINE__);
/* Create cbufs:s */ /* Create cbufs:s */
if ((simple_patch_request_uri = cbuf_new()) == NULL){ if ((simple_patch_request_uri = cbuf_new()) == NULL){
clixon_err(OE_UNIX, errno, "cbuf_new"); clixon_err(OE_UNIX, errno, "cbuf_new");
@ -778,7 +778,7 @@ api_data_yang_patch(clixon_handle h,
size_t veclen; size_t veclen;
cxobj **vec = NULL; cxobj **vec = NULL;
clixon_debug(CLIXON_DBG_CLIENT, "api_path:\"%s\"", api_path0); clixon_debug(CLIXON_DBG_RESTCONF, "api_path:\"%s\"", api_path0);
if ((yspec = clicon_dbspec_yang(h)) == NULL){ if ((yspec = clicon_dbspec_yang(h)) == NULL){
clixon_err(OE_FATAL, 0, "No DB_SPEC"); clixon_err(OE_FATAL, 0, "No DB_SPEC");
goto done; goto done;

View file

@ -189,8 +189,8 @@ api_data_post(clixon_handle h,
int nrchildren0 = 0; int nrchildren0 = 0;
yang_bind yb; yang_bind yb;
clixon_debug(CLIXON_DBG_CLIENT, "api_path:\"%s\"", api_path); clixon_debug(CLIXON_DBG_RESTCONF, "api_path:\"%s\"", api_path);
clixon_debug(CLIXON_DBG_CLIENT, "data:\"%s\"", data); clixon_debug(CLIXON_DBG_RESTCONF, "data:\"%s\"", data);
if ((yspec = clicon_dbspec_yang(h)) == NULL){ if ((yspec = clicon_dbspec_yang(h)) == NULL){
clixon_err(OE_FATAL, 0, "No DB_SPEC"); clixon_err(OE_FATAL, 0, "No DB_SPEC");
goto done; goto done;
@ -276,7 +276,7 @@ api_data_post(clixon_handle h,
/* RFC 8040 4.4.1: The message-body MUST contain exactly one instance of the /* RFC 8040 4.4.1: The message-body MUST contain exactly one instance of the
* expected data resource. * expected data resource.
*/ */
clixon_debug(CLIXON_DBG_CLIENT, "nrchildren0: %d", nrchildren0); clixon_debug(CLIXON_DBG_RESTCONF, "nrchildren0: %d", nrchildren0);
if (xml_child_nr_type(xbot, CX_ELMNT) - nrchildren0 != 1){ if (xml_child_nr_type(xbot, CX_ELMNT) - nrchildren0 != 1){
if (netconf_malformed_message_xml(&xerr, "The message-body MUST contain exactly one instance of the expected data resource") < 0) if (netconf_malformed_message_xml(&xerr, "The message-body MUST contain exactly one instance of the expected data resource") < 0)
goto done; goto done;
@ -330,7 +330,7 @@ api_data_post(clixon_handle h,
if (restconf_insert_attributes(xdata, qvec) < 0) if (restconf_insert_attributes(xdata, qvec) < 0)
goto done; goto done;
#if 1 #if 1
clixon_debug_xml(CLIXON_DBG_CLIENT, xdata, "xdata:"); clixon_debug_xml(CLIXON_DBG_RESTCONF, xdata, "xdata:");
#endif #endif
/* Create text buffer for transfer to backend */ /* Create text buffer for transfer to backend */
@ -369,7 +369,7 @@ api_data_post(clixon_handle h,
if (clixon_xml2cbuf(cbx, xtop, 0, 0, NULL, -1, 0) < 0) if (clixon_xml2cbuf(cbx, xtop, 0, 0, NULL, -1, 0) < 0)
goto done; goto done;
cprintf(cbx, "</edit-config></rpc>"); cprintf(cbx, "</edit-config></rpc>");
clixon_debug(CLIXON_DBG_CLIENT, "xml: %s api_path:%s", cbuf_get(cbx), api_path); clixon_debug(CLIXON_DBG_RESTCONF, "xml: %s api_path:%s", cbuf_get(cbx), api_path);
if (clicon_rpc_netconf(h, cbuf_get(cbx), &xret, NULL) < 0) if (clicon_rpc_netconf(h, cbuf_get(cbx), &xret, NULL) < 0)
goto done; goto done;
if ((xe = xpath_first(xret, NULL, "//rpc-error")) != NULL){ if ((xe = xpath_first(xret, NULL, "//rpc-error")) != NULL){
@ -384,7 +384,7 @@ api_data_post(clixon_handle h,
ok: ok:
retval = 0; retval = 0;
done: done:
clixon_debug(CLIXON_DBG_CLIENT, "retval:%d", retval); clixon_debug(CLIXON_DBG_RESTCONF, "retval:%d", retval);
if (xret) if (xret)
xml_free(xret); xml_free(xret);
if (xerr) if (xerr)
@ -441,7 +441,7 @@ api_operations_post_input(clixon_handle h,
int ret; int ret;
restconf_media media_in; restconf_media media_in;
clixon_debug(CLIXON_DBG_CLIENT, "%s", data); clixon_debug(CLIXON_DBG_RESTCONF, "%s", data);
if ((cbret = cbuf_new()) == NULL){ if ((cbret = cbuf_new()) == NULL){
clixon_err(OE_UNIX, 0, "cbuf_new"); clixon_err(OE_UNIX, 0, "cbuf_new");
goto done; goto done;
@ -491,7 +491,7 @@ api_operations_post_input(clixon_handle h,
* <data><input xmlns="urn:example:clixon">...</input></data> * <data><input xmlns="urn:example:clixon">...</input></data>
*/ */
#if 1 #if 1
clixon_debug_xml(CLIXON_DBG_CLIENT, xdata, "xdata:"); clixon_debug_xml(CLIXON_DBG_RESTCONF, xdata, "xdata:");
#endif #endif
/* Validate that exactly only <input> tag */ /* Validate that exactly only <input> tag */
if ((xinput = xml_child_i_type(xdata, 0, CX_ELMNT)) == NULL || if ((xinput = xml_child_i_type(xdata, 0, CX_ELMNT)) == NULL ||
@ -509,7 +509,7 @@ api_operations_post_input(clixon_handle h,
goto done; goto done;
goto fail; goto fail;
} }
// clixon_debug(CLIXON_DBG_CLIENT, "input validation passed"); // clixon_debug(CLIXON_DBG_RESTCONF, "input validation passed");
/* Add all input under <rpc>path */ /* Add all input under <rpc>path */
x = NULL; x = NULL;
while ((x = xml_child_i_type(xinput, 0, CX_ELMNT)) != NULL) while ((x = xml_child_i_type(xinput, 0, CX_ELMNT)) != NULL)
@ -520,7 +520,7 @@ api_operations_post_input(clixon_handle h,
// ok: // ok:
retval = 1; retval = 1;
done: done:
clixon_debug(CLIXON_DBG_CLIENT, "retval: %d", retval); clixon_debug(CLIXON_DBG_RESTCONF, "retval: %d", retval);
if (cbret) if (cbret)
cbuf_free(cbret); cbuf_free(cbret);
if (xerr) if (xerr)
@ -567,7 +567,7 @@ api_operations_post_output(clixon_handle h,
cxobj *xok; cxobj *xok;
int isempty; int isempty;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_RESTCONF, "");
/* Validate that exactly only <rpc-reply> tag with exactly one element child */ /* Validate that exactly only <rpc-reply> tag with exactly one element child */
if ((xoutput = xml_child_i_type(xret, 0, CX_ELMNT)) == NULL || if ((xoutput = xml_child_i_type(xret, 0, CX_ELMNT)) == NULL ||
strcmp(xml_name(xoutput),"rpc-reply") != 0 strcmp(xml_name(xoutput),"rpc-reply") != 0
@ -588,7 +588,7 @@ api_operations_post_output(clixon_handle h,
xml_name_set(xoutput, "output"); xml_name_set(xoutput, "output");
/* xoutput should now look: <output><x xmlns="uri">0</x></output> */ /* xoutput should now look: <output><x xmlns="uri">0</x></output> */
#if 1 #if 1
clixon_debug_xml(CLIXON_DBG_CLIENT, xoutput, "xoutput:"); clixon_debug_xml(CLIXON_DBG_RESTCONF, xoutput, "xoutput:");
#endif #endif
/* Remove original netconf default namespace. Somewhat unsure what "output" belongs to? */ /* Remove original netconf default namespace. Somewhat unsure what "output" belongs to? */
if ((xa = xml_find_type(xoutput, NULL, "xmlns", CX_ATTR)) != NULL) if ((xa = xml_find_type(xoutput, NULL, "xmlns", CX_ATTR)) != NULL)
@ -649,7 +649,7 @@ api_operations_post_output(clixon_handle h,
*xoutputp = xoutput; *xoutputp = xoutput;
retval = 1; retval = 1;
done: done:
clixon_debug(CLIXON_DBG_CLIENT, "retval: %d", retval); clixon_debug(CLIXON_DBG_RESTCONF, "retval: %d", retval);
if (xerr) if (xerr)
xml_free(xerr); xml_free(xerr);
return retval; return retval;
@ -722,7 +722,7 @@ api_operations_post(clixon_handle h,
char *namespace = NULL; char *namespace = NULL;
int nr = 0; int nr = 0;
clixon_debug(CLIXON_DBG_CLIENT, "json:\"%s\" path:\"%s\"", data, api_path); clixon_debug(CLIXON_DBG_RESTCONF, "json:\"%s\" path:\"%s\"", data, api_path);
/* 1. Initialize */ /* 1. Initialize */
if ((yspec = clicon_dbspec_yang(h)) == NULL){ if ((yspec = clicon_dbspec_yang(h)) == NULL){
clixon_err(OE_FATAL, 0, "No DB_SPEC"); clixon_err(OE_FATAL, 0, "No DB_SPEC");
@ -792,7 +792,7 @@ api_operations_post(clixon_handle h,
* XML: <input xmlns="uri"><x>0</x></input> * XML: <input xmlns="uri"><x>0</x></input>
*/ */
namespace = xml_find_type_value(xbot, NULL, "xmlns", CX_ATTR); namespace = xml_find_type_value(xbot, NULL, "xmlns", CX_ATTR);
clixon_debug(CLIXON_DBG_CLIENT, "4. Parse input data: %s", data); clixon_debug(CLIXON_DBG_RESTCONF, "4. Parse input data: %s", data);
if (data && strlen(data)){ if (data && strlen(data)){
if ((ret = api_operations_post_input(h, req, data, yspec, yrpc, xbot, if ((ret = api_operations_post_input(h, req, data, yspec, yrpc, xbot,
pretty, media_out)) < 0) pretty, media_out)) < 0)
@ -803,7 +803,7 @@ api_operations_post(clixon_handle h,
/* Here xtop is: /* Here xtop is:
<rpc username="foo"><myfn xmlns="uri"><x>42</x></myfn></rpc> */ <rpc username="foo"><myfn xmlns="uri"><x>42</x></myfn></rpc> */
#if 1 #if 1
clixon_debug_xml(CLIXON_DBG_CLIENT, xtop, ". Translate input args:"); clixon_debug_xml(CLIXON_DBG_RESTCONF, xtop, ". Translate input args:");
#endif #endif
/* 6. Validate outgoing RPC and fill in defaults */ /* 6. Validate outgoing RPC and fill in defaults */
if ((ret = xml_bind_yang_rpc(h, xtop, yspec, &xerr)) < 0) /* */ if ((ret = xml_bind_yang_rpc(h, xtop, yspec, &xerr)) < 0) /* */
@ -824,7 +824,7 @@ api_operations_post(clixon_handle h,
* <rpc username="foo"><myfn xmlns="uri"><x>42</x><y>99</y></myfn></rpc> * <rpc username="foo"><myfn xmlns="uri"><x>42</x><y>99</y></myfn></rpc>
*/ */
#if 0 #if 0
clixon_debug_xml(CLIXON_DBG_CLIENT, xtop, "6. Validate and defaults:"); clixon_debug_xml(CLIXON_DBG_RESTCONF, xtop, "6. Validate and defaults:");
#endif #endif
/* 7. Send to RPC handler, either local or backend /* 7. Send to RPC handler, either local or backend
* Note (1) xtop is <rpc><method> xbot is <method> * Note (1) xtop is <rpc><method> xbot is <method>
@ -865,7 +865,7 @@ api_operations_post(clixon_handle h,
* <rpc-reply><x xmlns="uri">0</x></rpc-reply> * <rpc-reply><x xmlns="uri">0</x></rpc-reply>
*/ */
#if 1 #if 1
clixon_debug_xml(CLIXON_DBG_CLIENT, xret, "Receive reply:"); clixon_debug_xml(CLIXON_DBG_RESTCONF, xret, "Receive reply:");
#endif #endif
youtput = yang_find(yrpc, Y_OUTPUT, NULL); youtput = yang_find(yrpc, Y_OUTPUT, NULL);
if ((ret = api_operations_post_output(h, req, xret, yspec, youtput, namespace, if ((ret = api_operations_post_output(h, req, xret, yspec, youtput, namespace,
@ -897,7 +897,7 @@ api_operations_post(clixon_handle h,
ok: ok:
retval = 0; retval = 0;
done: done:
clixon_debug(CLIXON_DBG_CLIENT, "retval:%d", retval); clixon_debug(CLIXON_DBG_RESTCONF, "retval:%d", retval);
if (prefix) if (prefix)
free(prefix); free(prefix);
if (id) if (id)

View file

@ -192,7 +192,7 @@ restconf_conn_new(clixon_handle h,
rc->rc_callhome = rsock->rs_callhome; rc->rc_callhome = rsock->rs_callhome;
rc->rc_socket = rsock; rc->rc_socket = rsock;
INSQ(rc, rsock->rs_conns); INSQ(rc, rsock->rs_conns);
clixon_debug(CLIXON_DBG_CLIENT, "%p", rc); clixon_debug(CLIXON_DBG_RESTCONF, "%p", rc);
return rc; return rc;
} }
@ -208,7 +208,7 @@ restconf_conn_free(restconf_conn *rc)
restconf_socket *rsock; restconf_socket *rsock;
restconf_conn *rc1; restconf_conn *rc1;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_RESTCONF, "");
if (rc == NULL){ if (rc == NULL){
clixon_err(OE_RESTCONF, EINVAL, "rc is NULL"); clixon_err(OE_RESTCONF, EINVAL, "rc is NULL");
goto done; goto done;
@ -416,7 +416,7 @@ native_buf_write(clixon_handle h,
} }
memcpy(dbgstr, buf, sz); memcpy(dbgstr, buf, sz);
dbgstr[sz] = '\0'; dbgstr[sz] = '\0';
clixon_debug(CLIXON_DBG_CLIENT, "%s buflen:%zu buf:\n%s", callfn, buflen, dbgstr); clixon_debug(CLIXON_DBG_RESTCONF, "%s buflen:%zu buf:\n%s", callfn, buflen, dbgstr);
free(dbgstr); free(dbgstr);
} }
while (totlen < buflen){ while (totlen < buflen){
@ -430,7 +430,7 @@ native_buf_write(clixon_handle h,
goto closed; /* Close socket and ssl */ goto closed; /* Close socket and ssl */
} }
else if (er == EAGAIN){ else if (er == EAGAIN){
clixon_debug(CLIXON_DBG_CLIENT, "write EAGAIN"); clixon_debug(CLIXON_DBG_RESTCONF, "write EAGAIN");
usleep(10000); usleep(10000);
continue; continue;
} }
@ -451,7 +451,7 @@ native_buf_write(clixon_handle h,
if ((len = write(rc->rc_s, buf+totlen, buflen-totlen)) < 0){ if ((len = write(rc->rc_s, buf+totlen, buflen-totlen)) < 0){
switch (errno){ switch (errno){
case EAGAIN: /* Operation would block */ case EAGAIN: /* Operation would block */
clixon_debug(CLIXON_DBG_CLIENT, "write EAGAIN"); clixon_debug(CLIXON_DBG_RESTCONF, "write EAGAIN");
usleep(10000); usleep(10000);
continue; continue;
break; break;
@ -471,7 +471,7 @@ native_buf_write(clixon_handle h,
} /* while */ } /* while */
retval = 1; retval = 1;
done: done:
clixon_debug(CLIXON_DBG_CLIENT, "retval:%d", retval); clixon_debug(CLIXON_DBG_RESTCONF, "retval:%d", retval);
return retval; return retval;
closed: closed:
retval = 0; retval = 0;
@ -498,7 +498,7 @@ native_send_badrequest(clixon_handle h,
int retval = -1; int retval = -1;
cbuf *cb = NULL; cbuf *cb = NULL;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_RESTCONF, "");
if ((cb = cbuf_new()) == NULL){ if ((cb = cbuf_new()) == NULL){
clixon_err(OE_UNIX, errno, "cbuf_new"); clixon_err(OE_UNIX, errno, "cbuf_new");
goto done; goto done;
@ -570,7 +570,7 @@ read_ssl(restconf_conn *rc,
if ((*np = SSL_read(rc->rc_ssl, buf, sz)) <= 0){ if ((*np = SSL_read(rc->rc_ssl, buf, sz)) <= 0){
sslerr = SSL_get_error(rc->rc_ssl, *np); sslerr = SSL_get_error(rc->rc_ssl, *np);
clixon_debug(CLIXON_DBG_CLIENT, "SSL_read() n:%zd errno:%d sslerr:%d", *np, errno, sslerr); clixon_debug(CLIXON_DBG_RESTCONF, "SSL_read() n:%zd errno:%d sslerr:%d", *np, errno, sslerr);
switch (sslerr){ switch (sslerr){
case SSL_ERROR_WANT_READ: /* 2 */ case SSL_ERROR_WANT_READ: /* 2 */
/* SSL_ERROR_WANT_READ is returned when the last operation was a read operation /* SSL_ERROR_WANT_READ is returned when the last operation was a read operation
@ -578,7 +578,7 @@ read_ssl(restconf_conn *rc,
* That is, it can happen if restconf_socket_init() below is called * That is, it can happen if restconf_socket_init() below is called
* with SOCK_NONBLOCK * with SOCK_NONBLOCK
*/ */
clixon_debug(CLIXON_DBG_CLIENT, "SSL_read SSL_ERROR_WANT_READ"); clixon_debug(CLIXON_DBG_RESTCONF, "SSL_read SSL_ERROR_WANT_READ");
usleep(1000); usleep(1000);
*again = 1; *again = 1;
break; break;
@ -593,7 +593,7 @@ read_ssl(restconf_conn *rc,
} }
retval = 0; retval = 0;
// done: // done:
clixon_debug(CLIXON_DBG_CLIENT, "retval:%d", retval); clixon_debug(CLIXON_DBG_RESTCONF, "retval:%d", retval);
return retval; return retval;
} }
@ -623,14 +623,14 @@ read_regular(restconf_conn *rc,
if ((*np = read(rc->rc_s, buf, sz)) < 0){ /* XXX atomicio ? */ if ((*np = read(rc->rc_s, buf, sz)) < 0){ /* XXX atomicio ? */
switch(errno){ switch(errno){
case ECONNRESET:/* Connection reset by peer */ case ECONNRESET:/* Connection reset by peer */
clixon_debug(CLIXON_DBG_CLIENT, "%d Connection reset by peer", rc->rc_s); clixon_debug(CLIXON_DBG_RESTCONF, "%d Connection reset by peer", rc->rc_s);
if (restconf_close_ssl_socket(rc, __FUNCTION__, 0) < 0) if (restconf_close_ssl_socket(rc, __FUNCTION__, 0) < 0)
goto done; goto done;
retval = 0; /* Close socket and ssl */ retval = 0; /* Close socket and ssl */
goto done; goto done;
break; break;
case EAGAIN: case EAGAIN:
clixon_debug(CLIXON_DBG_CLIENT, "read EAGAIN"); clixon_debug(CLIXON_DBG_RESTCONF, "read EAGAIN");
usleep(1000); usleep(1000);
*again = 1; *again = 1;
break; break;
@ -886,7 +886,7 @@ restconf_http2_process(restconf_conn *rc,
int ret; int ret;
nghttp2_error ngerr; nghttp2_error ngerr;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_RESTCONF, "");
if (rc->rc_exit){ /* Server-initiated exit for http/2 */ if (rc->rc_exit){ /* Server-initiated exit for http/2 */
if ((ngerr = nghttp2_session_terminate_session(rc->rc_ngsession, 0)) < 0){ if ((ngerr = nghttp2_session_terminate_session(rc->rc_ngsession, 0)) < 0){
clixon_err(OE_NGHTTP2, ngerr, "nghttp2_session_terminate_session %d", ngerr); clixon_err(OE_NGHTTP2, ngerr, "nghttp2_session_terminate_session %d", ngerr);
@ -913,7 +913,7 @@ restconf_http2_process(restconf_conn *rc,
} }
retval = 1; retval = 1;
done: done:
clixon_debug(CLIXON_DBG_CLIENT, "retval:%d", retval); clixon_debug(CLIXON_DBG_RESTCONF, "retval:%d", retval);
return retval; return retval;
} }
#endif /* HAVE_LIBNGHTTP2 */ #endif /* HAVE_LIBNGHTTP2 */
@ -961,7 +961,7 @@ restconf_connection(int s,
int readmore = 1; int readmore = 1;
int ret; int ret;
clixon_debug(CLIXON_DBG_CLIENT, "%d", s); clixon_debug(CLIXON_DBG_RESTCONF, "%d", s);
if ((rc = (restconf_conn*)arg) == NULL){ if ((rc = (restconf_conn*)arg) == NULL){
clixon_err(OE_RESTCONF, EINVAL, "arg is NULL"); clixon_err(OE_RESTCONF, EINVAL, "arg is NULL");
goto done; goto done;
@ -972,7 +972,7 @@ restconf_connection(int s,
} }
gettimeofday(&rc->rc_t, NULL); /* activity timer */ gettimeofday(&rc->rc_t, NULL); /* activity timer */
while (readmore) { while (readmore) {
clixon_debug(CLIXON_DBG_CLIENT, "readmore"); clixon_debug(CLIXON_DBG_RESTCONF, "readmore");
readmore = 0; readmore = 0;
/* Example: curl -Ssik -u wilma:bar -X GET https://localhost/restconf/data/example:x */ /* Example: curl -Ssik -u wilma:bar -X GET https://localhost/restconf/data/example:x */
if (rc->rc_ssl){ if (rc->rc_ssl){
@ -985,11 +985,11 @@ restconf_connection(int s,
if (ret == 0) if (ret == 0)
goto ok; /* abort here */ goto ok; /* abort here */
} }
clixon_debug(CLIXON_DBG_CLIENT, "read:%zd", n); clixon_debug(CLIXON_DBG_RESTCONF, "read:%zd", n);
if (readmore) if (readmore)
continue; continue;
if (n == 0){ if (n == 0){
clixon_debug(CLIXON_DBG_CLIENT, "n=0 closing socket"); clixon_debug(CLIXON_DBG_RESTCONF, "n=0 closing socket");
if (restconf_close_ssl_socket(rc, __FUNCTION__, 0) < 0) if (restconf_close_ssl_socket(rc, __FUNCTION__, 0) < 0)
goto done; goto done;
rc = NULL; rc = NULL;
@ -1029,7 +1029,7 @@ restconf_connection(int s,
ok: ok:
retval = 0; retval = 0;
done: done:
clixon_debug(CLIXON_DBG_CLIENT, "retval:%d", retval); clixon_debug(CLIXON_DBG_RESTCONF, "retval:%d", retval);
return retval; return retval;
} /* restconf_connection */ } /* restconf_connection */
@ -1053,7 +1053,7 @@ restconf_connection_close1(restconf_conn *rc)
goto done; goto done;
} }
rsock = rc->rc_socket; rsock = rc->rc_socket;
clixon_debug(CLIXON_DBG_CLIENT, "\"%s\"", rsock->rs_description); clixon_debug(CLIXON_DBG_RESTCONF, "\"%s\"", rsock->rs_description);
if (close(rc->rc_s) < 0){ if (close(rc->rc_s) < 0){
clixon_err(OE_UNIX, errno, "close"); clixon_err(OE_UNIX, errno, "close");
goto done; goto done;
@ -1068,7 +1068,7 @@ restconf_connection_close1(restconf_conn *rc)
} }
retval = 0; retval = 0;
done: done:
clixon_debug(CLIXON_DBG_CLIENT, "retval:%d", retval); clixon_debug(CLIXON_DBG_RESTCONF, "retval:%d", retval);
return retval; return retval;
} }
@ -1092,13 +1092,13 @@ restconf_close_ssl_socket(restconf_conn *rc,
int sslerr; int sslerr;
int er; int er;
clixon_debug(CLIXON_DBG_CLIENT, "%s", callfn); clixon_debug(CLIXON_DBG_RESTCONF, "%s", callfn);
if (rc->rc_ssl != NULL){ if (rc->rc_ssl != NULL){
if (!dontshutdown && if (!dontshutdown &&
(ret = SSL_shutdown(rc->rc_ssl)) < 0){ (ret = SSL_shutdown(rc->rc_ssl)) < 0){
er = errno; er = errno;
sslerr = SSL_get_error(rc->rc_ssl, ret); sslerr = SSL_get_error(rc->rc_ssl, ret);
clixon_debug(CLIXON_DBG_CLIENT, "errno:%s(%d) sslerr:%d", strerror(er), er, sslerr); clixon_debug(CLIXON_DBG_RESTCONF, "errno:%s(%d) sslerr:%d", strerror(er), er, sslerr);
if (sslerr == SSL_ERROR_SSL || /* 1 */ if (sslerr == SSL_ERROR_SSL || /* 1 */
sslerr == SSL_ERROR_ZERO_RETURN){ /* 6 */ sslerr == SSL_ERROR_ZERO_RETURN){ /* 6 */
} }
@ -1126,7 +1126,7 @@ restconf_close_ssl_socket(restconf_conn *rc,
goto done; goto done;
retval = 0; retval = 0;
done: done:
clixon_debug(CLIXON_DBG_CLIENT, "retval:%d", retval); clixon_debug(CLIXON_DBG_RESTCONF, "retval:%d", retval);
return retval; return retval;
} }
@ -1150,7 +1150,7 @@ ssl_alpn_check(clixon_handle h,
int retval = -1; int retval = -1;
cbuf *cberr = NULL; cbuf *cberr = NULL;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_RESTCONF, "");
/* Alternatively, call restconf_str2proto but alpn is not a proper string */ /* Alternatively, call restconf_str2proto but alpn is not a proper string */
if (alpn && alpnlen == 8 && memcmp("http/1.1", alpn, 8) == 0){ if (alpn && alpnlen == 8 && memcmp("http/1.1", alpn, 8) == 0){
*proto = HTTP_11; *proto = HTTP_11;
@ -1202,7 +1202,7 @@ ssl_alpn_check(clixon_handle h,
} }
retval = 1; retval = 1;
done: done:
clixon_debug(CLIXON_DBG_CLIENT, "retval:%d", retval); clixon_debug(CLIXON_DBG_RESTCONF, "retval:%d", retval);
if (cberr) if (cberr)
cbuf_free(cberr); cbuf_free(cberr);
return retval; return retval;
@ -1240,7 +1240,7 @@ restconf_ssl_accept_client(clixon_handle h,
unsigned int alpnlen = 0; unsigned int alpnlen = 0;
restconf_http_proto proto = HTTP_11; /* Non-SSL negotiation NYI */ restconf_http_proto proto = HTTP_11; /* Non-SSL negotiation NYI */
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_RESTCONF, "");
#ifdef HAVE_LIBNGHTTP2 #ifdef HAVE_LIBNGHTTP2
#ifndef HAVE_HTTP1 #ifndef HAVE_HTTP1
proto = HTTP_2; /* If nghttp2 only let default be 2.0 */ proto = HTTP_2; /* If nghttp2 only let default be 2.0 */
@ -1255,13 +1255,13 @@ restconf_ssl_accept_client(clixon_handle h,
*/ */
if ((rc = restconf_conn_new(h, s, rsock)) == NULL) if ((rc = restconf_conn_new(h, s, rsock)) == NULL)
goto done; goto done;
clixon_debug(CLIXON_DBG_CLIENT, "s:%d", rc->rc_s); clixon_debug(CLIXON_DBG_RESTCONF, "s:%d", rc->rc_s);
if (rsock->rs_ssl){ if (rsock->rs_ssl){
if ((rc->rc_ssl = SSL_new(rn->rn_ctx)) == NULL){ if ((rc->rc_ssl = SSL_new(rn->rn_ctx)) == NULL){
clixon_err(OE_SSL, 0, "SSL_new"); clixon_err(OE_SSL, 0, "SSL_new");
goto done; goto done;
} }
clixon_debug(CLIXON_DBG_CLIENT, "SSL_new(%p)", rc->rc_ssl); clixon_debug(CLIXON_DBG_RESTCONF, "SSL_new(%p)", rc->rc_ssl);
/* CCL_CTX_set_verify already set, need not call SSL_set_verify again for this server /* CCL_CTX_set_verify already set, need not call SSL_set_verify again for this server
*/ */
/* X509_CHECK_FLAG_NO_WILDCARDS disables wildcard expansion */ /* X509_CHECK_FLAG_NO_WILDCARDS disables wildcard expansion */
@ -1298,11 +1298,11 @@ restconf_ssl_accept_client(clixon_handle h,
* Both error cases: Call SSL_get_error() with the return value ret * Both error cases: Call SSL_get_error() with the return value ret
*/ */
if ((ret = SSL_accept(rc->rc_ssl)) != 1) { if ((ret = SSL_accept(rc->rc_ssl)) != 1) {
clixon_debug(CLIXON_DBG_CLIENT, "SSL_accept() ret:%d errno:%d", ret, er=errno); clixon_debug(CLIXON_DBG_RESTCONF, "SSL_accept() ret:%d errno:%d", ret, er=errno);
e = SSL_get_error(rc->rc_ssl, ret); e = SSL_get_error(rc->rc_ssl, ret);
switch (e){ switch (e){
case SSL_ERROR_SSL: /* 1 */ case SSL_ERROR_SSL: /* 1 */
clixon_debug(CLIXON_DBG_CLIENT, "SSL_ERROR_SSL (non-ssl message on ssl socket)"); clixon_debug(CLIXON_DBG_RESTCONF, "SSL_ERROR_SSL (non-ssl message on ssl socket)");
#ifdef HTTP_ON_HTTPS_REPLY #ifdef HTTP_ON_HTTPS_REPLY
SSL_free(rc->rc_ssl); SSL_free(rc->rc_ssl);
rc->rc_ssl = NULL; rc->rc_ssl = NULL;
@ -1320,7 +1320,7 @@ restconf_ssl_accept_client(clixon_handle h,
consult errno for details. If this error occurs then no further I/O consult errno for details. If this error occurs then no further I/O
operations should be performed on the connection and SSL_shutdown() must operations should be performed on the connection and SSL_shutdown() must
not be called.*/ not be called.*/
clixon_debug(CLIXON_DBG_CLIENT, "SSL_accept() SSL_ERROR_SYSCALL %d", er); clixon_debug(CLIXON_DBG_RESTCONF, "SSL_accept() SSL_ERROR_SYSCALL %d", er);
if (restconf_close_ssl_socket(rc, __FUNCTION__, 1) < 0) if (restconf_close_ssl_socket(rc, __FUNCTION__, 1) < 0)
goto done; goto done;
rc = NULL; rc = NULL;
@ -1333,7 +1333,7 @@ restconf_ssl_accept_client(clixon_handle h,
* That is, it can happen if restconf_socket_init() below is called * That is, it can happen if restconf_socket_init() below is called
* with SOCK_NONBLOCK * with SOCK_NONBLOCK
*/ */
clixon_debug(CLIXON_DBG_CLIENT, "write SSL_ERROR_WANT_READ"); clixon_debug(CLIXON_DBG_RESTCONF, "write SSL_ERROR_WANT_READ");
usleep(10000); usleep(10000);
readmore = 1; readmore = 1;
break; break;
@ -1367,7 +1367,7 @@ restconf_ssl_accept_client(clixon_handle h,
if (ret == 0){ if (ret == 0){
goto closed; goto closed;
} }
clixon_debug(CLIXON_DBG_CLIENT, "proto:%s", restconf_proto2str(proto)); clixon_debug(CLIXON_DBG_RESTCONF, "proto:%s", restconf_proto2str(proto));
#if 0 /* Seems too early to fail here, instead let authentication callback deal with this */ #if 0 /* Seems too early to fail here, instead let authentication callback deal with this */
/* For client-cert authentication, check if any certs are present, /* For client-cert authentication, check if any certs are present,
@ -1404,7 +1404,7 @@ restconf_ssl_accept_client(clixon_handle h,
const char *peername = SSL_get0_peername(rc->rc_ssl); const char *peername = SSL_get0_peername(rc->rc_ssl);
if (peername != NULL) { if (peername != NULL) {
/* Name checks were in scope and matched the peername */ /* Name checks were in scope and matched the peername */
clixon_debug(CLIXON_DBG_CLIENT, "peername:%s", peername); clixon_debug(CLIXON_DBG_RESTCONF, "peername:%s", peername);
} }
} }
#if 0 #if 0
@ -1457,7 +1457,7 @@ restconf_ssl_accept_client(clixon_handle h,
*rcp = rc; *rcp = rc;
retval = 1; /* OK, up */ retval = 1; /* OK, up */
done: done:
clixon_debug(CLIXON_DBG_CLIENT, "retval:%d", retval); clixon_debug(CLIXON_DBG_RESTCONF, "retval:%d", retval);
if (name) if (name)
free(name); free(name);
return retval; return retval;
@ -1528,7 +1528,7 @@ restconf_idle_cb(int fd,
clixon_err(OE_YANG, EINVAL, "rsock is NULL"); clixon_err(OE_YANG, EINVAL, "rsock is NULL");
goto done; goto done;
} }
clixon_debug(CLIXON_DBG_CLIENT, "\"%s\"", rsock->rs_description); clixon_debug(CLIXON_DBG_RESTCONF, "\"%s\"", rsock->rs_description);
if (rc->rc_callhome && rsock->rs_periodic && rc->rc_s > 0 && rsock->rs_idle_timeout){ if (rc->rc_callhome && rsock->rs_periodic && rc->rc_s > 0 && rsock->rs_idle_timeout){
gettimeofday(&now, NULL); gettimeofday(&now, NULL);
timersub(&now, &rc->rc_t, &td); /* Last packet timestamp */ timersub(&now, &rc->rc_t, &td); /* Last packet timestamp */
@ -1539,7 +1539,7 @@ restconf_idle_cb(int fd,
else{ else{
to.tv_sec = rsock->rs_idle_timeout; to.tv_sec = rsock->rs_idle_timeout;
timeradd(&now, &to, &tn); timeradd(&now, &to, &tn);
clixon_debug(CLIXON_DBG_CLIENT, "now:%lu timeout:%lu.%lu", clixon_debug(CLIXON_DBG_RESTCONF, "now:%lu timeout:%lu.%lu",
now.tv_sec, tn.tv_sec, tn.tv_usec); now.tv_sec, tn.tv_sec, tn.tv_usec);
if (restconf_idle_timer_set(tn, rc, rsock->rs_description) < 0) if (restconf_idle_timer_set(tn, rc, rsock->rs_description) < 0)
goto done; goto done;
@ -1585,7 +1585,7 @@ restconf_idle_timer(restconf_conn *rc)
clixon_err(OE_YANG, EINVAL, "rsock is NULL or not periodic"); clixon_err(OE_YANG, EINVAL, "rsock is NULL or not periodic");
goto done; goto done;
} }
clixon_debug(CLIXON_DBG_CLIENT, "\"%s\" register", rsock->rs_description); clixon_debug(CLIXON_DBG_RESTCONF, "\"%s\" register", rsock->rs_description);
gettimeofday(&now, NULL); gettimeofday(&now, NULL);
to.tv_sec = rsock->rs_idle_timeout; to.tv_sec = rsock->rs_idle_timeout;
timeradd(&now, &to, &t); timeradd(&now, &to, &t);
@ -1623,7 +1623,7 @@ restconf_callhome_cb(int fd,
clixon_err(OE_YANG, EINVAL, "rsock is NULL"); clixon_err(OE_YANG, EINVAL, "rsock is NULL");
goto done; goto done;
} }
clixon_debug(CLIXON_DBG_CLIENT, "\"%s\"", rsock->rs_description); clixon_debug(CLIXON_DBG_RESTCONF, "\"%s\"", rsock->rs_description);
h = rsock->rs_h; h = rsock->rs_h;
/* Already computed in restconf_socket_init, could be saved in rsock? */ /* Already computed in restconf_socket_init, could be saved in rsock? */
if (clixon_inet2sin(rsock->rs_addrtype, rsock->rs_addrstr, rsock->rs_port, sa, &sa_len) < 0) if (clixon_inet2sin(rsock->rs_addrtype, rsock->rs_addrstr, rsock->rs_port, sa, &sa_len) < 0)
@ -1633,7 +1633,7 @@ restconf_callhome_cb(int fd,
goto done; goto done;
} }
if (connect(s, sa, sa_len) < 0){ if (connect(s, sa, sa_len) < 0){
clixon_debug(CLIXON_DBG_CLIENT, "connect %hu fail:%d %s", rsock->rs_port, errno, strerror(errno)); clixon_debug(CLIXON_DBG_RESTCONF, "connect %hu fail:%d %s", rsock->rs_port, errno, strerror(errno));
close(s); close(s);
rsock->rs_attempts++; rsock->rs_attempts++;
/* Fail: Initiate new timer */ /* Fail: Initiate new timer */
@ -1641,7 +1641,7 @@ restconf_callhome_cb(int fd,
goto done; goto done;
} }
else { else {
clixon_debug(CLIXON_DBG_CLIENT, "connect %hu OK", rsock->rs_port); clixon_debug(CLIXON_DBG_RESTCONF, "connect %hu OK", rsock->rs_port);
rsock->rs_attempts = 0; rsock->rs_attempts = 0;
if ((ret = restconf_ssl_accept_client(h, s, rsock, &rc)) < 0) if ((ret = restconf_ssl_accept_client(h, s, rsock, &rc)) < 0)
goto done; goto done;
@ -1686,7 +1686,7 @@ restconf_callhome_timer(restconf_socket *rsock,
clixon_err(OE_YANG, EINVAL, "rsock is NULL or not callhome"); clixon_err(OE_YANG, EINVAL, "rsock is NULL or not callhome");
goto done; goto done;
} }
clixon_debug(CLIXON_DBG_CLIENT, "\"%s\"", rsock->rs_description); clixon_debug(CLIXON_DBG_RESTCONF, "\"%s\"", rsock->rs_description);
if (!rsock->rs_callhome) if (!rsock->rs_callhome)
goto ok; /* shouldnt happen */ goto ok; /* shouldnt happen */
gettimeofday(&now, NULL); gettimeofday(&now, NULL);
@ -1714,9 +1714,9 @@ restconf_callhome_timer(restconf_socket *rsock,
} }
cprintf(cb, "restconf callhome timer %s", rsock->rs_description); cprintf(cb, "restconf callhome timer %s", rsock->rs_description);
if (rsock->rs_description) if (rsock->rs_description)
clixon_debug(CLIXON_DBG_CLIENT, "registering \"%s\": +%lu", rsock->rs_description, t.tv_sec-now.tv_sec); clixon_debug(CLIXON_DBG_RESTCONF, "registering \"%s\": +%lu", rsock->rs_description, t.tv_sec-now.tv_sec);
else else
clixon_debug(CLIXON_DBG_CLIENT, "%lu", t.tv_sec); clixon_debug(CLIXON_DBG_RESTCONF, "%lu", t.tv_sec);
/* Should be only place restconf_callhome_cb is registered */ /* Should be only place restconf_callhome_cb is registered */
if (clixon_event_reg_timeout(t, if (clixon_event_reg_timeout(t,
restconf_callhome_cb, restconf_callhome_cb,

View file

@ -120,7 +120,7 @@ clixon_nghttp2_log_cb(void *handle,
int suberr, int suberr,
cbuf *cb) cbuf *cb)
{ {
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_RESTCONF, "");
cprintf(cb, "Fatal error: %s", nghttp2_strerror(suberr)); cprintf(cb, "Fatal error: %s", nghttp2_strerror(suberr));
return 0; return 0;
} }
@ -132,7 +132,7 @@ nghttp2_print_header(const uint8_t *name,
const uint8_t *value, const uint8_t *value,
size_t valuelen) size_t valuelen)
{ {
clixon_debug(CLIXON_DBG_CLIENT, "%s %s", name, value); clixon_debug(CLIXON_DBG_RESTCONF, "%s %s", name, value);
} }
/*! Print HTTP headers to |f|. /*! Print HTTP headers to |f|.
@ -178,20 +178,20 @@ session_send_callback(nghttp2_session *session,
int s; int s;
int sslerr; int sslerr;
clixon_debug(CLIXON_DBG_CLIENT, "buflen:%zu", buflen); clixon_debug(CLIXON_DBG_RESTCONF, "buflen:%zu", buflen);
s = rc->rc_s; s = rc->rc_s;
while (totlen < buflen){ while (totlen < buflen){
if (rc->rc_ssl){ if (rc->rc_ssl){
if ((len = SSL_write(rc->rc_ssl, buf+totlen, buflen-totlen)) <= 0){ if ((len = SSL_write(rc->rc_ssl, buf+totlen, buflen-totlen)) <= 0){
er = errno; er = errno;
sslerr = SSL_get_error(rc->rc_ssl, len); sslerr = SSL_get_error(rc->rc_ssl, len);
clixon_debug(CLIXON_DBG_CLIENT, "SSL_write: errno:%s(%d) sslerr:%d", clixon_debug(CLIXON_DBG_RESTCONF, "SSL_write: errno:%s(%d) sslerr:%d",
strerror(er), strerror(er),
er, er,
sslerr); sslerr);
switch (sslerr){ switch (sslerr){
case SSL_ERROR_WANT_WRITE: /* 3 */ case SSL_ERROR_WANT_WRITE: /* 3 */
clixon_debug(CLIXON_DBG_CLIENT, "write SSL_ERROR_WANT_WRITE"); clixon_debug(CLIXON_DBG_RESTCONF, "write SSL_ERROR_WANT_WRITE");
usleep(1000); usleep(1000);
continue; continue;
break; break;
@ -205,7 +205,7 @@ session_send_callback(nghttp2_session *session,
* platforms, linux here, freebsd want_write, or possibly differnt * platforms, linux here, freebsd want_write, or possibly differnt
* ssl lib versions? * ssl lib versions?
*/ */
clixon_debug(CLIXON_DBG_CLIENT, "write EAGAIN"); clixon_debug(CLIXON_DBG_RESTCONF, "write EAGAIN");
usleep(1000); usleep(1000);
continue; continue;
} }
@ -225,7 +225,7 @@ session_send_callback(nghttp2_session *session,
else{ else{
if ((len = write(s, buf+totlen, buflen-totlen)) < 0){ if ((len = write(s, buf+totlen, buflen-totlen)) < 0){
if (errno == EAGAIN){ if (errno == EAGAIN){
clixon_debug(CLIXON_DBG_CLIENT, "write EAGAIN"); clixon_debug(CLIXON_DBG_RESTCONF, "write EAGAIN");
usleep(10000); usleep(10000);
continue; continue;
} }
@ -252,10 +252,10 @@ session_send_callback(nghttp2_session *session,
retval = 0; retval = 0;
done: done:
if (retval < 0){ if (retval < 0){
clixon_debug(CLIXON_DBG_CLIENT, "retval:%d", retval); clixon_debug(CLIXON_DBG_RESTCONF, "retval:%d", retval);
return retval; return retval;
} }
clixon_debug(CLIXON_DBG_CLIENT, "retval:%zd", totlen); clixon_debug(CLIXON_DBG_RESTCONF, "retval:%zd", totlen);
return retval == 0 ? totlen : retval; return retval == 0 ? totlen : retval;
} }
@ -269,7 +269,7 @@ recv_callback(nghttp2_session *session,
void *user_data) void *user_data)
{ {
// restconf_conn *rc = (restconf_conn *)user_data; // restconf_conn *rc = (restconf_conn *)user_data;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_RESTCONF, "");
return 0; return 0;
} }
@ -294,7 +294,7 @@ restconf_nghttp2_path(restconf_stream_data *sd)
cvec *cvv = NULL; cvec *cvv = NULL;
char *cn; char *cn;
clixon_debug(CLIXON_DBG_CLIENT, "------------"); clixon_debug(CLIXON_DBG_RESTCONF, "------------");
rc = sd->sd_conn; rc = sd->sd_conn;
if ((h = rc->rc_h) == NULL){ if ((h = rc->rc_h) == NULL){
clixon_err(OE_RESTCONF, EINVAL, "arg is NULL"); clixon_err(OE_RESTCONF, EINVAL, "arg is NULL");
@ -346,7 +346,7 @@ restconf_nghttp2_path(restconf_stream_data *sd)
goto done; goto done;
retval = 0; retval = 0;
done: done:
clixon_debug(CLIXON_DBG_CLIENT, "retval:%d", retval); clixon_debug(CLIXON_DBG_RESTCONF, "retval:%d", retval);
if (cvv) if (cvv)
cvec_free(cvv); cvec_free(cvv);
if (oneline) if (oneline)
@ -390,7 +390,7 @@ restconf_sd_read(nghttp2_session *session,
#endif #endif
assert(cbuf_len(cb) > sd->sd_body_offset); assert(cbuf_len(cb) > sd->sd_body_offset);
remain = cbuf_len(cb) - sd->sd_body_offset; remain = cbuf_len(cb) - sd->sd_body_offset;
clixon_debug(CLIXON_DBG_CLIENT, "length:%zu totlen:%zu, offset:%zu remain:%zu", clixon_debug(CLIXON_DBG_RESTCONF, "length:%zu totlen:%zu, offset:%zu remain:%zu",
length, length,
cbuf_len(cb), cbuf_len(cb),
sd->sd_body_offset, sd->sd_body_offset,
@ -405,7 +405,7 @@ restconf_sd_read(nghttp2_session *session,
} }
memcpy(buf, cbuf_get(cb) + sd->sd_body_offset, len); memcpy(buf, cbuf_get(cb) + sd->sd_body_offset, len);
sd->sd_body_offset += len; sd->sd_body_offset += len;
clixon_debug(CLIXON_DBG_CLIENT, "retval:%zu", len); clixon_debug(CLIXON_DBG_RESTCONF, "retval:%zu", len);
return len; return len;
} }
@ -433,7 +433,7 @@ restconf_submit_response(nghttp2_session *session,
hdr = &hdrs[i++]; hdr = &hdrs[i++];
hdr->name = (uint8_t*)":status"; hdr->name = (uint8_t*)":status";
snprintf(valstr, 15, "%u", sd->sd_code); snprintf(valstr, 15, "%u", sd->sd_code);
clixon_debug(CLIXON_DBG_CLIENT, "status %d", sd->sd_code); clixon_debug(CLIXON_DBG_RESTCONF, "status %d", sd->sd_code);
hdr->value = (uint8_t*)valstr; hdr->value = (uint8_t*)valstr;
hdr->namelen = strlen(":status"); hdr->namelen = strlen(":status");
hdr->valuelen = strlen(valstr); hdr->valuelen = strlen(valstr);
@ -443,7 +443,7 @@ restconf_submit_response(nghttp2_session *session,
while ((cv = cvec_each(sd->sd_outp_hdrs, cv)) != NULL){ while ((cv = cvec_each(sd->sd_outp_hdrs, cv)) != NULL){
hdr = &hdrs[i++]; hdr = &hdrs[i++];
hdr->name = (uint8_t*)cv_name_get(cv); hdr->name = (uint8_t*)cv_name_get(cv);
clixon_debug(CLIXON_DBG_CLIENT, "hdr: %s", hdr->name); clixon_debug(CLIXON_DBG_RESTCONF, "hdr: %s", hdr->name);
hdr->value = (uint8_t*)cv_string_get(cv); hdr->value = (uint8_t*)cv_string_get(cv);
hdr->namelen = strlen(cv_name_get(cv)); hdr->namelen = strlen(cv_name_get(cv));
hdr->valuelen = strlen(cv_string_get(cv)); hdr->valuelen = strlen(cv_string_get(cv));
@ -458,7 +458,7 @@ restconf_submit_response(nghttp2_session *session,
} }
retval = 0; retval = 0;
done: done:
clixon_debug(CLIXON_DBG_CLIENT, "retval:%d", retval); clixon_debug(CLIXON_DBG_RESTCONF, "retval:%d", retval);
if (hdrs) if (hdrs)
free(hdrs); free(hdrs);
return retval; return retval;
@ -474,7 +474,7 @@ http2_exec(restconf_conn *rc,
{ {
int retval = -1; int retval = -1;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_RESTCONF, "");
if (sd->sd_path){ if (sd->sd_path){
free(sd->sd_path); free(sd->sd_path);
sd->sd_path = NULL; sd->sd_path = NULL;
@ -513,7 +513,7 @@ http2_exec(restconf_conn *rc,
} }
retval = 0; retval = 0;
done: done:
clixon_debug(CLIXON_DBG_CLIENT, "retval:%d", retval); clixon_debug(CLIXON_DBG_RESTCONF, "retval:%d", retval);
return retval; return retval;
} }
@ -529,7 +529,7 @@ on_frame_recv_callback(nghttp2_session *session,
restconf_stream_data *sd = NULL; restconf_stream_data *sd = NULL;
char *query; char *query;
clixon_debug(CLIXON_DBG_CLIENT, "%s %d", clixon_debug(CLIXON_DBG_RESTCONF, "%s %d",
clicon_int2str(nghttp2_frame_type_map, frame->hd.type), clicon_int2str(nghttp2_frame_type_map, frame->hd.type),
frame->hd.stream_id); frame->hd.stream_id);
switch (frame->hd.type) { switch (frame->hd.type) {
@ -571,7 +571,7 @@ on_invalid_frame_recv_callback(nghttp2_session *session,
void *user_data) void *user_data)
{ {
// restconf_conn *rc = (restconf_conn *)user_data; // restconf_conn *rc = (restconf_conn *)user_data;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_RESTCONF, "");
return 0; return 0;
} }
@ -593,7 +593,7 @@ on_data_chunk_recv_callback(nghttp2_session *session,
restconf_conn *rc = (restconf_conn *)user_data; restconf_conn *rc = (restconf_conn *)user_data;
restconf_stream_data *sd; restconf_stream_data *sd;
clixon_debug(CLIXON_DBG_CLIENT, "%d", stream_id); clixon_debug(CLIXON_DBG_RESTCONF, "%d", stream_id);
if ((sd = restconf_stream_find(rc, stream_id)) != NULL){ if ((sd = restconf_stream_find(rc, stream_id)) != NULL){
cbuf_append_buf(sd->sd_indata, (void*)data, len); cbuf_append_buf(sd->sd_indata, (void*)data, len);
} }
@ -608,7 +608,7 @@ before_frame_send_callback(nghttp2_session *session,
void *user_data) void *user_data)
{ {
// restconf_conn *rc = (restconf_conn *)user_data; // restconf_conn *rc = (restconf_conn *)user_data;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_RESTCONF, "");
return 0; return 0;
} }
@ -620,7 +620,7 @@ on_frame_send_callback(nghttp2_session *session,
void *user_data) void *user_data)
{ {
// restconf_conn *rc = (restconf_conn *)user_data; // restconf_conn *rc = (restconf_conn *)user_data;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_RESTCONF, "");
return 0; return 0;
} }
@ -633,7 +633,7 @@ on_frame_not_send_callback(nghttp2_session *session,
void *user_data) void *user_data)
{ {
// restconf_conn *rc = (restconf_conn *)user_data; // restconf_conn *rc = (restconf_conn *)user_data;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_RESTCONF, "");
return 0; return 0;
} }
@ -647,7 +647,7 @@ on_stream_close_callback(nghttp2_session *session,
{ {
// restconf_conn *rc = (restconf_conn *)user_data; // restconf_conn *rc = (restconf_conn *)user_data;
clixon_debug(CLIXON_DBG_CLIENT, "%d %s", error_code, nghttp2_strerror(error_code)); clixon_debug(CLIXON_DBG_RESTCONF, "%d %s", error_code, nghttp2_strerror(error_code));
#if 0 // NOTNEEDED /* XXX think this is not necessary? */ #if 0 // NOTNEEDED /* XXX think this is not necessary? */
if (error_code){ if (error_code){
if (restconf_close_ssl_socket(rc, __FUNCTION__, 0) < 0) if (restconf_close_ssl_socket(rc, __FUNCTION__, 0) < 0)
@ -667,7 +667,7 @@ on_begin_headers_callback(nghttp2_session *session,
restconf_conn *rc = (restconf_conn *)user_data; restconf_conn *rc = (restconf_conn *)user_data;
restconf_stream_data *sd; restconf_stream_data *sd;
clixon_debug(CLIXON_DBG_CLIENT, "%s", clicon_int2str(nghttp2_frame_type_map, frame->hd.type)); clixon_debug(CLIXON_DBG_RESTCONF, "%s", clicon_int2str(nghttp2_frame_type_map, frame->hd.type));
if (frame->hd.type == NGHTTP2_HEADERS && if (frame->hd.type == NGHTTP2_HEADERS &&
frame->headers.cat == NGHTTP2_HCAT_REQUEST) { frame->headers.cat == NGHTTP2_HCAT_REQUEST) {
sd = restconf_stream_data_new(rc, frame->hd.stream_id); sd = restconf_stream_data_new(rc, frame->hd.stream_id);
@ -735,12 +735,12 @@ on_header_callback(nghttp2_session *session,
switch (frame->hd.type){ switch (frame->hd.type){
case NGHTTP2_HEADERS: case NGHTTP2_HEADERS:
assert (frame->headers.cat == NGHTTP2_HCAT_REQUEST); assert (frame->headers.cat == NGHTTP2_HCAT_REQUEST);
clixon_debug(CLIXON_DBG_CLIENT, "HEADERS %s %s", name, value); clixon_debug(CLIXON_DBG_RESTCONF, "HEADERS %s %s", name, value);
if (nghttp2_hdr2clixon(rc->rc_h, (char*)name, (char*)value) < 0) if (nghttp2_hdr2clixon(rc->rc_h, (char*)name, (char*)value) < 0)
goto done; goto done;
break; break;
default: default:
clixon_debug(CLIXON_DBG_CLIENT, "%s %s", clicon_int2str(nghttp2_frame_type_map, frame->hd.type), name); clixon_debug(CLIXON_DBG_RESTCONF, "%s %s", clicon_int2str(nghttp2_frame_type_map, frame->hd.type), name);
break; break;
} }
retval = 0; retval = 0;
@ -758,7 +758,7 @@ select_padding_callback(nghttp2_session *session,
void *user_data) void *user_data)
{ {
// restconf_conn *rc = (restconf_conn *)user_data; // restconf_conn *rc = (restconf_conn *)user_data;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_RESTCONF, "");
return frame->hd.length; return frame->hd.length;
} }
@ -774,7 +774,7 @@ data_source_read_length_callback(nghttp2_session *session,
void *user_data) void *user_data)
{ {
// restconf_conn *rc = (restconf_conn *)user_data; // restconf_conn *rc = (restconf_conn *)user_data;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_RESTCONF, "");
return 0; return 0;
} }
#endif /* NOTUSED */ #endif /* NOTUSED */
@ -790,7 +790,7 @@ on_begin_frame_callback(nghttp2_session *session,
void *user_data) void *user_data)
{ {
// restconf_conn *rc = (restconf_conn *)user_data; // restconf_conn *rc = (restconf_conn *)user_data;
clixon_debug(CLIXON_DBG_CLIENT, "%s", clicon_int2str(nghttp2_frame_type_map, hd->type)); clixon_debug(CLIXON_DBG_RESTCONF, "%s", clicon_int2str(nghttp2_frame_type_map, hd->type));
if (hd->type == NGHTTP2_CONTINUATION) if (hd->type == NGHTTP2_CONTINUATION)
assert(0); assert(0);
return 0; return 0;
@ -810,7 +810,7 @@ send_data_callback(nghttp2_session *session,
void *user_data) void *user_data)
{ {
// restconf_conn *rc = (restconf_conn *)user_data; // restconf_conn *rc = (restconf_conn *)user_data;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_RESTCONF, "");
return 0; return 0;
} }
@ -824,7 +824,7 @@ pack_extension_callback(nghttp2_session *session,
void *user_data) void *user_data)
{ {
// restconf_conn *rc = (restconf_conn *)user_data; // restconf_conn *rc = (restconf_conn *)user_data;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_RESTCONF, "");
return 0; return 0;
} }
@ -837,7 +837,7 @@ unpack_extension_callback(nghttp2_session *session,
void *user_data) void *user_data)
{ {
// restconf_conn *rc = (restconf_conn *)user_data; // restconf_conn *rc = (restconf_conn *)user_data;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_RESTCONF, "");
return 0; return 0;
} }
#endif /* NOTUSED */ #endif /* NOTUSED */
@ -852,7 +852,7 @@ on_extension_chunk_recv_callback(nghttp2_session *session,
void *user_data) void *user_data)
{ {
// restconf_conn *rc = (restconf_conn *)user_data; // restconf_conn *rc = (restconf_conn *)user_data;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_RESTCONF, "");
return 0; return 0;
} }
@ -865,7 +865,7 @@ error_callback(nghttp2_session *session,
void *user_data) void *user_data)
{ {
// restconf_conn *rc = (restconf_conn *)user_data; // restconf_conn *rc = (restconf_conn *)user_data;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_RESTCONF, "");
return 0; return 0;
} }
@ -880,7 +880,7 @@ error_callback2(nghttp2_session *session,
void *user_data) void *user_data)
{ {
// restconf_conn *rc = (restconf_conn *)user_data; // restconf_conn *rc = (restconf_conn *)user_data;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_RESTCONF, "");
clixon_err(OE_NGHTTP2, lib_error_code, "%s", msg); clixon_err(OE_NGHTTP2, lib_error_code, "%s", msg);
return 0; return 0;
} }
@ -903,7 +903,7 @@ http2_recv(restconf_conn *rc,
int retval = -1; int retval = -1;
nghttp2_error ngerr; nghttp2_error ngerr;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_RESTCONF, "");
if (rc->rc_ngsession == NULL){ if (rc->rc_ngsession == NULL){
/* http2_session_init not called */ /* http2_session_init not called */
clixon_err(OE_RESTCONF, EINVAL, "No nghttp2 session"); clixon_err(OE_RESTCONF, EINVAL, "No nghttp2 session");
@ -940,7 +940,7 @@ http2_recv(restconf_conn *rc,
} }
retval = 1; /* OK */ retval = 1; /* OK */
done: done:
clixon_debug(CLIXON_DBG_CLIENT, "retval:%d", retval); clixon_debug(CLIXON_DBG_RESTCONF, "retval:%d", retval);
return retval; return retval;
fail: fail:
retval = 0; retval = 0;
@ -957,7 +957,7 @@ http2_send_server_connection(restconf_conn *rc)
,{NGHTTP2_SETTINGS_ENABLE_PUSH, 0}}; ,{NGHTTP2_SETTINGS_ENABLE_PUSH, 0}};
nghttp2_error ngerr; nghttp2_error ngerr;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_RESTCONF, "");
if ((ngerr = nghttp2_submit_settings(rc->rc_ngsession, if ((ngerr = nghttp2_submit_settings(rc->rc_ngsession,
NGHTTP2_FLAG_NONE, NGHTTP2_FLAG_NONE,
iv, iv,
@ -971,7 +971,7 @@ http2_send_server_connection(restconf_conn *rc)
} }
retval = 0; retval = 0;
done: done:
clixon_debug(CLIXON_DBG_CLIENT, "retval:%d", retval); clixon_debug(CLIXON_DBG_RESTCONF, "retval:%d", retval);
return retval; return retval;
} }

View file

@ -116,7 +116,7 @@ api_well_known(clixon_handle h,
cbuf *cb = NULL; cbuf *cb = NULL;
int head; int head;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_RESTCONF, "");
if (req == NULL){ if (req == NULL){
errno = EINVAL; errno = EINVAL;
goto done; goto done;
@ -179,7 +179,7 @@ api_root_restconf_exact(clixon_handle h,
cbuf *cb = NULL; cbuf *cb = NULL;
int head; int head;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_RESTCONF, "");
head = strcmp(request_method, "HEAD") == 0; head = strcmp(request_method, "HEAD") == 0;
if (!head && strcmp(request_method, "GET") != 0){ if (!head && strcmp(request_method, "GET") != 0){
if (restconf_method_notallowed(h, req, "GET", pretty, media_out) < 0) if (restconf_method_notallowed(h, req, "GET", pretty, media_out) < 0)
@ -248,7 +248,7 @@ api_operational_state(clixon_handle h,
restconf_media media_out) restconf_media media_out)
{ {
clixon_debug(CLIXON_DBG_CLIENT, "request method:%s", request_method); clixon_debug(CLIXON_DBG_RESTCONF, "request method:%s", request_method);
/* We are not implementing this method at this time, 20201105 despite it /* We are not implementing this method at this time, 20201105 despite it
* being mandatory https://tools.ietf.org/html/rfc8527#section-3.1 */ * being mandatory https://tools.ietf.org/html/rfc8527#section-3.1 */
@ -274,7 +274,7 @@ api_yang_library_version(clixon_handle h,
cbuf *cb = NULL; cbuf *cb = NULL;
yang_stmt *yspec; yang_stmt *yspec;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_RESTCONF, "");
if (restconf_reply_header(req, "Content-Type", "%s", restconf_media_int2str(media_out)) < 0) if (restconf_reply_header(req, "Content-Type", "%s", restconf_media_int2str(media_out)) < 0)
goto done; goto done;
if (restconf_reply_header(req, "Cache-Control", "no-cache") < 0) if (restconf_reply_header(req, "Cache-Control", "no-cache") < 0)
@ -349,9 +349,9 @@ api_data(clixon_handle h,
char *request_method; char *request_method;
cxobj *xerr = NULL; cxobj *xerr = NULL;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_RESTCONF, "");
request_method = restconf_param_get(h, "REQUEST_METHOD"); request_method = restconf_param_get(h, "REQUEST_METHOD");
clixon_debug(CLIXON_DBG_CLIENT, "method:%s", request_method); clixon_debug(CLIXON_DBG_RESTCONF, "method:%s", request_method);
/* https://tools.ietf.org/html/rfc8527#section-3.2 */ /* https://tools.ietf.org/html/rfc8527#section-3.2 */
/* We assume that dynamic datastores are read only at this time 20201105 */ /* We assume that dynamic datastores are read only at this time 20201105 */
@ -399,7 +399,7 @@ api_data(clixon_handle h,
goto done; goto done;
retval = api_return_err0(h, req, xerr, pretty, media_out, 0); retval = api_return_err0(h, req, xerr, pretty, media_out, 0);
} }
clixon_debug(CLIXON_DBG_CLIENT, "retval:%d", retval); clixon_debug(CLIXON_DBG_RESTCONF, "retval:%d", retval);
done: done:
if (xerr) if (xerr)
xml_free(xerr); xml_free(xerr);
@ -435,7 +435,7 @@ api_operations(clixon_handle h,
int retval = -1; int retval = -1;
cxobj *xerr = NULL; cxobj *xerr = NULL;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_RESTCONF, "");
if (strcmp(request_method, "GET")==0) if (strcmp(request_method, "GET")==0)
retval = api_operations_get(h, req, path, pi, qvec, data, pretty, media_out); retval = api_operations_get(h, req, path, pi, qvec, data, pretty, media_out);
else if (strcmp(request_method, "POST")==0) else if (strcmp(request_method, "POST")==0)
@ -482,7 +482,7 @@ api_root_restconf(clixon_handle h,
int ret; int ret;
cxobj *xerr = NULL; cxobj *xerr = NULL;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_RESTCONF, "");
if (req == NULL){ if (req == NULL){
errno = EINVAL; errno = EINVAL;
goto done; goto done;
@ -512,7 +512,7 @@ api_root_restconf(clixon_handle h,
goto ok; goto ok;
} }
} }
clixon_debug(CLIXON_DBG_CLIENT, "ACCEPT: %s %s", media_str, restconf_media_int2str(media_out)); clixon_debug(CLIXON_DBG_RESTCONF, "ACCEPT: %s %s", media_str, restconf_media_int2str(media_out));
if ((pvec = clicon_strsep(path, "/", &pn)) == NULL) if ((pvec = clicon_strsep(path, "/", &pn)) == NULL)
goto done; goto done;
@ -543,14 +543,14 @@ api_root_restconf(clixon_handle h,
goto done; goto done;
goto ok; goto ok;
} }
clixon_debug(CLIXON_DBG_CLIENT, "api_resource=%s", api_resource); clixon_debug(CLIXON_DBG_RESTCONF, "api_resource=%s", api_resource);
if (uri_str2cvec(path, '/', '=', 1, &pcvec) < 0) /* rest url eg /album=ricky/foo */ if (uri_str2cvec(path, '/', '=', 1, &pcvec) < 0) /* rest url eg /album=ricky/foo */
goto done; goto done;
/* data */ /* data */
if ((cb = restconf_get_indata(req)) == NULL) /* XXX NYI ACTUALLY not always needed, do this later? */ if ((cb = restconf_get_indata(req)) == NULL) /* XXX NYI ACTUALLY not always needed, do this later? */
goto done; goto done;
indata = cbuf_get(cb); indata = cbuf_get(cb);
clixon_debug(CLIXON_DBG_CLIENT, "DATA=%s", indata); clixon_debug(CLIXON_DBG_RESTCONF, "DATA=%s", indata);
/* If present, check credentials. See "plugin_credentials" in plugin /* If present, check credentials. See "plugin_credentials" in plugin
* retvals: * retvals:
@ -627,7 +627,7 @@ api_root_restconf(clixon_handle h,
ok: ok:
retval = 0; retval = 0;
done: done:
clixon_debug(CLIXON_DBG_CLIENT, "retval:%d", retval); clixon_debug(CLIXON_DBG_RESTCONF, "retval:%d", retval);
#ifdef WITH_RESTCONF_FCGI #ifdef WITH_RESTCONF_FCGI
if (cb) if (cb)
cbuf_free(cb); cbuf_free(cb);

View file

@ -215,16 +215,16 @@ restconf_stream_cb(int s,
int pretty = 0; /* XXX should be via arg */ int pretty = 0; /* XXX should be via arg */
int ret; int ret;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_STREAM, "");
/* get msg (this is the reason this function is called) */ /* get msg (this is the reason this function is called) */
if (clicon_msg_rcv(s, NULL, 0, &reply, &eof) < 0){ if (clicon_msg_rcv(s, NULL, 0, &reply, &eof) < 0){
clixon_debug(CLIXON_DBG_CLIENT, "msg_rcv error"); clixon_debug(CLIXON_DBG_STREAM, "msg_rcv error");
goto done; goto done;
} }
clixon_debug(CLIXON_DBG_CLIENT, "msg: %s", reply?reply->op_body:"null"); clixon_debug(CLIXON_DBG_STREAM, "msg: %s", reply?reply->op_body:"null");
/* handle close from remote end: this will exit the client */ /* handle close from remote end: this will exit the client */
if (eof){ if (eof){
clixon_debug(CLIXON_DBG_CLIENT, "eof"); clixon_debug(CLIXON_DBG_STREAM, "eof");
clixon_err(OE_PROTO, ESHUTDOWN, "Socket unexpected close"); clixon_err(OE_PROTO, ESHUTDOWN, "Socket unexpected close");
errno = ESHUTDOWN; errno = ESHUTDOWN;
FCGX_FPrintF(r->out, "SHUTDOWN\r\n"); FCGX_FPrintF(r->out, "SHUTDOWN\r\n");
@ -266,7 +266,7 @@ restconf_stream_cb(int s,
ok: ok:
retval = 0; retval = 0;
done: done:
clixon_debug(CLIXON_DBG_CLIENT, "retval: %d", retval); clixon_debug(CLIXON_DBG_STREAM, "retval: %d", retval);
if (xtop != NULL) if (xtop != NULL)
xml_free(xtop); xml_free(xtop);
if (reply) if (reply)
@ -306,7 +306,7 @@ restconf_stream(clixon_handle h,
cg_var *cv; cg_var *cv;
char *vname; char *vname;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_STREAM, "");
*sp = -1; *sp = -1;
if ((cb = cbuf_new()) == NULL){ if ((cb = cbuf_new()) == NULL){
clixon_err(OE_XML, errno, "cbuf_new"); clixon_err(OE_XML, errno, "cbuf_new");
@ -353,7 +353,7 @@ restconf_stream(clixon_handle h,
ok: ok:
retval = 0; retval = 0;
done: done:
clixon_debug(CLIXON_DBG_CLIENT, "retval: %d", retval); clixon_debug(CLIXON_DBG_STREAM, "retval: %d", retval);
if (xret) if (xret)
xml_free(xret); xml_free(xret);
if (cb) if (cb)
@ -376,9 +376,9 @@ stream_checkuplink(int s,
{ {
FCGX_Request *r = (FCGX_Request *)arg; FCGX_Request *r = (FCGX_Request *)arg;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_STREAM, "");
if (FCGX_GetError(r->out) != 0){ /* break loop */ if (FCGX_GetError(r->out) != 0){ /* break loop */
clixon_debug(CLIXON_DBG_CLIENT, "FCGX_GetError upstream"); clixon_debug(CLIXON_DBG_STREAM, "FCGX_GetError upstream");
clixon_exit_set(1); clixon_exit_set(1);
} }
return 0; return 0;
@ -392,9 +392,9 @@ stream_timeout(int s,
struct timeval t1; struct timeval t1;
FCGX_Request *r = (FCGX_Request *)arg; FCGX_Request *r = (FCGX_Request *)arg;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_STREAM, "");
if (FCGX_GetError(r->out) != 0){ /* break loop */ if (FCGX_GetError(r->out) != 0){ /* break loop */
clixon_debug(CLIXON_DBG_CLIENT, "FCGX_GetError upstream"); clixon_debug(CLIXON_DBG_STREAM, "FCGX_GetError upstream");
clixon_exit_set(1); clixon_exit_set(1);
} }
else{ else{
@ -442,7 +442,7 @@ api_stream(clixon_handle h,
struct stream_child *sc; struct stream_child *sc;
#endif #endif
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_STREAM, "");
streampath = clicon_option_str(h, "CLICON_STREAM_PATH"); streampath = clicon_option_str(h, "CLICON_STREAM_PATH");
if ((path = restconf_uripath(h)) == NULL) if ((path = restconf_uripath(h)) == NULL)
goto done; goto done;
@ -478,7 +478,7 @@ api_stream(clixon_handle h,
goto done; goto done;
goto ok; goto ok;
} }
clixon_debug(CLIXON_DBG_CLIENT, "method=%s", method); clixon_debug(CLIXON_DBG_STREAM, "method=%s", method);
if (uri_str2cvec(path, '/', '=', 1, &pcvec) < 0) /* rest url eg /album=ricky/foo */ if (uri_str2cvec(path, '/', '=', 1, &pcvec) < 0) /* rest url eg /album=ricky/foo */
goto done; goto done;
@ -486,7 +486,7 @@ api_stream(clixon_handle h,
if ((cb = restconf_get_indata(req)) == NULL) if ((cb = restconf_get_indata(req)) == NULL)
goto done; goto done;
indata = cbuf_get(cb); indata = cbuf_get(cb);
clixon_debug(CLIXON_DBG_CLIENT, "DATA=%s", indata); clixon_debug(CLIXON_DBG_STREAM, "DATA=%s", indata);
/* If present, check credentials. See "plugin_credentials" in plugin /* If present, check credentials. See "plugin_credentials" in plugin
* See RFC 8040 section 2.5 * See RFC 8040 section 2.5
@ -522,12 +522,12 @@ api_stream(clixon_handle h,
req, req,
"stream socket") < 0) "stream socket") < 0)
goto done; goto done;
clixon_debug(CLIXON_DBG_CLIENT, "before loop"); clixon_debug(CLIXON_DBG_STREAM, "before loop");
/* Poll upstream errors */ /* Poll upstream errors */
stream_timeout(0, req); stream_timeout(0, req);
/* Start loop */ /* Start loop */
clixon_event_loop(h); clixon_event_loop(h);
clixon_debug(CLIXON_DBG_CLIENT, "after loop"); clixon_debug(CLIXON_DBG_STREAM, "after loop");
clicon_rpc_close_session(h); clicon_rpc_close_session(h);
clixon_event_unreg_fd(s, restconf_stream_cb); clixon_event_unreg_fd(s, restconf_stream_cb);
close(s); close(s);
@ -562,7 +562,7 @@ api_stream(clixon_handle h,
ok: ok:
retval = 0; retval = 0;
done: done:
clixon_debug(CLIXON_DBG_CLIENT, "retval:%d", retval); clixon_debug(CLIXON_DBG_STREAM, "retval:%d", retval);
if (xerr) if (xerr)
xml_free(xerr); xml_free(xerr);
if (pvec) if (pvec)

View file

@ -100,7 +100,7 @@ snmp_common_handler(netsnmp_mib_handler *handler,
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, if (oid_eq(requestvb->name, requestvb->name_length,
(*shp)->sh_oid, (*shp)->sh_oidlen) == 0){ /* equal */ (*shp)->sh_oid, (*shp)->sh_oidlen) == 0){ /* equal */
clixon_debug(CLIXON_DBG_CLIENT, "\"%s\" %s inclusive:%d %s", clixon_debug(CLIXON_DBG_SNMP, "\"%s\" %s inclusive:%d %s",
cbuf_get(cb), cbuf_get(cb),
snmp_msg_int2str(reqinfo->mode), snmp_msg_int2str(reqinfo->mode),
request->inclusive, tablehandler?"table":"scalar"); request->inclusive, tablehandler?"table":"scalar");
@ -110,7 +110,7 @@ snmp_common_handler(netsnmp_mib_handler *handler,
oid_cbuf(cb, requestvb->name, requestvb->name_length); oid_cbuf(cb, requestvb->name, requestvb->name_length);
cprintf(cb, ")"); cprintf(cb, ")");
// nhreg->rootoid same as shp // nhreg->rootoid same as shp
clixon_debug(CLIXON_DBG_CLIENT, "\"%s\" %s inclusive:%d %s", clixon_debug(CLIXON_DBG_SNMP, "\"%s\" %s inclusive:%d %s",
cbuf_get(cb), cbuf_get(cb),
snmp_msg_int2str(reqinfo->mode), snmp_msg_int2str(reqinfo->mode),
request->inclusive, tablehandler?"table":"scalar"); request->inclusive, tablehandler?"table":"scalar");
@ -181,7 +181,7 @@ snmp_scalar_return(cxobj *xs,
if ((ret = type_xml2snmp(xmlstr, &asn1type, &snmpval, &snmplen, &reason)) < 0) if ((ret = type_xml2snmp(xmlstr, &asn1type, &snmpval, &snmplen, &reason)) < 0)
goto done; goto done;
if (ret == 0){ if (ret == 0){
clixon_debug(CLIXON_DBG_CLIENT, "%s", reason); clixon_debug(CLIXON_DBG_SNMP, "%s", reason);
if ((ret = netsnmp_request_set_error(request, SNMP_ERR_WRONGTYPE)) != SNMPERR_SUCCESS){ if ((ret = netsnmp_request_set_error(request, SNMP_ERR_WRONGTYPE)) != SNMPERR_SUCCESS){
clixon_err(OE_SNMP, ret, "netsnmp_request_set_error"); clixon_err(OE_SNMP, ret, "netsnmp_request_set_error");
goto done; goto done;
@ -246,7 +246,7 @@ snmp_scalar_get(clixon_handle h,
cxobj *xcache = NULL; cxobj *xcache = NULL;
char *body = NULL; char *body = NULL;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_SNMP, "");
/* Prepare backend call by constructing namespace context */ /* Prepare backend call by constructing namespace context */
if (xml_nsctx_yang(ys, &nsc) < 0) if (xml_nsctx_yang(ys, &nsc) < 0)
goto done; goto done;
@ -301,7 +301,7 @@ snmp_scalar_get(clixon_handle h,
if ((ret = type_xml2snmp(xmlstr, &asn1type, &snmpval, &snmplen, &reason)) < 0) if ((ret = type_xml2snmp(xmlstr, &asn1type, &snmpval, &snmplen, &reason)) < 0)
goto done; goto done;
if (ret == 0){ if (ret == 0){
clixon_debug(CLIXON_DBG_CLIENT, "%s", reason); clixon_debug(CLIXON_DBG_SNMP, "%s", reason);
if ((ret = netsnmp_request_set_error(request, SNMP_ERR_WRONGTYPE)) != SNMPERR_SUCCESS){ if ((ret = netsnmp_request_set_error(request, SNMP_ERR_WRONGTYPE)) != SNMPERR_SUCCESS){
clixon_err(OE_SNMP, ret, "netsnmp_request_set_error"); clixon_err(OE_SNMP, ret, "netsnmp_request_set_error");
goto done; goto done;
@ -408,7 +408,7 @@ snmp_scalar_set(clixon_handle h,
int asn1_type; int asn1_type;
enum operation_type op = OP_MERGE; enum operation_type op = OP_MERGE;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_SNMP, "");
if ((xtop = xml_new(NETCONF_INPUT_CONFIG, NULL, CX_ELMNT)) == NULL) if ((xtop = xml_new(NETCONF_INPUT_CONFIG, NULL, CX_ELMNT)) == NULL)
goto done; goto done;
if (snmp_yang2xml(xtop, ys, cvk, &xbot) < 0) if (snmp_yang2xml(xtop, ys, cvk, &xbot) < 0)
@ -557,7 +557,7 @@ snmp_cache_set(clixon_handle h,
int isrowstatus = 0; int isrowstatus = 0;
cxobj *xcache = NULL; cxobj *xcache = NULL;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_SNMP, "");
if ((yspec = clicon_dbspec_yang(h)) == NULL){ if ((yspec = clicon_dbspec_yang(h)) == NULL){
clixon_err(OE_FATAL, 0, "No DB_SPEC"); clixon_err(OE_FATAL, 0, "No DB_SPEC");
goto done; goto done;
@ -601,7 +601,7 @@ snmp_cache_set(clixon_handle h,
goto done; goto done;
} }
else if (strcmp(valstr, "destroy") == 0){ else if (strcmp(valstr, "destroy") == 0){
clixon_debug(CLIXON_DBG_CLIENT, "%d", rowstatus); clixon_debug(CLIXON_DBG_SNMP, "%d", rowstatus);
/* Don't send delete to backend if notInService(2) */ /* Don't send delete to backend if notInService(2) */
if (snmp_cache_row_op(h, yang_parent_get(ys), cvk, "delete", rowstatus!=2) < 0) if (snmp_cache_row_op(h, yang_parent_get(ys), cvk, "delete", rowstatus!=2) < 0)
goto done; goto done;
@ -660,7 +660,7 @@ snmp_table_rowstatus_get(clixon_handle h,
cxobj *xr; cxobj *xr;
char *body; char *body;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_SNMP, "");
/* Prepare backend call by constructing namespace context */ /* Prepare backend call by constructing namespace context */
if (xml_nsctx_yang(ys, &nsc) < 0) if (xml_nsctx_yang(ys, &nsc) < 0)
goto done; goto done;
@ -705,7 +705,7 @@ clixon_snmp_scalar_handler1(netsnmp_mib_handler *handler,
netsnmp_variable_list *requestvb = request->requestvb; netsnmp_variable_list *requestvb = request->requestvb;
int ret; int ret;
clixon_debug(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, ""); clixon_debug(CLIXON_DBG_SNMP | CLIXON_DBG_DETAIL, "");
if (snmp_common_handler(handler, nhreg, reqinfo, request, 0, &sh) < 0) if (snmp_common_handler(handler, nhreg, reqinfo, request, 0, &sh) < 0)
goto done; goto done;
/* see net-snmp/agent/snmp_agent.h / net-snmp/library/snmp.h */ /* see net-snmp/agent/snmp_agent.h / net-snmp/library/snmp.h */
@ -727,7 +727,7 @@ clixon_snmp_scalar_handler1(netsnmp_mib_handler *handler,
if (type_yang2asn1(sh->sh_ys, &asn1_type, 0) < 0) if (type_yang2asn1(sh->sh_ys, &asn1_type, 0) < 0)
goto done; goto done;
if (requestvb->type != asn1_type){ if (requestvb->type != asn1_type){
clixon_debug(CLIXON_DBG_CLIENT, "Expected type:%d, got: %d", requestvb->type, asn1_type); clixon_debug(CLIXON_DBG_SNMP, "Expected type:%d, got: %d", requestvb->type, asn1_type);
if ((ret = netsnmp_request_set_error(request, SNMP_ERR_WRONGTYPE)) != SNMPERR_SUCCESS){ if ((ret = netsnmp_request_set_error(request, SNMP_ERR_WRONGTYPE)) != SNMPERR_SUCCESS){
clixon_err(OE_SNMP, ret, "netsnmp_request_set_error"); clixon_err(OE_SNMP, ret, "netsnmp_request_set_error");
goto ok; goto ok;
@ -774,7 +774,7 @@ clixon_snmp_scalar_handler1(netsnmp_mib_handler *handler,
ok: ok:
retval = SNMP_ERR_NOERROR; retval = SNMP_ERR_NOERROR;
done: done:
clixon_debug(CLIXON_DBG_CLIENT, "retval:%d", retval); clixon_debug(CLIXON_DBG_SNMP, "retval:%d", retval);
return retval; return retval;
} }
@ -798,7 +798,7 @@ clixon_snmp_scalar_handler(netsnmp_mib_handler *handler,
netsnmp_request_info *req; netsnmp_request_info *req;
int ret; int ret;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_SNMP, "");
for (req = requests; req; req = req->next){ for (req = requests; req; req = req->next){
ret = clixon_snmp_scalar_handler1(handler, nhreg, reqinfo, req); ret = clixon_snmp_scalar_handler1(handler, nhreg, reqinfo, req);
if (ret != SNMP_ERR_NOERROR){ if (ret != SNMP_ERR_NOERROR){
@ -1037,7 +1037,7 @@ snmp_table_set(clixon_handle h,
goto done; goto done;
requestvb = request->requestvb; requestvb = request->requestvb;
if (requestvb->type != asn1_type){ if (requestvb->type != asn1_type){
clixon_debug(CLIXON_DBG_CLIENT, "Expected type:%d, got: %d", requestvb->type, asn1_type); clixon_debug(CLIXON_DBG_SNMP, "Expected type:%d, got: %d", requestvb->type, asn1_type);
if ((ret = netsnmp_request_set_error(request, SNMP_ERR_WRONGTYPE)) != SNMPERR_SUCCESS){ if ((ret = netsnmp_request_set_error(request, SNMP_ERR_WRONGTYPE)) != SNMPERR_SUCCESS){
clixon_err(OE_SNMP, ret, "netsnmp_request_set_error"); clixon_err(OE_SNMP, ret, "netsnmp_request_set_error");
goto ok; goto ok;
@ -1185,7 +1185,7 @@ snmp_table_getnext(clixon_handle h,
yang_stmt *ynext = NULL; yang_stmt *ynext = NULL;
cbuf *cb = NULL; cbuf *cb = NULL;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_SNMP, "");
if ((ys = yang_parent_get(ylist)) == NULL || if ((ys = yang_parent_get(ylist)) == NULL ||
yang_keyword_get(ys) != Y_CONTAINER){ yang_keyword_get(ys) != Y_CONTAINER){
clixon_err(OE_YANG, EINVAL, "ylist parent is not list"); clixon_err(OE_YANG, EINVAL, "ylist parent is not list");
@ -1247,7 +1247,7 @@ snmp_table_getnext(clixon_handle h,
goto done; goto done;
} }
oid_cbuf(cb, oidnext, oidnextlen); oid_cbuf(cb, oidnext, oidnextlen);
clixon_debug(CLIXON_DBG_CLIENT, "next: %s", cbuf_get(cb)); clixon_debug(CLIXON_DBG_SNMP, "next: %s", cbuf_get(cb));
} }
retval = found; retval = found;
done: done:
@ -1286,11 +1286,11 @@ clixon_snmp_table_handler1(netsnmp_mib_handler *handler,
netsnmp_variable_list *requestvb; netsnmp_variable_list *requestvb;
int err = 0; int err = 0;
clixon_debug(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, ""); clixon_debug(CLIXON_DBG_SNMP | CLIXON_DBG_DETAIL, "");
if ((ret = snmp_common_handler(handler, nhreg, reqinfo, request, 1, &sh)) < 0) if ((ret = snmp_common_handler(handler, nhreg, reqinfo, request, 1, &sh)) < 0)
goto done; goto done;
if (sh->sh_ys == NULL){ if (sh->sh_ys == NULL){
clixon_debug(CLIXON_DBG_CLIENT, "Error table not registered"); clixon_debug(CLIXON_DBG_SNMP, "Error table not registered");
goto ok; goto ok;
} }
requestvb = request->requestvb; requestvb = request->requestvb;
@ -1308,7 +1308,7 @@ clixon_snmp_table_handler1(netsnmp_mib_handler *handler,
clixon_err(OE_SNMP, ret, "netsnmp_request_set_error"); clixon_err(OE_SNMP, ret, "netsnmp_request_set_error");
goto done; goto done;
} }
clixon_debug(CLIXON_DBG_CLIENT, "Nosuchinstance"); clixon_debug(CLIXON_DBG_SNMP, "Nosuchinstance");
} }
break; break;
case MODE_GETNEXT: // 161 case MODE_GETNEXT: // 161
@ -1323,7 +1323,7 @@ clixon_snmp_table_handler1(netsnmp_mib_handler *handler,
clixon_err(OE_SNMP, ret, "netsnmp_request_set_error"); clixon_err(OE_SNMP, ret, "netsnmp_request_set_error");
goto done; goto done;
} }
clixon_debug(CLIXON_DBG_CLIENT, "No such object"); clixon_debug(CLIXON_DBG_SNMP, "No such object");
} }
break; break;
case MODE_SET_RESERVE1: // 0 case MODE_SET_RESERVE1: // 0
@ -1345,7 +1345,7 @@ clixon_snmp_table_handler1(netsnmp_mib_handler *handler,
clixon_err(OE_SNMP, ret, "netsnmp_request_set_error"); clixon_err(OE_SNMP, ret, "netsnmp_request_set_error");
goto done; goto done;
} }
clixon_debug(CLIXON_DBG_CLIENT, "Nosuchinstance"); clixon_debug(CLIXON_DBG_SNMP, "Nosuchinstance");
} }
/* /*
* 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
@ -1408,7 +1408,7 @@ clixon_snmp_table_handler(netsnmp_mib_handler *handler,
netsnmp_request_info *req; netsnmp_request_info *req;
int ret; int ret;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_SNMP, "");
for (req = requests; req; req = req->next){ for (req = requests; req; req = req->next){
ret = clixon_snmp_table_handler1(handler, nhreg, reqinfo, req); ret = clixon_snmp_table_handler1(handler, nhreg, reqinfo, req);
if (ret != SNMP_ERR_NOERROR){ 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) if (yang_extension_value_opt(yref, "smiv2:oid", &exist, &oidstr) < 0)
goto done; goto done;
if (exist == 0 || oidstr == NULL){ if (exist == 0 || oidstr == NULL){
clixon_debug(CLIXON_DBG_CLIENT, "OID not found as SMIv2 yang extension of %s", yang_argument_get(yref)); clixon_debug(CLIXON_DBG_SNMP, "OID not found as SMIv2 yang extension of %s", yang_argument_get(yref));
goto fail; goto fail;
} }
if (snmp_parse_oid(oidstr, objid, objidlen) == NULL){ if (snmp_parse_oid(oidstr, objid, objidlen) == NULL){
@ -649,7 +649,7 @@ type_snmp2xml(yang_stmt *ys,
yang_stmt *yrestype = NULL; yang_stmt *yrestype = NULL;
int ret; int ret;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_SNMP, "");
if (valstr == NULL){ if (valstr == NULL){
clixon_err(OE_UNIX, EINVAL, "valstr is NULL"); clixon_err(OE_UNIX, EINVAL, "valstr is NULL");
goto done; goto done;
@ -733,7 +733,7 @@ type_snmp2xml(yang_stmt *ys,
} }
default: default:
assert(0); // XXX assert(0); // XXX
clixon_debug(CLIXON_DBG_CLIENT, "%s not supported", cv_type2str(cvtype)); clixon_debug(CLIXON_DBG_SNMP, "%s not supported", cv_type2str(cvtype));
if ((ret = netsnmp_request_set_error(request, SNMP_ERR_WRONGTYPE)) != SNMPERR_SUCCESS){ if ((ret = netsnmp_request_set_error(request, SNMP_ERR_WRONGTYPE)) != SNMPERR_SUCCESS){
clixon_err(OE_SNMP, ret, "netsnmp_request_set_error"); clixon_err(OE_SNMP, ret, "netsnmp_request_set_error");
goto done; goto done;
@ -747,7 +747,7 @@ type_snmp2xml(yang_stmt *ys,
} }
retval = 1; retval = 1;
done: done:
clixon_debug(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, "retval:%d", retval); clixon_debug(CLIXON_DBG_SNMP | CLIXON_DBG_DETAIL, "retval:%d", retval);
if (origtype) if (origtype)
free(origtype); free(origtype);
if (cv) if (cv)
@ -794,7 +794,7 @@ type_xml2snmp_pre(char *xmlstr0,
if ((ret = yang_enum2valstr(yrestype, xmlstr0, &str)) < 0) if ((ret = yang_enum2valstr(yrestype, xmlstr0, &str)) < 0)
goto done; goto done;
if (ret == 0){ if (ret == 0){
clixon_debug(CLIXON_DBG_CLIENT, "Invalid enum valstr %s", xmlstr0); clixon_debug(CLIXON_DBG_SNMP, "Invalid enum valstr %s", xmlstr0);
goto fail; goto fail;
} }
} }
@ -820,7 +820,7 @@ type_xml2snmp_pre(char *xmlstr0,
if ((ret = parse_dec64(xmlstr0, cv_dec64_n_get(cv), &num, NULL)) < 0) if ((ret = parse_dec64(xmlstr0, cv_dec64_n_get(cv), &num, NULL)) < 0)
goto done; goto done;
if (ret == 0){ if (ret == 0){
clixon_debug(CLIXON_DBG_CLIENT, "Invalid decimal64 valstr %s", xmlstr0); clixon_debug(CLIXON_DBG_SNMP, "Invalid decimal64 valstr %s", xmlstr0);
goto fail; goto fail;
} }
cv_dec64_i_set(cv, num); cv_dec64_i_set(cv, num);
@ -836,7 +836,7 @@ type_xml2snmp_pre(char *xmlstr0,
} }
retval = 1; retval = 1;
done: done:
clixon_debug(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, "retval:%d", retval); clixon_debug(CLIXON_DBG_SNMP | CLIXON_DBG_DETAIL, "retval:%d", retval);
if (cb) if (cb)
cbuf_free(cb); cbuf_free(cb);
return retval; return retval;
@ -905,7 +905,7 @@ type_xml2snmp(char *snmpstr,
oid oid1[MAX_OID_LEN] = {0,}; oid oid1[MAX_OID_LEN] = {0,};
size_t sz1 = MAX_OID_LEN; size_t sz1 = MAX_OID_LEN;
if (snmp_parse_oid(snmpstr, oid1, &sz1) == NULL){ if (snmp_parse_oid(snmpstr, oid1, &sz1) == NULL){
clixon_debug(CLIXON_DBG_CLIENT, "Failed to parse OID %s", snmpstr); clixon_debug(CLIXON_DBG_SNMP, "Failed to parse OID %s", snmpstr);
goto fail; goto fail;
} }
*snmplen = sizeof(oid)*sz1; *snmplen = sizeof(oid)*sz1;
@ -961,7 +961,7 @@ type_xml2snmp(char *snmpstr,
} }
memset(*snmpval, 0, *snmplen + 1); memset(*snmpval, 0, *snmplen + 1);
if ((eaddr = ether_aton(snmpstr)) == NULL){ if ((eaddr = ether_aton(snmpstr)) == NULL){
clixon_debug(CLIXON_DBG_CLIENT, "ether_aton(%s)", snmpstr); clixon_debug(CLIXON_DBG_SNMP, "ether_aton(%s)", snmpstr);
goto fail; goto fail;
} }
memcpy(*snmpval, eaddr, sizeof(*eaddr)); memcpy(*snmpval, eaddr, sizeof(*eaddr));
@ -981,7 +981,7 @@ type_xml2snmp(char *snmpstr,
} }
retval = 1; retval = 1;
done: done:
clixon_debug(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, "retval:%d", retval); clixon_debug(CLIXON_DBG_SNMP | CLIXON_DBG_DETAIL, "retval:%d", retval);
return retval; return retval;
fail: fail:
retval = 0; retval = 0;
@ -1232,7 +1232,7 @@ clixon_snmp_err_cb(void *handle,
{ {
const char *errstr; const char *errstr;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_SNMP, "");
if (suberr < 0){ if (suberr < 0){
if (suberr < -CLIXON_ERR_SNMP_MIB){ if (suberr < -CLIXON_ERR_SNMP_MIB){
switch (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 */ /* eg 4, 6, 8 */
for (s=0; s<numfds; s++){ for (s=0; s<numfds; s++){
if (FD_ISSET(s, &readfds)){ if (FD_ISSET(s, &readfds)){
clixon_debug(CLIXON_DBG_CLIENT, "%d", s); clixon_debug(CLIXON_DBG_SNMP, "%d", s);
if (regfd){ if (regfd){
if (clixon_event_reg_fd(s, clixon_snmp_input_cb, h, "snmp socket") < 0) if (clixon_event_reg_fd(s, clixon_snmp_input_cb, h, "snmp socket") < 0)
goto done; goto done;
@ -205,7 +205,7 @@ clixon_snmp_input_cb(int s,
clixon_handle h = (clixon_handle)arg; clixon_handle h = (clixon_handle)arg;
int ret; int ret;
clixon_debug(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, "%d", s); clixon_debug(CLIXON_DBG_SNMP | CLIXON_DBG_DETAIL, "%d", s);
FD_ZERO(&readfds); FD_ZERO(&readfds);
FD_SET(s, &readfds); FD_SET(s, &readfds);
(void)snmp_read(&readfds); (void)snmp_read(&readfds);
@ -253,7 +253,7 @@ clixon_snmp_init_subagent(clixon_handle h,
int retval = -1; int retval = -1;
char *sockpath = NULL; char *sockpath = NULL;
clixon_debug(CLIXON_DBG_CLIENT, ""); clixon_debug(CLIXON_DBG_SNMP, "");
if (logdst == CLIXON_LOG_SYSLOG) if (logdst == CLIXON_LOG_SYSLOG)
snmp_enable_calllog(); snmp_enable_calllog();
else else
@ -320,7 +320,7 @@ usage(clixon_handle h,
"where options are\n" "where options are\n"
"\t-h\t\tHelp\n" "\t-h\t\tHelp\n"
"\t-V \t\tPrint version and exit\n" "\t-V \t\tPrint version and exit\n"
"\t-D <level>\tDebug level (>1 for extensive libnetsnmp debug)\n" "\t-D <level> \tDebug level (see available levels below)\n"
"\t-f <file>\tConfiguration file (mandatory)\n" "\t-f <file>\tConfiguration file (mandatory)\n"
"\t-l (e|o|s|f<file>) Log on std(e)rr, std(o)ut, (s)yslog(default), (f)ile\n" "\t-l (e|o|s|f<file>) Log on std(e)rr, std(o)ut, (s)yslog(default), (f)ile\n"
"\t-C <format>\tDump configuration options on stdout after loading. Format is xml|json|text\n" "\t-C <format>\tDump configuration options on stdout after loading. Format is xml|json|text\n"
@ -328,6 +328,9 @@ usage(clixon_handle h,
"\t-o \"<option>=<value>\"\tGive configuration option overriding config file (see clixon-config.yang)\n", "\t-o \"<option>=<value>\"\tGive configuration option overriding config file (see clixon-config.yang)\n",
argv0, argv0 argv0, argv0
); );
fprintf(stderr, "Debug keys: ");
clixon_debug_key_dump(stderr);
fprintf(stderr, "\n");
exit(0); exit(0);
} }
@ -381,10 +384,16 @@ main(int argc,
cligen_output(stdout, "Clixon version %s\n", CLIXON_VERSION_STRING); cligen_output(stdout, "Clixon version %s\n", CLIXON_VERSION_STRING);
exit(0); exit(0);
break; break;
case 'D' : /* debug */ case 'D' : { /* debug */
if (sscanf(optarg, "%d", &dbg) != 1) int d = 0;
/* Try first symbolic, then numeric match */
if ((d = clixon_debug_str2key(optarg)) < 0 &&
sscanf(optarg, "%d", &d) != 1){
usage(h, argv[0]); usage(h, argv[0]);
}
dbg |= d;
break; break;
}
case 'f': /* override config file */ case 'f': /* override config file */
if (!strlen(optarg)) if (!strlen(optarg))
usage(h, argv[0]); usage(h, argv[0]);

View file

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

View file

@ -46,27 +46,38 @@
* Constants * Constants
*/ */
/* Debug flags are seperated into subject areas and detail
* @see dbgmap Symbolic mapping (if you change here you may need to change dbgmap)
*/
/* Detail level */ /* Detail level */
#define CLIXON_DBG_ALWAYS 0x000000 /* Unconditionally logged */ #define CLIXON_DBG_ALWAYS 0x00000000 /* Unconditionally logged */
#define CLIXON_DBG_DETAIL 0x010000 /* Details: traces, parse trees, etc */ #define CLIXON_DBG_DETAIL 0x01000000 /* Details: traces, parse trees, etc */
#define CLIXON_DBG_DETAIL2 0x020000 /* Extra details */ #define CLIXON_DBG_DETAIL2 0x02000000 /* Extra details */
#define CLIXON_DBG_DETAIL3 0x030000 /* Probably more detail than you want */ #define CLIXON_DBG_DETAIL3 0x03000000 /* Probably more detail than you want */
#define CLIXON_DBG_DMASK 0x030000 /* Detail mask */ #define CLIXON_DBG_DMASK 0x03000000 /* Detail mask */
#define CLIXON_DBG_DSHIFT 16 #define CLIXON_DBG_DSHIFT 24
/* Subject area */ /* Subject area */
#define CLIXON_DBG_DEFAULT 0x000001 /* Default logs */ #define CLIXON_DBG_DEFAULT 0x00000001 /* Default logs */
#define CLIXON_DBG_MSG 0x000002 /* In/out messages */ #define CLIXON_DBG_MSG 0x00000002 /* In/out messages */
#define CLIXON_DBG_XML 0x000004 /* XML processing */ #define CLIXON_DBG_XML 0x00000004 /* XML processing */
#define CLIXON_DBG_XPATH 0x000008 /* XPath processing */ #define CLIXON_DBG_XPATH 0x00000008 /* XPath processing */
#define CLIXON_DBG_YANG 0x000010 /* YANG processing */ #define CLIXON_DBG_YANG 0x00000010 /* YANG processing */
#define CLIXON_DBG_CLIENT 0x000020 /* App-specific */ #define CLIXON_DBG_BACKEND 0x00000020 /* Backend-specific */
#define CLIXON_DBG_NACM 0x000040 /* NACM processing */ #define CLIXON_DBG_CLI 0x00000040 /* CLI frontend */
#define CLIXON_DBG_PROC 0x000080 /* Process handling */ #define CLIXON_DBG_NETCONF 0x00000080 /* NETCONF frontend */
#define CLIXON_DBG_DATASTORE 0x000100 /* Datastore management */ #define CLIXON_DBG_RESTCONF 0x00000100 /* RESTCONF frontend */
#define CLIXON_DBG_EVENT 0x000200 /* Event processing */ #define CLIXON_DBG_SNMP 0x00000200 /* SNMP frontend */
#define CLIXON_DBG_RPC 0x000400 /* RPC handling */ #define CLIXON_DBG_NACM 0x00000400 /* NACM processing */
#define CLIXON_DBG_SMASK 0x00ffff /* Subject mask */ #define CLIXON_DBG_PROC 0x00000800 /* Process handling */
#define CLIXON_DBG_DATASTORE 0x00001000 /* Datastore management */
#define CLIXON_DBG_EVENT 0x00002000 /* Event processing */
#define CLIXON_DBG_RPC 0x00004000 /* RPC handling */
#define CLIXON_DBG_STREAM 0x00008000 /* Notification streams */
#define CLIXON_DBG_APP 0x00010000 /* External application */
#define CLIXON_DBG_APP2 0x00020000 /* External application 2 */
#define CLIXON_DBG_APP3 0x00040000 /* External application 3 */
#define CLIXON_DBG_SMASK 0x0003ffff /* Subject mask */
/* /*
* Macros * Macros
@ -115,6 +126,9 @@
/* /*
* Prototypes * Prototypes
*/ */
char *clixon_debug_key2str(int keyword);
int clixon_debug_str2key(char *str);
int clixon_debug_key_dump(FILE *f);
int clixon_debug_init(clixon_handle h, int dbglevel); int clixon_debug_init(clixon_handle h, int dbglevel);
int clixon_debug_get(void); int clixon_debug_get(void);
int clixon_debug_fn(clixon_handle h, const char *fn, const int line, int dbglevel, cxobj *x, const char *format, ...) __attribute__ ((format (printf, 6, 7))); int clixon_debug_fn(clixon_handle h, const char *fn, const int line, int dbglevel, cxobj *x, const char *format, ...) __attribute__ ((format (printf, 6, 7)));

View file

@ -60,6 +60,7 @@
/* clixon */ /* clixon */
#include "clixon_queue.h" #include "clixon_queue.h"
#include "clixon_hash.h" #include "clixon_hash.h"
#include "clixon_string.h"
#include "clixon_handle.h" #include "clixon_handle.h"
#include "clixon_yang.h" #include "clixon_yang.h"
#include "clixon_xml.h" #include "clixon_xml.h"
@ -78,11 +79,84 @@
/* Cache handle since debug calls do not have handle parameter */ /* Cache handle since debug calls do not have handle parameter */
static clixon_handle _debug_clixon_h = NULL; static clixon_handle _debug_clixon_h = NULL;
/*! Mapping between Clixon debug symbolic names <--> bitfields
*
* Mapping between specific bitfields and symbolic names, note only perfect matches
*/
static const map_str2int dbgmap[] = {
{"default", CLIXON_DBG_DEFAULT},
{"msg", CLIXON_DBG_MSG},
{"xml", CLIXON_DBG_XML},
{"xpath", CLIXON_DBG_XPATH},
{"yang", CLIXON_DBG_YANG},
{"backend", CLIXON_DBG_BACKEND},
{"cli", CLIXON_DBG_CLI},
{"netconf", CLIXON_DBG_NETCONF},
{"restconf", CLIXON_DBG_RESTCONF},
{"snmp", CLIXON_DBG_SNMP},
{"nacm", CLIXON_DBG_NACM},
{"proc", CLIXON_DBG_PROC},
{"datastore", CLIXON_DBG_DATASTORE},
{"event", CLIXON_DBG_EVENT},
{"rpc", CLIXON_DBG_RPC},
{"stream", CLIXON_DBG_STREAM},
{"app", CLIXON_DBG_APP},
{"app2", CLIXON_DBG_APP2},
{"app3", CLIXON_DBG_APP3},
{"all", CLIXON_DBG_SMASK},
{"always", CLIXON_DBG_ALWAYS},
{"detail", CLIXON_DBG_DETAIL},
{"detail2", CLIXON_DBG_DETAIL2},
{"detail3", CLIXON_DBG_DETAIL3},
{NULL, -1}
};
/*! Map from clixon debug (specific) bitmask to string
*
* @param[in] int Bitfield, see CLIXON_DBG_DEFAULT and others
* @retval str String representation of bitfield
*/
char *
clixon_debug_key2str(int keyword)
{
return (char*)clicon_int2str(dbgmap, keyword);
}
/*! Map from clixon debug symbolic string to bitfield
*
* @param[in] str String representation of Clixon debug bit
* @retval int Bit representation of bitfield
*/
int
clixon_debug_str2key(char *str)
{
return clicon_str2int(dbgmap, str);
}
/*! Dump the symbolic bitfield names
*
* @param[in] f Output file
*/
int
clixon_debug_key_dump(FILE *f)
{
const struct map_str2int *ms;
for (ms = &dbgmap[0]; ms->ms_str; ms++){
if (ms != &dbgmap[0])
fprintf(f, ", ");
fprintf(f, "%s", ms->ms_str);
}
return -1;
}
/*! The global debug level. 0 means no debug /*! The global debug level. 0 means no debug
* *
* @note There are pros and cons in having the debug state as a global variable. The * @note There are pros and cons in having the debug state as a global variable. The
* alternative to bind it to the clicon handle (h) was considered but it limits its * alternative to bind it to the clicon handle (h) was considered but it limits its
* usefulness, since not all functions have h * usefulness, since not all functions have access to a handle.
* A compromise solution is now in place where h can be provided in the function call, but
* tolerates NULL, in which case a cached handle is used.
*/ */
static int _debug_level = 0; static int _debug_level = 0;

View file

@ -267,7 +267,7 @@ stream_timer_setup(int fd,
struct stream_replay *r; struct stream_replay *r;
struct stream_replay *r1; struct stream_replay *r1;
clixon_debug(CLIXON_DBG_DEFAULT | CLIXON_DBG_DETAIL, ""); clixon_debug(CLIXON_DBG_STREAM, "");
/* Go thru callbacks and see if any have timed out, if so remove them /* Go thru callbacks and see if any have timed out, if so remove them
* Could also be done by a separate timer. * Could also be done by a separate timer.
*/ */
@ -348,7 +348,7 @@ stream_ss_add(clixon_handle h,
event_stream_t *es; event_stream_t *es;
struct stream_subscription *ss = NULL; struct stream_subscription *ss = NULL;
clixon_debug(CLIXON_DBG_DEFAULT, ""); clixon_debug(CLIXON_DBG_STREAM, "");
if ((es = stream_find(h, stream)) == NULL){ if ((es = stream_find(h, stream)) == NULL){
clixon_err(OE_CFG, ENOENT, "Stream %s not found", stream); clixon_err(OE_CFG, ENOENT, "Stream %s not found", stream);
goto done; goto done;
@ -395,7 +395,7 @@ stream_ss_rm(clixon_handle h,
struct stream_subscription *ss, struct stream_subscription *ss,
int force) int force)
{ {
clixon_debug(CLIXON_DBG_DEFAULT, ""); clixon_debug(CLIXON_DBG_STREAM, "");
DELQ(ss, es->es_subscription, struct stream_subscription *); DELQ(ss, es->es_subscription, struct stream_subscription *);
/* Remove from upper layers - close socket etc. */ /* Remove from upper layers - close socket etc. */
(*ss->ss_fn)(h, 1, NULL, ss->ss_arg); (*ss->ss_fn)(h, 1, NULL, ss->ss_arg);
@ -406,7 +406,7 @@ stream_ss_rm(clixon_handle h,
free(ss->ss_xpath); free(ss->ss_xpath);
free(ss); free(ss);
} }
clixon_debug(CLIXON_DBG_DEFAULT, "retval: 0"); clixon_debug(CLIXON_DBG_STREAM, "retval: 0");
return 0; return 0;
} }
@ -519,7 +519,7 @@ stream_notify1(clixon_handle h,
int retval = -1; int retval = -1;
struct stream_subscription *ss; struct stream_subscription *ss;
clixon_debug(CLIXON_DBG_DEFAULT | CLIXON_DBG_DETAIL, ""); clixon_debug(CLIXON_DBG_STREAM, "");
/* Go thru all subscriptions and find matches */ /* Go thru all subscriptions and find matches */
if ((ss = es->es_subscription) != NULL) if ((ss = es->es_subscription) != NULL)
do { do {
@ -575,7 +575,7 @@ stream_notify(clixon_handle h,
struct timeval tv; struct timeval tv;
event_stream_t *es; event_stream_t *es;
clixon_debug(CLIXON_DBG_DEFAULT | CLIXON_DBG_DETAIL, ""); clixon_debug(CLIXON_DBG_STREAM, "");
if ((es = stream_find(h, stream)) == NULL) if ((es = stream_find(h, stream)) == NULL)
goto ok; goto ok;
va_start(args, event); va_start(args, event);
@ -652,7 +652,7 @@ stream_notify_xml(clixon_handle h,
struct timeval tv; struct timeval tv;
event_stream_t *es; event_stream_t *es;
clixon_debug(CLIXON_DBG_DEFAULT | CLIXON_DBG_DETAIL, ""); clixon_debug(CLIXON_DBG_STREAM, "");
if ((es = stream_find(h, stream)) == NULL) if ((es = stream_find(h, stream)) == NULL)
goto ok; goto ok;
if ((yspec = clicon_dbspec_yang(h)) == NULL){ if ((yspec = clicon_dbspec_yang(h)) == NULL){
@ -940,15 +940,15 @@ url_post(char *url,
CURLcode errcode; CURLcode errcode;
/* Try it with curl -X PUT -d '*/ /* Try it with curl -X PUT -d '*/
clixon_debug(CLIXON_DBG_DEFAULT, "curl -X POST -d '%s' %s", clixon_debug(CLIXON_DBG_STREAM, "curl -X POST -d '%s' %s",
postfields, url); postfields, url);
/* Set up curl for doing the communication with the controller */ /* Set up curl for doing the communication with the controller */
if ((curl = curl_easy_init()) == NULL) { if ((curl = curl_easy_init()) == NULL) {
clixon_debug(CLIXON_DBG_DEFAULT, "curl_easy_init"); clixon_debug(CLIXON_DBG_STREAM, "curl_easy_init");
goto done; goto done;
} }
if ((err = malloc(CURL_ERROR_SIZE)) == NULL) { if ((err = malloc(CURL_ERROR_SIZE)) == NULL) {
clixon_debug(CLIXON_DBG_DEFAULT, "malloc"); clixon_debug(CLIXON_DBG_STREAM, "malloc");
goto done; goto done;
} }
curl_easy_setopt(curl, CURLOPT_URL, url); curl_easy_setopt(curl, CURLOPT_URL, url);
@ -962,7 +962,7 @@ url_post(char *url,
if (clixon_debug_get()) if (clixon_debug_get())
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
if ((errcode = curl_easy_perform(curl)) != CURLE_OK){ if ((errcode = curl_easy_perform(curl)) != CURLE_OK){
clixon_debug(CLIXON_DBG_DEFAULT, "curl: %s(%d)", err, errcode); clixon_debug(CLIXON_DBG_STREAM, "curl: %s(%d)", err, errcode);
retval = 0; retval = 0;
goto done; goto done;
} }
@ -1005,7 +1005,7 @@ stream_publish_cb(clixon_handle h,
char *result = NULL; char *result = NULL;
char *stream = (char*)arg; char *stream = (char*)arg;
clixon_debug(CLIXON_DBG_DEFAULT, ""); clixon_debug(CLIXON_DBG_STREAM, "");
if (op != 0) if (op != 0)
goto ok; goto ok;
/* Create pub url */ /* Create pub url */
@ -1030,7 +1030,7 @@ stream_publish_cb(clixon_handle h,
&result) < 0) /* result as xml */ &result) < 0) /* result as xml */
goto done; goto done;
if (result) if (result)
clixon_debug(CLIXON_DBG_DEFAULT, "%s", result); clixon_debug(CLIXON_DBG_STREAM, "%s", result);
ok: ok:
retval = 0; retval = 0;
done: done: