aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2017-05-25 13:10:36 +0200
committerSzczepan Zalega <szczepan@nitrokey.com>2017-09-20 12:47:04 +0200
commit2a3e72179f1cadc01897d74a5fc87686863ec258 (patch)
tree47e7b295c5487bca337501ed80b736c224f23cf5 /include
parent36b563b8efa720f56739019778086762cc6aaa81 (diff)
downloadlibnitrokey-2a3e72179f1cadc01897d74a5fc87686863ec258.tar.gz
libnitrokey-2a3e72179f1cadc01897d74a5fc87686863ec258.tar.bz2
Show warning message about invalid incoming packet's CRC
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
Diffstat (limited to 'include')
-rw-r--r--include/device_proto.h14
1 files changed, 8 insertions, 6 deletions
diff --git a/include/device_proto.h b/include/device_proto.h
index b557384..c126acd 100644
--- a/include/device_proto.h
+++ b/include/device_proto.h
@@ -352,12 +352,6 @@ namespace nitrokey {
clear_packet(outp);
- if (!resp.isCRCcorrect())
- LOGD(std::string("Accepting response from device with invalid CRC. ")
- + "Command ID: " + std::to_string(resp.command_id) + " " +
- commandid_to_string(static_cast<CommandID>(resp.command_id))
- );
-
if (status <= 0) {
dev->m_counters.receiving_error++;
@@ -398,6 +392,14 @@ namespace nitrokey {
dev->m_counters.successful_storage_commands++;
}
+ if (!resp.isCRCcorrect())
+ LOG(std::string("Accepting response from device with invalid CRC. ")
+ + "Command ID: " + std::to_string(resp.command_id) + " " +
+ commandid_to_string(static_cast<CommandID>(resp.command_id)) + " "
+ + "Reported and calculated: " + std::to_string(resp.crc) + "!=" + std::to_string(resp.calculate_CRC()),
+ Loglevel::WARNING
+ );
+
// See: DeviceResponse
return resp;
}