save work

This commit is contained in:
Nanosonde 2020-06-01 19:06:04 +02:00
parent c35c550bc2
commit 262842cea3
4 changed files with 98 additions and 1 deletions

View File

@ -32,6 +32,7 @@ add_executable(knx-linux
../../src/knx/cemi_frame.h
../../src/knx/cemi_server.cpp
../../src/knx/cemi_server_object.cpp
../../src/knx/cemi_server_object.h
../../src/knx/data_link_layer.cpp
../../src/knx/data_link_layer.h
../../src/knx/data_property.cpp
@ -81,6 +82,8 @@ add_executable(knx-linux
../../src/knx/rf_physical_layer.h
../../src/knx/secure_application_layer.cpp
../../src/knx/secure_application_layer.h
../../src/knx/security_interface_object.cpp
../../src/knx/security_interface_object.h
../../src/knx/table_object.cpp
../../src/knx/table_object.h
../../src/knx/tpdu.cpp

View File

@ -158,6 +158,19 @@ enum PropertyID
PID_MAX_INTERFACE_APDU_LENGTH = 68,
PID_MAX_LOCAL_APDU_LENGTH = 69,
/** Security Interface Object */
PID_SECURITY_MODE = 51, // Enable and disable the Security Mode
PID_P2P_KEY_TABLE = 52, // Security keys used for securing point-to-point and broadcast communication
PID_GRP_KEY_TABLE = 53, // Security keys used for securing standard mode group communication
PID_SECURITY_INDIVIDUAL_ADDRESS_TABLE = 54, // IAs and last valid sequence numbers of communication partners with secure links
PID_SECURITY_FAILURES_LOG = 55, // Provides security failure information
PID_TOOL_KEY = 56, // Stores the security information for the central MaC in S-Mode and Ctrl-Mode
PID_SECURITY_REPORT = 57, // KNX Data Security-related status and diagnostic information
PID_SECURITY_REPORT_CONTROL = 58, // Control the spontaneous communication of the security report through DMP_InterfaceObject-InfoReport_RCl
PID_SEQUENCE_NUMBER_SENDING = 59, // Sequence Number used for the next outgoing secure communication
PID_ZONE_KEY_TABLE = 60, // Security keys used for securing zone addressing communication
PID_GO_SECURITY_FLAGS = 61, // Defines the required security requirements for each group object
PID_ROLE_TABLE = 62, // Role table
};
enum LoadState

View File

@ -0,0 +1,68 @@
#include "config.h"
#ifdef USE_DATASECURE
#include <cstring>
#include "security_interface_object.h"
#include "bits.h"
#include "data_property.h"
#include "callback_property.h"
#include "function_property.h"
SecurityInterfaceObject::SecurityInterfaceObject()
{
Property* properties[] =
{
new DataProperty( PID_OBJECT_TYPE, false, PDT_UNSIGNED_INT, 1, ReadLv3 | WriteLv0, (uint16_t)OT_SECURITY ),
new CallbackProperty<SecurityInterfaceObject>(this, PID_LOAD_STATE_CONTROL, true, PDT_CONTROL, 1, ReadLv3 | WriteLv3,
// ReadCallback of PID_LOAD_STATE_CONTROL
[](SecurityInterfaceObject* obj, uint16_t start, uint8_t count, uint8_t* data) -> uint8_t {
if (start == 0)
return 1;
// TODO: implement PID_LOAD_STATE_CONTROL for complete interface object
//data[0] = obj->_state;
return 1;
},
// WriteCallback of PID_LOAD_STATE_CONTROL
[](SecurityInterfaceObject* obj, uint16_t start, uint8_t count, const uint8_t* data) -> uint8_t {
// TODO: implement PID_LOAD_STATE_CONTROL for complete interface object
//obj->loadEvent(data);
return 1;
}),
new FunctionProperty<SecurityInterfaceObject>(this, PID_SECURITY_MODE, ReadLv3 | WriteLv0,
// Command Callback of PID_SECURITY_MODE
[](SecurityInterfaceObject* obj, uint8_t* data, uint8_t length, uint8_t* resultData, uint8_t& resultLength) -> uint8_t {
// TODO
return 0;
},
// State Callback of PID_SECURITY_MODE
[](SecurityInterfaceObject* obj, uint8_t* data, uint8_t length, uint8_t* resultData, uint8_t& resultLength) -> uint8_t {
// TODO
return 0;
}),
new DataProperty( PID_P2P_KEY_TABLE, true, PDT_GENERIC_20, 1, ReadLv3 | WriteLv0, (uint16_t)0 ), // TODO: value
new DataProperty( PID_GRP_KEY_TABLE, true, PDT_GENERIC_18, 1, ReadLv3 | WriteLv0, (uint16_t)0 ), // TODO: value
new DataProperty( PID_SECURITY_INDIVIDUAL_ADDRESS_TABLE, true, PDT_GENERIC_08, 1, ReadLv3 | WriteLv0, (uint16_t)0 ), // TODO: value
new FunctionProperty<SecurityInterfaceObject>(this, PID_SECURITY_FAILURES_LOG, ReadLv3 | WriteLv0,
// Command Callback of PID_SECURITY_FAILURES_LOG
[](SecurityInterfaceObject* obj, uint8_t* data, uint8_t length, uint8_t* resultData, uint8_t& resultLength) -> uint8_t {
// TODO
return 0;
},
// State Callback of PID_SECURITY_FAILURES_LOG
[](SecurityInterfaceObject* obj, uint8_t* data, uint8_t length, uint8_t* resultData, uint8_t& resultLength) -> uint8_t {
// TODO
return 0;
}),
new DataProperty( PID_TOOL_KEY, true, PDT_GENERIC_16, 1, ReadLv3 | WriteLv0, (uint16_t)0 ), // TODO: value (default is FDSK)
new DataProperty( PID_SECURITY_REPORT, true, PDT_BITSET8, 1, ReadLv3 | WriteLv0, (uint16_t)0 ), // TODO: value
new DataProperty( PID_SECURITY_REPORT_CONTROL, true, PDT_BINARY_INFORMATION, 1, ReadLv3 | WriteLv0, (uint16_t)0 ), // TODO: value
new DataProperty( PID_SEQUENCE_NUMBER_SENDING, true, PDT_GENERIC_06, 1, ReadLv3 | WriteLv0, (uint16_t)0 ), // TODO: value
new DataProperty( PID_ZONE_KEY_TABLE, true, PDT_GENERIC_19, 1, ReadLv3 | WriteLv0, (uint16_t)0 ), // TODO: value
new DataProperty( PID_GO_SECURITY_FLAGS, true, PDT_GENERIC_01, 1, ReadLv3 | WriteLv0, (uint16_t)0 ), // TODO: value
new DataProperty( PID_ROLE_TABLE, true, PDT_GENERIC_01, 1, ReadLv3 | WriteLv0, (uint16_t)0 ), // TODO: value
};
initializeProperties(sizeof(properties), properties);
}
#endif

View File

@ -0,0 +1,13 @@
#pragma once
#include "config.h"
#ifdef USE_DATASECURE
#include "interface_object.h"
class SecurityInterfaceObject: public InterfaceObject
{
public:
SecurityInterfaceObject();
};
#endif