diff --git a/src/config.h b/src/config.h index 7004d40..abcbf35 100644 --- a/src/config.h +++ b/src/config.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2019-2021 Fredrik Öhrström (gpl-3.0-or-later) + Copyright (C) 2019-2023 Fredrik Öhrström (gpl-3.0-or-later) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -47,6 +47,13 @@ enum class LogSummary All, Unknown }; +enum class DllCrcCheck +{ + TryVerify, // Try if the crc match, then remove. Security problem? Ok, for hex, simulation and cli. + ExpectAndVerify, // Crcs are expected, if not found then fail. + NotExpected // Dll crcs should not be there, do not try to remove them. +}; + // These values can be overridden from the command line. struct ConfigOverrides { diff --git a/src/metermanager.cc b/src/metermanager.cc index 920f3e9..a1315b1 100644 --- a/src/metermanager.cc +++ b/src/metermanager.cc @@ -128,6 +128,8 @@ public: bool handleTelegram(AboutTelegram &about, vector input_frame, bool simulated) { + removeAnyDLLCRCs(input_frame); + if (should_analyze_) { analyzeTelegram(about, input_frame, simulated); diff --git a/src/wmbus.cc b/src/wmbus.cc index 67e9f70..8ee0083 100644 --- a/src/wmbus.cc +++ b/src/wmbus.cc @@ -4765,10 +4765,12 @@ bool trimCRCsFrameFormatBInternal(std::vector &payload, bool fail_is_ok) return true; } -void removeAnyDLLCRCs(std::vector &payload) +bool removeAnyDLLCRCs(std::vector &payload) { bool trimmed = trimCRCsFrameFormatAInternal(payload, true); - if (!trimmed) trimCRCsFrameFormatBInternal(payload, true); + if (!trimmed) trimmed = trimCRCsFrameFormatBInternal(payload, true); + + return trimmed; } bool trimCRCsFrameFormatA(std::vector &payload) diff --git a/src/wmbus.h b/src/wmbus.h index e156abd..fea4cb0 100644 --- a/src/wmbus.h +++ b/src/wmbus.h @@ -30,7 +30,7 @@ // Check and remove the data link layer CRCs from a wmbus telegram. // If the CRCs do not pass the test, return false. -void removeAnyDLLCRCs(std::vector &payload); +bool removeAnyDLLCRCs(std::vector &payload); bool trimCRCsFrameFormatA(std::vector &payload); bool trimCRCsFrameFormatB(std::vector &payload);