diff --git a/configs/config.example.yml b/configs/config.example.yml index 6c637ee9..068d9b06 100644 --- a/configs/config.example.yml +++ b/configs/config.example.yml @@ -762,6 +762,8 @@ system: time: 2 # Flag indicating whether or not RID ACLs are enforced. acl: false + # Flag indicating whether or not the RID ACL updates are logged. + verbose: false # # Talkgroupd ID ACL Configuration @@ -775,3 +777,5 @@ system: time: 2 # Flag indicating whether or not TGID ACLs are enforced. acl: false + # Flag indicating whether or not the talkgroup rules updates are logged. + verbose: true diff --git a/configs/fne-config.example.yml b/configs/fne-config.example.yml index 2fb1c119..0c4c1277 100644 --- a/configs/fne-config.example.yml +++ b/configs/fne-config.example.yml @@ -240,6 +240,8 @@ master: file: talkgroup_rules.yml # Amount of time between updates of talkgroup rules file. (minutes) time: 30 + # Flag indicating whether or not the talkgroup rules updates are logged. + verbose: true # # Adj. Site Map Configuration @@ -345,6 +347,8 @@ system: file: rid_acl.dat # Amount of time between updates of Radio ID ACL file. (minutes) time: 2 + # Flag indicating whether or not the Radio ID ACL updates are logged. + verbose: false # # Peer ACL configuration @@ -356,6 +360,8 @@ system: file: peer_list.dat # Amount of time between updates of peer ACL file. (minutes) time: 2 + # Flag indicating whether or not the peer ACL updates are logged. + verbose: true # # Packet Data Virtual Network Tunnel Configuration diff --git a/src/common/lookups/PeerListLookup.cpp b/src/common/lookups/PeerListLookup.cpp index 40e0cff9..6f85814d 100644 --- a/src/common/lookups/PeerListLookup.cpp +++ b/src/common/lookups/PeerListLookup.cpp @@ -50,8 +50,9 @@ bool PeerListLookup::s_locked = false; /* Initializes a new instance of the PeerListLookup class. */ -PeerListLookup::PeerListLookup(const std::string& filename, uint32_t reloadTime, bool peerAcl) : LookupTable(filename, reloadTime), - m_acl(peerAcl) +PeerListLookup::PeerListLookup(const std::string& filename, uint32_t reloadTime, bool peerAcl, bool verbose) : LookupTable(filename, reloadTime), + m_acl(peerAcl), + m_verbose(verbose) { /* stub */ } @@ -275,14 +276,16 @@ bool PeerListLookup::load() m_table[id] = entry; // log depending on what was loaded - LogInfoEx(LOG_HOST, "Loaded peer ID %u%s into peer ID lookup table, %s%s%s%s%s%s", id, - (!alias.empty() ? (" (" + alias + ")").c_str() : ""), - (!password.empty() ? "using unique peer password" : "using master password"), - (peerReplica) ? ", Replication Enabled" : "", - (canRequestKeys) ? ", Can Request Keys" : "", - (canIssueInhibit) ? ", Can Issue Inhibit" : "", - (hasCallPriority) ? ", Has Call Priority" : "", - (jitterBufferEnabled) ? ", Jitter Buffer Enabled" : ""); + if (m_verbose) { + LogInfoEx(LOG_HOST, "Loaded peer ID %u%s into peer ID lookup table, %s%s%s%s%s%s", id, + (!alias.empty() ? (" (" + alias + ")").c_str() : ""), + (!password.empty() ? "using unique peer password" : "using master password"), + (peerReplica) ? ", Replication Enabled" : "", + (canRequestKeys) ? ", Can Request Keys" : "", + (canIssueInhibit) ? ", Can Issue Inhibit" : "", + (hasCallPriority) ? ", Has Call Priority" : "", + (jitterBufferEnabled) ? ", Jitter Buffer Enabled" : ""); + } } } diff --git a/src/common/lookups/PeerListLookup.h b/src/common/lookups/PeerListLookup.h index c9938382..04f6d140 100644 --- a/src/common/lookups/PeerListLookup.h +++ b/src/common/lookups/PeerListLookup.h @@ -212,8 +212,9 @@ namespace lookups * @param filename Full-path to the list file. * @param reloadTime Interval of time to reload the lookup table. * @param peerAcl Flag indicating these rules are enabled for enforcing access control. + * @param verbose Flag indicating if logging should be enabled for this lookup table. */ - PeerListLookup(const std::string& filename, uint32_t reloadTime, bool peerAcl); + PeerListLookup(const std::string& filename, uint32_t reloadTime, bool peerAcl, bool verbose = true); /** * @brief Clears all entries from the list. @@ -283,6 +284,8 @@ namespace lookups protected: bool m_acl; + bool m_verbose; + /** * @brief Loads the table from the passed lookup table file. * @return True, if lookup table was loaded, otherwise false. diff --git a/src/common/lookups/RadioIdLookup.cpp b/src/common/lookups/RadioIdLookup.cpp index fd241ebc..7a8de404 100644 --- a/src/common/lookups/RadioIdLookup.cpp +++ b/src/common/lookups/RadioIdLookup.cpp @@ -52,8 +52,9 @@ bool RadioIdLookup::s_locked = false; /* Initializes a new instance of the RadioIdLookup class. */ -RadioIdLookup::RadioIdLookup(const std::string& filename, uint32_t reloadTime, bool ridAcl) : LookupTable(filename, reloadTime), - m_acl(ridAcl) +RadioIdLookup::RadioIdLookup(const std::string& filename, uint32_t reloadTime, bool ridAcl, bool verbose) : LookupTable(filename, reloadTime), + m_acl(ridAcl), + m_verbose(verbose) { /* stub */ } @@ -223,7 +224,10 @@ bool RadioIdLookup::load() } m_table[id] = RadioId(radioEnabled, false, alias, ipAddress); - //::LogInfoEx(LOG_HOST, "Radio NAME: %s RID: %u ENABLED: %u IPADDR: %s", alias.c_str(), id, radioEnabled, ipAddress.c_str()); + + if (m_verbose) { + LogInfoEx(LOG_HOST, "Radio NAME: %s RID: %u ENABLED: %u IPADDR: %s", alias.c_str(), id, radioEnabled, ipAddress.c_str()); + } } } diff --git a/src/common/lookups/RadioIdLookup.h b/src/common/lookups/RadioIdLookup.h index 51c42ce0..b917772f 100644 --- a/src/common/lookups/RadioIdLookup.h +++ b/src/common/lookups/RadioIdLookup.h @@ -147,8 +147,9 @@ namespace lookups * @param filename Full-path to the radio ID table file. * @param reloadTime Interval of time to reload the radio ID table. * @param ridAcl Flag indicating whether radio ID access control is enabled. + * @param verbose Flag indicating if logging should be enabled for this lookup table. */ - RadioIdLookup(const std::string& filename, uint32_t reloadTime, bool ridAcl); + RadioIdLookup(const std::string& filename, uint32_t reloadTime, bool ridAcl, bool verbose = false); /** * @brief Clears all entries from the lookup table. @@ -207,6 +208,8 @@ namespace lookups protected: bool m_acl; + bool m_verbose; + /** * @brief Loads the table from the passed lookup table file. * @return True, if lookup table was loaded, otherwise false. diff --git a/src/common/lookups/TalkgroupRulesLookup.cpp b/src/common/lookups/TalkgroupRulesLookup.cpp index 5f5073e4..b31dfd9b 100644 --- a/src/common/lookups/TalkgroupRulesLookup.cpp +++ b/src/common/lookups/TalkgroupRulesLookup.cpp @@ -50,12 +50,13 @@ bool TalkgroupRulesLookup::s_locked = false; /* Initializes a new instance of the TalkgroupRulesLookup class. */ -TalkgroupRulesLookup::TalkgroupRulesLookup(const std::string& filename, uint32_t reloadTime, bool acl) : Thread(), +TalkgroupRulesLookup::TalkgroupRulesLookup(const std::string& filename, uint32_t reloadTime, bool acl, bool verbose) : Thread(), m_rulesFile(filename), m_reloadTime(reloadTime), m_rules(), m_lastLoadTime(0U), m_acl(acl), + m_verbose(verbose), m_stop(false), m_groupHangTime(5U), m_sendTalkgroups(false), @@ -345,29 +346,31 @@ bool TalkgroupRulesLookup::load() TalkgroupRuleGroupVoice groupVoice = TalkgroupRuleGroupVoice(groupVoiceList[i]); m_groupVoice.push_back(groupVoice); - std::string groupName = groupVoice.name(); - uint32_t tgId = groupVoice.source().tgId(); - uint8_t tgSlot = groupVoice.source().tgSlot(); - bool active = groupVoice.config().active(); - bool parrot = groupVoice.config().parrot(); - bool affil = groupVoice.config().affiliated(); - - uint32_t incCount = groupVoice.config().inclusion().size(); - uint32_t excCount = groupVoice.config().exclusion().size(); - uint32_t rewrCount = groupVoice.config().rewrite().size(); - uint32_t alwyCount = groupVoice.config().alwaysSend().size(); - uint32_t prefCount = groupVoice.config().preferred().size(); - uint32_t permRIDCount = groupVoice.config().permittedRIDs().size(); - - if (incCount > 0 && excCount > 0) { - ::LogWarning(LOG_HOST, "Talkgroup (%s) defines both inclusions and exclusions! Inclusion rules take precedence and exclusion rules will be ignored.", groupName.c_str()); - } + if (m_verbose) { + std::string groupName = groupVoice.name(); + uint32_t tgId = groupVoice.source().tgId(); + uint8_t tgSlot = groupVoice.source().tgSlot(); + bool active = groupVoice.config().active(); + bool parrot = groupVoice.config().parrot(); + bool affil = groupVoice.config().affiliated(); + + uint32_t incCount = groupVoice.config().inclusion().size(); + uint32_t excCount = groupVoice.config().exclusion().size(); + uint32_t rewrCount = groupVoice.config().rewrite().size(); + uint32_t alwyCount = groupVoice.config().alwaysSend().size(); + uint32_t prefCount = groupVoice.config().preferred().size(); + uint32_t permRIDCount = groupVoice.config().permittedRIDs().size(); + + if (incCount > 0 && excCount > 0) { + ::LogWarning(LOG_HOST, "Talkgroup (%s) defines both inclusions and exclusions! Inclusion rules take precedence and exclusion rules will be ignored.", groupName.c_str()); + } - if (alwyCount > 0 && affil) { - ::LogWarning(LOG_HOST, "Talkgroup (%s) is marked as affiliation required and has a defined always send list! Always send peers take rule precedence and defined peers will always receive traffic.", groupName.c_str()); - } + if (alwyCount > 0 && affil) { + ::LogWarning(LOG_HOST, "Talkgroup (%s) is marked as affiliation required and has a defined always send list! Always send peers take rule precedence and defined peers will always receive traffic.", groupName.c_str()); + } - ::LogInfoEx(LOG_HOST, "Talkgroup NAME: %s SRC_TGID: %u SRC_TS: %u ACTIVE: %u PARROT: %u AFFILIATED: %u INCLUSIONS: %u EXCLUSIONS: %u REWRITES: %u ALWAYS: %u PREFERRED: %u PERMITTED RIDS: %u", groupName.c_str(), tgId, tgSlot, active, parrot, affil, incCount, excCount, rewrCount, alwyCount, prefCount, permRIDCount); + ::LogInfoEx(LOG_HOST, "Talkgroup NAME: %s SRC_TGID: %u SRC_TS: %u ACTIVE: %u PARROT: %u AFFILIATED: %u INCLUSIONS: %u EXCLUSIONS: %u REWRITES: %u ALWAYS: %u PREFERRED: %u PERMITTED RIDS: %u", groupName.c_str(), tgId, tgSlot, active, parrot, affil, incCount, excCount, rewrCount, alwyCount, prefCount, permRIDCount); + } } __UNLOCK_TABLE(); diff --git a/src/common/lookups/TalkgroupRulesLookup.h b/src/common/lookups/TalkgroupRulesLookup.h index 04de671d..6160bacc 100644 --- a/src/common/lookups/TalkgroupRulesLookup.h +++ b/src/common/lookups/TalkgroupRulesLookup.h @@ -537,8 +537,9 @@ namespace lookups * @param filename Full-path to the routing rules file. * @param reloadTime Interval of time to reload the routing rules. * @param acl Flag indicating these rules are enabled for enforcing access control. + * @param verbose Flag indicating if logging should be enabled for this lookup table. */ - TalkgroupRulesLookup(const std::string& filename, uint32_t reloadTime, bool acl); + TalkgroupRulesLookup(const std::string& filename, uint32_t reloadTime, bool acl, bool verbose = true); /** * @brief Finalizes a instance of the TalkgroupRulesLookup class. */ @@ -652,6 +653,8 @@ namespace lookups bool m_acl; bool m_stop; + bool m_verbose; + static std::mutex s_mutex; //!< Mutex used for change locking. static bool s_locked; //!< Flag used for read locking (prevents find lookups), should be used when atomic operations (add/erase/etc) are being used. diff --git a/src/fne/HostFNE.cpp b/src/fne/HostFNE.cpp index 5d8f01d4..115f0f0e 100644 --- a/src/fne/HostFNE.cpp +++ b/src/fne/HostFNE.cpp @@ -177,13 +177,15 @@ int HostFNE::run() // try to load radio IDs table std::string ridLookupFile = systemConf["radio_id"]["file"].as(); uint32_t ridReloadTime = systemConf["radio_id"]["time"].as(0U); + bool verboseRIDRules = systemConf["radio_id"]["verbose"].as(false); LogInfo("Radio Id Lookups"); LogInfo(" File: %s", ridLookupFile.length() > 0U ? ridLookupFile.c_str() : "None"); if (ridReloadTime > 0U) LogInfo(" Reload: %u mins", ridReloadTime); + LogInfo(" Verbose: %s", verboseRIDRules ? "true" : "false"); - m_ridLookup = new RadioIdLookup(ridLookupFile, ridReloadTime, true); + m_ridLookup = new RadioIdLookup(ridLookupFile, ridReloadTime, true, verboseRIDRules); m_ridLookup->read(); // initialize master networking @@ -400,6 +402,7 @@ bool HostFNE::readParams() yaml::Node talkgroupRules = masterConf["talkgroup_rules"]; std::string talkgroupConfig = talkgroupRules["file"].as(); uint32_t talkgroupConfigReload = talkgroupRules["time"].as(30U); + bool verboseTalkgroupRules = talkgroupRules["verbose"].as(true); yaml::Node adjSiteMapRules = masterConf["adj_site_map"]; std::string adjSiteMapConfig = adjSiteMapRules["file"].as(); @@ -417,13 +420,15 @@ bool HostFNE::readParams() std::string peerListLookupFile = systemConf["peer_acl"]["file"].as(); bool peerListLookupEnable = systemConf["peer_acl"]["enable"].as(false); uint32_t peerListConfigReload = systemConf["peer_acl"]["time"].as(30U); + bool verbosePeerListRules = systemConf["peer_acl"]["verbose"].as(true); LogInfo("Talkgroup Rule Lookups"); LogInfo(" File: %s", talkgroupConfig.length() > 0U ? talkgroupConfig.c_str() : "None"); if (talkgroupConfigReload > 0U) LogInfo(" Reload: %u mins", talkgroupConfigReload); + LogInfo(" Verbose: %s", verboseTalkgroupRules ? "true" : "false"); - m_tidLookup = new TalkgroupRulesLookup(talkgroupConfig, talkgroupConfigReload, true); + m_tidLookup = new TalkgroupRulesLookup(talkgroupConfig, talkgroupConfigReload, true, verboseTalkgroupRules); m_tidLookup->sendTalkgroups(sendTalkgroups); m_tidLookup->read(); @@ -433,8 +438,9 @@ bool HostFNE::readParams() LogInfo(" File: %s", peerListLookupFile.length() > 0U ? peerListLookupFile.c_str() : "None"); if (peerListConfigReload > 0U) LogInfo(" Reload: %u mins", peerListConfigReload); + LogInfo(" Verbose: %s", verbosePeerListRules ? "true" : "false"); - m_peerListLookup = new PeerListLookup(peerListLookupFile, peerListConfigReload, peerListLookupEnable); + m_peerListLookup = new PeerListLookup(peerListLookupFile, peerListConfigReload, peerListLookupEnable, verbosePeerListRules); m_peerListLookup->read(); LogInfo("Adjacent Site Map Lookups"); diff --git a/src/host/Host.cpp b/src/host/Host.cpp index 440cc0a7..63136818 100644 --- a/src/host/Host.cpp +++ b/src/host/Host.cpp @@ -326,28 +326,32 @@ int Host::run() std::string ridLookupFile = systemConf["radio_id"]["file"].as(); uint32_t ridReloadTime = systemConf["radio_id"]["time"].as(0U); bool ridAcl = systemConf["radio_id"]["acl"].as(false); + bool verboseRIDRules = systemConf["radio_id"]["verbose"].as(false); LogInfo("Radio Id Lookups"); LogInfo(" File: %s", ridLookupFile.length() > 0U ? ridLookupFile.c_str() : "None"); if (ridReloadTime > 0U) LogInfo(" Reload: %u mins", ridReloadTime); LogInfo(" ACL: %s", ridAcl ? "yes" : "no"); + LogInfo(" Verbose: %s", verboseRIDRules ? "true" : "false"); - m_ridLookup = new RadioIdLookup(ridLookupFile, ridReloadTime, ridAcl); + m_ridLookup = new RadioIdLookup(ridLookupFile, ridReloadTime, ridAcl, verboseRIDRules); m_ridLookup->read(); // try to load talkgroup IDs table std::string tidLookupFile = systemConf["talkgroup_id"]["file"].as(); uint32_t tidReloadTime = systemConf["talkgroup_id"]["time"].as(0U); bool tidAcl = systemConf["talkgroup_id"]["acl"].as(false); + bool verboseTalkgroupRules = systemConf["talkgroup_id"]["verbose"].as(true); LogInfo("Talkgroup Rule Lookups"); LogInfo(" File: %s", tidLookupFile.length() > 0U ? tidLookupFile.c_str() : "None"); if (tidReloadTime > 0U) LogInfo(" Reload: %u mins", tidReloadTime); LogInfo(" ACL: %s", tidAcl ? "yes" : "no"); + LogInfo(" Verbose: %s", verboseTalkgroupRules ? "true" : "false"); - m_tidLookup = new TalkgroupRulesLookup(tidLookupFile, tidReloadTime, tidAcl); + m_tidLookup = new TalkgroupRulesLookup(tidLookupFile, tidReloadTime, tidAcl, verboseTalkgroupRules); m_tidLookup->read(); // initialize networking