3 * Routines to dissect WTP component of WAP traffic.
5 * $Id: packet-wtp.c,v 1.62 2004/01/27 00:20:37 obiot Exp $
7 * Ethereal - Network traffic analyzer
8 * By Gerald Combs <gerald@ethereal.com>
9 * Copyright 1998 Gerald Combs
11 * WAP dissector based on original work by Ben Fowler
12 * Updated by Neil Hunter <neil.hunter@energis-squared.com>
13 * WTLS support by Alexandre P. Ferreira (Splice IP)
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
37 #ifdef NEED_SNPRINTF_H
38 # include "snprintf.h"
43 #include <epan/packet.h>
44 #include "reassemble.h"
45 #include "packet-wap.h"
46 #include "packet-wtp.h"
47 #include "packet-wsp.h"
49 static const true_false_string continue_truth = {
54 static const true_false_string RID_truth = {
59 static const true_false_string TIDNew_truth = {
64 static const true_false_string tid_response_truth = {
69 static const true_false_string UP_truth = {
70 "User Acknowledgement required" ,
71 "User Acknowledgement optional"
74 static const true_false_string TVETOK_truth = {
79 static const value_string vals_wtp_pdu_type[] = {
85 { 5, "Segmented Invoke" },
86 { 6, "Segmented Result" },
87 { 7, "Negative Ack" },
91 static const value_string vals_transaction_trailer[] = {
92 { 0, "Not last packet" },
93 { 1, "Last packet of message" },
94 { 2, "Last packet of group" },
95 { 3, "Re-assembly not supported" },
99 static const value_string vals_version[] = {
107 static const value_string vals_abort_type[] = {
113 static const value_string vals_abort_reason_provider[] = {
115 { 0x01, "Protocol Error" },
116 { 0x02, "Invalid TID" },
117 { 0x03, "Not Implemented Class 2" },
118 { 0x04, "Not Implemented SAR" },
119 { 0x05, "Not Implemented User Acknowledgement" },
120 { 0x06, "WTP Version Zero" },
121 { 0x07, "Capacity Temporarily Exceeded" },
122 { 0x08, "No Response" },
123 { 0x09, "Message Too Large" },
127 static const value_string vals_transaction_classes[] = {
128 { 0x00, "Unreliable Invoke without Result" },
129 { 0x01, "Reliable Invoke without Result" },
130 { 0x02, "Reliable Invoke with Reliable Result" },
134 static const value_string vals_tpi_type[] = {
138 { 0x03, "Packet sequence number" },
139 { 0x04, "SDU boundary" },
140 { 0x05, "Frame boundary" },
144 static const value_string vals_tpi_opt[] = {
145 { 0x01, "Maximum receive unit" },
146 { 0x02, "Total message size" },
147 { 0x03, "Delay transmission timer" },
148 { 0x04, "Maximum group" },
149 { 0x05, "Current TID" },
150 { 0x06, "No cached TID" },
154 /* File scoped variables for the protocol and registered fields */
155 static int proto_wtp = HF_EMPTY;
157 /* These fields used by fixed part of header */
158 static int hf_wtp_header_sub_pdu_size = HF_EMPTY;
159 static int hf_wtp_header_flag_continue = HF_EMPTY;
160 static int hf_wtp_header_pdu_type = HF_EMPTY;
161 static int hf_wtp_header_flag_Trailer = HF_EMPTY;
162 static int hf_wtp_header_flag_RID = HF_EMPTY;
163 static int hf_wtp_header_flag_TID = HF_EMPTY;
164 static int hf_wtp_header_flag_TID_response = HF_EMPTY;
166 /* These fields used by Invoke packets */
167 static int hf_wtp_header_Inv_version = HF_EMPTY;
168 static int hf_wtp_header_Inv_flag_TIDNew = HF_EMPTY;
169 static int hf_wtp_header_Inv_flag_UP = HF_EMPTY;
170 static int hf_wtp_header_Inv_Reserved = HF_EMPTY;
171 static int hf_wtp_header_Inv_TransactionClass = HF_EMPTY;
174 static int hf_wtp_header_variable_part = HF_EMPTY;
175 static int hf_wtp_data = HF_EMPTY;
177 static int hf_wtp_tpi_type = HF_EMPTY;
178 static int hf_wtp_tpi_psn = HF_EMPTY;
179 static int hf_wtp_tpi_opt = HF_EMPTY;
180 static int hf_wtp_tpi_optval = HF_EMPTY;
181 static int hf_wtp_tpi_info = HF_EMPTY;
183 static int hf_wtp_header_Ack_flag_TVETOK = HF_EMPTY;
184 static int hf_wtp_header_Abort_type = HF_EMPTY;
185 static int hf_wtp_header_Abort_reason_provider = HF_EMPTY;
186 static int hf_wtp_header_Abort_reason_user = HF_EMPTY;
187 static int hf_wtp_header_sequence_number = HF_EMPTY;
188 static int hf_wtp_header_missing_packets = HF_EMPTY;
190 /* These fields used when reassembling WTP fragments */
191 static int hf_wtp_fragments = HF_EMPTY;
192 static int hf_wtp_fragment = HF_EMPTY;
193 static int hf_wtp_fragment_overlap = HF_EMPTY;
194 static int hf_wtp_fragment_overlap_conflict = HF_EMPTY;
195 static int hf_wtp_fragment_multiple_tails = HF_EMPTY;
196 static int hf_wtp_fragment_too_long_fragment = HF_EMPTY;
197 static int hf_wtp_fragment_error = HF_EMPTY;
198 static int hf_wtp_reassembled_in = HF_EMPTY;
200 /* Initialize the subtree pointers */
201 static gint ett_wtp = ETT_EMPTY;
202 static gint ett_wtp_sub_pdu_tree = ETT_EMPTY;
203 static gint ett_header = ETT_EMPTY;
204 static gint ett_tpilist = ETT_EMPTY;
205 static gint ett_wsp_fragments = ETT_EMPTY;
206 static gint ett_wtp_fragment = ETT_EMPTY;
208 static const fragment_items wtp_frag_items = {
213 &hf_wtp_fragment_overlap,
214 &hf_wtp_fragment_overlap_conflict,
215 &hf_wtp_fragment_multiple_tails,
216 &hf_wtp_fragment_too_long_fragment,
217 &hf_wtp_fragment_error,
218 &hf_wtp_reassembled_in,
222 /* Handle for WSP dissector */
223 static dissector_handle_t wsp_handle;
228 static GHashTable *wtp_fragment_table = NULL;
231 wtp_defragment_init(void)
233 fragment_table_init(&wtp_fragment_table);
237 * Extract some bitfields
239 #define pdu_type(octet) (((octet) >> 3) & 0x0F) /* Note pdu type must not be 0x00 */
240 #define transaction_class(octet) ((octet) & 0x03) /* ......XX */
241 #define transmission_trailer(octet) (((octet) >> 1) & 0x01) /* ......X. */
243 static char retransmission_indicator(unsigned char octet)
245 switch (pdu_type(octet)) {
249 case SEGMENTED_INVOKE:
250 case SEGMENTED_RESULT:
252 return octet & 0x01; /* .......X */
262 wtp_handle_tpi(proto_tree *tree, tvbuff_t *tvb)
268 proto_item *subTree = NULL;
270 tByte = tvb_get_guint8(tvb, offset++);
271 tType = (tByte & 0x78) >> 3;
272 if (tByte & 0x04) /* Long TPI */
273 tLen = tvb_get_guint8(tvb, offset++);
276 subTree = proto_tree_add_uint(tree, hf_wtp_tpi_type,
277 tvb, 0, tvb_length(tvb), tType);
278 proto_item_add_subtree(subTree, ett_tpilist);
280 case 0x00: /* Error*/
283 case 0x01: /* Info */
284 /* Beware, untested case here */
285 proto_tree_add_item(subTree, hf_wtp_tpi_info,
286 tvb, offset, tLen, bo_little_endian);
288 case 0x02: /* Option */
289 proto_tree_add_item(subTree, hf_wtp_tpi_opt,
290 tvb, offset++, 1, bo_little_endian);
291 proto_tree_add_item(subTree, hf_wtp_tpi_optval,
292 tvb, offset, tLen - 1, bo_little_endian);
295 proto_tree_add_item(subTree, hf_wtp_tpi_psn,
296 tvb, offset, 1, bo_little_endian);
298 case 0x04: /* SDU boundary */
301 case 0x05: /* Frame boundary */
309 /* Code to actually dissect the packets */
311 dissect_wtp_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
313 static GString *szInfo = NULL;
314 int offCur = 0; /* current offset from start of WTP data */
318 /* continuation flag */
319 unsigned char fCon; /* Continue flag */
320 unsigned char fRID; /* Re-transmission indicator*/
321 unsigned char fTTR = '\0'; /* Transmission trailer */
322 guint cbHeader = 0; /* Fixed header length */
323 guint vHeader = 0; /* Variable header length*/
326 /* Set up structures we'll need to add the protocol subtree and manage it */
327 proto_item *ti = NULL;
328 proto_tree *wtp_tree = NULL;
331 char clsTransaction = ' ';
332 int numMissing = 0; /* Number of missing packets in a negative ack */
334 tvbuff_t *wsp_tvb = NULL;
335 guint8 psn = 0; /* Packet sequence number*/
336 guint16 TID = 0; /* Transaction-Id */
341 szInfo = g_string_sized_new(32);
343 b0 = tvb_get_guint8 (tvb, offCur + 0);
344 /* Discover Concatenated PDUs */
346 guint c_fieldlen = 0; /* Length of length-field */
347 guint c_pdulen = 0; /* Length of conc. PDU */
350 ti = proto_tree_add_item(tree, proto_wtp,
351 tvb, offCur, 1, bo_little_endian);
352 wtp_tree = proto_item_add_subtree(ti, ett_wtp_sub_pdu_tree);
353 proto_item_append_text(ti, ", PDU concatenation");
357 while (offCur < (int) tvb_reported_length(tvb)) {
359 /* The length of an embedded WTP PDU is coded as either:
360 * - a 7-bit value contained in one octet with highest bit == 0.
361 * - a 15-bit value contained in two octets (little endian)
362 * if the 1st octet has its highest bit == 1.
363 * This means that this is NOT encoded as an uintvar-integer!!!
365 b0 = tvb_get_guint8(tvb, offCur + 0);
368 c_pdulen = ((b0 & 0x7f) << 8) | tvb_get_guint8(tvb, offCur + 1);
374 proto_tree_add_uint(wtp_tree, hf_wtp_header_sub_pdu_size,
375 tvb, offCur, c_fieldlen, c_pdulen);
377 if (i > 1 && check_col(pinfo->cinfo, COL_INFO)) {
378 col_append_str(pinfo->cinfo, COL_INFO, ", ");
380 /* Skip the length field for the WTP sub-tvb */
381 wtp_tvb = tvb_new_subset(tvb, offCur + c_fieldlen, c_pdulen, c_pdulen);
382 dissect_wtp_common(wtp_tvb, pinfo, wtp_tree);
383 offCur += c_fieldlen + c_pdulen;
387 proto_item_append_text(ti, ", PDU count: %u", i);
391 /* No concatenation */
393 fRID = retransmission_indicator(b0);
397 printf("WTP packet %u: tree = %p, pdu = %s (%u) length: %u\n",
398 pinfo->fd->num, tree,
399 match_strval(pdut, vals_wtp_pdu_type), pdut, tvb_length(tvb));
402 /* Develop the string to put in the Info column */
403 g_string_sprintf(szInfo, "WTP %s",
404 val_to_str(pdut, vals_wtp_pdu_type, "Unknown PDU type 0x%x"));
408 fTTR = transmission_trailer(b0);
409 TID = tvb_get_ntohs(tvb, offCur + 1);
411 clsTransaction = transaction_class(tvb_get_guint8(tvb, offCur + 3));
412 g_string_sprintfa(szInfo, " Class %d", clsTransaction);
416 case SEGMENTED_INVOKE:
417 case SEGMENTED_RESULT:
418 fTTR = transmission_trailer(b0);
419 TID = tvb_get_ntohs(tvb, offCur + 1);
420 psn = tvb_get_guint8(tvb, offCur + 3);
422 g_string_sprintfa(szInfo, " (%u)", psn);
431 fTTR = transmission_trailer(b0);
432 TID = tvb_get_ntohs(tvb, offCur + 1);
442 /* Variable number of missing packets */
443 numMissing = tvb_get_guint8(tvb, offCur + 3);
444 cbHeader = numMissing + 4;
451 g_string_append( szInfo, " R" );
453 /* In the interest of speed, if "tree" is NULL, don't do any work not
454 necessary to generate protocol tree items. */
457 fprintf(stderr, "dissect_wtp: cbHeader = %d\n", cbHeader);
459 /* NOTE - Length will be set when we process the TPI */
460 ti = proto_tree_add_item(tree, proto_wtp, tvb, offCur, 0, bo_little_endian);
462 fprintf(stderr, "dissect_wtp: (7) Returned from proto_tree_add_item\n");
464 wtp_tree = proto_item_add_subtree(ti, ett_wtp);
466 /* Code to process the packet goes here */
468 fprintf(stderr, "dissect_wtp: cbHeader = %d\n", cbHeader);
469 fprintf(stderr, "dissect_wtp: offCur = %d\n", offCur);
471 /* Add common items: only CON and PDU Type */
474 hf_wtp_header_flag_continue, /* id */
476 offCur, /* start of highlight */
477 1, /* length of highlight*/
480 proto_tree_add_item(wtp_tree, hf_wtp_header_pdu_type, tvb, offCur, 1, bo_little_endian);
484 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_Trailer, tvb, offCur, 1, bo_little_endian);
485 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_RID, tvb, offCur, 1, bo_little_endian);
486 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_TID_response, tvb, offCur + 1, 2, bo_big_endian);
487 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_TID, tvb, offCur + 1, 2, bo_big_endian);
489 proto_tree_add_item(wtp_tree, hf_wtp_header_Inv_version , tvb, offCur + 3, 1, bo_little_endian);
490 proto_tree_add_item(wtp_tree, hf_wtp_header_Inv_flag_TIDNew, tvb, offCur + 3, 1, bo_little_endian);
491 proto_tree_add_item(wtp_tree, hf_wtp_header_Inv_flag_UP, tvb, offCur + 3, 1, bo_little_endian);
492 proto_tree_add_item(wtp_tree, hf_wtp_header_Inv_Reserved, tvb, offCur + 3, 1, bo_little_endian);
493 proto_tree_add_item(wtp_tree, hf_wtp_header_Inv_TransactionClass, tvb, offCur + 3, 1, bo_little_endian);
494 proto_item_append_text(ti,
496 ", Transaction Class: %s (%u)",
498 match_strval(clsTransaction, vals_transaction_classes),
503 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_Trailer, tvb, offCur, 1, bo_little_endian);
504 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_RID, tvb, offCur, 1, bo_little_endian);
505 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_TID_response, tvb, offCur + 1, 2, bo_big_endian);
506 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_TID, tvb, offCur + 1, 2, bo_big_endian);
507 proto_item_append_text(ti, ", PDU: Result (%u)", RESULT);
511 proto_tree_add_item(wtp_tree, hf_wtp_header_Ack_flag_TVETOK, tvb, offCur, 1, bo_big_endian);
513 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_RID, tvb, offCur, 1, bo_little_endian);
514 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_TID_response, tvb, offCur + 1, 2, bo_big_endian);
515 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_TID, tvb, offCur + 1, 2, bo_big_endian);
516 proto_item_append_text(ti, ", PDU: ACK (%u)", ACK);
520 abortType = tvb_get_guint8 (tvb, offCur) & 0x07;
521 proto_tree_add_item(wtp_tree, hf_wtp_header_Abort_type , tvb, offCur , 1, bo_little_endian);
522 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_TID_response, tvb, offCur + 1, 2, bo_big_endian);
523 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_TID, tvb, offCur + 1, 2, bo_big_endian);
525 if (abortType == PROVIDER)
527 guint8 reason = tvb_get_guint8(tvb, offCur + 3);
528 proto_tree_add_item( wtp_tree, hf_wtp_header_Abort_reason_provider , tvb, offCur + 3 , 1, bo_little_endian);
529 proto_item_append_text(ti,
531 ", Type: Provider (%u)"
535 match_strval(reason, vals_abort_reason_provider),
538 else if (abortType == USER)
540 guint8 reason = tvb_get_guint8(tvb, offCur + 3);
541 proto_tree_add_item(wtp_tree, hf_wtp_header_Abort_reason_user , tvb, offCur + 3 , 1, bo_little_endian);
542 proto_item_append_text(ti,
548 match_strval(reason, vals_wsp_reason_codes),
553 case SEGMENTED_INVOKE:
554 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_Trailer, tvb, offCur, 1, bo_little_endian);
555 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_RID, tvb, offCur, 1, bo_little_endian);
556 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_TID_response, tvb, offCur + 1, 2, bo_big_endian);
557 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_TID, tvb, offCur + 1, 2, bo_big_endian);
559 proto_tree_add_item(wtp_tree, hf_wtp_header_sequence_number , tvb, offCur + 3, 1, bo_little_endian);
560 proto_item_append_text(ti,
561 ", PDU: Segmented Invoke (%u)"
562 ", Packet Sequence Number: %u",
563 SEGMENTED_INVOKE, psn);
566 case SEGMENTED_RESULT:
567 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_Trailer, tvb, offCur, 1, bo_little_endian);
568 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_RID, tvb, offCur, 1, bo_little_endian);
569 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_TID_response, tvb, offCur + 1, 2, bo_big_endian);
570 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_TID, tvb, offCur + 1, 2, bo_big_endian);
572 proto_tree_add_item(wtp_tree, hf_wtp_header_sequence_number , tvb, offCur + 3, 1, bo_little_endian);
573 proto_item_append_text(ti,
574 ", PDU: Segmented Result (%u)"
575 ", Packet Sequence Number: %u",
576 SEGMENTED_RESULT, psn);
580 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_RID, tvb, offCur, 1, bo_little_endian);
581 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_TID_response, tvb, offCur + 1, 2, bo_big_endian);
582 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_TID, tvb, offCur + 1, 2, bo_big_endian);
584 proto_tree_add_item(wtp_tree, hf_wtp_header_missing_packets , tvb, offCur + 3, 1, bo_little_endian);
585 /* Iterate through missing packets */
586 for (i = 0; i < numMissing; i++)
588 proto_tree_add_item(wtp_tree, hf_wtp_header_sequence_number, tvb, offCur + 4 + i, 1, bo_little_endian);
590 proto_item_append_text(ti,
591 ", PDU: Negative Ack (%u)"
592 ", Missing Packets: %u",
593 NEGATIVE_ACK, numMissing);
600 proto_item_append_text(ti, ", Retransmission");
602 } else { /* tree is NULL */
604 fprintf(stderr, "dissect_wtp: (4) tree was %p\n", tree);
607 /* Process the variable part */
608 if (fCon) { /* Now, analyze variable part */
611 unsigned char tpiLen;
614 vHeader = 0; /* Start scan all over */
617 tByte = tvb_get_guint8(tvb, offCur + cbHeader + vHeader);
619 if (tByte & 0x04) /* Long TPI */
620 tpiLen = 2 + tvb_get_guint8(tvb,
621 offCur + cbHeader + vHeader + 1);
623 tpiLen = 1 + (tByte & 0x03);
626 tmp_tvb = tvb_new_subset(tvb, offCur + cbHeader + vHeader,
628 wtp_handle_tpi(wtp_tree, tmp_tvb);
633 /* There is no variable part */
634 } /* End of variable part of header */
636 /* Set the length of the WTP protocol part now we know the length of the
637 * fixed and variable WTP headers */
639 proto_item_set_len(ti, cbHeader + vHeader);
642 fprintf( stderr, "dissect_wtp: cbHeader = %d\n", cbHeader );
646 * Any remaining data ought to be WSP data (if not WTP ACK, NACK
647 * or ABORT pdu), so, if we have any remaining data, and it's
648 * not an ACK, NACK, or ABORT PDU, hand it off (defragmented) to the
650 * Note that the last packet of a fragmented WTP message needn't
651 * contain any data, so we allow payloadless packets to be
652 * reassembled. (XXX - does the reassembly code handle this
653 * for packets other than the last packet?)
655 * Try calling a subdissector only if:
656 * - The WTP payload is ressembled in this very packet,
657 * - The WTP payload is not fragmented across packets.
659 dataOffset = offCur + cbHeader + vHeader;
660 dataLen = tvb_reported_length_remaining(tvb, dataOffset);
661 if ((dataLen >= 0) &&
662 ! ((pdut==ACK) || (pdut==NEGATIVE_ACK) || (pdut==ABORT)))
664 /* Try to reassemble if needed, and hand over to WSP
665 * A fragmented WTP packet is either:
666 * - An INVOKE with fTTR (transmission trailer) not set,
667 * - a SEGMENTED_INVOKE,
668 * - A RESULT with fTTR (transmission trailer) not set,
669 * - a SEGMENTED_RESULT.
671 if ( ( (pdut == SEGMENTED_INVOKE) || (pdut == SEGMENTED_RESULT)
672 || ( ((pdut == INVOKE) || (pdut == RESULT)) && (!fTTR) )
673 ) && tvb_bytes_exist(tvb, dataOffset, dataLen) )
675 /* Try reassembling fragments */
676 fragment_data *fd_wtp = NULL;
677 guint32 reassembled_in = 0;
678 gboolean save_fragmented = pinfo->fragmented;
680 pinfo->fragmented = TRUE;
681 fd_wtp = fragment_add_seq(tvb, dataOffset, pinfo, TID,
682 wtp_fragment_table, psn, dataLen, !fTTR);
683 /* XXX - fragment_add_seq() yields NULL unless Ethereal knows
684 * that the packet is part of a reassembled whole. This means
685 * that fd_wtp will be NULL as long as Ethereal did not encounter
686 * (and process) the packet containing the last fragment.
687 * This implies that Ethereal needs two passes over the data for
688 * correct reassembly. At the first pass, a capture containing
689 * three fragments plus a retransmssion of the last fragment
690 * will progressively show:
692 * Packet 1: (Unreassembled fragment 1)
693 * Packet 2: (Unreassembled fragment 2)
694 * Packet 3: (Reassembled WTP)
695 * Packet 4: (WTP payload reassembled in packet 3)
697 * However at subsequent evaluation (e.g., by applying a display
698 * filter) the packet summary will show:
700 * Packet 1: (WTP payload reassembled in packet 3)
701 * Packet 2: (WTP payload reassembled in packet 3)
702 * Packet 3: (Reassembled WTP)
703 * Packet 4: (WTP payload reassembled in packet 3)
705 * This is important to know, and also affects read filters!
707 wsp_tvb = process_reassembled_data(tvb, dataOffset, pinfo,
708 "Reassembled WTP", fd_wtp, &wtp_frag_items,
711 printf("WTP: Packet %u %s -> %d: wsp_tvb = %p, fd_wtp = %p, frame = %u\n",
713 fd_wtp ? "Reassembled" : "Not reassembled",
714 fd_wtp ? fd_wtp->reassembled_in : -1,
721 reassembled_in = fd_wtp->reassembled_in;
722 if (pinfo->fd->num == reassembled_in) {
723 /* Reassembled in this very packet:
724 * We can safely hand the tvb to the WSP dissector */
725 call_dissector(wsp_handle, wsp_tvb, pinfo, tree);
727 /* Not reassembled in this packet */
728 if (check_col(pinfo->cinfo, COL_INFO)) {
729 col_append_fstr(pinfo->cinfo, COL_INFO,
730 "%s (WTP payload reassembled in packet %u)",
731 szInfo->str, fd_wtp->reassembled_in);
734 proto_tree_add_text(wtp_tree, tvb, dataOffset, -1,
739 /* Not reassembled yet, or not reassembled at all */
740 if (check_col(pinfo->cinfo, COL_INFO)) {
741 col_append_fstr(pinfo->cinfo, COL_INFO,
742 "%s (Unreassembled fragment %u)",
746 proto_tree_add_text(wtp_tree, tvb, dataOffset, -1,
750 /* Now reset fragmentation information in pinfo */
751 pinfo->fragmented = save_fragmented;
753 else if ( ((pdut == INVOKE) || (pdut == RESULT)) && (fTTR) )
755 /* Non-fragmented payload */
756 wsp_tvb = tvb_new_subset(tvb, dataOffset, -1, -1);
757 /* We can safely hand the tvb to the WSP dissector */
758 call_dissector(wsp_handle, wsp_tvb, pinfo, tree);
762 /* Nothing to hand to subdissector */
763 if (check_col(pinfo->cinfo, COL_INFO))
764 col_append_str(pinfo->cinfo, COL_INFO, szInfo->str);
769 /* Nothing to hand to subdissector */
770 if (check_col(pinfo->cinfo, COL_INFO))
771 col_append_str(pinfo->cinfo, COL_INFO, szInfo->str);
776 * Called directly from UDP.
777 * Put "WTP+WSP" into the "Protocol" column.
780 dissect_wtp_fromudp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
782 if (check_col(pinfo->cinfo, COL_PROTOCOL))
783 col_set_str(pinfo->cinfo, COL_PROTOCOL, "WTP+WSP" );
784 if (check_col(pinfo->cinfo, COL_INFO))
785 col_clear(pinfo->cinfo, COL_INFO);
787 dissect_wtp_common(tvb, pinfo, tree);
791 * Called from a higher-level WAP dissector, presumably WTLS.
792 * Put "WTLS+WSP+WTP" to the "Protocol" column.
794 * XXX - is this supposed to be called from WTLS? If so, we're not
797 * XXX - can this be called from any other dissector?
800 dissect_wtp_fromwtls(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
802 if (check_col(pinfo->cinfo, COL_PROTOCOL))
803 col_set_str(pinfo->cinfo, COL_PROTOCOL, "WTLS+WTP+WSP" );
804 if (check_col(pinfo->cinfo, COL_INFO))
805 col_clear(pinfo->cinfo, COL_INFO);
807 dissect_wtp_common(tvb, pinfo, tree);
810 /* Register the protocol with Ethereal */
812 proto_register_wtp(void)
815 /* Setup list of header fields */
816 static hf_register_info hf[] = {
817 { &hf_wtp_header_sub_pdu_size,
820 FT_UINT16, BASE_DEC, NULL, 0x0,
821 "Size of Sub-PDU (bytes)", HFILL
824 { &hf_wtp_header_flag_continue,
827 FT_BOOLEAN, 8, TFS( &continue_truth ), 0x80,
828 "Continue Flag", HFILL
831 { &hf_wtp_header_pdu_type,
834 FT_UINT8, BASE_HEX, VALS( vals_wtp_pdu_type ), 0x78,
838 { &hf_wtp_header_flag_Trailer,
841 FT_UINT8, BASE_HEX, VALS( vals_transaction_trailer ), 0x06,
842 "Trailer Flags", HFILL
845 { &hf_wtp_header_flag_RID,
846 { "Re-transmission Indicator",
848 FT_BOOLEAN, 8, TFS( &RID_truth ), 0x01,
849 "Re-transmission Indicator", HFILL
852 { &hf_wtp_header_flag_TID_response,
855 FT_BOOLEAN, 16, TFS( &tid_response_truth ), 0x8000,
856 "TID Response", HFILL
859 { &hf_wtp_header_flag_TID,
862 FT_UINT16, BASE_HEX, NULL, 0x7FFF,
863 "Transaction ID", HFILL
866 { &hf_wtp_header_Inv_version,
868 "wtp.header.version",
869 FT_UINT8, BASE_HEX, VALS( vals_version ), 0xC0,
873 { &hf_wtp_header_Inv_flag_TIDNew,
876 FT_BOOLEAN, 8, TFS( &TIDNew_truth ), 0x20,
880 { &hf_wtp_header_Inv_flag_UP,
883 FT_BOOLEAN, 8, TFS( &UP_truth ), 0x10,
887 { &hf_wtp_header_Inv_Reserved,
890 FT_UINT8, BASE_HEX, NULL, 0x0C,
894 { &hf_wtp_header_Inv_TransactionClass,
895 { "Transaction Class",
896 "wtp.inv.transaction_class",
897 FT_UINT8, BASE_HEX, VALS( vals_transaction_classes ), 0x03,
898 "Transaction Class", HFILL
901 { &hf_wtp_header_Ack_flag_TVETOK,
904 FT_BOOLEAN, 8, TFS( &TVETOK_truth ), 0x04,
905 "Tve/Tok flag", HFILL
908 { &hf_wtp_header_Abort_type,
911 FT_UINT8, BASE_HEX, VALS ( vals_abort_type ), 0x07,
915 { &hf_wtp_header_Abort_reason_provider,
917 "wtp.abort.reason.provider",
918 FT_UINT8, BASE_HEX, VALS ( vals_abort_reason_provider ), 0x00,
919 "Abort Reason", HFILL
922 /* Assume WSP is the user and use its reason codes */
923 { &hf_wtp_header_Abort_reason_user,
925 "wtp.abort.reason.user",
926 FT_UINT8, BASE_HEX, VALS ( vals_wsp_reason_codes ), 0x00,
927 "Abort Reason", HFILL
930 { &hf_wtp_header_sequence_number,
931 { "Packet Sequence Number",
932 "wtp.header.sequence",
933 FT_UINT8, BASE_DEC, NULL, 0x00,
934 "Packet Sequence Number", HFILL
937 { &hf_wtp_header_missing_packets,
939 "wtp.header.missing_packets",
940 FT_UINT8, BASE_DEC, NULL, 0x00,
941 "Missing Packets", HFILL
944 { &hf_wtp_header_variable_part,
945 { "Header: Variable part",
946 "wtp.header_variable_part",
947 FT_BYTES, BASE_HEX, NULL, 0x0,
948 "Variable part of the header", HFILL
954 FT_BYTES, BASE_HEX, NULL, 0x0,
961 FT_UINT8, BASE_HEX, VALS(vals_tpi_type), 0x00,
962 "Identification of the Transport Information Item", HFILL
966 { "Packet sequence number",
968 FT_UINT8, BASE_DEC, NULL, 0x00,
969 "Sequence number of this packet", HFILL
975 FT_UINT8, BASE_HEX, VALS(vals_tpi_opt), 0x00,
976 "The given option for this TPI", HFILL
979 { &hf_wtp_tpi_optval,
982 FT_NONE, BASE_NONE, NULL, 0x00,
983 "The value that is supplied with this option", HFILL
989 FT_NONE, BASE_NONE, NULL, 0x00,
990 "The information being send by this TPI", HFILL
994 /* Fragment fields */
995 { &hf_wtp_fragment_overlap,
996 { "Fragment overlap",
997 "wtp.fragment.overlap",
998 FT_BOOLEAN, BASE_NONE, NULL, 0x0,
999 "Fragment overlaps with other fragments", HFILL
1002 { &hf_wtp_fragment_overlap_conflict,
1003 { "Conflicting data in fragment overlap",
1004 "wtp.fragment.overlap.conflict",
1005 FT_BOOLEAN, BASE_NONE, NULL, 0x0,
1006 "Overlapping fragments contained conflicting data", HFILL
1009 { &hf_wtp_fragment_multiple_tails,
1010 { "Multiple tail fragments found",
1011 "wtp.fragment.multipletails",
1012 FT_BOOLEAN, BASE_NONE, NULL, 0x0,
1013 "Several tails were found when defragmenting the packet", HFILL
1016 { &hf_wtp_fragment_too_long_fragment,
1017 { "Fragment too long",
1018 "wtp.fragment.toolongfragment",
1019 FT_BOOLEAN, BASE_NONE, NULL, 0x0,
1020 "Fragment contained data past end of packet", HFILL
1023 { &hf_wtp_fragment_error,
1024 { "Defragmentation error",
1025 "wtp.fragment.error",
1026 FT_FRAMENUM, BASE_NONE, NULL, 0x0,
1027 "Defragmentation error due to illegal fragments", HFILL
1030 { &hf_wtp_reassembled_in,
1032 "wtp.reassembled.in",
1033 FT_FRAMENUM, BASE_NONE, NULL, 0x0,
1034 "WTP fragments are reassembled in the given packet", HFILL
1040 FT_FRAMENUM, BASE_NONE, NULL, 0x0,
1041 "WTP Fragment", HFILL
1044 { &hf_wtp_fragments,
1047 FT_NONE, BASE_NONE, NULL, 0x0,
1048 "WTP Fragments", HFILL
1053 /* Setup protocol subtree array */
1054 static gint *ett[] = {
1056 &ett_wtp_sub_pdu_tree,
1063 /* Register the protocol name and description */
1064 proto_wtp = proto_register_protocol(
1065 "Wireless Transaction Protocol", /* protocol name for use by ethereal */
1066 "WTP", /* short version of name */
1067 "wtp" /* Abbreviated protocol name, should Match IANA
1068 < URL:http://www.isi.edu/in-notes/iana/assignments/port-numbers/ >
1072 /* Required calls to register the header fields and subtrees used */
1073 proto_register_field_array(proto_wtp, hf, array_length(hf));
1074 proto_register_subtree_array(ett, array_length(ett));
1076 register_dissector("wtp-wtls", dissect_wtp_fromwtls, proto_wtp);
1077 register_dissector("wtp-udp", dissect_wtp_fromudp, proto_wtp);
1078 register_init_routine(wtp_defragment_init);
1082 proto_reg_handoff_wtp(void)
1084 dissector_handle_t wtp_fromudp_handle;
1087 * Get a handle for the connection-oriented WSP dissector - if WTP
1088 * PDUs have data, it is WSP.
1090 wsp_handle = find_dissector("wsp-co");
1092 wtp_fromudp_handle = find_dissector("wtp-udp");
1093 dissector_add("udp.port", UDP_PORT_WTP_WSP, wtp_fromudp_handle);
1094 dissector_add("gsm-sms-ud.udh.port", UDP_PORT_WTP_WSP, wtp_fromudp_handle);