3 * Routines to dissect WTP component of WAP traffic.
5 * $Id: packet-wtp.c,v 1.53 2003/11/05 04:23:59 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_wtp_sub_pdu_tree = ETT_EMPTY;
202 static gint ett_header = ETT_EMPTY;
203 static gint ett_tpilist = ETT_EMPTY;
204 static gint ett_wsp_fragments = ETT_EMPTY;
205 static gint ett_wtp_fragment = ETT_EMPTY;
207 static const fragment_items wtp_frag_items = {
212 &hf_wtp_fragment_overlap,
213 &hf_wtp_fragment_overlap_conflict,
214 &hf_wtp_fragment_multiple_tails,
215 &hf_wtp_fragment_too_long_fragment,
216 &hf_wtp_fragment_error,
221 /* Handle for WSP dissector */
222 static dissector_handle_t wsp_handle;
227 static GHashTable *wtp_fragment_table = NULL;
230 wtp_defragment_init(void)
232 fragment_table_init(&wtp_fragment_table);
236 * Extract some bitfields
238 #define pdu_type(octet) (((octet) >> 3) & 0x0F) /* Note pdu type must not be 0x00 */
239 #define transaction_class(octet) ((octet) & 0x03) /* ......XX */
240 #define transmission_trailer(octet) (((octet) >> 1) & 0x01) /* ......X. */
242 static char retransmission_indicator(unsigned char octet)
244 switch (pdu_type(octet)) {
248 case SEGMENTED_INVOKE:
249 case SEGMENTED_RESULT:
251 return octet & 0x01; /* .......X */
261 wtp_handle_tpi(proto_tree *tree, tvbuff_t *tvb)
267 proto_item *subTree = NULL;
269 tByte = tvb_get_guint8(tvb, offset++);
270 tType = (tByte & 0x78) >> 3;
271 if (tByte & 0x04) /* Long TPI */
272 tLen = tvb_get_guint8(tvb, offset++);
275 subTree = proto_tree_add_uint(tree, hf_wtp_tpi_type,
276 tvb, 0, tvb_length(tvb), tType);
277 proto_item_add_subtree(subTree, ett_tpilist);
279 case 0x00: /* Error*/
282 case 0x01: /* Info */
283 /* Beware, untested case here */
284 proto_tree_add_item(subTree, hf_wtp_tpi_info,
285 tvb, offset, tLen, bo_little_endian);
287 case 0x02: /* Option */
288 proto_tree_add_item(subTree, hf_wtp_tpi_opt,
289 tvb, offset++, 1, bo_little_endian);
290 proto_tree_add_item(subTree, hf_wtp_tpi_optval,
291 tvb, offset, tLen - 1, bo_little_endian);
294 proto_tree_add_item(subTree, hf_wtp_tpi_psn,
295 tvb, offset, 1, bo_little_endian);
297 case 0x04: /* SDU boundary */
300 case 0x05: /* Frame boundary */
308 /* Code to actually dissect the packets */
310 dissect_wtp_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
312 static GString *szInfo = NULL;
313 int offCur = 0; /* current offset from start of WTP data */
317 /* continuation flag */
318 unsigned char fCon; /* Continue flag */
319 unsigned char fRID; /* Re-transmission indicator*/
320 unsigned char fTTR = '\0'; /* Transmission trailer */
321 guint cbHeader = 0; /* Fixed header length */
322 guint vHeader = 0; /* Variable header length*/
325 /* Set up structures we'll need to add the protocol subtree and manage it */
327 proto_tree *wtp_tree = NULL;
330 char clsTransaction = ' ';
331 int numMissing = 0; /* Number of missing packets in a negative ack */
333 tvbuff_t *wsp_tvb = NULL;
334 fragment_data *fd_head = NULL;
335 guint8 psn = 0; /* Packet sequence number*/
336 guint16 TID = 0; /* Transaction-Id */
339 szInfo = g_string_sized_new(32);
341 b0 = tvb_get_guint8 (tvb, offCur + 0);
342 /* Discover Concatenated PDUs */
344 guint c_fieldlen = 0; /* Length of length-field */
345 guint c_pdulen = 0; /* Length of conc. PDU */
348 ti = proto_tree_add_item(tree, proto_wtp,
349 tvb, offCur, 1, bo_little_endian);
350 wtp_tree = proto_item_add_subtree(ti, ett_wtp_sub_pdu_tree);
354 while (offCur < (int) tvb_reported_length(tvb)) {
355 b0 = tvb_get_guint8(tvb, offCur + 0);
358 c_pdulen = ((b0 & 0x7f) << 8) | tvb_get_guint8(tvb, offCur + 1);
364 proto_tree_add_uint(wtp_tree, hf_wtp_header_sub_pdu_size,
365 tvb, offCur, c_fieldlen, c_pdulen);
367 if (i > 1 && check_col(pinfo->cinfo, COL_INFO)) {
368 col_append_str(pinfo->cinfo, COL_INFO, ", ");
370 wsp_tvb = tvb_new_subset(tvb, offCur + c_fieldlen, c_pdulen, c_pdulen);
371 dissect_wtp_common(wsp_tvb, pinfo, wtp_tree);
372 offCur += c_fieldlen + c_pdulen;
378 fRID = retransmission_indicator(b0);
381 /* Develop the string to put in the Info column */
382 g_string_sprintf(szInfo, "WTP %s",
383 val_to_str(pdut, vals_pdu_type, "Unknown PDU type 0x%x"));
387 fTTR = transmission_trailer(b0);
388 TID = tvb_get_ntohs(tvb, offCur + 1);
390 clsTransaction = transaction_class(tvb_get_guint8(tvb, offCur + 3));
391 g_string_sprintfa(szInfo, " Class %d", clsTransaction);
395 case SEGMENTED_INVOKE:
396 case SEGMENTED_RESULT:
397 fTTR = transmission_trailer(b0);
398 TID = tvb_get_ntohs(tvb, offCur + 1);
399 psn = tvb_get_guint8(tvb, offCur + 3);
408 fTTR = transmission_trailer(b0);
409 TID = tvb_get_ntohs(tvb, offCur + 1);
419 /* Variable number of missing packets */
420 numMissing = tvb_get_guint8(tvb, offCur + 3);
421 cbHeader = numMissing + 4;
428 g_string_append( szInfo, " R" );
430 if (fCon) { /* Scan variable part (TPI's), */
431 /* determine length of it */
436 tByte = tvb_get_guint8(tvb, offCur + cbHeader + vHeader);
438 if (tByte & 0x04) /* Long format */
439 vHeader = vHeader + tvb_get_guint8(tvb,
440 offCur + cbHeader + vHeader + 1) + 2;
442 vHeader = vHeader + (tByte & 0x03) + 1;
447 fprintf( stderr, "dissect_wtp: cbHeader = %d\n", cbHeader );
450 /* Only update "Info" column when no data in this PDU will
451 * be handed off to a subsequent dissector.
453 if (check_col(pinfo->cinfo, COL_INFO) &&
454 ((tvb_length_remaining(tvb, offCur + cbHeader + vHeader) <= 0) ||
455 (pdut == ACK) || (pdut==NEGATIVE_ACK) || (pdut==ABORT)) ) {
457 fprintf(stderr, "dissect_wtp: (6) About to set info_col header to %s\n", szInfo->str);
459 col_append_str(pinfo->cinfo, COL_INFO, szInfo->str);
461 /* In the interest of speed, if "tree" is NULL, don't do any work not
462 necessary to generate protocol tree items. */
465 fprintf(stderr, "dissect_wtp: cbHeader = %d\n", cbHeader);
467 ti = proto_tree_add_item(tree, proto_wtp, tvb, offCur, cbHeader + vHeader, bo_little_endian);
469 fprintf(stderr, "dissect_wtp: (7) Returned from proto_tree_add_item\n");
471 wtp_tree = proto_item_add_subtree(ti, ett_wtp);
473 /* Code to process the packet goes here */
475 fprintf(stderr, "dissect_wtp: cbHeader = %d\n", cbHeader);
476 fprintf(stderr, "dissect_wtp: offCur = %d\n", offCur);
478 /* Add common items: only CON and PDU Type */
481 hf_wtp_header_flag_continue, /* id */
483 offCur, /* start of highlight */
484 1, /* length of highlight*/
487 proto_tree_add_item(wtp_tree, hf_wtp_header_pdu_type, tvb, offCur, 1, bo_little_endian);
491 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_Trailer, tvb, offCur, 1, bo_little_endian);
492 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_RID, tvb, offCur, 1, bo_little_endian);
493 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_TID_response, tvb, offCur + 1, 2, bo_big_endian);
494 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_TID, tvb, offCur + 1, 2, bo_big_endian);
496 proto_tree_add_item(wtp_tree, hf_wtp_header_Inv_version , tvb, offCur + 3, 1, bo_little_endian);
497 proto_tree_add_item(wtp_tree, hf_wtp_header_Inv_flag_TIDNew, tvb, offCur + 3, 1, bo_little_endian);
498 proto_tree_add_item(wtp_tree, hf_wtp_header_Inv_flag_UP, tvb, offCur + 3, 1, bo_little_endian);
499 proto_tree_add_item(wtp_tree, hf_wtp_header_Inv_Reserved, tvb, offCur + 3, 1, bo_little_endian);
500 proto_tree_add_item(wtp_tree, hf_wtp_header_Inv_TransactionClass, tvb, offCur + 3, 1, bo_little_endian);
504 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_Trailer, tvb, offCur, 1, bo_little_endian);
505 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_RID, tvb, offCur, 1, bo_little_endian);
506 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_TID_response, tvb, offCur + 1, 2, bo_big_endian);
507 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_TID, tvb, offCur + 1, 2, bo_big_endian);
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);
519 abortType = tvb_get_guint8 (tvb, offCur) & 0x07;
520 proto_tree_add_item(wtp_tree, hf_wtp_header_Abort_type , tvb, offCur , 1, bo_little_endian);
521 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_TID_response, tvb, offCur + 1, 2, bo_big_endian);
522 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_TID, tvb, offCur + 1, 2, bo_big_endian);
524 if (abortType == PROVIDER)
526 proto_tree_add_item( wtp_tree, hf_wtp_header_Abort_reason_provider , tvb, offCur + 3 , 1, bo_little_endian);
528 else if (abortType == USER)
530 proto_tree_add_item(wtp_tree, hf_wtp_header_Abort_reason_user , tvb, offCur + 3 , 1, bo_little_endian);
534 case SEGMENTED_INVOKE:
535 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_Trailer, tvb, offCur, 1, bo_little_endian);
536 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_RID, tvb, offCur, 1, bo_little_endian);
537 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_TID_response, tvb, offCur + 1, 2, bo_big_endian);
538 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_TID, tvb, offCur + 1, 2, bo_big_endian);
540 proto_tree_add_item(wtp_tree, hf_wtp_header_sequence_number , tvb, offCur + 3, 1, bo_little_endian);
543 case SEGMENTED_RESULT:
544 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_Trailer, tvb, offCur, 1, bo_little_endian);
545 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_RID, tvb, offCur, 1, bo_little_endian);
546 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_TID_response, tvb, offCur + 1, 2, bo_big_endian);
547 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_TID, tvb, offCur + 1, 2, bo_big_endian);
549 proto_tree_add_item(wtp_tree, hf_wtp_header_sequence_number , tvb, offCur + 3, 1, bo_little_endian);
553 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_RID, tvb, offCur, 1, bo_little_endian);
554 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_TID_response, tvb, offCur + 1, 2, bo_big_endian);
555 proto_tree_add_item(wtp_tree, hf_wtp_header_flag_TID, tvb, offCur + 1, 2, bo_big_endian);
557 proto_tree_add_item(wtp_tree, hf_wtp_header_missing_packets , tvb, offCur + 3, 1, bo_little_endian);
558 /* Iterate through missing packets */
559 for (i = 0; i < numMissing; i++)
561 proto_tree_add_item(wtp_tree, hf_wtp_header_sequence_number, tvb, offCur + 4 + i, 1, bo_little_endian);
568 if (fCon) { /* Now, analyze variable part */
571 unsigned char tpiLen;
574 vHeader = 0; /* Start scan all over */
577 tByte = tvb_get_guint8(tvb, offCur + cbHeader + vHeader);
579 if (tByte & 0x04) /* Long TPI */
580 tpiLen = 2 + tvb_get_guint8(tvb,
581 offCur + cbHeader + vHeader + 1);
583 tpiLen = 1 + (tByte & 0x03);
584 tmp_tvb = tvb_new_subset(tvb, offCur + cbHeader + vHeader,
586 wtp_handle_tpi(wtp_tree, tmp_tvb);
590 /* There is no variable part */
591 } /* End of variable part of header */
594 fprintf(stderr, "dissect_wtp: (4) tree was %p\n", tree);
598 * Any remaining data ought to be WSP data (if not WTP ACK, NACK
599 * or ABORT pdu), so hand off (defragmented) to the WSP dissector.
600 * Note that the last packet of a fragmented WTP message needn't
601 * contain any data, so we allow payloadless packets to be
602 * reassembled. (XXX - does the reassembly code handle this
603 * for packets other than the last packet?)
605 if ((tvb_reported_length_remaining(tvb, offCur + cbHeader + vHeader) >= 0) &&
606 ! ((pdut==ACK) || (pdut==NEGATIVE_ACK) || (pdut==ABORT)))
608 int dataOffset = offCur + cbHeader + vHeader;
609 gint dataLen = tvb_reported_length_remaining(tvb, dataOffset);
610 gboolean save_fragmented;
612 if (((pdut == SEGMENTED_INVOKE) || (pdut == SEGMENTED_RESULT) ||
613 (((pdut == INVOKE) || (pdut == RESULT)) && (!fTTR))) &&
614 tvb_bytes_exist(tvb, dataOffset, dataLen))
615 { /* 1st part of segment */
616 save_fragmented = pinfo->fragmented;
617 pinfo->fragmented = TRUE;
618 fd_head = fragment_add_seq(tvb, dataOffset, pinfo, TID,
619 wtp_fragment_table, psn, dataLen, !fTTR);
620 if (fd_head != NULL) /* Reassembled */
622 /* Reassembly is complete; show the reassembled PDU */
623 wsp_tvb = tvb_new_real_data(fd_head->data,
626 tvb_set_child_real_data_tvbuff(tvb, wsp_tvb);
627 add_new_data_source(pinfo, wsp_tvb,
629 pinfo->fragmented = FALSE;
631 /* show all fragments */
632 show_fragment_seq_tree(fd_head, &wtp_frag_items,
633 wtp_tree, pinfo, wsp_tvb);
635 call_dissector(wsp_handle, wsp_tvb, pinfo, tree);
639 /* Reassembly isn't complete; just show the fragment */
640 if (check_col(pinfo->cinfo, COL_INFO)) /* Won't call WSP so display */
641 col_append_str(pinfo->cinfo, COL_INFO, szInfo->str);
643 proto_tree_add_text(wtp_tree, tvb, dataOffset, -1, "Payload");
645 pinfo->fragmented = save_fragmented;
650 * Normal packet, or not all the fragment data is available;
651 * call next dissector, unless this is a segment of a
652 * segmented invoke or result and isn't the first segment.
654 if ((pdut == SEGMENTED_INVOKE || pdut == SEGMENTED_RESULT) &&
657 * This is a segmented invoke or result, and not the first
658 * segment; just show it as a segmented invoke or result,
659 * don't try to dissect its payload.
661 if (check_col(pinfo->cinfo, COL_INFO))
662 col_add_fstr(pinfo->cinfo, COL_INFO,
664 (pdut == SEGMENTED_INVOKE ?
665 "Segmented Invoke" : "Segmented Result"),
668 proto_tree_add_text(wtp_tree, tvb, dataOffset, -1, "Payload");
670 wsp_tvb = tvb_new_subset(tvb, dataOffset, -1, -1);
671 call_dissector(wsp_handle, wsp_tvb, pinfo, tree);
678 * Called directly from UDP.
679 * Put "WTP+WSP" into the "Protocol" column.
682 dissect_wtp_fromudp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
684 if (check_col(pinfo->cinfo, COL_PROTOCOL))
685 col_set_str(pinfo->cinfo, COL_PROTOCOL, "WTP+WSP" );
686 if (check_col(pinfo->cinfo, COL_INFO))
687 col_clear(pinfo->cinfo, COL_INFO);
689 dissect_wtp_common(tvb, pinfo, tree);
693 * Called from a higher-level WAP dissector, presumably WTLS.
694 * Put "WTLS+WSP+WTP" to the "Protocol" column.
696 * XXX - is this supposed to be called from WTLS? If so, we're not
699 * XXX - can this be called from any other dissector?
702 dissect_wtp_fromwap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
704 if (check_col(pinfo->cinfo, COL_PROTOCOL))
705 col_set_str(pinfo->cinfo, COL_PROTOCOL, "WTLS+WTP+WSP" );
706 if (check_col(pinfo->cinfo, COL_INFO))
707 col_clear(pinfo->cinfo, COL_INFO);
709 dissect_wtp_common(tvb, pinfo, tree);
712 /* Register the protocol with Ethereal */
714 proto_register_wtp(void)
717 /* Setup list of header fields */
718 static hf_register_info hf[] = {
719 { &hf_wtp_header_sub_pdu_size,
722 FT_UINT16, BASE_DEC, NULL, 0x0,
723 "Size of Sub-PDU (bytes)", HFILL
726 { &hf_wtp_header_flag_continue,
729 FT_BOOLEAN, 8, TFS( &continue_truth ), 0x80,
730 "Continue Flag", HFILL
733 { &hf_wtp_header_pdu_type,
736 FT_UINT8, BASE_HEX, VALS( vals_pdu_type ), 0x78,
740 { &hf_wtp_header_flag_Trailer,
743 FT_UINT8, BASE_HEX, VALS( vals_transaction_trailer ), 0x06,
744 "Trailer Flags", HFILL
747 { &hf_wtp_header_flag_RID,
748 { "Re-transmission Indicator",
750 FT_BOOLEAN, 8, TFS( &RID_truth ), 0x01,
751 "Re-transmission Indicator", HFILL
754 { &hf_wtp_header_flag_TID_response,
757 FT_BOOLEAN, 16, TFS( &tid_response_truth ), 0x8000,
758 "TID Response", HFILL
761 { &hf_wtp_header_flag_TID,
764 FT_UINT16, BASE_HEX, NULL, 0x7FFF,
765 "Transaction ID", HFILL
768 { &hf_wtp_header_Inv_version,
770 "wtp.header.version",
771 FT_UINT8, BASE_HEX, VALS( vals_version ), 0xC0,
775 { &hf_wtp_header_Inv_flag_TIDNew,
778 FT_BOOLEAN, 8, TFS( &TIDNew_truth ), 0x20,
782 { &hf_wtp_header_Inv_flag_UP,
785 FT_BOOLEAN, 8, TFS( &UP_truth ), 0x10,
789 { &hf_wtp_header_Inv_Reserved,
792 FT_UINT8, BASE_HEX, NULL, 0x0C,
796 { &hf_wtp_header_Inv_TransactionClass,
797 { "Transaction Class",
798 "wtp.inv.transaction_class",
799 FT_UINT8, BASE_HEX, VALS( vals_transaction_classes ), 0x03,
800 "Transaction Class", HFILL
803 { &hf_wtp_header_Ack_flag_TVETOK,
806 FT_BOOLEAN, 8, TFS( &TVETOK_truth ), 0x04,
807 "Tve/Tok flag", HFILL
810 { &hf_wtp_header_Abort_type,
813 FT_UINT8, BASE_HEX, VALS ( vals_abort_type ), 0x07,
817 { &hf_wtp_header_Abort_reason_provider,
819 "wtp.abort.reason.provider",
820 FT_UINT8, BASE_HEX, VALS ( vals_abort_reason_provider ), 0x00,
821 "Abort Reason", HFILL
824 /* Assume WSP is the user and use its reason codes */
825 { &hf_wtp_header_Abort_reason_user,
827 "wtp.abort.reason.user",
828 FT_UINT8, BASE_HEX, VALS ( vals_wsp_reason_codes ), 0x00,
829 "Abort Reason", HFILL
832 { &hf_wtp_header_sequence_number,
833 { "Packet Sequence Number",
834 "wtp.header.sequence",
835 FT_UINT8, BASE_DEC, NULL, 0x00,
836 "Packet Sequence Number", HFILL
839 { &hf_wtp_header_missing_packets,
841 "wtp.header.missing_packets",
842 FT_UINT8, BASE_DEC, NULL, 0x00,
843 "Missing Packets", HFILL
846 { &hf_wtp_header_variable_part,
847 { "Header: Variable part",
848 "wtp.header_variable_part",
849 FT_BYTES, BASE_HEX, NULL, 0x0,
850 "Variable part of the header", HFILL
856 FT_BYTES, BASE_HEX, NULL, 0x0,
863 FT_UINT8, BASE_HEX, VALS(vals_tpi_type), 0x00,
864 "Identification of the Transport Information Item", HFILL
868 { "Packet sequence number",
870 FT_UINT8, BASE_DEC, NULL, 0x00,
871 "Sequence number of this packet", HFILL
877 FT_UINT8, BASE_HEX, VALS(vals_tpi_opt), 0x00,
878 "The given option for this TPI", HFILL
881 { &hf_wtp_tpi_optval,
884 FT_NONE, BASE_NONE, NULL, 0x00,
885 "The value that is supplied with this option", HFILL
891 FT_NONE, BASE_NONE, NULL, 0x00,
892 "The information being send by this TPI", HFILL
896 /* Fragment fields */
897 { &hf_wtp_fragment_overlap,
898 { "Fragment overlap",
899 "wtp.fragment.overlap",
900 FT_BOOLEAN, BASE_NONE, NULL, 0x0,
901 "Fragment overlaps with other fragments", HFILL
904 { &hf_wtp_fragment_overlap_conflict,
905 { "Conflicting data in fragment overlap",
906 "wtp.fragment.overlap.conflict",
907 FT_BOOLEAN, BASE_NONE, NULL, 0x0,
908 "Overlapping fragments contained conflicting data", HFILL
911 { &hf_wtp_fragment_multiple_tails,
912 { "Multiple tail fragments found",
913 "wtp.fragment.multipletails",
914 FT_BOOLEAN, BASE_NONE, NULL, 0x0,
915 "Several tails were found when defragmenting the packet", HFILL
918 { &hf_wtp_fragment_too_long_fragment,
919 { "Fragment too long",
920 "wtp.fragment.toolongfragment",
921 FT_BOOLEAN, BASE_NONE, NULL, 0x0,
922 "Fragment contained data past end of packet", HFILL
925 { &hf_wtp_fragment_error,
926 { "Defragmentation error",
927 "wtp.fragment.error",
928 FT_FRAMENUM, BASE_NONE, NULL, 0x0,
929 "Defragmentation error due to illegal fragments", HFILL
935 FT_FRAMENUM, BASE_NONE, NULL, 0x0,
936 "WTP Fragment", HFILL
942 FT_NONE, BASE_NONE, NULL, 0x0,
943 "WTP Fragments", HFILL
948 /* Setup protocol subtree array */
949 static gint *ett[] = {
951 &ett_wtp_sub_pdu_tree,
958 /* Register the protocol name and description */
959 proto_wtp = proto_register_protocol(
960 "Wireless Transaction Protocol", /* protocol name for use by ethereal */
961 "WTP", /* short version of name */
962 "wap-wsp-wtp" /* Abbreviated protocol name, should Match IANA
963 < URL:http://www.isi.edu/in-notes/iana/assignments/port-numbers/ >
967 /* Required calls to register the header fields and subtrees used */
968 proto_register_field_array(proto_wtp, hf, array_length(hf));
969 proto_register_subtree_array(ett, array_length(ett));
971 register_dissector("wtp", dissect_wtp_fromwap, proto_wtp);
972 register_dissector("wtp-udp", dissect_wtp_fromudp, proto_wtp);
973 register_init_routine(wtp_defragment_init);
977 proto_reg_handoff_wtp(void)
979 dissector_handle_t wtp_fromudp_handle;
982 * Get a handle for the connection-oriented WSP dissector - if WTP
983 * PDUs have data, it is WSP.
985 wsp_handle = find_dissector("wsp-co");
987 wtp_fromudp_handle = find_dissector("wtp-udp");
988 dissector_add("udp.port", UDP_PORT_WTP_WSP, wtp_fromudp_handle);
989 dissector_add("smpp.udh.port", UDP_PORT_WTP_WSP, wtp_fromudp_handle);