summaryrefslogtreecommitdiff
path: root/epan/dissectors/asn1/t38
diff options
context:
space:
mode:
authorJoão Valverde <joao.valverde@tecnico.ulisboa.pt>2016-03-09 03:17:51 +0000
committerJoão Valverde <j@v6e.pt>2016-03-13 21:30:24 +0000
commit54a520d4a1151c68d0b4e5f09a8d82466fa499f3 (patch)
tree7aacae160382098ce651ac862a5dfd5de4beff94 /epan/dissectors/asn1/t38
parentc1f3c935bdd33090c87f0d2f84842ce9729b747a (diff)
downloadwireshark-54a520d4a1151c68d0b4e5f09a8d82466fa499f3.tar.gz
Move /asn1 to /epan/dissectors
Change-Id: I1208fe3c2ba428995526f561e8f792b8d871e9a9 Reviewed-on: https://code.wireshark.org/review/14388 Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com> Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Reviewed-by: João Valverde <j@v6e.pt>
Diffstat (limited to 'epan/dissectors/asn1/t38')
-rw-r--r--epan/dissectors/asn1/t38/CMakeLists.txt48
-rw-r--r--epan/dissectors/asn1/t38/Makefile.am23
-rw-r--r--epan/dissectors/asn1/t38/Makefile.common45
-rw-r--r--epan/dissectors/asn1/t38/Makefile.nmake26
-rw-r--r--epan/dissectors/asn1/t38/T38_1998.asn55
-rw-r--r--epan/dissectors/asn1/t38/T38_2002.asn54
-rw-r--r--epan/dissectors/asn1/t38/packet-t38-template.c779
-rw-r--r--epan/dissectors/asn1/t38/packet-t38-template.h85
-rw-r--r--epan/dissectors/asn1/t38/t38.cnf261
9 files changed, 1376 insertions, 0 deletions
diff --git a/epan/dissectors/asn1/t38/CMakeLists.txt b/epan/dissectors/asn1/t38/CMakeLists.txt
new file mode 100644
index 0000000000..fd58d0e7a1
--- /dev/null
+++ b/epan/dissectors/asn1/t38/CMakeLists.txt
@@ -0,0 +1,48 @@
+# CMakeLists.txt
+#
+# Wireshark - Network traffic analyzer
+# By Gerald Combs <gerald@wireshark.org>
+# Copyright 1998 Gerald Combs
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+
+set( PROTOCOL_NAME t38 )
+
+set( PROTO_OPT )
+
+set( EXT_ASN_FILE_LIST
+)
+
+set( ASN_FILE_LIST
+ T38_2002.asn
+)
+
+set( EXTRA_DIST
+ ${ASN_FILE_LIST}
+ packet-${PROTOCOL_NAME}-template.c
+ packet-${PROTOCOL_NAME}-template.h
+ ${PROTOCOL_NAME}.cnf
+)
+
+set( SRC_FILES
+ ${EXTRA_DIST}
+ ${EXT_ASN_FILE_LIST}
+)
+
+set( A2W_FLAGS )
+
+ASN2WRS()
+
diff --git a/epan/dissectors/asn1/t38/Makefile.am b/epan/dissectors/asn1/t38/Makefile.am
new file mode 100644
index 0000000000..72d28e600b
--- /dev/null
+++ b/epan/dissectors/asn1/t38/Makefile.am
@@ -0,0 +1,23 @@
+# Wireshark - Network traffic analyzer
+# By Gerald Combs <gerald@wireshark.org>
+# Copyright 1998 Gerald Combs
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+include ../Makefile.preinc
+include Makefile.common
+include ../Makefile.inc
+
diff --git a/epan/dissectors/asn1/t38/Makefile.common b/epan/dissectors/asn1/t38/Makefile.common
new file mode 100644
index 0000000000..de556f6893
--- /dev/null
+++ b/epan/dissectors/asn1/t38/Makefile.common
@@ -0,0 +1,45 @@
+# Wireshark - Network traffic analyzer
+# By Gerald Combs <gerald@wireshark.org>
+# Copyright 1998 Gerald Combs
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+PROTOCOL_NAME = t38
+
+EXT_ASN_FILE_LIST =
+
+ASN_FILE_LIST = \
+ T38_2002.asn
+
+INCLUDED_ASN_FILE_LIST = \
+ T38_1998.asn
+
+EXTRA_DIST = \
+ $(EXTRA_DIST_COMMON) \
+ $(ASN_FILE_LIST) \
+ $(INCLUDED_ASN_FILE_LIST) \
+ packet-$(PROTOCOL_NAME)-template.c \
+ packet-$(PROTOCOL_NAME)-template.h \
+ $(PROTOCOL_NAME).cnf
+
+SRC_FILES = \
+ $(EXTRA_DIST) \
+ $(EXT_ASN_FILE_LIST)
+
+A2W_FLAGS =
+
+EXTRA_CNF =
+
diff --git a/epan/dissectors/asn1/t38/Makefile.nmake b/epan/dissectors/asn1/t38/Makefile.nmake
new file mode 100644
index 0000000000..d296638ddd
--- /dev/null
+++ b/epan/dissectors/asn1/t38/Makefile.nmake
@@ -0,0 +1,26 @@
+## Use: $(MAKE) /$(MAKEFLAGS) -f makefile.nmake
+#
+# Wireshark - Network traffic analyzer
+# By Gerald Combs <gerald@wireshark.org>
+# Copyright 1998 Gerald Combs
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+include ../../../../config.nmake
+include ../Makefile.preinc.nmake
+include Makefile.common
+include ../Makefile.inc.nmake
+
diff --git a/epan/dissectors/asn1/t38/T38_1998.asn b/epan/dissectors/asn1/t38/T38_1998.asn
new file mode 100644
index 0000000000..deaa3d84d5
--- /dev/null
+++ b/epan/dissectors/asn1/t38/T38_1998.asn
@@ -0,0 +1,55 @@
+-- T38(1998).asn
+--
+-- Taken from ITU ASN.1 database
+-- http://www.itu.int/ITU-T/asn1/database/itu-t/t/t38/2005/T38(1998).asn
+--
+-- it is not used for dissector generation
+-- it is here only for information to see difference of the "Pre-Corrigendum" version
+--
+
+-- Module T38(1998) (T.38:09/2005)
+T38 DEFINITIONS AUTOMATIC TAGS ::=
+BEGIN
+
+IFPPacket ::= SEQUENCE {
+ type-of-msg Type-of-msg,
+ data-field Data-Field OPTIONAL
+}
+
+Type-of-msg ::= CHOICE {
+ t30-indicator
+ ENUMERATED {no-signal, cng, ced, v21-preamble, v27-2400-training,
+ v27-4800-training, v29-7200-training, v29-9600-training,
+ v17-7200-short-training, v17-7200-long-training,
+ v17-9600-short-training, v17-9600-long-training,
+ v17-12000-short-training, v17-12000-long-training,
+ v17-14400-short-training, v17-14400-long-training, ...
+ },
+ data
+ ENUMERATED {v21, v27-2400, v27-4800, v29-7200, v29-9600, v17-7200,
+ v17-9600, v17-12000, v17-14400, ...
+ }
+}
+
+Data-Field ::=
+ SEQUENCE OF
+ SEQUENCE {field-type
+ ENUMERATED {hdlc-data, hdlc-sig-end, hdlc-fcs-OK, hdlc-fcs-BAD,
+ hdlc-fcs-OK-sig-end, hdlc-fcs-BAD-sig-end,
+ t4-non-ecm-data, t4-non-ecm-sig-end},
+ field-data OCTET STRING(SIZE (1..65535)) OPTIONAL}
+
+UDPTLPacket ::= SEQUENCE {
+ seq-number INTEGER(0..65535),
+ primary-ifp-packet TYPE-IDENTIFIER.&Type(IFPPacket),
+ error-recovery
+ CHOICE {secondary-ifp-packets SEQUENCE OF TYPE-IDENTIFIER.&Type(IFPPacket),
+ fec-info
+ SEQUENCE {fec-npackets INTEGER,
+ fec-data SEQUENCE OF OCTET STRING}}
+}
+
+END
+
+-- Generated by Asnp, the ASN.1 pretty-printer of France Telecom R&D
+
diff --git a/epan/dissectors/asn1/t38/T38_2002.asn b/epan/dissectors/asn1/t38/T38_2002.asn
new file mode 100644
index 0000000000..a0ff932cad
--- /dev/null
+++ b/epan/dissectors/asn1/t38/T38_2002.asn
@@ -0,0 +1,54 @@
+-- T38(2002).asn
+--
+-- Taken from ITU ASN.1 database
+-- http://www.itu.int/ITU-T/asn1/database/itu-t/t/t38/2005/T38(2002).asn
+--
+
+-- Module T38(2002) (T.38:09/2005)
+T38 DEFINITIONS AUTOMATIC TAGS ::=
+BEGIN
+
+IFPPacket ::= SEQUENCE {
+ type-of-msg Type-of-msg,
+ data-field Data-Field OPTIONAL
+}
+
+Type-of-msg ::= CHOICE {
+ t30-indicator
+ ENUMERATED {no-signal, cng, ced, v21-preamble, v27-2400-training,
+ v27-4800-training, v29-7200-training, v29-9600-training,
+ v17-7200-short-training, v17-7200-long-training,
+ v17-9600-short-training, v17-9600-long-training,
+ v17-12000-short-training, v17-12000-long-training,
+ v17-14400-short-training, v17-14400-long-training, ...,
+ v8-ansam, v8-signal, v34-cntl-channel-1200, v34-pri-channel,
+ v34-CC-retrain, v33-12000-training, v33-14400-training},
+ t30-data
+ ENUMERATED {v21, v27-2400, v27-4800, v29-7200, v29-9600, v17-7200,
+ v17-9600, v17-12000, v17-14400, ...,
+ v8, v34-pri-rate, v34-CC-1200, v34-pri-ch, v33-12000, v33-14400}
+}
+
+Data-Field ::=
+ SEQUENCE OF
+ SEQUENCE {field-type
+ ENUMERATED {hdlc-data, hdlc-sig-end, hdlc-fcs-OK, hdlc-fcs-BAD,
+ hdlc-fcs-OK-sig-end, hdlc-fcs-BAD-sig-end,
+ t4-non-ecm-data, t4-non-ecm-sig-end, ...,
+ cm-message, jm-message, ci-message, v34rate},
+ field-data OCTET STRING(SIZE (1..65535)) OPTIONAL}
+
+UDPTLPacket ::= SEQUENCE {
+ seq-number INTEGER(0..65535),
+ primary-ifp-packet TYPE-IDENTIFIER.&Type(IFPPacket),
+ error-recovery
+ CHOICE {secondary-ifp-packets SEQUENCE OF TYPE-IDENTIFIER.&Type(IFPPacket),
+ fec-info
+ SEQUENCE {fec-npackets INTEGER,
+ fec-data SEQUENCE OF OCTET STRING}}
+}
+
+END
+
+-- Generated by Asnp, the ASN.1 pretty-printer of France Telecom R&D
+
diff --git a/epan/dissectors/asn1/t38/packet-t38-template.c b/epan/dissectors/asn1/t38/packet-t38-template.c
new file mode 100644
index 0000000000..b224b664fe
--- /dev/null
+++ b/epan/dissectors/asn1/t38/packet-t38-template.c
@@ -0,0 +1,779 @@
+/* packet-t38.c
+ * Routines for T.38 packet dissection
+ * 2003 Hans Viens
+ * 2004 Alejandro Vaquero, add support Conversations for SDP
+ * 2006 Alejandro Vaquero, add T30 reassemble and dissection
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+
+/* Depending on what ASN.1 specification is used you may have to change
+ * the preference setting regarding Pre-Corrigendum ASN.1 specification:
+ * http://www.itu.int/ITU-T/asn1/database/itu-t/t/t38/1998/T38.html (Pre-Corrigendum=TRUE)
+ * http://www.itu.int/ITU-T/asn1/database/itu-t/t/t38/2003/T38(1998).html (Pre-Corrigendum=TRUE)
+ *
+ * http://www.itu.int/ITU-T/asn1/database/itu-t/t/t38/2003/T38(2002).html (Pre-Corrigendum=FALSE)
+ * http://www.itu.int/ITU-T/asn1/database/itu-t/t/t38/2002/t38.html (Pre-Corrigendum=FALSE)
+ * http://www.itu.int/ITU-T/asn1/database/itu-t/t/t38/2002-Amd1/T38.html (Pre-Corrigendum=FALSE)
+ */
+
+/* TO DO:
+ * - TCP desegmentation is currently not supported for T.38 IFP directly over TCP.
+ * - H.245 dissectors should be updated to start conversations for T.38 similar to RTP.
+ * - Sometimes the last octet is not high-lighted when selecting something in the tree. Bug in PER dissector?
+ * - Add support for RTP payload audio/t38 (draft-jones-avt-audio-t38-03.txt), i.e. T38 in RTP packets.
+ */
+
+
+#include "config.h"
+
+#include <epan/packet.h>
+#include <epan/reassemble.h>
+#include <epan/conversation.h>
+#include <epan/tap.h>
+#include <epan/expert.h>
+#include <epan/strutil.h>
+#include <epan/prefs.h>
+#include <epan/ipproto.h>
+#include <epan/asn1.h>
+#include <epan/proto_data.h>
+
+#include "packet-t38.h"
+#include "packet-per.h"
+#include "packet-tpkt.h"
+
+void proto_register_t38(void);
+
+static int t38_tap = -1;
+
+/* dissect using the Pre Corrigendum T.38 ASN.1 specification (1998) */
+static gboolean use_pre_corrigendum_asn1_specification = TRUE;
+
+/* dissect packets that looks like RTP version 2 packets as RTP */
+/* instead of as T.38. This may result in that some T.38 UPTL */
+/* packets with sequence number values higher than 32767 may be */
+/* shown as RTP packets. */
+static gboolean dissect_possible_rtpv2_packets_as_rtp = FALSE;
+
+
+/* Reassembly of T.38 PDUs over TPKT over TCP */
+static gboolean t38_tpkt_reassembly = TRUE;
+
+/* Preference setting whether TPKT header is used when sending T.38 over TCP.
+ * The default setting is Maybe where the dissector will look on the first
+ * bytes to try to determine whether TPKT header is used or not. This may not
+ * work so well in some cases. You may want to change the setting to Always or
+ * Newer.
+ */
+#define T38_TPKT_NEVER 0 /* Assume that there is never a TPKT header */
+#define T38_TPKT_ALWAYS 1 /* Assume that there is always a TPKT header */
+#define T38_TPKT_MAYBE 2 /* Assume TPKT if first octets are 03-00-xx-xx */
+static gint t38_tpkt_usage = T38_TPKT_MAYBE;
+
+static const enum_val_t t38_tpkt_options[] = {
+ {"never", "Never", T38_TPKT_NEVER},
+ {"always", "Always", T38_TPKT_ALWAYS},
+ {"maybe", "Maybe", T38_TPKT_MAYBE},
+ {NULL, NULL, -1}
+};
+
+
+
+/* T38 */
+static dissector_handle_t t38_udp_handle;
+static dissector_handle_t t38_tcp_handle;
+static dissector_handle_t t38_tcp_pdu_handle;
+static dissector_handle_t rtp_handle;
+static dissector_handle_t t30_hdlc_handle;
+static dissector_handle_t data_handle;
+
+static gint32 Type_of_msg_value;
+static guint32 Data_Field_field_type_value;
+static guint32 Data_value;
+static guint32 T30ind_value;
+static guint32 Data_Field_item_num;
+
+static int proto_t38 = -1;
+#include "packet-t38-hf.c"
+
+/* T38 setup fields */
+static int hf_t38_setup = -1;
+static int hf_t38_setup_frame = -1;
+static int hf_t38_setup_method = -1;
+
+/* T38 Data reassemble fields */
+static int hf_t38_fragments = -1;
+static int hf_t38_fragment = -1;
+static int hf_t38_fragment_overlap = -1;
+static int hf_t38_fragment_overlap_conflicts = -1;
+static int hf_t38_fragment_multiple_tails = -1;
+static int hf_t38_fragment_too_long_fragment = -1;
+static int hf_t38_fragment_error = -1;
+static int hf_t38_fragment_count = -1;
+static int hf_t38_reassembled_in = -1;
+static int hf_t38_reassembled_length = -1;
+
+static gint ett_t38 = -1;
+#include "packet-t38-ett.c"
+static gint ett_t38_setup = -1;
+
+static gint ett_data_fragment = -1;
+static gint ett_data_fragments = -1;
+
+static expert_field ei_t38_malformed = EI_INIT;
+
+static gboolean primary_part = TRUE;
+static guint32 seq_number = 0;
+
+/* Tables for reassembly of Data fragments. */
+static reassembly_table data_reassembly_table;
+
+static const fragment_items data_frag_items = {
+ /* Fragment subtrees */
+ &ett_data_fragment,
+ &ett_data_fragments,
+ /* Fragment fields */
+ &hf_t38_fragments,
+ &hf_t38_fragment,
+ &hf_t38_fragment_overlap,
+ &hf_t38_fragment_overlap_conflicts,
+ &hf_t38_fragment_multiple_tails,
+ &hf_t38_fragment_too_long_fragment,
+ &hf_t38_fragment_error,
+ &hf_t38_fragment_count,
+ /* Reassembled in field */
+ &hf_t38_reassembled_in,
+ /* Reassembled length field */
+ &hf_t38_reassembled_length,
+ /* Reassembled data field */
+ NULL,
+ /* Tag */
+ "Data fragments"
+};
+
+typedef struct _fragment_key {
+ address src;
+ address dst;
+ guint32 id;
+} fragment_key;
+
+static conversation_t *p_conv= NULL;
+static t38_conv *p_t38_conv = NULL;
+static t38_conv *p_t38_packet_conv = NULL;
+static t38_conv_info *p_t38_conv_info = NULL;
+static t38_conv_info *p_t38_packet_conv_info = NULL;
+
+/* RTP Version is the first 2 bits of the first octet in the UDP payload*/
+#define RTP_VERSION(octet) ((octet) >> 6)
+
+void proto_reg_handoff_t38(void);
+
+static void show_setup_info(tvbuff_t *tvb, proto_tree *tree, t38_conv *p_t38_conv);
+/* Preferences bool to control whether or not setup info should be shown */
+static gboolean global_t38_show_setup_info = TRUE;
+
+/* Can tap up to 4 T38 packets within same packet */
+/* We only tap the primary part, not the redundancy */
+#define MAX_T38_MESSAGES_IN_PACKET 4
+static t38_packet_info t38_info_arr[MAX_T38_MESSAGES_IN_PACKET];
+static int t38_info_current=0;
+static t38_packet_info *t38_info=NULL;
+
+static void t38_defragment_init(void)
+{
+ /* Init reassembly table */
+ reassembly_table_init(&data_reassembly_table,
+ &addresses_reassembly_table_functions);
+}
+
+static void t38_defragment_cleanup(void)
+{
+ reassembly_table_destroy(&data_reassembly_table);
+}
+
+
+/* Set up an T38 conversation */
+void t38_add_address(packet_info *pinfo,
+ address *addr, int port,
+ int other_port,
+ const gchar *setup_method, guint32 setup_frame_number)
+{
+ address null_addr;
+ conversation_t* p_conversation;
+ t38_conv* p_conversation_data = NULL;
+
+ /*
+ * If this isn't the first time this packet has been processed,
+ * we've already done this work, so we don't need to do it
+ * again.
+ */
+ if ((pinfo->fd->flags.visited) || (t38_udp_handle == NULL))
+ {
+ return;
+ }
+
+ clear_address(&null_addr);
+
+ /*
+ * Check if the ip address and port combination is not
+ * already registered as a conversation.
+ */
+ p_conversation = find_conversation( setup_frame_number, addr, &null_addr, PT_UDP, port, other_port,
+ NO_ADDR_B | (!other_port ? NO_PORT_B : 0));
+
+ /*
+ * If not, create a new conversation.
+ */
+ if ( !p_conversation || p_conversation->setup_frame != setup_frame_number) {
+ p_conversation = conversation_new( setup_frame_number, addr, &null_addr, PT_UDP,
+ (guint32)port, (guint32)other_port,
+ NO_ADDR2 | (!other_port ? NO_PORT2 : 0));
+ }
+
+ /* Set dissector */
+ conversation_set_dissector(p_conversation, t38_udp_handle);
+
+ /*
+ * Check if the conversation has data associated with it.
+ */
+ p_conversation_data = (t38_conv*)conversation_get_proto_data(p_conversation, proto_t38);
+
+ /*
+ * If not, add a new data item.
+ */
+ if ( ! p_conversation_data ) {
+ /* Create conversation data */
+ p_conversation_data = wmem_new(wmem_file_scope(), t38_conv);
+
+ conversation_add_proto_data(p_conversation, proto_t38, p_conversation_data);
+ }
+
+ /*
+ * Update the conversation data.
+ */
+ g_strlcpy(p_conversation_data->setup_method, setup_method, MAX_T38_SETUP_METHOD_SIZE);
+ p_conversation_data->setup_frame_number = setup_frame_number;
+ p_conversation_data->src_t38_info.reass_ID = 0;
+ p_conversation_data->src_t38_info.reass_start_seqnum = -1;
+ p_conversation_data->src_t38_info.reass_data_type = 0;
+ p_conversation_data->src_t38_info.last_seqnum = -1;
+ p_conversation_data->src_t38_info.packet_lost = 0;
+ p_conversation_data->src_t38_info.burst_lost = 0;
+ p_conversation_data->src_t38_info.time_first_t4_data = 0;
+ p_conversation_data->src_t38_info.additional_hdlc_data_field_counter = 0;
+ p_conversation_data->src_t38_info.seqnum_prev_data_field = -1;
+
+ p_conversation_data->dst_t38_info.reass_ID = 0;
+ p_conversation_data->dst_t38_info.reass_start_seqnum = -1;
+ p_conversation_data->dst_t38_info.reass_data_type = 0;
+ p_conversation_data->dst_t38_info.last_seqnum = -1;
+ p_conversation_data->dst_t38_info.packet_lost = 0;
+ p_conversation_data->dst_t38_info.burst_lost = 0;
+ p_conversation_data->dst_t38_info.time_first_t4_data = 0;
+ p_conversation_data->dst_t38_info.additional_hdlc_data_field_counter = 0;
+ p_conversation_data->dst_t38_info.seqnum_prev_data_field = -1;
+}
+
+
+static fragment_head *
+force_reassemble_seq(reassembly_table *table, packet_info *pinfo, guint32 id)
+{
+ fragment_head *fd_head;
+ fragment_item *fd_i;
+ fragment_item *last_fd;
+ guint32 dfpos, size, packet_lost, burst_lost, seq_num;
+ guint8 *data;
+
+ fd_head = fragment_get(table, pinfo, id, NULL);
+
+ /* have we already seen this frame ?*/
+ if (pinfo->fd->flags.visited) {
+ if (fd_head != NULL && fd_head->flags & FD_DEFRAGMENTED) {
+ return fd_head;
+ } else {
+ return NULL;
+ }
+ }
+
+ if (fd_head==NULL){
+ /* we must have it to continue */
+ return NULL;
+ }
+
+ /* check for packet lost and count the burst of packet lost */
+ packet_lost = 0;
+ burst_lost = 0;
+ seq_num = 0;
+ for(fd_i=fd_head->next;fd_i;fd_i=fd_i->next) {
+ if (seq_num != fd_i->offset) {
+ packet_lost += fd_i->offset - seq_num;
+ if ( (fd_i->offset - seq_num) > burst_lost ) {
+ burst_lost = fd_i->offset - seq_num;
+ }
+ }
+ seq_num = fd_i->offset + 1;
+ }
+
+ /* we have received an entire packet, defragment it and
+ * free all fragments
+ */
+ size=0;
+ last_fd=NULL;
+ for(fd_i=fd_head->next;fd_i;fd_i=fd_i->next) {
+ if(!last_fd || last_fd->offset!=fd_i->offset){
+ size+=fd_i->len;
+ }
+ last_fd=fd_i;
+ }
+
+ data = (guint8 *) g_malloc(size);
+ fd_head->tvb_data = tvb_new_real_data(data, size, size);
+ fd_head->len = size; /* record size for caller */
+
+ /* add all data fragments */
+ dfpos = 0;
+ last_fd=NULL;
+ for (fd_i=fd_head->next;fd_i && fd_i->len + dfpos <= size;fd_i=fd_i->next) {
+ if (fd_i->len) {
+ if(!last_fd || last_fd->offset!=fd_i->offset){
+ tvb_memcpy(fd_i->tvb_data, data+dfpos, 0, fd_i->len);
+ dfpos += fd_i->len;
+ } else {
+ /* duplicate/retransmission/overlap */
+ fd_i->flags |= FD_OVERLAP;
+ fd_head->flags |= FD_OVERLAP;
+ if( (last_fd->len!=fd_i->len)
+ || tvb_memeql(last_fd->tvb_data, 0, tvb_get_ptr(fd_i->tvb_data, 0, last_fd->len), last_fd->len) ){
+ fd_i->flags |= FD_OVERLAPCONFLICT;
+ fd_head->flags |= FD_OVERLAPCONFLICT;
+ }
+ }
+ }
+ last_fd=fd_i;
+ }
+
+ /* we have defragmented the pdu, now free all fragments*/
+ for (fd_i=fd_head->next;fd_i;fd_i=fd_i->next) {
+ if(fd_i->tvb_data){
+ tvb_free(fd_i->tvb_data);
+ fd_i->tvb_data=NULL;
+ }
+ }
+
+ /* mark this packet as defragmented */
+ fd_head->flags |= FD_DEFRAGMENTED;
+ fd_head->reassembled_in=pinfo->num;
+
+ col_append_fstr(pinfo->cinfo, COL_INFO, " (t4-data Reassembled: %d pack lost, %d pack burst lost)", packet_lost, burst_lost);
+
+ p_t38_packet_conv_info->packet_lost = packet_lost;
+ p_t38_packet_conv_info->burst_lost = burst_lost;
+
+ return fd_head;
+}
+
+/* T38 Routines */
+#include "packet-t38-fn.c"
+
+/* initialize the tap t38_info and the conversation */
+static void
+init_t38_info_conv(packet_info *pinfo)
+{
+ /* tap info */
+ t38_info_current++;
+ if (t38_info_current==MAX_T38_MESSAGES_IN_PACKET) {
+ t38_info_current=0;
+ }
+ t38_info = &t38_info_arr[t38_info_current];
+
+ t38_info->seq_num = 0;
+ t38_info->type_msg = 0;
+ t38_info->data_value = 0;
+ t38_info->t30ind_value =0;
+ t38_info->setup_frame_number = 0;
+ t38_info->Data_Field_field_type_value = 0;
+ t38_info->desc[0] = '\0';
+ t38_info->desc_comment[0] = '\0';
+ t38_info->time_first_t4_data = 0;
+ t38_info->frame_num_first_t4_data = 0;
+
+
+ /*
+ p_t38_packet_conv hold the conversation info in each of the packets.
+ p_t38_conv hold the conversation info used to reassemble the HDLC packets, and also the Setup info (e.g SDP)
+ If we already have p_t38_packet_conv in the packet, it means we already reassembled the HDLC packets, so we don't
+ need to use p_t38_conv
+ */
+ p_t38_packet_conv = NULL;
+ p_t38_conv = NULL;
+
+ /* Use existing packet info if available */
+ p_t38_packet_conv = (t38_conv *)p_get_proto_data(wmem_file_scope(), pinfo, proto_t38, 0);
+
+
+ /* find the conversation used for Reassemble and Setup Info */
+ p_conv = find_conversation(pinfo->num, &pinfo->net_dst, &pinfo->net_src,
+ pinfo->ptype,
+ pinfo->destport, pinfo->srcport, NO_ADDR_B | NO_PORT_B);
+
+ /* create a conv if it doen't exist */
+ if (!p_conv) {
+ p_conv = conversation_new(pinfo->num, &pinfo->net_src, &pinfo->net_dst,
+ pinfo->ptype, pinfo->srcport, pinfo->destport, NO_ADDR_B | NO_PORT_B);
+
+ /* Set dissector */
+ conversation_set_dissector(p_conv, t38_udp_handle);
+ }
+
+ p_t38_conv = (t38_conv *)conversation_get_proto_data(p_conv, proto_t38);
+
+ /* create the conversation if it doesn't exist */
+ if (!p_t38_conv) {
+ p_t38_conv = wmem_new(wmem_file_scope(), t38_conv);
+ p_t38_conv->setup_method[0] = '\0';
+ p_t38_conv->setup_frame_number = 0;
+
+ p_t38_conv->src_t38_info.reass_ID = 0;
+ p_t38_conv->src_t38_info.reass_start_seqnum = -1;
+ p_t38_conv->src_t38_info.reass_data_type = 0;
+ p_t38_conv->src_t38_info.last_seqnum = -1;
+ p_t38_conv->src_t38_info.packet_lost = 0;
+ p_t38_conv->src_t38_info.burst_lost = 0;
+ p_t38_conv->src_t38_info.time_first_t4_data = 0;
+ p_t38_conv->src_t38_info.additional_hdlc_data_field_counter = 0;
+ p_t38_conv->src_t38_info.seqnum_prev_data_field = -1;
+
+ p_t38_conv->dst_t38_info.reass_ID = 0;
+ p_t38_conv->dst_t38_info.reass_start_seqnum = -1;
+ p_t38_conv->dst_t38_info.reass_data_type = 0;
+ p_t38_conv->dst_t38_info.last_seqnum = -1;
+ p_t38_conv->dst_t38_info.packet_lost = 0;
+ p_t38_conv->dst_t38_info.burst_lost = 0;
+ p_t38_conv->dst_t38_info.time_first_t4_data = 0;
+ p_t38_conv->dst_t38_info.additional_hdlc_data_field_counter = 0;
+ p_t38_conv->dst_t38_info.seqnum_prev_data_field = -1;
+
+ conversation_add_proto_data(p_conv, proto_t38, p_t38_conv);
+ }
+
+ if (!p_t38_packet_conv) {
+ /* copy the t38 conversation info to the packet t38 conversation */
+ p_t38_packet_conv = wmem_new(wmem_file_scope(), t38_conv);
+ g_strlcpy(p_t38_packet_conv->setup_method, p_t38_conv->setup_method, MAX_T38_SETUP_METHOD_SIZE);
+ p_t38_packet_conv->setup_frame_number = p_t38_conv->setup_frame_number;
+
+ memcpy(&(p_t38_packet_conv->src_t38_info), &(p_t38_conv->src_t38_info), sizeof(t38_conv_info));
+ memcpy(&(p_t38_packet_conv->dst_t38_info), &(p_t38_conv->dst_t38_info), sizeof(t38_conv_info));
+
+ p_add_proto_data(wmem_file_scope(), pinfo, proto_t38, 0, p_t38_packet_conv);
+ }
+
+ if (addresses_equal(&p_conv->key_ptr->addr1, &pinfo->net_src)) {
+ p_t38_conv_info = &(p_t38_conv->src_t38_info);
+ p_t38_packet_conv_info = &(p_t38_packet_conv->src_t38_info);
+ } else {
+ p_t38_conv_info = &(p_t38_conv->dst_t38_info);
+ p_t38_packet_conv_info = &(p_t38_packet_conv->dst_t38_info);
+ }
+
+ /* update t38_info */
+ t38_info->setup_frame_number = p_t38_packet_conv->setup_frame_number;
+}
+
+/* Entry point for dissection */
+static int
+dissect_t38_udp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
+{
+ guint8 octet1;
+ proto_item *it;
+ proto_tree *tr;
+ guint32 offset=0;
+
+ /*
+ * XXX - heuristic to check for misidentified packets.
+ */
+ if (dissect_possible_rtpv2_packets_as_rtp){
+ octet1 = tvb_get_guint8(tvb, offset);
+ if (RTP_VERSION(octet1) == 2){
+ return call_dissector(rtp_handle,tvb,pinfo,tree);
+ }
+ }
+
+ col_set_str(pinfo->cinfo, COL_PROTOCOL, "T.38");
+ col_clear(pinfo->cinfo, COL_INFO);
+
+ primary_part = TRUE;
+
+ /* This indicate the item number in the primary part of the T38 message, it is used for the reassemble of T30 packets */
+ Data_Field_item_num = 0;
+
+ it=proto_tree_add_protocol_format(tree, proto_t38, tvb, 0, -1, "ITU-T Recommendation T.38");
+ tr=proto_item_add_subtree(it, ett_t38);
+
+ /* init tap and conv info */
+ init_t38_info_conv(pinfo);
+
+ /* Show Conversation setup info if exists*/
+ if (global_t38_show_setup_info) {
+ show_setup_info(tvb, tr, p_t38_packet_conv);
+ }
+
+ col_append_str(pinfo->cinfo, COL_INFO, "UDP: UDPTLPacket ");
+
+ offset = dissect_UDPTLPacket_PDU(tvb, pinfo, tr, NULL);
+
+ if (tvb_reported_length_remaining(tvb,offset)>0){
+ proto_tree_add_expert_format(tr, pinfo, &ei_t38_malformed, tvb, offset, tvb_reported_length_remaining(tvb, offset),
+ "[MALFORMED PACKET or wrong preference settings]");
+ col_append_str(pinfo->cinfo, COL_INFO, " [Malformed?]");
+ }
+ return tvb_captured_length(tvb);
+}
+
+static int
+dissect_t38_tcp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
+{
+ proto_item *it;
+ proto_tree *tr;
+ guint32 offset=0;
+ tvbuff_t *next_tvb;
+ guint16 ifp_packet_number=1;
+
+ col_set_str(pinfo->cinfo, COL_PROTOCOL, "T.38");
+ col_clear(pinfo->cinfo, COL_INFO);
+
+ primary_part = TRUE;
+
+ /* This indicate the item number in the primary part of the T38 message, it is used for the reassemble of T30 packets */
+ Data_Field_item_num = 0;
+
+ it=proto_tree_add_protocol_format(tree, proto_t38, tvb, 0, -1, "ITU-T Recommendation T.38");
+ tr=proto_item_add_subtree(it, ett_t38);
+
+ /* init tap and conv info */
+ init_t38_info_conv(pinfo);
+
+ /* Show Conversation setup info if exists*/
+ if (global_t38_show_setup_info) {
+ show_setup_info(tvb, tr, p_t38_packet_conv);
+ }
+
+ col_append_str(pinfo->cinfo, COL_INFO, "TCP: IFPPacket");
+
+ while(tvb_reported_length_remaining(tvb,offset)>0)
+ {
+ next_tvb = tvb_new_subset_remaining(tvb, offset);
+ offset += dissect_IFPPacket_PDU(next_tvb, pinfo, tr, NULL);
+ ifp_packet_number++;
+
+ if(tvb_reported_length_remaining(tvb,offset)>0){
+ if(t38_tpkt_usage == T38_TPKT_ALWAYS){
+ proto_tree_add_expert_format(tr, pinfo, &ei_t38_malformed, tvb, offset, tvb_reported_length_remaining(tvb, offset),
+ "[MALFORMED PACKET or wrong preference settings]");
+ col_append_str(pinfo->cinfo, COL_INFO, " [Malformed?]");
+ break;
+ }else {
+ col_append_fstr(pinfo->cinfo, COL_INFO, " IFPPacket#%u",ifp_packet_number);
+ }
+ }
+ }
+
+ return tvb_captured_length(tvb);
+}
+
+static int
+dissect_t38_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
+{
+ primary_part = TRUE;
+
+ if(t38_tpkt_usage == T38_TPKT_ALWAYS){
+ dissect_tpkt_encap(tvb,pinfo,tree,t38_tpkt_reassembly,t38_tcp_pdu_handle);
+ }
+ else if((t38_tpkt_usage == T38_TPKT_NEVER) || (is_tpkt(tvb,1) == -1)){
+ dissect_t38_tcp_pdu(tvb, pinfo, tree, data);
+ }
+ else {
+ dissect_tpkt_encap(tvb,pinfo,tree,t38_tpkt_reassembly,t38_tcp_pdu_handle);
+ }
+ return tvb_captured_length(tvb);
+}
+
+/* Look for conversation info and display any setup info found */
+void
+show_setup_info(tvbuff_t *tvb, proto_tree *tree, t38_conv *p_t38_conversation)
+{
+ proto_tree *t38_setup_tree;
+ proto_item *ti;
+
+ if (!p_t38_conversation || p_t38_conversation->setup_frame_number == 0) {
+ /* there is no Setup info */
+ return;
+ }
+
+ ti = proto_tree_add_string_format(tree, hf_t38_setup, tvb, 0, 0,
+ "",
+ "Stream setup by %s (frame %u)",
+ p_t38_conversation->setup_method,
+ p_t38_conversation->setup_frame_number);
+ PROTO_ITEM_SET_GENERATED(ti);
+ t38_setup_tree = proto_item_add_subtree(ti, ett_t38_setup);
+ if (t38_setup_tree)
+ {
+ /* Add details into subtree */
+ proto_item* item = proto_tree_add_uint(t38_setup_tree, hf_t38_setup_frame,
+ tvb, 0, 0, p_t38_conversation->setup_frame_number);
+ PROTO_ITEM_SET_GENERATED(item);
+ item = proto_tree_add_string(t38_setup_tree, hf_t38_setup_method,
+ tvb, 0, 0, p_t38_conversation->setup_method);
+ PROTO_ITEM_SET_GENERATED(item);
+ }
+}
+
+
+
+/* Wireshark Protocol Registration */
+void
+proto_register_t38(void)
+{
+ static hf_register_info hf[] =
+ {
+#include "packet-t38-hfarr.c"
+ { &hf_t38_setup,
+ { "Stream setup", "t38.setup", FT_STRING, BASE_NONE,
+ NULL, 0x0, "Stream setup, method and frame number", HFILL }},
+ { &hf_t38_setup_frame,
+ { "Stream frame", "t38.setup-frame", FT_FRAMENUM, BASE_NONE,
+ NULL, 0x0, "Frame that set up this stream", HFILL }},
+ { &hf_t38_setup_method,
+ { "Stream Method", "t38.setup-method", FT_STRING, BASE_NONE,
+ NULL, 0x0, "Method used to set up this stream", HFILL }},
+ {&hf_t38_fragments,
+ {"Message fragments", "t38.fragments",
+ FT_NONE, BASE_NONE, NULL, 0x00, NULL, HFILL } },
+ {&hf_t38_fragment,
+ {"Message fragment", "t38.fragment",
+ FT_FRAMENUM, BASE_NONE, NULL, 0x00, NULL, HFILL } },
+ {&hf_t38_fragment_overlap,
+ {"Message fragment overlap", "t38.fragment.overlap",
+ FT_BOOLEAN, BASE_NONE, NULL, 0x0, NULL, HFILL } },
+ {&hf_t38_fragment_overlap_conflicts,
+ {"Message fragment overlapping with conflicting data",
+ "t38.fragment.overlap.conflicts",
+ FT_BOOLEAN, BASE_NONE, NULL, 0x0, NULL, HFILL } },
+ {&hf_t38_fragment_multiple_tails,
+ {"Message has multiple tail fragments",
+ "t38.fragment.multiple_tails",
+ FT_BOOLEAN, BASE_NONE, NULL, 0x0, NULL, HFILL } },
+ {&hf_t38_fragment_too_long_fragment,
+ {"Message fragment too long", "t38.fragment.too_long_fragment",
+ FT_BOOLEAN, BASE_NONE, NULL, 0x0, NULL, HFILL } },
+ {&hf_t38_fragment_error,
+ {"Message defragmentation error", "t38.fragment.error",
+ FT_FRAMENUM, BASE_NONE, NULL, 0x00, NULL, HFILL } },
+ {&hf_t38_fragment_count,
+ {"Message fragment count", "t38.fragment.count",
+ FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL } },
+ {&hf_t38_reassembled_in,
+ {"Reassembled in", "t38.reassembled.in",
+ FT_FRAMENUM, BASE_NONE, NULL, 0x00, NULL, HFILL } },
+ {&hf_t38_reassembled_length,
+ {"Reassembled T38 length", "t38.reassembled.length",
+ FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL } },
+ };
+
+ static gint *ett[] =
+ {
+ &ett_t38,
+#include "packet-t38-ettarr.c"
+ &ett_t38_setup,
+ &ett_data_fragment,
+ &ett_data_fragments
+ };
+
+ static ei_register_info ei[] = {
+ { &ei_t38_malformed, { "t38.malformed", PI_MALFORMED, PI_ERROR, "Malformed packet", EXPFILL }},
+ };
+
+ module_t *t38_module;
+ expert_module_t* expert_t38;
+
+ proto_t38 = proto_register_protocol("T.38", "T.38", "t38");
+ proto_register_field_array(proto_t38, hf, array_length(hf));
+ proto_register_subtree_array(ett, array_length(ett));
+ expert_t38 = expert_register_protocol(proto_t38);
+ expert_register_field_array(expert_t38, ei, array_length(ei));
+ register_dissector("t38_udp", dissect_t38_udp, proto_t38);
+
+ /* Init reassemble tables for HDLC */
+ register_init_routine(t38_defragment_init);
+ register_cleanup_routine(t38_defragment_cleanup);
+
+ t38_tap = register_tap("t38");
+
+ t38_module = prefs_register_protocol(proto_t38, proto_reg_handoff_t38);
+ prefs_register_bool_preference(t38_module, "use_pre_corrigendum_asn1_specification",
+ "Use the Pre-Corrigendum ASN.1 specification",
+ "Whether the T.38 dissector should decode using the Pre-Corrigendum T.38 "
+ "ASN.1 specification (1998).",
+ &use_pre_corrigendum_asn1_specification);
+ prefs_register_bool_preference(t38_module, "dissect_possible_rtpv2_packets_as_rtp",
+ "Dissect possible RTP version 2 packets with RTP dissector",
+ "Whether a UDP packet that looks like RTP version 2 packet will "
+ "be dissected as RTP packet or T.38 packet. If enabled there is a risk that T.38 UDPTL "
+ "packets with sequence number higher than 32767 may be dissected as RTP.",
+ &dissect_possible_rtpv2_packets_as_rtp);
+ prefs_register_obsolete_preference(t38_module, "tcp.port");
+ prefs_register_obsolete_preference(t38_module, "udp.port");
+ prefs_register_bool_preference(t38_module, "reassembly",
+ "Reassemble T.38 PDUs over TPKT over TCP",
+ "Whether the dissector should reassemble T.38 PDUs spanning multiple TCP segments "
+ "when TPKT is used over TCP. "
+ "To use this option, you must also enable \"Allow subdissectors to reassemble "
+ "TCP streams\" in the TCP protocol settings.",
+ &t38_tpkt_reassembly);
+ prefs_register_enum_preference(t38_module, "tpkt_usage",
+ "TPKT used over TCP",
+ "Whether T.38 is used with TPKT for TCP",
+ (gint *)&t38_tpkt_usage,t38_tpkt_options,FALSE);
+
+ prefs_register_bool_preference(t38_module, "show_setup_info",
+ "Show stream setup information",
+ "Where available, show which protocol and frame caused "
+ "this T.38 stream to be created",
+ &global_t38_show_setup_info);
+
+}
+
+void
+proto_reg_handoff_t38(void)
+{
+ static gboolean t38_prefs_initialized = FALSE;
+
+ if (!t38_prefs_initialized) {
+ t38_udp_handle=create_dissector_handle(dissect_t38_udp, proto_t38);
+ t38_tcp_handle=create_dissector_handle(dissect_t38_tcp, proto_t38);
+ t38_tcp_pdu_handle=create_dissector_handle(dissect_t38_tcp_pdu, proto_t38);
+ rtp_handle = find_dissector("rtp");
+ t30_hdlc_handle = find_dissector("t30.hdlc");
+ data_handle = find_dissector("data");
+ t38_prefs_initialized = TRUE;
+ }
+}
+
diff --git a/epan/dissectors/asn1/t38/packet-t38-template.h b/epan/dissectors/asn1/t38/packet-t38-template.h
new file mode 100644
index 0000000000..a2ef4b949b
--- /dev/null
+++ b/epan/dissectors/asn1/t38/packet-t38-template.h
@@ -0,0 +1,85 @@
+/* packet-t38.h
+ *
+ * Routines for T38 dissection
+ * 2003 Hans Viens
+ * 2004 Alejandro Vaquero, add support to conversation
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "ws_symbol_export.h"
+
+#define MAX_T38_DATA_ITEMS 4
+#define MAX_T38_DESC 128
+
+typedef struct _t38_packet_info {
+ guint16 seq_num; /* UDPTLPacket sequence number */
+ gint32 type_msg; /* 0=t30-indicator 1=data */
+ guint32 t30ind_value;
+ guint32 data_value; /* standard and speed */
+ guint32 setup_frame_number;
+ guint32 Data_Field_field_type_value;
+ guint8 t30_Facsimile_Control;
+ gchar desc[MAX_T38_DESC]; /* Description used to be displayed in the frame label Graph Anlaysis */
+ gchar desc_comment[MAX_T38_DESC]; /* Description used to be displayed in the Comment Graph Anlaysis */
+ double time_first_t4_data;
+ guint32 frame_num_first_t4_data;
+} t38_packet_info;
+
+
+#define MAX_T38_SETUP_METHOD_SIZE 7
+
+
+/* Info to save the State to reassemble Data (e.g. HDLC) and the Setup (e.g. SDP) in T38 conversations */
+typedef struct _t38_conv_info
+{
+
+ guint32 reass_ID;
+ int reass_start_seqnum;
+ guint32 reass_data_type;
+ gint32 last_seqnum; /* used to avoid duplicated seq num shown in the Graph Analysis */
+ guint32 packet_lost;
+ guint32 burst_lost;
+ double time_first_t4_data;
+ guint32 additional_hdlc_data_field_counter;
+ gint32 seqnum_prev_data_field;
+
+} t38_conv_info;
+
+/* Info to save the State to reassemble Data (e.g. HDLC) and the Setup (e.g. SDP) in T38 conversations */
+typedef struct _t38_conv
+{
+ gchar setup_method[MAX_T38_SETUP_METHOD_SIZE + 1];
+ guint32 setup_frame_number;
+ t38_conv_info src_t38_info;
+ t38_conv_info dst_t38_info;
+} t38_conv;
+
+/* Add an T38 conversation with the given details */
+WS_DLL_PUBLIC
+void t38_add_address(packet_info *pinfo,
+ address *addr, int port,
+ int other_port,
+ const gchar *setup_method, guint32 setup_frame_number);
+
+
+#include "packet-t38-exp.h"
+
+
+
diff --git a/epan/dissectors/asn1/t38/t38.cnf b/epan/dissectors/asn1/t38/t38.cnf
new file mode 100644
index 0000000000..db61672b71
--- /dev/null
+++ b/epan/dissectors/asn1/t38/t38.cnf
@@ -0,0 +1,261 @@
+# t38.cnf
+# T.38 conformation file
+# 2007 Tomas Kukosa
+
+#.EXPORTS ONLY_VALS WS_DLL
+Type-of-msg/t30-indicator
+Type-of-msg/t30-data
+#.END
+
+#.TYPE_RENAME
+Type-of-msg/t30-indicator T30_indicator
+Type-of-msg/t30-data T30_data
+#.END
+
+#.PDU
+IFPPacket
+UDPTLPacket
+#.END
+
+#.FN_PARS Type-of-msg VAL_PTR=&Type_of_msg_value
+#.FN_FTR Type-of-msg
+ /* info for tap */
+ if (primary_part)
+ t38_info->type_msg = Type_of_msg_value;
+#.END
+
+#.FN_PARS Type-of-msg/t30-indicator VAL_PTR=&T30ind_value
+#.FN_FTR Type-of-msg/t30-indicator
+ if (primary_part){
+ col_append_fstr(actx->pinfo->cinfo, COL_INFO, " t30ind: %s",
+ val_to_str(T30ind_value,t38_T30_indicator_vals,"<unknown>"));
+ }
+
+ /* info for tap */
+ if (primary_part)
+ t38_info->t30ind_value = T30ind_value;
+#.END
+
+#.FN_PARS Type-of-msg/t30-data VAL_PTR=&Data_value
+#.FN_FTR Type-of-msg/t30-data
+ if (primary_part){
+ col_append_fstr(actx->pinfo->cinfo, COL_INFO, " data:%s:",
+ val_to_str(Data_value,t38_T30_data_vals,"<unknown>"));
+ }
+
+
+ /* info for tap */
+ if (primary_part)
+ t38_info->data_value = Data_value;
+#.END
+
+#.FN_FTR Data-Field/_item
+ if (primary_part) Data_Field_item_num++;
+#.END
+
+#.FN_PARS Data-Field/_item/field-type
+EXT=(use_pre_corrigendum_asn1_specification)?FALSE:TRUE
+EXT_NUM=(use_pre_corrigendum_asn1_specification)?0:4
+VAL_PTR=&Data_Field_field_type_value
+#.FN_FTR Data-Field/_item/field-type
+ if (primary_part){
+ col_append_fstr(actx->pinfo->cinfo, COL_INFO, " %s",
+ val_to_str(Data_Field_field_type_value,t38_T_field_type_vals,"<unknown>"));
+ }
+
+ /* We only reassmeble packets in the Primary part and in the first two Items. */
+ /* There maybe be t38 packets with more than two Items, but reassemble those packets is not easy */
+ /* using the current ressaemble functions. */
+ /* TODO: reassemble all the Items in one frame */
+ if (primary_part && (Data_Field_item_num<2)) {
+ if (Data_Field_field_type_value == 2 || Data_Field_field_type_value == 4 || Data_Field_field_type_value == 7) {/* hdlc-fcs-OK or hdlc-fcs-OK-sig-end or t4-non-ecm-sig-end*/
+ fragment_head *frag_msg = NULL;
+ tvbuff_t* new_tvb = NULL;
+ gboolean save_fragmented = actx->pinfo->fragmented;
+
+ actx->pinfo->fragmented = TRUE;
+
+ /* if reass_start_seqnum=-1 it means we have received the end of the fragmente, without received any fragment data */
+ if (p_t38_packet_conv_info->reass_start_seqnum != -1) {
+ frag_msg = fragment_add_seq(&data_reassembly_table, /* reassembly table */
+ tvb, offset, actx->pinfo,
+ p_t38_packet_conv_info->reass_ID, /* ID for fragments belonging together */
+ NULL,
+ seq_number + Data_Field_item_num - (guint32)p_t38_packet_conv_info->reass_start_seqnum + (guint32)p_t38_packet_conv_info->additional_hdlc_data_field_counter, /* fragment sequence number */
+ /*0,*/
+ 0, /* fragment length */
+ FALSE, /* More fragments */
+ 0);
+ if ( Data_Field_field_type_value == 7 ) {
+ /* if there was packet lost or other errors during the defrag then frag_msg is NULL. This could also means
+ * there are out of order packets (e.g, got the tail frame t4-non-ecm-sig-end before the last fragment),
+ * but we will assume there was packet lost instead, which is more usual. So, we are going to reassemble the packet
+ * and get some stat, like packet lost and burst number of packet lost
+ */
+ if (!frag_msg) {
+ force_reassemble_seq(&data_reassembly_table, /* reassembly table */
+ actx->pinfo,
+ p_t38_packet_conv_info->reass_ID /* ID for fragments belonging together */
+ );
+ } else {
+ col_append_str(actx->pinfo->cinfo, COL_INFO, " (t4-data Reassembled: No packet lost)");
+
+ g_snprintf(t38_info->desc_comment, MAX_T38_DESC, "No packet lost");
+ }
+
+
+ if (p_t38_packet_conv_info->packet_lost) {
+ g_snprintf(t38_info->desc_comment, MAX_T38_DESC, " Pack lost: %d, Pack burst lost: %d", p_t38_packet_conv_info->packet_lost, p_t38_packet_conv_info->burst_lost);
+ } else {
+ g_snprintf(t38_info->desc_comment, MAX_T38_DESC, "No packet lost");
+ }
+
+ process_reassembled_data(tvb, offset, actx->pinfo,
+ "Reassembled T38", frag_msg, &data_frag_items, NULL, tree);
+
+ /* Now reset fragmentation information in pinfo */
+ actx->pinfo->fragmented = save_fragmented;
+
+ t38_info->time_first_t4_data = p_t38_packet_conv_info->time_first_t4_data;
+ t38_info->frame_num_first_t4_data = p_t38_packet_conv_info->reass_ID; /* The reass_ID is the Frame number of the first t4 fragment */
+
+ } else {
+ new_tvb = process_reassembled_data(tvb, offset, actx->pinfo,
+ "Reassembled T38", frag_msg, &data_frag_items, NULL, tree);
+
+ /* Now reset fragmentation information in pinfo */
+ actx->pinfo->fragmented = save_fragmented;
+
+ if (new_tvb) call_dissector_with_data((t30_hdlc_handle) ? t30_hdlc_handle : data_handle, new_tvb, actx->pinfo, tree, t38_info);
+ }
+ } else {
+ proto_tree_add_expert_format(tree, actx->pinfo, &ei_t38_malformed, tvb, offset, tvb_reported_length_remaining(tvb, offset),
+ "[RECEIVED END OF FRAGMENT W/OUT ANY FRAGMENT DATA]");
+ col_append_str(actx->pinfo->cinfo, COL_INFO, " [Malformed?]");
+ actx->pinfo->fragmented = save_fragmented;
+ }
+ }
+
+ /* reset the reassemble ID and the start seq number if it is not HDLC data */
+ if ( p_t38_conv && ( ((Data_Field_field_type_value >0) && (Data_Field_field_type_value <6)) || (Data_Field_field_type_value == 7) ) ){
+ p_t38_conv_info->reass_ID = 0;
+ p_t38_conv_info->reass_start_seqnum = -1;
+ p_t38_conv_info->additional_hdlc_data_field_counter = 0;
+ p_t38_conv_info->seqnum_prev_data_field = -1;
+ }
+ t38_info->Data_Field_field_type_value = Data_Field_field_type_value;
+ }
+#.END
+
+#.FN_BODY Data-Field/_item/field-data VAL_PTR=&value_tvb
+ tvbuff_t *value_tvb = NULL;
+ guint32 value_len;
+
+%(DEFAULT_BODY)s
+ value_len = tvb_reported_length(value_tvb);
+
+#.FN_FTR Data-Field/_item/field-data
+ if (primary_part){
+ if(value_len < 8){
+ col_append_fstr(actx->pinfo->cinfo, COL_INFO, "[%s]",
+ tvb_bytes_to_str(wmem_packet_scope(), value_tvb,0,value_len));
+ }
+ else {
+ col_append_fstr(actx->pinfo->cinfo, COL_INFO, "[%s...]",
+ tvb_bytes_to_str(wmem_packet_scope(), value_tvb,0,7));
+ }
+ }
+
+ /* We only reassmeble packets in the Primary part and in the first two Items. */
+ /* There maybe be t38 packets with more than two Items, but reassemble those packets is not easy */
+ /* using the current ressaemble functions. */
+ /* TODO: reassemble all the Items in one frame */
+ if (primary_part && (Data_Field_item_num<2)) {
+ fragment_head *frag_msg = NULL;
+
+ /* HDLC Data or t4-non-ecm-data */
+ if (Data_Field_field_type_value == 0 || Data_Field_field_type_value == 6) { /* 0=HDLC Data or 6=t4-non-ecm-data*/
+ gboolean save_fragmented = actx->pinfo->fragmented;
+
+ actx->pinfo->fragmented = TRUE;
+
+ /* if we have not reassembled this packet and it is the first fragment, reset the reassemble ID and the start seq number*/
+ if (p_t38_packet_conv && p_t38_conv && (p_t38_packet_conv_info->reass_ID == 0)) {
+ /* we use the first fragment's frame_number as fragment ID because the protocol doesn't provide it */
+ p_t38_conv_info->reass_ID = actx->pinfo->num;
+ p_t38_conv_info->reass_start_seqnum = seq_number;
+ p_t38_conv_info->time_first_t4_data = nstime_to_sec(&actx->pinfo->rel_ts);
+ p_t38_conv_info->additional_hdlc_data_field_counter = 0;
+ p_t38_packet_conv_info->reass_ID = p_t38_conv_info->reass_ID;
+ p_t38_packet_conv_info->reass_start_seqnum = p_t38_conv_info->reass_start_seqnum;
+ p_t38_packet_conv_info->seqnum_prev_data_field = p_t38_conv_info->seqnum_prev_data_field;
+ p_t38_packet_conv_info->additional_hdlc_data_field_counter = p_t38_conv_info->additional_hdlc_data_field_counter;
+ p_t38_packet_conv_info->time_first_t4_data = p_t38_conv_info->time_first_t4_data;
+ }
+ if (seq_number == (guint32)p_t38_packet_conv_info->seqnum_prev_data_field){
+ p_t38_packet_conv_info->additional_hdlc_data_field_counter ++;
+ if(p_t38_conv){
+ p_t38_conv_info->additional_hdlc_data_field_counter = p_t38_packet_conv_info->additional_hdlc_data_field_counter;
+ }
+ }
+ frag_msg = fragment_add_seq(&data_reassembly_table,
+ value_tvb, 0,
+ actx->pinfo,
+ p_t38_packet_conv_info->reass_ID, /* ID for fragments belonging together */
+ NULL,
+ seq_number - (guint32)p_t38_packet_conv_info->reass_start_seqnum + (guint32)p_t38_packet_conv_info->additional_hdlc_data_field_counter, /* fragment sequence number */
+ value_len, /* fragment length */
+ TRUE, /* More fragments */
+ 0);
+ p_t38_packet_conv_info->seqnum_prev_data_field = (gint32)seq_number;
+ process_reassembled_data(tvb, offset, actx->pinfo,
+ "Reassembled T38", frag_msg, &data_frag_items, NULL, tree);
+
+ if (!frag_msg) { /* Not last packet of reassembled */
+ if (Data_Field_field_type_value == 0) {
+ col_append_fstr(actx->pinfo->cinfo, COL_INFO," (HDLC fragment %u)",
+ seq_number + (guint32)p_t38_packet_conv_info->additional_hdlc_data_field_counter
+ - (guint32)p_t38_packet_conv_info->reass_start_seqnum);
+ } else {
+ col_append_fstr(actx->pinfo->cinfo, COL_INFO," (t4-data fragment %u)", seq_number - (guint32)p_t38_packet_conv_info->reass_start_seqnum);
+ }
+ }
+
+ /* Now reset fragmentation information in pinfo */
+ actx->pinfo->fragmented = save_fragmented;
+ }
+ }
+#.END
+
+
+#.FN_HDR UDPTLPacket
+ /* Initialize to something else than data type */
+ Data_Field_field_type_value = 1;
+#.END
+
+#.FN_PARS UDPTLPacket/seq-number VAL_PTR=&seq_number
+#.FN_FTR UDPTLPacket/seq-number
+ /* info for tap */
+ if (primary_part)
+ t38_info->seq_num = seq_number;
+
+ col_append_fstr(actx->pinfo->cinfo, COL_INFO, "Seq=%05u ",seq_number);
+#.END
+
+#.FN_HDR UDPTLPacket/primary-ifp-packet
+ primary_part = TRUE;
+#.FN_FTR UDPTLPacket/primary-ifp-packet
+ /* if is a valid t38 packet, add to tap */
+ /* Note that t4-non-ecm-sig-end without first_t4_data is not valid */
+ if (p_t38_packet_conv && (!actx->pinfo->flags.in_error_pkt) && ((gint32) seq_number != p_t38_packet_conv_info->last_seqnum) &&
+ !(t38_info->type_msg == 1 && t38_info->Data_Field_field_type_value == 7 && t38_info->frame_num_first_t4_data == 0))
+ tap_queue_packet(t38_tap, actx->pinfo, t38_info);
+
+ if (p_t38_conv) p_t38_conv_info->last_seqnum = (gint32) seq_number;
+#.END
+
+#.FN_HDR UDPTLPacket/error-recovery
+ primary_part = FALSE;
+#.FN_FTR UDPTLPacket/error-recovery
+ primary_part = TRUE;
+#.END