tools/mgmt-tester: Add callback routine for validating the parameter
authorTedd Ho-Jeong An <tedd.an@intel.com>
Sat, 10 Apr 2021 06:46:04 +0000 (23:46 -0700)
committerAyush Garg <ayush.garg@samsung.com>
Fri, 11 Mar 2022 13:38:35 +0000 (19:08 +0530)
This patch adds a callback routine for validating the received HCI
parameter, so it can customize to compare the parameters instead of
memcmp the full length.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
tools/mgmt-tester.c

index 1835ca0..ef37f0e 100755 (executable)
@@ -280,6 +280,7 @@ struct generic_data {
        uint16_t expect_alt_ev_len;
        uint16_t expect_hci_command;
        const void *expect_hci_param;
+       int (*expect_hci_param_check_func)(const void *param, uint16_t length);
        uint8_t expect_hci_len;
        const void * (*expect_hci_func)(uint8_t *len);
        bool expect_pin;
@@ -6632,6 +6633,7 @@ static void command_hci_callback(uint16_t opcode, const void *param,
        const struct generic_data *test = data->test_data;
        const void *expect_hci_param = test->expect_hci_param;
        uint8_t expect_hci_len = test->expect_hci_len;
+       int ret;
 
        tester_print("HCI Command 0x%04x length %u", opcode, length);
 
@@ -6647,7 +6649,11 @@ static void command_hci_callback(uint16_t opcode, const void *param,
                return;
        }
 
-       if (memcmp(param, expect_hci_param, length) != 0) {
+       if (test->expect_hci_param_check_func)
+               ret = test->expect_hci_param_check_func(param, length);
+       else
+               ret = memcmp(param, expect_hci_param, length);
+       if (ret != 0) {
                tester_warn("Unexpected HCI command parameter value:");
                util_hexdump('>', param, length, print_debug, "");
                util_hexdump('!', expect_hci_param, length, print_debug, "");