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