IP Prefix field support in CDP, from Paul Ionescu.
[obnox/wireshark/wip.git] / packet-wtp.c
1 /* packet-wtp.c (c) 2000 Neil Hunter
2  * Base on original work by Ben Fowler
3  *
4  * Routines to dissect WTP component of WAP traffic.
5  * 
6  * $Id: packet-wtp.c,v 1.8 2001/01/03 16:41:08 gram Exp $
7  *
8  * Ethereal - Network traffic analyzer
9  * By Gerald Combs <gerald@zing.org>
10  * Copyright 1998 Didier Jorand
11  *
12  * This program is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU General Public License
14  * as published by the Free Software Foundation; either version 2
15  * of the License, or (at your option) any later version.
16  * 
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  * 
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25  */
26
27 #ifdef HAVE_CONFIG_H
28 # include "config.h"
29 #endif
30
31 #include <stdio.h>
32 #include <stdlib.h>
33
34 #ifdef HAVE_SYS_TYPES_H
35 # include <sys/types.h>
36 #endif
37
38 #ifdef HAVE_NETINET_IN_H
39 # include <netinet/in.h>
40 #endif
41
42 #ifdef NEED_SNPRINTF_H
43 # ifdef HAVE_STDARG_H
44 #  include <stdarg.h>
45 # else
46 #  include <varargs.h>
47 # endif
48 # include "snprintf.h"
49 #endif
50
51 #include <string.h>
52 #include <glib.h>
53 #include "packet.h"
54 #include "packet-wap.h"
55 #include "packet-wtp.h"
56 #include "packet-wsp.h"
57
58 static const true_false_string continue_truth = { 
59         "TPI Present" ,
60         "No TPI"
61 };
62
63 static const true_false_string RID_truth = { 
64         "Re-Transmission",
65         "First transmission"
66 };
67
68 static const true_false_string TIDNew_truth = { 
69         "TID is new" ,
70         "TID is valid"
71 };
72
73 static const true_false_string tid_response_truth = { 
74         "Response" ,
75         "Original"
76 };
77
78 static const true_false_string UP_truth = { 
79         "User Acknowledgement required" ,
80         "User Acknowledgement optional"
81 };
82
83 static const true_false_string TVETOK_truth = {
84         "True",
85         "False"
86 };
87
88 static const value_string vals_pdu_type[] = {
89         { 0, "Not Allowed" },
90         { 1, "Invoke" },
91         { 2, "Result" },
92         { 3, "Ack" },
93         { 4, "Abort" },
94         { 5, "Segmented Invoke" },
95         { 6, "Segmented Result" },
96         { 7, "Negative Ack" },
97         { 0, NULL }
98 };
99
100 static const value_string vals_transmission_trailer[] = {
101         { 0, "Not last packet" },
102         { 1, "Last packet of message" },
103         { 2, "Last packet of group" },
104         { 3, "Re-assembly not supported" },
105         { 0, NULL }
106 };
107
108 static const value_string vals_version[] = {
109         { 0, "Current" },
110         { 1, "Undefined" },
111         { 2, "Undefined" },
112         { 3, "Undefined" },
113         { 0, NULL }
114 };
115
116 static const value_string vals_abort_type[] = {
117         { 0, "Provider" },
118         { 1, "User (WSP)" },
119         { 0, NULL }
120 };
121
122 static const value_string vals_abort_reason_provider[] = {
123         { 0x00, "Unknown" },
124         { 0x01, "Protocol Error" },
125         { 0x02, "Invalid TID" },
126         { 0x03, "Not Implemented Class 2" },
127         { 0x04, "Not Implemented SAR" },
128         { 0x05, "Not Implemented User Acknowledgement" },
129         { 0x06, "WTP Version Zero" },
130         { 0x07, "Capacity Temporarily Exceeded" },
131         { 0x08, "No Response" },
132         { 0x09, "Message Too Large" },
133         { 0x00, NULL }
134 };
135
136 /* File scoped variables for the protocol and registered fields */
137 static int proto_wtp                                                    = HF_EMPTY;
138
139 /* These fields used by fixed part of header */
140 static int hf_wtp_header_fixed_part                     = HF_EMPTY;
141 static int hf_wtp_header_flag_continue                  = HF_EMPTY;
142 static int hf_wtp_header_pdu_type                               = HF_EMPTY;
143 static int hf_wtp_header_flag_Trailer                   = HF_EMPTY;
144 static int hf_wtp_header_flag_RID                               = HF_EMPTY;
145 static int hf_wtp_header_flag_TID                               = HF_EMPTY;
146 static int hf_wtp_header_flag_TID_response              = HF_EMPTY;
147
148 /* These fields used by Invoke packets */
149 static int hf_wtp_header_Inv_version                    = HF_EMPTY;
150 static int hf_wtp_header_Inv_flag_TIDNew                = HF_EMPTY;
151 static int hf_wtp_header_Inv_flag_UP                    = HF_EMPTY;
152 static int hf_wtp_header_Inv_Reserved                   = HF_EMPTY;
153 static int hf_wtp_header_Inv_TransactionClass   = HF_EMPTY;
154
155
156 static int hf_wtp_header_variable_part                  = HF_EMPTY;
157 static int hf_wtp_data                                                  = HF_EMPTY;
158
159 static int hf_wtp_header_Ack_flag_TVETOK                = HF_EMPTY;
160 static int hf_wtp_header_Abort_type                             = HF_EMPTY;
161 static int hf_wtp_header_Abort_reason_provider  = HF_EMPTY;
162 static int hf_wtp_header_Abort_reason_user              = HF_EMPTY;
163 static int hf_wtp_header_sequence_number                = HF_EMPTY;
164 static int hf_wtp_header_missing_packets                = HF_EMPTY;
165
166 /* Initialize the subtree pointers */
167 static gint ett_wtp                                                     = ETT_EMPTY;
168 static gint ett_header                                                  = ETT_EMPTY;
169
170 static dissector_handle_t wsp_handle;
171
172 /* Declarations */
173 static char transaction_class(unsigned char octet);
174 static char pdu_type(unsigned char octet);
175 static char retransmission_indicator(unsigned char octet);
176
177 /* Code to actually dissect the packets */
178 static void
179 dissect_wtp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
180 {
181         frame_data *fdata = pinfo->fd;
182
183         char szInfo[ 50 ];
184         int offCur                      = 0; /* current offset from start of WTP data */
185
186         /* bytes at offset 0 - 3 */
187         /*
188         unsigned char  b0 = pd[offset + 0];
189         unsigned char  b3 = pd[offset + 3];
190         */
191         unsigned char  b0 = tvb_get_guint8 (tvb, offCur + 0);
192
193         /* continuation flag */
194         unsigned char   fCon            = b0 & 0x80;
195         unsigned char   fRID            = retransmission_indicator( b0 );
196         int             cbHeader        = 0;
197         int             abortType       = 0;
198
199 /* Set up structures we will need to add the protocol subtree and manage it */
200         proto_item *ti;
201         proto_tree *wtp_tree;
202         proto_tree *wtp_header_fixed;
203         
204         char pdut                       = pdu_type( b0 );
205         char clsTransaction             = ' ';
206         int cchInfo;
207         int numMissing = 0;             /* Number of missing packets in a negative ack */
208         int i;
209         tvbuff_t *wsp_tvb = NULL;
210
211         CHECK_DISPLAY_AS_DATA(proto_wtp, tvb, pinfo, tree);
212
213         pinfo->current_proto = "WTP";
214
215 /* Make entries in Protocol column and Info column of summary display */
216
217 #ifdef DEBUG
218         fprintf( stderr, "dissect_wtp: (Entering) Frame data at %p\n", fdata ); 
219         fprintf( stderr, "dissect_wtp: tvb length is %d\n", tvb_reported_length( tvb ) ); 
220 #endif
221         /* Display protocol type depending on the port */
222         if (check_col(fdata, COL_PROTOCOL)) 
223         {
224                 switch ( pinfo->match_port )
225                 {
226                         case UDP_PORT_WTP_WSP:
227                                 col_add_fstr(fdata, COL_PROTOCOL, "WTP+WSP" );
228                                 break;
229                         case UDP_PORT_WTLS_WTP_WSP:
230                                 col_add_fstr(fdata, COL_PROTOCOL, "WTLS+WTP+WSP" );
231                                 break;
232                         default:
233                                 break;
234                 }
235         }
236     
237         /* Develop the string to put in the Info column */
238         cchInfo = snprintf( szInfo, sizeof( szInfo ), "WTP %s", vals_pdu_type[ ( int )pdut ].strptr  );
239
240         switch( pdut ) {
241                 case INVOKE:
242                         clsTransaction = transaction_class( tvb_get_guint8 (tvb, offCur + 3) );
243                         snprintf( szInfo + cchInfo, sizeof( szInfo ) - cchInfo, " Class %d", clsTransaction  );
244
245                 case ABORT:
246                 case SEGMENTED_INVOKE:
247                 case SEGMENTED_RESULT:
248                         cbHeader = 4;
249                         break;
250
251                 case RESULT:
252                 case ACK:
253                         cbHeader = 3;
254                         break;
255
256                 case NEGATIVE_ACK:
257                         /* Varible number of missing packets */
258                         numMissing = tvb_get_guint8 (tvb, offCur + 3);
259                         cbHeader = numMissing + 4;
260                         break;
261
262                 default:
263                         break;
264         };
265
266         if( fRID ) {
267                 strcat( szInfo, " R" );
268         };
269
270 #ifdef DEBUG
271         fprintf( stderr, "dissect_wtp: cbHeader = %d\n", cbHeader );  
272 #endif
273
274 /* This field shows up as the "Info" column in the display; you should make
275    it, if possible, summarize what's in the packet, so that a user looking
276    at the list of packets can tell what type of packet it is. */
277         if (check_col(fdata, COL_INFO)) {
278 #ifdef DEBUG
279                 fprintf( stderr, "dissect_wtp: (6) About to set info_col header to %s\n", szInfo );
280 #endif
281                 col_add_str(fdata, COL_INFO, szInfo );
282         };
283 /* In the interest of speed, if "tree" is NULL, don't do any work not
284    necessary to generate protocol tree items. */
285         if (tree) {
286 #ifdef DEBUG
287                 fprintf( stderr, "dissect_wtp: cbHeader = %d\n", cbHeader );  
288 #endif
289                 ti = proto_tree_add_item(tree, proto_wtp, tvb, offCur, cbHeader, bo_little_endian);
290 #ifdef DEBUG
291                 fprintf( stderr, "dissect_wtp: (7) Returned from proto_tree_add_item\n" );  
292 #endif
293                 wtp_tree = proto_item_add_subtree(ti, ett_wtp);
294
295 /* Code to process the packet goes here */
296                 {
297 #ifdef DEBUG
298                         fprintf( stderr, "dissect_wtp: cbHeader = %d\n", cbHeader );  
299                         fprintf( stderr, "dissect_wtp: offCur = %d\n", offCur );  
300                         fprintf( stderr, "dissect_wtp: About to call proto_tree_add_item with %p %d %p %d %d %d\n", 
301                                         wtp_tree, hf_wtp_header_fixed_part, tvb, offCur, cbHeader, bo_little_endian ); 
302                         ti = proto_tree_add_item( wtp_tree, hf_wtp_header_fixed_part, tvb, offCur, cbHeader, bo_little_endian );
303                         fprintf( stderr, "dissect_wtp: (6) Returned from proto_tree_add_item\n" );  
304 #endif
305                         wtp_header_fixed = proto_item_add_subtree(
306                                         ti, 
307                                         ett_header 
308                                 );
309
310                         /* Add common items: only CON and PDU Type */
311                         ti = proto_tree_add_item(
312                                         wtp_header_fixed,               /* tree */
313                                         hf_wtp_header_flag_continue,    /* id */
314                                         tvb, 
315                                         offCur,                         /* start of high light */
316                                         1,                              /* length of high light */
317                                         b0                              /* value */
318                              );
319                         ti = proto_tree_add_item( wtp_header_fixed, hf_wtp_header_pdu_type, tvb, offCur, 1, bo_little_endian );
320
321                         switch( pdut ) {
322                                 case INVOKE:
323                                         ti = proto_tree_add_item( wtp_header_fixed, hf_wtp_header_flag_Trailer, tvb, offCur, 1, bo_little_endian );
324                                         ti = proto_tree_add_item( wtp_header_fixed, hf_wtp_header_flag_RID, tvb, offCur, 1, bo_little_endian );
325                                         ti = proto_tree_add_item( wtp_header_fixed, hf_wtp_header_flag_TID_response, tvb, offCur + 1, 2, bo_big_endian );
326                                         ti = proto_tree_add_item( wtp_header_fixed, hf_wtp_header_flag_TID, tvb, offCur + 1, 2, bo_big_endian );
327
328                                         ti = proto_tree_add_item( wtp_header_fixed, hf_wtp_header_Inv_version , tvb, offCur + 3, 1, bo_little_endian );
329                                         ti = proto_tree_add_item( wtp_header_fixed, hf_wtp_header_Inv_flag_TIDNew, tvb, offCur + 3, 1, bo_little_endian );
330                                         ti = proto_tree_add_item( wtp_header_fixed, hf_wtp_header_Inv_flag_UP, tvb, offCur + 3, 1, bo_little_endian );
331                                         ti = proto_tree_add_item( wtp_header_fixed, hf_wtp_header_Inv_Reserved, tvb, offCur + 3, 1, bo_little_endian );
332                                         ti = proto_tree_add_item( wtp_header_fixed, hf_wtp_header_Inv_TransactionClass, tvb, offCur + 3, 1, bo_little_endian );
333                                         break;
334
335                                 case RESULT:
336                                         ti = proto_tree_add_item( wtp_header_fixed, hf_wtp_header_flag_Trailer, tvb, offCur, 1, bo_little_endian );
337                                         ti = proto_tree_add_item( wtp_header_fixed, hf_wtp_header_flag_RID, tvb, offCur, 1, bo_little_endian );
338                                         ti = proto_tree_add_item( wtp_header_fixed, hf_wtp_header_flag_TID_response, tvb, offCur + 1, 2, bo_big_endian );
339                                         ti = proto_tree_add_item( wtp_header_fixed, hf_wtp_header_flag_TID, tvb, offCur + 1, 2, bo_big_endian );
340                                         break;
341
342                                 case ACK:
343                                         ti = proto_tree_add_item( wtp_header_fixed, hf_wtp_header_Ack_flag_TVETOK, tvb, offCur, 1, bo_big_endian );
344
345                                         ti = proto_tree_add_item( wtp_header_fixed, hf_wtp_header_flag_RID, tvb, offCur, 1, bo_little_endian );
346                                         ti = proto_tree_add_item( wtp_header_fixed, hf_wtp_header_flag_TID_response, tvb, offCur + 1, 2, bo_big_endian );
347                                         ti = proto_tree_add_item( wtp_header_fixed, hf_wtp_header_flag_TID, tvb, offCur + 1, 2, bo_big_endian );
348                                         break;
349
350                                 case ABORT:
351                                         abortType = tvb_get_guint8 (tvb, offCur) & 0x07;
352                                         ti = proto_tree_add_item( wtp_header_fixed, hf_wtp_header_Abort_type , tvb, offCur , 1, bo_little_endian );
353                                         ti = proto_tree_add_item( wtp_header_fixed, hf_wtp_header_flag_TID_response, tvb, offCur + 1, 2, bo_big_endian );
354                                         ti = proto_tree_add_item( wtp_header_fixed, hf_wtp_header_flag_TID, tvb, offCur + 1, 2, bo_big_endian );
355
356                                         if (abortType == PROVIDER)
357                                         {
358                                                 ti = proto_tree_add_item( wtp_header_fixed, hf_wtp_header_Abort_reason_provider , tvb, offCur + 3 , 1, bo_little_endian );
359                                         }
360                                         else if (abortType == USER)
361                                         {
362                                                 ti = proto_tree_add_item( wtp_header_fixed, hf_wtp_header_Abort_reason_user , tvb, offCur + 3 , 1, bo_little_endian );
363                                         }
364                                         break;
365
366                                 case SEGMENTED_INVOKE:
367                                         ti = proto_tree_add_item( wtp_header_fixed, hf_wtp_header_flag_Trailer, tvb, offCur, 1, bo_little_endian );
368                                         ti = proto_tree_add_item( wtp_header_fixed, hf_wtp_header_flag_RID, tvb, offCur, 1, bo_little_endian );
369                                         ti = proto_tree_add_item( wtp_header_fixed, hf_wtp_header_flag_TID_response, tvb, offCur + 1, 2, bo_big_endian );
370                                         ti = proto_tree_add_item( wtp_header_fixed, hf_wtp_header_flag_TID, tvb, offCur + 1, 2, bo_big_endian );
371
372                                         ti = proto_tree_add_item( wtp_header_fixed, hf_wtp_header_sequence_number , tvb, offCur + 3, 1, bo_little_endian );
373                                         break;
374
375                                 case SEGMENTED_RESULT:
376                                         ti = proto_tree_add_item( wtp_header_fixed, hf_wtp_header_flag_Trailer, tvb, offCur, 1, bo_little_endian );
377                                         ti = proto_tree_add_item( wtp_header_fixed, hf_wtp_header_flag_RID, tvb, offCur, 1, bo_little_endian );
378                                         ti = proto_tree_add_item( wtp_header_fixed, hf_wtp_header_flag_TID_response, tvb, offCur + 1, 2, bo_big_endian );
379                                         ti = proto_tree_add_item( wtp_header_fixed, hf_wtp_header_flag_TID, tvb, offCur + 1, 2, bo_big_endian );
380
381                                         ti = proto_tree_add_item( wtp_header_fixed, hf_wtp_header_sequence_number , tvb, offCur + 3, 1, bo_little_endian );
382                                         break;
383
384                                 case NEGATIVE_ACK:
385                                         ti = proto_tree_add_item( wtp_header_fixed, hf_wtp_header_flag_RID, tvb, offCur, 1, bo_little_endian );
386                                         ti = proto_tree_add_item( wtp_header_fixed, hf_wtp_header_flag_TID_response, tvb, offCur + 1, 2, bo_big_endian );
387                                         ti = proto_tree_add_item( wtp_header_fixed, hf_wtp_header_flag_TID, tvb, offCur + 1, 2, bo_big_endian );
388
389                                         ti = proto_tree_add_item( wtp_header_fixed, hf_wtp_header_missing_packets , tvb, offCur + 3, 1, bo_little_endian );
390                                         /* Iterate through missing packets */
391                                         for (i=0; i<numMissing; i++)
392                                         {
393                                                 ti = proto_tree_add_item( wtp_header_fixed, hf_wtp_header_sequence_number , tvb, offCur + i, 1, bo_little_endian );
394                                         }
395                                         break;
396
397                                 default:
398                                         break;
399                         };
400
401                         if( fCon ) {
402                                 /* There is a variable part if the Con flag is set */ 
403                                 ti = proto_tree_add_bytes_format(
404                                                 wtp_tree,                       /* tree */
405                                                 hf_wtp_header_variable_part,    /* id */
406                                                 tvb, 
407                                                 offCur + 4,                     /* start */
408                                                 4,                              /* length */
409                                                 "What should go here!",         /* value */
410                                                 "Header (Variable part) %02X %02X %02X %02X"  ,                 /* format */
411                                                 0, 1, 2, 3
412                                     );
413                         } else {
414                                 /* There is no variable part */
415                         }; /* End of variable part of header */
416                 }
417         } else {
418 #ifdef DEBUG
419                 fprintf( stderr, "dissect_wtp: (4) tree was %p\n", tree ); 
420 #endif
421         }
422                 
423         /* Any remaining data ought to be WSP data, so hand off to the WSP dissector */
424         if (tvb_reported_length (tvb) > cbHeader)
425         {
426                 wsp_tvb = tvb_new_subset(tvb, cbHeader, -1, tvb_reported_length (tvb)-cbHeader);
427                 call_dissector(wsp_handle, wsp_tvb, pinfo, tree);
428         }
429
430 #ifdef DEBUG
431         fprintf( stderr, "dissect_wtp: (leaving) fdata->cinfo is %p\n", fdata->cinfo ); 
432 #endif
433 }
434
435 static char pdu_type(unsigned char octet)
436 {
437         char ch = (octet >> 3) & 0x0F;
438         /* Note pdu type must not be 0x00 */
439         return ch;
440 };
441
442 static char transaction_class(unsigned char octet)
443 {
444         char ch = (octet >> 0) & 0x03; /* ......XX */
445         return ch;
446 };
447
448 static char retransmission_indicator(unsigned char octet)
449 {
450         char ch = (octet >> 0) & 0x01; /* ......,X */
451         return ch;
452 };
453
454 /* Register the protocol with Ethereal */
455 void
456 proto_register_wtp(void)
457 {                 
458
459 /* Setup list of header fields */
460         static hf_register_info hf[] = {
461                 { &hf_wtp_header_fixed_part,
462                         {       "Header",           
463                                 "wtp.header_fixed_part",
464                                 FT_BYTES, BASE_HEX, NULL, 0x0,          
465                                 "Fixed part of the header" 
466                         }
467                 },
468                 { &hf_wtp_header_flag_continue,
469                         {       "Continue Flag",           
470                                 "wtp.continue-flag",
471                                 FT_BOOLEAN, 8, TFS( &continue_truth ), 0x80,          
472                                 "Continue Flag" 
473                         }
474                 },
475                 { &hf_wtp_header_pdu_type,
476                         {       "PDU Type",           
477                                 "wtp.pdu-type",
478                                  FT_UINT8, BASE_HEX, VALS( vals_pdu_type ), 0x78,
479                                 "PDU Type" 
480                         }
481                 },
482                 { &hf_wtp_header_flag_Trailer,
483                         {       "Trailer Flags",           
484                                 "wtp.trailer-flags",
485                                  FT_UINT8, BASE_HEX, VALS( vals_transmission_trailer ), 0x06,
486                                 "PDU Type" 
487                         }
488                 },
489                 { &hf_wtp_header_flag_RID,
490                         {       "Re-transmission Indicator",           
491                                 "wtp.RID",
492                                  FT_BOOLEAN, 8, TFS( &RID_truth ), 0x01,
493                                 "Re-transmission Indicator" 
494                         }
495                 },
496                 { &hf_wtp_header_flag_TID_response,
497                         {       "TID Response",           
498                                 "wtp.TID.response",
499                                 FT_BOOLEAN, 16, TFS( &tid_response_truth ), 0x8000,
500                                 "TID Response" 
501                         }
502                 },
503                 { &hf_wtp_header_flag_TID,
504                         {       "Transmission ID",           
505                                 "wtp.TID",
506                                  FT_UINT16, BASE_HEX, NULL, 0x7FFF,
507                                 "Transmission ID" 
508                         }
509                 },
510                 { &hf_wtp_header_Inv_version,
511                         {       "Version",           
512                                 "wtp.header.version",
513                                  FT_UINT8, BASE_HEX, VALS( vals_version ), 0xC0,
514                                 "Version" 
515                         }
516                 },
517                 { &hf_wtp_header_Inv_flag_TIDNew,
518                         {       "TIDNew",           
519                                 "wtp.header.TIDNew",
520                                  FT_BOOLEAN, 8, TFS( &TIDNew_truth ), 0x20,
521                                 "TIDNew" 
522                         }
523                 },
524                 { &hf_wtp_header_Inv_flag_UP,
525                         {       "U/P flag",           
526                                 "wtp.header.UP",
527                                  FT_BOOLEAN, 8, TFS( &UP_truth ), 0x10,
528                                 "U/P Flag" 
529                         }
530                 },
531                 { &hf_wtp_header_Inv_Reserved,
532                         {       "Reserved",           
533                                 "wtp.inv.reserved",
534                                  FT_UINT8, BASE_HEX, NULL, 0x0C,
535                                 "Reserved" 
536                         }
537                 },
538                 { &hf_wtp_header_Inv_TransactionClass,
539                         {       "Transaction Class",           
540                                 "wtp.inv.transaction-class",
541                                  FT_UINT8, BASE_HEX, NULL, 0x03,
542                                 "Transaction Class" 
543                         }
544                 },
545                 { &hf_wtp_header_Ack_flag_TVETOK,
546                         {       "Tve/Tok flag",           
547                                 "wtp.ack.tvetok",
548                                  FT_BOOLEAN, 8, TFS( &TVETOK_truth ), 0x04,
549                                 "Tve/Tok flag"
550                         }
551                 },
552                 { &hf_wtp_header_Abort_type,
553                         {       "Abort Type",           
554                                 "wtp.abort.type",
555                                  FT_UINT8, BASE_HEX, VALS ( vals_abort_type ), 0x07,
556                                 "Abort Type" 
557                         }
558                 },
559                 { &hf_wtp_header_Abort_reason_provider,
560                         {       "Abort Reason",           
561                                 "wtp.abort.reason.provider",
562                                  FT_UINT8, BASE_HEX, VALS ( vals_abort_reason_provider ), 0x00,
563                                 "Abort Reason" 
564                         }
565                 },
566                 /* Assume WSP is the user and use its reason codes */
567                 { &hf_wtp_header_Abort_reason_user,
568                         {       "Abort Reason",           
569                                 "wtp.abort.reason.user",
570                                  FT_UINT8, BASE_HEX, VALS ( vals_wsp_reason_codes ), 0x00,
571                                 "Abort Reason" 
572                         }
573                 },
574                 { &hf_wtp_header_sequence_number,
575                         {       "Packet Sequence Number",           
576                                 "wtp.header.sequence",
577                                  FT_UINT8, BASE_HEX, NULL, 0x00,
578                                 "Packet Sequence Number" 
579                         }
580                 },
581                 { &hf_wtp_header_missing_packets,
582                         {       "Missing Packets",           
583                                 "wtp.header.missing_packets",
584                                  FT_UINT8, BASE_HEX, NULL, 0x00,
585                                 "Missing Packets" 
586                         }
587                 },
588                 { &hf_wtp_header_variable_part,
589                         {       "Header: Variable part",           
590                                 "wtp.header_variable_part",
591                                 FT_BYTES, BASE_HEX, NULL, 0x0,          
592                                 "Variable part of the header" 
593                         }
594                 },
595                 { &hf_wtp_data,
596                         {       "Data",           
597                                 "wtp.header_data",
598                                 FT_BYTES, BASE_HEX, NULL, 0x0,          
599                                 "Data" 
600                         }
601                 },
602         };
603         
604 /* Setup protocol subtree array */
605         static gint *ett[] = {
606                 &ett_wtp,
607                 &ett_header,
608         };
609
610 /* Register the protocol name and description */
611         proto_wtp = proto_register_protocol(
612                 "Wireless Transaction Protocol",   /* protocol name for use by ethereal */ 
613                 "WTP",                             /* short version of name */
614                 "wap-wsp-wtp"                    /* Abbreviated protocol name, should Match IANA 
615                                                     < URL:http://www.isi.edu/in-notes/iana/assignments/port-numbers/ >
616                                                   */
617         );
618
619 /* Required function calls to register the header fields and subtrees used */
620         proto_register_field_array(proto_wtp, hf, array_length(hf));
621         proto_register_subtree_array(ett, array_length(ett));
622 };
623
624 void
625 proto_reg_handoff_wtp(void)
626 {
627         /*
628          * Get a handle for the IP WSP dissector.
629          */
630         wsp_handle = find_dissector("wsp");
631
632         dissector_add("udp.port", UDP_PORT_WTP_WSP, dissect_wtp);
633         /* dissector_add("udp.port", UDP_PORT_WTLS_WTP_WSP, dissect_wsp); */
634 }