From 8b49ee9e25efbca9d0d51fcc8be17fd115fc78fd Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Mon, 31 Oct 2016 16:56:40 +0100 Subject: Define configuration response packet separately Signed-off-by: Szczepan Zalega --- include/stick20_commands.h | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/include/stick20_commands.h b/include/stick20_commands.h index 31d7b13..5c2d97e 100644 --- a/include/stick20_commands.h +++ b/include/stick20_commands.h @@ -178,23 +178,7 @@ namespace nitrokey { - - class SendStartup : Command { - public: - struct CommandPayload { - uint64_t localtime; // POSIX seconds from epoch start, supports until year 2106 - std::string dissect() const { - std::stringstream ss; - print_to_ss( localtime ); - return ss.str(); - } - void set_defaults(){ - localtime = - std::chrono::duration_cast ( - std::chrono::system_clock::now().time_since_epoch()).count(); - } - }__packed; - + namespace DeviceConfigurationResponsePacket{ static const int OUTPUT_CMD_RESULT_STICK20_STATUS_START = 25 + 1; static const int payload_absolute_begin = 8; static const int padding_size = OUTPUT_CMD_RESULT_STICK20_STATUS_START - payload_absolute_begin; @@ -249,14 +233,33 @@ namespace nitrokey { print_to_ss((int) AdminPwRetryCount ); print_to_ss( ActiveSmartCardID_u32 ); print_to_ss((int) StickKeysNotInitiated ); - ss << "_padding:\t" + ss << "_padding:" << std::endl << ::nitrokey::misc::hexdump((const char *) (_padding), sizeof _padding); return ss.str(); } } __packed; + } + + class SendStartup : Command { + public: + struct CommandPayload { + uint64_t localtime; // POSIX seconds from epoch start, supports until year 2106 + std::string dissect() const { + std::stringstream ss; + print_to_ss( localtime ); + return ss.str(); + } + void set_defaults(){ + localtime = + std::chrono::duration_cast ( + std::chrono::system_clock::now().time_since_epoch()).count(); + } + }__packed; + + using ResponsePayload = DeviceConfigurationResponsePacket::ResponsePayload; - typedef Transaction + typedef Transaction CommandTransaction; }; @@ -268,8 +271,9 @@ namespace nitrokey { class GetDeviceStatus : Command { public: + using ResponsePayload = DeviceConfigurationResponsePacket::ResponsePayload; - typedef Transaction + typedef Transaction CommandTransaction; }; -- cgit v1.2.3