Prepare for configuring check or no check of dll-crcs.

Add-DLL-CRC-option
Fredrik Öhrström 2023-03-05 19:41:36 +01:00
rodzic 298124c51a
commit 51868591bb
4 zmienionych plików z 15 dodań i 4 usunięć

Wyświetl plik

@ -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
{

Wyświetl plik

@ -128,6 +128,8 @@ public:
bool handleTelegram(AboutTelegram &about, vector<uchar> input_frame, bool simulated)
{
removeAnyDLLCRCs(input_frame);
if (should_analyze_)
{
analyzeTelegram(about, input_frame, simulated);

Wyświetl plik

@ -4765,10 +4765,12 @@ bool trimCRCsFrameFormatBInternal(std::vector<uchar> &payload, bool fail_is_ok)
return true;
}
void removeAnyDLLCRCs(std::vector<uchar> &payload)
bool removeAnyDLLCRCs(std::vector<uchar> &payload)
{
bool trimmed = trimCRCsFrameFormatAInternal(payload, true);
if (!trimmed) trimCRCsFrameFormatBInternal(payload, true);
if (!trimmed) trimmed = trimCRCsFrameFormatBInternal(payload, true);
return trimmed;
}
bool trimCRCsFrameFormatA(std::vector<uchar> &payload)

Wyświetl plik

@ -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<uchar> &payload);
bool removeAnyDLLCRCs(std::vector<uchar> &payload);
bool trimCRCsFrameFormatA(std::vector<uchar> &payload);
bool trimCRCsFrameFormatB(std::vector<uchar> &payload);