3 * Routines to dissect WTP component of WAP traffic.
5 * $Id: packet-wtp.c,v 1.51 2003/07/29 22:10:18 guy 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_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;
199 /* Initialize the subtree pointers */
200 static gint ett_wtp = ETT_EMPTY;
201 static gint ett_header = ETT_EMPTY;
202 static gint ett_tpilist = ETT_EMPTY;
203 static gint ett_wsp_fragments = ETT_EMPTY;
204 static gint ett_wtp_fragment = ETT_EMPTY;
206 static const fragment_items wtp_frag_items = {
211 &hf_wtp_fragment_overlap,
212 &hf_wtp_fragment_overlap_conflict,
213 &hf_wtp_fragment_multiple_tails,
214 &hf_wtp_fragment_too_long_fragment,
215 &hf_wtp_fragment_error,
220 /* Handle for WSP dissector */
221 static dissector_handle_t wsp_handle;
226 static GHashTable *wtp_fragment_table = NULL;
229 wtp_defragment_init(void)
231 fragment_table_init(&wtp_fragment_table);
235 * Extract some bitfields
237 #define pdu_type(octet) (((octet) >> 3) & 0x0F) /* Note pdu type must not be 0x00 */
238 #define transaction_class(octet) ((octet) & 0x03) /* ......XX */
239 #define transmission_trailer(octet) (((octet) >> 1) & 0x01) /* ......X. */
241 static char retransmission_indicator(unsigned char octet)
243 switch (pdu_type(octet)) {
247 case SEGMENTED_INVOKE:
248 case SEGMENTED_RESULT:
250 return octet & 0x01; /* .......X */
260 wtp_handle_tpi(proto_tree *tree, tvbuff_t *tvb)
266 proto_item *subTree = NULL;
268 tByte = tvb_get_guint8(tvb, offset++);
269 tType = (tByte & 0x78) >> 3;
270 if (tByte & 0x04) /* Long TPI */
271 tLen = tvb_get_guint8(tvb, offset++);
274 subTree = proto_tree_add_uint(tree, hf_wtp_tpi_type,
275 tvb, 0, tvb_length(tvb), tType);
276 proto_item_add_subtree(subTree, ett_tpilist);
278 case 0x00: /* Error*/
281 case 0x01: /* Info */
282 /* Beware, untested case here */
283 proto_tree_add_item(subTree, hf_wtp_tpi_info,
284 tvb, offset, tLen, bo_little_endian);
286 case 0x02: /* Option */
287 proto_tree_add_item(subTree, hf_wtp_tpi_opt,
288 tvb, offset++, 1, bo_little_endian);
289 proto_tree_add_item(subTree, hf_wtp_tpi_optval,
290 tvb, offset, tLen - 1, bo_little_endian);
293 proto_tree_add_item(subTree, hf_wtp_tpi_psn,
294 tvb, offset, 1, bo_little_endian);
296 case 0x04: /* SDU boundary */
299 case 0x05: /* Frame boundary */
307 /* Code to actually dissect the packets */
309 dissect_wtp_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
311 static GString *szInfo = NULL;
312 int offCur = 0; /* current offset from start of WTP data */
316 /* continuation flag */
317 unsigned char fCon; /* Continue flag */
318 unsigned char fRID; /* Re-transmission indicator*/
319 unsigned char fTTR = '\0'; /* Transmission trailer */
320 guint cbHeader = 0; /* Fixed header length */
321 guint vHeader = 0; /* Variable header length*/
324 /* Set up structures we'll need to add the protocol subtree and manage it */
326 proto_tree *wtp_tree = NULL;
329 char clsTransaction = ' ';
330 int numMissing = 0; /* Number of missing packets in a negative ack */
332 tvbuff_t *wsp_tvb = NULL;
333 fragment_data *fd_head = NULL;
334 guint8 psn = 0; /* Packet sequence number*/
335 guint16 TID = 0; /* Transaction-Id */
338 szInfo = g_string_sized_new(32);
340 b0 = tvb_get_guint8 (tvb, offCur + 0);
341 /* Discover Concatenated PDUs */
343 guint c_fieldlen = 0; /* Length of length-field */
344 guint c_pdulen = 0; /* Length of conc. PDU */
347 ti = proto_tree_add_item(tree, proto_wtp,
348 tvb, offCur, 1, bo_little_endian);
349 wtp_tree = proto_item_add_subtree(ti, ett_wtp);
353 while (offCur < (int) tvb_reported_length(tvb)) {
354 b0 = tvb_get_guint8(tvb, offCur + 0);
357 c_pdulen = ((b0 & 0x7f) << 8) | tvb_get_guint8(tvb, offCur + 1);
363 proto_tree_add_uint(wtp_tree, hf_wtp_header_sub_pdu_size,
364 tvb, offCur, c_fieldlen, c_pdulen);
366 if (i > 1 && check_col(pinfo->cinfo, COL_INFO)) {
367 col_append_str(pinfo->cinfo, COL_INFO, ", ");
369 wsp_tvb = tvb_new_subset(tvb, offCur + c_fieldlen, c_pdulen, c_pdulen);
370 dissect_wtp_common(wsp_tvb, pinfo, wtp_tree);
371 offCur += c_fieldlen + c_pdulen;
377 fRID = retransmission_indicator(b0);
380 /* Develop the string to put in the Info column */
381 g_string_sprintf(szInfo, "WTP %s",
382 val_to_str(pdut, vals_pdu_type, "Unknown PDU type 0x%x"));
386 fTTR = transmission_trailer(b0);
387 TID = tvb_get_ntohs(tvb, offCur + 1);
389 clsTransaction = transaction_class(tvb_get_guint8(tvb, offCur + 3));
390 g_string_sprintfa(szInfo, " Class %d", clsTransaction);
394 case SEGMENTED_INVOKE:
395 case SEGMENTED_RESULT:
396 fTTR = transmission_trailer(b0);
397 TID = tvb_get_ntohs(tvb, offCur + 1);
398 psn = tvb_get_guint8(tvb, offCur + 3);
407 fTTR = transmission_trailer(b0);
408 TID = tvb_get_ntohs(tvb, offCur + 1);
418 /* Variable number of missing packets */
419 numMissing = tvb_get_guint8(tvb, offCur + 3);
420 cbHeader = numMissing + 4;
427 g_string_append( szInfo, " R" );
429 if (fCon) { /* Scan variable part (TPI's), */
430 /* determine length of it */
435 tByte = tvb_get_guint8(tvb, offCur + cbHeader + vHeader);
437 if (tByte & 0x04) /* Long format */
438 vHeader = vHeader + tvb_get_guint8(tvb,
439 offCur + cbHeader + vHeader + 1) + 2;
441 vHeader = vHeader + (tByte & 0x03) + 1;
446 fprintf( stderr, "dissect_wtp: cbHeader = %d\n", cbHeader );
449 /* Only update "Info" column when no data in this PDU will
450 * be handed off to a subsequent dissector.
452 if (check_col(pinfo->cinfo, COL_INFO) &&
453 ((tvb_length_remaining(tvb, offCur + cbHeader + vHeader) <= 0) ||
454 (pdut == ACK) || (pdut==NEGATIVE_ACK) || (pdut==ABORT)) ) {
456 fprintf(stderr, "dissect_wtp: (6) About to set info_col header to %s\n", szInfo->str);
458 col_append_str(pinfo->cinfo, COL_INFO, szInfo->str);
460 /* In the interest of speed, if "tree" is NULL, don't do any work not
461 necessary to generate protocol tree items. */
464 fprintf(stderr, "dissect_wtp: cbHeader = %d\n", cbHeader);
466 ti = proto_tree_add_item(tree, proto_wtp, tvb, offCur, cbHeader + vHeader, bo_little_endian);
468 fprintf(stderr, "dissect_wtp: (7) Returned from proto_tree_add_item\n");
470 wtp_tree = proto_item_add_subtree(ti, ett_wtp);
472 /* Code to process the packet goes here */
474 fprintf(stderr, "dissect_wtp: cbHeader = %d\n", cbHeader);
475 fprintf(stderr, "dissect_wtp: offCur = %d\n", offCur);
477 /* Add common items: only CON and PDU Type */
480 hf_wtp_header_flag_continue, /* id */
482 offCur, /* start of highlight */
483 1, /* length of highlight*/
486 proto_tree_add_item(wtp_tree, hf_wtp_header_pdu_type, tvb, offCur, 1, bo_little_endian);
490 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_Trailer, tvb, offCur, 1, bo_little_endian);
491 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_RID, tvb, offCur, 1, bo_little_endian);
492 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_TID_response, tvb, offCur + 1, 2, bo_big_endian);
493 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_TID, tvb, offCur + 1, 2, bo_big_endian);
495 proto_tree_add_item(wtp_tree, hf_wtp_header_Inv_version , tvb, offCur + 3, 1, bo_little_endian);
496 proto_tree_add_item(wtp_tree, hf_wtp_header_Inv_flag_TIDNew, tvb, offCur + 3, 1, bo_little_endian);
497 proto_tree_add_item(wtp_tree, hf_wtp_header_Inv_flag_UP, tvb, offCur + 3, 1, bo_little_endian);
498 proto_tree_add_item(wtp_tree, hf_wtp_header_Inv_Reserved, tvb, offCur + 3, 1, bo_little_endian);
499 proto_tree_add_item(wtp_tree, hf_wtp_header_Inv_TransactionClass, tvb, offCur + 3, 1, bo_little_endian);
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);
510 proto_tree_add_item(wtp_tree, hf_wtp_header_Ack_flag_TVETOK, tvb, offCur, 1, bo_big_endian);
512 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_RID, tvb, offCur, 1, bo_little_endian);
513 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_TID_response, tvb, offCur + 1, 2, bo_big_endian);
514 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_TID, tvb, offCur + 1, 2, bo_big_endian);
518 abortType = tvb_get_guint8 (tvb, offCur) & 0x07;
519 proto_tree_add_item(wtp_tree, hf_wtp_header_Abort_type , tvb, offCur , 1, bo_little_endian);
520 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_TID_response, tvb, offCur + 1, 2, bo_big_endian);
521 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_TID, tvb, offCur + 1, 2, bo_big_endian);
523 if (abortType == PROVIDER)
525 proto_tree_add_item( wtp_tree, hf_wtp_header_Abort_reason_provider , tvb, offCur + 3 , 1, bo_little_endian);
527 else if (abortType == USER)
529 proto_tree_add_item(wtp_tree, hf_wtp_header_Abort_reason_user , tvb, offCur + 3 , 1, bo_little_endian);
533 case SEGMENTED_INVOKE:
534 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_Trailer, tvb, offCur, 1, bo_little_endian);
535 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_RID, tvb, offCur, 1, bo_little_endian);
536 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_TID_response, tvb, offCur + 1, 2, bo_big_endian);
537 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_TID, tvb, offCur + 1, 2, bo_big_endian);
539 proto_tree_add_item(wtp_tree, hf_wtp_header_sequence_number , tvb, offCur + 3, 1, bo_little_endian);
542 case SEGMENTED_RESULT:
543 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_Trailer, tvb, offCur, 1, bo_little_endian);
544 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_RID, tvb, offCur, 1, bo_little_endian);
545 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_TID_response, tvb, offCur + 1, 2, bo_big_endian);
546 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_TID, tvb, offCur + 1, 2, bo_big_endian);
548 proto_tree_add_item(wtp_tree, hf_wtp_header_sequence_number , tvb, offCur + 3, 1, bo_little_endian);
552 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_RID, tvb, offCur, 1, bo_little_endian);
553 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_TID_response, tvb, offCur + 1, 2, bo_big_endian);
554 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_TID, tvb, offCur + 1, 2, bo_big_endian);
556 proto_tree_add_item(wtp_tree, hf_wtp_header_missing_packets , tvb, offCur + 3, 1, bo_little_endian);
557 /* Iterate through missing packets */
558 for (i = 0; i < numMissing; i++)
560 proto_tree_add_item(wtp_tree, hf_wtp_header_sequence_number, tvb, offCur + 4 + i, 1, bo_little_endian);
567 if (fCon) { /* Now, analyze variable part */
570 unsigned char tpiLen;
573 vHeader = 0; /* Start scan all over */
576 tByte = tvb_get_guint8(tvb, offCur + cbHeader + vHeader);
578 if (tByte & 0x04) /* Long TPI */
579 tpiLen = 2 + tvb_get_guint8(tvb,
580 offCur + cbHeader + vHeader + 1);
582 tpiLen = 1 + (tByte & 0x03);
583 tmp_tvb = tvb_new_subset(tvb, offCur + cbHeader + vHeader,
585 wtp_handle_tpi(wtp_tree, tmp_tvb);
589 /* There is no variable part */
590 } /* End of variable part of header */
593 fprintf(stderr, "dissect_wtp: (4) tree was %p\n", tree);
597 * Any remaining data ought to be WSP data (if not WTP ACK, NACK
598 * or ABORT pdu), so hand off (defragmented) to the WSP dissector
600 if ((tvb_reported_length_remaining(tvb, offCur + cbHeader + vHeader) > 0) &&
601 ! ((pdut==ACK) || (pdut==NEGATIVE_ACK) || (pdut==ABORT)))
603 int dataOffset = offCur + cbHeader + vHeader;
604 gint dataLen = tvb_reported_length_remaining(tvb, dataOffset);
605 gboolean save_fragmented;
607 if (((pdut == SEGMENTED_INVOKE) || (pdut == SEGMENTED_RESULT) ||
608 (((pdut == INVOKE) || (pdut == RESULT)) && (!fTTR))) &&
609 tvb_bytes_exist(tvb, dataOffset, dataLen))
610 { /* 1st part of segment */
611 save_fragmented = pinfo->fragmented;
612 pinfo->fragmented = TRUE;
613 fd_head = fragment_add_seq(tvb, dataOffset, pinfo, TID,
614 wtp_fragment_table, psn, dataLen, !fTTR);
615 if (fd_head != NULL) /* Reassembled */
617 /* Reassembly is complete; show the reassembled PDU */
618 wsp_tvb = tvb_new_real_data(fd_head->data,
621 tvb_set_child_real_data_tvbuff(tvb, wsp_tvb);
622 add_new_data_source(pinfo, wsp_tvb,
624 pinfo->fragmented = FALSE;
626 /* show all fragments */
627 show_fragment_seq_tree(fd_head, &wtp_frag_items,
628 wtp_tree, pinfo, wsp_tvb);
630 call_dissector(wsp_handle, wsp_tvb, pinfo, tree);
634 /* Reassembly isn't complete; just show the fragment */
635 if (check_col(pinfo->cinfo, COL_INFO)) /* Won't call WSP so display */
636 col_append_str(pinfo->cinfo, COL_INFO, szInfo->str);
638 proto_tree_add_text(wtp_tree, tvb, dataOffset, -1, "Payload");
640 pinfo->fragmented = save_fragmented;
645 * Normal packet, or not all the fragment data is available;
646 * call next dissector, unless this is a segment of a
647 * segmented invoke or result and isn't the first segment.
649 if ((pdut == SEGMENTED_INVOKE || pdut == SEGMENTED_RESULT) &&
652 * This is a segmented invoke or result, and not the first
653 * segment; just show it as a segmented invoke or result,
654 * don't try to dissect its payload.
656 if (check_col(pinfo->cinfo, COL_INFO))
657 col_add_fstr(pinfo->cinfo, COL_INFO,
659 (pdut == SEGMENTED_INVOKE ?
660 "Segmented Invoke" : "Segmented Result"),
663 proto_tree_add_text(wtp_tree, tvb, dataOffset, -1, "Payload");
665 wsp_tvb = tvb_new_subset(tvb, dataOffset, -1, -1);
666 call_dissector(wsp_handle, wsp_tvb, pinfo, tree);
673 * Called directly from UDP.
674 * Put "WTP+WSP" into the "Protocol" column.
677 dissect_wtp_fromudp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
679 if (check_col(pinfo->cinfo, COL_PROTOCOL))
680 col_set_str(pinfo->cinfo, COL_PROTOCOL, "WTP+WSP" );
681 if (check_col(pinfo->cinfo, COL_INFO))
682 col_clear(pinfo->cinfo, COL_INFO);
684 dissect_wtp_common(tvb, pinfo, tree);
688 * Called from a higher-level WAP dissector, presumably WTLS.
689 * Put "WTLS+WSP+WTP" to the "Protocol" column.
691 * XXX - is this supposed to be called from WTLS? If so, we're not
694 * XXX - can this be called from any other dissector?
697 dissect_wtp_fromwap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
699 if (check_col(pinfo->cinfo, COL_PROTOCOL))
700 col_set_str(pinfo->cinfo, COL_PROTOCOL, "WTLS+WTP+WSP" );
701 if (check_col(pinfo->cinfo, COL_INFO))
702 col_clear(pinfo->cinfo, COL_INFO);
704 dissect_wtp_common(tvb, pinfo, tree);
707 /* Register the protocol with Ethereal */
709 proto_register_wtp(void)
712 /* Setup list of header fields */
713 static hf_register_info hf[] = {
714 { &hf_wtp_header_sub_pdu_size,
717 FT_UINT16, BASE_DEC, NULL, 0x0,
718 "Size of Sub-PDU (bytes)", HFILL
721 { &hf_wtp_header_flag_continue,
724 FT_BOOLEAN, 8, TFS( &continue_truth ), 0x80,
725 "Continue Flag", HFILL
728 { &hf_wtp_header_pdu_type,
731 FT_UINT8, BASE_HEX, VALS( vals_pdu_type ), 0x78,
735 { &hf_wtp_header_flag_Trailer,
738 FT_UINT8, BASE_HEX, VALS( vals_transaction_trailer ), 0x06,
739 "Trailer Flags", HFILL
742 { &hf_wtp_header_flag_RID,
743 { "Re-transmission Indicator",
745 FT_BOOLEAN, 8, TFS( &RID_truth ), 0x01,
746 "Re-transmission Indicator", HFILL
749 { &hf_wtp_header_flag_TID_response,
752 FT_BOOLEAN, 16, TFS( &tid_response_truth ), 0x8000,
753 "TID Response", HFILL
756 { &hf_wtp_header_flag_TID,
759 FT_UINT16, BASE_HEX, NULL, 0x7FFF,
760 "Transaction ID", HFILL
763 { &hf_wtp_header_Inv_version,
765 "wtp.header.version",
766 FT_UINT8, BASE_HEX, VALS( vals_version ), 0xC0,
770 { &hf_wtp_header_Inv_flag_TIDNew,
773 FT_BOOLEAN, 8, TFS( &TIDNew_truth ), 0x20,
777 { &hf_wtp_header_Inv_flag_UP,
780 FT_BOOLEAN, 8, TFS( &UP_truth ), 0x10,
784 { &hf_wtp_header_Inv_Reserved,
787 FT_UINT8, BASE_HEX, NULL, 0x0C,
791 { &hf_wtp_header_Inv_TransactionClass,
792 { "Transaction Class",
793 "wtp.inv.transaction_class",
794 FT_UINT8, BASE_HEX, VALS( vals_transaction_classes ), 0x03,
795 "Transaction Class", HFILL
798 { &hf_wtp_header_Ack_flag_TVETOK,
801 FT_BOOLEAN, 8, TFS( &TVETOK_truth ), 0x04,
802 "Tve/Tok flag", HFILL
805 { &hf_wtp_header_Abort_type,
808 FT_UINT8, BASE_HEX, VALS ( vals_abort_type ), 0x07,
812 { &hf_wtp_header_Abort_reason_provider,
814 "wtp.abort.reason.provider",
815 FT_UINT8, BASE_HEX, VALS ( vals_abort_reason_provider ), 0x00,
816 "Abort Reason", HFILL
819 /* Assume WSP is the user and use its reason codes */
820 { &hf_wtp_header_Abort_reason_user,
822 "wtp.abort.reason.user",
823 FT_UINT8, BASE_HEX, VALS ( vals_wsp_reason_codes ), 0x00,
824 "Abort Reason", HFILL
827 { &hf_wtp_header_sequence_number,
828 { "Packet Sequence Number",
829 "wtp.header.sequence",
830 FT_UINT8, BASE_DEC, NULL, 0x00,
831 "Packet Sequence Number", HFILL
834 { &hf_wtp_header_missing_packets,
836 "wtp.header.missing_packets",
837 FT_UINT8, BASE_DEC, NULL, 0x00,
838 "Missing Packets", HFILL
841 { &hf_wtp_header_variable_part,
842 { "Header: Variable part",
843 "wtp.header_variable_part",
844 FT_BYTES, BASE_HEX, NULL, 0x0,
845 "Variable part of the header", HFILL
851 FT_BYTES, BASE_HEX, NULL, 0x0,
858 FT_UINT8, BASE_HEX, VALS(vals_tpi_type), 0x00,
859 "Identification of the Transport Information Item", HFILL
863 { "Packet sequence number",
865 FT_UINT8, BASE_DEC, NULL, 0x00,
866 "Sequence number of this packet", HFILL
872 FT_UINT8, BASE_HEX, VALS(vals_tpi_opt), 0x00,
873 "The given option for this TPI", HFILL
876 { &hf_wtp_tpi_optval,
879 FT_NONE, BASE_NONE, NULL, 0x00,
880 "The value that is supplied with this option", HFILL
886 FT_NONE, BASE_NONE, NULL, 0x00,
887 "The information being send by this TPI", HFILL
891 /* Fragment fields */
892 { &hf_wtp_fragment_overlap,
893 { "Fragment overlap",
894 "wtp.fragment.overlap",
895 FT_BOOLEAN, BASE_NONE, NULL, 0x0,
896 "Fragment overlaps with other fragments", HFILL
899 { &hf_wtp_fragment_overlap_conflict,
900 { "Conflicting data in fragment overlap",
901 "wtp.fragment.overlap.conflict",
902 FT_BOOLEAN, BASE_NONE, NULL, 0x0,
903 "Overlapping fragments contained conflicting data", HFILL
906 { &hf_wtp_fragment_multiple_tails,
907 { "Multiple tail fragments found",
908 "wtp.fragment.multipletails",
909 FT_BOOLEAN, BASE_NONE, NULL, 0x0,
910 "Several tails were found when defragmenting the packet", HFILL
913 { &hf_wtp_fragment_too_long_fragment,
914 { "Fragment too long",
915 "wtp.fragment.toolongfragment",
916 FT_BOOLEAN, BASE_NONE, NULL, 0x0,
917 "Fragment contained data past end of packet", HFILL
920 { &hf_wtp_fragment_error,
921 { "Defragmentation error",
922 "wtp.fragment.error",
923 FT_FRAMENUM, BASE_NONE, NULL, 0x0,
924 "Defragmentation error due to illegal fragments", HFILL
930 FT_FRAMENUM, BASE_NONE, NULL, 0x0,
931 "WTP Fragment", HFILL
937 FT_NONE, BASE_NONE, NULL, 0x0,
938 "WTP Fragments", HFILL
943 /* Setup protocol subtree array */
944 static gint *ett[] = {
952 /* Register the protocol name and description */
953 proto_wtp = proto_register_protocol(
954 "Wireless Transaction Protocol", /* protocol name for use by ethereal */
955 "WTP", /* short version of name */
956 "wap-wsp-wtp" /* Abbreviated protocol name, should Match IANA
957 < URL:http://www.isi.edu/in-notes/iana/assignments/port-numbers/ >
961 /* Required calls to register the header fields and subtrees used */
962 proto_register_field_array(proto_wtp, hf, array_length(hf));
963 proto_register_subtree_array(ett, array_length(ett));
965 register_dissector("wtp", dissect_wtp_fromwap, proto_wtp);
966 register_dissector("wtp-udp", dissect_wtp_fromudp, proto_wtp);
967 register_init_routine(wtp_defragment_init);
971 proto_reg_handoff_wtp(void)
973 dissector_handle_t wtp_fromudp_handle;
976 * Get a handle for the connection-oriented WSP dissector - if WTP
977 * PDUs have data, it is WSP.
979 wsp_handle = find_dissector("wsp-co");
981 wtp_fromudp_handle = find_dissector("wtp-udp");
982 dissector_add("udp.port", UDP_PORT_WTP_WSP, wtp_fromudp_handle);
983 dissector_add("smpp.udh.port", UDP_PORT_WTP_WSP, wtp_fromudp_handle);