aboutsummaryrefslogtreecommitdiff
path: root/include/stick20_commands.h
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2016-10-31 16:56:40 +0100
committerSzczepan Zalega <szczepan@nitrokey.com>2016-11-26 18:56:26 +0100
commit8b49ee9e25efbca9d0d51fcc8be17fd115fc78fd (patch)
tree3702a13952d214e21db41e1b96895a5dc3544d2d /include/stick20_commands.h
parent90e3e144728114189b5b33b4763b07e871b2e66c (diff)
downloadlibnitrokey-8b49ee9e25efbca9d0d51fcc8be17fd115fc78fd.tar.gz
libnitrokey-8b49ee9e25efbca9d0d51fcc8be17fd115fc78fd.tar.bz2
Define configuration response packet separately
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
Diffstat (limited to 'include/stick20_commands.h')
-rw-r--r--include/stick20_commands.h44
1 files 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<CommandID::SEND_STARTUP> {
- 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::seconds> (
- 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<CommandID::SEND_STARTUP> {
+ 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::seconds> (
+ std::chrono::system_clock::now().time_since_epoch()).count();
+ }
+ }__packed;
+
+ using ResponsePayload = DeviceConfigurationResponsePacket::ResponsePayload;
- typedef Transaction<command_id(), struct CommandPayload, struct ResponsePayload>
+ typedef Transaction<command_id(), struct CommandPayload, ResponsePayload>
CommandTransaction;
};
@@ -268,8 +271,9 @@ namespace nitrokey {
class GetDeviceStatus : Command<CommandID::GET_DEVICE_STATUS> {
public:
+ using ResponsePayload = DeviceConfigurationResponsePacket::ResponsePayload;
- typedef Transaction<command_id(), struct EmptyPayload, struct EmptyPayload>
+ typedef Transaction<command_id(), struct EmptyPayload, ResponsePayload>
CommandTransaction;
};