ANNOUNCEMENT: Live Wireshark University & Allegro Packets online APAC Wireshark Training Session
July 17th, 2024 | 10:00am-11:55am SGT (UTC+8) | Online

Ethereal-dev: [Ethereal-dev] T38 patch

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Alejandro Vaquero <alejandrovaquero@xxxxxxxxx>
Date: Sat, 14 Jan 2006 19:44:29 -0700
Hi All,
   find attached a couple of changes for t38:
- Use the dissector to reassemble t30 frames
- Dissect t30 protocol
- Move the "Fax t38 analysis" to the "VoIP Calls". Now when selecting "Statistics"->"Fax t38 analysis" option, there is a message that redirect the user to use the "Voip calls" instead. We may keep this option for one release, and then remove it ? - Added in the "Voip calls" the ability to detect a t38 call if there are not signaling associated with it. For example, when using "Decode as.." to dissect t38 packets, it is possible to use the "Voip calls" to analyze that call.
- Display "SDP (t38)" in the "Voip calls graph" for SDP t38 sessions.

Regards
Alejandro


Index: gtk/voip_calls_dlg.c
===================================================================
--- gtk/voip_calls_dlg.c	(revision 17031)
+++ gtk/voip_calls_dlg.c	(working copy)
@@ -196,6 +196,7 @@
 		remove_tap_listener_mgcp_calls();
 	}
 	remove_tap_listener_actrace_calls();
+	remove_tap_listener_t38();
 }
 
 /****************************************************************************/
@@ -338,6 +339,7 @@
 			case VOIP_MGCP:
 			case VOIP_AC_ISDN:
 			case VOIP_AC_CAS:
+			case MEDIA_T38:
 				/* XXX - not supported */
 				break;
 		}
@@ -774,6 +776,7 @@
 		mgcp_calls_init_tap();
 	}
 	actrace_calls_init_tap();
+	t38_init_tap();
 
 	/* create dialog box if necessary */
 	if (voip_calls_dlg == NULL) {
Index: gtk/voip_calls.c
===================================================================
--- gtk/voip_calls.c	(revision 17031)
+++ gtk/voip_calls.c	(working copy)
@@ -10,7 +10,7 @@
  * Copyright 2004, Iskratel, Ltd, Kranj
  * By Miha Jemec <m.jemec@xxxxxxxxxxx>
  * 
- * H323, RTP, RTP Event, MGCP, AudioCodes (ISDN PRI and CAS) and Graph Support
+ * H323, RTP, RTP Event, MGCP, AudioCodes (ISDN PRI and CAS), T38 and Graph Support
  * By Alejandro Vaquero, alejandro.vaquero@xxxxxxxxx
  * Copyright 2005, Verso Technologies Inc.
  *
@@ -57,6 +57,7 @@
 #include <epan/dissectors/packet-actrace.h>
 #include <epan/dissectors/packet-rtp.h>
 #include <epan/dissectors/packet-rtp-events.h>
+#include <epan/dissectors/packet-t38.h>
 #include <epan/conversation.h>
 #include <epan/rtp_pt.h>
 
@@ -74,13 +75,14 @@
 	};
 
 /* defines whether we can consider the call active */
-const char *voip_protocol_name[6]={
+const char *voip_protocol_name[7]={
 	"SIP",
 	"ISUP",
 	"H323",
 	"MGCP",
 	"AC_ISDN",
-	"AC_CAS"
+	"AC_CAS",
+	"T38"
 	};
 
 typedef struct {
@@ -101,7 +103,7 @@
 /****************************************************************************/
 /* the one and only global voip_calls_tapinfo_t structure */
 static voip_calls_tapinfo_t the_tapinfo_struct =
-	{0, NULL, 0, NULL, 0, 0, 0, 0, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+	{0, NULL, 0, NULL, 0, 0, 0, 0, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
 
 /* the one and only global voip_rtp_tapinfo_t structure */
 static voip_rtp_tapinfo_t the_tapinfo_rtp_struct =
@@ -192,7 +194,7 @@
 
 /****************************************************************************/
 /* Add a new item into the graph */
-static int add_to_graph(voip_calls_tapinfo_t *tapinfo _U_, packet_info *pinfo, const gchar *frame_label, gchar *comment, guint16 call_num, address *src_addr, address *dst_addr)
+static int add_to_graph(voip_calls_tapinfo_t *tapinfo _U_, packet_info *pinfo, const gchar *frame_label, gchar *comment, guint16 call_num, address *src_addr, address *dst_addr, guint16 line_style)
 {
 	graph_analysis_item_t *gai;
 
@@ -214,7 +216,7 @@
 	else
 		gai->comment = g_strdup("");
 	gai->conv_num=call_num;
-	gai->line_style=1;
+	gai->line_style=line_style;
 	gai->display=FALSE;
 
 	tapinfo->graph_analysis->list = g_list_append(tapinfo->graph_analysis->list, gai);
@@ -318,6 +320,57 @@
 	return items_changed;
 }
 
+
+
+
+/****************************************************************************/
+/* Insert the item in the graph list */
+void insert_to_graph(voip_calls_tapinfo_t *tapinfo _U_, packet_info *pinfo, const gchar *frame_label, gchar *comment, guint16 call_num, address *src_addr, address *dst_addr, guint16 line_style, double time, guint32 frame_num)
+{
+	graph_analysis_item_t *gai, *new_gai;
+	GList* list;
+	guint item_num;
+	gboolean inserted;
+
+	new_gai = g_malloc(sizeof(graph_analysis_item_t));
+	new_gai->frame_num = frame_num;
+	new_gai->time= time;
+	COPY_ADDRESS(&(new_gai->src_addr),src_addr);
+	COPY_ADDRESS(&(new_gai->dst_addr),dst_addr);
+
+	new_gai->port_src=pinfo->srcport;
+	new_gai->port_dst=pinfo->destport;
+	if (frame_label != NULL)
+		new_gai->frame_label = g_strdup(frame_label);
+	else
+		new_gai->frame_label = g_strdup("");
+
+	if (comment != NULL)
+		new_gai->comment = g_strdup(comment);
+	else
+		new_gai->comment = g_strdup("");
+	new_gai->conv_num=call_num;
+	new_gai->line_style=line_style;
+	new_gai->display=FALSE;
+
+	item_num = 0; 
+	inserted = FALSE;
+	list = g_list_first(tapinfo->graph_analysis->list);
+	while (list)
+	{
+		gai = list->data;
+		if (gai->frame_num > frame_num){
+			the_tapinfo_struct.graph_analysis->list = g_list_insert(the_tapinfo_struct.graph_analysis->list, new_gai, item_num);
+			inserted = TRUE;
+			break;
+		}
+		list = g_list_next (list);
+		item_num++;
+	}
+
+	if ( !inserted) tapinfo->graph_analysis->list = g_list_append(tapinfo->graph_analysis->list, new_gai);
+}
+
 /* XXX just copied from gtk/rpc_stat.c */
 void protect_thread_critical_region(void);
 void unprotect_thread_critical_region(void);
@@ -605,7 +658,175 @@
 	have_RTP_tap_listener=FALSE;
 }
 
+/* XXX just copied from gtk/rpc_stat.c */
+void protect_thread_critical_region(void);
+void unprotect_thread_critical_region(void);
+
 /****************************************************************************/
+/******************************TAP for T38 **********************************/
+/****************************************************************************/
+
+/****************************************************************************/
+/* whenever a T38 packet is seen by the tap listener */
+static int 
+T38_packet( void *ptr _U_, packet_info *pinfo, epan_dissect_t *edt _U_, const void *T38info)
+{
+	voip_calls_tapinfo_t *tapinfo = &the_tapinfo_struct;
+
+	voip_calls_info_t *strinfo = NULL;
+	voip_calls_info_t *tmp_listinfo;
+	GList* voip_calls_graph_list;
+	GList* list;
+	gchar *frame_label = NULL;
+	gchar *comment = NULL;
+	graph_analysis_item_t *gai, *tmp_gai;
+	guint16 line_style = 2;
+	double duration;
+	int conv_num = -1;
+
+	const t38_packet_info *pi = T38info;
+
+	if  (pi->setup_frame_number != 0) {
+		/* using the setup frame number of the T38 packet, we get the call number that it belongs */
+		voip_calls_graph_list = g_list_first(tapinfo->graph_analysis->list);
+		while (voip_calls_graph_list)
+		{			
+			tmp_gai = voip_calls_graph_list->data;
+			if (pi->setup_frame_number == tmp_gai->frame_num){
+				gai = tmp_gai;
+				break;
+			}
+			voip_calls_graph_list = g_list_next(voip_calls_graph_list);
+		}
+		if (gai) conv_num = (int) gai->conv_num;
+	}
+
+	/* if setup_frame_number in the t38 packet is 0, it means it was not set using an SDP or H245 sesion, which means we don't 
+	 * have the associated Voip calls. It probably means the the packet was decoded using the deafult t38 port, or using "Decode as.."
+	 * in this case we create a "voip" call that only have t38 media (no signaling)
+	 * OR if we have not found the Setup message in the graph. 
+	 */
+	if ( (pi->setup_frame_number == 0) || (gai == NULL) ){
+		/* check wether we already have a call with these parameters in the list */
+		list = g_list_first(tapinfo->strinfo_list);
+		while (list)
+		{
+			tmp_listinfo=list->data;
+			if (tmp_listinfo->protocol == MEDIA_T38){
+				strinfo = (voip_calls_info_t*)(list->data);
+				break;
+			}
+			list = g_list_next (list);
+		}
+
+		/* not in the list? then create a new entry */
+		if (strinfo==NULL){
+			strinfo = g_malloc(sizeof(voip_calls_info_t));
+			strinfo->call_active_state = VOIP_ACTIVE;
+			strinfo->call_state = VOIP_UNKNOWN;
+			strinfo->from_identity=g_strdup("T38 Media only");
+			strinfo->to_identity=g_strdup("T38 Media only");
+			COPY_ADDRESS(&(strinfo->initial_speaker),&(pinfo->src));
+			strinfo->first_frame_num=pinfo->fd->num;
+			strinfo->selected=FALSE;
+			strinfo->start_sec=pinfo->fd->rel_ts.secs;
+			strinfo->start_usec=pinfo->fd->rel_ts.nsecs/1000;
+			strinfo->protocol=MEDIA_T38;
+			strinfo->prot_info=NULL;
+			strinfo->npackets = 0;
+			strinfo->call_num = tapinfo->ncalls++;
+			tapinfo->strinfo_list = g_list_append(tapinfo->strinfo_list, strinfo);
+		}
+		++(strinfo->npackets);
+		/* increment the packets counter of all calls */
+		++(tapinfo->npackets);
+
+		conv_num = (int) strinfo->call_num;
+	}
+
+	/* at this point we should have found the call num for this t38 packets belong */
+	if (conv_num == -1) {
+		return 0;
+	}
+
+	/* add the item to the graph list */
+	if (pi->type_msg == 0) { /* 0=t30-indicator */
+		frame_label = g_strdup(val_to_str(pi->t30ind_value, t30_indicator_vals, "Ukn (0x%02X)") );
+		comment = g_strdup_printf("t38:t30 Ind:%s",val_to_str(pi->t30ind_value, t30_indicator_vals, "Ukn (0x%02X)") );
+		line_style = 1;
+	} else if (pi->type_msg == 1) {	/* 1=data */
+		switch(pi->Data_Field_field_type_value){
+			case 0: /* hdlc-data */
+				break;
+			case 2: /* hdlc-fcs-OK */
+			case 4: /* hdlc-fcs-OK-sig-end */
+					frame_label = g_strdup_printf("%s %s", val_to_str(pi->t30_Facsimile_Control & 0x7F, t30_facsimile_control_field_vals_short, "Ukn (0x%02X)"), pi->desc);
+					comment = g_strdup_printf("t38:%s:HDLC:%s",val_to_str(pi->data_value, t30_data_vals, "Ukn (0x%02X)"), val_to_str(pi->t30_Facsimile_Control & 0x7F, t30_facsimile_control_field_vals, "Ukn (0x%02X)"));
+				break;
+			case 3: /* hdlc-fcs-BAD */
+			case 5: /* hdlc-fcs-BAD-sig-end */
+				frame_label = g_strdup(pi->Data_Field_field_type_value == 3 ? "fcs-BAD" : "fcs-BAD-sig-end");
+				comment = g_strdup_printf("WARNING: received t38:%s:HDLC:%s", val_to_str(pi->data_value, t30_data_vals, "Ukn (0x%02X)"), pi->Data_Field_field_type_value == 3 ? "fcs-BAD" : "fcs-BAD-sig-end");
+				break;
+			case 7: /* t4-non-ecm-sig-end */
+				duration = nstime_to_sec(&pinfo->fd->rel_ts) - pi->time_first_t4_data;
+				frame_label = g_strdup_printf("t4-non-ecm-data:%s",val_to_str(pi->data_value, t30_data_vals, "Ukn (0x%02X)") );
+				comment = g_strdup_printf("t38:t4-non-ecm-data:%s Duration: %.2fs %s",val_to_str(pi->data_value, t30_data_vals, "Ukn (0x%02X)"), duration, pi->desc_comment );
+				insert_to_graph(tapinfo, pinfo, frame_label, comment, (guint16)conv_num, &(pinfo->src), &(pinfo->dst), line_style, pi->time_first_t4_data, pi->frame_num_first_t4_data);
+				break;
+		}
+	}
+
+	if (frame_label && !(pi->Data_Field_field_type_value == 7 && pi->type_msg == 1)) {
+		add_to_graph(tapinfo, pinfo, frame_label, comment, (guint16)conv_num, &(pinfo->src), &(pinfo->dst), line_style);
+	}
+
+	g_free(comment);
+	g_free(frame_label);
+	
+	tapinfo->redraw = TRUE;
+
+	return 1;  /* refresh output */
+}
+
+static gboolean have_T38_tap_listener=FALSE;
+/****************************************************************************/
+void
+t38_init_tap(void)
+{
+	GString *error_string;
+
+	if(have_T38_tap_listener==FALSE)
+	{
+		/* don't register tap listener, if we have it already */
+		error_string = register_tap_listener("t38", &(the_tapinfo_struct.t38_dummy), NULL,
+			voip_calls_dlg_reset, 
+			T38_packet, 
+			voip_calls_dlg_draw
+			);
+		if (error_string != NULL) {
+			simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
+				      error_string->str);
+			g_string_free(error_string, TRUE);
+			exit(1);
+		}
+		have_T38_tap_listener=TRUE;
+	}
+}
+
+/****************************************************************************/
+void
+remove_tap_listener_t38(void)
+{
+	protect_thread_critical_region();
+	remove_tap_listener(&(the_tapinfo_struct.t38_dummy));
+	unprotect_thread_critical_region();
+
+	have_T38_tap_listener=FALSE;
+}
+
+
+/****************************************************************************/
 static gchar *sdp_summary = NULL;
 static guint32 sdp_frame_num = 0;
 
@@ -736,7 +957,7 @@
 		++(tapinfo->npackets);
 
 		/* add to the graph */
-		add_to_graph(tapinfo, pinfo, frame_label, comment, strinfo->call_num, &(pinfo->src), &(pinfo->dst));  
+		add_to_graph(tapinfo, pinfo, frame_label, comment, strinfo->call_num, &(pinfo->src), &(pinfo->dst), 1);  
 		g_free(comment);
 		g_free(frame_label);
 		g_free((void *)tmp_src.data);
@@ -791,12 +1012,6 @@
 	}
 }
 
-
-
-/* XXX just copied from gtk/rpc_stat.c */
-void protect_thread_critical_region(void);
-void unprotect_thread_critical_region(void);
-
 /****************************************************************************/
 void
 remove_tap_listener_sip_calls(void)
@@ -988,7 +1203,7 @@
 		++(tapinfo->npackets);
 
 		/* add to the graph */
-		add_to_graph(tapinfo, pinfo, frame_label, comment, strinfo->call_num, &(pinfo->src), &(pinfo->dst));  
+		add_to_graph(tapinfo, pinfo, frame_label, comment, strinfo->call_num, &(pinfo->src), &(pinfo->dst), 1);  
 		g_free(comment);
 		g_free(frame_label);
 	}
@@ -1273,7 +1488,7 @@
 					/* if the frame number exists in graph, append to it*/
 					if (!append_to_frame_graph(tapinfo, q931_frame_num, "", comment)) {
 						/* if not exist, add to the graph */
-						add_to_graph(tapinfo, pinfo, "", comment, tmp_listinfo->call_num, &(pinfo->src), &(pinfo->dst));
+						add_to_graph(tapinfo, pinfo, "", comment, tmp_listinfo->call_num, &(pinfo->src), &(pinfo->dst), 1);
 						++(tmp_listinfo->npackets);
 						/* increment the packets counter of all calls */
 						++(tapinfo->npackets);
@@ -1376,7 +1591,8 @@
 
 		add_to_graph(tapinfo, pinfo, val_to_str(pi->message_type, q931_message_type_vals, "<unknown>") , comment, strinfo->call_num, 
 				actrace_direction?&pstn_add:&(pinfo->src),
-				actrace_direction?&(pinfo->src):&pstn_add);
+				actrace_direction?&(pinfo->src):&pstn_add,
+				1 );
 
 		g_free(comment);
 		g_free((char *)pstn_add.data);
@@ -1643,7 +1859,7 @@
 	/* if the frame number exists in graph, append to it*/
 	if (!append_to_frame_graph(tapinfo, pinfo->fd->num, pi->frame_label, comment)) {
 		/* if not exist, add to the graph */
-		add_to_graph(tapinfo, pinfo, frame_label, comment, strinfo->call_num, &(pinfo->src), &(pinfo->dst));
+		add_to_graph(tapinfo, pinfo, frame_label, comment, strinfo->call_num, &(pinfo->src), &(pinfo->dst), 1);
 		g_free((void *)tmp_src.data);
 		g_free((void *)tmp_dst.data);
 	}
@@ -1818,7 +2034,7 @@
 		/* if the frame number exists in graph, append to it*/
 		if (!append_to_frame_graph(tapinfo, pinfo->fd->num, frame_label, comment)) {
 			/* if not exist, add to the graph */
-			add_to_graph(tapinfo, pinfo, frame_label, comment, strinfo->call_num, &(pinfo->src), &(pinfo->dst));
+			add_to_graph(tapinfo, pinfo, frame_label, comment, strinfo->call_num, &(pinfo->src), &(pinfo->dst), 1);
 		}
 		g_free(frame_label);
 		g_free(comment);
@@ -2186,8 +2402,8 @@
 			frame_label = g_strdup_printf("%s ObsEvt:%s",pi->code, pi->observedEvents);
 
 			if (tmp_mgcpinfo->fromEndpoint){
-				/* use the Dialed digits to fill the "To" for the call */
-				mgcpDialedDigits(pi->observedEvents, &(strinfo->to_identity));
+				/* use the Dialed digits to fill the "To" for the call, but use the first NTFY */
+				if (strinfo->to_identity[0] == '\0') mgcpDialedDigits(pi->observedEvents, &(strinfo->to_identity));
 
 			/* from MGC and the user picked up, the call is connected */
 			} else if (isSignal("hd", pi->observedEvents))  
@@ -2259,7 +2475,7 @@
 	++(tapinfo->npackets);
 
 	/* add to the graph */
-	add_to_graph(tapinfo, pinfo, frame_label, comment, strinfo->call_num, &(pinfo->src), &(pinfo->dst));  
+	add_to_graph(tapinfo, pinfo, frame_label, comment, strinfo->call_num, &(pinfo->src), &(pinfo->dst), 1);  
 	g_free(comment);
 	g_free(frame_label);
 
@@ -2399,7 +2615,8 @@
 
 		add_to_graph(tapinfo, pinfo, pi->cas_frame_label , comment, strinfo->call_num, 
 				actrace_direction?&pstn_add:&(pinfo->src),
-				actrace_direction?&(pinfo->src):&pstn_add);
+				actrace_direction?&(pinfo->src):&pstn_add,
+				1 );
 
 		g_free(comment);
 		g_free((char *)pstn_add.data);
Index: gtk/voip_calls.h
===================================================================
--- gtk/voip_calls.h	(revision 17031)
+++ gtk/voip_calls.h	(working copy)
@@ -65,10 +65,11 @@
 		VOIP_H323,
 		VOIP_MGCP,
 		VOIP_AC_ISDN,
-		VOIP_AC_CAS
+		VOIP_AC_CAS,
+		MEDIA_T38
 } voip_protocol;
 
-extern const char *voip_protocol_name[6];
+extern const char *voip_protocol_name[7];
 
 /* defines specific SIP data */
 
@@ -174,6 +175,7 @@
 	int q931_dummy;
 	int mgcp_dummy;
 	int actrace_dummy;
+	int t38_dummy;
 } voip_calls_tapinfo_t;
 
 
@@ -229,6 +231,7 @@
 void rtp_event_init_tap(void);
 void mgcp_calls_init_tap(void);
 void actrace_calls_init_tap(void);
+void t38_init_tap(void);
 
 /*
 * Removes the voip_calls tap listener (if not already done)
@@ -245,6 +248,7 @@
 void remove_tap_listener_rtp_event(void);
 void remove_tap_listener_mgcp_calls(void);
 void remove_tap_listener_actrace_calls(void);
+void remove_tap_listener_t38(void);
 
 /*
 * Retrieves a constant reference to the unique info structure of the voip_calls tap listener.
Index: gtk/t38_analysis.c
===================================================================
--- gtk/t38_analysis.c	(revision 17031)
+++ gtk/t38_analysis.c	(working copy)
@@ -50,677 +50,16 @@
 #include "graph_analysis.h"
 #include "gui_stat_menu.h"
 
-#define MAX_HDLC_FRAME 1024
 
-typedef enum {
-	UNKNOWN,
-    CORRECT, 
-    EARLY,	/* seq_num > than expected, we assume all previous as lost */
-    LATE    /* seq_num < than expected, late packet we drop it */
-} SEQ_STATUS;
 
-typedef struct _tap_t38_stat_t {
-	gboolean first_packet;
-	gint32 seq_num;	/* UDPTLPacket sequence number */
-	gint32 wrong_seq_num;	/* count UDPTLPacket wron sequence number */
-	guint8 hdlc_data[MAX_HDLC_FRAME];  /* V21 HDLC data */
-	guint16 hdlc_data_index;			/* V21 HDLC index */
-	gboolean valid_hdlc_data;
-	guint32 other_data_num_bytes;		/* num of bytes of other data (non hdlc) */
-	guint32 other_data_lost;		/* num of packet lost (wrong seq num) of other data (non hdlc) */
-	guint32 other_data_max_burst_lost;	/* max burst num of packet lost (wrong seq num) of other data (non hdlc) */
-	guint32 other_data_burst_lost;	/* burst num of packet lost (wrong seq num) of other data (non hdlc) */
-	gint32 start_frame_other_data; /* start frame of other_data */
-	double start_time_other_data; /* start time of other_data */
-	SEQ_STATUS prev_seq_status;   /*previous seq num status used to calclate the busrt error */
-
-} tap_t38_stat_t;
-
-/* structure that holds general information about the connection 
-* and structures for both directions */
-typedef struct _user_data_t {
-	/* tap associated data*/
-	address ip_src_fwd;
-	guint16 port_src_fwd;
-	address ip_dst_fwd;
-	guint16 port_dst_fwd;
-	address ip_src_rev;
-	guint16 port_src_rev;
-	address ip_dst_rev;
-	guint16 port_dst_rev;
-
-	tap_t38_stat_t forward;
-	tap_t38_stat_t reverse;
-
-	graph_analysis_data_t *graph_analysis_data;
-} user_data_t;
-
-
-
-
-
 /****************************************************************************/
-/* Add a new item into the graph */
-int add_to_graph_t38(user_data_t *user_data, packet_info *pinfo, const gchar *frame_label, gchar *comment, gint line_style)
-{
-	graph_analysis_item_t *gai;
-
-	gai = g_malloc(sizeof(graph_analysis_item_t));
-	gai->frame_num = pinfo->fd->num;
-	gai->time= nstime_to_sec(&pinfo->fd->rel_ts);
-	COPY_ADDRESS(&(gai->src_addr),&(pinfo->src));
-	COPY_ADDRESS(&(gai->dst_addr),&(pinfo->dst));
-
-	gai->port_src=pinfo->srcport;
-	gai->port_dst=pinfo->destport;
-	if (frame_label != NULL)
-		gai->frame_label = g_strdup(frame_label);
-	else
-		gai->frame_label = g_strdup("");
-
-	if (comment != NULL)
-		gai->comment = g_strdup(comment);
-	else
-		gai->comment = g_strdup("");
-	gai->conv_num=1;
-	gai->line_style=line_style; /* 1=single line   2=dual line */
-	gai->display=TRUE;
-
-	user_data->graph_analysis_data->graph_info->list = g_list_append(user_data->graph_analysis_data->graph_info->list, gai);
-
-	return 1;
-}
-
-/****************************************************************************/
-/* Change the frame_label and comment in a graph item if not NULL*/
-/* return 0 if the frame_num is not in the graph list */
-int change_frame_graph_t38(user_data_t *user_data, gint32 frame_num, const gchar *new_frame_label, const gchar *new_comment)
-{
-	graph_analysis_item_t *gai;
-	GList* list;
-	gchar *tmp_str = NULL;
-	gchar *tmp_str2 = NULL;
-
-	if (frame_num == -1) return 0;
-
-	list = g_list_first(user_data->graph_analysis_data->graph_info->list);
-	while (list)
-	{
-		gai = list->data;
-		if (gai->frame_num == (guint32) frame_num){
-			tmp_str = gai->frame_label;
-			tmp_str2 = gai->comment;
-
-			if (new_frame_label != NULL){
-				gai->frame_label = g_strdup(new_frame_label);
-				g_free(tmp_str);
-			}
-
-			if (new_comment != NULL){
-				gai->comment = g_strdup(new_comment);
-				g_free(tmp_str2);
-			}
-			break;
-		}
-		list = g_list_next (list);
-	}
-	if (tmp_str == NULL) return 0;		/* it is not in the list */
-	return 1;
-}
-
-/* TODO: Dissect the complete t30 HDLC packets */
-#if 0
-#define MAX_DESC 1024 
-void dissect_t30_DIS_DTC(guint8 *data, guint len)
-{
-	guint8 octet;
-	int offset;
-	gchar  buf[MAX_DESC];
-
-	offset = 3;
-
-	if (len == 0)
-		return;
-	octet = data[offset];
-
-	g_snprintf(buf, MAX_DESC, "%sStore and forward Internet fax- Simple mode (ITU-T T.37)", octet&0x80?"":"No ");
-
-	g_snprintf(buf, MAX_DESC, "%sReal-time Internet fax (ITU T T.38)", octet&0x20?"":"No ");
-
-	g_snprintf(buf, MAX_DESC, "%s3rd Generation Mobile Network ", octet&0x10?"":"No ")
-}
-#endif
-
-/****************************************************************************/
-static const value_string t30_facsimile_control_field_vals_short[] = {
-	{ 0x01, "DIS" },
-	{ 0x02, "CSI" },
-	{ 0x04, "NSF" },
-	{ 0x81, "DTC" },
-	{ 0x82, "CIG" },
-	{ 0x84, "NSC" },
-	{ 0x83, "PWD" },
-	{ 0x85, "SEP" },
-	{ 0x86, "PSA" },
-	{ 0x87, "CIA" },
-	{ 0x88, "ISP" },
-	{ 0x41, "DCS" },
-	{ 0x42, "TSI" },
-	{ 0x44, "NSS" },
-	{ 0x43, "SUB" },
-	{ 0x45, "SID" },
-	{ 0x46, "TSA" },
-	{ 0x47, "IRA" },
-	{ 0x21, "CFR" },
-	{ 0x22, "FTT" },
-	{ 0x24, "CSA" },
-	{ 0x71, "EOM" },
-	{ 0x72, "MPS" },
-	{ 0x74, "EOP" },
-	{ 0x79, "PRI-EOM" },
-	{ 0x7A, "PRI-MPS" },
-	{ 0x7C, "PRI-EOP" },
-	{ 0x78, "PRI-EOP" },
-	{ 0x31, "MCF" },
-	{ 0x33, "RTP" },
-	{ 0x32, "RTN" },
-	{ 0x35, "PIP" },
-	{ 0x34, "PIN" },
-	{ 0x3F, "FDM" },
-	{ 0x5F, "DCN" },
-	{ 0x58, "CRP" },
-	{ 0x53, "FNV" },
-	{ 0x57, "TNR" },
-	{ 0x56, "TR" },
-	{ 0, NULL }
-};
-
-static const value_string t30_facsimile_control_field_vals[] = {
-	{ 0x01, "Digital Identification Signal" },
-	{ 0x02, "Called Subscriber Identification" },
-	{ 0x04, "Non-Standard Facilities" },
-	{ 0x81, "Digital Transmit Command" },
-	{ 0x82, "Calling Subscriber Identification" },
-	{ 0x84, "Non-Standard facilities Command" },
-	{ 0x83, "Password" },
-	{ 0x85, "Selective Polling" },
-	{ 0x86, "Polled Subaddress" },
-	{ 0x87, "Calling subscriber Internet Address" },
-	{ 0x88, "Internet Selective Polling Address" },
-	{ 0x41, "Digital Command Signal" },
-	{ 0x42, "Transmitting Subscriber Identification" },
-	{ 0x44, "Non-Standard facilities Set-up" },
-	{ 0x43, "Subaddress" },
-	{ 0x45, "Sender Identification" },
-	{ 0x46, "Transmitting Subscriber Internet address" },
-	{ 0x47, "Internet Routing Address" },
-	{ 0x21, "Confirmation To Receive" },
-	{ 0x22, "Failure To Train" },
-	{ 0x24, "Called Subscriber Internet Address" },
-	{ 0x71, "End Of Message" },
-	{ 0x72, "MultiPage Signal" },
-	{ 0x74, "End Of Procedure" },
-	{ 0x79, "Procedure Interrupt-End Of Message" },
-	{ 0x7A, "Procedure Interrupt-MultiPage Signal" },
-	{ 0x7C, "Procedure Interrupt-End Of Procedure" },
-	{ 0x78, "Procedure Interrupt-End Of Procedure" },
-	{ 0x31, "Message Confirmation" },
-	{ 0x33, "Retrain Positive" },
-	{ 0x32, "Retrain Negative" },
-	{ 0x35, "Procedure Interrupt Positive" },
-	{ 0x34, "Procedure Interrupt Negative" },
-	{ 0x3F, "File Diagnostics Message" },
-	{ 0x5F, "Disconnect" },
-	{ 0x58, "Command Repeat" },
-	{ 0x53, "Field Not Valid" },
-	{ 0x57, "Transmit not ready" },
-	{ 0x56, "Transmit ready" },
-	{ 0, NULL }
-};
-
-static const value_string data_vals[] = {
-	{ 0, "v21" },
-	{ 1, "v27-2400" },
-	{ 2, "v27-4800" },
-	{ 3, "v29-7200" },
-	{ 4, "v29-9600" },
-	{ 5, "v17-7200" },
-	{ 6, "v17-9600" },
-	{ 7, "v17-12000" },
-	{ 8, "v17-14400" },
-	{ 9, "v8" },
-	{ 10, "v34-pri-rate" },
-	{ 11, "v34-CC-1200" },
-	{ 12, "v34-pri-ch" },
-	{ 13, "v33-12000" },
-	{ 14, "v33-14400" },
-	{ 0, NULL }
-};
-
-void dissect_t30(tap_t38_stat_t *statinfo,
- 							  user_data_t *user_data _U_,
-                              packet_info *pinfo,
-							  guint32 data_value
-)
-{
-	gchar *frame_label = NULL;
-	gchar *comment = NULL;
-	guint8 octet;
-
-	octet = statinfo->hdlc_data[2];
-
-/* TODO: Dissect the complete t30 HDLC packets */
-#if 0
-	/* Facsimile Control Field (FCF) */
-	if ( ((octet&0xF0) == 0x00) || ((octet&0xF0) == 0x80) ) { /* Initial identification  or Command to send */
-		frame_label = g_strdup_printf("%s:hdlc:%s", val_to_str(data_value, data_vals, "Ukn (0x%02X)"), val_to_str(octet, t30_facsimile_control_field_vals_short, "Ukn (0x%02X)"));
-		comment = g_strdup_printf("%s:HDLC:%s",val_to_str(data_value, data_vals, "Ukn (0x%02X)"), val_to_str(octet, t30_facsimile_control_field_vals, "Ukn (0x%02X)"));
-		if ( (octet == 0x01) || (octet == 0x81) ) {
-			dissect_t30_DIS_DTC(statinfo->hdlc_data, statinfo->hdlc_data_index);
-		}
-	} else { /* all other values */
-		frame_label = g_strdup_printf("%s:hdlc:%s", val_to_str(data_value, data_vals, "Ukn (0x%02X)"), val_to_str(octet&0x7F, t30_facsimile_control_field_vals_short, "Ukn (0x%02X)"));
-		comment = g_strdup_printf("%s:HDLC:%s",val_to_str(data_value, data_vals, "Ukn (0x%02X)"), val_to_str(octet&0x7F, t30_facsimile_control_field_vals, "Ukn (0x%02X)"));
-	}
-#else
-	frame_label = g_strdup_printf("%s:hdlc:%s", val_to_str(data_value, data_vals, "Ukn (0x%02X)"), val_to_str(octet&0x7F, t30_facsimile_control_field_vals_short, "Ukn (0x%02X)"));
-	comment = g_strdup_printf("%s:HDLC:%s",val_to_str(data_value, data_vals, "Ukn (0x%02X)"), val_to_str(octet&0x7F, t30_facsimile_control_field_vals, "Ukn (0x%02X)"));
-#endif
-	add_to_graph_t38(user_data, pinfo, frame_label, comment, 2);
-}
-
-/****************************************************************************/
-int t38_packet_analyse(tap_t38_stat_t *statinfo,
-							  user_data_t *user_data _U_,
-                              packet_info *pinfo,
-                              const t38_packet_info *t38_info)
-{
-	gchar *frame_label = NULL;
-	gchar *comment = NULL;
-	SEQ_STATUS seq_status = UNKNOWN;
-	
-	/* if it is duplicated, just return */
-	if (statinfo->seq_num == t38_info->seq_num) return 0;
-
-	/* if it is the correct seq or first packet */
-	if ( (statinfo->seq_num+1 == t38_info->seq_num) || (statinfo->seq_num == -1) ) seq_status = CORRECT;
-
-	/* EARLY: seq_num > than expexted */
-	else if (t38_info->seq_num > statinfo->seq_num+1 ) seq_status = EARLY;
-
-	/* LATE: seq_num < than expexted */
-	else if (t38_info->seq_num < statinfo->seq_num+1 ) seq_status = LATE;
-
-		
-	if (t38_info->type_msg == 0) {	/*  t30-indicator */
-		frame_label = g_strdup_printf("t30 Ind:%s",val_to_str(t38_info->t30ind_value, t30_indicator_vals, "Ukn (0x%02X)") );
-		comment = g_strdup_printf("t30 Ind:%s",val_to_str(t38_info->t30ind_value, t30_indicator_vals, "Ukn (0x%02X)") );
-		add_to_graph_t38(user_data, pinfo, frame_label, comment, 1);
-
-		/* reset other_data stats in case we never got the previos t4-non-ecm-sig-end */
-		statinfo->other_data_num_bytes = 0;
-		statinfo->other_data_lost = 0;
-		statinfo->start_frame_other_data = -1;
-		statinfo->prev_seq_status = CORRECT;
-		statinfo->other_data_max_burst_lost = 0;
-		statinfo->other_data_burst_lost = 0;
-		statinfo->start_time_other_data = 0;
-	} else if (t38_info->type_msg == 1) {	/*  data */
-		int i;
-		for (i=0; i<t38_info->t38_info_data_item_index; i++) {
-			switch(t38_info->data_type[i]){
-			case 0: /* hdlc-data */
-				/* if it is hdlc-data add it to the array */
-				/* check we'll not excede the array */
-				if (statinfo->hdlc_data_index+t38_info->data_len[i] < MAX_HDLC_FRAME) {
-					g_memmove(&statinfo->hdlc_data[statinfo->hdlc_data_index], t38_info->data[i],t38_info->data_len[i]);
-					statinfo->hdlc_data_index += t38_info->data_len[i];
-				}
-				if (seq_status != CORRECT) statinfo->valid_hdlc_data = FALSE;
-				break;
-			case 2: /* hdlc-fcs-OK */
-			case 4: /* hdlc-fcs-OK-sig-end */
-				if (statinfo->valid_hdlc_data)
-					dissect_t30(statinfo, user_data, pinfo, t38_info->data_value);
-				else {
-					frame_label = g_strdup_printf("%s:hdlc:not decoded",val_to_str(t38_info->data_value, data_vals, "Ukn (0x%02X)"));
-					comment = g_strdup_printf("%s:HDLC:ERROR: wrong seq number in HDLC packet(s)",val_to_str(t38_info->data_value, data_vals, "Ukn (0x%02X)"));
-					add_to_graph_t38(user_data, pinfo, frame_label, comment, 2);
-				}
-				statinfo->hdlc_data_index = 0;
-				statinfo->valid_hdlc_data = TRUE;
-				break;
-			case 1: /* hdlc-sig-end */
-				if (statinfo->hdlc_data_index != 0) { /* if there was no fcs-OK, this is an error */
-					frame_label = g_strdup_printf("%s:hdlc:hdlc-sig-end",val_to_str(t38_info->data_value, data_vals, "Ukn (0x%02X)"));
-					comment = g_strdup_printf("%s:HDLC:ERROR: received hdlc-sig-end without received fcs-OK or fcs-BAD",val_to_str(t38_info->data_value, data_vals, "Ukn (0x%02X)"));
-					add_to_graph_t38(user_data, pinfo, frame_label, comment, 2);
-					statinfo->hdlc_data_index = 0;
-				}
-				break;
-			case 3: /* hdlc-fcs-BAD */
-			case 5: /* hdlc-fcs-BAD-sig-end */
-				frame_label = g_strdup_printf("%s:hdlc:%s",val_to_str(t38_info->data_value, data_vals, "Ukn (0x%02X)"),t38_info->data_type[i] == 3 ? "fcs-BAD" : "fcs-BAD-sig-end" );
-				comment = g_strdup_printf("WARNING: received %s:hdlc:%s", val_to_str(t38_info->data_value, data_vals, "Ukn (0x%02X)"), t38_info->data_type[i] == 3 ? "fcs-BAD" : "fcs-BAD-sig-end");
-				add_to_graph_t38(user_data, pinfo, frame_label, comment, 2);
-				statinfo->hdlc_data_index = 0;
-				break;
-			} 
-			if ( (t38_info->data_type[i] == 6) || (t38_info->data_type[i] == 7) ) { /* t4-non-ecm-data or t4-non-ecm-sig-end */
-				statinfo->other_data_num_bytes += t38_info->data_len[i];
-				if (seq_status != CORRECT) { 
-					statinfo->other_data_lost++;
-					statinfo->other_data_burst_lost++;
-				} else {
-					if (statinfo->other_data_burst_lost > statinfo->other_data_max_burst_lost) 
-						statinfo->other_data_max_burst_lost = statinfo->other_data_burst_lost;
-						statinfo->other_data_burst_lost = 0;
-				}
-				if (statinfo->start_frame_other_data == -1) {
-					statinfo->start_frame_other_data = pinfo->fd->num;
-					statinfo->start_time_other_data = nstime_to_sec(&pinfo->fd->rel_ts);
-				}
-
-				frame_label = g_strdup_printf("data:%s",val_to_str(t38_info->data_value, data_vals, "Ukn (0x%02X)")  );
-				comment = g_strdup_printf("Num of bytes: %d  Duration: %.2fs Wrong seq num: %d  Burst pack lost: %d", 
-					statinfo->other_data_num_bytes, 
-					nstime_to_sec(&pinfo->fd->rel_ts) - statinfo->start_time_other_data,
-					statinfo->other_data_lost, 
-					statinfo->other_data_max_burst_lost);
-				if ( !change_frame_graph_t38(user_data, statinfo->start_frame_other_data, frame_label, comment) )
-					add_to_graph_t38(user_data, pinfo, frame_label, comment, 2);
-
-				if (t38_info->data_type[i] == 7) { /* t4-non-ecm-sig-end reset values */
-					statinfo->other_data_num_bytes = 0;
-					statinfo->other_data_lost = 0;
-					statinfo->start_frame_other_data = -1;
-					statinfo->prev_seq_status = CORRECT;
-					statinfo->other_data_max_burst_lost = 0;
-					statinfo->other_data_burst_lost = 0;
-				}
-			}
-		}
-	}
-	if (seq_status != LATE) statinfo->seq_num = t38_info->seq_num;
-	g_free(frame_label);
-	g_free(comment);
-	return 0;
-}
-
-/****************************************************************************/
-/* whenever a T38 packet is seen by the tap listener */
-static int t38_packet(void *user_data_arg, packet_info *pinfo, epan_dissect_t *edt _U_, const void *t38_info_arg)
-{
-	user_data_t *user_data = user_data_arg;
-	const t38_packet_info *t38_info = t38_info_arg;
-	/* we ignore packets that are not displayed */
-	if (pinfo->fd->flags.passed_dfilter == 0)
-		return 0;
-	/* is it the forward direction?  */
-	else if (CMP_ADDRESS(&(user_data->ip_src_fwd), &(pinfo->net_src)) == 0
-		&& user_data->port_src_fwd == pinfo->srcport
-		&& CMP_ADDRESS(&(user_data->ip_dst_fwd), &(pinfo->net_dst)) == 0
-		&& user_data->port_dst_fwd == pinfo->destport)  {
-		t38_packet_analyse(&(user_data->forward),user_data, pinfo, t38_info);
-	}
-	/* is it the reversed direction? */
-	else if (CMP_ADDRESS(&(user_data->ip_src_rev), &(pinfo->net_src)) == 0
-		&& user_data->port_src_rev == pinfo->srcport
-		&& CMP_ADDRESS(&(user_data->ip_dst_rev), &(pinfo->net_dst)) == 0
-		&& user_data->port_dst_rev == pinfo->destport)  {
-		t38_packet_analyse(&(user_data->reverse),user_data, pinfo, t38_info);
-	}
-
-	return 1;
-}
-
-/****************************************************************************/
-/* reset user_data valueas and clean graph info */
-static void
-t38_clean(user_data_t *user_data)
-{
-	graph_analysis_item_t *gai;
-	GList* list;
-
-	user_data->forward.hdlc_data_index = 0;
-	user_data->reverse.hdlc_data_index = 0;
-
-	user_data->forward.wrong_seq_num = 0;
-	user_data->reverse.wrong_seq_num = 0;
-
-	user_data->forward.seq_num = -1;
-	user_data->reverse.seq_num = -1;
-
-	user_data->forward.valid_hdlc_data = TRUE;
-	user_data->reverse.valid_hdlc_data = TRUE;
-
-	user_data->forward.other_data_num_bytes = 0;
-	user_data->reverse.other_data_num_bytes = 0;
-
-	user_data->forward.other_data_lost = 0;
-	user_data->reverse.other_data_lost = 0;
-
-	user_data->forward.other_data_max_burst_lost = 0;
-	user_data->reverse.other_data_max_burst_lost = 0;
-
-	user_data->forward.other_data_burst_lost = 0;
-	user_data->reverse.other_data_burst_lost = 0;
-
-	user_data->forward.start_frame_other_data = -1;
-	user_data->reverse.start_frame_other_data = -1;
-
-	user_data->forward.start_time_other_data = 0;
-	user_data->reverse.start_time_other_data = 0;
-
-	user_data->forward.prev_seq_status = CORRECT;
-	user_data->reverse.prev_seq_status = CORRECT;
-	
-	/* free the graph list */
-	list = g_list_first(user_data->graph_analysis_data->graph_info->list);
-	while (list)
-	{
-		gai = list->data;
-		g_free(gai->frame_label);
-		g_free(gai->comment);
-		g_free((void *)gai->src_addr.data);
-		g_free((void *)gai->dst_addr.data);
-		g_free(list->data);
-		list = g_list_next (list);
-	}
-	g_list_free(user_data->graph_analysis_data->graph_info->list);
-	user_data->graph_analysis_data->graph_info->nconv = 0;
-	user_data->graph_analysis_data->graph_info->list = NULL;
-
-	return;
-}
-
-
-/****************************************************************************/
-/* when there is a [re]reading of packet's */
-static void
-t38_reset(void *user_data_arg)
-{
-	user_data_t *user_data = user_data_arg;
-
-	t38_clean(user_data);
-	
-	/* create or refresh the graph windows */
-	if (user_data->graph_analysis_data->dlg.window == NULL)	/* create the window */
-		graph_analysis_create(user_data->graph_analysis_data);
-	else
-		graph_analysis_update(user_data->graph_analysis_data);		/* refresh it */
-
-	return;
-}
-
-/****************************************************************************/
-static void
-t38_draw(void *user_data_arg)
-{
-	user_data_t *user_data = user_data_arg;
-
-	graph_analysis_redraw(user_data->graph_analysis_data);
-
-	return;
-}
-
-/****************************************************************************/
-/* called when the graph windows is destroyed */
-static void
-t38_on_destroy(void *user_data_arg)
-{
-	user_data_t *user_data = user_data_arg;
-
-	/* remove tap listener */
-	protect_thread_critical_region();
-	remove_tap_listener(user_data);
-	unprotect_thread_critical_region();
-
-	/* free the address */
-	g_free((void *)user_data->ip_src_fwd.data);
-	g_free((void *)user_data->ip_dst_fwd.data);
-	g_free((void *)user_data->ip_src_rev.data);
-	g_free((void *)user_data->ip_dst_rev.data);
-
-	/* clean graph info */
-	t38_clean(user_data);
-
-	g_free(user_data->graph_analysis_data->graph_info);
-
-}
-
-/****************************************************************************/
-void t38_analysis(
-		address *ip_src_fwd,
-		guint16 port_src_fwd,
-		address *ip_dst_fwd,
-		guint16 port_dst_fwd,
-		address *ip_src_rev,
-		guint16 port_src_rev,
-		address *ip_dst_rev,
-		guint16 port_dst_rev
-		)
-{
-	user_data_t *user_data;
-	GString *error_string;
-
-	/* init */
-	user_data = g_malloc(sizeof(user_data_t));
-
-	user_data->graph_analysis_data = graph_analysis_init();
-	user_data->graph_analysis_data->graph_info = g_malloc(sizeof(graph_analysis_info_t));
-	user_data->graph_analysis_data->graph_info->nconv = 0;
-	user_data->graph_analysis_data->graph_info->list = NULL;
-
-	user_data->graph_analysis_data->dlg.title = g_strdup("Fax T38 analysis");
-
-	user_data->graph_analysis_data->dlg.inverse = TRUE;  /* to display "calling ----> called" fax call */
-
-	user_data->graph_analysis_data->on_destroy_user_data = t38_on_destroy;
-	user_data->graph_analysis_data->data = user_data;
-
-	COPY_ADDRESS(&(user_data->ip_src_fwd), ip_src_fwd);
-	user_data->port_src_fwd = port_src_fwd;
-	COPY_ADDRESS(&(user_data->ip_dst_fwd), ip_dst_fwd);
-	user_data->port_dst_fwd = port_dst_fwd;
-	COPY_ADDRESS(&(user_data->ip_src_rev), ip_src_rev);
-	user_data->port_src_rev = port_src_rev;
-	COPY_ADDRESS(&(user_data->ip_dst_rev), ip_dst_rev);
-	user_data->port_dst_rev = port_dst_rev;
-	
-	/* register tap listener */
-	error_string = register_tap_listener("t38", user_data, NULL,
-		t38_reset, t38_packet, t38_draw);
-	if (error_string != NULL) {
-		simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, error_string->str);
-			g_string_free(error_string, TRUE);
-		return;
-	}
-
-	/* retap all packets */
-	cf_retap_packets(&cfile, FALSE);	
-}
-
-/****************************************************************************/
 /* entry point from main menu */
 void t38_analysis_cb(GtkWidget *w _U_, gpointer data _U_) 
 {
-	address ip_src_fwd;
-	guint16 port_src_fwd;
-	address ip_dst_fwd;
-	guint16 port_dst_fwd;
-	address ip_src_rev;
-	guint16 port_src_rev;
-	address ip_dst_rev;
-	guint16 port_dst_rev;
-
-	gchar filter_text[256];
-	dfilter_t *sfcode;
-	capture_file *cf;
-	epan_dissect_t *edt;
-	gint err;
-	gchar *err_info;
-	gboolean frame_matched;
-	frame_data *fdata;
-
-	/* Try to compile the filter. */
-	strcpy(filter_text,"t38 && (ip || ipv6)");
-	if (!dfilter_compile(filter_text, &sfcode)) {
-		simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, dfilter_error_msg);
-		return;
-	}
-	/* we load the current file into cf variable */
-	cf = &cfile;
-	fdata = cf->current_frame;
-	
-	/* we are on the selected frame now */
-	if (fdata == NULL)
-		return; /* if we exit here it's an error */
-
-	/* dissect the current frame */
-	if (!wtap_seek_read(cf->wth, fdata->file_off, &cf->pseudo_header,
-	    cf->pd, fdata->cap_len, &err, &err_info)) {
-		simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
-			cf_read_error_message(err, err_info), cf->filename);
-		return;
-	}
-	edt = epan_dissect_new(TRUE, FALSE);
-	epan_dissect_prime_dfilter(edt, sfcode);
-	epan_dissect_run(edt, &cf->pseudo_header, cf->pd, fdata, NULL);
-	frame_matched = dfilter_apply_edt(sfcode, edt);
-	
-	/* check if it is a t38 frame */
-	frame_matched = dfilter_apply_edt(sfcode, edt);
-	if (frame_matched != 1) {
-		epan_dissect_free(edt);
-		simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
-		    "You didn't choose a T38 packet!");
-		return;
-	}
-
-	/* ok, it is a T38 frame, so let's get the ip and port values */
-	COPY_ADDRESS(&(ip_src_fwd), &(edt->pi.src))
-	COPY_ADDRESS(&(ip_dst_fwd), &(edt->pi.dst))
-	port_src_fwd = edt->pi.srcport;
-	port_dst_fwd = edt->pi.destport;
-
-	/* assume the inverse ip/port combination for the reverse direction */
-	COPY_ADDRESS(&(ip_src_rev), &(edt->pi.dst))
-	COPY_ADDRESS(&(ip_dst_rev), &(edt->pi.src))
-	port_src_rev = edt->pi.destport;
-	port_dst_rev = edt->pi.srcport;
-	
-	t38_analysis(
-		&ip_src_fwd,
-		port_src_fwd,
-		&ip_dst_fwd,
-		port_dst_fwd,
-		&ip_src_rev,
-		port_src_rev,
-		&ip_dst_rev,
-		port_dst_rev
-	);
-	
+	/* We have moved this directly to the VoIP Calls */
+	simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
+		  "This feature has been moved to the \"VoIP Calls\"");
+	return;	
 }
 
 /****************************************************************************/
Index: epan/libethereal.def
===================================================================
--- epan/libethereal.def	(revision 17031)
+++ epan/libethereal.def	(working copy)
@@ -583,6 +583,9 @@
 stream_process_reassembled
 string_to_name_resolve
 swaptab
+t30_data_vals                   DATA
+t30_facsimile_control_field_vals        DATA
+t30_facsimile_control_field_vals_short  DATA
 t30_indicator_vals		DATA
 T_h323_message_body_vals	DATA
 tap_push_tapped_queue
Index: epan/dissectors/packet-t38.c
===================================================================
--- epan/dissectors/packet-t38.c	(revision 17031)
+++ epan/dissectors/packet-t38.c	(working copy)
@@ -2,6 +2,7 @@
  * 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
  *
  * $Id$
  *
@@ -38,7 +39,6 @@
 /* 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.
- * - It would be nice if we could dissect the T.30 data.
  * - 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.
  */
@@ -50,8 +50,10 @@
 
 #include <glib.h>
 #include <epan/packet.h>
+#include <epan/reassemble.h>
 #include <epan/conversation.h>
 #include <epan/tap.h>
+#include <epan/expert.h>
 
 #include <stdio.h>
 #include <string.h>
@@ -90,9 +92,6 @@
 /* Reassembly of T.38 PDUs over TPKT over TCP */
 static gboolean t38_tpkt_reassembly = TRUE;
 
-
-static t38_packet_info *t38_info=NULL;
-
 /* 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
@@ -112,6 +111,118 @@
 };
 
 
+
+/* T30 */
+static int proto_t30 = -1;
+static int hf_t30_Address = -1;
+static int hf_t30_Control = -1;
+static int hf_t30_Facsimile_Control = -1;
+static int hf_t30_fif_sm = -1; 
+static int hf_t30_fif_rtif = -1; 
+static int hf_t30_fif_3gmn = -1; 
+static int hf_t30_fif_v8c = -1; 
+static int hf_t30_fif_op = -1; 
+static int hf_t30_fif_rtfc = -1;
+static int hf_t30_fif_rfo = -1;
+static int hf_t30_fif_dsr = -1;
+static int hf_t30_fif_dsr_dcs = -1;
+static int hf_t30_fif_res = -1;
+static int hf_t30_fif_tdcc = -1;
+static int hf_t30_fif_rwc = -1;
+static int hf_t30_fif_rw_dcs = -1;
+static int hf_t30_fif_rlc = -1;
+static int hf_t30_fif_rl_dcs = -1;
+static int hf_t30_fif_msltcr = -1;
+static int hf_t30_fif_mslt_dcs = -1;
+static int hf_t30_fif_ext = -1;
+static int hf_t30_fif_cm = -1;
+static int hf_t30_fif_ecm = -1;
+static int hf_t30_fif_fs_dcs = -1;
+static int hf_t30_fif_t6 = -1;
+static int hf_t30_fif_fvc = -1;
+static int hf_t30_fif_mspc = -1;
+static int hf_t30_fif_ps = -1;
+static int hf_t30_fif_t43 = -1;
+static int hf_t30_fif_pi = -1;
+static int hf_t30_fif_vc32k = -1;
+static int hf_t30_fif_r8x15 = -1;
+static int hf_t30_fif_300x300 = -1;
+static int hf_t30_fif_r16x15 = -1;
+static int hf_t30_fif_ibrp = -1;
+static int hf_t30_fif_mbrp = -1;
+static int hf_t30_fif_msltchr = -1;
+static int hf_t30_fif_rts = -1;
+static int hf_t30_fif_sp = -1;
+static int hf_t30_fif_sc = -1;
+static int hf_t30_fif_passw = -1;
+static int hf_t30_fif_sit = -1;
+static int hf_t30_fif_rttd = -1;
+static int hf_t30_fif_bft = -1;
+static int hf_t30_fif_dtm = -1;
+static int hf_t30_fif_edi = -1;
+static int hf_t30_fif_btm = -1;
+static int hf_t30_fif_rttcmmd = -1;
+static int hf_t30_fif_chrm = -1;
+static int hf_t30_fif_mm = -1;
+static int hf_t30_fif_pm26 = -1;
+static int hf_t30_fif_dnc = -1;
+static int hf_t30_fif_do = -1;
+static int hf_t30_fif_jpeg = -1;
+static int hf_t30_fif_fcm = -1;
+static int hf_t30_fif_pht = -1;
+static int hf_t30_fif_12c = -1;
+static int hf_t30_fif_ns = -1;
+static int hf_t30_fif_ci = -1;
+static int hf_t30_fif_cgr = -1;
+static int hf_t30_fif_nalet = -1;
+static int hf_t30_fif_naleg = -1;
+static int hf_t30_fif_spscb = -1;
+static int hf_t30_fif_spsco = -1;
+static int hf_t30_fif_hkm = -1;
+static int hf_t30_fif_rsa = -1;
+static int hf_t30_fif_oc = -1;
+static int hf_t30_fif_hfx40 = -1;
+static int hf_t30_fif_acn2c = -1;
+static int hf_t30_fif_acn3c = -1;
+static int hf_t30_fif_hfx40i = -1;
+static int hf_t30_fif_ahsn2 = -1;
+static int hf_t30_fif_ahsn3 = -1;
+static int hf_t30_fif_t441 = -1;
+static int hf_t30_fif_t442 = -1;
+static int hf_t30_fif_t443 = -1;
+static int hf_t30_fif_plmss = -1;
+static int hf_t30_fif_cg300 = -1;
+static int hf_t30_fif_100x100cg = -1;
+static int hf_t30_fif_spcbft = -1;
+static int hf_t30_fif_ebft = -1;
+static int hf_t30_fif_isp = -1;
+static int hf_t30_fif_ira = -1;
+static int hf_t30_fif_600x600 = -1;
+static int hf_t30_fif_1200x1200 = -1;
+static int hf_t30_fif_300x600 = -1;
+static int hf_t30_fif_400x800 = -1;
+static int hf_t30_fif_600x1200 = -1;
+static int hf_t30_fif_cg600x600 = -1;
+static int hf_t30_fif_cg1200x1200 = -1;
+static int hf_t30_fif_dspcam = -1;
+static int hf_t30_fif_dspccm = -1;
+static int hf_t30_fif_bwmrcp = -1;
+static int hf_t30_fif_t45 = -1;
+static int hf_t30_fif_sdmc = -1;
+static int hf_t30_fif_number = -1;
+static int hf_t30_fif_country_code = -1;
+static int hf_t30_fif_non_stand_bytes = -1;
+static int hf_t30_t4_frame_num = -1;
+static int hf_t30_t4_data = -1;
+static int hf_t30_partial_page_fcf2 = -1;
+static int hf_t30_partial_page_i1 = -1;
+static int hf_t30_partial_page_i2 = -1;
+static int hf_t30_partial_page_i3 = -1;
+
+static gint ett_t30 = -1;
+static gint ett_t30_fif = -1;
+
+/* T38 */
 static dissector_handle_t t38_udp_handle;
 static dissector_handle_t t38_tcp_handle;
 static dissector_handle_t t38_tcp_pdu_handle;
@@ -121,6 +232,7 @@
 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;
 static int hf_t38_IFPPacket = -1;
@@ -149,6 +261,16 @@
 static int hf_t38_setup_frame  = -1;
 static int hf_t38_setup_method = -1;
 
+/* T38 Data reassemble fields */
+static int hf_data_fragments = -1;
+static int hf_data_fragment = -1;
+static int hf_data_fragment_overlap = -1;
+static int hf_data_fragment_overlap_conflicts = -1;
+static int hf_data_fragment_multiple_tails = -1;
+static int hf_data_fragment_too_long_fragment = -1;
+static int hf_data_fragment_error = -1;
+static int hf_data_reassembled_in = -1;
+
 static gint ett_t38 = -1;
 static gint ett_t38_IFPPacket = -1;
 static gint ett_t38_Type_of_msg = -1;
@@ -164,18 +286,70 @@
 static gint ett_t38_fec_data = -1;
 static gint ett_t38_setup = -1;
 
+static gint ett_data_fragment = -1;
+static gint ett_data_fragments = -1;
+
 static gboolean primary_part = TRUE;
 static guint32 seq_number = 0;
 
+/* Tables for reassembly of Data fragments. */
+static GHashTable *data_fragment_table = NULL;
+static GHashTable *data_reassembled_table = NULL;
+
+static const fragment_items data_frag_items = {
+	/* Fragment subtrees */
+	&ett_data_fragment,
+	&ett_data_fragments,
+	/* Fragment fields */
+	&hf_data_fragments,
+	&hf_data_fragment,
+	&hf_data_fragment_overlap,
+	&hf_data_fragment_overlap_conflicts,
+	&hf_data_fragment_multiple_tails,
+	&hf_data_fragment_too_long_fragment,
+	&hf_data_fragment_error,
+	/* Reassembled in field */
+	&hf_data_reassembled_in,
+	/* 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, packet_info *pinfo, proto_tree *tree);
+static void show_setup_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, conversation_t *p_conv, 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 reassemble tables */
+	fragment_table_init(&data_fragment_table);
+	reassembled_table_init(&data_reassembled_table);
+}
+
+
 /* Set up an T38 conversation */
 void t38_add_address(packet_info *pinfo,
                      address *addr, int port,
@@ -184,7 +358,7 @@
 {
         address null_addr;
         conversation_t* p_conv;
-        struct _t38_conversation_info *p_conv_data = NULL;
+        t38_conv* p_conv_data = NULL;
 
         /*
          * If this isn't the first time this packet has been processed,
@@ -227,7 +401,7 @@
          */
         if ( ! p_conv_data ) {
                 /* Create conversation data */
-                p_conv_data = se_alloc(sizeof(struct _t38_conversation_info));
+                p_conv_data = se_alloc(sizeof(t38_conv));
 
                 conversation_add_proto_data(p_conv, proto_t38, p_conv_data);
         }
@@ -235,13 +409,830 @@
         /*
          * Update the conversation data.
          */
-        strncpy(p_conv_data->method, setup_method, MAX_T38_SETUP_METHOD_SIZE);
-        p_conv_data->method[MAX_T38_SETUP_METHOD_SIZE] = '\0';
-        p_conv_data->frame_number = setup_frame_number;
+        strncpy(p_conv_data->setup_method, setup_method, MAX_T38_SETUP_METHOD_SIZE);
+        p_conv_data->setup_method[MAX_T38_SETUP_METHOD_SIZE] = '\0';
+        p_conv_data->setup_frame_number = setup_frame_number;
+		p_conv_data->src_t38_info.reass_ID = 0;
+		p_conv_data->src_t38_info.reass_start_seqnum = -1;
+		p_conv_data->src_t38_info.reass_data_type = 0;
+		p_conv_data->src_t38_info.last_seqnum = -1;
+		p_conv_data->src_t38_info.packet_lost = 0;
+		p_conv_data->src_t38_info.burst_lost = 0;
+		p_conv_data->src_t38_info.time_first_t4_data = 0;
+
+
+		p_conv_data->dst_t38_info.reass_ID = 0;
+		p_conv_data->dst_t38_info.reass_start_seqnum = -1;
+		p_conv_data->dst_t38_info.reass_data_type = 0;
+		p_conv_data->dst_t38_info.last_seqnum = -1;
+		p_conv_data->dst_t38_info.packet_lost = 0;
+		p_conv_data->dst_t38_info.burst_lost = 0;
+		p_conv_data->dst_t38_info.time_first_t4_data = 0;
 }
 
 
+/* T30 Routines */
+
 static int
+dissect_t30_NULL(tvbuff_t *tvb _U_, int offset, packet_info *pinfo _U_, proto_tree *tree _U_)
+{
+	return offset;
+}
+
+static const value_string t30_control_vals[] = {
+	{ 0xC0, "non-final frames within the procedure" },
+	{ 0xC8, "final frames within the procedure" },
+	{ 0,    NULL }
+};
+
+
+#define	T30_FC_DIS	0x01
+#define	T30_FC_CSI	0x02
+#define	T30_FC_NSF	0x04
+#define	T30_FC_DTC	0x81
+#define	T30_FC_CIG	0x82
+#define	T30_FC_NSC	0x84
+#define	T30_FC_PWD	0x83
+#define	T30_FC_SEP	0x85
+#define	T30_FC_PSA	0x86
+#define	T30_FC_CIA	0x87
+#define	T30_FC_ISP	0x88
+#define	T30_FC_DCS	0x41
+#define	T30_FC_TSI	0x42
+#define	T30_FC_NSS	0x44
+#define	T30_FC_SUB	0x43
+#define	T30_FC_SID	0x45
+#define	T30_FC_TSA	0x46
+#define	T30_FC_IRA	0x47
+#define	T30_FC_CFR	0x21
+#define	T30_FC_FTT	0x22
+#define	T30_FC_CSA	0x24
+#define	T30_FC_EOM	0x71
+#define	T30_FC_MPS	0x72
+#define	T30_FC_EOP	0x74
+#define	T30_FC_PRI_EOM	0x79
+#define	T30_FC_PRI_MPS	0x7A
+#define	T30_FC_PRI_EOP	0x7C
+#define	T30_FC_PRI_EOP2	0x78
+#define	T30_FC_MCF	0x31
+#define	T30_FC_RTP	0x33
+#define	T30_FC_RTN	0x32
+#define	T30_FC_PIP	0x35
+#define	T30_FC_PIN	0x34
+#define	T30_FC_FDM	0x3F
+#define	T30_FC_DCN	0x5F
+#define	T30_FC_CRP	0x58
+#define	T30_FC_FNV	0x53
+#define	T30_FC_TNR	0x57
+#define	T30_FC_TR	0x56
+#define	T30_FC_MCF	0x31
+#define	T30_FC_PID	0x36
+#define	T30_FC_PPR	0x3D
+#define	T30_FC_RNR	0x37
+#define	T30_FC_CRP	0x58
+#define	T30_FC_CTC	0x48
+#define	T30_FC_CTR	0x23
+#define	T30_FC_PPS	0x7D
+#define	T30_FC_EOR	0x73
+#define	T30_FC_RR	0x76
+#define	T30_FC_ERR	0x38
+#define	T30_FC_FCD	0x60
+#define	T30_FC_RCP	0x61
+
+const value_string t30_facsimile_control_field_vals[] = {
+	{ T30_FC_DIS, "Digital Identification Signal" },
+	{ T30_FC_CSI, "Called Subscriber Identification" },
+	{ T30_FC_NSF, "Non-Standard Facilities" },
+	{ T30_FC_DTC, "Digital Transmit Command" },
+	{ T30_FC_CIG, "Calling Subscriber Identification" },
+	{ T30_FC_NSC, "Non-Standard facilities Command" },
+	{ T30_FC_PWD, "Password" },
+	{ T30_FC_SEP, "Selective Polling" },
+	{ T30_FC_PSA, "Polled Subaddress" },
+	{ T30_FC_CIA, "Calling subscriber Internet Address" },
+	{ T30_FC_ISP, "Internet Selective Polling Address" },
+	{ T30_FC_DCS, "Digital Command Signal" },
+	{ T30_FC_TSI, "Transmitting Subscriber Identification" },
+	{ T30_FC_NSS, "Non-Standard facilities Set-up" },
+	{ T30_FC_SUB, "Subaddress" },
+	{ T30_FC_SID, "Sender Identification" },
+	{ T30_FC_TSA, "Transmitting Subscriber Internet address" },
+	{ T30_FC_IRA, "Internet Routing Address" },
+	{ T30_FC_CFR, "Confirmation To Receive" },
+	{ T30_FC_FTT, "Failure To Train" },
+	{ T30_FC_CSA, "Called Subscriber Internet Address" },
+	{ T30_FC_EOM, "End Of Message" },
+	{ T30_FC_MPS, "MultiPage Signal" },
+	{ T30_FC_EOP, "End Of Procedure" },
+	{ T30_FC_PRI_EOM, "Procedure Interrupt-End Of Message" },
+	{ T30_FC_PRI_MPS, "Procedure Interrupt-MultiPage Signal" },
+	{ T30_FC_PRI_EOP, "Procedure Interrupt-End Of Procedure" },
+	{ T30_FC_PRI_EOP2, "Procedure Interrupt-End Of Procedure" },
+	{ T30_FC_MCF, "Message Confirmation" },
+	{ T30_FC_RTP, "Retrain Positive" },
+	{ T30_FC_RTN, "Retrain Negative" },
+	{ T30_FC_PIP, "Procedure Interrupt Positive" },
+	{ T30_FC_PIN, "Procedure Interrupt Negative" },
+	{ T30_FC_FDM, "File Diagnostics Message" },
+	{ T30_FC_DCN, "Disconnect" },
+	{ T30_FC_CRP, "Command Repeat" },
+	{ T30_FC_FNV, "Field Not Valid" },
+	{ T30_FC_TNR, "Transmit not ready" },
+	{ T30_FC_TR, "Transmit ready" },
+	{ T30_FC_MCF, "Message Confirmation" },
+	{ T30_FC_PID, "Procedure Interrupt Disconnect" },
+	{ T30_FC_PPR, "Partial Page Request" },
+	{ T30_FC_RNR, "Receive Not Ready" },
+	{ T30_FC_CRP, "Command Repeat" },
+	{ T30_FC_CTC, "Continue To Correct" },
+	{ T30_FC_CTR, "Response for Continue To Correct" },
+	{ T30_FC_PPS, "Partial Page Signal" },
+	{ T30_FC_EOR, "End Of Retransmission" },
+	{ T30_FC_RR, "Receive Ready" },
+	{ T30_FC_ERR, "Response for End of Retransmission" },
+	{ T30_FC_FCD, "Facsimile coded data" },
+	{ T30_FC_RCP, "Return to control for partial page" },
+	{ 0, NULL }
+};
+
+const value_string t30_facsimile_control_field_vals_short[] = {
+	{ T30_FC_DIS, "DIS" },
+	{ T30_FC_CSI, "CSI" },
+	{ T30_FC_NSF, "NSF" },
+	{ T30_FC_DTC, "DTC" },
+	{ T30_FC_CIG, "CIG" },
+	{ T30_FC_NSC, "NSC" },
+	{ T30_FC_PWD, "PWD" },
+	{ T30_FC_SEP, "SEP" },
+	{ T30_FC_PSA, "PSA" },
+	{ T30_FC_CIA, "CIA" },
+	{ T30_FC_ISP, "ISP" },
+	{ T30_FC_DCS, "DCS" },
+	{ T30_FC_TSI, "TSI" },
+	{ T30_FC_NSS, "NSS" },
+	{ T30_FC_SUB, "SUB" },
+	{ T30_FC_SID, "SID" },
+	{ T30_FC_TSA, "TSA" },
+	{ T30_FC_IRA, "IRA" },
+	{ T30_FC_CFR, "CFR" },
+	{ T30_FC_FTT, "FTT" },
+	{ T30_FC_CSA, "CSA" },
+	{ T30_FC_EOM, "EOM" },
+	{ T30_FC_MPS, "MPS" },
+	{ T30_FC_EOP, "EOP" },
+	{ T30_FC_PRI_EOM, "PRI_EOM" },
+	{ T30_FC_PRI_MPS, "PRI_MPS" },
+	{ T30_FC_PRI_EOP, "EOP" },
+	{ T30_FC_PRI_EOP2, "EOP2" },
+	{ T30_FC_MCF, "MCF" },
+	{ T30_FC_RTP, "RTP" },
+	{ T30_FC_RTN, "RTN" },
+	{ T30_FC_PIP, "PIP" },
+	{ T30_FC_PIN, "PIN" },
+	{ T30_FC_FDM, "FDM" },
+	{ T30_FC_DCN, "DCN" },
+	{ T30_FC_CRP, "CRP" },
+	{ T30_FC_FNV, "FNV" },
+	{ T30_FC_TNR, "TNR" },
+	{ T30_FC_TR, "TR" },
+	{ T30_FC_MCF, "MCF" },
+	{ T30_FC_PID, "PID" },
+	{ T30_FC_PPR, "PPR" },
+	{ T30_FC_RNR, "RNR" },
+	{ T30_FC_CRP, "CRP" },
+	{ T30_FC_CTC, "CTC" },
+	{ T30_FC_CTR, "CTR" },
+	{ T30_FC_PPS, "PPS" },
+	{ T30_FC_EOR, "EOR" },
+	{ T30_FC_RR, "RR" },
+	{ T30_FC_ERR, "ERR" },
+	{ T30_FC_FCD, "FCD" },
+	{ T30_FC_RCP, "RCP" },
+	{ 0, NULL }
+};
+
+static const value_string t30_data_signalling_rate_vals[] = {
+	{ 0x00, "ITU-T V.27 ter fall-back mode" },
+	{ 0x04, "ITU-T V.27 ter" },
+	{ 0x08, "ITU-T V.29" },
+	{ 0x0C, "ITU-T V.27 ter and V.29" },
+	{ 0x02, "Not used" },
+	{ 0x06, "Reserved" },
+	{ 0x0A, "Not used" },
+	{ 0x0E, "Invalid" },
+	{ 0x01, "Not used" },
+	{ 0x05, "Reserved" },
+	{ 0x09, "Not used" },
+	{ 0x0D, "ITU-T V.27 ter, V.29, and V.17" },
+	{ 0x03, "Not used" },
+	{ 0x07, "Reserved" },
+	{ 0x0B, "Not used" },
+	{ 0x0F, "Reserved" },
+};
+
+static const value_string t30_data_signalling_rate_dcs_vals[] = {
+	{ 0x00, "2400 bit/s, ITU-T V.27 ter" },
+	{ 0x04, "4800 bit/s, ITU-T V.27 ter" },
+	{ 0x08, "9600 bit/s, ITU-T V.29" },
+	{ 0x0C, "7200 bit/s, ITU-T V.29" },
+	{ 0x02, "Invalid" },
+	{ 0x06, "Invalid" },
+	{ 0x0A, "Reserved" },
+	{ 0x0E, "Reserved" },
+	{ 0x01, "14 400 bit/s, ITU-T V.17" },
+	{ 0x05, "12 000 bit/s, ITU-T V.17" },
+	{ 0x09, "9600 bit/s, ITU-T V.17" },
+	{ 0x0D, "7200 bit/s, ITU-T V.17" },
+	{ 0x03, "Reserved" },
+	{ 0x07, "Reserved" },
+	{ 0x0B, "Reserved" },
+	{ 0x0F, "Reserved" },
+};
+
+static const value_string t30_recording_width_capabilities_vals[] = {
+	{ 0x00, "Scan line length 215 mm +- 1%" },
+	{ 0x01, "Scan line length 215 mm +- 1% and Scan line length 255 mm +- 1% and Scan line length 303 mm +- 1%" },
+	{ 0x02, "Scan line length 215 mm +- 1% and Scan line length 255 mm +- 1%" },
+	{ 0x03, "Invalid" },
+};
+
+static const value_string t30_recording_width_dcs_vals[] = {
+	{ 0x00, "Scan line length 215 mm +- 1%" },
+	{ 0x01, "Scan line length 303 mm +- 1%" },
+	{ 0x02, "Scan line length 255 mm +- 1%" },
+	{ 0x03, "Invalid" },
+};
+
+static const value_string t30_recording_length_capability_vals[] = {
+	{ 0x00, "A4 (297 mm)" },
+	{ 0x01, "Unlimited" },
+	{ 0x02, "A4 (297 mm) and B4 (364 mm)" },
+	{ 0x03, "Invalid" },
+};
+
+static const value_string t30_recording_length_dcs_vals[] = {
+	{ 0x00, "A4 (297 mm)" },
+	{ 0x01, "Unlimited" },
+	{ 0x02, "B4 (364 mm)" },
+	{ 0x03, "Invalid" },
+};
+
+static const value_string t30_minimum_scan_line_time_rec_vals[] = {
+	{ 0x00, "20 ms at 3.85 l/mm: T7.7 = T3.85" },
+	{ 0x01, "40 ms at 3.85 l/mm: T7.7 = T3.85" },
+	{ 0x02, "10 ms at 3.85 l/mm: T7.7 = T3.85" },
+	{ 0x04, "05 ms at 3.85 l/mm: T7.7 = T3.85" },
+	{ 0x03, "10 ms at 3.85 l/mm: T7.7 = 1/2 T3.85" },
+	{ 0x06, "20 ms at 3.85 l/mm: T7.7 = 1/2 T3.85" },
+	{ 0x05, "40 ms at 3.85 l/mm: T7.7 = 1/2 T3.85" },
+	{ 0x07, "00 ms at 3.85 l/mm: T7.7 = T3.85" },
+};
+
+static const value_string t30_partial_page_fcf2_vals[] = {
+	{ 0x00, "NULL code which indicates the partial page boundary" },
+	{ 0xF1, "EOM in optional T.4 error correction mode" },
+	{ 0xF2, "MPS in optional T.4 error correction mode" },
+	{ 0xF4, "EOP in optional T.4 error correction mode" },
+	{ 0xF8, "EOS in optional T.4 error correction mode" },
+	{ 0xF9, "PRI-EOM in optional T.4 error correction mode" },
+	{ 0xFA, "PRI-MPS in optional T.4 error correction mode" },
+	{ 0xFC, "PRI-EOP in optional T.4 error correction mode" },
+};
+
+static const value_string t30_minimum_scan_line_time_dcs_vals[] = {
+	{ 0x00, "20 ms" },
+	{ 0x01, "40 ms" },
+	{ 0x02, "10 ms" },
+	{ 0x04, "05 ms" },
+	{ 0x07, "00 ms" },
+};
+
+static const value_string t30_SharedDataMemory_capacity_vals[] = {
+	{ 0x00, "Not available" },
+	{ 0x01, "Level 1 = 1.0 Mbytes" },
+	{ 0x02, "Level 2 = 2.0 Mbytes" },
+	{ 0x03, "Level 3 = unlimited (i.e. >= 32 Mbytes)" },
+};
+
+static const true_false_string t30_octets_preferred_value = {
+  "64 octets preferred",
+  "256 octets preferred",
+};
+
+static const true_false_string t30_extension_ind_value = {
+  "information continues through the next octet",
+  "last octet",
+};
+
+static const true_false_string t30_compress_value = {
+  "Uncompressed mode",
+  "Compressed mode",
+};
+
+static const true_false_string t30_minimum_scan_value = {
+  "T15.4 = 1/2 T7.7",
+  "T15.4 = T7.7",
+};
+
+static const true_false_string t30_duplex_operation_value = {
+  "Duplex  and half duplex operation",
+  "Half duplex operation only",
+};
+
+static const true_false_string t30_frame_size_dcs_value = {
+  "64 octets",
+  "256 octets",
+};
+
+static const true_false_string t30_res_type_sel_value = {
+  "inch based resolution",
+  "metric based resolution",
+};
+
+guint8 reverse_byte(guint8 val)
+{
+	return ( ((val & 0x80)>>7) | ((val & 0x40)>>5) |
+		((val & 0x20)>>3) | ((val & 0x10)>>1) |
+		((val & 0x08)<<1) | ((val & 0x04)<<3) |
+		((val & 0x02)<<5) | ((val & 0x01)<<7) );
+}
+
+#define LENGTH_T30_NUM	20
+gchar * 
+t30_get_string_numbers(tvbuff_t *tvb, int offset, int len)
+{
+	gchar *buf;
+	int i;
+
+	/* the lenght must be 20 bytes per T30 rec*/
+	if (len != LENGTH_T30_NUM) return NULL;
+
+	buf=ep_alloc(LENGTH_T30_NUM+1);
+
+	for (i=0; i<LENGTH_T30_NUM; i++) 
+		buf[LENGTH_T30_NUM-i-1] = reverse_byte(tvb_get_guint8(tvb, offset+i));
+	
+	/* add end of string */
+	buf[LENGTH_T30_NUM] = '\0';
+
+	return g_strstrip(buf);
+
+}
+
+static void
+dissect_t30_numbers(tvbuff_t *tvb, int offset, packet_info *pinfo, int len, proto_tree *tree)
+{
+	gchar *str_num=NULL;
+
+	str_num = t30_get_string_numbers(tvb, offset, len);
+	if (str_num) {
+		proto_tree_add_string_format(tree, hf_t30_fif_number, tvb, offset, LENGTH_T30_NUM, str_num, "Number: %s", str_num);
+
+		if (check_col(pinfo->cinfo, COL_INFO))
+			col_append_fstr(pinfo->cinfo, COL_INFO, " - Number:%s", str_num );	
+
+		g_snprintf(t38_info->desc, MAX_T38_DESC, "Num: %s", str_num);
+	}
+	else {
+		proto_tree_add_text(tree, tvb, offset, tvb_reported_length_remaining(tvb, offset), "[MALFORMED OR SHORT PACKET: number of digits must be 20]");
+
+		if (check_col(pinfo->cinfo, COL_INFO))
+			col_append_str(pinfo->cinfo, COL_INFO, " [MALFORMED OR SHORT PACKET: number of digits must be 20]" );	
+	}
+}
+
+static void
+dissect_t30_facsimile_coded_data(tvbuff_t *tvb, int offset, packet_info *pinfo, int len, proto_tree *tree)
+{
+	guint8 octet;
+	gchar *t4_data;
+
+	if (len < 2) {
+		proto_tree_add_text(tree, tvb, offset, tvb_reported_length_remaining(tvb, offset), "[MALFORMED OR SHORT PACKET: FCD length must be at least 2 bytes]");
+		expert_add_info_format(pinfo, NULL, PI_MALFORMED, PI_ERROR, "T30 FCD length must be at least 2 bytes");
+		if (check_col(pinfo->cinfo, COL_INFO))
+			col_append_str(pinfo->cinfo, COL_INFO, " [MALFORMED OR SHORT PACKET]");				
+		return;
+	}
+	
+	octet = tvb_get_guint8(tvb, offset);
+	proto_tree_add_uint(tree, hf_t30_t4_frame_num, tvb, offset, 1, reverse_byte(octet));
+	offset++;
+
+	if (check_col(pinfo->cinfo, COL_INFO))
+		col_append_fstr(pinfo->cinfo, COL_INFO, " - Frame num:%d", reverse_byte(octet));
+
+	g_snprintf(t38_info->desc, MAX_T38_DESC, "Frm num: %d", reverse_byte(octet));
+
+	t4_data = ep_alloc(len-1);
+	tvb_memcpy(tvb, t4_data, offset, len-1);
+	proto_tree_add_bytes(tree, hf_t30_t4_data, tvb, offset, len-1, t4_data);
+}
+
+static void
+dissect_t30_non_standard_cap(tvbuff_t *tvb, int offset, packet_info *pinfo, int len, proto_tree *tree)
+{
+	guint8 octet;
+	gchar *non_standard_bytes;
+
+	if (len < 2) {
+		proto_tree_add_text(tree, tvb, offset, tvb_reported_length_remaining(tvb, offset), "[MALFORMED OR SHORT PACKET: NSC length must be at least 2 bytes]");
+		expert_add_info_format(pinfo, NULL, PI_MALFORMED, PI_ERROR, "T30 NSC length must be at least 2 bytes");
+		if (check_col(pinfo->cinfo, COL_INFO))
+			col_append_str(pinfo->cinfo, COL_INFO, " [MALFORMED OR SHORT PACKET]");				
+		return;
+	}
+	
+	octet = tvb_get_guint8(tvb, offset);
+	proto_tree_add_uint(tree, hf_t30_fif_country_code, tvb, offset, 1, octet);
+	offset++;
+
+	non_standard_bytes = ep_alloc(len-1);
+	tvb_memcpy(tvb, non_standard_bytes, offset, len-1);
+	proto_tree_add_bytes(tree, hf_t30_fif_non_stand_bytes, tvb, offset, len-1, non_standard_bytes);
+
+}
+
+static void
+dissect_t30_partial_page_signal(tvbuff_t *tvb, int offset, packet_info *pinfo, int len, proto_tree *tree)
+{
+	guint8 octet, page_count, block_count, frame_count;
+
+	if (len != 4) {
+		proto_tree_add_text(tree, tvb, offset, tvb_reported_length_remaining(tvb, offset), "[MALFORMED OR SHORT PACKET: PPS length must be 4 bytes]");
+		expert_add_info_format(pinfo, NULL, PI_MALFORMED, PI_ERROR, "T30 PPS length must be 4 bytes");
+		if (check_col(pinfo->cinfo, COL_INFO))
+			col_append_str(pinfo->cinfo, COL_INFO, " [MALFORMED OR SHORT PACKET]");				
+		return;
+	}
+
+	octet = tvb_get_guint8(tvb, offset);
+	proto_tree_add_uint(tree, hf_t30_partial_page_fcf2, tvb, offset, 1, octet);
+	offset += 1;
+
+	octet = tvb_get_guint8(tvb, offset);
+	page_count = reverse_byte(octet);
+	proto_tree_add_uint(tree, hf_t30_partial_page_i1, tvb, offset, 1, page_count);
+	offset++;
+
+	octet = tvb_get_guint8(tvb, offset);
+	block_count = reverse_byte(octet);
+	proto_tree_add_uint(tree, hf_t30_partial_page_i2, tvb, offset, 1, block_count);
+	offset++;
+
+	octet = tvb_get_guint8(tvb, offset);
+	frame_count = reverse_byte(octet);
+	proto_tree_add_uint(tree, hf_t30_partial_page_i3, tvb, offset, 1, frame_count);
+	offset++;
+
+	if (check_col(pinfo->cinfo, COL_INFO))
+		col_append_fstr(pinfo->cinfo, COL_INFO, " - PC:%d BC:%d FC:%d", page_count, block_count, frame_count);
+
+	g_snprintf(t38_info->desc, MAX_T38_DESC, "PC:%d BC:%d FC:%d", page_count, block_count, frame_count);
+
+}
+
+static void
+dissect_t30_dis_dtc(tvbuff_t *tvb, int offset, packet_info *pinfo, int len, proto_tree *tree, gboolean dis_dtc)
+{
+	guint8 octet;
+
+	if (len < 3) {
+		proto_tree_add_text(tree, tvb, offset, tvb_reported_length_remaining(tvb, offset), "[MALFORMED OR SHORT PACKET: DIS length must be at least 4 bytes]");
+		expert_add_info_format(pinfo, NULL, PI_MALFORMED, PI_ERROR, "T30 DIS length must be at least 4 bytes");
+		if (check_col(pinfo->cinfo, COL_INFO))
+			col_append_str(pinfo->cinfo, COL_INFO, " [MALFORMED OR SHORT PACKET]");				
+		return;
+	}
+
+	/* bits 1 to 8 */
+	octet = tvb_get_guint8(tvb, offset);
+	
+    proto_tree_add_boolean(tree, hf_t30_fif_sm, tvb, offset, 1, octet);
+    proto_tree_add_boolean(tree, hf_t30_fif_rtif, tvb, offset, 1, octet);
+    proto_tree_add_boolean(tree, hf_t30_fif_3gmn, tvb, offset, 1, octet);
+    if (dis_dtc) {
+		proto_tree_add_boolean(tree, hf_t30_fif_v8c, tvb, offset, 1, octet);
+		proto_tree_add_boolean(tree, hf_t30_fif_op, tvb, offset, 1, octet);
+	}
+	/* bits 9 to 16 */
+	offset += 1;
+	octet = tvb_get_guint8(tvb, offset);
+
+	if (dis_dtc) proto_tree_add_boolean(tree, hf_t30_fif_rtfc, tvb, offset, 1, octet);
+    proto_tree_add_boolean(tree, hf_t30_fif_rfo, tvb, offset, 1, octet);
+	if (dis_dtc) {
+		proto_tree_add_uint(tree, hf_t30_fif_dsr, tvb, offset, 1, octet);
+
+		if (check_col(pinfo->cinfo, COL_INFO))
+			col_append_fstr(pinfo->cinfo, COL_INFO, " - DSR:%s", val_to_str((octet&0x3C) >> 2, t30_data_signalling_rate_vals, "<unknown>"));
+
+		g_snprintf(t38_info->desc, MAX_T38_DESC, "DSR:%s", val_to_str((octet&0x3C) >> 2, t30_data_signalling_rate_vals, "<unknown>"));
+	}
+	else {
+		proto_tree_add_uint(tree, hf_t30_fif_dsr_dcs, tvb, offset, 1, octet);
+
+		if (check_col(pinfo->cinfo, COL_INFO))
+			col_append_fstr(pinfo->cinfo, COL_INFO, " - DSR:%s", val_to_str((octet&0x3C) >> 2, t30_data_signalling_rate_dcs_vals, "<unknown>"));
+
+		g_snprintf(t38_info->desc, MAX_T38_DESC, "DSR:%s", val_to_str((octet&0x3C) >> 2, t30_data_signalling_rate_dcs_vals, "<unknown>"));
+	}
+    proto_tree_add_boolean(tree, hf_t30_fif_res, tvb, offset, 1, octet);
+    proto_tree_add_boolean(tree, hf_t30_fif_tdcc, tvb, offset, 1, octet);
+
+	/* bits 17 to 24 */
+	offset += 1;
+	octet = tvb_get_guint8(tvb, offset);
+
+	if (dis_dtc) {
+		proto_tree_add_uint(tree, hf_t30_fif_rwc, tvb, offset, 1, octet);
+		proto_tree_add_uint(tree, hf_t30_fif_rlc, tvb, offset, 1, octet);
+		proto_tree_add_uint(tree, hf_t30_fif_msltcr, tvb, offset, 1, octet);
+	} else {
+		proto_tree_add_uint(tree, hf_t30_fif_rw_dcs, tvb, offset, 1, octet);
+		proto_tree_add_uint(tree, hf_t30_fif_rl_dcs, tvb, offset, 1, octet);
+		proto_tree_add_uint(tree, hf_t30_fif_mslt_dcs, tvb, offset, 1, octet);
+	}
+    proto_tree_add_boolean(tree, hf_t30_fif_ext, tvb, offset, 1, octet);
+
+	if ( !(octet & 0x01) || (len < 4) ) return;	/* no extension */
+
+	/* bits 25 to 32 */
+	offset += 1;
+	octet = tvb_get_guint8(tvb, offset);
+
+	proto_tree_add_boolean(tree, hf_t30_fif_cm, tvb, offset, 1, octet);
+    proto_tree_add_boolean(tree, hf_t30_fif_ecm, tvb, offset, 1, octet);
+	if (!dis_dtc) proto_tree_add_boolean(tree, hf_t30_fif_fs_dcs, tvb, offset, 1, octet);
+    proto_tree_add_boolean(tree, hf_t30_fif_t6, tvb, offset, 1, octet);
+    proto_tree_add_boolean(tree, hf_t30_fif_ext, tvb, offset, 1, octet);
+
+	if ( !(octet & 0x01) || (len < 5) ) return;	/* no extension */	
+
+	/* bits 33 to 40 */
+	offset += 1;
+	octet = tvb_get_guint8(tvb, offset);
+
+	proto_tree_add_boolean(tree, hf_t30_fif_fvc, tvb, offset, 1, octet);
+    if (dis_dtc) {
+		proto_tree_add_boolean(tree, hf_t30_fif_mspc, tvb, offset, 1, octet);
+		proto_tree_add_boolean(tree, hf_t30_fif_ps, tvb, offset, 1, octet);
+	}
+	proto_tree_add_boolean(tree, hf_t30_fif_t43, tvb, offset, 1, octet);
+    proto_tree_add_boolean(tree, hf_t30_fif_pi, tvb, offset, 1, octet);
+    proto_tree_add_boolean(tree, hf_t30_fif_vc32k, tvb, offset, 1, octet);
+    proto_tree_add_boolean(tree, hf_t30_fif_ext, tvb, offset, 1, octet);
+
+	if ( !(octet & 0x01) || (len < 6) ) return;	/* no extension */	
+
+	/* bits 41 to 48 */
+	offset += 1;
+	octet = tvb_get_guint8(tvb, offset);
+
+	proto_tree_add_boolean(tree, hf_t30_fif_r8x15, tvb, offset, 1, octet);
+	proto_tree_add_boolean(tree, hf_t30_fif_300x300, tvb, offset, 1, octet);
+    proto_tree_add_boolean(tree, hf_t30_fif_r16x15, tvb, offset, 1, octet);
+	if (dis_dtc) {
+	    proto_tree_add_boolean(tree, hf_t30_fif_ibrp, tvb, offset, 1, octet);
+		proto_tree_add_boolean(tree, hf_t30_fif_mbrp, tvb, offset, 1, octet);
+		proto_tree_add_boolean(tree, hf_t30_fif_msltchr, tvb, offset, 1, octet);
+		proto_tree_add_boolean(tree, hf_t30_fif_sp, tvb, offset, 1, octet);
+	} else {
+	    proto_tree_add_boolean(tree, hf_t30_fif_rts, tvb, offset, 1, octet);
+	}
+    proto_tree_add_boolean(tree, hf_t30_fif_ext, tvb, offset, 1, octet);
+
+	if ( !(octet & 0x01) || (len < 7) ) return;	/* no extension */	
+
+	/* bits 49 to 56 */
+	offset += 1;
+	octet = tvb_get_guint8(tvb, offset);
+
+	proto_tree_add_boolean(tree, hf_t30_fif_sc, tvb, offset, 1, octet);
+	if (dis_dtc) {
+		proto_tree_add_boolean(tree, hf_t30_fif_passw, tvb, offset, 1, octet);
+		proto_tree_add_boolean(tree, hf_t30_fif_rttd, tvb, offset, 1, octet);
+	} else {
+		proto_tree_add_boolean(tree, hf_t30_fif_sit, tvb, offset, 1, octet);
+    }
+    proto_tree_add_boolean(tree, hf_t30_fif_bft, tvb, offset, 1, octet);
+	proto_tree_add_boolean(tree, hf_t30_fif_dtm, tvb, offset, 1, octet);
+    proto_tree_add_boolean(tree, hf_t30_fif_edi, tvb, offset, 1, octet);
+    proto_tree_add_boolean(tree, hf_t30_fif_ext, tvb, offset, 1, octet);
+
+	if ( !(octet & 0x01) || (len < 8) ) return;	/* no extension */	
+
+	/* bits 57 to 64 */
+	offset += 1;
+	octet = tvb_get_guint8(tvb, offset);
+
+    proto_tree_add_boolean(tree, hf_t30_fif_btm, tvb, offset, 1, octet);
+    if (dis_dtc) proto_tree_add_boolean(tree, hf_t30_fif_rttcmmd, tvb, offset, 1, octet);
+	proto_tree_add_boolean(tree, hf_t30_fif_chrm, tvb, offset, 1, octet);
+    proto_tree_add_boolean(tree, hf_t30_fif_mm, tvb, offset, 1, octet);
+    proto_tree_add_boolean(tree, hf_t30_fif_ext, tvb, offset, 1, octet);
+
+	if ( !(octet & 0x01) || (len < 9) ) return;	/* no extension */	
+
+	/* bits 65 to 72 */
+	offset += 1;
+	octet = tvb_get_guint8(tvb, offset);
+
+	proto_tree_add_boolean(tree, hf_t30_fif_pm26, tvb, offset, 1, octet);
+	proto_tree_add_boolean(tree, hf_t30_fif_dnc, tvb, offset, 1, octet);
+    proto_tree_add_boolean(tree, hf_t30_fif_do, tvb, offset, 1, octet);
+    proto_tree_add_boolean(tree, hf_t30_fif_jpeg, tvb, offset, 1, octet);
+	proto_tree_add_boolean(tree, hf_t30_fif_fcm, tvb, offset, 1, octet);
+	if (!dis_dtc) proto_tree_add_boolean(tree, hf_t30_fif_pht, tvb, offset, 1, octet);
+    proto_tree_add_boolean(tree, hf_t30_fif_12c, tvb, offset, 1, octet);
+    proto_tree_add_boolean(tree, hf_t30_fif_ext, tvb, offset, 1, octet);
+
+	if ( !(octet & 0x01) || (len < 10) ) return;	/* no extension */	
+
+	/* bits 73 to 80 */
+	offset += 1;
+	octet = tvb_get_guint8(tvb, offset);
+
+	proto_tree_add_boolean(tree, hf_t30_fif_ns, tvb, offset, 1, octet);
+	proto_tree_add_boolean(tree, hf_t30_fif_ci, tvb, offset, 1, octet);
+	proto_tree_add_boolean(tree, hf_t30_fif_cgr, tvb, offset, 1, octet);
+    proto_tree_add_boolean(tree, hf_t30_fif_nalet, tvb, offset, 1, octet);
+    proto_tree_add_boolean(tree, hf_t30_fif_naleg, tvb, offset, 1, octet);
+	proto_tree_add_boolean(tree, hf_t30_fif_spscb, tvb, offset, 1, octet);
+    proto_tree_add_boolean(tree, hf_t30_fif_spsco, tvb, offset, 1, octet);
+    proto_tree_add_boolean(tree, hf_t30_fif_ext, tvb, offset, 1, octet);
+
+	if ( !(octet & 0x01) || (len < 11) ) return;	/* no extension */	
+
+	/* bits 81 to 88 */
+	offset += 1;
+	octet = tvb_get_guint8(tvb, offset);
+
+	proto_tree_add_boolean(tree, hf_t30_fif_hkm, tvb, offset, 1, octet);
+	proto_tree_add_boolean(tree, hf_t30_fif_rsa, tvb, offset, 1, octet);
+	proto_tree_add_boolean(tree, hf_t30_fif_oc, tvb, offset, 1, octet);
+    proto_tree_add_boolean(tree, hf_t30_fif_hfx40, tvb, offset, 1, octet);
+    proto_tree_add_boolean(tree, hf_t30_fif_acn2c, tvb, offset, 1, octet);
+	proto_tree_add_boolean(tree, hf_t30_fif_acn3c, tvb, offset, 1, octet);
+    proto_tree_add_boolean(tree, hf_t30_fif_hfx40i, tvb, offset, 1, octet);
+    proto_tree_add_boolean(tree, hf_t30_fif_ext, tvb, offset, 1, octet);
+
+	if ( !(octet & 0x01) || (len < 12) ) return;	/* no extension */	
+
+	/* bits 89 to 96 */
+	offset += 1;
+	octet = tvb_get_guint8(tvb, offset);
+
+	proto_tree_add_boolean(tree, hf_t30_fif_ahsn2, tvb, offset, 1, octet);
+	proto_tree_add_boolean(tree, hf_t30_fif_ahsn3, tvb, offset, 1, octet);
+    proto_tree_add_boolean(tree, hf_t30_fif_t441, tvb, offset, 1, octet);
+    proto_tree_add_boolean(tree, hf_t30_fif_t442, tvb, offset, 1, octet);
+	proto_tree_add_boolean(tree, hf_t30_fif_t443, tvb, offset, 1, octet);
+    proto_tree_add_boolean(tree, hf_t30_fif_plmss, tvb, offset, 1, octet);
+    proto_tree_add_boolean(tree, hf_t30_fif_ext, tvb, offset, 1, octet);
+
+	if ( !(octet & 0x01) || (len < 13) ) return;	/* no extension */	
+
+	/* bits 97 to 104 */
+	offset += 1;
+	octet = tvb_get_guint8(tvb, offset);
+
+	proto_tree_add_boolean(tree, hf_t30_fif_cg300, tvb, offset, 1, octet);
+	proto_tree_add_boolean(tree, hf_t30_fif_100x100cg, tvb, offset, 1, octet);
+    proto_tree_add_boolean(tree, hf_t30_fif_spcbft, tvb, offset, 1, octet);
+    if (dis_dtc) {
+		proto_tree_add_boolean(tree, hf_t30_fif_ebft, tvb, offset, 1, octet);
+		proto_tree_add_boolean(tree, hf_t30_fif_isp, tvb, offset, 1, octet);
+	}
+    proto_tree_add_boolean(tree, hf_t30_fif_ira, tvb, offset, 1, octet);
+    proto_tree_add_boolean(tree, hf_t30_fif_ext, tvb, offset, 1, octet);
+
+	if ( !(octet & 0x01) || (len < 14) ) return;	/* no extension */	
+
+	/* bits 105 to 112 */
+	offset += 1;
+	octet = tvb_get_guint8(tvb, offset);
+
+	proto_tree_add_boolean(tree, hf_t30_fif_600x600, tvb, offset, 1, octet);
+	proto_tree_add_boolean(tree, hf_t30_fif_1200x1200, tvb, offset, 1, octet);
+	proto_tree_add_boolean(tree, hf_t30_fif_300x600, tvb, offset, 1, octet);
+    proto_tree_add_boolean(tree, hf_t30_fif_400x800, tvb, offset, 1, octet);
+    proto_tree_add_boolean(tree, hf_t30_fif_600x1200, tvb, offset, 1, octet);
+	proto_tree_add_boolean(tree, hf_t30_fif_cg600x600, tvb, offset, 1, octet);
+    proto_tree_add_boolean(tree, hf_t30_fif_cg1200x1200, tvb, offset, 1, octet);
+    proto_tree_add_boolean(tree, hf_t30_fif_ext, tvb, offset, 1, octet);
+
+	if ( !(octet & 0x01) || (len < 15) ) return;	/* no extension */	
+
+	/* bits 113 to 120 */
+	offset += 1;
+	octet = tvb_get_guint8(tvb, offset);
+
+	proto_tree_add_boolean(tree, hf_t30_fif_dspcam, tvb, offset, 1, octet);
+    proto_tree_add_boolean(tree, hf_t30_fif_dspccm, tvb, offset, 1, octet);
+    if (dis_dtc) proto_tree_add_boolean(tree, hf_t30_fif_bwmrcp, tvb, offset, 1, octet);
+    proto_tree_add_boolean(tree, hf_t30_fif_t45, tvb, offset, 1, octet);
+	proto_tree_add_uint(tree, hf_t30_fif_sdmc, tvb, offset, 1, octet);
+	proto_tree_add_boolean(tree, hf_t30_fif_ext, tvb, offset, 1, octet);
+
+	if ( !(octet & 0x01) ) return;	/* no extension */	
+	
+}
+
+static int
+dissect_t30_hdlc(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+{
+	proto_item *it;
+	proto_tree *tr;
+	proto_tree *tr_fif;
+	proto_item *it_fcf;
+	guint8 octet;
+	guint32	frag_len;
+	proto_item *item;
+
+	if (tvb_reported_length_remaining(tvb, offset) < 3) {
+		proto_tree_add_text(tree, tvb, offset, tvb_reported_length_remaining(tvb, offset), "[MALFORMED OR SHORT PACKET: hdlc T30 length must be at least 4 bytes]");
+		expert_add_info_format(pinfo, NULL, PI_MALFORMED, PI_ERROR, "T30 length must be at least 4 bytes");
+		if (check_col(pinfo->cinfo, COL_INFO))
+			col_append_str(pinfo->cinfo, COL_INFO, " (HDLC Reassembled: [MALFORMED OR SHORT PACKET])");				
+		return offset;
+	}
+
+/*	if (tree) {
+		proto_item *item;*/
+		if (check_col(pinfo->cinfo, COL_INFO))
+			col_append_str(pinfo->cinfo, COL_INFO, " (HDLC Reassembled:");				
+
+		it=proto_tree_add_protocol_format(tree, proto_t30, tvb, offset, -1,
+	    "ITU-T Recommendation T.30");
+		tr=proto_item_add_subtree(it, ett_t30);
+
+		octet = tvb_get_guint8(tvb, offset);
+		item = proto_tree_add_uint(tr, hf_t30_Address, tvb, offset, 1, octet);
+		if (octet != 0xFF) expert_add_info_format(pinfo, item, PI_REASSEMBLE, PI_WARN, "T30 Address must be 0xFF");
+		offset += 1;
+
+		octet = tvb_get_guint8(tvb, offset);
+		item = proto_tree_add_uint(tr, hf_t30_Control, tvb, offset, 1, octet);
+		if ((octet != 0xC0) && (octet != 0xC8)) expert_add_info_format(pinfo, item, PI_REASSEMBLE, PI_WARN, "T30 Control Field must be 0xC0 or 0xC8");
+		offset += 1;
+
+		octet = tvb_get_guint8(tvb, offset);
+		it_fcf = proto_tree_add_uint(tr, hf_t30_Facsimile_Control, tvb, offset, 1, octet & 0x7F);
+		offset += 1;
+
+		tr_fif = proto_item_add_subtree(it_fcf, ett_t30_fif);
+
+		frag_len = tvb_length_remaining(tvb, offset);
+		t38_info->t30_Facsimile_Control = octet;
+
+		if (check_col(pinfo->cinfo, COL_INFO))
+			col_append_fstr(pinfo->cinfo, COL_INFO, " %s - %s", val_to_str(octet & 0x7F, t30_facsimile_control_field_vals_short, "<unknown>"),
+				val_to_str(octet & 0x7F, t30_facsimile_control_field_vals, "<unknown>") );	
+
+		switch (octet & 0x7F) {
+		case T30_FC_DIS:
+		case T30_FC_DTC:
+			dissect_t30_dis_dtc(tvb, offset, pinfo, frag_len, tr_fif, TRUE);
+			break;
+		case T30_FC_DCS:
+			dissect_t30_dis_dtc(tvb, offset, pinfo, frag_len, tr_fif, FALSE);
+			break;
+		case T30_FC_CSI:
+		case T30_FC_CIG:
+		case T30_FC_TSI:
+		case T30_FC_PWD:
+		case T30_FC_SEP:
+		case T30_FC_SUB:
+		case T30_FC_SID:
+		case T30_FC_PSA:
+			dissect_t30_numbers(tvb, offset, pinfo, frag_len, tr_fif);
+			break;
+		case T30_FC_NSF:
+		case T30_FC_NSC:
+		case T30_FC_NSS:
+			dissect_t30_non_standard_cap(tvb, offset, pinfo, frag_len, tr_fif);
+			break;
+		case T30_FC_FCD:
+			dissect_t30_facsimile_coded_data(tvb, offset, pinfo, frag_len, tr_fif);
+			break;
+		case T30_FC_PPS:
+			dissect_t30_partial_page_signal(tvb, offset, pinfo, frag_len, tr_fif);
+			break;
+		}
+
+		if (check_col(pinfo->cinfo, COL_INFO))
+			col_append_str(pinfo->cinfo, COL_INFO, ")");				
+
+/*	}*/
+	
+	return offset;
+}
+
+
+/* T38 Routines */
+
+static int
 dissect_t38_NULL(tvbuff_t *tvb _U_, int offset, packet_info *pinfo _U_, proto_tree *tree _U_)
 {
 	return offset;
@@ -377,7 +1368,7 @@
 	{ 0, NULL, 0, NULL }
 };
 
-static const value_string data_vals[] = {
+const value_string t30_data_vals[] = {
 	{ 0, "v21" },
 	{ 1, "v27-2400" },
 	{ 2, "v27-4800" },
@@ -405,7 +1396,7 @@
 
     if (check_col(pinfo->cinfo, COL_INFO) && primary_part){
         col_append_fstr(pinfo->cinfo, COL_INFO, " data:%s:",
-         val_to_str(Data_value,data_vals,"<unknown>"));
+         val_to_str(Data_value,t30_data_vals,"<unknown>"));
 	}
 
 	
@@ -512,6 +1503,110 @@
 	{ 0, NULL },
 };
 
+fragment_data *
+force_reassmeble_seq(tvbuff_t *tvb, int offset, packet_info *pinfo, guint32 id,
+	     GHashTable *fragment_table, guint32 frag_number)
+{
+	fragment_key key;
+	fragment_data *fd_head;
+
+	fragment_data *fd;
+	fragment_data *fd_i;
+	fragment_data *last_fd;
+	guint32 dfpos, size, packet_lost, burst_lost, seq_num;
+
+	/* create key to search hash with */
+	key.src = pinfo->src;
+	key.dst = pinfo->dst;
+	key.id  = id;
+
+	fd_head = g_hash_table_lookup(fragment_table, &key);
+
+	/* 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;
+	}
+	fd_head->data = g_malloc(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){
+	      memcpy(fd_head->data+dfpos,fd_i->data,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->datalen)
+		  || memcmp(last_fd->data, fd_i->data, last_fd->len) ){
+			fd->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->data){
+	    g_free(fd_i->data);
+	    fd_i->data=NULL;
+	  }
+	}
+
+	/* mark this packet as defragmented */
+	fd_head->flags |= FD_DEFRAGMENTED;
+	fd_head->reassembled_in=pinfo->fd->num;
+
+	if (check_col(pinfo->cinfo, COL_INFO))
+			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;
+}
+
 static int
 dissect_t38_Data_Field_field_type(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
 {
@@ -531,16 +1626,78 @@
          val_to_str(Data_Field_field_type_value,Data_Field_field_type_vals,"<unknown>"));
 	}
 
-	/* info for tap */
-	if (primary_part) {
-		if ( (t38_info->t38_info_data_item_index < MAX_T38_DATA_ITEMS) && (t38_info->t38_info_data_item_index >= 0) ){ /*sanity check */
-			t38_info->data_type[t38_info->t38_info_data_item_index] = Data_Field_field_type_value;
+	/* 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_data *frag_msg = NULL;
+			tvbuff_t* new_tvb = NULL;
+			gboolean save_fragmented = pinfo->fragmented;
 
-			if (t38_info->t38_info_data_item_index++ == MAX_T38_DATA_ITEMS-1) t38_info->t38_info_data_item_index = 1;
+			pinfo->fragmented = TRUE;
+
+			frag_msg = fragment_add_seq(tvb, offset, pinfo,
+				p_t38_packet_conv_info->reass_ID, /* ID for fragments belonging together */
+				data_fragment_table, /* list of message fragments */
+				seq_number + Data_Field_item_num - (guint32)p_t38_packet_conv_info->reass_start_seqnum,  /* fragment sequence number */
+				/*0,*/
+				0, /* fragment length */
+				FALSE); /* More fragments */
+
+			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_reassmeble_seq(tvb, offset, pinfo,
+						p_t38_packet_conv_info->reass_ID, /* ID for fragments belonging together */
+						data_fragment_table, /* list of message fragments */
+						seq_number + Data_Field_item_num - (guint32)p_t38_packet_conv_info->reass_start_seqnum);  /* fragment sequence number */
+				} else {
+					if (check_col(pinfo->cinfo, COL_INFO))
+						col_append_str(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");
+				}
+
+				new_tvb = process_reassembled_data(tvb, offset, pinfo,
+							"Reassembled Message", frag_msg, &data_frag_items, NULL, tree);
+
+				/* Now reset fragmentation information in pinfo */
+				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, pinfo,
+							"Reassembled Message", frag_msg, &data_frag_items, NULL, tree);
+
+				/* Now reset fragmentation information in pinfo */
+				pinfo->fragmented = save_fragmented;
+
+				if (new_tvb) dissect_t30_hdlc(new_tvb, 0, pinfo, tree); 
+			}
 		}
+
+		/* 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;
+		}
+		t38_info->Data_Field_field_type_value = Data_Field_field_type_value;
 	}
-
-
     return offset;
 }
 
@@ -566,12 +1723,53 @@
         }
 	}
 
+	/* 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)) {
+		tvbuff_t* new_tvb = NULL;
+		fragment_data *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 = pinfo->fragmented;
 
-	/* info for tap */
-	if (primary_part) {
-		if ( (t38_info->t38_info_data_item_index <= MAX_T38_DATA_ITEMS) && (t38_info->t38_info_data_item_index > 0) ){ /*sanity check */
-			t38_info->data_len[t38_info->t38_info_data_item_index-1] = value_len;
-			t38_info->data[t38_info->t38_info_data_item_index-1] = tvb_memdup(value_tvb,0,value_len);
+			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 = pinfo->fd->num;
+					p_t38_conv_info->reass_start_seqnum = seq_number;
+					p_t38_conv_info->time_first_t4_data = nstime_to_sec(&pinfo->fd->rel_ts);
+					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->time_first_t4_data = p_t38_conv_info->time_first_t4_data;
+			}
+
+			frag_msg = fragment_add_seq(value_tvb, 0, pinfo,
+				p_t38_packet_conv_info->reass_ID, /* ID for fragments belonging together */
+				data_fragment_table, /* list of message fragments */
+				seq_number - (guint32)p_t38_packet_conv_info->reass_start_seqnum, /* fragment sequence number */
+				value_len, /* fragment length */
+				TRUE); /* More fragments */
+
+			new_tvb = process_reassembled_data(tvb, offset, pinfo,
+						"Reassembled Message", frag_msg, &data_frag_items, NULL, tree);
+
+			if (!frag_msg) { /* Not last packet of reassembled */
+				if (Data_Field_field_type_value == 0) {
+					if (check_col(pinfo->cinfo, COL_INFO))
+						col_append_fstr(pinfo->cinfo, COL_INFO," (HDLC fragment %u)", seq_number - (guint32)p_t38_packet_conv_info->reass_start_seqnum);
+				} else {
+					if (check_col(pinfo->cinfo, COL_INFO))
+						col_append_fstr(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 */
+			pinfo->fragmented = save_fragmented;
 		}
 	}
 
@@ -592,6 +1790,9 @@
 	offset=dissect_per_sequence(tvb, offset, pinfo,
         tree, hf_t38_Data_Field_item, ett_t38_Data_Field_item,
         Data_Field_item_sequence);
+
+	if (primary_part) Data_Field_item_num++;
+
 	return offset;
 }
 
@@ -646,11 +1847,19 @@
 dissect_t38_primary_ifp_packet(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
 {
     guint32 length;
+
 	primary_part = TRUE;
 
     offset=dissect_per_length_determinant(tvb, offset, pinfo,
         tree, hf_t38_primary_ifp_packet_length, &length);
     offset=dissect_t38_IFPPacket(tvb, offset, pinfo, tree);
+
+	/* if is a valid t38 packet, add to tap */
+	if (p_t38_packet_conv && (!pinfo->in_error_pkt) && ((gint32) seq_number != p_t38_packet_conv_info->last_seqnum))
+		tap_queue_packet(t38_tap, pinfo, t38_info);
+
+	if (p_t38_conv) p_t38_conv_info->last_seqnum = (gint32) seq_number;
+
 	return offset;
 }
 
@@ -792,22 +2001,6 @@
 	guint32 offset=0;
 	int i;
 
-	/* tap info */
-	t38_info = ep_alloc(sizeof(t38_packet_info));
-
-	t38_info->seq_num = 0;
-	t38_info->type_msg = 0;
-	t38_info->data_value = 0;
-	t38_info->t30ind_value =0;
-
-	t38_info->t38_info_data_item_index = 0;
-	for (i=0; i<MAX_T38_DATA_ITEMS; i++) {
-		t38_info->data_type[i] = 0;
-		t38_info->data[i] = NULL;
-		t38_info->data_len[i] = 0;
-	}
-
-
 	/*
 	 * XXX - heuristic to check for misidentified packets.
 	 */
@@ -819,6 +2012,24 @@
 		}
 	}
 
+	/* 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;
+
 	if (check_col(pinfo->cinfo, COL_PROTOCOL)){
 		col_set_str(pinfo->cinfo, COL_PROTOCOL, "T.38");
 	}
@@ -828,16 +2039,95 @@
 
 	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);
 
-        /* Conversation setup info */
-        if (global_t38_show_setup_info)
-        {
-                show_setup_info(tvb, pinfo, tr);
-        }
+	/* 
+		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 = p_get_proto_data(pinfo->fd, proto_t38);
+
+
+	/* find the conversation used for Reassemble and Setup Info */
+	p_conv = find_conversation(pinfo->fd->num, &pinfo->net_src, &pinfo->net_dst,
+                                   pinfo->ptype,
+                                   pinfo->srcport, pinfo->destport, NO_ADDR_B | NO_PORT_B);
+
+	/* create a conv if it doen't exist */
+	if (!p_conv) {
+		p_conv = conversation_new(pinfo->fd->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);
+	}
+
+	if (!p_t38_packet_conv) {
+		p_t38_conv = conversation_get_proto_data(p_conv, proto_t38);
+
+		/* create the conversation if it doen't exist */
+		if (!p_t38_conv) {
+			p_t38_conv = se_alloc(sizeof(t38_conv));
+			p_t38_conv->setup_method[0] = NULL;
+	        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->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;
+
+			conversation_add_proto_data(p_conv, proto_t38, p_t38_conv);
+		}
+
+		/* copy the t38 conversation info to the packet t38 conversation */
+		p_t38_packet_conv = se_alloc(sizeof(t38_conv));
+		strcpy(p_t38_packet_conv->setup_method, p_t38_conv->setup_method);
+	    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(pinfo->fd, proto_t38, 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);
+	}
+
+    /* Show Conversation setup info if exists*/
+    if (global_t38_show_setup_info) {
+		show_setup_info(tvb, pinfo, tr, p_conv, p_t38_packet_conv);
+	}
+
+	/* update t38_info */
+	t38_info->setup_frame_number = p_t38_packet_conv->setup_frame_number;
+
 	if (check_col(pinfo->cinfo, COL_INFO)){
 		col_append_fstr(pinfo->cinfo, COL_INFO, "UDP: UDPTLPacket ");
 	}
@@ -856,18 +2146,6 @@
 			col_append_fstr(pinfo->cinfo, COL_INFO, " [Malformed?]");
 		}
 	}
-	
-	/* if is a valid t38 packet, add to tap */
-	if (!pinfo->in_error_pkt)
-		tap_queue_packet(t38_tap, pinfo, t38_info);
-	else { /* if not, free the data */
-		for (i=0; i<MAX_T38_DATA_ITEMS; i++) {
-			t38_info->data_type[i] = 0;
-			g_free(t38_info->data[i]);
-			t38_info->data[i] = NULL;
-			t38_info->data_len[i] = 0;
-		}
-	}
 }
 
 static void
@@ -880,21 +2158,23 @@
 	int i;
 
 	/* tap info */
-	t38_info = ep_alloc(sizeof(t38_packet_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;
 
-	t38_info->t38_info_data_item_index = 0;
-	for (i=0; i<MAX_T38_DATA_ITEMS; i++) {
-		t38_info->data_type[i] = 0;
-		t38_info->data[i] = NULL;
-		t38_info->data_len[i] = 0;
-	}
-
-
 	if (check_col(pinfo->cinfo, COL_PROTOCOL)){
 		col_set_str(pinfo->cinfo, COL_PROTOCOL, "T.38");
 	}
@@ -970,60 +2250,33 @@
 }
 
 /* Look for conversation info and display any setup info found */
-void show_setup_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
+void show_setup_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, conversation_t *p_conv, t38_conv *p_t38_conv)
 {
-        /* Conversation and current data */
-        conversation_t *p_conv = NULL;
-        struct _t38_conversation_info *p_conv_data = NULL;
+	proto_tree *t38_setup_tree;
+	proto_item *ti;
 
-        /* Use existing packet info if available */
-        p_conv_data = p_get_proto_data(pinfo->fd, proto_t38);
+	if (!p_t38_conv || p_t38_conv->setup_frame_number == 0) {
+		/* there is no Setup info */
+		return;
+	}
 
-        if (!p_conv_data)
-        {
-                /* First time, get info from conversation */
-                p_conv = find_conversation(pinfo->fd->num, &pinfo->net_src, &pinfo->net_dst,
-                                   pinfo->ptype,
-                                   pinfo->srcport, pinfo->destport, NO_ADDR_B);
-                if (p_conv)
-                {
-                        /* Create space for packet info */
-                        struct _t38_conversation_info *p_conv_packet_data;
-                        p_conv_data = conversation_get_proto_data(p_conv, proto_t38);
-
-                        if (p_conv_data) {
-                                /* Save this conversation info into packet info */
-                                p_conv_packet_data = se_alloc(sizeof(struct _t38_conversation_info));
-                                g_snprintf(p_conv_packet_data->method, MAX_T38_SETUP_METHOD_SIZE, "%s", p_conv_data->method);
-				p_conv_packet_data->method[MAX_T38_SETUP_METHOD_SIZE]=0;
-                                p_conv_packet_data->frame_number = p_conv_data->frame_number;
-                                p_add_proto_data(pinfo->fd, proto_t38, p_conv_packet_data);
-                        }
-                }
-        }
-
-        /* Create setup info subtree with summary info. */
-        if (p_conv_data)
-        {
-                proto_tree *t38_setup_tree;
-                proto_item *ti =  proto_tree_add_string_format(tree, hf_t38_setup, tvb, 0, 0,
-                                                               "",
-                                                               "Stream setup by %s (frame %u)",
-                                                               p_conv_data->method,
-                                                               p_conv_data->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_conv_data->frame_number);
-                        PROTO_ITEM_SET_GENERATED(item);
-                        item = proto_tree_add_string(t38_setup_tree, hf_t38_setup_method,
-                                                     tvb, 0, 0, p_conv_data->method);
-                        PROTO_ITEM_SET_GENERATED(item);
-                }
-        }
+	ti =  proto_tree_add_string_format(tree, hf_t38_setup, tvb, 0, 0,
+                      "",
+                      "Stream setup by %s (frame %u)",
+                      p_t38_conv->setup_method,
+                      p_t38_conv->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_conv->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_conv->setup_method);
+		PROTO_ITEM_SET_GENERATED(item);
+    }
 }
 
 
@@ -1045,7 +2298,7 @@
               VALS(t30_indicator_vals), 0, "t30_indicator", HFILL }},
         {  &hf_t38_data,
             { "data", "t38.t38_data", FT_UINT32, BASE_DEC,
-              VALS(data_vals), 0, "data", HFILL }},
+              VALS(t30_data_vals), 0, "data", HFILL }},
         {  &hf_t38_Data_Field,
             { "Data Field", "t38.Data_Field", FT_NONE, BASE_NONE,
               NULL, 0, "Data_Field sequence of", HFILL }},
@@ -1094,16 +2347,42 @@
         {  &hf_t38_fec_data_item,
             { "t38_fec_data_item", "t38.t38_fec_data_item", FT_BYTES, BASE_HEX,
             NULL, 0, "t38_fec_data_item octet string", HFILL }},
-	{   &hf_t38_setup,
-	    { "Stream setup", "t38.setup", FT_STRING, BASE_NONE,
-	    NULL, 0x0, "Stream setup, method and frame number", HFILL }},
-	{   &hf_t38_setup_frame,
+		{   &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_data_fragments,
+			{"Message fragments", "data.fragments",
+			FT_NONE, BASE_NONE, NULL, 0x00,	NULL, HFILL } },
+		{&hf_data_fragment,
+			{"Message fragment", "data.fragment",
+			FT_FRAMENUM, BASE_NONE, NULL, 0x00, NULL, HFILL } },
+		{&hf_data_fragment_overlap,
+			{"Message fragment overlap", "data.fragment.overlap",
+			FT_BOOLEAN, BASE_NONE, NULL, 0x00, NULL, HFILL } },
+		{&hf_data_fragment_overlap_conflicts,
+			{"Message fragment overlapping with conflicting data",
+			"data.fragment.overlap.conflicts",
+			FT_BOOLEAN, BASE_NONE, NULL, 0x00, NULL, HFILL } },
+		{&hf_data_fragment_multiple_tails,
+			{"Message has multiple tail fragments",
+			"data.fragment.multiple_tails", 
+			FT_BOOLEAN, BASE_NONE, NULL, 0x00, NULL, HFILL } },
+		{&hf_data_fragment_too_long_fragment,
+			{"Message fragment too long", "data.fragment.too_long_fragment",
+			FT_BOOLEAN, BASE_NONE, NULL, 0x00, NULL, HFILL } },
+		{&hf_data_fragment_error,
+			{"Message defragmentation error", "data.fragment.error",
+			FT_FRAMENUM, BASE_NONE, NULL, 0x00, NULL, HFILL } },
+		{&hf_data_reassembled_in,
+			{"Reassembled in", "data.reassembled.in",
+			FT_FRAMENUM, BASE_NONE, NULL, 0x00, NULL, HFILL } },
+	};
 
 	static gint *ett[] =
 	{
@@ -1121,7 +2400,349 @@
 		&ett_t38_fec_info,
 		&ett_t38_fec_data,
 		&ett_t38_setup,
+		&ett_data_fragment,
+		&ett_data_fragments
 	};
+
+	static hf_register_info hf_t30[] =
+	{
+        {  &hf_t30_Address,
+            { "Address", "t30.Address", FT_UINT8, BASE_HEX,
+		      NULL, 0, "Address Field", HFILL }},
+        {  &hf_t30_Control,
+            { "Control", "t30.Control", FT_UINT8, BASE_HEX,
+		      VALS(t30_control_vals), 0, "Address Field", HFILL }},
+        {  &hf_t30_Facsimile_Control,
+            { "Facsimile Control", "t30.FacsimileControl", FT_UINT8, BASE_DEC,
+		      VALS(t30_facsimile_control_field_vals), 0, "Facsimile Control", HFILL }},
+
+		{  &hf_t30_fif_sm,
+            { "Store and forward Internet fax- Simple mode (ITU-T T.37)", "t30.fif.sm", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x80, "", HFILL }},
+		{  &hf_t30_fif_rtif,
+            { "Real-time Internet fax (ITU T T.38)", "t30.fif.rtif", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x20, "", HFILL }},
+		{  &hf_t30_fif_3gmn,
+            { "3rd Generation Mobile Network", "t30.fif.3gmn", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x10, "", HFILL }},
+		{  &hf_t30_fif_v8c,
+            { "V.8 capabilities", "t30.fif.v8c", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x04, "", HFILL }},
+		{  &hf_t30_fif_op,
+            { "Octets preferred", "t30.fif.op", FT_BOOLEAN,  8,
+			  TFS(&t30_octets_preferred_value), 0x02, "", HFILL }},
+		{  &hf_t30_fif_rtfc,
+            { "Ready to transmit a facsimile document (polling)", "t30.fif.rtfc", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x80, "", HFILL }},
+		{  &hf_t30_fif_rfo,
+            { "Receiver fax operation", "t30.fif.rfo", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x40, "", HFILL }},
+		{  &hf_t30_fif_dsr,
+            { "Data signalling rate", "t30.fif.dsr", FT_UINT8,  BASE_HEX,
+			  VALS(t30_data_signalling_rate_vals), 0x3C, "", HFILL }},
+		{  &hf_t30_fif_dsr_dcs,
+            { "Data signalling rate", "t30.fif.dsr_dcs", FT_UINT8,  BASE_HEX,
+			  VALS(t30_data_signalling_rate_dcs_vals), 0x3C, "", HFILL }},
+		{  &hf_t30_fif_res,
+            { "R8x7.7 lines/mm and/or 200x200 pels/25.4 mm", "t30.fif.res", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x02, "", HFILL }},
+		{  &hf_t30_fif_tdcc,
+            { "Two dimensional coding capability", "t30.fif.tdcc", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x01, "", HFILL }},
+		{  &hf_t30_fif_rwc,
+            { "Recording width capabilities", "t30.fif.rwc", FT_UINT8,  BASE_HEX,
+			  VALS(t30_recording_width_capabilities_vals), 0xC0, "", HFILL }},
+		{  &hf_t30_fif_rw_dcs,
+            { "Recording width", "t30.fif.rw_dcs", FT_UINT8,  BASE_HEX,
+			  VALS(t30_recording_width_dcs_vals), 0xC0, "", HFILL }},
+		{  &hf_t30_fif_rlc,
+            { "Recording length capability", "t30.fif.rlc", FT_UINT8,  BASE_HEX,
+			  VALS(t30_recording_length_capability_vals), 0x30, "", HFILL }},
+		{  &hf_t30_fif_rl_dcs,
+            { "Recording length capability", "t30.fif.rl_dcs", FT_UINT8,  BASE_HEX,
+			  VALS(t30_recording_length_dcs_vals), 0x30, "", HFILL }},
+		{  &hf_t30_fif_msltcr,
+            { "Minimum scan line time capability at the receiver", "t30.fif.msltcr", FT_UINT8,  BASE_HEX,
+			  VALS(t30_minimum_scan_line_time_rec_vals), 0x0E, "", HFILL }},
+		{  &hf_t30_fif_mslt_dcs,
+            { "Minimum scan line time", "t30.fif.mslt_dcs", FT_UINT8,  BASE_HEX,
+			  VALS(t30_minimum_scan_line_time_dcs_vals), 0x0E, "", HFILL }},
+		{  &hf_t30_fif_ext,
+            { "Extension indicator", "t30.fif.ext", FT_BOOLEAN,  8,
+			  TFS(&t30_extension_ind_value), 0x01, "", HFILL }},
+
+		{  &hf_t30_fif_cm,
+            { "Compress/Uncompress mode", "t30.fif.cm", FT_BOOLEAN,  8,
+			  TFS(&t30_compress_value), 0x40, "", HFILL }},
+		{  &hf_t30_fif_ecm,
+            { "Error correction mode", "t30.fif.ecm", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x20, "", HFILL }},
+		{  &hf_t30_fif_fs_dcs,
+            { "Frame size", "t30.fif.fs_dcm", FT_BOOLEAN,  8,
+			  TFS(&t30_frame_size_dcs_value), 0x10, "", HFILL }},
+		{  &hf_t30_fif_t6,
+            { "T.6 coding capability", "t30.fif.t6", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x02, "", HFILL }},
+
+		{  &hf_t30_fif_fvc,
+            { "Field valid capability", "t30.fif.fvc", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x80, "", HFILL }},
+		{  &hf_t30_fif_mspc,
+            { "Multiple selective polling capability", "t30.fif.mspc", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x40, "", HFILL }},
+		{  &hf_t30_fif_ps,
+            { "Polled Subaddress", "t30.fif.ps", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x20, "", HFILL }},
+		{  &hf_t30_fif_t43,
+            { "T.43 coding", "t30.fif.t43", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x10, "", HFILL }},
+		{  &hf_t30_fif_pi,
+            { "Plane interleave", "t30.fif.pi", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x08, "", HFILL }},
+		{  &hf_t30_fif_vc32k,
+            { "Voice coding with 32k ADPCM (ITU T G.726)", "t30.fif.vc32k", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x04, "", HFILL }},
+
+		{  &hf_t30_fif_r8x15,
+            { "R8x15.4 lines/mm", "t30.fif.r8x15", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x80, "", HFILL }},
+		{  &hf_t30_fif_300x300,
+            { "300x300 pels/25.4 mm", "t30.fif.300x300", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x40, "", HFILL }},
+		{  &hf_t30_fif_r16x15,
+            { "R16x15.4 lines/mm and/or 400x400 pels/25.4 mm", "t30.fif.r16x15", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x20, "", HFILL }},
+		{  &hf_t30_fif_ibrp,
+            { "Inch based resolution preferred", "t30.fif.ibrp", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x10, "", HFILL }},
+		{  &hf_t30_fif_mbrp,
+            { "Metric based resolution preferred", "t30.fif.mbrp", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x08, "", HFILL }},
+		{  &hf_t30_fif_msltchr,
+            { "Minimum scan line time capability for higher resolutions", "t30.fif.msltchr", FT_BOOLEAN,  8,
+			  TFS(&t30_minimum_scan_value), 0x04, "", HFILL }},
+		{  &hf_t30_fif_rts,
+            { "Resolution type selection", "t30.fif.rts", FT_BOOLEAN,  8,
+			  TFS(&t30_res_type_sel_value), 0x10, "", HFILL }},
+		{  &hf_t30_fif_sp,
+            { "Selective polling", "t30.fif.sp", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x02, "", HFILL }},
+
+		{  &hf_t30_fif_sc,
+            { "Subaddressing capability", "t30.fif.sc", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x80, "", HFILL }},
+		{  &hf_t30_fif_passw,
+            { "Password", "t30.fif.passw", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x40, "", HFILL }},
+		{  &hf_t30_fif_sit,
+            { "Sender Identification transmission", "t30.fif.sit", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x40, "", HFILL }},
+		{  &hf_t30_fif_rttd,
+            { "Ready to transmit a data file (polling)", "t30.fif.rttd", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x20, "", HFILL }},
+		{  &hf_t30_fif_bft,
+            { "Binary File Transfer (BFT)", "t30.fif.bft", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x08, "", HFILL }},
+		{  &hf_t30_fif_dtm,
+            { "Document Transfer Mode (DTM)", "t30.fif.dtm", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x04, "", HFILL }},
+		{  &hf_t30_fif_edi,
+            { "Electronic Data Interchange (EDI)", "t30.fif.edi", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x02, "", HFILL }},
+
+		{  &hf_t30_fif_btm,
+            { "Basic Transfer Mode (BTM)", "t30.fif.btm", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x80, "", HFILL }},
+		{  &hf_t30_fif_rttcmmd,
+            { "Ready to transmit a character or mixed mode document (polling)", "t30.fif.rttcmmd", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x20, "", HFILL }},
+		{  &hf_t30_fif_chrm,
+            { "Character mode", "t30.fif.cm", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x10, "", HFILL }},
+		{  &hf_t30_fif_mm,
+            { "Mixed mode (Annex E/T.4)", "t30.fif.mm", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x04, "", HFILL }},
+
+		{  &hf_t30_fif_pm26,
+            { "Processable mode 26 (ITU T T.505)", "t30.fif.pm26", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x80, "", HFILL }},
+		{  &hf_t30_fif_dnc,
+            { "Digital network capability", "t30.fif.dnc", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x40, "", HFILL }},
+		{  &hf_t30_fif_do,
+            { "Duplex operation", "t30.fif.do", FT_BOOLEAN,  8,
+			  TFS(&t30_duplex_operation_value), 0x20, "", HFILL }},
+		{  &hf_t30_fif_jpeg,
+            { "JPEG coding", "t30.fif.jpeg", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x10, "", HFILL }},
+		{  &hf_t30_fif_fcm,
+            { "Full colour mode", "t30.fif.fcm", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x08, "", HFILL }},
+		{  &hf_t30_fif_pht,
+            { "Preferred Huffman tables", "t30.fif.pht", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x08, "", HFILL }},
+		{  &hf_t30_fif_12c,
+            { "12 bits/pel component", "t30.fif.12c", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x02, "", HFILL }},
+
+		{  &hf_t30_fif_ns,
+            { "No subsampling (1:1:1)", "t30.fif.ns", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x80, "", HFILL }},
+		{  &hf_t30_fif_ci,
+            { "Custom illuminant", "t30.fif.ci", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x40, "", HFILL }},
+		{  &hf_t30_fif_cgr,
+            { "Custom gamut range", "t30.fif.cgr", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x20, "", HFILL }},
+		{  &hf_t30_fif_nalet,
+            { "North American Letter (215.9 x 279.4 mm) capability", "t30.fif.nalet", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x10, "", HFILL }},
+		{  &hf_t30_fif_naleg,
+            { "North American Legal (215.9 x 355.6 mm) capability", "t30.fif.naleg", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x08, "", HFILL }},
+		{  &hf_t30_fif_spscb,
+            { "Single-progression sequential coding (ITU-T T.85) basic capability", "t30.fif.spscb", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x04, "", HFILL }},
+		{  &hf_t30_fif_spsco,
+            { "Single-progression sequential coding (ITU-T T.85) optional L0 capability", "t30.fif.spsco", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x02, "", HFILL }},
+
+		{  &hf_t30_fif_hkm,
+            { "HKM key management capability", "t30.fif.hkm", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x80, "", HFILL }},
+		{  &hf_t30_fif_rsa,
+            { "RSA key management capability", "t30.fif.rsa", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x40, "", HFILL }},
+		{  &hf_t30_fif_oc,
+            { "Override capability", "t30.fif.oc", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x20, "", HFILL }},
+		{  &hf_t30_fif_hfx40,
+            { "HFX40 cipher capability", "t30.fif.hfx40", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x10, "", HFILL }},
+		{  &hf_t30_fif_acn2c,
+            { "Alternative cipher number 2 capability", "t30.fif.acn2c", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x08, "", HFILL }},
+		{  &hf_t30_fif_acn3c,
+            { "Alternative cipher number 3 capability", "t30.fif.acn3c", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x04, "", HFILL }},
+		{  &hf_t30_fif_hfx40i,
+            { "HFX40-I hashing capability", "t30.fif.hfx40i", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x02, "", HFILL }},
+
+		{  &hf_t30_fif_ahsn2,
+            { "Alternative hashing system number 2 capability", "t30.fif.ahsn2", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x80, "", HFILL }},
+		{  &hf_t30_fif_ahsn3,
+            { "Alternative hashing system number 3 capability", "t30.fif.ahsn3", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x40, "", HFILL }},
+		{  &hf_t30_fif_t441,
+            { "T.44 (Mixed Raster Content)", "t30.fif.t441", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x10, "", HFILL }},
+		{  &hf_t30_fif_t442,
+            { "T.44 (Mixed Raster Content)", "t30.fif.t442", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x08, "", HFILL }},
+		{  &hf_t30_fif_t443,
+            { "T.44 (Mixed Raster Content)", "t30.fif.t443", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x04, "", HFILL }},
+		{  &hf_t30_fif_plmss,
+            { "Page length maximum strip size for T.44 (Mixed Raster Content)", "t30.fif.plmss", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x02, "", HFILL }},
+
+		{  &hf_t30_fif_cg300,
+            { "Colour/gray-scale 300 pels/25.4 mm x 300 lines/25.4 mm or 400 pels/25.4 mm x 400 lines/25.4 mm resolution", "t30.fif.cg300", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x80, "", HFILL }},
+		{  &hf_t30_fif_100x100cg,
+            { "100 pels/25.4 mm x 100 lines/25.4 mm for colour/gray scale", "t30.fif.100x100cg", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x40, "", HFILL }},
+		{  &hf_t30_fif_spcbft,
+            { "Simple Phase C BFT Negotiations capability", "t30.fif.spcbft", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x20, "", HFILL }},
+		{  &hf_t30_fif_ebft,
+            { "Extended BFT Negotiations capability", "t30.fif.ebft", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x10, "", HFILL }},
+		{  &hf_t30_fif_isp,
+            { "Internet Selective Polling Address (ISP)", "t30.fif.isp", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x08, "", HFILL }},
+		{  &hf_t30_fif_ira,
+            { "Internet Routing Address (IRA)", "t30.fif.ira", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x04, "", HFILL }},
+	  
+		{  &hf_t30_fif_600x600,
+            { "600 pels/25.4 mm x 600 lines/25.4 mm", "t30.fif.600x600", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x80, "", HFILL }},
+		{  &hf_t30_fif_1200x1200,
+            { "1200 pels/25.4 mm x 1200 lines/25.4 mm", "t30.fif.1200x1200", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x40, "", HFILL }},
+		{  &hf_t30_fif_300x600,
+            { "300 pels/25.4 mm x 600 lines/25.4 mm", "t30.fif.300x600", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x20, "", HFILL }},
+		{  &hf_t30_fif_400x800,
+            { "400 pels/25.4 mm x 800 lines/25.4 mm", "t30.fif.400x800", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x10, "", HFILL }},
+		{  &hf_t30_fif_600x1200,
+            { "600 pels/25.4 mm x 1200 lines/25.4 mm", "t30.fif.600x1200", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x08, "", HFILL }},
+		{  &hf_t30_fif_cg600x600,
+            { "Colour/gray scale 600 pels/25.4 mm x 600 lines/25.4 mm resolution", "t30.fif.cg600x600", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x04, "", HFILL }},
+		{  &hf_t30_fif_cg1200x1200,
+            { "Colour/gray scale 1200 pels/25.4 mm x 1200 lines/25.4 mm resolution", "t30.fif.cg1200x1200", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x02, "", HFILL }},
+
+		{  &hf_t30_fif_dspcam,
+            { "Double sided printing capability (alternate mode)", "t30.fif.dspcam", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x80, "", HFILL }},
+		{  &hf_t30_fif_dspccm,
+            { "Double sided printing capability (continuous mode)", "t30.fif.dspccm", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x40, "", HFILL }},
+		{  &hf_t30_fif_bwmrcp,
+            { "Black and white mixed raster content profile (MRCbw)", "t30.fif.bwmrcp", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x20, "", HFILL }},
+		{  &hf_t30_fif_t45,
+            { "T.45 (run length colour encoding)", "t30.fif.t45", FT_BOOLEAN,  8,
+			  TFS(&flags_set_truth), 0x10, "", HFILL }},
+		{  &hf_t30_fif_sdmc,
+            { "SharedDataMemory capacity", "t30.fif.sdmc", FT_UINT8,  BASE_HEX,
+			  VALS(t30_SharedDataMemory_capacity_vals), 0x0C, "", HFILL }},
+
+		{ &hf_t30_fif_number,
+		  { "Number", "t30.fif.number", FT_STRING, BASE_NONE, NULL, 0x0,
+			"", HFILL }},
+
+        {  &hf_t30_fif_country_code,
+            { "ITU-T Country code", "t30.fif.country_code", FT_UINT8, BASE_DEC,
+		      NULL, 0, "ITU-T Country code", HFILL }},
+        {  &hf_t30_fif_non_stand_bytes,
+            { "Non-standard capabilities", "t30.fif.non_standard_cap", FT_BYTES, BASE_HEX,
+		      NULL, 0, "Non-standard capabilities", HFILL }},
+ 
+		{  &hf_t30_t4_frame_num,
+            { "T.4 Frame number", "t30.t4.frame_num", FT_UINT8, BASE_DEC,
+		      NULL, 0, "T.4 Frame number", HFILL }},
+        {  &hf_t30_t4_data,
+            { "T.4 Facsimile data field", "t30.t4.data", FT_BYTES, BASE_HEX,
+		      NULL, 0, "T.4 Facsimile data field", HFILL }},
+
+        {  &hf_t30_partial_page_fcf2,
+            { "Post-message command", "t30.pps.fcf2", FT_UINT8, BASE_DEC,
+		      VALS(t30_partial_page_fcf2_vals), 0, "Post-message command", HFILL }},			  
+		{  &hf_t30_partial_page_i1,
+            { "Page counter", "t30.t4.page_count", FT_UINT8, BASE_DEC,
+		      NULL, 0, "Page counter", HFILL }},
+		{  &hf_t30_partial_page_i2,
+            { "Block counter", "t30.t4.block_count", FT_UINT8, BASE_DEC,
+		      NULL, 0, "Block counter", HFILL }},
+		{  &hf_t30_partial_page_i3,
+            { "Frame counter", "t30.t4.frame_count", FT_UINT8, BASE_DEC,
+		      NULL, 0, "Frame counter", HFILL }},
+	};
+
+	static gint *t30_ett[] =
+	{
+		&ett_t30,
+		&ett_t30_fif,
+	};
+
 	module_t *t38_module;
 
 	proto_t38 = proto_register_protocol("T.38", "T.38", "t38");
@@ -1129,6 +2750,9 @@
 	proto_register_subtree_array(ett, array_length(ett));
 	register_dissector("t38", dissect_t38, proto_t38);
 
+	/* Init reassemble tables for HDLC */
+    register_init_routine(t38_defragment_init);
+
 	t38_tap = register_tap("t38");
 
 	t38_module = prefs_register_protocol(proto_t38, proto_reg_handoff_t38);
@@ -1168,6 +2792,10 @@
                 "this T.38 stream to be created",
                 &global_t38_show_setup_info);
 
+	/* T30 */
+	proto_t30 = proto_register_protocol("T.30", "T.30", "t30");
+	proto_register_field_array(proto_t30, hf_t30, array_length(hf_t30));
+	proto_register_subtree_array(t30_ett, array_length(t30_ett));
 }
 
 void
@@ -1193,3 +2821,7 @@
 
 	rtp_handle = find_dissector("rtp");
 }
+
+
+
+
Index: epan/dissectors/packet-t38.h
===================================================================
--- epan/dissectors/packet-t38.h	(revision 17031)
+++ epan/dissectors/packet-t38.h	(working copy)
@@ -26,27 +26,47 @@
  */
 
 #define MAX_T38_DATA_ITEMS 4
+#define MAX_T38_DESC 128
+
 typedef struct _t38_packet_info {
 	guint16 seq_num;	/* UDPTLPacket sequence number */
 	guint32 type_msg;	/* 0=t30-indicator    1=data */
 	guint32 t30ind_value;
 	guint32 data_value;	/* standard and speed */
-
-	int t38_info_data_item_index; /* this will have the number of Data Items in the packet and is used as the index when decoding the packet */
-	guint32 data_type[MAX_T38_DATA_ITEMS];
-	guint8 *data[MAX_T38_DATA_ITEMS];
-	gint data_len[MAX_T38_DATA_ITEMS];
+	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;
 
 
-/* Info to save in T38 conversation / packet-info */
 #define MAX_T38_SETUP_METHOD_SIZE 7
-struct _t38_conversation_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_info
 {
-	gchar   method[MAX_T38_SETUP_METHOD_SIZE + 1];
-	guint32 frame_number;
-};
+	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; 
+} 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 */
 void t38_add_address(packet_info *pinfo,
                      address *addr, int port,
@@ -54,3 +74,9 @@
                      const gchar *setup_method, guint32 setup_frame_number);
 
 ETH_VAR_IMPORT const value_string t30_indicator_vals[];
+ETH_VAR_IMPORT const value_string t30_facsimile_control_field_vals[];
+ETH_VAR_IMPORT const value_string t30_facsimile_control_field_vals_short[];
+ETH_VAR_IMPORT const value_string t30_data_vals[];
+
+
+
Index: epan/dissectors/packet-sdp.c
===================================================================
--- epan/dissectors/packet-sdp.c	(revision 17031)
+++ epan/dissectors/packet-sdp.c	(working copy)
@@ -437,13 +437,13 @@
 			
 	    /* Add t38 conversation, if available and only if no rtp */
 	    if((!pinfo->fd->flags.visited) && port!=0 && !set_rtp && is_t38 && is_ipv4_addr){
-                    src_addr.data=(char *)&ipaddr;
-                    if(t38_handle){
-                                t38_add_address(pinfo, &src_addr, port, 0, "SDP", pinfo->fd->num);
-                    }
+			src_addr.data=(char *)&ipaddr;
+            if(t38_handle){
+				t38_add_address(pinfo, &src_addr, port, 0, "SDP", pinfo->fd->num);
+            }	
 	    }
 
-		/* Create the summary str for the Voip Call analysis */
+		/* Create the RTP summary str for the Voip Call analysis */
 		for (i = 0; i < transport_info.media[n].pt_count; i++)
 		{
 			/* if the payload type is dynamic (96 to 127), check the hash table to add the desc in the SDP summary */
@@ -460,6 +460,9 @@
 		/* Free the hash table if we did't assigned it to a conv use it */
 		if (set_rtp == FALSE) 
 			rtp_free_hash_dyn_payload(transport_info.media[n].rtp_dyn_payload);
+
+		/* Create the T38 summary str for the Voip Call analysis */
+		if (is_t38) g_snprintf(sdp_pi->summary_str, 50, "%s t38", sdp_pi->summary_str);	
 	}
 
 	/* Free the remainded hash tables not used */
Index: epan/reassemble.c
===================================================================
--- epan/reassemble.c	(revision 17031)
+++ epan/reassemble.c	(working copy)
@@ -1107,7 +1107,7 @@
 		/* make sure it doesnt conflict with previous data */
 		dfpos=0;
 		last_fd=NULL;
-		for (fd_i=fd_head->next;fd_i->offset!=fd->offset;fd_i=fd_i->next) {
+		for (fd_i=fd_head->next;fd_i && (fd_i->offset!=fd->offset);fd_i=fd_i->next) {
 		  if (!last_fd || last_fd->offset!=fd_i->offset){
 		    dfpos += fd_i->len;
 		  }
@@ -1182,8 +1182,11 @@
 	 * XXX - what if we didn't capture the entire fragment due
 	 * to a too-short snapshot length?
 	 */
-	fd->data = g_malloc(fd->len);
-	tvb_memcpy(tvb, fd->data, offset, fd->len);
+	/* check len, ther may be a fragment with 0 len, that is actually the tail */
+	if (fd->len) {
+		fd->data = g_malloc(fd->len);
+		tvb_memcpy(tvb, fd->data, offset, fd->len);
+	}
 	LINK_FRAG(fd_head,fd);