if (code) {
ref = log_ref_get(code);
- if (!ref) {
- vty_out(vty, "Code %"PRIu32" - Unknown\n", code);
+ if (!ref)
return;
- }
listnode_add(errlist, ref);
}
"Error Reference Texts");
}
pthread_mutex_unlock(&refs_mtx);
-
- install_element(VIEW_NODE, &show_error_code_cmd);
}
void log_ref_fini(void)
pthread_mutex_unlock(&refs_mtx);
}
+void log_ref_vty_init(void)
+{
+ install_element(VIEW_NODE, &show_error_code_cmd);
+}
+
+
const struct ferr *ferr_get_last(ferr_r errval)
{
struct ferr *last_error = pthread_getspecific(errkey);
#include "command_graph.h"
#include "frrstr.h"
#include "json.h"
+#include "ferr.h"
DEFINE_MTYPE_STATIC(MVTYSH, VTYSH_CMD, "Vtysh cmd copy")
"Information on all errors\n"
JSON_STR)
{
- char *fcmd = argv_concat(argv, argc, 0);
- char cmd[256];
- int rv;
+ uint32_t arg = 0;
- snprintf(cmd, sizeof(cmd), "do %s", fcmd);
+ if (!strmatch(argv[2]->text, "all"))
+ arg = strtoul(argv[2]->arg, NULL, 10);
- /* FIXME: Needs to determine which daemon to send to via code ranges */
- rv = show_per_daemon(cmd, "");
+ /* If it's not a shared code, send it to all the daemons */
+ if (arg < LIB_FERR_START || arg > LIB_FERR_END) {
+ char *fcmd = argv_concat(argv, argc, 0);
+ char cmd[256];
+ snprintf(cmd, sizeof(cmd), "do %s", fcmd);
+ show_per_daemon(cmd, "");
+ XFREE(MTYPE_TMP, fcmd);
+ /* Otherwise, print it ourselves to avoid duplication */
+ } else {
+ bool json = strmatch(argv[argc - 1]->text, "json");
+ if (!strmatch(argv[2]->text, "all"))
+ arg = strtoul(argv[2]->arg, NULL, 10);
+
+ log_ref_display(vty, arg, json);
+ }
- XFREE(MTYPE_TMP, fcmd);
- return rv;
+ return CMD_SUCCESS;
}
/* Memory */