Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-acdr.c
blob6195c79edc53ef3df69f464378c08cd666f336ee
1 /* packet-acdr.c
2 * Routines for acdr packet dissection
3 * Copyright 2019, AudioCodes Ltd
4 * @author: Alex Rodikov <alex.rodikov@audiocodes.com>
5 * @author: Beni Bloch <beni.bloch@audiocodes.com>
6 * @author: Orgad Shaneh <orgad.shaneh@audiocodes.com>
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
10 * Copyright 1998 Gerald Combs
12 * SPDX-License-Identifier: GPL-2.0-or-later
15 #include "config.h"
17 #include <epan/packet.h>
18 #include <epan/exceptions.h>
19 #include <epan/ipproto.h>
20 #include <epan/prefs.h>
21 #include <epan/expert.h>
22 #include <epan/proto_data.h>
23 #include <epan/to_str.h>
24 #include "packet-acdr.h"
26 #define ACDR_VERSION_MAJOR 0
27 #define ACDR_VERSION_MINOR 9
28 #define PORT_AC_DR 925
30 // acdr header definitions
32 // 1 B 6 B 2 B 2B 1 B 1 B 1 B 1 B 0-14 B
33 //------------------------------------------------------------------------------------------------------------------------------------------
34 //Version | TimeStamp | Source ID | Dest ID | Reserved | Trace Point | Media Type | Payload Header Length | Payload Header | Payload
35 //------------------------------------------------------------------------------------------------------------------------------------------
37 // From version #4:
39 // 1 B 4 B 2 B 4 B 4 B 1 B 1 B 1 B 1 B 0-14 B
40 //------------------------------------------------------------------------------------------------------------------------------------------
41 //Version | TimeStamp | SeqNum | Source ID | Dest ID | Reserved | Trace Point | Media Type | Payload Header Length | Payload Header | Payload
42 //------------------------------------------------------------------------------------------------------------------------------------------
44 #define MII_HEADER_BYTE_LENGTH 4
45 #define AC5X_ANALYSIS_PACKET_HEADER 16
46 #define AC5X_HPI_PACKET_HEADER 4
48 // ACDR extension header macros:
49 #define EXT_HEADER_IPV4_ADDRESS_BYTE_COUNT 4
50 #define EXT_HEADER_IPV6_ADDRESS_BYTE_COUNT 16
51 #define EXT_HEADER_UDP_PORT_BYTE_COUNT 2
52 #define EXT_HEADER_IP_TOS_BYTE_COUNT 1
53 #define EXT_HEADER_C5_CONTROL_FLAFS_COUNT 1
55 // Signaling Packet Macros:
56 #define HEADER_FIELD_SIG_OPCODE_BYTE_NO 0
57 #define HEADER_FIELD_SIG_OPCODE_BYTE_COUNT 2
58 #define HEADER_FIELD_SIG_SIZE_BYTE_NO 2
59 #define HEADER_FIELD_SIG_SIZE_BYTE_COUNT 2
60 #define HEADER_FIELD_SIG_TIME_BYTE_NO 2
61 #define HEADER_FIELD_SIG_TIME_BYTE_COUNT 4
62 #define HEADER_FIELD_SIG_MESSAGE_BYTE_NO 6
65 // masks for the former reserved byte (data byte)
66 // Must be same as in file DebugTarget.h
67 #define MEDIUM_MASK 0x1
68 #define IPV6_MASK 0x2
69 #define FRAGMENTED_MASK 0x4
70 #define HEADERADDED_MASK 0x8
71 #define ENCRYPTED_MASK 0x10
72 #define MTCE_MASK 0x20
73 #define LI_MASK 0x40
75 #define FAVORITE_MASK 0x10
77 void proto_register_acdr(void);
78 void proto_reg_handoff_acdr(void);
80 enum Direction
82 DIR_TX = 0,
83 DIR_RX = 1
86 // Array that is used to check missed ACDR packets
87 #define AC_SEQ_NUM_AR_SIZE 255
88 struct SeqNumIpSeq
90 unsigned ip;
91 unsigned seq;
94 static const value_string acdr_trace_pt_vals[] = {
95 {Net2Dsp, "Network -> Dsp" }, // 0
96 {Dsp2Net, "Dsp -> Network" }, // 1
97 {Dsp2Host, "Dsp -> Host" }, // 2
98 {Host2Dsp, "Host -> Dsp" }, // 3
99 {Net2Host, "Network -> Host" }, // 4
100 {Host2Net, "Host -> Network" }, // 5
101 {System, "System" }, // 6
102 {Dsp2Dsp, "Dsp -> Dsp (Media Loopback)" }, // 7
103 {Net2Net, "Network -> Network (Mediation)" }, // 8
104 {Dsp2Tdm, "Dsp -> Tdm" }, // 9
105 {Tdm2Dsp, "Tdm -> Dsp" }, // 10
106 {Np2Dsp, "Network Processor(C5) -> Dsp" }, // 11
107 {Dsp2Np, "Dsp -> Network Processor(C5)" }, // 12
108 {Host2Np, "Host -> Network Processor(C5)" }, // 13
109 {Np2Host, "Network Processor(C5) -> Host" }, // 14
110 {acUnknown, "Unknown" }, // 15 (Internal Only - not in Wireshark)
111 {Net, "Network Only" }, // 16
112 {P2P, "Dsp -> Dsp (P2P)" }, // 17
113 {DspDecoder, "Host -> DSP (before DSP Decoder)" }, // 18
114 {DspEncoder, "Dsp -> Host (before DSP Encoder)" }, // 19
115 {VoipDecoder, "Media Network Incoming (before Voip Decoder)"}, // 20
116 {VoipEncoder, "Media Voip Outgoing (before Voip Encoder)" }, // 21
117 {NetEncoder, "Media Network Outgoing (before Net Encoder)" }, // 22
118 {P2PDecoder, "Dsp Internal <- DSP (after Native Decoder)" }, // 23
119 {P2PEncoder, "Dsp Internal -> DSP (before Native Encoder)" }, // 24
120 {Host2Pstn, "Host -> Pstn" }, // 25
121 {Pstn2Host, "Pstn -> Host" }, // 26
122 {Net2DspPing, "Srtp Ping: Network -> Dsp" }, // 27
123 {Dsp2NetPing, "Srtp Ping: Dsp -> Network" }, // 28
124 {Src2Dest, "Src -> Dst" }, // 29 (Internal Only - not in Wireshark)
125 {Addr2Addr, "Addr -> Addr" }, // 30 (Internal Only - not in Wireshark)
126 {GeneralSystem, "General System" }, // 31 (Internal Only - not in Wireshark)
127 {AllMedia, "All Media" }, // 32 (Internal Only - not in Wireshark)
128 {DspIncoming, "Dsp Internal <- Host (DSP Incoming)" }, // 33
129 {DspOutgoing, "Dsp Internal -> Host (DSP Outgoing)" }, // 34
130 {AfterSrtpDecoder, "Media Network Incoming (After Srtp Decoder)" }, // 35
131 {0, NULL }
134 static const value_string acdr_media_type_vals[] = {
135 {ACDR_DSP_AC49X, "DSP 49x Packet" },
136 {ACDR_RTP, "RTP Packet" },
137 {ACDR_RTCP, "RTCP Packet" },
138 {ACDR_T38, "T38 Packet" },
139 {ACDR_Event, "HostEvent" },
140 {ACDR_Info, "System Info" },
141 {ACDR_VoiceAI, "Voice AI Packet" },
142 {ACDR_NotUse1, "Not Use 1" },
143 {ACDR_NotUse2, "Not Use 2" },
144 {ACDR_NotUse3, "Not Use 3" },
145 {ACDR_SIP, "SIP Packet" },
146 {ACDR_MEGACO, "Megaco Packet" },
147 {ACDR_MGCP, "MGCP Packet" },
148 {ACDR_TPNCP, "TPNCP Packet" },
149 {ACDR_Control, "Control Packet" },
150 {ACDR_PCM, "PCM" },
151 {ACDR_NP_CONTROL, "C5 Control packet" },
152 {ACDR_NP_DATA, "C5 Data packet" },
153 {ACDR_DSP_AC45X, "DSP 64x Packet" },
154 {ACDR_DSP_AC48X, "DSP 48x Packet" },
155 {ACDR_HA, "HA trace" },
156 {ACDR_CAS, "CAS" },
157 {ACDR_NET_BRICKS, "Net Bricks trace" },
158 {ACDR_COMMAND, "TPNCP Command" },
159 {ACDR_VIDEORTP, "Video RTP" },
160 {ACDR_VIDEORTCP, "Video RTCP" },
161 {ACDR_PCIIF_COMMAND, "PCIIF Command" },
162 {ACDR_GWAPPSYSLOG, "GWApp syslog" },
163 {ACDR_V1501, "V150.1 - Data relay"},
164 {ACDR_DSP_AC5X, "DSP 5x Packet" },
165 {ACDR_TLS, "TLS Data" },
166 {ACDR_TLSPeek, "TLS Peek Date" },
167 {ACDR_DSP_AC5X_MII, "DSP 5x MII Packet" },
168 {ACDR_NATIVE, "P2P - NATIVE" },
169 {ACDR_SIGNALING, "Signaling" },
170 {ACDR_FRAGMENTED, "Fragmented" },
171 {ACDR_QOE_CDR, "QOE CDR" },
172 {ACDR_QOE_MDR, "QOE MDR" },
173 {ACDR_QOE_EVENT, "QOE Event" },
174 {ACDR_DSP_TDM_PLAYBACK, "DSP Tdm Playback" },
175 {ACDR_DSP_NET_PLAYBACK, "DSP Net Playback" },
176 {ACDR_DSP_DATA_RELAY, "DSP Data Relay" },
177 {ACDR_DSP_SNIFFER, "DSP Sniffer" },
178 {ACDR_RTP_AMR, "RTP AMR" },
179 {ACDR_RTP_EVRC, "RTP EVRC" },
180 {ACDR_RTP_RFC2198, "RTP Rfc2198" },
181 {ACDR_RTP_RFC2833, "RTP Rfc2833" },
182 {ACDR_T38_OVER_RTP, "T38 over RTP" },
183 {ACDR_RTP_FEC, "RTP FEC" },
184 {ACDR_RTP_FAX_BYPASS, "RTP Fax Bypass" },
185 {ACDR_RTP_MODEM_BYPASS, "RTP Modem Bypass" },
186 {ACDR_RTP_NSE, "RTP NSE" },
187 {ACDR_RTP_NO_OP, "RTP NoOp" },
188 {ACDR_DTLS, "DTLS Data" },
189 {ACDR_SSH_SHELL, "SSH Shell" },
190 {ACDR_SSH_SFTP, "SSH SFTP" },
191 {ACDR_SSH_SCP, "SSH SCP" },
192 {0, NULL }
195 static const value_string acdr_media_type_dummy_vals[] = {
196 {ACDR_DSP_AC49X, "" },
197 {ACDR_RTP, "" },
198 {ACDR_RTCP, "" },
199 {ACDR_T38, "" },
200 {ACDR_Event, "" },
201 {ACDR_Info, "" },
202 {ACDR_VoiceAI, "" },
203 {ACDR_NotUse1, "" },
204 {ACDR_NotUse2, "" },
205 {ACDR_NotUse3, "" },
206 {ACDR_SIP, "" },
207 {ACDR_MEGACO, "" },
208 {ACDR_MGCP, "" },
209 {ACDR_TPNCP, "" },
210 {ACDR_Control, "" },
211 {ACDR_PCM, "" },
212 {ACDR_NP_CONTROL, "" },
213 {ACDR_NP_DATA, "" },
214 {ACDR_DSP_AC45X, "" },
215 {ACDR_DSP_AC48X, "" },
216 {ACDR_HA, "" },
217 {ACDR_CAS, "" },
218 {ACDR_NET_BRICKS, "" },
219 {ACDR_COMMAND, "" },
220 {ACDR_VIDEORTP, "" },
221 {ACDR_VIDEORTCP, "" },
222 {ACDR_PCIIF_COMMAND, "" },
223 {ACDR_GWAPPSYSLOG, "" },
224 {ACDR_V1501, "" },
225 {ACDR_DSP_AC5X, "" },
226 {ACDR_TLS, "" },
227 {ACDR_TLSPeek, "" },
228 {ACDR_DSP_AC5X_MII, "DSP 5x Packet"},
229 {0, NULL }
232 enum AcdrAc5xProtocolType
234 ACDR_AC5X_PROTOCOL_TYPE__REGULAR,
235 ACDR_AC5X_PROTOCOL_TYPE__TDM_PLAYBACK,
236 ACDR_AC5X_PROTOCOL_TYPE__NET_PLAYBACK
239 struct AcdrAc5xPrivateData
241 unsigned packet_direction;
242 enum AcdrAc5xProtocolType protocol_type;
243 unsigned mii_header_exist;
246 typedef struct AcdrTlsPacketInfo
248 uint16_t source_port;
249 uint16_t dest_port;
250 uint8_t application;
251 } AcdrTlsPacketInfo;
254 static const value_string hf_acdr_ext_tls_application_vals[] = {
255 {0, "UNKNWN"},
256 {1, "HTTP" },
257 {2, "TR069" },
258 {3, "SIP" },
259 {4, "LDAP" },
260 {5, "XML" },
261 {6, "TCP" },
262 {7, "TELNET"},
263 {8, "FTP" },
264 {9, "TPNCP" },
265 {0, NULL },
268 static const value_string hf_acdr_ext_direction_vals[] = {
269 {1, "Outgoing"},
270 {0, "Incoming"},
271 {0, NULL }
274 static int proto_acdr;
275 static int proto_ac5xmii;
276 static int proto_ac5x;
277 static int proto_ac48x;
278 static int proto_ac49x;
280 // Define headers for acdr
281 static int hf_acdr_seq_num;
282 static int hf_acdr_timestamp;
283 static int hf_acdr_sourceid;
284 static int hf_acdr_destid;
285 static int hf_acdr_version;
286 static int hf_acdr_trace_pt;
287 static int hf_acdr_media_type;
288 static int hf_acdr_media_type_dsp_ac5x;
289 static int hf_acdr_pl_offset_type;
290 static int hf_acdr_header_ext_len_type;
291 static int hf_acdr_data;
292 static int hf_acdr_data_mii;
293 static int hf_acdr_data_ipv6;
294 static int hf_acdr_data_fragmented;
295 static int hf_acdr_data_headeradded;
296 static int hf_acdr_data_encrypted;
297 static int hf_acdr_data_mtce;
298 static int hf_acdr_data_li;
300 static int hf_acdr_session_id;
301 static int hf_acdr_session_id_board_id;
302 static int hf_acdr_session_id_reset_counter;
303 static int hf_acdr_session_id_session_number;
304 static int hf_acdr_session_id_long_session_number;
306 static int hf_acdr_ext_c5_control_favorite;
308 static int hf_acdr_payload_header;
309 static int hf_acdr_mii_header;
311 // header extension
312 static int hf_acdr_ext_srcudp;
313 static int hf_acdr_ext_dstudp;
314 static int hf_acdr_ext_srcip;
315 static int hf_acdr_ext_srcipv6;
316 static int hf_acdr_ext_dstip;
317 static int hf_acdr_ext_dstipv6;
318 static int hf_acdr_ext_protocol;
319 static int hf_acdr_ext_tls_application;
320 static int hf_acdr_ext_direction;
321 static int hf_acdr_ext_iptos;
322 static int hf_acdr_ext_c5_control_flags;
324 static int hf_acdr_unknown_packet;
325 static int hf_acdr_ext_pstn_trace_seq_num;
326 static int hf_acdr_header_extension;
327 static int hf_acdr_ext_dsp_core;
328 static int hf_acdr_ext_dsp_channel;
329 static int hf_acdr_ext_event_id;
330 static int hf_acdr_ext_event_source;
332 // Mii header extension
333 static int hf_acdr_mii_sequence;
334 static int hf_acdr_mii_packet_size;
335 static int hf_acdr_5x_analysis_packet_header;
336 static int hf_5x_analysis_version;
337 static int hf_5x_analysis_direction;
338 static int hf_5x_analysis_sub_version;
339 static int hf_5x_analysis_device;
340 static int hf_5x_analysis_sequence;
341 static int hf_5x_analysis_spare1;
342 static int hf_5x_analysis_timestamp;
343 static int hf_5x_analysis_spare2;
345 static int hf_acdr_5x_hpi_packet_header;
346 static int hf_5x_hpi_sync5;
347 static int hf_5x_hpi_udp_checksum;
348 static int hf_5x_hpi_resource_id;
349 static int hf_5x_hpi_favorite;
350 static int hf_5x_hpi_protocol;
352 static int hf_ac45x_packet;
353 static int hf_ac48x_packet;
354 static int hf_ac49x_packet;
355 static int hf_ac5x_packet;
357 static int hf_signaling_packet;
358 static int hf_acdr_signaling_opcode;
359 static int hf_acdr_signaling_size;
360 static int hf_acdr_signaling_timestamp;
363 // Define the trees for acdr
364 static int ett_acdr;
365 static int ett_extension;
366 static int ett_ac49x_packet;
367 static int ett_ac48x_packet;
368 static int ett_ac45x_packet;
369 static int ett_ac5x_packet;
370 static int ett_ac5x_mii_packet;
371 static int ett_mii_header;
372 static int ett_signaling_packet;
373 static int ett_extra_data;
374 static int ett_c5_cntrl_flags;
375 static int ett_5x_analysis_packet_header;
376 static int ett_5x_hpi_packet_header;
377 static int ett_session_id;
379 static expert_field ei_acdr_version_not_supported;
381 static int proto_rtp;
383 static dissector_table_t media_type_table;
384 static dissector_table_t tls_application_table;
385 static dissector_table_t tls_application_port_table;
387 static dissector_handle_t acdr_dissector_handle;
388 static dissector_handle_t acdr_mii_dissector_handle;
389 static dissector_handle_t acdr_rtp_dissector_handle;
390 static dissector_handle_t acdr_xml_dissector_handle;
391 static dissector_handle_t rtp_dissector_handle;
392 static dissector_handle_t udp_stun_dissector_handle;
393 static dissector_handle_t rtp_events_handle;
394 static dissector_handle_t rtp_rfc2198_handle;
395 static dissector_handle_t amr_handle;
396 static dissector_handle_t evrc_handle;
397 static dissector_table_t rtp_dissector_table;
398 static dissector_handle_t rtcp_dissector_handle;
399 static dissector_handle_t ip_dissector_handle;
400 static dissector_handle_t json_dissector_handle;
401 static dissector_handle_t megaco_dissector_handle;
402 static dissector_handle_t mgcp_dissector_handle;
403 static dissector_handle_t sip_dissector_handle;
404 static dissector_handle_t dsp_49x_dissector_handle;
405 static dissector_handle_t dsp_48x_dissector_handle;
406 static dissector_handle_t dsp_45x_dissector_handle;
407 static dissector_handle_t dsp_5x_dissector_handle;
408 static dissector_handle_t dsp_5x_MII_dissector_handle;
409 static dissector_handle_t udp_dissector_handle;
410 static dissector_handle_t xml_dissector_handle;
411 static dissector_handle_t lix2x3_dissector_handle;
412 static dissector_handle_t ssh_dissector_handle;
414 static void dissect_rtp_packet(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
415 uint8_t media_type, uint16_t payload_type);
416 static void create_5x_analysis_packet_header_subtree(proto_tree *tree, tvbuff_t *tvb);
417 static void create_5x_hpi_packet_header_subtree(proto_tree *tree, tvbuff_t *tvb);
419 static int
420 create_full_session_id_subtree(wmem_allocator_t *scope, proto_tree *tree, tvbuff_t *tvb, int offset, uint8_t ver)
422 uint64_t full_session_id = tvb_get_letoh64(tvb, offset);
423 proto_item *packet_item = NULL;
424 proto_item *packet_tree = NULL;
425 uint64_t session_int = 0;
426 int session_id_length;
428 // SessionID
429 const char *str = "N/A";
431 if (full_session_id != 0) {
432 const char *session_ext = "";
433 uint32_t board_id = tvb_get_ntoh24(tvb, offset);
434 uint8_t reset_counter = tvb_get_uint8(tvb, offset + 3);
436 if ((ver & 0xF) == 7)
437 session_int = tvb_get_ntohl(tvb, offset + 4);
438 else
439 session_int = tvb_get_ntoh40(tvb, offset + 4);
441 if (session_int != 0)
442 session_ext = wmem_strdup_printf(scope, ":%" PRIu64, session_int);
443 str = wmem_strdup_printf(scope, "%x:%d%s", board_id, reset_counter, session_ext);
446 if ((ver & 0xF) == 7) {
447 session_id_length = 8;
448 packet_item = proto_tree_add_string(tree, hf_acdr_session_id, tvb, offset, session_id_length, str);
449 } else {
450 session_id_length = 9;
451 packet_item = proto_tree_add_string(tree, hf_acdr_session_id, tvb, offset, session_id_length, str);
453 if (full_session_id == 0)
454 return offset + session_id_length;
456 packet_tree = proto_item_add_subtree(packet_item, ett_session_id);
458 // SessionID.boardid
459 proto_tree_add_item(packet_tree, hf_acdr_session_id_board_id, tvb, offset, 3, ENC_BIG_ENDIAN);
460 offset += 3;
462 // SessionID.resetcounter
463 proto_tree_add_item(packet_tree, hf_acdr_session_id_reset_counter, tvb, offset, 1, ENC_BIG_ENDIAN);
464 offset++;
466 // SessionID.sessionnumber
467 if ((ver & 0xF) == 7) {
468 proto_tree_add_item(packet_tree, hf_acdr_session_id_session_number, tvb,
469 offset, 4, ENC_BIG_ENDIAN);
470 offset += 4;
471 } else {
472 proto_tree_add_item(packet_tree, hf_acdr_session_id_long_session_number, tvb,
473 offset, 5, ENC_BIG_ENDIAN);
474 offset += 5;
477 return offset;
480 static void
481 create_header_extension_subtree(proto_tree *tree, tvbuff_t *tvb, int offset, uint8_t extension_length,
482 uint32_t ver, uint8_t media_type, uint8_t trace_point, uint8_t extra_data,
483 AcdrTlsPacketInfo *tls_packet_info)
485 proto_tree *extension_tree;
486 bool ipv6 = ((IPV6_MASK & extra_data) == IPV6_MASK);
488 // parse the header extension
489 proto_item *ti = proto_tree_add_item(tree, hf_acdr_header_extension, tvb, offset,
490 extension_length, ENC_NA);
492 extension_tree = proto_item_add_subtree(ti, ett_extension);
494 if (media_type == ACDR_TLS || media_type == ACDR_TLSPeek) {
495 tls_packet_info->source_port = tvb_get_ntohs(tvb, offset);
496 tls_packet_info->dest_port = tvb_get_ntohs(tvb, offset + 2);
497 tls_packet_info->application = tvb_get_uint8(tvb, offset + 12);
500 //further processing only involves adding fields
501 if (tree == NULL)
502 return;
504 switch (trace_point) {
505 case DspIncoming:
506 case DspOutgoing:
508 // Gen5 only - special case of recorded packets from DSP
509 proto_tree_add_item(extension_tree, hf_acdr_ext_dsp_core, tvb, offset, 1, ENC_BIG_ENDIAN);
510 offset++;
512 proto_tree_add_item(extension_tree, hf_acdr_ext_dsp_channel, tvb, offset, 1, ENC_BIG_ENDIAN);
513 return;
516 switch (media_type) {
517 case ACDR_CAS:
518 case ACDR_NET_BRICKS:
519 if (extension_length > 0) {
520 proto_tree_add_item(extension_tree, hf_acdr_ext_pstn_trace_seq_num, tvb,
521 offset, 4, ENC_BIG_ENDIAN);
523 break;
524 case ACDR_Event:
525 proto_tree_add_item(extension_tree, hf_acdr_ext_event_id, tvb, offset, 1, ENC_BIG_ENDIAN);
526 offset++;
528 proto_tree_add_item(extension_tree, hf_acdr_ext_event_source, tvb, offset, 1, ENC_BIG_ENDIAN);
529 break;
530 case ACDR_DSP_AC49X:
531 case ACDR_DSP_AC48X:
532 case ACDR_DSP_AC45X:
533 case ACDR_DSP_AC5X:
534 case ACDR_DSP_AC5X_MII:
535 case ACDR_DSP_SNIFFER:
536 proto_tree_add_item(extension_tree, hf_acdr_ext_dsp_core, tvb, offset, 1, ENC_BIG_ENDIAN);
537 offset++;
539 proto_tree_add_item(extension_tree, hf_acdr_ext_dsp_channel, tvb, offset, 1, ENC_BIG_ENDIAN);
540 break;
541 case ACDR_RTP:
542 case ACDR_RTP_AMR:
543 case ACDR_RTP_EVRC:
544 case ACDR_RTP_RFC2198:
545 case ACDR_RTP_RFC2833:
546 case ACDR_T38_OVER_RTP:
547 case ACDR_RTP_FEC:
548 case ACDR_RTP_FAX_BYPASS:
549 case ACDR_RTP_MODEM_BYPASS:
550 case ACDR_RTP_NSE:
551 case ACDR_RTP_NO_OP:
552 case ACDR_T38:
553 case ACDR_RTCP:
554 case ACDR_VIDEORTP:
555 case ACDR_VIDEORTCP:
556 case ACDR_NATIVE:
557 case ACDR_DTLS:
559 switch (trace_point) {
560 case Net2Dsp:
561 case Net2Host:
562 case DspDecoder:
563 case VoipDecoder:
564 case Net2DspPing:
565 case AfterSrtpDecoder:
566 if (((ver & 0xF) >= 3) && ipv6) {
567 proto_tree_add_item(extension_tree, hf_acdr_ext_srcipv6, tvb, offset, 16, ENC_NA);
568 offset += 16;
569 } else {
570 proto_tree_add_item(extension_tree, hf_acdr_ext_srcip, tvb, offset, 4, ENC_BIG_ENDIAN);
571 offset += 4;
574 // Gen3 only: we put the UDP header in the last 8 bytes of the header extension.
575 // So, we have only IP address into the real header extension
576 if ((media_type == ACDR_T38) && (trace_point == Net2Dsp) && (extension_length == 4))
577 break;
579 proto_tree_add_item(extension_tree, hf_acdr_ext_srcudp, tvb, offset, 2, ENC_BIG_ENDIAN);
580 offset += 2;
582 proto_tree_add_item(extension_tree, hf_acdr_ext_dstudp, tvb, offset, 2, ENC_BIG_ENDIAN);
583 offset += 2;
585 proto_tree_add_item(extension_tree, hf_acdr_ext_iptos, tvb, offset, 1, ENC_BIG_ENDIAN);
586 offset++;
588 if ((trace_point == Net2Dsp) && (extension_length == 10)) {
589 // Gen3 only: we should add one byte of C5 Control Flags
590 // C5 Control Flags
592 static int * const c5_cntrl_flags[] = {
593 &hf_acdr_ext_c5_control_favorite,
594 NULL
597 proto_tree_add_bitmask(extension_tree, tvb, offset, hf_acdr_ext_c5_control_flags,
598 ett_c5_cntrl_flags, c5_cntrl_flags, ENC_BIG_ENDIAN);
600 break;
601 case Dsp2Net:
602 case Host2Net:
603 case P2P:
604 case P2PDecoder:
605 case P2PEncoder:
606 case NetEncoder:
607 case VoipEncoder:
608 case DspEncoder:
609 case Dsp2NetPing:
610 if (((ver & 0xF) >= 3) && ipv6) {
611 proto_tree_add_item(extension_tree, hf_acdr_ext_dstipv6, tvb, offset, 16, ENC_NA);
612 offset += 16;
613 } else {
614 proto_tree_add_item(extension_tree, hf_acdr_ext_dstip, tvb, offset, 4, ENC_BIG_ENDIAN);
615 offset += 4;
618 // Gen3 only: we put the UDP header in the last 8 bytes of the header extension.
619 // So, we have only IP address into the real header extension
620 if ((media_type == ACDR_T38) && (trace_point == Dsp2Net) && (extension_length == 4))
621 break;
623 proto_tree_add_item(extension_tree, hf_acdr_ext_dstudp, tvb, offset, 2, ENC_BIG_ENDIAN);
624 offset += 2;
626 proto_tree_add_item(extension_tree, hf_acdr_ext_srcudp, tvb, offset, 2, ENC_BIG_ENDIAN);
627 offset += 2;
629 proto_tree_add_item(extension_tree, hf_acdr_ext_iptos, tvb, offset, 1, ENC_BIG_ENDIAN);
630 offset++;
631 break;
633 default:
634 proto_tree_add_item(extension_tree, hf_acdr_payload_header, tvb, offset,
635 extension_length, ENC_NA);
636 break;
638 break;
641 case ACDR_VoiceAI:
642 case ACDR_SIP:
643 case ACDR_MEGACO:
644 case ACDR_MGCP:
645 case ACDR_TPNCP:
646 case ACDR_Control:
647 if (trace_point == System) {
648 proto_tree_add_item(extension_tree, hf_acdr_ext_srcip, tvb, offset, 4, ENC_BIG_ENDIAN);
649 offset += 4;
651 proto_tree_add_item(extension_tree, hf_acdr_ext_dstip, tvb, offset, 4, ENC_BIG_ENDIAN);
652 offset += 4;
654 proto_tree_add_item(extension_tree, hf_acdr_ext_srcudp, tvb, offset, 2, ENC_BIG_ENDIAN);
655 offset += 2;
657 proto_tree_add_item(extension_tree, hf_acdr_ext_dstudp, tvb, offset, 2, ENC_BIG_ENDIAN);
658 offset += 2;
660 proto_tree_add_item(extension_tree, hf_acdr_ext_protocol, tvb, offset, 1, ENC_BIG_ENDIAN);
661 offset++;
663 proto_tree_add_item(extension_tree, hf_acdr_ext_direction, tvb, offset, 1, ENC_BIG_ENDIAN);
664 offset++;
665 } else {
666 proto_tree_add_item(extension_tree, hf_acdr_payload_header, tvb, offset,
667 extension_length, ENC_NA);
669 break;
670 case ACDR_TLS:
671 case ACDR_TLSPeek:
672 proto_tree_add_item(extension_tree, hf_acdr_ext_srcudp, tvb, offset, 2, ENC_BIG_ENDIAN);
673 offset += 2;
675 proto_tree_add_item(extension_tree, hf_acdr_ext_dstudp, tvb, offset, 2, ENC_BIG_ENDIAN);
676 offset += 2;
678 proto_tree_add_item(extension_tree, hf_acdr_ext_srcip, tvb, offset, 4, ENC_BIG_ENDIAN);
679 offset += 4;
681 proto_tree_add_item(extension_tree, hf_acdr_ext_dstip, tvb, offset, 4, ENC_BIG_ENDIAN);
682 offset += 4;
684 proto_tree_add_item(extension_tree, hf_acdr_ext_tls_application, tvb, offset, 1, ENC_BIG_ENDIAN);
685 break;
687 default:
689 // Payload Header - only show it if exists
690 proto_tree_add_item(extension_tree, hf_acdr_payload_header, tvb, offset, extension_length,
691 ENC_NA);
695 static void
696 create_mii_header_subtree(proto_tree *tree, tvbuff_t *tvb, int offset, uint8_t media_type)
698 proto_tree *mii_header_tree;
700 // parse the header extension
701 proto_item *ti = proto_tree_add_item(tree, hf_acdr_mii_header, tvb,
702 offset, MII_HEADER_BYTE_LENGTH, ENC_NA);
704 mii_header_tree = proto_item_add_subtree(ti, ett_mii_header);
706 switch (media_type) {
707 case ACDR_DSP_AC5X_MII:
708 case ACDR_RTP:
709 case ACDR_RTP_AMR:
710 case ACDR_RTP_EVRC:
711 case ACDR_RTP_RFC2198:
712 case ACDR_RTP_RFC2833:
713 case ACDR_T38_OVER_RTP:
714 case ACDR_RTP_FEC:
715 case ACDR_RTP_FAX_BYPASS:
716 case ACDR_RTP_MODEM_BYPASS:
717 case ACDR_RTP_NSE:
718 case ACDR_RTP_NO_OP:
719 case ACDR_T38:
720 case ACDR_RTCP:
721 case ACDR_VIDEORTP:
722 case ACDR_VIDEORTCP:
723 case ACDR_NATIVE:
724 proto_tree_add_item(mii_header_tree, hf_acdr_mii_sequence, tvb, offset, 2, ENC_BIG_ENDIAN);
725 offset += 2;
727 proto_tree_add_item(mii_header_tree, hf_acdr_mii_packet_size, tvb, offset, 2, ENC_BIG_ENDIAN);
728 break;
732 static void
733 create_5x_analysis_packet_header_subtree(proto_tree *tree, tvbuff_t *tvb)
735 proto_tree *ac5x_analysis_packet_header;
737 // parse the header extension
738 proto_item *ti = proto_tree_add_item(tree, hf_acdr_5x_analysis_packet_header, tvb,
739 AC5X_ANALYSIS_PACKET_HEADER, -1, ENC_NA);
741 ac5x_analysis_packet_header = proto_item_add_subtree(ti, ett_5x_analysis_packet_header);
743 if (tree) {
744 proto_tree_add_item(ac5x_analysis_packet_header, hf_5x_analysis_version, tvb, 0, 2,
745 ENC_BIG_ENDIAN);
746 proto_tree_add_item(ac5x_analysis_packet_header, hf_5x_analysis_direction, tvb, 2, 1,
747 ENC_BIG_ENDIAN);
748 proto_tree_add_item(ac5x_analysis_packet_header, hf_5x_analysis_sub_version, tvb, 2, 1,
749 ENC_BIG_ENDIAN);
750 proto_tree_add_item(ac5x_analysis_packet_header, hf_5x_analysis_device, tvb, 3, 1,
751 ENC_BIG_ENDIAN);
752 proto_tree_add_item(ac5x_analysis_packet_header, hf_5x_analysis_sequence, tvb, 4, 2,
753 ENC_BIG_ENDIAN);
754 proto_tree_add_item(ac5x_analysis_packet_header, hf_5x_analysis_spare1, tvb, 6, 2,
755 ENC_BIG_ENDIAN);
756 proto_tree_add_item(ac5x_analysis_packet_header, hf_5x_analysis_timestamp, tvb, 8, 4,
757 ENC_BIG_ENDIAN);
758 proto_tree_add_item(ac5x_analysis_packet_header, hf_5x_analysis_spare2, tvb, 12, 4,
759 ENC_BIG_ENDIAN);
763 static void
764 create_5x_hpi_packet_header_subtree(proto_tree *tree, tvbuff_t *tvb)
766 proto_tree *ac5x_hpi_packet_header;
768 // parse the header extension
769 proto_item *ti = proto_tree_add_item(tree, hf_acdr_5x_hpi_packet_header, tvb, 0,
770 AC5X_HPI_PACKET_HEADER, ENC_NA);
772 ac5x_hpi_packet_header = proto_item_add_subtree(ti, ett_5x_hpi_packet_header);
774 if (!tree)
775 return;
776 proto_tree_add_item(ac5x_hpi_packet_header, hf_5x_hpi_sync5, tvb, 0, 1, ENC_BIG_ENDIAN);
777 proto_tree_add_item(ac5x_hpi_packet_header, hf_5x_hpi_udp_checksum, tvb, 0, 1,
778 ENC_BIG_ENDIAN);
779 proto_tree_add_item(ac5x_hpi_packet_header, hf_5x_hpi_resource_id, tvb, 1, 1,
780 ENC_BIG_ENDIAN);
781 proto_tree_add_item(ac5x_hpi_packet_header, hf_5x_hpi_favorite, tvb, 2, 1, ENC_BIG_ENDIAN);
782 proto_tree_add_item(ac5x_hpi_packet_header, hf_5x_hpi_protocol, tvb, 3, 1, ENC_BIG_ENDIAN);
785 static void
786 acdr_payload_handler(proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb,
787 acdr_dissector_data_t *data, const char *proto_name)
789 if (data->header_added && data->media_type != ACDR_Control) {
790 dissector_handle_t dissector = ip_dissector_handle;
791 if (data->media_type == ACDR_DTLS || data->media_type == ACDR_T38)
792 dissector = udp_dissector_handle;
793 if (dissector)
794 call_dissector(dissector, tvb, pinfo, tree);
795 else
796 call_data_dissector(tvb, pinfo, tree);
797 if (proto_name)
798 col_set_str(pinfo->cinfo, COL_PROTOCOL, proto_name);
799 return;
801 if (data->li_packet && !data->header_added && lix2x3_dissector_handle)
803 if (call_dissector_only(lix2x3_dissector_handle, tvb, pinfo, tree, data))
804 return;
806 // check registered media types
807 if (dissector_try_uint_with_data(media_type_table, data->media_type, tvb, pinfo, tree, false, data))
808 return;
809 proto_tree_add_item(tree, hf_acdr_unknown_packet, tvb, 0, 0, ENC_NA);
812 static void
813 dissect_rtp_packet(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, uint8_t media_type,
814 uint16_t payload_type)
816 proto_tree *rtp_data_tree;
817 dissector_handle_t old_dissector_handle = NULL;
819 int bytes_dissected = 0;
821 if ((tvb_get_uint8(tvb, 0) & 0xC0) == 0) {
822 // RTP Version = 0
823 if (tvb_get_ntohl(tvb, 4) == 0x2112a442) {
824 // This is STUN RFC 5389 packet
825 if (udp_stun_dissector_handle) {
826 bytes_dissected = call_dissector(udp_stun_dissector_handle, tvb, pinfo, tree);
827 if (bytes_dissected > 0)
828 return;
833 if (payload_type != 0) {
834 switch (media_type) {
835 case ACDR_RTP_AMR:
836 if (amr_handle) {
837 old_dissector_handle = dissector_get_uint_handle(rtp_dissector_table, payload_type);
838 if (old_dissector_handle != amr_handle)
839 dissector_add_uint("rtp.pt", payload_type, amr_handle);
841 break;
842 case ACDR_RTP_EVRC:
843 if (evrc_handle) {
844 old_dissector_handle = dissector_get_uint_handle(rtp_dissector_table, payload_type);
845 if (old_dissector_handle != evrc_handle)
846 dissector_add_uint("rtp.pt", payload_type, evrc_handle);
848 break;
849 case ACDR_RTP_RFC2198:
850 if (rtp_rfc2198_handle) {
851 old_dissector_handle = dissector_get_uint_handle(rtp_dissector_table, payload_type);
852 if (old_dissector_handle != rtp_rfc2198_handle)
853 dissector_add_uint("rtp.pt", payload_type, rtp_rfc2198_handle);
855 break;
856 case ACDR_RTP_RFC2833:
857 if (rtp_events_handle) {
858 old_dissector_handle = dissector_get_uint_handle(rtp_dissector_table, payload_type);
859 if (old_dissector_handle != rtp_events_handle)
860 dissector_add_uint("rtp.pt", payload_type, rtp_events_handle);
862 break;
863 case ACDR_RTP_FEC:
864 if (rtp_rfc2198_handle) {
865 old_dissector_handle = dissector_get_uint_handle(rtp_dissector_table, payload_type);
866 if (old_dissector_handle != rtp_rfc2198_handle)
867 dissector_add_uint("rtp.pt", payload_type, rtp_rfc2198_handle);
869 break;
873 call_dissector(rtp_dissector_handle, tvb, pinfo, tree);
875 // see that the bottom protocol is indeed RTP and not some other protocol on top RTP
876 if (tree && tree->last_child && PITEM_FINFO(tree->last_child)) {
877 if (PITEM_HFINFO(tree->last_child)->id == proto_rtp) {
878 // add the length & offset fields to the RTP payload
879 rtp_data_tree = tree->last_child->last_child; // the rtp subtree->the payload field
881 if (rtp_data_tree) {
882 proto_item_set_text(rtp_data_tree, "RTP Data (%d bytes, offset %d)",
883 rtp_data_tree->finfo->length, rtp_data_tree->finfo->start);
888 switch (media_type) {
889 case ACDR_RTP_AMR:
890 if (old_dissector_handle && (old_dissector_handle != amr_handle))
891 dissector_add_uint("rtp.pt", payload_type, old_dissector_handle);
892 col_set_str(pinfo->cinfo, COL_PROTOCOL, "RTP AMR");
893 break;
894 case ACDR_RTP_EVRC:
895 if (old_dissector_handle && (old_dissector_handle != evrc_handle))
896 dissector_add_uint("rtp.pt", payload_type, old_dissector_handle);
897 col_set_str(pinfo->cinfo, COL_PROTOCOL, "RTP Evrc");
898 break;
899 case ACDR_RTP_RFC2198:
900 if (old_dissector_handle && (old_dissector_handle != rtp_rfc2198_handle))
901 dissector_add_uint("rtp.pt", payload_type, old_dissector_handle);
902 col_set_str(pinfo->cinfo, COL_PROTOCOL, "RTP Rfc2198");
903 break;
904 case ACDR_RTP_RFC2833:
905 if (old_dissector_handle && (old_dissector_handle != rtp_events_handle))
906 dissector_add_uint("rtp.pt", payload_type, old_dissector_handle);
907 col_set_str(pinfo->cinfo, COL_PROTOCOL, "RTP Rfc2833");
908 break;
909 case ACDR_T38_OVER_RTP:
910 col_set_str(pinfo->cinfo, COL_PROTOCOL, "T38 over RTP");
911 break;
912 case ACDR_RTP_FEC:
913 if (old_dissector_handle && (old_dissector_handle != rtp_rfc2198_handle))
914 dissector_add_uint("rtp.pt", payload_type, old_dissector_handle);
915 col_set_str(pinfo->cinfo, COL_PROTOCOL, "RTP FEC");
916 break;
917 case ACDR_RTP_FAX_BYPASS:
918 col_set_str(pinfo->cinfo, COL_PROTOCOL, "RTP Fax Bypass");
919 break;
920 case ACDR_RTP_MODEM_BYPASS:
921 col_set_str(pinfo->cinfo, COL_PROTOCOL, "RTP Modem Bypass");
922 break;
923 case ACDR_RTP_NSE:
924 col_set_str(pinfo->cinfo, COL_PROTOCOL, "RTP NSE");
925 break;
926 case ACDR_RTP_NO_OP:
927 col_set_str(pinfo->cinfo, COL_PROTOCOL, "RTP NoOp");
928 break;
929 case ACDR_VIDEORTP:
930 col_set_str(pinfo->cinfo, COL_PROTOCOL, "RTP Video");
931 break;
935 static int
936 dissect_signaling_packet(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, uint8_t trace_point)
938 tvbuff_t *next_tvb = NULL;
939 int32_t offset = 0;
940 int remaining;
941 const bool is_incoming = trace_point == Host2Pstn || trace_point == DspIncoming;
943 proto_tree_add_item(tree, hf_acdr_signaling_opcode, tvb, HEADER_FIELD_SIG_OPCODE_BYTE_NO,
944 HEADER_FIELD_SIG_OPCODE_BYTE_COUNT, ENC_BIG_ENDIAN);
945 offset += HEADER_FIELD_SIG_OPCODE_BYTE_COUNT;
946 if (is_incoming) {
947 proto_tree_add_item(tree, hf_acdr_signaling_size, tvb, HEADER_FIELD_SIG_SIZE_BYTE_NO,
948 HEADER_FIELD_SIG_SIZE_BYTE_COUNT, ENC_BIG_ENDIAN);
949 offset += HEADER_FIELD_SIG_SIZE_BYTE_COUNT;
950 } else {
951 const uint32_t timestamp = tvb_get_ntohl(tvb, HEADER_FIELD_SIG_TIME_BYTE_NO);
952 nstime_t sig_time = {timestamp / 1000000, (timestamp % 1000000) * 1000};
953 proto_tree_add_time_format_value(
954 tree, hf_acdr_signaling_timestamp, tvb, HEADER_FIELD_SIG_TIME_BYTE_NO,
955 HEADER_FIELD_SIG_TIME_BYTE_COUNT, &sig_time, "%f sec", timestamp / 1000000.0f);
956 offset += HEADER_FIELD_SIG_TIME_BYTE_COUNT;
959 remaining = tvb_reported_length_remaining(tvb, offset);
960 if (remaining == 0)
961 return tvb_reported_length(tvb);
962 next_tvb = tvb_new_subset_length_caplen(tvb, offset, remaining, -1);
964 return call_data_dissector(next_tvb, pinfo, tree);
967 static int32_t
968 add_cid(proto_tree *tree, tvbuff_t *tvb, int offset, int cid_byte_length, int hf)
970 int32_t cid = 0;
971 if (cid_byte_length == 2) {
972 cid = tvb_get_ntohs(tvb, offset);
973 } else {
974 cid = tvb_get_ntohl(tvb, offset);
976 if (cid_byte_length == 2 && cid == 0xFFFF)
977 cid = -1;
978 proto_tree_add_int_format_value(tree, hf, tvb, offset, cid_byte_length, cid, "%d", cid);
979 return cid;
982 static void
983 create_acdr_tree(proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb)
985 proto_item *header_ti = NULL;
986 proto_tree *acdr_tree;
987 tvbuff_t *next_tvb = NULL;
988 int offset = 0;
989 int header_byte_length = 15;
990 int cid_byte_length = 2;
991 uint32_t sequence_num = 0;
992 uint32_t version, trace_point, header_extension_len = 0;
993 uint8_t media_type, extra_data;
994 bool medium_mii = 0;
995 int64_t timestamp;
996 nstime_t acdr_time = NSTIME_INIT_ZERO;
997 int time_size = 0;
998 int acdr_header_length;
999 bool header_added;
1000 bool li_packet;
1001 uint16_t payload_type = 0;
1002 AcdrTlsPacketInfo tls_packet_info = {0xFFFF, 0xFFFF, TLS_APP_UNKNWN};
1003 const char *proto_name = NULL;
1005 header_ti = proto_tree_add_item(tree, proto_acdr, tvb, 0, -1, ENC_NA);
1006 acdr_tree = proto_item_add_subtree(header_ti, ett_acdr);
1008 // Version
1009 proto_tree_add_item_ret_uint(acdr_tree, hf_acdr_version, tvb, offset, 1, ENC_BIG_ENDIAN, &version);
1010 offset++;
1012 if ((version & 0xF) < 5) {
1013 header_byte_length = 15;
1014 cid_byte_length = 2;
1015 } else if ((version & 0xF) < 7) {
1016 header_byte_length = 19;
1017 cid_byte_length = 2;
1018 } else if ((version & 0xF) == 7) {
1019 header_byte_length = 23;
1020 cid_byte_length = 2;
1021 } else if ((version & 0xF) == 8) {
1022 header_byte_length = 24;
1023 cid_byte_length = 2;
1024 } else {
1025 header_byte_length = 28;
1026 cid_byte_length = 4;
1029 if (((version & 0xF) > ACDR_VERSION_MINOR) || (((version >> 4) & 0xF) != ACDR_VERSION_MAJOR)) {
1030 // version not supported
1031 expert_add_info_format(pinfo, header_ti, &ei_acdr_version_not_supported,
1032 "ACDR version %d not supported", version);
1033 return;
1036 // Timestamp
1037 if ((version & 0xF) <= 3) {
1038 timestamp = (tvb_get_ntohl(tvb, offset) << 16) | tvb_get_ntohs(tvb, offset + 4);
1039 time_size = 6;
1040 } else {
1041 timestamp = tvb_get_ntohl(tvb, offset);
1042 time_size = 4;
1044 acdr_time.secs = timestamp / 1000000;
1045 acdr_time.nsecs = (timestamp % 1000000) * 1000;
1046 proto_tree_add_time_format_value(acdr_tree, hf_acdr_timestamp, tvb, offset, time_size, &acdr_time,
1047 "%f sec", timestamp / 1000000.0f);
1048 offset += time_size;
1050 // Sequence Number
1051 if ((version & 0xF) >= 4) {
1052 proto_tree_add_item_ret_uint(acdr_tree, hf_acdr_seq_num, tvb, offset, 2, ENC_BIG_ENDIAN,
1053 &sequence_num);
1054 offset += 2;
1057 add_cid(acdr_tree, tvb, offset, cid_byte_length, hf_acdr_sourceid);
1058 offset += cid_byte_length;
1059 add_cid(acdr_tree, tvb, offset, cid_byte_length, hf_acdr_destid);
1060 offset += cid_byte_length;
1062 // Extra Data
1063 extra_data = tvb_get_uint8(tvb, offset);
1064 if ((extra_data == 0) ||
1066 // Backward Compatible: in old versions we always set the extra_data with 0xAA value
1067 ((extra_data == 0xAA) && ((version & 0xF) <= 3))) {
1068 proto_tree_add_item(acdr_tree, hf_acdr_data, tvb, offset, 1, ENC_BIG_ENDIAN);
1069 } else {
1070 static int * const extra_data_bits[] = {
1071 &hf_acdr_data_li,
1072 &hf_acdr_data_mtce,
1073 &hf_acdr_data_encrypted,
1074 &hf_acdr_data_headeradded,
1075 &hf_acdr_data_fragmented,
1076 &hf_acdr_data_ipv6,
1077 &hf_acdr_data_mii,
1078 NULL
1081 proto_tree_add_bitmask(acdr_tree, tvb, offset, hf_acdr_data, ett_extra_data,
1082 extra_data_bits, ENC_BIG_ENDIAN);
1084 offset++;
1086 if (((version & 0xF) >= 3) && ((MEDIUM_MASK & extra_data) == MEDIUM_MASK))
1087 medium_mii = 1;
1089 header_added = ((HEADERADDED_MASK & extra_data) == HEADERADDED_MASK) && (extra_data != 0xAA);
1090 li_packet = (LI_MASK & extra_data) == LI_MASK;
1092 // Trace Point Type
1093 proto_tree_add_item_ret_uint(acdr_tree, hf_acdr_trace_pt, tvb, offset, 1, ENC_BIG_ENDIAN,
1094 &trace_point);
1095 offset++;
1097 // Media Type
1098 media_type = tvb_get_uint8(tvb, offset);
1099 if ((media_type == ACDR_DSP_AC5X_MII) && (medium_mii == 0))
1100 proto_tree_add_item(acdr_tree, hf_acdr_media_type_dsp_ac5x, tvb, offset, 1, ENC_BIG_ENDIAN);
1101 else
1102 proto_tree_add_item(acdr_tree, hf_acdr_media_type, tvb, offset, 1, ENC_BIG_ENDIAN);
1103 offset++;
1105 if ((version & 0xF) < 5) {
1106 // Payload Offset
1107 proto_tree_add_item(acdr_tree, hf_acdr_pl_offset_type, tvb, offset, 1, ENC_BIG_ENDIAN);
1108 } else {
1109 // Header Extension Length
1110 proto_tree_add_item_ret_uint(acdr_tree, hf_acdr_header_ext_len_type, tvb, offset, 1,
1111 ENC_BIG_ENDIAN, &header_extension_len);
1113 offset++;
1115 // calculate the header length
1116 acdr_header_length = header_byte_length + header_extension_len;
1117 if (medium_mii)
1118 acdr_header_length += MII_HEADER_BYTE_LENGTH;
1120 if ((version & 0xF) >= 5) {
1121 if ((version & 0xF) < 7) {
1122 // Simple SessionID (not include BoardID)
1123 proto_tree_add_item(acdr_tree, hf_acdr_session_id_session_number, tvb,
1124 offset, 4, ENC_BIG_ENDIAN);
1125 } else {
1126 // Full SessionID (include also BoardID)
1127 create_full_session_id_subtree(pinfo->pool, acdr_tree, tvb, offset, version);
1131 proto_item_set_len(header_ti, acdr_header_length);
1132 if (header_added) {
1133 p_add_proto_data(pinfo->pool, pinfo, proto_acdr, 0, GUINT_TO_POINTER(media_type));
1134 if (media_type == ACDR_VoiceAI)
1135 proto_name = "VoiceAI";
1136 else if (media_type == ACDR_DTLS)
1137 proto_name = "DTLS data";
1140 // Header extension
1141 if (header_extension_len > 0) {
1142 switch (media_type) {
1143 case ACDR_T38:
1144 if (header_added) {
1145 // Gen3 only: we put the UDP header in the last 8 bytes of the header extension.
1146 // So, we have only IP address into the real header extension
1147 if (header_extension_len == 12)
1148 header_extension_len = 4;
1150 break;
1152 case ACDR_RTP_AMR:
1153 case ACDR_RTP_EVRC:
1154 case ACDR_RTP_RFC2198:
1155 case ACDR_RTP_RFC2833:
1156 case ACDR_RTP_FEC:
1157 payload_type = (tvb_get_uint8(tvb, acdr_header_length + 1) & 0x7F);
1158 break;
1161 create_header_extension_subtree(acdr_tree, tvb, header_byte_length, header_extension_len,
1162 version, media_type, trace_point, extra_data, &tls_packet_info);
1165 if (medium_mii)
1166 create_mii_header_subtree(acdr_tree, tvb, header_byte_length + header_extension_len, media_type);
1168 // create a new tvbuff for the next dissector
1169 next_tvb = tvb_new_subset_remaining(tvb, header_byte_length + header_extension_len);
1171 if ((trace_point == DspIncoming) || (trace_point == DspOutgoing)) {
1172 // Gen5 only - special case of recorded packets from DSP
1173 create_5x_analysis_packet_header_subtree(tree, next_tvb);
1175 next_tvb = tvb_new_subset_remaining(tvb, header_byte_length + header_extension_len +
1176 AC5X_ANALYSIS_PACKET_HEADER);
1177 create_5x_hpi_packet_header_subtree(tree, next_tvb);
1179 next_tvb = tvb_new_subset_remaining(tvb, header_byte_length + header_extension_len +
1180 AC5X_ANALYSIS_PACKET_HEADER + AC5X_HPI_PACKET_HEADER);
1183 acdr_dissector_data_t data;
1185 data.header_added = header_added;
1186 data.version = version;
1187 data.tls_source_port = tls_packet_info.source_port;
1188 data.tls_dest_port = tls_packet_info.dest_port;
1189 data.tls_application = tls_packet_info.application;
1190 data.media_type = media_type;
1191 data.payload_type = payload_type;
1192 data.trace_point = trace_point;
1193 data.medium_mii = medium_mii;
1194 data.li_packet = li_packet;
1195 acdr_payload_handler(tree, pinfo, next_tvb, &data, proto_name);
1198 static int
1199 dissect_acdr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
1201 pinfo->current_proto = "acdr";
1203 col_set_str(pinfo->cinfo, COL_PROTOCOL, "AC DR");
1204 col_set_str(pinfo->cinfo, COL_INFO, "AC DEBUG Packet");
1206 create_acdr_tree(tree, pinfo, tvb);
1208 return tvb_captured_length(tvb);
1211 static int
1212 dissect_acdr_voiceai(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
1215 * I guess this is just a blob of JSON.
1217 * Do *NOT* pass data to the JSON dissector; it's expecting
1218 * an http_message_info_t *, and that's *NOT* what we hand
1219 * subdissectors. Hilarity ensures; see
1221 * https://gitlab.com/wireshark/wireshark/-/issues/16622
1223 call_dissector(json_dissector_handle, tvb, pinfo, tree);
1224 return tvb_captured_length(tvb);
1227 static int
1228 dissect_acdr_tls(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
1230 acdr_dissector_data_t *acdr_data = (acdr_dissector_data_t *) data;
1231 int dissected;
1233 if (acdr_data == NULL)
1234 return 0;
1236 if (acdr_data->tls_application == TLS_APP_TCP) {
1237 dissected = dissector_try_uint(tls_application_port_table, acdr_data->tls_source_port, tvb,
1238 pinfo, tree);
1239 if (dissected != 0)
1240 return dissected;
1242 dissected = dissector_try_uint(tls_application_port_table, acdr_data->tls_dest_port, tvb,
1243 pinfo, tree);
1244 if (dissected != 0)
1245 return dissected;
1246 } else {
1247 dissected = dissector_try_uint(tls_application_table, acdr_data->tls_application, tvb,
1248 pinfo, tree);
1249 if (dissected != 0)
1250 return dissected;
1253 //dissector wasn't found
1254 col_set_str(pinfo->cinfo, COL_PROTOCOL, "TLS");
1255 col_clear(pinfo->cinfo, COL_INFO);
1256 col_set_str(pinfo->cinfo, COL_INFO, "TLS raw data");
1257 call_data_dissector(tvb, pinfo, tree);
1259 return tvb_captured_length(tvb);
1262 static int
1263 dissect_acdr_ip_or_other(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data,
1264 dissector_handle_t other_dissector_handle)
1266 acdr_dissector_data_t *acdr_data = (acdr_dissector_data_t *) data;
1268 if (acdr_data == NULL)
1269 return 0;
1271 if (acdr_data->header_added && ip_dissector_handle) {
1272 call_dissector(ip_dissector_handle, tvb, pinfo, tree);
1273 } else if (other_dissector_handle) {
1274 call_dissector(other_dissector_handle, tvb, pinfo, tree);
1275 } else {
1276 call_data_dissector(tvb, pinfo, tree);
1279 return tvb_captured_length(tvb);
1282 static int
1283 dissect_acdr_sip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
1285 return dissect_acdr_ip_or_other(tvb, pinfo, tree, data, sip_dissector_handle);
1288 static int
1289 dissect_acdr_megaco(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
1291 return dissect_acdr_ip_or_other(tvb, pinfo, tree, data, megaco_dissector_handle);
1294 static int
1295 dissect_acdr_mgcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
1297 return dissect_acdr_ip_or_other(tvb, pinfo, tree, data, mgcp_dissector_handle);
1300 static int
1301 dissect_acdr_rtp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
1303 acdr_dissector_data_t *acdr_data = (acdr_dissector_data_t *) data;
1305 if (acdr_data == NULL)
1306 return 0;
1308 dissect_rtp_packet(tvb, pinfo, tree, acdr_data->media_type, acdr_data->payload_type);
1310 return tvb_captured_length(tvb);
1313 static int
1314 dissect_acdr_rtcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
1316 acdr_dissector_data_t *acdr_data = (acdr_dissector_data_t *) data;
1318 if (acdr_data == NULL)
1319 return 0;
1321 int bytes_dissected = 0;
1322 if ((tvb_get_uint8(tvb, 0) & 0xC0) == 0) {
1323 // RTCP Version = 0
1324 if (tvb_get_ntohl(tvb, 4) == 0x2112a442) {
1325 // This is STUN RFC 5389 packet
1326 if (udp_stun_dissector_handle) {
1327 bytes_dissected = call_dissector(udp_stun_dissector_handle, tvb, pinfo, tree);
1328 if (bytes_dissected > 0)
1329 return bytes_dissected;
1334 if (rtcp_dissector_handle)
1335 return call_dissector(rtcp_dissector_handle, tvb, pinfo, tree);
1337 return tvb_captured_length(tvb);
1340 static int
1341 dissect_acdr_video_rtcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
1343 int res = dissect_acdr_rtcp(tvb, pinfo, tree, data);
1345 col_set_str(pinfo->cinfo, COL_PROTOCOL, "RTCP Video");
1346 return res;
1349 static int
1350 dissect_acdr_xml(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
1352 const char *name;
1353 acdr_dissector_data_t *acdr_data = (acdr_dissector_data_t *) data;
1354 if (acdr_data == NULL)
1355 return 0;
1357 name = val_to_str_const(acdr_data->media_type, acdr_media_type_vals, "Unknown");
1358 col_set_str(pinfo->cinfo, COL_PROTOCOL, "ACDR");
1359 col_set_str(pinfo->cinfo, COL_INFO, name);
1361 return call_dissector(xml_dissector_handle, tvb, pinfo, tree);
1364 static int
1365 dissect_acdr_dsp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void *data,
1366 int hf, int ett, const char *name, dissector_handle_t dissector)
1368 unsigned packet_direction;
1369 proto_item *packet_item;
1370 proto_tree *packet_tree;
1371 acdr_dissector_data_t *acdr_data = (acdr_dissector_data_t *) data;
1373 if (!dissector)
1374 return call_data_dissector(tvb, pinfo, parent_tree);
1375 packet_item = proto_tree_add_item(parent_tree, hf, tvb, 0, -1, ENC_NA);
1376 packet_tree = proto_item_add_subtree(packet_item, ett);
1378 col_clear(pinfo->cinfo, COL_INFO);
1380 col_set_str(pinfo->cinfo, COL_PROTOCOL, name);
1382 if (acdr_data->trace_point == Dsp2Host)
1383 packet_direction = DIR_RX;
1384 else
1385 packet_direction = DIR_TX;
1387 return call_dissector_with_data(dissector, tvb, pinfo, packet_tree, &packet_direction);
1390 static int
1391 dissect_acdr_ac45x(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void *data)
1393 return dissect_acdr_dsp(tvb, pinfo, parent_tree, data, hf_ac45x_packet, ett_ac45x_packet,
1394 "AC45X", dsp_45x_dissector_handle);
1397 static int
1398 dissect_acdr_ac48x(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void *data)
1400 return dissect_acdr_dsp(tvb, pinfo, parent_tree, data, hf_ac48x_packet, ett_ac48x_packet,
1401 "AC48X", dsp_48x_dissector_handle);
1404 static int
1405 dissect_acdr_ac49x(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void *data)
1407 return dissect_acdr_dsp(tvb, pinfo, parent_tree, data, hf_ac49x_packet, ett_ac49x_packet,
1408 "AC49X", dsp_49x_dissector_handle);
1411 static int
1412 dissect_acdr_ac5x(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void *data)
1414 return dissect_acdr_dsp(tvb, pinfo, parent_tree, data, hf_ac5x_packet, ett_ac5x_packet,
1415 "AC5X", dsp_5x_dissector_handle);
1418 static int
1419 dissect_acdr_mii(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
1421 proto_item *packet_item = NULL;
1422 proto_item *packet_tree = NULL;
1423 acdr_dissector_data_t *acdr_data = (acdr_dissector_data_t *) data;
1424 struct AcdrAc5xPrivateData private_data;
1426 if (!dsp_5x_MII_dissector_handle)
1427 return call_data_dissector(tvb, pinfo, packet_tree);
1429 if (acdr_data->media_type == ACDR_DSP_TDM_PLAYBACK) {
1430 private_data.protocol_type = ACDR_AC5X_PROTOCOL_TYPE__TDM_PLAYBACK;
1431 private_data.mii_header_exist = 1;
1432 } else if (acdr_data->media_type == ACDR_DSP_NET_PLAYBACK) {
1433 private_data.protocol_type = ACDR_AC5X_PROTOCOL_TYPE__NET_PLAYBACK;
1434 private_data.mii_header_exist = 1;
1435 } else {
1436 private_data.protocol_type = ACDR_AC5X_PROTOCOL_TYPE__REGULAR;
1437 private_data.mii_header_exist = acdr_data->medium_mii;
1440 packet_item = proto_tree_add_item(tree, proto_ac5xmii, tvb, 0, -1, ENC_NA);
1441 packet_tree = proto_item_add_subtree(packet_item, ett_ac5x_mii_packet);
1443 col_clear(pinfo->cinfo, COL_INFO);
1444 if (acdr_data->media_type == ACDR_DSP_AC5X_MII) {
1445 if (acdr_data->medium_mii)
1446 col_set_str(pinfo->cinfo, COL_PROTOCOL, "AC5x_MII");
1447 else
1448 col_set_str(pinfo->cinfo, COL_PROTOCOL, "AC5x");
1449 } else {
1450 col_set_str(pinfo->cinfo, COL_PROTOCOL, "AC5x_MII");
1453 if ((acdr_data->trace_point == Dsp2Host) || (acdr_data->trace_point == DspOutgoing))
1454 private_data.packet_direction = DIR_RX;
1455 else
1456 private_data.packet_direction = DIR_TX;
1458 return call_dissector_with_data(dsp_5x_MII_dissector_handle, tvb, pinfo, packet_tree, &private_data);
1461 static int
1462 dissect_acdr_v1501(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
1464 col_set_str(pinfo->cinfo, COL_PROTOCOL, "V150.1");
1465 return call_data_dissector(tvb, pinfo, tree);
1468 static int
1469 dissect_acdr_signaling(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
1471 acdr_dissector_data_t *acdr_data = (acdr_dissector_data_t *) data;
1472 proto_item *packet_item = proto_tree_add_item(tree, hf_signaling_packet, tvb, 0, -1, ENC_NA);
1473 proto_tree *packet_tree = proto_item_add_subtree(packet_item, ett_signaling_packet);
1475 int res = dissect_signaling_packet(tvb, pinfo, packet_tree, acdr_data->trace_point);
1477 col_set_str(pinfo->cinfo, COL_PROTOCOL, "Signaling");
1478 col_clear(pinfo->cinfo, COL_INFO);
1479 switch (acdr_data->trace_point) {
1480 case Host2Pstn:
1481 col_prepend_fstr(pinfo->cinfo, COL_INFO, "HOST --> PSTN");
1482 break;
1483 case Pstn2Host:
1484 col_prepend_fstr(pinfo->cinfo, COL_INFO, "PSTN --> HOST");
1485 break;
1486 case DspIncoming:
1487 col_prepend_fstr(pinfo->cinfo, COL_INFO, "DSP Incoming: HOST --> PSTN");
1488 break;
1489 case DspOutgoing:
1490 col_prepend_fstr(pinfo->cinfo, COL_INFO, "DSP Outgoing: PSTN --> HOST");
1491 break;
1493 return res;
1496 static int
1497 dissect_acdr_fragmented(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
1499 col_set_str(pinfo->cinfo, COL_PROTOCOL, "Fragmented");
1500 col_set_str(pinfo->cinfo, COL_INFO, "fragment of previous ACDR packet");
1501 return call_data_dissector(tvb, pinfo, tree);
1504 static int
1505 dissect_acdr_dsp_data_relay(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
1507 col_set_str(pinfo->cinfo, COL_PROTOCOL, "DSP Data Relay");
1508 return call_data_dissector(tvb, pinfo, tree);
1511 static const char *acdr_ssh_protocol(int media_type)
1513 switch (media_type) {
1514 case ACDR_SSH_SHELL: return "SSH-SHELL";
1515 case ACDR_SSH_SFTP: return "SSH-SFTP";
1516 case ACDR_SSH_SCP: return "SSH-SCP";
1518 return "Unknown";
1521 static int
1522 dissect_acdr_ssh(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
1524 acdr_dissector_data_t *acdr_data = (acdr_dissector_data_t *) data;
1525 col_set_str(pinfo->cinfo, COL_PROTOCOL, acdr_ssh_protocol(acdr_data->media_type));
1526 col_set_str(pinfo->cinfo, COL_INFO, "SSH raw data");
1527 return call_data_dissector(tvb, pinfo, tree);
1530 void
1531 proto_register_acdr(void)
1533 static hf_register_info hf[] = {
1534 { &hf_acdr_unknown_packet,
1535 { "Unknown packet Type", "acdr.unknown_packet",
1536 FT_NONE, BASE_NONE,
1537 NULL, 0x0,
1538 NULL, HFILL }
1540 { &hf_acdr_timestamp,
1541 { "Time Stamp", "acdr.timestamp",
1542 FT_RELATIVE_TIME, BASE_NONE,
1543 NULL, 0x0,
1544 "timestamp in us resolution", HFILL }
1546 { &hf_acdr_seq_num,
1547 { "Sequence Number", "acdr.seq",
1548 FT_UINT16, BASE_DEC,
1549 NULL, 0x0,
1550 NULL, HFILL }
1552 { &hf_acdr_sourceid,
1553 { "Source ID", "acdr.src_id",
1554 FT_INT32, BASE_DEC,
1555 NULL, 0x0,
1556 "source EP ID (CID)", HFILL }
1558 { &hf_acdr_destid,
1559 { "Dest ID", "acdr.dst_id",
1560 FT_INT32, BASE_DEC,
1561 NULL, 0x0,
1562 "dest EP ID (CID)", HFILL }
1564 { &hf_acdr_version,
1565 { "Version", "acdr.ver",
1566 FT_UINT8, BASE_HEX,
1567 NULL, 0x0,
1568 "DR Protocol version (Major.Minor)", HFILL }
1570 { &hf_acdr_trace_pt,
1571 { "Trace Point", "acdr.trace_pt",
1572 FT_UINT8, BASE_DEC,
1573 VALS(acdr_trace_pt_vals), 0x0,
1574 "AC Debug trace point", HFILL }
1576 { &hf_acdr_media_type,
1577 { "Media Type", "acdr.media_type",
1578 FT_UINT8, BASE_DEC,
1579 VALS(acdr_media_type_vals), 0x0,
1580 "AC Debug layer 2 packet type", HFILL }
1582 { &hf_acdr_media_type_dsp_ac5x,
1583 { "Media Type", "acdr.media_type",
1584 FT_UINT8, BASE_DEC,
1585 VALS(acdr_media_type_dummy_vals), 0x0,
1586 "AC Debug layer 2 packet type", HFILL }
1588 { &hf_acdr_pl_offset_type,
1589 { "Payload offset", "acdr.payload_offset",
1590 FT_UINT8, BASE_DEC,
1591 NULL, 0x0,
1592 "Offset to packet Payload", HFILL }
1594 { &hf_acdr_header_ext_len_type,
1595 { "Header Extension Len", "acdr.header_ext_len",
1596 FT_UINT8, BASE_DEC,
1597 NULL, 0x0,
1598 "Header extension length", HFILL }
1600 { &hf_acdr_data,
1601 { "Extra Data", "acdr.extra_data",
1602 FT_UINT8, BASE_HEX,
1603 NULL, 0x0,
1604 NULL, HFILL }
1606 { &hf_acdr_data_li,
1607 { "LI", "acdr.extra_data.li",
1608 FT_UINT8, BASE_HEX,
1609 NULL, LI_MASK,
1610 "Packet LI (with X2 or X3 header)", HFILL }
1612 { &hf_acdr_data_mtce,
1613 { "Mtce", "acdr.extra_data.mtce",
1614 FT_UINT8, BASE_HEX,
1615 NULL, MTCE_MASK,
1616 "Packet of Mtce", HFILL }
1618 { &hf_acdr_data_encrypted,
1619 { "Encrypted", "acdr.extra_data.encrypted",
1620 FT_UINT8, BASE_HEX,
1621 NULL, ENCRYPTED_MASK,
1622 "Packet is Encrypted", HFILL }
1624 { &hf_acdr_data_headeradded,
1625 { "header_added", "acdr.extra_data.headeradded",
1626 FT_UINT8, BASE_HEX,
1627 NULL, HEADERADDED_MASK,
1628 "Header Added", HFILL }
1630 { &hf_acdr_data_fragmented,
1631 { "Fragmented", "acdr.extra_data.fragmented",
1632 FT_UINT8, BASE_HEX,
1633 NULL, FRAGMENTED_MASK,
1634 "Fragmented Data", HFILL }
1636 { &hf_acdr_data_ipv6,
1637 { "IPV6", "acdr.extra_data.ipv6",
1638 FT_UINT8, BASE_HEX,
1639 NULL, IPV6_MASK,
1640 NULL, HFILL }
1642 { &hf_acdr_data_mii,
1643 { "MII", "acdr.extra_data.mii",
1644 FT_UINT8, BASE_HEX,
1645 NULL, MEDIUM_MASK,
1646 NULL, HFILL }
1648 { &hf_acdr_session_id,
1649 { "Full Session ID", "acdr.full_session_id",
1650 FT_STRING, BASE_NONE,
1651 NULL, 0x0,
1652 NULL, HFILL }
1654 { &hf_acdr_session_id_board_id,
1655 { "Board ID", "acdr.board_id",
1656 FT_UINT24, BASE_HEX,
1657 NULL, 0x0,
1658 NULL, HFILL }
1660 { &hf_acdr_session_id_reset_counter,
1661 { "Reset Counter", "acdr.reset_counter",
1662 FT_UINT8, BASE_DEC,
1663 NULL, 0x0,
1664 NULL, HFILL }
1666 { &hf_acdr_session_id_session_number,
1667 { "Session ID", "acdr.session_id",
1668 FT_UINT32, BASE_DEC,
1669 NULL, 0x0,
1670 NULL, HFILL }
1672 { &hf_acdr_session_id_long_session_number,
1673 { "Session ID", "acdr.long_session_id",
1674 FT_UINT40, BASE_DEC,
1675 NULL, 0x0,
1676 NULL, HFILL }
1678 { &hf_acdr_payload_header,
1679 { "Payload Header", "acdr.payload_header",
1680 FT_BYTES, BASE_NONE,
1681 NULL, 0x0,
1682 "Payload header bytes", HFILL }
1684 { &hf_acdr_ext_srcudp,
1685 { "Packet source UDP port", "acdr.ext.src_port",
1686 FT_UINT16, BASE_DEC,
1687 NULL, 0x0,
1688 NULL, HFILL }
1690 { &hf_acdr_ext_dstudp,
1691 { "Packet destination UDP port", "acdr.ext.dst_port",
1692 FT_UINT16, BASE_DEC,
1693 NULL, 0x0,
1694 NULL, HFILL }
1696 { &hf_acdr_ext_srcip,
1697 { "Packet source IP address", "acdr.ext.src_ip",
1698 FT_IPv4, BASE_NONE,
1699 NULL, 0x0,
1700 NULL, HFILL }
1702 { &hf_acdr_ext_srcipv6,
1703 { "Packet source IPv6 address", "acdr.ext.src_ip_v6",
1704 FT_IPv6, BASE_NONE,
1705 NULL, 0x0,
1706 NULL, HFILL }
1709 &hf_acdr_ext_dstip,
1710 { "Packet destination IP address", "acdr.ext.dst_ip",
1711 FT_IPv4, BASE_NONE,
1712 NULL, 0x0,
1713 NULL, HFILL }
1715 { &hf_acdr_ext_dstipv6,
1716 { "Packet destination IPv6 address", "acdr.ext.dst_ip_v6",
1717 FT_IPv6, BASE_NONE,
1718 NULL, 0x0,
1719 NULL, HFILL }
1721 { &hf_acdr_ext_protocol,
1722 { "IP protocol type", "acdr.ext.protocol",
1723 FT_UINT8, BASE_DEC | BASE_EXT_STRING,
1724 &ipproto_val_ext, 0x0,
1725 "IP protocol type (as defined by IANA)", HFILL }
1727 { &hf_acdr_ext_tls_application,
1728 { "TLS Application", "acdr.ext.application",
1729 FT_UINT8, BASE_DEC,
1730 VALS(hf_acdr_ext_tls_application_vals), 0x0,
1731 NULL, HFILL }
1733 { &hf_acdr_ext_direction,
1734 { "Packet Direction", "acdr.ext.direction",
1735 FT_UINT8, BASE_DEC,
1736 VALS(hf_acdr_ext_direction_vals), 0x0,
1737 NULL, HFILL }
1739 { &hf_acdr_ext_iptos,
1740 { "IP type of service", "acdr.ext.iptos",
1741 FT_UINT8, BASE_DEC,
1742 NULL, 0x0,
1743 "IP Type Of Service (IP TOS)", HFILL }
1745 { &hf_acdr_ext_c5_control_flags,
1746 { "C5 Control Flags", "acdr.c5_control_flags",
1747 FT_UINT8, BASE_HEX,
1748 NULL, 0x0,
1749 NULL, HFILL }
1751 { &hf_acdr_ext_c5_control_favorite,
1752 { "Favorite flag", "acdr.c5_control.favorite",
1753 FT_UINT8, BASE_HEX,
1754 NULL, FAVORITE_MASK,
1755 NULL, HFILL }
1757 { &hf_acdr_ext_pstn_trace_seq_num,
1758 { "PSTN Trace Seq Num", "acdr.ext.pstn_trace_seq_num",
1759 FT_UINT32, BASE_DEC,
1760 NULL, 0x0,
1761 "acdr.ext.pstn_trace_seq_num", HFILL }
1763 { &hf_acdr_header_extension,
1764 { "Header Extension", "acdr.ext.header_extension",
1765 FT_NONE, BASE_NONE,
1766 NULL, 0x0,
1767 "acdr.ext.header_extension", HFILL }
1769 { &hf_acdr_ext_dsp_core,
1770 { "DSP Core", "acdr.ext.dsp_core",
1771 FT_UINT8, BASE_DEC,
1772 NULL, 0x0,
1773 "DSP core number", HFILL }
1775 { &hf_acdr_ext_dsp_channel,
1776 { "DSP Channel", "acdr.ext.dsp_ch",
1777 FT_UINT8, BASE_DEC,
1778 NULL, 0x0,
1779 "DSP Channel number", HFILL }
1781 { &hf_acdr_ext_event_id,
1782 { "Event ID", "acdr.ext.event_id",
1783 FT_UINT8, BASE_DEC,
1784 NULL, 0x0,
1785 NULL, HFILL }
1787 { &hf_acdr_ext_event_source,
1788 { "Event source module", "acdr.ext.event_src",
1789 FT_UINT8, BASE_DEC,
1790 NULL, 0x0,
1791 NULL, HFILL }
1793 { &hf_acdr_mii_header,
1794 { "MII Header", "acdr.mii_header",
1795 FT_NONE, BASE_NONE,
1796 NULL, 0x0,
1797 NULL, HFILL }
1799 { &hf_acdr_mii_sequence,
1800 { "MII sequence number", "acdr.mii_sequence_num",
1801 FT_UINT16, BASE_DEC,
1802 NULL, 0x0,
1803 NULL, HFILL }
1805 { &hf_acdr_mii_packet_size,
1806 { "MII packet size", "acdr.mii_packet_size",
1807 FT_UINT16, BASE_DEC,
1808 NULL, 0x0,
1809 NULL, HFILL }
1811 { &hf_acdr_5x_analysis_packet_header,
1812 { "5x Analysis Packet Header", "acdr.5x_analysis_packet_header",
1813 FT_NONE, BASE_NONE,
1814 NULL, 0x0,
1815 NULL, HFILL }
1817 { &hf_5x_analysis_version,
1818 { "Version", "acdr.analysis_version",
1819 FT_UINT16, BASE_DEC,
1820 NULL, 0x0,
1821 "5x Analysis Version", HFILL }
1823 { &hf_5x_analysis_direction,
1824 { "Direction", "acdr.analysis_direction",
1825 FT_UINT8, BASE_HEX,
1826 NULL, 0x80,
1827 "5x Analysis Direction", HFILL }
1829 { &hf_5x_analysis_sub_version,
1830 { "SubVersion", "acdr.analysis_subversion",
1831 FT_UINT8, BASE_DEC,
1832 NULL, 0x7F,
1833 "5x Analysis SubVersion", HFILL }
1835 { &hf_5x_analysis_device,
1836 { "Device", "acdr.analysis_device",
1837 FT_UINT8, BASE_DEC,
1838 NULL, 0x0,
1839 "5x Analysis Device", HFILL }
1841 { &hf_5x_analysis_sequence,
1842 { "Sequence", "acdr.analysis_sequence",
1843 FT_UINT16, BASE_DEC,
1844 NULL, 0x0,
1845 "5x Analysis Sequence", HFILL }
1847 { &hf_5x_analysis_spare1,
1848 { "Spare1", "acdr.analysis_spare1",
1849 FT_UINT16, BASE_DEC,
1850 NULL, 0x0,
1851 "5x Analysis spare1", HFILL }
1853 { &hf_5x_analysis_timestamp,
1854 { "Timestamp", "acdr.analysis_timestamp",
1855 FT_UINT32, BASE_DEC,
1856 NULL, 0x0,
1857 "5x Analysis Timestamp", HFILL }
1859 { &hf_5x_analysis_spare2,
1860 { "Spare2", "acdr.analysis_spare2",
1861 FT_UINT32, BASE_DEC,
1862 NULL, 0x0,
1863 "5x Analysis Spare2", HFILL }
1865 { &hf_acdr_5x_hpi_packet_header,
1866 { "5x HPI Packet Header", "acdr.5x_hpi_packet_header",
1867 FT_NONE, BASE_NONE,
1868 NULL, 0x0,
1869 "acdr.5x_hpi_packet_header", HFILL }
1871 { &hf_5x_hpi_sync5,
1872 { "Sync5", "acdr.5x.HpiHeader.Sync5",
1873 FT_UINT8, BASE_HEX,
1874 NULL, 0xE0,
1875 "DSP Sync const 0x5", HFILL }
1877 { &hf_5x_hpi_udp_checksum,
1878 { "UDP Checksum Included", "acdr.5x.HpiHeader.UdpChecksum",
1879 FT_UINT8, BASE_HEX,
1880 NULL, 0x10,
1881 "5x HpiHeader UdpChecksum", HFILL }
1883 { &hf_5x_hpi_resource_id,
1884 { "Resource ID", "acdr.5x.HpiHeader.ResourceId",
1885 FT_UINT8, BASE_DEC,
1886 NULL, 0x0,
1887 "Resource ID into core", HFILL }
1889 { &hf_5x_hpi_favorite,
1890 { "Favorite Stream", "acdr.5x.HpiHeader.Favorite",
1891 FT_UINT8, BASE_DEC,
1892 NULL, 0x80,
1893 NULL, HFILL }
1895 { &hf_5x_hpi_protocol,
1896 { "Protocol", "acdr.5x.HpiHeader.Protocol",
1897 FT_UINT8, BASE_DEC,
1898 NULL, 0x3F,
1899 "Protocol Proprietary", HFILL }
1901 { &hf_signaling_packet,
1902 { "Signaling Packet", "acdr.signaling_packet",
1903 FT_NONE, BASE_NONE,
1904 NULL, 0x0,
1905 NULL, HFILL }
1907 { &hf_ac45x_packet,
1908 { "45x DSP packet", "acdr.45x_dsp_packet",
1909 FT_NONE, BASE_NONE,
1910 NULL, 0x0,
1911 NULL, HFILL }
1913 { &hf_ac48x_packet,
1914 { "48x DSP packet", "acdr.48x_dsp_packet",
1915 FT_NONE, BASE_NONE,
1916 NULL, 0x0,
1917 NULL, HFILL }
1919 { &hf_ac49x_packet,
1920 { "49x DSP packet", "acdr.49x_dsp_packet",
1921 FT_NONE, BASE_NONE,
1922 NULL, 0x0,
1923 NULL, HFILL }
1925 { &hf_ac5x_packet,
1926 { "5x DSP packet", "acdr.5x_dsp_packet",
1927 FT_NONE, BASE_NONE,
1928 NULL, 0x0,
1929 NULL, HFILL }
1931 { &hf_acdr_signaling_opcode,
1932 { "OpCode", "acdr.signaling_opcode",
1933 FT_UINT16, BASE_HEX,
1934 NULL, 0x0,
1935 NULL, HFILL }
1937 { &hf_acdr_signaling_size,
1938 { "Size", "acdr.signaling_size",
1939 FT_UINT16, BASE_DEC,
1940 NULL, 0x0,
1941 NULL, HFILL }
1943 { &hf_acdr_signaling_timestamp,
1944 { "Timestamp", "acdr.signaling_timestamp",
1945 FT_RELATIVE_TIME, BASE_NONE,
1946 NULL, 0x0,
1947 "Timestamp in us resolution", HFILL }
1951 static int *ett[] = {
1952 &ett_acdr,
1953 &ett_extension,
1954 &ett_ac45x_packet,
1955 &ett_ac48x_packet,
1956 &ett_ac49x_packet,
1957 &ett_ac5x_packet,
1958 &ett_ac5x_mii_packet,
1959 &ett_mii_header,
1960 &ett_signaling_packet,
1961 &ett_extra_data,
1962 &ett_c5_cntrl_flags,
1963 &ett_5x_analysis_packet_header,
1964 &ett_5x_hpi_packet_header,
1965 &ett_session_id
1968 static ei_register_info ei[] = {
1969 { &ei_acdr_version_not_supported, { "acdr.version_not_supported", PI_UNDECODED, PI_WARN, "Version not supported", EXPFILL } },
1972 expert_module_t *expert_acdr;
1974 proto_acdr = proto_register_protocol("AUDIOCODES DEBUG RECORDING", "AC DR", "acdr");
1975 proto_register_field_array(proto_acdr, hf, array_length(hf));
1976 proto_register_subtree_array(ett, array_length(ett));
1978 expert_acdr = expert_register_protocol(proto_acdr);
1979 expert_register_field_array(expert_acdr, ei, array_length(ei));
1981 acdr_dissector_handle = register_dissector("acdr", dissect_acdr, proto_acdr);
1982 acdr_mii_dissector_handle = register_dissector("acdr.mii", dissect_acdr_mii, proto_acdr);
1983 acdr_rtp_dissector_handle = register_dissector("acdr.rtp", dissect_acdr_rtp, proto_acdr);
1984 acdr_xml_dissector_handle = register_dissector("acdr.xml", dissect_acdr_xml, proto_acdr);
1986 media_type_table = register_dissector_table("acdr.media_type", "AC DR Media Type", proto_acdr,
1987 FT_UINT32, BASE_HEX);
1988 tls_application_table = register_dissector_table("acdr.tls_application",
1989 "AC DR TLS Application Type", proto_acdr,
1990 FT_UINT32, BASE_HEX);
1992 //For backwards compatibility
1993 tls_application_port_table = register_dissector_table("acdr.tls_application_port",
1994 "AC DR TLS Application Port", proto_acdr,
1995 FT_UINT32, BASE_HEX);
1998 void
1999 proto_reg_handoff_acdr(void)
2001 rtp_dissector_handle = find_dissector("rtp");
2002 rtp_dissector_table = find_dissector_table("rtp.pt");
2003 rtp_events_handle = find_dissector("rtpevent");
2004 rtp_rfc2198_handle = find_dissector("rtp.rfc2198");
2005 amr_handle = find_dissector("amr");
2006 evrc_handle = find_dissector("EVRC");
2007 ip_dissector_handle = find_dissector("ip");
2008 rtcp_dissector_handle = find_dissector("rtcp");
2009 json_dissector_handle = find_dissector("json");
2010 megaco_dissector_handle = find_dissector("megaco");
2012 mgcp_dissector_handle = find_dissector("mgcp");
2013 sip_dissector_handle = find_dissector("sip");
2014 udp_dissector_handle = find_dissector("udp");
2015 lix2x3_dissector_handle = find_dissector("lix2x3");
2017 dsp_49x_dissector_handle = find_dissector("ac49x");
2018 proto_ac49x = proto_get_id_by_filter_name("ac49x");
2019 dsp_48x_dissector_handle = find_dissector("ac48x");
2020 proto_ac48x = proto_get_id_by_filter_name("ac48x");
2021 dsp_45x_dissector_handle = find_dissector("AC45x");
2022 dsp_5x_dissector_handle = find_dissector("ac5x");
2023 proto_ac5x = proto_get_id_by_filter_name("ac5x");
2024 dsp_5x_MII_dissector_handle = find_dissector("ac5xmii");
2025 proto_ac5xmii = proto_get_id_by_filter_name("ac5xmii");
2027 proto_rtp = proto_get_id_by_filter_name("rtp");
2029 udp_stun_dissector_handle = find_dissector("stun-udp");
2030 xml_dissector_handle = find_dissector("xml");
2031 ssh_dissector_handle = create_dissector_handle(dissect_acdr_ssh, proto_acdr);
2033 // register our port number to the underlying TCP/UDP layers so our
2034 // dissector gets called for the appropriate port
2035 dissector_add_uint_with_preference("udp.port", PORT_AC_DR, acdr_dissector_handle);
2036 dissector_add_uint_with_preference("tcp.port", PORT_AC_DR, acdr_dissector_handle);
2038 // Register "local" media types
2039 dissector_add_uint("acdr.media_type", ACDR_VoiceAI, create_dissector_handle(dissect_acdr_voiceai, proto_acdr));
2040 dissector_add_uint("acdr.media_type", ACDR_TLS, create_dissector_handle(dissect_acdr_tls, proto_acdr));
2041 dissector_add_uint("acdr.media_type", ACDR_TLSPeek, create_dissector_handle(dissect_acdr_tls, proto_acdr));
2042 dissector_add_uint("acdr.media_type", ACDR_SIP, create_dissector_handle(dissect_acdr_sip, proto_acdr));
2043 dissector_add_uint("acdr.media_type", ACDR_MEGACO, create_dissector_handle(dissect_acdr_megaco, proto_acdr));
2044 dissector_add_uint("acdr.media_type", ACDR_MGCP, create_dissector_handle(dissect_acdr_mgcp, proto_acdr));
2046 dissector_add_uint("acdr.media_type", ACDR_RTP, acdr_rtp_dissector_handle);
2047 dissector_add_uint("acdr.media_type", ACDR_RTP_AMR, acdr_rtp_dissector_handle);
2048 dissector_add_uint("acdr.media_type", ACDR_RTP_EVRC, acdr_rtp_dissector_handle);
2049 dissector_add_uint("acdr.media_type", ACDR_RTP_RFC2198, acdr_rtp_dissector_handle);
2050 dissector_add_uint("acdr.media_type", ACDR_RTP_RFC2833, acdr_rtp_dissector_handle);
2051 dissector_add_uint("acdr.media_type", ACDR_T38_OVER_RTP, acdr_rtp_dissector_handle);
2052 dissector_add_uint("acdr.media_type", ACDR_RTP_FEC, acdr_rtp_dissector_handle);
2053 dissector_add_uint("acdr.media_type", ACDR_RTP_FAX_BYPASS, acdr_rtp_dissector_handle);
2054 dissector_add_uint("acdr.media_type", ACDR_RTP_MODEM_BYPASS, acdr_rtp_dissector_handle);
2055 dissector_add_uint("acdr.media_type", ACDR_RTP_NSE, acdr_rtp_dissector_handle);
2056 dissector_add_uint("acdr.media_type", ACDR_RTP_NO_OP, acdr_rtp_dissector_handle);
2057 dissector_add_uint("acdr.media_type", ACDR_PCM, acdr_rtp_dissector_handle);
2058 dissector_add_uint("acdr.media_type", ACDR_NATIVE, acdr_rtp_dissector_handle);
2059 dissector_add_uint("acdr.media_type", ACDR_VIDEORTP, acdr_rtp_dissector_handle);
2060 dissector_add_uint("acdr.media_type", ACDR_RTCP, create_dissector_handle(dissect_acdr_rtcp, proto_acdr));
2061 dissector_add_uint("acdr.media_type", ACDR_VIDEORTCP, create_dissector_handle(dissect_acdr_video_rtcp, proto_acdr));
2062 dissector_add_uint("acdr.media_type", ACDR_DSP_AC45X, create_dissector_handle(dissect_acdr_ac45x, proto_acdr));
2063 dissector_add_uint("acdr.media_type", ACDR_DSP_AC48X, create_dissector_handle(dissect_acdr_ac48x, proto_acdr));
2064 dissector_add_uint("acdr.media_type", ACDR_DSP_AC49X, create_dissector_handle(dissect_acdr_ac49x, proto_acdr));
2065 dissector_add_uint("acdr.media_type", ACDR_DSP_AC5X, create_dissector_handle(dissect_acdr_ac5x, proto_acdr));
2066 dissector_add_uint("acdr.media_type", ACDR_DSP_AC5X_MII, acdr_mii_dissector_handle);
2067 dissector_add_uint("acdr.media_type", ACDR_DSP_TDM_PLAYBACK, acdr_mii_dissector_handle);
2068 dissector_add_uint("acdr.media_type", ACDR_DSP_NET_PLAYBACK, acdr_mii_dissector_handle);
2069 dissector_add_uint("acdr.media_type", ACDR_V1501, create_dissector_handle(dissect_acdr_v1501, proto_acdr));
2070 dissector_add_uint("acdr.media_type", ACDR_SIGNALING, create_dissector_handle(dissect_acdr_signaling, proto_acdr));
2071 dissector_add_uint("acdr.media_type", ACDR_FRAGMENTED, create_dissector_handle(dissect_acdr_fragmented, proto_acdr));
2072 dissector_add_uint("acdr.media_type", ACDR_DSP_DATA_RELAY,
2073 create_dissector_handle(dissect_acdr_dsp_data_relay, proto_acdr));
2074 dissector_add_uint("acdr.media_type", ACDR_QOE_CDR, acdr_xml_dissector_handle);
2075 dissector_add_uint("acdr.media_type", ACDR_QOE_MDR, acdr_xml_dissector_handle);
2076 dissector_add_uint("acdr.media_type", ACDR_QOE_EVENT, acdr_xml_dissector_handle);
2077 dissector_add_uint("acdr.media_type", ACDR_SSH_SHELL, ssh_dissector_handle);
2078 dissector_add_uint("acdr.media_type", ACDR_SSH_SFTP, ssh_dissector_handle);
2079 dissector_add_uint("acdr.media_type", ACDR_SSH_SCP, ssh_dissector_handle);
2083 * Editor modelines - https://www.wireshark.org/tools/modelines.html
2085 * Local variables:
2086 * c-basic-offset: 4
2087 * tab-width: 8
2088 * indent-tabs-mode: nil
2089 * End:
2091 * vi: set shiftwidth=4 tabstop=8 expandtab:
2092 * :indentSize=4:tabSize=8:noTabs=true: