/src/wireshark/epan/dissectors/packet-btamp.c
Line | Count | Source |
1 | | /* packet-btamp.c |
2 | | * Routines for the Bluetooth AMP dissection |
3 | | * |
4 | | * Copyright 2009, Kovarththanan Rajaratnam <kovarththanan.rajaratnam@gmail.com> |
5 | | * |
6 | | * Wireshark - Network traffic analyzer |
7 | | * By Gerald Combs <gerald@wireshark.org> |
8 | | * Copyright 1998 Gerald Combs |
9 | | * |
10 | | * SPDX-License-Identifier: GPL-2.0-or-later |
11 | | */ |
12 | | |
13 | | #include "config.h" |
14 | | |
15 | | #include <epan/packet.h> |
16 | | |
17 | | #include "packet-btl2cap.h" |
18 | | |
19 | | /* Initialize the protocol and registered fields */ |
20 | | static int proto_btamp; |
21 | | static int hf_btamp_command; |
22 | | static int hf_btamp_cmd_code; |
23 | | static int hf_btamp_cmd_ident; |
24 | | static int hf_btamp_cmd_length; |
25 | | static int hf_btamp_cmd_data; |
26 | | static int hf_btamp_rej_reason; |
27 | | static int hf_btamp_mtu; |
28 | | static int hf_btamp_extfeatures; |
29 | | static int hf_btamp_lcontroller_id; |
30 | | static int hf_btamp_rcontroller_id; |
31 | | static int hf_btamp_controller_list; |
32 | | static int hf_btamp_controllers; |
33 | | static int hf_btamp_controller_id; |
34 | | static int hf_btamp_controller_type; |
35 | | static int hf_btamp_controller_status; |
36 | | static int hf_btamp_status; |
37 | | /* static int hf_btamp_create_status; */ |
38 | | /* static int hf_btamp_disc_status; */ |
39 | | static int hf_btamp_total_bw; |
40 | | static int hf_btamp_max_guaran_bw; |
41 | | static int hf_btamp_min_latency; |
42 | | static int hf_btamp_pal_caps_guaranteed; |
43 | | static int hf_btamp_pal_caps_mask; |
44 | | static int hf_btamp_amp_assoc_size; |
45 | | static int hf_btamp_amp_assoc; |
46 | | |
47 | | /* Initialize the subtree pointers */ |
48 | | static int ett_btamp; |
49 | | static int ett_btamp_cmd; |
50 | | static int ett_btamp_caps; |
51 | | static int ett_btamp_controller_entry; |
52 | | static int ett_btamp_controller_list; |
53 | | |
54 | | static dissector_handle_t btamp_handle; |
55 | | |
56 | | |
57 | | static const value_string command_code_vals[] = { |
58 | | { 0x01, "AMP Command Reject" }, |
59 | | { 0x02, "AMP Discover Request" }, |
60 | | { 0x03, "AMP Discover Response" }, |
61 | | { 0x04, "AMP Change Notify" }, |
62 | | { 0x05, "AMP Change Response" }, |
63 | | { 0x06, "AMP Get Info Request" }, |
64 | | { 0x07, "AMP Get Info Response" }, |
65 | | { 0x08, "AMP Get AMP Assoc Request" }, |
66 | | { 0x09, "AMP Get AMP Assoc Response" }, |
67 | | { 0x0A, "AMP Create Physical Link Request" }, |
68 | | { 0x0B, "AMP Create Physical Link Response" }, |
69 | | { 0x0C, "AMP Disconnect Physical Link Request" }, |
70 | | { 0x0D, "AMP Disconnect Physical Link Response" }, |
71 | | { 0, NULL } |
72 | | }; |
73 | | |
74 | | static const value_string reason_vals[] = { |
75 | | { 0x0000, "Command not understood" }, |
76 | | { 0, NULL } |
77 | | }; |
78 | | |
79 | | static const value_string controller_type_vals[] = { |
80 | | { 0x0000, "Bluetooth BR/EDR" }, |
81 | | { 0x0001, "802.11" }, |
82 | | { 0x0002, "ECMA-368" }, |
83 | | { 0, NULL } |
84 | | }; |
85 | | |
86 | | static const value_string controller_status_vals[] = { |
87 | | { 0x0000, "Controller available but currently physically powered down" }, |
88 | | { 0x0001, "Controller used exclusively by Bluetooth BR/EDR" }, |
89 | | { 0x0002, "Controller has no capacity available for Bluetooth operation" }, |
90 | | { 0x0003, "Controller has low capacity available for Bluetooth operation" }, |
91 | | { 0x0004, "Controller has medium capacity available for Bluetooth operation" }, |
92 | | { 0x0005, "Controller has high capacity available for Bluetooth operation" }, |
93 | | { 0x0006, "Controller has full capacity available for Bluetooth operation" }, |
94 | | { 0, NULL } |
95 | | }; |
96 | | |
97 | | static const value_string status_vals[] = { |
98 | | { 0x0000, "Success" }, |
99 | | { 0x0001, "Invalid Controller ID" }, |
100 | | { 0, NULL } |
101 | | }; |
102 | | |
103 | | #if 0 |
104 | | static const value_string create_status_vals[] = { |
105 | | { 0x0000, "Success" }, |
106 | | { 0x0001, "Invalid Controller ID" }, |
107 | | { 0x0002, "Failed - Unable to start link creation" }, |
108 | | { 0x0003, "Failed - Collision Occurred" }, |
109 | | { 0x0004, "Failed - AMP Disconnected Physical Link Request packet received" }, |
110 | | { 0x0005, "Failed - Physical Link Already Exists" }, |
111 | | { 0, NULL } |
112 | | }; |
113 | | |
114 | | static const value_string disc_status_vals[] = { |
115 | | { 0x0000, "Success" }, |
116 | | { 0x0001, "Invalid Controller ID" }, |
117 | | { 0x0002, "Failed - No Physical Link exists and no Physical Link creation is in progress" }, |
118 | | { 0, NULL } |
119 | | }; |
120 | | #endif |
121 | | |
122 | | void proto_register_btamp(void); |
123 | | void proto_reg_handoff_btamp(void); |
124 | | |
125 | | static int |
126 | | dissect_comrej(tvbuff_t *tvb, unsigned offset, packet_info *pinfo _U_, proto_tree *tree) |
127 | 0 | { |
128 | 0 | uint16_t reason; |
129 | |
|
130 | 0 | proto_tree_add_item_ret_uint16(tree, hf_btamp_rej_reason, tvb, offset, 2, ENC_LITTLE_ENDIAN, &reason); |
131 | 0 | offset += 2; |
132 | |
|
133 | 0 | switch (reason) { |
134 | 0 | case 0x0000: /* Command not understood */ |
135 | 0 | break; |
136 | | |
137 | 0 | default: |
138 | 0 | break; |
139 | 0 | } |
140 | | |
141 | 0 | return offset; |
142 | 0 | } |
143 | | |
144 | | static int |
145 | | dissect_discoverrequest(tvbuff_t *tvb, unsigned offset, packet_info *pinfo _U_, proto_tree *tree) |
146 | 1 | { |
147 | 1 | proto_tree_add_item(tree, hf_btamp_mtu, tvb, offset, 2, ENC_LITTLE_ENDIAN); |
148 | 1 | offset += 2; |
149 | | |
150 | 1 | proto_tree_add_item(tree, hf_btamp_extfeatures, tvb, offset, 2, ENC_LITTLE_ENDIAN); |
151 | 1 | offset += 2; |
152 | | |
153 | 1 | return offset; |
154 | 1 | } |
155 | | |
156 | | static int |
157 | | dissect_controller_entry(tvbuff_t *tvb, unsigned offset, packet_info *pinfo _U_, proto_tree *tree, uint16_t idx) |
158 | 35 | { |
159 | 35 | proto_item *ti_controller_entry; |
160 | 35 | proto_tree *btamp_controller_entry_tree; |
161 | | |
162 | 35 | ti_controller_entry = proto_tree_add_none_format(tree, |
163 | 35 | hf_btamp_controllers, tvb, |
164 | 35 | offset, 3, |
165 | 35 | "Entry: %u", idx); |
166 | 35 | btamp_controller_entry_tree = proto_item_add_subtree(ti_controller_entry, ett_btamp_controller_entry); |
167 | | |
168 | 35 | proto_tree_add_item(btamp_controller_entry_tree, hf_btamp_controller_id, tvb, offset, 1, ENC_LITTLE_ENDIAN); |
169 | 35 | offset += 1; |
170 | | |
171 | 35 | proto_tree_add_item(btamp_controller_entry_tree, hf_btamp_controller_type, tvb, offset, 1, ENC_LITTLE_ENDIAN); |
172 | 35 | offset += 1; |
173 | | |
174 | 35 | proto_tree_add_item(btamp_controller_entry_tree, hf_btamp_controller_status, tvb, offset, 1, ENC_LITTLE_ENDIAN); |
175 | 35 | offset += 1; |
176 | | |
177 | 35 | return offset; |
178 | 35 | } |
179 | | |
180 | | static int |
181 | | dissect_discoverresponse(tvbuff_t *tvb, unsigned offset, packet_info *pinfo, proto_tree *tree) |
182 | 1 | { |
183 | 1 | uint16_t length; |
184 | 1 | uint16_t idx = 1; |
185 | 1 | proto_item *ti_controller_list; |
186 | 1 | proto_tree *btamp_controller_list_tree; |
187 | | |
188 | 1 | proto_tree_add_item(tree, hf_btamp_mtu, tvb, offset, 2, ENC_LITTLE_ENDIAN); |
189 | 1 | offset += 2; |
190 | | |
191 | 1 | proto_tree_add_item(tree, hf_btamp_extfeatures, tvb, offset, 2, ENC_LITTLE_ENDIAN); |
192 | 1 | offset += 2; |
193 | | |
194 | 1 | length = tvb_reported_length_remaining(tvb, offset); |
195 | 1 | ti_controller_list = proto_tree_add_none_format(tree, |
196 | 1 | hf_btamp_controller_list, tvb, |
197 | 1 | offset, length, |
198 | 1 | "Controller list"); |
199 | 1 | btamp_controller_list_tree = proto_item_add_subtree(ti_controller_list, ett_btamp_controller_list); |
200 | | |
201 | 2 | while (tvb_reported_length_remaining(tvb, offset) >= 3) { |
202 | 1 | offset = dissect_controller_entry(tvb, offset, pinfo, btamp_controller_list_tree, idx); |
203 | 1 | idx += 1; |
204 | 1 | } |
205 | | |
206 | 1 | return offset; |
207 | 1 | } |
208 | | |
209 | | static int |
210 | | dissect_changenotify(tvbuff_t *tvb, unsigned offset, packet_info *pinfo, proto_tree *tree) |
211 | 2 | { |
212 | 2 | uint16_t length; |
213 | 2 | uint16_t idx = 1; |
214 | 2 | proto_item *ti_controller_list; |
215 | 2 | proto_tree *btamp_controller_list_tree; |
216 | | |
217 | 2 | length = tvb_reported_length_remaining(tvb, offset); |
218 | 2 | ti_controller_list = proto_tree_add_none_format(tree, |
219 | 2 | hf_btamp_controller_list, tvb, |
220 | 2 | offset, length, |
221 | 2 | "Controller list"); |
222 | 2 | btamp_controller_list_tree = proto_item_add_subtree(ti_controller_list, ett_btamp_controller_list); |
223 | | |
224 | 36 | while (tvb_reported_length_remaining(tvb, offset) >= 3) { |
225 | 34 | offset = dissect_controller_entry(tvb, offset, pinfo, btamp_controller_list_tree, idx); |
226 | 34 | idx += 1; |
227 | 34 | } |
228 | | |
229 | 2 | return offset; |
230 | 2 | } |
231 | | |
232 | | static int |
233 | | dissect_changeresponse(tvbuff_t *tvb _U_, unsigned offset, packet_info *pinfo _U_, proto_tree *tree _U_) |
234 | 0 | { |
235 | 0 | return offset; |
236 | 0 | } |
237 | | |
238 | | static int |
239 | | dissect_getinforequest(tvbuff_t *tvb, unsigned offset, packet_info *pinfo _U_, proto_tree *tree) |
240 | 1 | { |
241 | 1 | proto_tree_add_item(tree, hf_btamp_controller_id, tvb, offset, 1, ENC_LITTLE_ENDIAN); |
242 | 1 | offset += 1; |
243 | | |
244 | 1 | return offset; |
245 | 1 | } |
246 | | |
247 | | static int |
248 | | dissect_getinforesponse(tvbuff_t *tvb, unsigned offset, packet_info *pinfo _U_, proto_tree *tree) |
249 | 0 | { |
250 | 0 | proto_item *ti_controller; |
251 | 0 | proto_tree *btamp_controller_tree; |
252 | |
|
253 | 0 | proto_tree_add_item(tree, hf_btamp_controller_id, tvb, offset, 1, ENC_LITTLE_ENDIAN); |
254 | 0 | offset += 1; |
255 | |
|
256 | 0 | proto_tree_add_item(tree, hf_btamp_status, tvb, offset, 1, ENC_LITTLE_ENDIAN); |
257 | 0 | offset += 1; |
258 | |
|
259 | 0 | proto_tree_add_item(tree, hf_btamp_total_bw, tvb, offset, 4, ENC_LITTLE_ENDIAN); |
260 | 0 | offset += 4; |
261 | |
|
262 | 0 | proto_tree_add_item(tree, hf_btamp_max_guaran_bw, tvb, offset, 4, ENC_LITTLE_ENDIAN); |
263 | 0 | offset += 4; |
264 | |
|
265 | 0 | proto_tree_add_item(tree, hf_btamp_min_latency, tvb, offset, 4, ENC_LITTLE_ENDIAN); |
266 | 0 | offset += 4; |
267 | |
|
268 | 0 | ti_controller = proto_tree_add_none_format(tree, |
269 | 0 | hf_btamp_pal_caps_mask, tvb, |
270 | 0 | offset, 2, |
271 | 0 | "PAL Capabilities"); |
272 | 0 | btamp_controller_tree = proto_item_add_subtree(ti_controller, ett_btamp_caps); |
273 | 0 | proto_tree_add_item(btamp_controller_tree, hf_btamp_pal_caps_guaranteed, tvb, offset, 2, ENC_LITTLE_ENDIAN); |
274 | 0 | offset += 2; |
275 | |
|
276 | 0 | proto_tree_add_item(tree, hf_btamp_amp_assoc_size, tvb, offset, 2, ENC_LITTLE_ENDIAN); |
277 | 0 | offset += 2; |
278 | |
|
279 | 0 | return offset; |
280 | 0 | } |
281 | | |
282 | | static int |
283 | | dissect_getampassocrequest(tvbuff_t *tvb, unsigned offset, packet_info *pinfo _U_, proto_tree *tree) |
284 | 0 | { |
285 | 0 | proto_tree_add_item(tree, hf_btamp_controller_id, tvb, offset, 1, ENC_LITTLE_ENDIAN); |
286 | 0 | offset += 1; |
287 | |
|
288 | 0 | return offset; |
289 | 0 | } |
290 | | |
291 | | static int |
292 | | dissect_ampassoc(tvbuff_t *tvb, unsigned offset, packet_info *pinfo _U_, proto_tree *tree) |
293 | 0 | { |
294 | 0 | proto_tree_add_item(tree, hf_btamp_amp_assoc, tvb, offset, tvb_reported_length_remaining(tvb, offset), ENC_NA); |
295 | 0 | return tvb_reported_length(tvb); |
296 | 0 | } |
297 | | |
298 | | static int |
299 | | dissect_getampassocresponse(tvbuff_t *tvb, unsigned offset, packet_info *pinfo, proto_tree *tree) |
300 | 0 | { |
301 | 0 | proto_tree_add_item(tree, hf_btamp_controller_id, tvb, offset, 1, ENC_LITTLE_ENDIAN); |
302 | 0 | offset += 1; |
303 | |
|
304 | 0 | proto_tree_add_item(tree, hf_btamp_status, tvb, offset, 1, ENC_LITTLE_ENDIAN); |
305 | 0 | offset += 1; |
306 | |
|
307 | 0 | offset = dissect_ampassoc(tvb, offset, pinfo, tree); |
308 | |
|
309 | 0 | return offset; |
310 | 0 | } |
311 | | |
312 | | static int |
313 | | dissect_createphysicalrequest(tvbuff_t *tvb, unsigned offset, packet_info *pinfo, proto_tree *tree) |
314 | 0 | { |
315 | 0 | proto_tree_add_item(tree, hf_btamp_lcontroller_id, tvb, offset, 1, ENC_LITTLE_ENDIAN); |
316 | 0 | offset += 1; |
317 | |
|
318 | 0 | proto_tree_add_item(tree, hf_btamp_rcontroller_id, tvb, offset, 1, ENC_LITTLE_ENDIAN); |
319 | 0 | offset += 1; |
320 | |
|
321 | 0 | offset = dissect_ampassoc(tvb, offset, pinfo, tree); |
322 | |
|
323 | 0 | return offset; |
324 | 0 | } |
325 | | |
326 | | static int |
327 | | dissect_createphysicalresponse(tvbuff_t *tvb, unsigned offset, packet_info *pinfo _U_, proto_tree *tree) |
328 | 0 | { |
329 | 0 | proto_tree_add_item(tree, hf_btamp_lcontroller_id, tvb, offset, 1, ENC_LITTLE_ENDIAN); |
330 | 0 | offset += 1; |
331 | |
|
332 | 0 | proto_tree_add_item(tree, hf_btamp_rcontroller_id, tvb, offset, 1, ENC_LITTLE_ENDIAN); |
333 | 0 | offset += 1; |
334 | |
|
335 | 0 | proto_tree_add_item(tree, hf_btamp_status, tvb, offset, 1, ENC_LITTLE_ENDIAN); |
336 | 0 | offset += 1; |
337 | |
|
338 | 0 | return offset; |
339 | 0 | } |
340 | | |
341 | | static int |
342 | | dissect_discphysicalchanrequest(tvbuff_t *tvb, unsigned offset, packet_info *pinfo _U_, proto_tree *tree) |
343 | 0 | { |
344 | 0 | proto_tree_add_item(tree, hf_btamp_lcontroller_id, tvb, offset, 1, ENC_LITTLE_ENDIAN); |
345 | 0 | offset += 1; |
346 | |
|
347 | 0 | proto_tree_add_item(tree, hf_btamp_rcontroller_id, tvb, offset, 1, ENC_LITTLE_ENDIAN); |
348 | 0 | offset += 1; |
349 | |
|
350 | 0 | return offset; |
351 | 0 | } |
352 | | |
353 | | static int |
354 | | dissect_discphysicalchanresponse(tvbuff_t *tvb, unsigned offset, packet_info *pinfo _U_, proto_tree *tree) |
355 | 0 | { |
356 | 0 | proto_tree_add_item(tree, hf_btamp_lcontroller_id, tvb, offset, 1, ENC_LITTLE_ENDIAN); |
357 | 0 | offset += 1; |
358 | |
|
359 | 0 | proto_tree_add_item(tree, hf_btamp_rcontroller_id, tvb, offset, 1, ENC_LITTLE_ENDIAN); |
360 | 0 | offset += 1; |
361 | |
|
362 | 0 | proto_tree_add_item(tree, hf_btamp_controller_status, tvb, offset, 1, ENC_LITTLE_ENDIAN); |
363 | 0 | offset += 1; |
364 | |
|
365 | 0 | return offset; |
366 | 0 | } |
367 | | |
368 | | static int |
369 | | dissect_btamp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) |
370 | 6 | { |
371 | 6 | int offset = 0; |
372 | 6 | proto_item *ti; |
373 | 6 | proto_tree *btamp_tree; |
374 | 6 | uint16_t length; |
375 | 6 | proto_item *ti_command; |
376 | 6 | proto_tree *btamp_cmd_tree; |
377 | 6 | uint8_t cmd_code; |
378 | 6 | char *str_cmd_code; |
379 | 6 | uint16_t cmd_length; |
380 | | |
381 | 6 | col_set_str(pinfo->cinfo, COL_PROTOCOL, "AMP"); |
382 | | |
383 | 6 | switch (pinfo->p2p_dir) { |
384 | 0 | case P2P_DIR_SENT: |
385 | 0 | col_set_str(pinfo->cinfo, COL_INFO, "Sent "); |
386 | 0 | break; |
387 | 0 | case P2P_DIR_RECV: |
388 | 0 | col_set_str(pinfo->cinfo, COL_INFO, "Rcvd "); |
389 | 0 | break; |
390 | 6 | default: |
391 | 6 | col_set_str(pinfo->cinfo, COL_INFO, "UnknownDirection "); |
392 | 6 | break; |
393 | 6 | } |
394 | | |
395 | 6 | ti = proto_tree_add_item(tree, proto_btamp, tvb, offset, -1, ENC_NA); |
396 | 6 | btamp_tree = proto_item_add_subtree(ti, ett_btamp); |
397 | | |
398 | 6 | length = tvb_reported_length_remaining(tvb, offset); |
399 | 6 | ti_command = proto_tree_add_none_format(btamp_tree, |
400 | 6 | hf_btamp_command, tvb, |
401 | 6 | offset, length, |
402 | 6 | "Command: "); |
403 | 6 | btamp_cmd_tree = proto_item_add_subtree(ti_command, ett_btamp_cmd); |
404 | | |
405 | 6 | proto_tree_add_item_ret_uint8(btamp_cmd_tree, hf_btamp_cmd_code, tvb, offset, 1, ENC_LITTLE_ENDIAN, &cmd_code); |
406 | 6 | offset += 1; |
407 | | |
408 | 6 | proto_tree_add_item(btamp_cmd_tree, hf_btamp_cmd_ident, tvb, offset, 1, ENC_LITTLE_ENDIAN); |
409 | 6 | offset += 1; |
410 | | |
411 | 6 | proto_tree_add_item_ret_uint16(btamp_cmd_tree, hf_btamp_cmd_length, tvb, offset, 2, ENC_LITTLE_ENDIAN, &cmd_length); |
412 | 6 | proto_item_set_len(ti_command, cmd_length+4); |
413 | 6 | offset += 2; |
414 | | |
415 | 6 | switch(cmd_code) { |
416 | 0 | case 0x01: /* Command Reject */ |
417 | 0 | offset = dissect_comrej(tvb, offset, pinfo, btamp_cmd_tree); |
418 | 0 | break; |
419 | | |
420 | 1 | case 0x02: /* Discover Request */ |
421 | 1 | offset = dissect_discoverrequest(tvb, offset, pinfo, btamp_cmd_tree); |
422 | 1 | break; |
423 | | |
424 | 1 | case 0x03: /* Discover Response */ |
425 | 1 | offset = dissect_discoverresponse(tvb, offset, pinfo, btamp_cmd_tree); |
426 | 1 | break; |
427 | | |
428 | 2 | case 0x04: /* AMP Change Notify */ |
429 | 2 | offset = dissect_changenotify(tvb, offset, pinfo, btamp_cmd_tree); |
430 | 2 | break; |
431 | | |
432 | 0 | case 0x05: /* AMP Change Response */ |
433 | 0 | offset = dissect_changeresponse(tvb, offset, pinfo, btamp_cmd_tree); |
434 | 0 | break; |
435 | | |
436 | 1 | case 0x06: /* AMP Get Info Request */ |
437 | 1 | offset = dissect_getinforequest(tvb, offset, pinfo, btamp_cmd_tree); |
438 | 1 | break; |
439 | | |
440 | 0 | case 0x07: /* AMP Get Info Response */ |
441 | 0 | offset = dissect_getinforesponse(tvb, offset, pinfo, btamp_cmd_tree); |
442 | 0 | break; |
443 | | |
444 | 0 | case 0x08: /* Get AMP Assoc Request */ |
445 | 0 | offset = dissect_getampassocrequest(tvb, offset, pinfo, btamp_cmd_tree); |
446 | 0 | break; |
447 | | |
448 | 0 | case 0x09: /* Get AMP Assoc Response */ |
449 | 0 | offset = dissect_getampassocresponse(tvb, offset, pinfo, btamp_cmd_tree); |
450 | 0 | break; |
451 | | |
452 | 0 | case 0x0A: /* Create Physical Link Request */ |
453 | 0 | offset = dissect_createphysicalrequest(tvb, offset, pinfo, btamp_cmd_tree); |
454 | 0 | break; |
455 | | |
456 | 0 | case 0x0B: /* Create Physical Link Response */ |
457 | 0 | offset = dissect_createphysicalresponse(tvb, offset, pinfo, btamp_cmd_tree); |
458 | 0 | break; |
459 | | |
460 | 0 | case 0x0c: /* Disconnect Physical Link Request */ |
461 | 0 | offset = dissect_discphysicalchanrequest(tvb, offset, pinfo, btamp_cmd_tree); |
462 | 0 | break; |
463 | | |
464 | 0 | case 0x0d: /* Disconnect Physical Link Response */ |
465 | 0 | offset = dissect_discphysicalchanresponse(tvb, offset, pinfo, btamp_cmd_tree); |
466 | 0 | break; |
467 | | |
468 | 1 | default: |
469 | 1 | proto_tree_add_item(btamp_cmd_tree, hf_btamp_cmd_data, tvb, offset, -1, ENC_NA); |
470 | 1 | offset = tvb_reported_length(tvb); |
471 | 1 | break; |
472 | 6 | } |
473 | | |
474 | 5 | str_cmd_code = val_to_str(pinfo->pool, cmd_code, command_code_vals, "Unknown PDU (%u)"); |
475 | 5 | proto_item_append_text(ti_command, "%s", str_cmd_code); |
476 | 5 | col_append_str(pinfo->cinfo, COL_INFO, str_cmd_code); |
477 | | |
478 | 5 | return offset; |
479 | 6 | } |
480 | | |
481 | | /* Register the protocol with Wireshark */ |
482 | | void |
483 | | proto_register_btamp(void) |
484 | 14 | { |
485 | | /* Setup list of header fields See Section 1.6.1 for details*/ |
486 | 14 | static hf_register_info hf[] = { |
487 | 14 | { &hf_btamp_command, |
488 | 14 | { "Command", "btamp.command", |
489 | 14 | FT_NONE, BASE_NONE, NULL, 0x0, |
490 | 14 | "L2CAP Command", HFILL } |
491 | 14 | }, |
492 | 14 | { &hf_btamp_cmd_code, |
493 | 14 | { "Command Code", "btamp.cmd_code", |
494 | 14 | FT_UINT8, BASE_HEX, VALS(command_code_vals), 0x0, |
495 | 14 | "L2CAP Command Code", HFILL } |
496 | 14 | }, |
497 | 14 | { &hf_btamp_cmd_ident, |
498 | 14 | { "Command Identifier", "btamp.cmd_ident", |
499 | 14 | FT_UINT8, BASE_HEX, NULL, 0x0, |
500 | 14 | "L2CAP Command Identifier", HFILL } |
501 | 14 | }, |
502 | 14 | { &hf_btamp_cmd_length, |
503 | 14 | { "Command Length", "btamp.cmd_length", |
504 | 14 | FT_UINT16, BASE_DEC, NULL, 0x0, |
505 | 14 | "L2CAP Command Length", HFILL } |
506 | 14 | }, |
507 | 14 | { &hf_btamp_cmd_data, |
508 | 14 | { "Command Data", "btamp.cmd_data", |
509 | 14 | FT_NONE, BASE_NONE, NULL, 0x0, |
510 | 14 | "L2CAP Command Data", HFILL } |
511 | 14 | }, |
512 | 14 | { &hf_btamp_rej_reason, |
513 | 14 | { "Reason", "btamp.rej_reason", |
514 | 14 | FT_UINT16, BASE_HEX, VALS(reason_vals), 0x0, |
515 | 14 | NULL, HFILL } |
516 | 14 | }, |
517 | 14 | { &hf_btamp_mtu, |
518 | 14 | { "MPS/MTU", "btamp.mps", |
519 | 14 | FT_UINT16, BASE_HEX, NULL, 0x0, |
520 | 14 | "MPS/MTU Size", HFILL } |
521 | 14 | }, |
522 | 14 | { &hf_btamp_extfeatures, |
523 | 14 | { "Extended Features", "btamp.extfeatures", |
524 | 14 | FT_UINT16, BASE_HEX, NULL, 0x0, |
525 | 14 | "Extended Features Mask", HFILL } |
526 | 14 | }, |
527 | 14 | { &hf_btamp_controllers, |
528 | 14 | { "Controller entry", "btamp.ctrl_entry", |
529 | 14 | FT_NONE, BASE_NONE, NULL, 0x0, |
530 | 14 | NULL, HFILL } |
531 | 14 | }, |
532 | 14 | { &hf_btamp_controller_list, |
533 | 14 | { "Controller list", "btamp.ctrl_list", |
534 | 14 | FT_NONE, BASE_NONE, NULL, 0x0, |
535 | 14 | NULL, HFILL } |
536 | 14 | }, |
537 | 14 | { &hf_btamp_lcontroller_id, |
538 | 14 | { "Local Controller ID", "btamp.lctrl_id", |
539 | 14 | FT_UINT8, BASE_DEC, NULL, 0x0, |
540 | 14 | NULL, HFILL } |
541 | 14 | }, |
542 | 14 | { &hf_btamp_rcontroller_id, |
543 | 14 | { "Remote Controller ID", "btamp.rctrl_id", |
544 | 14 | FT_UINT8, BASE_DEC, NULL, 0x0, |
545 | 14 | NULL, HFILL } |
546 | 14 | }, |
547 | 14 | { &hf_btamp_controller_id, |
548 | 14 | { "Controller ID", "btamp.ctrl_id", |
549 | 14 | FT_UINT8, BASE_DEC, NULL, 0x0, |
550 | 14 | NULL, HFILL } |
551 | 14 | }, |
552 | 14 | { &hf_btamp_controller_type, |
553 | 14 | { "Controller Type", "btamp.ctrl_type", |
554 | 14 | FT_UINT8, BASE_DEC, VALS(controller_type_vals), 0x0, |
555 | 14 | NULL, HFILL } |
556 | 14 | }, |
557 | 14 | { &hf_btamp_controller_status, |
558 | 14 | { "Controller Status", "btamp.ctrl_status", |
559 | 14 | FT_UINT8, BASE_DEC, VALS(controller_status_vals), 0x0, |
560 | 14 | NULL, HFILL } |
561 | 14 | }, |
562 | 14 | { &hf_btamp_status, |
563 | 14 | { "Status", "btamp.status", |
564 | 14 | FT_UINT8, BASE_DEC, VALS(status_vals), 0x0, |
565 | 14 | NULL, HFILL } |
566 | 14 | }, |
567 | | #if 0 |
568 | | { &hf_btamp_create_status, |
569 | | { "Status", "btamp.create_status", |
570 | | FT_UINT8, BASE_DEC, VALS(create_status_vals), 0x0, |
571 | | NULL, HFILL } |
572 | | }, |
573 | | { &hf_btamp_disc_status, |
574 | | { "Status", "btamp.disc_status", |
575 | | FT_UINT8, BASE_DEC, VALS(disc_status_vals), 0x0, |
576 | | NULL, HFILL } |
577 | | }, |
578 | | #endif |
579 | 14 | { &hf_btamp_pal_caps_mask, |
580 | 14 | { "PAL Capabilities Mask", "btamp.pal_caps_mask", |
581 | 14 | FT_NONE, BASE_NONE, NULL, 0x0, |
582 | 14 | NULL, HFILL } |
583 | 14 | }, |
584 | 14 | { &hf_btamp_pal_caps_guaranteed, |
585 | 14 | { "Guaranteed Service type", "btamp.guaranteed_type", |
586 | 14 | FT_BOOLEAN, 16, NULL, 0x0001, |
587 | 14 | NULL, HFILL } |
588 | 14 | }, |
589 | 14 | { &hf_btamp_total_bw, |
590 | 14 | { "Total Bandwidth", "btamp.total_bw", |
591 | 14 | FT_UINT32, BASE_HEX, NULL, 0x0, |
592 | 14 | NULL, HFILL } |
593 | 14 | }, |
594 | 14 | { &hf_btamp_max_guaran_bw, |
595 | 14 | { "Max Guaranteed Bandwidth", "btamp.max_guaran_bw", |
596 | 14 | FT_UINT32, BASE_HEX, NULL, 0x0, |
597 | 14 | NULL, HFILL } |
598 | 14 | }, |
599 | 14 | { &hf_btamp_min_latency, |
600 | 14 | { "Minimum latency", "btamp.min_latency", |
601 | 14 | FT_UINT32, BASE_HEX, NULL, 0x0, |
602 | 14 | NULL, HFILL } |
603 | 14 | }, |
604 | 14 | { &hf_btamp_amp_assoc_size, |
605 | 14 | { "Assoc Size", "btamp.assoc_size", |
606 | 14 | FT_UINT16, BASE_HEX, NULL, 0x0, |
607 | 14 | NULL, HFILL } |
608 | 14 | }, |
609 | 14 | { &hf_btamp_amp_assoc, |
610 | 14 | { "Assoc", "btamp.assoc", |
611 | 14 | FT_BYTES, BASE_NONE, NULL, 0x0, |
612 | 14 | NULL, HFILL } |
613 | 14 | }, |
614 | 14 | }; |
615 | | |
616 | | /* Setup protocol subtree array */ |
617 | 14 | static int *ett[] = { |
618 | 14 | &ett_btamp, |
619 | 14 | &ett_btamp_cmd, |
620 | 14 | &ett_btamp_caps, |
621 | 14 | &ett_btamp_controller_entry, |
622 | 14 | &ett_btamp_controller_list, |
623 | 14 | }; |
624 | | |
625 | | /* Register the protocol name and description */ |
626 | 14 | proto_btamp = proto_register_protocol("Bluetooth AMP Packet", "BT AMP", "btamp"); |
627 | | |
628 | 14 | btamp_handle = register_dissector("btamp", dissect_btamp, proto_btamp); |
629 | | |
630 | | /* Required function calls to register the header fields and subtrees used */ |
631 | 14 | proto_register_field_array(proto_btamp, hf, array_length(hf)); |
632 | 14 | proto_register_subtree_array(ett, array_length(ett)); |
633 | 14 | } |
634 | | |
635 | | void |
636 | | proto_reg_handoff_btamp(void) |
637 | 14 | { |
638 | 14 | dissector_add_uint("btl2cap.cid", BTL2CAP_FIXED_CID_AMP_MAN, btamp_handle); |
639 | 14 | } |
640 | | |
641 | | /* |
642 | | * Editor modelines - https://www.wireshark.org/tools/modelines.html |
643 | | * |
644 | | * Local variables: |
645 | | * c-basic-offset: 4 |
646 | | * tab-width: 8 |
647 | | * indent-tabs-mode: nil |
648 | | * End: |
649 | | * |
650 | | * vi: set shiftwidth=4 tabstop=8 expandtab: |
651 | | * :indentSize=4:tabSize=8:noTabs=true: |
652 | | */ |