summaryrefslogtreecommitdiffstats
path: root/src/bin/netconf
diff options
context:
space:
mode:
authorFrancis Dupont <fdupont@isc.org>2021-12-16 00:13:49 +0100
committerAndrei Pavel <andrei@isc.org>2021-12-17 16:21:22 +0100
commit2ef7df964296046ad529c9a81ed12148071cb404 (patch)
treebc32ae9c404c71c066d819eb039a8a224921497d /src/bin/netconf
parent[#2084] warnAboutExtraCommas() in parsers (diff)
downloadkea-2ef7df964296046ad529c9a81ed12148071cb404.tar.xz
kea-2ef7df964296046ad529c9a81ed12148071cb404.zip
[#2084] Addressed all concerns outside .yy files
Diffstat (limited to 'src/bin/netconf')
-rw-r--r--src/bin/netconf/netconf_messages.cc4
-rw-r--r--src/bin/netconf/netconf_messages.h3
-rw-r--r--src/bin/netconf/netconf_messages.mes4
-rw-r--r--src/bin/netconf/parser_context.cc16
-rw-r--r--src/bin/netconf/parser_context.h9
5 files changed, 19 insertions, 17 deletions
diff --git a/src/bin/netconf/netconf_messages.cc b/src/bin/netconf/netconf_messages.cc
index c6c4aa64c6..8464ef777c 100644
--- a/src/bin/netconf/netconf_messages.cc
+++ b/src/bin/netconf/netconf_messages.cc
@@ -1,4 +1,4 @@
-// File created from ../../../src/bin/netconf/netconf_messages.mes
+// File created from netconf_messages.mes
#include <cstddef>
#include <log/message_types.h>
@@ -12,6 +12,7 @@ extern const isc::log::MessageID NETCONF_CONFIG_CHANGED_DETAIL = "NETCONF_CONFIG
extern const isc::log::MessageID NETCONF_CONFIG_CHANGE_EVENT = "NETCONF_CONFIG_CHANGE_EVENT";
extern const isc::log::MessageID NETCONF_CONFIG_CHECK_FAIL = "NETCONF_CONFIG_CHECK_FAIL";
extern const isc::log::MessageID NETCONF_CONFIG_FAIL = "NETCONF_CONFIG_FAIL";
+extern const isc::log::MessageID NETCONF_CONFIG_SYNTAX_WARNING = "NETCONF_CONFIG_SYNTAX_WARNING";
extern const isc::log::MessageID NETCONF_FAILED = "NETCONF_FAILED";
extern const isc::log::MessageID NETCONF_GET_CONFIG = "NETCONF_GET_CONFIG";
extern const isc::log::MessageID NETCONF_GET_CONFIG_FAILED = "NETCONF_GET_CONFIG_FAILED";
@@ -52,6 +53,7 @@ const char* values[] = {
"NETCONF_CONFIG_CHANGE_EVENT", "Received YANG configuration change %1 event",
"NETCONF_CONFIG_CHECK_FAIL", "Netconf configuration check failed: %1",
"NETCONF_CONFIG_FAIL", "Netconf configuration failed: %1",
+ "NETCONF_CONFIG_SYNTAX_WARNING", "Netconf configuration syntax warning: %1",
"NETCONF_FAILED", "application experienced a fatal error: %1",
"NETCONF_GET_CONFIG", "got configuration from %1 server: %2",
"NETCONF_GET_CONFIG_FAILED", "getting configuration from %1 server failed: %2",
diff --git a/src/bin/netconf/netconf_messages.h b/src/bin/netconf/netconf_messages.h
index cdec3995f5..7ca4abc211 100644
--- a/src/bin/netconf/netconf_messages.h
+++ b/src/bin/netconf/netconf_messages.h
@@ -1,4 +1,4 @@
-// File created from ../../../src/bin/netconf/netconf_messages.mes
+// File created from netconf_messages.mes
#ifndef NETCONF_MESSAGES_H
#define NETCONF_MESSAGES_H
@@ -13,6 +13,7 @@ extern const isc::log::MessageID NETCONF_CONFIG_CHANGED_DETAIL;
extern const isc::log::MessageID NETCONF_CONFIG_CHANGE_EVENT;
extern const isc::log::MessageID NETCONF_CONFIG_CHECK_FAIL;
extern const isc::log::MessageID NETCONF_CONFIG_FAIL;
+extern const isc::log::MessageID NETCONF_CONFIG_SYNTAX_WARNING;
extern const isc::log::MessageID NETCONF_FAILED;
extern const isc::log::MessageID NETCONF_GET_CONFIG;
extern const isc::log::MessageID NETCONF_GET_CONFIG_FAILED;
diff --git a/src/bin/netconf/netconf_messages.mes b/src/bin/netconf/netconf_messages.mes
index 3619929e0e..7883c1d8a8 100644
--- a/src/bin/netconf/netconf_messages.mes
+++ b/src/bin/netconf/netconf_messages.mes
@@ -29,6 +29,10 @@ This error message indicates that Netconf had failed configuration
attempt. Details are provided. Additional details may be available
in earlier log entries, possibly on lower levels.
+% NETCONF_CONFIG_SYNTAX_WARNING Netconf configuration syntax warning: %1
+This warning message indicates that the Netconf configuration had a minor
+syntax error. The error was displayed and the configuration parsing resumed.
+
% NETCONF_FAILED application experienced a fatal error: %1
This is a fatal error message issued when the Netconf application
got an unrecoverable error from within the event loop.
diff --git a/src/bin/netconf/parser_context.cc b/src/bin/netconf/parser_context.cc
index c672d95226..e57b4c51ac 100644
--- a/src/bin/netconf/parser_context.cc
+++ b/src/bin/netconf/parser_context.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2018-2020 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2018-2021 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -8,10 +8,12 @@
#include <netconf/parser_context.h>
#include <netconf/netconf_parser.h>
+#include <netconf/netconf_log.h>
#include <exceptions/exceptions.h>
//#include <cc/dhcp_config_error.h>
#include <cc/data.h>
#include <fstream>
+#include <sstream>
#include <limits>
namespace isc {
@@ -182,13 +184,11 @@ ParserContext::contextName()
void
ParserContext::warning(const isc::netconf::location& loc,
- const std::string& what,
- size_t pos /* = 0 */) {
- if (pos == 0) {
- std::cerr << loc << ": " << what << std::endl;
- } else {
- std::cerr << loc << " (near " << pos << "): " << what << std::endl;
- }
+ const std::string& what) {
+ std::ostringstream msg;
+ msg << loc << ": " << what;
+ LOG_WARN(netconf_logger, NETCONF_CONFIG_SYNTAX_WARNING)
+ .arg(msg.str());
}
} // namespace netconf
diff --git a/src/bin/netconf/parser_context.h b/src/bin/netconf/parser_context.h
index 5db590fff0..32a39245d0 100644
--- a/src/bin/netconf/parser_context.h
+++ b/src/bin/netconf/parser_context.h
@@ -1,4 +1,4 @@
-// Copyright (C) 2018-2020 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2018-2021 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -182,14 +182,9 @@ public:
///
/// @param loc location within the parsed file where the problem was experienced
/// @param what string explaining the nature of the error
- /// @param pos optional position for in string errors. The optional position
- /// for an error in a string begins by 1 so the caller should add 1 to the
- /// position of the C++ string.
///
/// @throw ParseError
- void warning(const isc::netconf::location& loc,
- const std::string& what,
- size_t pos = 0);
+ void warning(const isc::netconf::location& loc, const std::string& what);
/// @brief Defines syntactic contexts for lexical tie-ins
typedef enum {