1 /* packet-aastra-aasp.c
2 * Routines for AASP (Aastra Signalling Protocol) packet dissection.
3 * Copyright 2011, Marek Tews <marek.tews@gmail.com>
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * SPDX-License-Identifier: GPL-2.0-or-later
14 * Content-Type: message/x-aasp-signalling
19 #include <epan/packet.h>
22 #define BEGIN_BLOCK_DATA 0x80
26 #define MENU_ITEM 0x85
27 #define CONTEXT_INFO 0x86
28 #define BUTTON_PRESSED 0x87
31 #define DATE_TIME_INFO 0xA4
32 #define INCOMING_CALLER 0xA5
33 #define DO_COMMAND 0xA9
34 #define PUSH_BTN_C 0xC8
35 #define PUSH_BTN_TASK 0xC9
36 #define PUSH_BTN_PLUS 0xCA
37 #define PUSH_BTN_MINUS 0xCB
38 #define PUSH_BTN_MIC 0xCC
39 #define PUSH_BTN_SPK 0xCD
40 #define PUSH_BTN_TBOOK 0xCE
41 #define PUSH_BTN_DBL_ARROW 0xCF
42 #define PUSH_BTN_ON_HOOK 0xD0
43 #define PUSH_BTN_OFF_HOOK 0xD1
44 #define PUSH_BTN_UP 0xD2
45 #define PUSH_BTN_DOWN 0xD3
46 #define PUSH_BTN_LEFT 0xD4
47 #define PUSH_BTN_RIGHT 0xD5
48 #define END_BLOCK_DATA 0xFE
51 /* Forward declarations */
52 void proto_register_aasp(void);
53 void proto_reg_handoff_aasp(void);
55 static dissector_handle_t aasp_handle
;
57 /* Initialize the protocol and registered fields */
58 static int proto_aasp
;
63 static int hf_a_length
;
67 static int hf_a_button_id
;
73 static int hf_a_minute
;
75 static int hf_a_month
;
76 static int hf_a_weekofyear
;
77 static int hf_a_weekday
;
78 static int hf_a_month_name
;
79 static int hf_a_weekofyear_prefix
;
81 /* Initialize the subtree pointers */
84 static int ett_a_item
;
91 static const value_string szCmdID
[] =
93 { BEGIN_BLOCK_DATA
, "Begin Block Data" },
97 { MENU_ITEM
, "Menu Item" },
98 { CONTEXT_INFO
, "Context Info" },
99 { BUTTON_PRESSED
, "Button Pressed" },
100 { COLUMN
, "Column" },
101 { SET_TEXT
, "Set Text" },
102 { DATE_TIME_INFO
, "Date Time Info" },
103 { INCOMING_CALLER
, "Incoming Caller" },
104 { DO_COMMAND
, "Do Command" },
105 { PUSH_BTN_C
, "Push Button 'C'" },
106 { PUSH_BTN_TASK
, "Push Button 'Task'" },
107 { PUSH_BTN_PLUS
, "Push Button '+'" },
108 { PUSH_BTN_MINUS
, "Push Button '-'" },
109 { PUSH_BTN_MIC
, "Push Button 'Microphone'" },
110 { PUSH_BTN_SPK
, "Push Button 'Speaker'" },
111 { PUSH_BTN_TBOOK
, "Push Button 'Telephone Book'" },
112 { PUSH_BTN_DBL_ARROW
, "Push Button 'Double-Arrow'" },
113 { PUSH_BTN_ON_HOOK
, "Red Button 'On Hook'" },
114 { PUSH_BTN_OFF_HOOK
, "Green Button 'Off Hook'" },
115 { PUSH_BTN_UP
, "Push Button 'Up'" },
116 { PUSH_BTN_DOWN
, "Push Button 'Down'" },
117 { PUSH_BTN_LEFT
, "Push Button 'Left'" },
118 { PUSH_BTN_RIGHT
, "Push Button 'Right'" },
119 { END_BLOCK_DATA
, "End Block Data" },
124 * Dissect single command
127 dissect_a_binary_command(tvbuff_t
*tvb
, packet_info
*pinfo _U_
, proto_tree
*tree
)
134 /* create command subtree */
135 ti
= proto_tree_add_item(tree
, hf_a_cmd
, tvb
, 0, -1, ENC_NA
);
136 subtree
= proto_item_add_subtree(ti
, ett_a_cmd
);
137 proto_item_append_text(ti
, ", %s", val_to_str(tvb_get_uint8(tvb
, 0), szCmdID
, "Unk %d"));
140 proto_tree_add_item(subtree
, hf_a_id
, tvb
, 0, 1, ENC_BIG_ENDIAN
);
143 switch(tvb_get_uint8(tvb
, 0))
147 if(tvb_reported_length(tvb
) > 1)
148 proto_tree_add_item(subtree
, hf_a_data
, tvb
, 1, -1, ENC_NA
);
153 for(i
= 1; i
<tvb_reported_length(tvb
); )
155 switch(tvb_get_uint8(tvb
, i
))
157 default: i
= tvb_reported_length(tvb
); continue;
163 ti
= proto_tree_add_item(subtree
, hf_a_attr
, tvb
, i
, 2, ENC_NA
);
164 proto_item_append_text(ti
, " %d", tvb_get_uint8(tvb
, i
));
171 ti
= proto_tree_add_item(subtree
, hf_a_attr
, tvb
, i
, 3, ENC_NA
);
172 proto_item_append_text(ti
, " %d", tvb_get_uint8(tvb
, i
));
178 ti
= proto_tree_add_item(subtree
, hf_a_attr
, tvb
, i
, 5, ENC_NA
);
179 proto_item_append_text(ti
, " %d", tvb_get_uint8(tvb
, i
));
188 uint8_t c
= tvb_get_uint8(tvb
, 5);
189 proto_item_append_text(ti
, ": %d '%c'", c
, c
);
191 proto_tree_add_item(subtree
, hf_a_data
, tvb
, 1, 4, ENC_NA
);
192 ti
= proto_tree_add_item(subtree
, hf_a_button_id
, tvb
, 5, 1, ENC_BIG_ENDIAN
);
194 proto_item_append_text(ti
, " '%c'", c
);
199 if(tvb_reported_length(tvb
) > 3)
201 proto_tree_add_item(subtree
, hf_a_data
, tvb
, 1, 3, ENC_NA
);
202 proto_tree_add_item(subtree
, hf_a_length
, tvb
, 4, 1, ENC_BIG_ENDIAN
);
203 proto_tree_add_item(subtree
, hf_a_text
, tvb
, 5, -1, ENC_ASCII
);
205 pstr
= tvb_get_string_enc(pinfo
->pool
, tvb
, 5, tvb_get_uint8(tvb
, 4), ENC_ASCII
|ENC_NA
);
208 proto_item_append_text(ti
, ": '%s'", pstr
);
213 proto_tree_add_item(subtree
, hf_a_data
, tvb
, 1, -1, ENC_NA
);
219 proto_tree
*infotree
;
221 for(i
=1; i
<tvb_reported_length(tvb
); )
223 switch(tvb_get_uint8(tvb
, i
))
229 ti
= proto_tree_add_item(subtree
, hf_a_item
, tvb
, i
, len
, ENC_NA
);
230 infotree
= proto_item_add_subtree(ti
, ett_a_item
);
231 proto_tree_add_item(infotree
, hf_a_day
, tvb
, i
+1, 1, ENC_BIG_ENDIAN
);
232 proto_item_append_text(ti
, ", Day: '%d'", tvb_get_uint8(tvb
, i
+1));
239 ti
= proto_tree_add_item(subtree
, hf_a_item
, tvb
, i
, len
, ENC_NA
);
240 infotree
= proto_item_add_subtree(ti
, ett_a_item
);
241 proto_tree_add_item(infotree
, hf_a_month
, tvb
, i
+1, 1, ENC_BIG_ENDIAN
);
242 proto_item_append_text(ti
, ", Month: '%d'", tvb_get_uint8(tvb
, i
+1));
249 ti
= proto_tree_add_item(subtree
, hf_a_item
, tvb
, i
, len
, ENC_NA
);
250 infotree
= proto_item_add_subtree(ti
, ett_a_item
);
251 proto_tree_add_item(infotree
, hf_a_weekofyear
, tvb
, i
+1, 1, ENC_BIG_ENDIAN
);
252 proto_item_append_text(ti
, ", Week of the year: '%d'", tvb_get_uint8(tvb
, i
+1));
258 len
= tvb_get_uint8(tvb
, i
+1);
259 ti
= proto_tree_add_item(subtree
, hf_a_item
, tvb
, i
, len
+2, ENC_NA
);
260 infotree
= proto_item_add_subtree(ti
, ett_a_item
);
261 proto_tree_add_item(infotree
, hf_a_data
, tvb
, i
+2, len
, ENC_NA
);
267 len
= tvb_get_uint8(tvb
, i
+1);
268 ti
= proto_tree_add_item(subtree
, hf_a_item
, tvb
, i
, len
+2, ENC_NA
);
269 infotree
= proto_item_add_subtree(ti
, ett_a_item
);
270 proto_tree_add_item_ret_string(infotree
, hf_a_weekday
, tvb
, i
+2, len
, ENC_ASCII
|ENC_NA
, pinfo
->pool
, &pstr
);
272 proto_item_append_text(ti
, ", Weekday: '%s'", pstr
);
279 len
= tvb_get_uint8(tvb
, i
+1);
280 ti
= proto_tree_add_item(subtree
, hf_a_item
, tvb
, i
, len
+2, ENC_NA
);
281 infotree
= proto_item_add_subtree(ti
, ett_a_item
);
282 proto_tree_add_item_ret_string(infotree
, hf_a_month_name
, tvb
, i
+2, len
, ENC_ASCII
|ENC_NA
, pinfo
->pool
, &pstr
);
284 proto_item_append_text(ti
, ", Month name: '%s'", pstr
);
290 len
= tvb_get_uint8(tvb
, i
+1);
291 ti
= proto_tree_add_item(subtree
, hf_a_item
, tvb
, i
, len
+2, ENC_NA
);
292 infotree
= proto_item_add_subtree(ti
, ett_a_item
);
293 proto_tree_add_item_ret_string(infotree
, hf_a_weekofyear_prefix
, tvb
, i
+2, len
, ENC_ASCII
|ENC_NA
, pinfo
->pool
, &pstr
);
295 proto_item_append_text(ti
, ", Week of the year prefix: '%s'", pstr
);
302 ti
= proto_tree_add_item(subtree
, hf_a_item
, tvb
, i
, len
, ENC_NA
);
303 infotree
= proto_item_add_subtree(ti
, ett_a_item
);
304 proto_tree_add_item(infotree
, hf_a_hour
, tvb
, i
+1, 1, ENC_BIG_ENDIAN
);
305 proto_item_append_text(ti
, ", Hour: '%d'", tvb_get_uint8(tvb
, i
+1));
312 ti
= proto_tree_add_item(subtree
, hf_a_item
, tvb
, i
, len
, ENC_NA
);
313 infotree
= proto_item_add_subtree(ti
, ett_a_item
);
314 proto_tree_add_item(infotree
, hf_a_minute
, tvb
, i
+1, 1, ENC_BIG_ENDIAN
);
315 proto_item_append_text(ti
, ", Minute: '%d'", tvb_get_uint8(tvb
, i
+1));
322 ti
= proto_tree_add_item(subtree
, hf_a_item
, tvb
, i
, len
, ENC_NA
);
323 infotree
= proto_item_add_subtree(ti
, ett_a_item
);
324 proto_tree_add_item(infotree
, hf_a_data
, tvb
, i
+1, 1, ENC_NA
);
334 if(tvb_reported_length(tvb
) > 1)
336 proto_tree_add_item(subtree
, hf_a_line
, tvb
, 1, 1, ENC_BIG_ENDIAN
);
337 proto_tree_add_item(subtree
, hf_a_length
, tvb
, 2, 1, ENC_BIG_ENDIAN
);
338 proto_tree_add_item(subtree
, hf_a_cdpn
, tvb
, 3, -1, ENC_ASCII
);
340 pstr
= tvb_get_string_enc(pinfo
->pool
, tvb
, 3, tvb_get_uint8(tvb
, 2), ENC_ASCII
|ENC_NA
);
342 proto_item_append_text(ti
, ": '%s'", pstr
);
345 proto_item_append_text(ti
, ": ???");
352 * Searching for the next command when the variable or unknown length.
354 static unsigned searchNext(tvbuff_t
*tvb
, unsigned begin
, unsigned end
)
356 for(; begin
< end
; begin
++)
358 if(tvb_get_uint8(tvb
, begin
) & 0x80)
368 dissect_aasp(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *data _U_
)
370 /* Set up structures needed to add the protocol subtree and manage it */
371 proto_item
*ti
; proto_tree
*aasp_tree
; unsigned n
;
373 /* Check that there's enough data */
374 n
= tvb_reported_length(tvb
);
377 col_clear(pinfo
->cinfo
, COL_INFO
);
378 col_append_str(pinfo
->cinfo
, COL_PROTOCOL
, "/AASP");
384 /* create display subtree for the protocol */
385 ti
= proto_tree_add_item(tree
, proto_aasp
, tvb
, 0, -1, ENC_NA
);
386 aasp_tree
= proto_item_add_subtree(ti
, ett_aasp
);
388 /* separation of command; jump "a=" */
389 if(tvb_memeql(tvb
, 0, (const uint8_t*)"a=", 2) == 0)
394 switch(tvb_get_uint8(tvb
, i
))
399 /* 86:02:00:02:00:23:04:00 */
400 /* 86:02:00:12:00:23:04:00 */
401 /* 86:02:00:3a:02:77 */
402 /* 86:02:00:45:02:77 */
403 /* 86:02:00:62:02:77 */
404 /* 86:02:00:61:02:77 */
405 /* 86:02:00:1e:02:77 */
406 /* 86:02:00:00:12:77 */
407 /* 86:02:00:07:12:77 */
408 /* 86:02:00:00:00:01:03:02 */
409 /* 86:02:00:00:01:03:02 */
410 switch(tvb_get_uint8(tvb
, i
+2))
412 case 0x00: i
+= 11; break;
413 case 0x02: i
+= 8; break;
419 i
= searchNext(tvb
, i
+1, n
);
422 dissect_a_binary_command(tvb_new_subset_length(tvb
, prev
, i
-prev
), pinfo
, aasp_tree
);
428 proto_tree_add_item(aasp_tree
, hf_a_text
, tvb
, 0, -1, ENC_ASCII
);
432 /* Return the amount of data this dissector was able to dissect */
436 /* Register the protocol with Wireshark */
438 proto_register_aasp(void)
440 /*module_t *aasp_module;*/
442 /* Setup list of header fields See Section 1.6.1 for details*/
443 static hf_register_info hf
[] = {
445 { "Data", "aasp.bin.data", FT_BYTES
, BASE_NONE
, NULL
, 0, NULL
, HFILL
}},
447 { "Bin Cmd", "aasp.a", FT_NONE
, BASE_NONE
, NULL
, 0, NULL
, HFILL
}},
449 { "ID", "aasp.a.id", FT_UINT8
, BASE_DEC
, VALS(szCmdID
), 0, NULL
, HFILL
}},
451 { "Length", "aasp.bin.length", FT_UINT8
, BASE_DEC
, NULL
, 0, NULL
, HFILL
}},
453 { "Text", "aasp.bin.text", FT_STRING
, BASE_NONE
, NULL
, 0, NULL
, HFILL
}},
455 { "Line", "aasp.bin.line", FT_UINT8
, BASE_DEC
, NULL
, 0, NULL
, HFILL
}},
457 { "CDPN", "aasp.bin.cdpn", FT_STRING
, BASE_NONE
, NULL
, 0, NULL
, HFILL
}},
459 { "Button ID", "aasp.bin.btnid", FT_UINT8
, BASE_HEX_DEC
, NULL
, 0, NULL
, HFILL
}},
462 { "Attribute", "aasp.a.attr", FT_NONE
, BASE_NONE
, NULL
, 0, NULL
, HFILL
}},
465 { "Info item", "aasp.bin.infoitem", FT_NONE
, BASE_NONE
, NULL
, 0, NULL
, HFILL
}},
467 { "Hour", "aasp.bin.hour", FT_UINT8
, BASE_DEC
, NULL
, 0, NULL
, HFILL
}},
469 { "Minute", "aasp.bin.minute", FT_UINT8
, BASE_DEC
, NULL
, 0, NULL
, HFILL
}},
471 { "Day", "aasp.bin.day", FT_UINT8
, BASE_DEC
, NULL
, 0, NULL
, HFILL
}},
473 { "Month", "aasp.bin.month", FT_UINT8
, BASE_DEC
, NULL
, 0, NULL
, HFILL
}},
475 { "Week of the year", "aasp.bin.weekofyear", FT_UINT8
, BASE_DEC
, NULL
, 0,
476 "Week number in the year", HFILL
}},
478 { "Weekday", "aasp.bin.weekday", FT_STRING
, BASE_NONE
, NULL
, 0,
479 "Short weekday name in the PBX current language", HFILL
}},
481 { "Month name", "aasp.bin.monthname", FT_STRING
, BASE_NONE
, NULL
, 0,
482 "Short month name in the PBX current language", HFILL
}},
483 { &hf_a_weekofyear_prefix
,
484 { "Week of the year prefix", "aasp.bin.weekofyearprefix", FT_STRING
, BASE_NONE
, NULL
, 0,
485 "Precedes the number on the screen which is the week number in year", HFILL
}},
488 /* Setup protocol subtree array */
489 static int *ett
[] = {
495 /* Register the protocol name and description */
496 proto_aasp
= proto_register_protocol("Aastra Signalling Protocol", "AASP", "aasp");
498 /* Required function calls to register the header fields and subtrees used */
499 proto_register_field_array(proto_aasp
, hf
, array_length(hf
));
500 proto_register_subtree_array(ett
, array_length(ett
));
502 /* Register our configuration options */
503 /* aasp_module = prefs_register_protocol(proto_aasp, proto_reg_handoff_aasp); */
505 aasp_handle
= register_dissector("aasp", dissect_aasp
, proto_aasp
);
510 proto_reg_handoff_aasp(void)
512 dissector_add_string("media_type", "message/x-aasp-signalling", aasp_handle
);
516 * Editor modelines - https://www.wireshark.org/tools/modelines.html
521 * indent-tabs-mode: nil
524 * vi: set shiftwidth=4 tabstop=8 expandtab:
525 * :indentSize=4:tabSize=8:noTabs=true: