Skip to content

Commit dab27ba

Browse files
committed
SWPROT-9242: Move s2 protocol CC encryption handling to protocol CC
- create a protocol command class handler that handle also protocol LR commands - add unit tests for this handler - remove request protocol cc encryption code from s2 and move it to new protocol cc
1 parent 14a1b28 commit dab27ba

16 files changed

+492
-320
lines changed

applications/zpc/components/zwave/zwave_controller/src/zwave_controller_callbacks.c

+5-17
Original file line numberDiff line numberDiff line change
@@ -313,23 +313,11 @@ void zwave_controller_on_frame_received(
313313
frame_length);
314314
//If no transport plugins needs the frame parse it on to upper layers
315315
if (status == SL_STATUS_NOT_FOUND) {
316-
// Check if the frame is a protocol CC
317-
if (frame_data[0] == ZWAVE_CMD_CLASS_PROTOCOL || frame_data[0] == ZWAVE_CMD_CLASS_PROTOCOL_LR)
318-
{
319-
ZWAVE_CONTROLLER_DISPATCH_CALLBACKS(on_protocol_frame_received,
320-
connection_info,
321-
rx_options,
322-
frame_data,
323-
frame_length);
324-
}
325-
else
326-
{
327-
ZWAVE_CONTROLLER_DISPATCH_CALLBACKS(on_application_frame_received,
328-
connection_info,
329-
rx_options,
330-
frame_data,
331-
frame_length);
332-
}
316+
ZWAVE_CONTROLLER_DISPATCH_CALLBACKS(on_application_frame_received,
317+
connection_info,
318+
rx_options,
319+
frame_data,
320+
frame_length);
333321
}
334322
}
335323

applications/zpc/components/zwave/zwave_controller/test/zwave_controller_callbacks_test.c

-77
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,6 @@ static void zwave_controller_on_protocol_cc_encryption_request(
9898
zwave_controller_on_protocol_cc_encryption_request_count += 1;
9999
}
100100

101-
static void zwave_controller_on_protocol_frame_received(
102-
const zwave_controller_connection_info_t *connection_info,
103-
const zwave_rx_receive_options_t *rx_options,
104-
const uint8_t *frame_data,
105-
uint16_t frame_length)
106-
{
107-
zwave_controller_on_protocol_frame_received_count += 1;
108-
}
109-
110101
static void zwave_controller_on_node_event_test(zwave_node_id_t node_id)
111102
{
112103
zwave_controller_on_node_event_test_call_count += 1;
@@ -344,74 +335,6 @@ void test_zwave_controller_on_protocol_cc_encryption_request_received()
344335
callbacks.on_protocol_cc_encryption_request = NULL;
345336
}
346337

347-
void test_zwave_controller_on_controller_protocol_frames()
348-
{
349-
// We need to inject a valid frame, as this will go through the transports
350-
zwave_controller_on_frame_received(&info,
351-
&rx_options,
352-
protocol_frame_data,
353-
sizeof(protocol_frame_data));
354-
TEST_ASSERT_EQUAL(0, zwave_controller_on_protocol_frame_received_count);
355-
TEST_ASSERT_EQUAL(0, zwave_controller_on_rx_frame_received_count);
356-
TEST_ASSERT_EQUAL(0, zwave_controller_on_application_frame_received_count);
357-
358-
callbacks.on_rx_frame_received
359-
= &zwave_controller_on_rx_frame_received_callback;
360-
callbacks.on_application_frame_received
361-
= &zwave_controller_on_application_frame_received;
362-
callbacks.on_protocol_frame_received
363-
= &zwave_controller_on_protocol_frame_received;
364-
TEST_ASSERT_EQUAL(SL_STATUS_OK,
365-
zwave_controller_register_callbacks(&callbacks));
366-
367-
zwave_controller_on_frame_received(&info,
368-
&rx_options,
369-
protocol_frame_data,
370-
sizeof(protocol_frame_data));
371-
TEST_ASSERT_EQUAL(1, zwave_controller_on_protocol_frame_received_count);
372-
TEST_ASSERT_EQUAL(0, zwave_controller_on_application_frame_received_count);
373-
TEST_ASSERT_EQUAL(0, zwave_controller_on_rx_frame_received_count);
374-
375-
// remove these callbacks:
376-
callbacks.on_rx_frame_received = NULL;
377-
callbacks.on_application_frame_received = NULL;
378-
callbacks.on_protocol_frame_received = NULL;
379-
}
380-
381-
void test_zwave_controller_on_controller_protocol_lr_frames()
382-
{
383-
// We need to inject a valid frame, as this will go through the transports
384-
zwave_controller_on_frame_received(&info,
385-
&rx_options,
386-
protocol_lr_frame_data,
387-
sizeof(protocol_lr_frame_data));
388-
TEST_ASSERT_EQUAL(0, zwave_controller_on_protocol_frame_received_count);
389-
TEST_ASSERT_EQUAL(0, zwave_controller_on_rx_frame_received_count);
390-
TEST_ASSERT_EQUAL(0, zwave_controller_on_application_frame_received_count);
391-
392-
callbacks.on_rx_frame_received
393-
= &zwave_controller_on_rx_frame_received_callback;
394-
callbacks.on_application_frame_received
395-
= &zwave_controller_on_application_frame_received;
396-
callbacks.on_protocol_frame_received
397-
= &zwave_controller_on_protocol_frame_received;
398-
TEST_ASSERT_EQUAL(SL_STATUS_OK,
399-
zwave_controller_register_callbacks(&callbacks));
400-
401-
zwave_controller_on_frame_received(&info,
402-
&rx_options,
403-
protocol_lr_frame_data,
404-
sizeof(protocol_lr_frame_data));
405-
TEST_ASSERT_EQUAL(1, zwave_controller_on_protocol_frame_received_count);
406-
TEST_ASSERT_EQUAL(0, zwave_controller_on_application_frame_received_count);
407-
TEST_ASSERT_EQUAL(0, zwave_controller_on_rx_frame_received_count);
408-
409-
// remove these callbacks:
410-
callbacks.on_rx_frame_received = NULL;
411-
callbacks.on_application_frame_received = NULL;
412-
callbacks.on_protocol_frame_received = NULL;
413-
}
414-
415338
void test_zwave_controller_on_network_address_update()
416339
{
417340
// Nothing happens with no callback registered

applications/zpc/components/zwave/zwave_transports/s2/CMakeLists.txt

+2-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ set(KEYSTORE_SOURCES "src/zwave_s2_keystore.c")
1818
add_library(
1919
zwave_s2
2020
src/zwave_s2_fixt.c ${KEYSTORE_SOURCES} src/zwave_s2_network.c
21-
src/zwave_s2_printf.c src/zwave_s2_process.c src/zwave_s2_transport.c src/zwave_s2_protocol_cc_encryption.c)
21+
src/zwave_s2_printf.c src/zwave_s2_process.c src/zwave_s2_transport.c)
2222

2323
set(DEFAULT_ZW-LIBS2_PATH libs/zw-libs2)
2424
if(EXISTS ${ZW-LIBS2_LOCATION})
@@ -40,13 +40,12 @@ target_include_directories(
4040
zwave_s2
4141
PUBLIC include
4242
PRIVATE ${ZW-LIBS2_PATH}/include src)
43-
4443
install(TARGETS zwave_s2 LIBRARY DESTINATION lib)
4544

4645
target_link_libraries(
4746
zwave_s2
4847
PUBLIC zwave_s2_nonce_management unify
49-
PRIVATE s2_controller zwave_controller zwave_s0 zpc_attribute_store)
48+
PRIVATE s2_controller zwave_controller zwave_s0 zpc_attribute_store zpc_utils)
5049

5150
target_compile_definitions(zwave_s2 PRIVATE ZIPGW ZW_CONTROLLER)
5251

applications/zpc/components/zwave/zwave_transports/s2/src/zwave_s2_process.c

-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include "zwave_s2_keystore_int.h"
2323
#include "zwave_s2_network.h"
2424
#include "zwave_s2_transport.h"
25-
#include "zwave_s2_protocol_cc_encryption.h"
2625

2726
#define LOG_TAG "zwave_s2_process"
2827

@@ -86,7 +85,6 @@ static void zwave_s2_init()
8685
.on_network_address_update = zwave_s2_on_network_address_update,
8786
.on_new_network_entered = zwave_s2_on_new_network_entered,
8887
.on_multicast_group_deleted = zwave_s2_on_on_multicast_group_deleted,
89-
.on_protocol_cc_encryption_request = zwave_s2_on_protocol_cc_encryption_request,
9088
};
9189

9290
zwave_controller_register_callbacks(&callbacks);

applications/zpc/components/zwave/zwave_transports/s2/src/zwave_s2_protocol_cc_encryption.c

-80
This file was deleted.

applications/zpc/components/zwave/zwave_transports/s2/test/CMakeLists.txt

-15
Original file line numberDiff line numberDiff line change
@@ -63,21 +63,6 @@ target_add_unittest(
6363
zwave_tx_mock
6464
zwave_network_management_mock)
6565

66-
# ####################### S2 Protocol CC Encryption test ##################################
67-
target_add_unittest(
68-
zwave_s2
69-
NAME
70-
zwave_s2_protocol_cc_encryption_test
71-
SOURCES
72-
zwave_s2_protocol_cc_encryption_test.c
73-
DEPENDS
74-
zwave_controller ## Non-mock, we use the real thing here
75-
libs2_mock
76-
zwave_api_mock
77-
uic_contiki_stub
78-
zwave_tx_mock
79-
zwave_network_management_mock)
80-
8166
# ####################### S2 Nonce Management test ##################################
8267
target_add_unittest(
8368
zwave_s2_nonce_management

applications/zpc/components/zwave/zwave_transports/s2/test/zwave_s2_protocol_cc_encryption_test.c

-96
This file was deleted.

applications/zpc/components/zwave_command_classes/CMakeLists.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ add_library(
6262
src/zwave_command_classes_fixt.c
6363
src/zwave_command_classes_utils.c
6464
src/zwave_command_class_inclusion_controller.cpp
65-
src/zwave_command_class_transport_service.c)
65+
src/zwave_command_class_transport_service.c
66+
src/zwave_command_class_protocol.c)
6667
install(TARGETS zwave_command_classes LIBRARY DESTINATION lib)
6768

6869
target_include_directories(

0 commit comments

Comments
 (0)