OSDN Git Service

tools/smp-tester: Improve logging of received SMP PDUs
authorJohan Hedberg <johan.hedberg@intel.com>
Fri, 29 Nov 2013 13:12:46 +0000 (15:12 +0200)
committerJohan Hedberg <johan.hedberg@intel.com>
Fri, 29 Nov 2013 13:12:49 +0000 (15:12 +0200)
tools/smp-tester.c

index aa55402..05d620a 100644 (file)
@@ -661,7 +661,14 @@ static void smp_server(const void *data, uint16_t len, void *user_data)
        const void *pdu;
        uint8_t opcode;
 
-       tester_print("Received SMP PDU");
+       if (len < 1) {
+               tester_warn("Received too small SMP PDU");
+               goto failed;
+       }
+
+       opcode = *((const uint8_t *) data);
+
+       tester_print("Received SMP opcode 0x%02x", opcode);
 
        if (test_data->counter >= smp->req_count) {
                tester_test_passed();
@@ -678,8 +685,6 @@ static void smp_server(const void *data, uint16_t len, void *user_data)
                goto failed;
        }
 
-       opcode = *((const uint8_t *) data);
-
        switch (opcode) {
        case 0x01: /* Pairing Request */
                memcpy(test_data->smp_preq, data, sizeof(test_data->smp_preq));