2 # T.38 conformation file
7 #.EXPORTS ONLY_VALS WS_DLL
8 Type-of-msg/t30-indicator
13 Type-of-msg/t30-indicator T30_indicator
14 Type-of-msg/t30-data T30_data
22 #.FN_PARS Type-of-msg VAL_PTR=&Type_of_msg_value
26 t38_info->type_msg = Type_of_msg_value;
29 #.FN_PARS Type-of-msg/t30-indicator VAL_PTR=&T30ind_value
30 #.FN_FTR Type-of-msg/t30-indicator
32 col_append_fstr(actx->pinfo->cinfo, COL_INFO, " t30ind: %s",
33 val_to_str(T30ind_value,t38_T30_indicator_vals,"<unknown>"));
38 t38_info->t30ind_value = T30ind_value;
41 #.FN_PARS Type-of-msg/t30-data VAL_PTR=&Data_value
42 #.FN_FTR Type-of-msg/t30-data
44 col_append_fstr(actx->pinfo->cinfo, COL_INFO, " data:%s:",
45 val_to_str(Data_value,t38_T30_data_vals,"<unknown>"));
51 t38_info->data_value = Data_value;
54 #.FN_FTR Data-Field/_item
55 if (primary_part) Data_Field_item_num++;
58 #.FN_PARS Data-Field/_item/field-type
59 EXT=(use_pre_corrigendum_asn1_specification)?FALSE:TRUE
60 EXT_NUM=(use_pre_corrigendum_asn1_specification)?0:4
61 VAL_PTR=&Data_Field_field_type_value
62 #.FN_FTR Data-Field/_item/field-type
64 col_append_fstr(actx->pinfo->cinfo, COL_INFO, " %s",
65 val_to_str(Data_Field_field_type_value,t38_T_field_type_vals,"<unknown>"));
68 /* We only reassmeble packets in the Primary part and in the first two Items. */
69 /* There maybe be t38 packets with more than two Items, but reassemble those packets is not easy */
70 /* using the current ressaemble functions. */
71 /* TODO: reassemble all the Items in one frame */
72 if (primary_part && (Data_Field_item_num<2)) {
73 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*/
74 fragment_head *frag_msg = NULL;
75 tvbuff_t* new_tvb = NULL;
76 gboolean save_fragmented = actx->pinfo->fragmented;
78 actx->pinfo->fragmented = TRUE;
80 /* if reass_start_seqnum=-1 it means we have received the end of the fragmente, without received any fragment data */
81 if (p_t38_packet_conv_info->reass_start_seqnum != -1) {
82 frag_msg = fragment_add_seq(&data_reassembly_table, /* reassembly table */
83 tvb, offset, actx->pinfo,
84 p_t38_packet_conv_info->reass_ID, /* ID for fragments belonging together */
86 seq_number + Data_Field_item_num - (guint32)p_t38_packet_conv_info->reass_start_seqnum + (guint32)p_t38_packet_conv_info->additional_hdlc_data_field_counter, /* fragment sequence number */
88 0, /* fragment length */
89 FALSE, /* More fragments */
91 if ( Data_Field_field_type_value == 7 ) {
92 /* if there was packet lost or other errors during the defrag then frag_msg is NULL. This could also means
93 * there are out of order packets (e.g, got the tail frame t4-non-ecm-sig-end before the last fragment),
94 * but we will assume there was packet lost instead, which is more usual. So, we are going to reassemble the packet
95 * and get some stat, like packet lost and burst number of packet lost
98 force_reassemble_seq(&data_reassembly_table, /* reassembly table */
100 p_t38_packet_conv_info->reass_ID /* ID for fragments belonging together */
103 col_append_str(actx->pinfo->cinfo, COL_INFO, " (t4-data Reassembled: No packet lost)");
105 g_snprintf(t38_info->desc_comment, MAX_T38_DESC, "No packet lost");
109 if (p_t38_packet_conv_info->packet_lost) {
110 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);
112 g_snprintf(t38_info->desc_comment, MAX_T38_DESC, "No packet lost");
115 process_reassembled_data(tvb, offset, actx->pinfo,
116 "Reassembled T38", frag_msg, &data_frag_items, NULL, tree);
118 /* Now reset fragmentation information in pinfo */
119 actx->pinfo->fragmented = save_fragmented;
121 t38_info->time_first_t4_data = p_t38_packet_conv_info->time_first_t4_data;
122 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 */
125 new_tvb = process_reassembled_data(tvb, offset, actx->pinfo,
126 "Reassembled T38", frag_msg, &data_frag_items, NULL, tree);
128 /* Now reset fragmentation information in pinfo */
129 actx->pinfo->fragmented = save_fragmented;
131 if (new_tvb) call_dissector_with_data((t30_hdlc_handle) ? t30_hdlc_handle : data_handle, new_tvb, actx->pinfo, tree, t38_info);
135 proto_tree_add_text(tree, tvb, offset, tvb_reported_length_remaining(tvb, offset),
136 "[RECEIVED END OF FRAGMENT W/OUT ANY FRAGMENT DATA]");
138 col_append_str(actx->pinfo->cinfo, COL_INFO, " [Malformed?]");
139 actx->pinfo->fragmented = save_fragmented;
143 /* reset the reassemble ID and the start seq number if it is not HDLC data */
144 if ( p_t38_conv && ( ((Data_Field_field_type_value >0) && (Data_Field_field_type_value <6)) || (Data_Field_field_type_value == 7) ) ){
145 p_t38_conv_info->reass_ID = 0;
146 p_t38_conv_info->reass_start_seqnum = -1;
147 p_t38_conv_info->additional_hdlc_data_field_counter = 0;
148 p_t38_conv_info->seqnum_prev_data_field = -1;
150 t38_info->Data_Field_field_type_value = Data_Field_field_type_value;
154 #.FN_BODY Data-Field/_item/field-data VAL_PTR=&value_tvb
155 tvbuff_t *value_tvb = NULL;
159 value_len = tvb_length(value_tvb);
161 #.FN_FTR Data-Field/_item/field-data
164 col_append_fstr(actx->pinfo->cinfo, COL_INFO, "[%s]",
165 tvb_bytes_to_str(value_tvb,0,value_len));
168 col_append_fstr(actx->pinfo->cinfo, COL_INFO, "[%s...]",
169 tvb_bytes_to_str(value_tvb,0,7));
173 /* We only reassmeble packets in the Primary part and in the first two Items. */
174 /* There maybe be t38 packets with more than two Items, but reassemble those packets is not easy */
175 /* using the current ressaemble functions. */
176 /* TODO: reassemble all the Items in one frame */
177 if (primary_part && (Data_Field_item_num<2)) {
178 fragment_head *frag_msg = NULL;
180 /* HDLC Data or t4-non-ecm-data */
181 if (Data_Field_field_type_value == 0 || Data_Field_field_type_value == 6) { /* 0=HDLC Data or 6=t4-non-ecm-data*/
182 gboolean save_fragmented = actx->pinfo->fragmented;
184 actx->pinfo->fragmented = TRUE;
186 /* if we have not reassembled this packet and it is the first fragment, reset the reassemble ID and the start seq number*/
187 if (p_t38_packet_conv && p_t38_conv && (p_t38_packet_conv_info->reass_ID == 0)) {
188 /* we use the first fragment's frame_number as fragment ID because the protocol doesn't provide it */
189 p_t38_conv_info->reass_ID = actx->pinfo->fd->num;
190 p_t38_conv_info->reass_start_seqnum = seq_number;
191 p_t38_conv_info->time_first_t4_data = nstime_to_sec(&actx->pinfo->rel_ts);
192 p_t38_conv_info->additional_hdlc_data_field_counter = 0;
193 p_t38_packet_conv_info->reass_ID = p_t38_conv_info->reass_ID;
194 p_t38_packet_conv_info->reass_start_seqnum = p_t38_conv_info->reass_start_seqnum;
195 p_t38_packet_conv_info->seqnum_prev_data_field = p_t38_conv_info->seqnum_prev_data_field;
196 p_t38_packet_conv_info->additional_hdlc_data_field_counter = p_t38_conv_info->additional_hdlc_data_field_counter;
197 p_t38_packet_conv_info->time_first_t4_data = p_t38_conv_info->time_first_t4_data;
199 if (seq_number == (guint32)p_t38_packet_conv_info->seqnum_prev_data_field){
200 p_t38_packet_conv_info->additional_hdlc_data_field_counter ++;
202 p_t38_conv_info->additional_hdlc_data_field_counter = p_t38_packet_conv_info->additional_hdlc_data_field_counter;
205 frag_msg = fragment_add_seq(&data_reassembly_table,
208 p_t38_packet_conv_info->reass_ID, /* ID for fragments belonging together */
210 seq_number - (guint32)p_t38_packet_conv_info->reass_start_seqnum + (guint32)p_t38_packet_conv_info->additional_hdlc_data_field_counter, /* fragment sequence number */
211 value_len, /* fragment length */
212 TRUE, /* More fragments */
214 p_t38_packet_conv_info->seqnum_prev_data_field = (gint32)seq_number;
215 process_reassembled_data(tvb, offset, actx->pinfo,
216 "Reassembled T38", frag_msg, &data_frag_items, NULL, tree);
218 if (!frag_msg) { /* Not last packet of reassembled */
219 if (Data_Field_field_type_value == 0) {
220 col_append_fstr(actx->pinfo->cinfo, COL_INFO," (HDLC fragment %u)",
221 seq_number + (guint32)p_t38_packet_conv_info->additional_hdlc_data_field_counter
222 - (guint32)p_t38_packet_conv_info->reass_start_seqnum);
224 col_append_fstr(actx->pinfo->cinfo, COL_INFO," (t4-data fragment %u)", seq_number - (guint32)p_t38_packet_conv_info->reass_start_seqnum);
228 /* Now reset fragmentation information in pinfo */
229 actx->pinfo->fragmented = save_fragmented;
236 /* Initialize to something else than data type */
237 Data_Field_field_type_value = 1;
240 #.FN_PARS UDPTLPacket/seq-number VAL_PTR=&seq_number
241 #.FN_FTR UDPTLPacket/seq-number
244 t38_info->seq_num = seq_number;
246 col_append_fstr(actx->pinfo->cinfo, COL_INFO, "Seq=%05u ",seq_number);
249 #.FN_HDR UDPTLPacket/primary-ifp-packet
251 #.FN_FTR UDPTLPacket/primary-ifp-packet
252 /* if is a valid t38 packet, add to tap */
253 if (p_t38_packet_conv && (!actx->pinfo->flags.in_error_pkt) && ((gint32) seq_number != p_t38_packet_conv_info->last_seqnum))
254 tap_queue_packet(t38_tap, actx->pinfo, t38_info);
256 if (p_t38_conv) p_t38_conv_info->last_seqnum = (gint32) seq_number;
259 #.FN_HDR UDPTLPacket/error-recovery
260 primary_part = FALSE;
261 #.FN_FTR UDPTLPacket/error-recovery