Re: [PATCH v3 5/6] monitor: Add basic decoding for Mesh Provisioning

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Luiz,

> This adds basic decoding for Mesh Provisioning packets such as:
> 
> < HCI Command: LE Set Advertising Data (0x08|0x0008) plen 32
>        Length: 24
>        Mesh Provision: 024874cb0003dddd0000000000000000000000000000
>          Link ID: 0x024874cb
>          Transaction Number: 0
>          Provisioning Bearer Control (0x03)
>          Link Open (0x00)
>          Device UUID: 03dddd00000000000000000000000000
> 
>> HCI Event: LE Meta Event (0x3e) plen 20
>      LE Advertising Report (0x02)
>        Num reports: 1
>        Event type: Non connectable undirected - ADV_NONCONN_IND (0x03)
>        Address type: Random (0x01)
>        Address: 34:11:85:DC:41:39 (Non-Resolvable)
>        Data length: 8
>        Mesh Provision: 024874cb0007
>          Link ID: 0x024874cb
>          Transaction Number: 0
>          Provisioning Bearer Control (0x03)
>          Link Ack (0x01)
>        RSSI: -28 dBm (0xe4)
> ---
> monitor/packet.c | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 92 insertions(+), 1 deletion(-)
> 
> diff --git a/monitor/packet.c b/monitor/packet.c
> index 345a7da..3906eee 100644
> --- a/monitor/packet.c
> +++ b/monitor/packet.c
> @@ -3594,6 +3594,97 @@ static void print_mesh_beacon(const uint8_t *data, uint8_t len)
> 	}
> }
> 
> +static void print_mesh_prov(const uint8_t *data, uint8_t len)
> +{
> +	print_hex_field("Mesh Provisioning", data, len);
> +
> +	if (len < 6) {
> +		packet_hexdump(data, len);
> +		return;
> +	}
> +
> +	print_field("  Link ID: 0x%08x", get_be32(data));
> +	print_field("  Transaction Number: %u", data[4]);
> +
> +	data += 5;
> +	len -= 5;
> +
> +	switch (data[0] & 0x03) {
> +	case 0x00:
> +		print_field("  Transaction Start (0x00)");
> +		if (len < 5) {
> +			packet_hexdump(data + 1, len - 1);
> +			return;
> +		}
> +		print_field("  SeqN: %u", data[0] & 0xfc >> 2);
> +		print_field("  TotalLength: %u", get_be16(data + 1));
> +		print_field("  FCS: 0x%2.2x", data[3]);
> +		print_hex_field("  Data", data + 4, len - 4);
> +		packet_hexdump(data + 5, len - 5);
> +		break;
> +	case 0x01:
> +		print_field("  Transaction Acknowledgment (0x01)");
> +		packet_hexdump(data + 1, len - 1);
> +		break;
> +	case 0x02:
> +		print_field("  Transaction Continuation (0x02)");
> +		print_field("  SegmentIndex: %u", data[0] >> 2);
> +		if (len < 2) {
> +			packet_hexdump(data + 1, len - 1);
> +			return;
> +		}
> +		print_hex_field("  Data", data + 1, len - 1);
> +		packet_hexdump(data + 2, len - 2);
> +		break;
> +	case 0x03:
> +		print_field("  Provisioning Bearer Control (0x03)");
> +		switch (data[0] >> 2) {
> +		case 0x00:
> +			print_field("  Link Open (0x00)");
> +			if (len < 17) {
> +				packet_hexdump(data + 1, len - 1);
> +				break;
> +			}
> +			print_hex_field("  Device UUID", data, 16);
> +			break;
> +		case 0x01:
> +			print_field("  Link Ack (0x01)");
> +			break;
> +		case 0x02:
> +			print_field("  Link Close (0x02)");
> +			if (len < 2) {
> +				packet_hexdump(data + 1, len - 1);
> +				break;
> +			}
> +
> +			switch (data[1]) {
> +			case 0x00:
> +				print_field("  Reason: Success (0x00)");
> +				break;
> +			case 0x01:
> +				print_field("  Reason: Timeout (0x01)");
> +				break;
> +			case 0x02:
> +				print_field("  Reason: Fail (0x02)");
> +				break;
> +			default:
> +				print_field("  Reason: Unrecognized (0x%2.2x)",
> +								data[1]);

look default: labels also deserve a break.

Regards

Marcel

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux