Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SWPROT-9242: Move s2 protocol CC encryption handling to protocol CC #43

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -313,23 +313,11 @@ void zwave_controller_on_frame_received(
frame_length);
//If no transport plugins needs the frame parse it on to upper layers
if (status == SL_STATUS_NOT_FOUND) {
// Check if the frame is a protocol CC
if (frame_data[0] == ZWAVE_CMD_CLASS_PROTOCOL || frame_data[0] == ZWAVE_CMD_CLASS_PROTOCOL_LR)
{
ZWAVE_CONTROLLER_DISPATCH_CALLBACKS(on_protocol_frame_received,
connection_info,
rx_options,
frame_data,
frame_length);
}
else
{
ZWAVE_CONTROLLER_DISPATCH_CALLBACKS(on_application_frame_received,
connection_info,
rx_options,
frame_data,
frame_length);
}
ZWAVE_CONTROLLER_DISPATCH_CALLBACKS(on_application_frame_received,
connection_info,
rx_options,
frame_data,
frame_length);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,6 @@ static void zwave_controller_on_protocol_cc_encryption_request(
zwave_controller_on_protocol_cc_encryption_request_count += 1;
}

static void zwave_controller_on_protocol_frame_received(
const zwave_controller_connection_info_t *connection_info,
const zwave_rx_receive_options_t *rx_options,
const uint8_t *frame_data,
uint16_t frame_length)
{
zwave_controller_on_protocol_frame_received_count += 1;
}

static void zwave_controller_on_node_event_test(zwave_node_id_t node_id)
{
zwave_controller_on_node_event_test_call_count += 1;
Expand Down Expand Up @@ -344,74 +335,6 @@ void test_zwave_controller_on_protocol_cc_encryption_request_received()
callbacks.on_protocol_cc_encryption_request = NULL;
}

void test_zwave_controller_on_controller_protocol_frames()
{
// We need to inject a valid frame, as this will go through the transports
zwave_controller_on_frame_received(&info,
&rx_options,
protocol_frame_data,
sizeof(protocol_frame_data));
TEST_ASSERT_EQUAL(0, zwave_controller_on_protocol_frame_received_count);
TEST_ASSERT_EQUAL(0, zwave_controller_on_rx_frame_received_count);
TEST_ASSERT_EQUAL(0, zwave_controller_on_application_frame_received_count);

callbacks.on_rx_frame_received
= &zwave_controller_on_rx_frame_received_callback;
callbacks.on_application_frame_received
= &zwave_controller_on_application_frame_received;
callbacks.on_protocol_frame_received
= &zwave_controller_on_protocol_frame_received;
TEST_ASSERT_EQUAL(SL_STATUS_OK,
zwave_controller_register_callbacks(&callbacks));

zwave_controller_on_frame_received(&info,
&rx_options,
protocol_frame_data,
sizeof(protocol_frame_data));
TEST_ASSERT_EQUAL(1, zwave_controller_on_protocol_frame_received_count);
TEST_ASSERT_EQUAL(0, zwave_controller_on_application_frame_received_count);
TEST_ASSERT_EQUAL(0, zwave_controller_on_rx_frame_received_count);

// remove these callbacks:
callbacks.on_rx_frame_received = NULL;
callbacks.on_application_frame_received = NULL;
callbacks.on_protocol_frame_received = NULL;
}

void test_zwave_controller_on_controller_protocol_lr_frames()
{
// We need to inject a valid frame, as this will go through the transports
zwave_controller_on_frame_received(&info,
&rx_options,
protocol_lr_frame_data,
sizeof(protocol_lr_frame_data));
TEST_ASSERT_EQUAL(0, zwave_controller_on_protocol_frame_received_count);
TEST_ASSERT_EQUAL(0, zwave_controller_on_rx_frame_received_count);
TEST_ASSERT_EQUAL(0, zwave_controller_on_application_frame_received_count);

callbacks.on_rx_frame_received
= &zwave_controller_on_rx_frame_received_callback;
callbacks.on_application_frame_received
= &zwave_controller_on_application_frame_received;
callbacks.on_protocol_frame_received
= &zwave_controller_on_protocol_frame_received;
TEST_ASSERT_EQUAL(SL_STATUS_OK,
zwave_controller_register_callbacks(&callbacks));

zwave_controller_on_frame_received(&info,
&rx_options,
protocol_lr_frame_data,
sizeof(protocol_lr_frame_data));
TEST_ASSERT_EQUAL(1, zwave_controller_on_protocol_frame_received_count);
TEST_ASSERT_EQUAL(0, zwave_controller_on_application_frame_received_count);
TEST_ASSERT_EQUAL(0, zwave_controller_on_rx_frame_received_count);

// remove these callbacks:
callbacks.on_rx_frame_received = NULL;
callbacks.on_application_frame_received = NULL;
callbacks.on_protocol_frame_received = NULL;
}

void test_zwave_controller_on_network_address_update()
{
// Nothing happens with no callback registered
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ set(KEYSTORE_SOURCES "src/zwave_s2_keystore.c")
add_library(
zwave_s2
src/zwave_s2_fixt.c ${KEYSTORE_SOURCES} src/zwave_s2_network.c
src/zwave_s2_printf.c src/zwave_s2_process.c src/zwave_s2_transport.c src/zwave_s2_protocol_cc_encryption.c)
src/zwave_s2_printf.c src/zwave_s2_process.c src/zwave_s2_transport.c)

set(DEFAULT_ZW-LIBS2_PATH libs/zw-libs2)
if(EXISTS ${ZW-LIBS2_LOCATION})
Expand All @@ -40,13 +40,12 @@ target_include_directories(
zwave_s2
PUBLIC include
PRIVATE ${ZW-LIBS2_PATH}/include src)

install(TARGETS zwave_s2 LIBRARY DESTINATION lib)

target_link_libraries(
zwave_s2
PUBLIC zwave_s2_nonce_management unify
PRIVATE s2_controller zwave_controller zwave_s0 zpc_attribute_store)
PRIVATE s2_controller zwave_controller zwave_s0 zpc_attribute_store zpc_utils)

target_compile_definitions(zwave_s2 PRIVATE ZIPGW ZW_CONTROLLER)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include "zwave_s2_keystore_int.h"
#include "zwave_s2_network.h"
#include "zwave_s2_transport.h"
#include "zwave_s2_protocol_cc_encryption.h"

#define LOG_TAG "zwave_s2_process"

Expand Down Expand Up @@ -86,7 +85,6 @@ static void zwave_s2_init()
.on_network_address_update = zwave_s2_on_network_address_update,
.on_new_network_entered = zwave_s2_on_new_network_entered,
.on_multicast_group_deleted = zwave_s2_on_on_multicast_group_deleted,
.on_protocol_cc_encryption_request = zwave_s2_on_protocol_cc_encryption_request,
};

zwave_controller_register_callbacks(&callbacks);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,6 @@ target_add_unittest(
zpc_attribute_store_test_helper
zwave_network_management_mock)

# ####################### S2 Protocol CC Encryption test ##################################
target_add_unittest(
zwave_s2
NAME
zwave_s2_protocol_cc_encryption_test
SOURCES
zwave_s2_protocol_cc_encryption_test.c
DEPENDS
zwave_controller ## Non-mock, we use the real thing here
libs2_mock
zwave_api_mock
uic_contiki_stub
zwave_tx_mock
zwave_network_management_mock)

# ####################### S2 Nonce Management test ##################################
target_add_unittest(
zwave_s2_nonce_management
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ add_library(
src/zwave_command_classes_fixt.c
src/zwave_command_classes_utils.c
src/zwave_command_class_inclusion_controller.cpp
src/zwave_command_class_transport_service.c)
src/zwave_command_class_transport_service.c
src/zwave_command_class_protocol.c)
install(TARGETS zwave_command_classes LIBRARY DESTINATION lib)

target_include_directories(
Expand Down
Loading