diff options
author | Szczepan Zalega <szczepan@nitrokey.com> | 2016-08-08 14:36:44 +0200 |
---|---|---|
committer | Szczepan Zalega <szczepan@nitrokey.com> | 2016-08-08 14:37:06 +0200 |
commit | 394754e9b281f6451a4eac351ce9c84912167a0d (patch) | |
tree | e8a0950ae827e449086442cf09b45aba72ae0a2c /include | |
parent | a8c8d96fedb52f6232f7f5ecbf185bf920c1d53c (diff) | |
download | libnitrokey-394754e9b281f6451a4eac351ce9c84912167a0d.tar.gz libnitrokey-394754e9b281f6451a4eac351ce9c84912167a0d.tar.bz2 |
Clearing whole response packet instead of only payload part #20
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/device_proto.h | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/include/device_proto.h b/include/device_proto.h index f0d26c0..40b2a22 100644 --- a/include/device_proto.h +++ b/include/device_proto.h @@ -133,22 +133,22 @@ struct EmptyPayload { std::string dissect() const { return std::string("Empty Payload."); } } __packed; -template <typename command_payload> +template <typename command_packet, typename response_payload> class ClearingProxy{ public: - ClearingProxy(command_payload &p){ - payload = p; + ClearingProxy(command_packet &p){ + packet = p; bzero(&p, sizeof(p)); } ~ClearingProxy(){ - bzero(&payload, sizeof(payload)); + bzero(&packet, sizeof(packet)); } - command_payload & data(){ - return payload; + response_payload & data(){ + return packet.payload; } - command_payload payload; + command_packet packet; }; template <CommandID cmd_id, typename command_payload, typename response_payload> @@ -185,7 +185,7 @@ class Transaction : semantics::non_constructible { } - static ClearingProxy<response_payload> run(device::Device &dev, + static ClearingProxy<ResponsePacket, response_payload> run(device::Device &dev, const command_payload &payload) { using namespace ::nitrokey::device; using namespace ::nitrokey::log; @@ -249,10 +249,10 @@ class Transaction : semantics::non_constructible { // See: DeviceResponse - return resp.payload; + return resp; } - static ClearingProxy<response_payload> run(device::Device &dev) { + static ClearingProxy<ResponsePacket, response_payload> run(device::Device &dev) { command_payload empty_payload; return run(dev, empty_payload); } |