3 * Routines to dissect WSP component of WAP traffic.
5 * $Id: packet-wsp.c,v 1.18 2001/02/13 00:17:54 guy Exp $
7 * Ethereal - Network traffic analyzer
8 * By Gerald Combs <gerald@zing.org>
9 * Copyright 1998 Didier Jorand
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 HAVE_SYS_TYPES_H
38 # include <sys/types.h>
41 #ifdef HAVE_NETINET_IN_H
42 # include <netinet/in.h>
45 #ifdef NEED_SNPRINTF_H
51 # include "snprintf.h"
57 #include "packet-wap.h"
58 #include "packet-wsp.h"
60 /* File scoped variables for the protocol and registered fields */
61 static int proto_wsp = HF_EMPTY;
63 /* These fields used by fixed part of header */
64 static int hf_wsp_header_tid = HF_EMPTY;
65 static int hf_wsp_header_pdu_type = HF_EMPTY;
66 static int hf_wsp_version_major = HF_EMPTY;
67 static int hf_wsp_version_minor = HF_EMPTY;
68 static int hf_wsp_capability_length = HF_EMPTY;
69 static int hf_wsp_capabilities_section = HF_EMPTY;
70 static int hf_wsp_header_uri_len = HF_EMPTY;
71 static int hf_wsp_header_uri = HF_EMPTY;
72 static int hf_wsp_server_session_id = HF_EMPTY;
73 static int hf_wsp_header_status = HF_EMPTY;
74 static int hf_wsp_header_length = HF_EMPTY;
75 static int hf_wsp_headers_section = HF_EMPTY;
76 static int hf_wsp_header = HF_EMPTY;
77 static int hf_wsp_content_type = HF_EMPTY;
78 static int hf_wsp_parameter_well_known_charset = HF_EMPTY;
79 static int hf_wsp_reply_data = HF_EMPTY;
80 static int hf_wsp_post_data = HF_EMPTY;
82 static int hf_wsp_header_accept = HF_EMPTY;
83 static int hf_wsp_header_accept_str = HF_EMPTY;
84 static int hf_wsp_header_accept_charset = HF_EMPTY;
85 static int hf_wsp_header_accept_charset_str = HF_EMPTY;
86 static int hf_wsp_header_accept_language = HF_EMPTY;
87 static int hf_wsp_header_accept_language_str = HF_EMPTY;
88 static int hf_wsp_header_accept_ranges = HF_EMPTY;
89 static int hf_wsp_header_cache_control = HF_EMPTY;
90 static int hf_wsp_header_content_length = HF_EMPTY;
91 static int hf_wsp_header_age = HF_EMPTY;
92 static int hf_wsp_header_date = HF_EMPTY;
93 static int hf_wsp_header_etag = HF_EMPTY;
94 static int hf_wsp_header_expires = HF_EMPTY;
95 static int hf_wsp_header_last_modified = HF_EMPTY;
96 static int hf_wsp_header_location = HF_EMPTY;
97 static int hf_wsp_header_if_modified_since = HF_EMPTY;
98 static int hf_wsp_header_server = HF_EMPTY;
99 static int hf_wsp_header_user_agent = HF_EMPTY;
100 static int hf_wsp_header_application_header = HF_EMPTY;
101 static int hf_wsp_header_application_value = HF_EMPTY;
102 static int hf_wsp_header_x_wap_tod = HF_EMPTY;
103 static int hf_wsp_header_transfer_encoding = HF_EMPTY;
104 static int hf_wsp_header_transfer_encoding_str = HF_EMPTY;
105 static int hf_wsp_header_via = HF_EMPTY;
107 /* Initialize the subtree pointers */
108 static gint ett_wsp = ETT_EMPTY;
109 static gint ett_header = ETT_EMPTY;
110 static gint ett_headers = ETT_EMPTY;
111 static gint ett_capabilities = ETT_EMPTY;
112 static gint ett_content_type = ETT_EMPTY;
114 /* Handle for WMLC dissector */
115 static dissector_handle_t wmlc_handle;
117 static const value_string vals_pdu_type[] = {
118 { 0x00, "Reserved" },
120 { 0x02, "ConnectReply" },
121 { 0x03, "Redirect" },
123 { 0x05, "Disconnect" },
125 { 0x07, "ConfirmedPush" },
129 /* 0x10 - 0x3F Unassigned */
137 /* 0x45 - 0x4F Unassigned (Get PDU) */
138 /* 0x50 - 0x5F Extended method (Get PDU) */
143 /* 0x62 - 0x6F Unassigned (Post PDU) */
144 /* 0x70 - 0x7F Extended method (Post PDU) */
145 /* 0x80 - 0xFF Reserved */
151 static const value_string vals_status[] = {
152 /* 0x00 - 0x0F Reserved */
154 { 0x10, "Continue" },
155 { 0x11, "Switching Protocols" },
159 { 0x22, "Accepted" },
160 { 0x23, "Non-Authoritative Information" },
161 { 0x24, "No Content" },
162 { 0x25, "Reset Content" },
163 { 0x26, "Partial Content" },
165 { 0x30, "Multiple Choices" },
166 { 0x31, "Moved Permanently" },
167 { 0x32, "Moved Temporarily" },
168 { 0x33, "See Other" },
169 { 0x34, "Not Modified" },
170 { 0x35, "Use Proxy" },
172 { 0x40, "Bad Request" },
173 { 0x41, "Unauthorised" },
174 { 0x42, "Payment Required" },
175 { 0x43, "Forbidden" },
176 { 0x44, "Not Found" },
177 { 0x45, "Method Not Allowed" },
178 { 0x46, "Not Acceptable" },
179 { 0x47, "Proxy Authentication Required" },
180 { 0x48, "Request Timeout" },
181 { 0x49, "Conflict" },
183 { 0x4B, "Length Required" },
184 { 0x4C, "Precondition Failed" },
185 { 0x4D, "Request Entity Too Large" },
186 { 0x4E, "Request-URI Too Large" },
187 { 0x4F, "Unsupported Media Type" },
189 { 0x60, "Internal Server Error" },
190 { 0x61, "Not Implemented" },
191 { 0x62, "Bad Gateway" },
192 { 0x63, "Service Unavailable" },
193 { 0x64, "Gateway Timeout" },
194 { 0x65, "HTTP Version Not Supported" },
198 static const value_string vals_content_types[] = {
201 { 0x02, "text/html" },
202 { 0x03, "text/plain" },
203 { 0x04, "text/x-hdml" },
204 { 0x05, "text/x-ttml" },
205 { 0x06, "text/x-vCalendar" },
206 { 0x07, "text/x-vCard" },
207 { 0x08, "text/vnd.wap.wml" },
208 { 0x09, "text/vnd.wap.wmlscript" },
209 { 0x0A, "text/vnd.wap.channel" },
210 { 0x0B, "Multipart/*" },
211 { 0x0C, "Multipart/mixed" },
212 { 0x0D, "Multipart/form-data" },
213 { 0x0E, "Multipart/byteranges" },
214 { 0x0F, "Multipart/alternative" },
215 { 0x10, "application/*" },
216 { 0x11, "application/java-vm" },
217 { 0x12, "application/x-www-form-urlencoded" },
218 { 0x13, "application/x-hdmlc" },
219 { 0x14, "application/vnd.wap.wmlc" },
220 { 0x15, "application/vnd.wap.wmlscriptc" },
221 { 0x16, "application/vnd.wap.channelc" },
222 { 0x17, "application/vnd.wap.uaprof" },
223 { 0x18, "application/vnd.wap.wtls-ca-certificate" },
224 { 0x19, "application/vnd.wap.wtls-user-certificate" },
225 { 0x1A, "application/x-x509-ca-cert" },
226 { 0x1B, "application/x-x509-user-cert" },
228 { 0x1D, "image/gif" },
229 { 0x1E, "image/jpeg" },
230 { 0x1F, "image/tiff" },
231 { 0x20, "image/png" },
232 { 0x21, "image/vnd.wap.wbmp" },
233 { 0x22, "application/vnd.wap.multipart.*" },
234 { 0x23, "application/vnd.wap.multipart.mixed" },
235 { 0x24, "application/vnd.wap.multipart.form-data" },
236 { 0x25, "application/vnd.wap.multipart.byteranges" },
237 { 0x26, "application/vnd.wap.multipart.alternative" },
238 { 0x27, "application/xml" },
239 { 0x28, "text/xml" },
240 { 0x29, "application/vnd.wap.wbxml" },
241 { 0x2A, "application/x-x968-cross-cert" },
242 { 0x2B, "application/x-x968-ca-cert" },
243 { 0x2C, "application/x-x968-user-cert" },
244 { 0x2D, "text/vnd.wap.si" },
245 { 0x2E, "application/vnd.wap.sic" },
246 { 0x2F, "text/vnd.wap.sl" },
247 { 0x30, "application/vnd.wap.slc" },
248 { 0x31, "text/vnd.wap.co" },
249 { 0x32, "application/vnd.wap.coc" },
250 { 0x33, "application/vnd.wap.multipart.related" },
251 { 0x34, "application/vnd.wap.sia" },
255 static const value_string vals_languages[] = {
256 { 0x01, "Afar (aa)" },
257 { 0x02, "Abkhazian (ab)" },
258 { 0x03, "Afrikaans (af)" },
259 { 0x04, "Amharic (am)" },
260 { 0x05, "Arabic (ar)" },
261 { 0x06, "Assamese (as)" },
262 { 0x07, "Aymara (ay)" },
263 { 0x08, "Azerbaijani (az)" },
264 { 0x09, "Bashkir (ba)" },
265 { 0x0A, "Byelorussian (be)" },
266 { 0x0B, "Bulgarian (bg)" },
267 { 0x0C, "Bihari (bh)" },
268 { 0x0D, "Bislama (bi)" },
269 { 0x0E, "Bengali; Bangla (bn)" },
270 { 0x0F, "Tibetan (bo)" },
271 { 0x10, "Breton (br)" },
272 { 0x11, "Catalan (ca)" },
273 { 0x12, "Corsican (co)" },
274 { 0x13, "Czech (cs)" },
275 { 0x14, "Welsh (cy)" },
276 { 0x15, "Danish (da)" },
277 { 0x16, "German (de)" },
278 { 0x17, "Bhutani (dz)" },
279 { 0x18, "Greek (el)" },
280 { 0x19, "English (en)" },
281 { 0x1A, "Esperanto (eo)" },
282 { 0x1B, "Spanish (es)" },
283 { 0x1C, "Estonian (et)" },
284 { 0x1D, "Basque (eu)" },
285 { 0x1E, "Persian (fa)" },
286 { 0x1F, "Finnish (fi)" },
287 { 0x20, "Fiji (fj)" },
288 { 0x22, "French (fr)" },
289 { 0x24, "Irish (ga)" },
290 { 0x25, "Scots Gaelic (gd)" },
291 { 0x26, "Galician (gl)" },
292 { 0x27, "Guarani (gn)" },
293 { 0x28, "Gujarati (gu)" },
294 { 0x29, "Hausa (ha)" },
295 { 0x2A, "Hebrew (formerly iw) (he)" },
296 { 0x2B, "Hindi (hi)" },
297 { 0x2C, "Croatian (hr)" },
298 { 0x2D, "Hungarian (hu)" },
299 { 0x2E, "Armenian (hy)" },
300 { 0x30, "Indonesian (formerly in) (id)" },
301 { 0x47, "Maori (mi)" },
302 { 0x48, "Macedonian (mk)" },
303 { 0x49, "Malayalam (ml)" },
304 { 0x4A, "Mongolian (mn)" },
305 { 0x4B, "Moldavian (mo)" },
306 { 0x4C, "Marathi (mr)" },
307 { 0x4D, "Malay (ms)" },
308 { 0x4E, "Maltese (mt)" },
309 { 0x4F, "Burmese (my)" },
310 { 0x51, "Nepali (ne)" },
311 { 0x52, "Dutch (nl)" },
312 { 0x53, "Norwegian (no)" },
313 { 0x54, "Occitan (oc)" },
314 { 0x55, "(Afan) Oromo (om)" },
315 { 0x56, "Oriya (or)" },
316 { 0x57, "Punjabi (pa)" },
317 { 0x58, "Polish (po)" },
318 { 0x59, "Pashto, Pushto (ps)" },
319 { 0x5A, "Portuguese (pt)" },
320 { 0x5B, "Quechua (qu)" },
321 { 0x5D, "Kirundi (rn)" },
322 { 0x5E, "Romanian (ro)" },
323 { 0x5F, "Russian (ru)" },
324 { 0x60, "Kinyarwanda (rw)" },
325 { 0x61, "Sanskrit (sa)" },
326 { 0x62, "Sindhi (sd)" },
327 { 0x63, "Sangho (sg)" },
328 { 0x64, "Serbo-Croatian (sh)" },
329 { 0x65, "Sinhalese (si)" },
330 { 0x66, "Slovak (sk)" },
331 { 0x67, "Slovenian (sl)" },
332 { 0x68, "Samoan (sm)" },
333 { 0x69, "Shona (sn)" },
334 { 0x6A, "Somali (so)" },
335 { 0x6B, "Albanian (sq)" },
336 { 0x6C, "Serbian (sr)" },
337 { 0x6D, "Siswati (ss)" },
338 { 0x6E, "Sesotho (st)" },
339 { 0x6F, "Sundanese (su)" },
340 { 0x70, "Swedish (sv)" },
341 { 0x71, "Swahili (sw)" },
342 { 0x72, "Tamil (ta)" },
343 { 0x73, "Telugu (te)" },
344 { 0x74, "Tajik (tg)" },
345 { 0x75, "Thai (th)" },
346 { 0x76, "Tigrinya (ti)" },
347 { 0x81, "Nauru (na)" },
348 { 0x82, "Faeroese (fo)" },
349 { 0x83, "Frisian (fy)" },
350 { 0x84, "Interlingua (ia)" },
351 { 0x8C, "Rhaeto-Romance (rm)" },
355 static const value_string vals_accept_ranges[] = {
361 static const value_string vals_cache_control[] = {
362 { 0x80, "No-cache" },
363 { 0x81, "No-store" },
365 { 0x83, "Max-stale" },
366 { 0x84, "Min-fresh" },
367 { 0x85, "Only-if-cached" },
370 { 0x88, "No-transform" },
371 { 0x89, "Must-revalidate" },
372 { 0x8A, "Proxy-revalidate" },
376 static const value_string vals_transfer_encoding[] = {
382 * Windows appears to define DELETE.
392 REDIRECT = 0x03, /* No sample data */
395 PUSH = 0x06, /* No sample data */
396 CONFIRMEDPUSH = 0x07, /* No sample data */
397 SUSPEND = 0x08, /* No sample data */
398 RESUME = 0x09, /* No sample data */
401 OPTIONS = 0x41, /* No sample data */
402 HEAD = 0x42, /* No sample data */
403 DELETE = 0x43, /* No sample data */
404 TRACE = 0x44, /* No sample data */
407 PUT = 0x61, /* No sample data */
410 static void add_uri (proto_tree *, tvbuff_t *, guint, guint);
411 static void add_headers (proto_tree *, tvbuff_t *);
412 static void add_header (proto_tree *, tvbuff_t *, tvbuff_t *);
413 static guint get_value_length (tvbuff_t *, guint, guint *);
414 static guint add_content_type (proto_tree *, tvbuff_t *, guint, guint *);
415 static gint get_date_value (tvbuff_t * ,guint ,struct timeval *);
416 static void add_date_value (tvbuff_t * ,guint ,proto_tree * ,int ,
417 tvbuff_t * ,guint ,guint ,struct timeval *, const char *);
418 static guint add_parameter (proto_tree *, tvbuff_t *, guint);
419 static guint add_parameter_charset (proto_tree *, tvbuff_t *, guint, guint);
420 static void add_post_data (proto_tree *, tvbuff_t *, guint);
421 static void add_post_variable (proto_tree *, tvbuff_t *, guint, guint, guint, guint);
423 /* Code to actually dissect the packets */
425 dissect_wsp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
427 frame_data *fdata = pinfo->fd;
435 guint capabilityLength = 0;
436 guint capabilityStart = 0;
437 guint headersLength = 0;
438 guint headerLength = 0;
439 guint headerStart = 0;
440 guint nextOffset = 0;
441 guint contentTypeStart = 0;
442 guint contentType = 0;
445 /* Set up structures we will need to add the protocol subtree and manage it */
447 proto_tree *wsp_tree;
448 /* proto_tree *wsp_header_fixed; */
449 proto_tree *wsp_capabilities;
451 /* This field shows up as the "Info" column in the display; you should make
452 it, if possible, summarize what's in the packet, so that a user looking
453 at the list of packets can tell what type of packet it is. */
455 /* Display protocol type depending on the port */
456 if (check_col(fdata, COL_PROTOCOL))
458 switch ( pinfo->match_port )
461 col_set_str(fdata, COL_PROTOCOL, "WSP" );
463 case UDP_PORT_WTLS_WSP:
464 col_set_str(fdata, COL_PROTOCOL, "WTLS+WSP" );
469 /* Clear the Info column before we fetch anything from the packet */
470 if (check_col(fdata, COL_INFO))
472 col_clear(fdata, COL_INFO);
475 /* Connection-less mode has a TID first */
476 if ( (pinfo->match_port == UDP_PORT_WSP) ||
477 (pinfo->match_port == UDP_PORT_WTLS_WSP))
482 /* Find the PDU type */
483 pdut = tvb_get_guint8 (tvb, offset);
485 /* Develop the string to put in the Info column */
486 if (check_col(fdata, COL_INFO))
488 col_add_fstr(fdata, COL_INFO, "WSP %s",
489 val_to_str (pdut, vals_pdu_type, "Unknown PDU type (0x%02x)"));
492 /* In the interest of speed, if "tree" is NULL, don't do any work not
493 necessary to generate protocol tree items. */
495 ti = proto_tree_add_item(tree, proto_wsp, tvb, 0,
496 tvb_length(tvb), bo_little_endian);
497 wsp_tree = proto_item_add_subtree(ti, ett_wsp);
499 /* Code to process the packet goes here */
501 wsp_header_fixed = proto_item_add_subtree(ti, ett_header );
504 /* Add common items: only TID and PDU Type */
506 /* If this is connectionless, then the TID Field is always first */
507 if ( (pinfo->match_port == UDP_PORT_WSP) ||
508 (pinfo->match_port == UDP_PORT_WTLS_WSP))
510 ti = proto_tree_add_item (wsp_tree, hf_wsp_header_tid,tvb,
511 0,1,bo_little_endian);
514 ti = proto_tree_add_item(
516 hf_wsp_header_pdu_type, /* id */
518 offset++, /* start of high light */
519 1, /* length of high light */
520 bo_little_endian /* value */
526 ti = proto_tree_add_item (wsp_tree, hf_wsp_version_major,tvb,offset,1,bo_little_endian);
527 ti = proto_tree_add_item (wsp_tree, hf_wsp_version_minor,tvb,offset,1,bo_little_endian);
529 capabilityStart = offset;
530 count = 0; /* Initialise count */
531 capabilityLength = tvb_get_guintvar (tvb, offset, &count);
533 ti = proto_tree_add_uint (wsp_tree, hf_wsp_capability_length,tvb,capabilityStart,count,capabilityLength);
535 headerStart = offset;
536 count = 0; /* Initialise count */
537 headerLength = tvb_get_guintvar (tvb, offset, &count);
539 ti = proto_tree_add_uint (wsp_tree, hf_wsp_header_length,tvb,headerStart,count,headerLength);
540 if (capabilityLength > 0)
542 ti = proto_tree_add_item (wsp_tree, hf_wsp_capabilities_section,tvb,offset,capabilityLength,bo_little_endian);
543 wsp_capabilities = proto_item_add_subtree( ti, ett_capabilities );
544 offset += capabilityLength;
547 if (headerLength > 0)
549 tmp_tvb = tvb_new_subset (tvb, offset, headerLength, headerLength);
550 add_headers (wsp_tree, tmp_tvb);
556 count = 0; /* Initialise count */
557 value = tvb_get_guintvar (tvb, offset, &count);
558 ti = proto_tree_add_uint (wsp_tree, hf_wsp_server_session_id,tvb,offset,count,value);
561 capabilityStart = offset;
562 count = 0; /* Initialise count */
563 capabilityLength = tvb_get_guintvar (tvb, offset, &count);
565 ti = proto_tree_add_uint (wsp_tree, hf_wsp_capability_length,tvb,capabilityStart,count,capabilityLength);
567 headerStart = offset;
568 count = 0; /* Initialise count */
569 headerLength = tvb_get_guintvar (tvb, offset, &count);
571 ti = proto_tree_add_uint (wsp_tree, hf_wsp_header_length,tvb,headerStart,count,headerLength);
572 if (capabilityLength > 0)
574 ti = proto_tree_add_item (wsp_tree, hf_wsp_capabilities_section,tvb,offset,capabilityLength,bo_little_endian);
575 wsp_capabilities = proto_item_add_subtree( ti, ett_capabilities );
576 offset += capabilityLength;
579 if (headerLength > 0)
583 ti = proto_tree_add_item (wsp_tree, hf_wsp_headers_section,tvb,offset,headerLength,bo_little_endian);
584 wsp_headers = proto_item_add_subtree( ti, ett_headers );
586 tmp_tvb = tvb_new_subset (tvb, offset, headerLength, headerLength);
587 add_headers (wsp_tree, tmp_tvb);
593 count = 0; /* Initialise count */
594 value = tvb_get_guintvar (tvb, offset, &count);
595 ti = proto_tree_add_uint (wsp_tree, hf_wsp_server_session_id,tvb,offset,count,value);
599 count = 0; /* Initialise count */
600 /* Length of URI and size of URILen field */
601 value = tvb_get_guintvar (tvb, offset, &count);
602 nextOffset = offset + count;
603 add_uri (wsp_tree, tvb, offset, nextOffset);
604 offset += (value+count); /* VERIFY */
605 tmp_tvb = tvb_new_subset (tvb, offset, -1, -1);
606 add_headers (wsp_tree, tmp_tvb);
611 count = 0; /* Initialise count */
612 uriLength = tvb_get_guintvar (tvb, offset, &count);
613 headerStart = uriStart+count;
614 count = 0; /* Initialise count */
615 headersLength = tvb_get_guintvar (tvb, headerStart, &count);
616 offset = headerStart + count;
618 add_uri (wsp_tree, tvb, uriStart, offset);
621 ti = proto_tree_add_item (wsp_tree, hf_wsp_header_length,tvb,headerStart,count,bo_little_endian);
623 contentTypeStart = offset;
624 nextOffset = add_content_type (wsp_tree, tvb, offset, &contentType);
626 /* Add headers subtree that will hold the headers fields */
627 /* Runs from nextOffset for value-(length of content-type field)*/
628 headerLength = headersLength-(nextOffset-contentTypeStart);
629 tmp_tvb = tvb_new_subset (tvb, nextOffset, headerLength, headerLength);
630 add_headers (wsp_tree, tmp_tvb);
632 /* TODO: Post DATA */
633 /* Runs from start of headers+headerLength to END_OF_FRAME */
634 offset = nextOffset+headerLength;
635 tmp_tvb = tvb_new_subset (tvb, offset, tvb_reported_length (tvb)-offset, tvb_reported_length (tvb)-offset);
636 add_post_data (wsp_tree, tmp_tvb, contentType);
640 ti = proto_tree_add_item (wsp_tree, hf_wsp_header_status,tvb,offset,1,bo_little_endian);
641 count = 0; /* Initialise count */
642 value = tvb_get_guintvar (tvb, offset+1, &count);
643 nextOffset = offset + 1 + count;
644 ti = proto_tree_add_uint (wsp_tree, hf_wsp_header_length,tvb,offset+1,count,value);
646 contentTypeStart = nextOffset;
647 nextOffset = add_content_type (wsp_tree, tvb, nextOffset, &contentType);
649 /* Add headers subtree that will hold the headers fields */
650 /* Runs from nextOffset for value-(length of content-type field)*/
651 headerLength = value-(nextOffset-contentTypeStart);
652 tmp_tvb = tvb_new_subset (tvb, nextOffset, headerLength, headerLength);
653 add_headers (wsp_tree, tmp_tvb);
654 offset += count+value+1;
656 /* TODO: Data - decode WMLC */
657 /* Runs from offset+1+count+value+1 to END_OF_FRAME */
658 if (offset < tvb_reported_length (tvb))
660 ti = proto_tree_add_item (wsp_tree, hf_wsp_reply_data,tvb,offset,END_OF_FRAME,bo_little_endian);
668 add_uri (proto_tree *tree, tvbuff_t *tvb, guint URILenOffset, guint URIOffset)
671 guint8 terminator = 0;
675 guint uriLen = tvb_get_guintvar (tvb, URILenOffset, &count);
677 ti = proto_tree_add_uint (tree, hf_wsp_header_uri_len,tvb,URILenOffset,count,uriLen);
679 /* If string doesn't end with a 0x00, we need to add one to be on the safe side */
680 terminator = tvb_get_guint8 (tvb, URIOffset+uriLen-1);
683 newBuffer = g_malloc (uriLen+1);
684 strncpy (newBuffer, tvb_get_ptr (tvb, URIOffset, uriLen), uriLen);
685 newBuffer[uriLen] = 0;
686 ti = proto_tree_add_string (tree, hf_wsp_header_uri,tvb,URIOffset,uriLen,newBuffer);
691 ti = proto_tree_add_item (tree, hf_wsp_header_uri,tvb,URIOffset,uriLen,bo_little_endian);
696 add_headers (proto_tree *tree, tvbuff_t *tvb)
699 proto_tree *wsp_headers;
701 guint headersLen = tvb_reported_length (tvb);
702 guint8 headerStart = 0;
704 tvbuff_t *header_buff;
705 tvbuff_t *value_buff;
707 guint valueStart = 0;
711 fprintf (stderr, "dissect_wsp: Offset is %d, size is %d\n", offset, headersLen);
721 fprintf (stderr, "dissect_wsp: Headers to process\n");
724 ti = proto_tree_add_item (tree, hf_wsp_headers_section,tvb,offset,headersLen,bo_little_endian);
725 wsp_headers = proto_item_add_subtree( ti, ett_headers );
729 while (offset < headersLen)
731 /* Loop round each header */
732 headerStart = offset;
733 peek = tvb_get_guint8 (tvb, headerStart);
735 if (peek < 32) /* Short-cut shift delimeter */
737 fprintf (stderr, "dissect_wsp: header: short-cut shift %d (0x%02X)\n", peek, peek);
740 else if (peek == 0x7F) /* Shift delimeter */
742 fprintf (stderr, "dissect_wsp: header: shift delimeter %d (0x%02X)\n", peek, peek);
748 fprintf (stderr, "dissect_wsp: header: application-header start %d (0x%02X)\n", peek, peek);
750 while (tvb_get_guint8 (tvb, offset++)) { /* Do nothing, just look for NULL */ }
752 else if (peek & 0x80) /* Well-known header */
755 fprintf (stderr, "dissect_wsp: header: well-known %d (0x%02X)\n", peek, peek);
760 /* Get value part of header */
762 peek = tvb_get_guint8 (tvb, valueStart);
766 fprintf (stderr, "dissect_wsp: Looking for %d octets\n", peek);
768 /* VERIFY: valueStart++; */
769 valueEnd = offset+1+peek;
775 fprintf (stderr, "dissect_wsp: Looking for uintvar octets\n");
777 count = 0; /* Initialise count */
778 tvb_get_guintvar (tvb, valueStart, &count);
779 valueEnd = offset+1+count;
782 else if (peek <= 127)
785 fprintf (stderr, "dissect_wsp: Looking for NULL-terminated string\n");
787 valueEnd = valueStart+1;
788 while (tvb_get_guint8 (tvb, valueEnd++)) { /* Do nothing, just look for NULL */ }
794 fprintf (stderr, "dissect_wsp: Value is %d\n", (peek & 0x7F));
800 fprintf (stderr, "dissect_wsp: Creating value buffer from offset %d, size=%d\n", headerStart, (offset-headerStart));
803 header_buff = tvb_new_subset (tvb, headerStart, (offset-headerStart), (offset-headerStart));
804 value_buff = tvb_new_subset (tvb, valueStart, (valueEnd-valueStart), (valueEnd-valueStart));
806 add_header (wsp_headers, header_buff, value_buff);
811 add_header (proto_tree *tree, tvbuff_t *header_buff, tvbuff_t *value_buff)
814 guint valueStart = 0;
815 guint8 headerType = 0;
817 guint headerLen = tvb_reported_length (header_buff);
818 guint valueLen = tvb_reported_length (value_buff);
820 struct timeval timeValue;
823 guint valueLength = 0;
825 char *valMatch = NULL;
826 double q_value = 1.0;
828 /* Initialise time values */
830 timeValue.tv_usec = 0;
832 headerType = tvb_get_guint8 (header_buff, 0);
833 peek = tvb_get_guint8 (value_buff, 0);
835 fprintf (stderr, "dissect_wsp: Got header 0x%02x\n", headerType);
836 fprintf (stderr, "dissect_wsp: First value octet is 0x%02x\n", peek);
839 if (headerType == 0x7F)
842 else if (headerType < 0x1F)
845 else if (headerType & 0x80)
847 headerType = headerType & 0x7F;
850 case 0x00: /* Accept */
853 proto_tree_add_uint (tree, hf_wsp_header_accept, header_buff, offset, headerLen, (peek & 0x7F));
857 proto_tree_add_string (tree, hf_wsp_header_accept_str,header_buff,offset,headerLen,tvb_get_ptr (value_buff, 0, valueLen));
861 case 0x01: /* Accept-Charset */
862 if (peek <= 31) /* Accept-charset-general-form */
864 /* Get Value-Length */
865 valueLength = get_value_length (value_buff, offset,
869 peek = tvb_get_guint8 (value_buff, offset);
870 if ((peek >= 0x80) || (peek <= 30)) /* Well-known-charset */
872 if (peek == 0x80) /* Any */
877 else if (peek & 0x80) /* Short-Integer */
882 else if (peek <= 30) /* Long-Integer */
886 /* TODO: Need to read peek octets */
890 valMatch = match_strval(value, vals_character_sets);
892 else /* Assume Token-text */
894 fprintf (stderr, "dissect_wsp: Accept-Charset Token-text NYI\n");
897 /* Any remaining data relates to Q-Value */
898 if (offset < valueLen)
901 q_value = tvb_get_guintvar (value_buff, offset, &count);
902 if (count == 1) /* Two decimal quality factors */
907 else if (count == 2) /* Three decimal quality factors */
914 fprintf (stderr, "dissect_wsp: Accept-Charset invalid Q-value %f\n", q_value);
918 /* Build string including Q values if present */
919 if (q_value == 1.0) /* Default */
921 if (valMatch == NULL)
923 snprintf (valString, 100, "Unknown (%02X)", peek);
927 snprintf (valString, 100, "%s", valMatch);
932 snprintf (valString, 100, "Unknown %d; Q=%5.3f", value,
934 if (valMatch == NULL)
936 snprintf (valString, 100, "Unknown (%02X)", peek);
940 snprintf (valString, 100, "%s", valMatch);
944 /* Add string to tree */
945 proto_tree_add_string (tree, hf_wsp_header_accept_charset_str,
946 header_buff, 0, headerLen, valString);
948 else /* Constrained-charset */
950 if (peek == 0x80) /* Any-charset */
952 proto_tree_add_string (tree, hf_wsp_header_accept_charset,
953 header_buff, offset, headerLen,
956 else if (peek & 0x80) /* Short-Integer */
958 proto_tree_add_uint (tree, hf_wsp_header_accept_charset,
959 header_buff, offset, headerLen, (peek & 0x7F) );
961 else /* Assume *TEXT */
963 proto_tree_add_string (tree, hf_wsp_header_accept_charset,
964 header_buff, offset, headerLen,
965 tvb_get_ptr (value_buff, 0, valueLen));
970 case 0x03: /* Accept-Language */
973 /* Peek contains the number of octets to follow */
977 proto_tree_add_uint (tree, hf_wsp_header_accept_language, header_buff, offset,
978 headerLen, tvb_get_guint8 (value_buff, 1) );
981 proto_tree_add_uint (tree, hf_wsp_header_accept_language, header_buff, offset,
982 headerLen, tvb_get_ntohs (value_buff, 1) );
985 proto_tree_add_uint (tree, hf_wsp_header_accept_language, header_buff, offset,
986 headerLen, tvb_get_ntohl (value_buff, 1) );
989 fprintf (stderr, "dissect_wsp: accept-language size %d NYI\n", peek);
992 else if (peek & 0x80)
994 proto_tree_add_uint (tree, hf_wsp_header_accept_language, header_buff, offset, headerLen, (peek & 0x7F) );
998 proto_tree_add_string (tree, hf_wsp_header_accept_language_str, header_buff, offset,headerLen,
999 tvb_get_ptr (value_buff, 0, valueLen));
1003 case 0x04: /* Accept-Ranges */
1004 if ((peek == 128) || (peek == 129))
1006 proto_tree_add_uint (tree, hf_wsp_header_accept_ranges, header_buff, offset, headerLen, peek);
1010 fprintf (stderr, "dissect_wsp: accept-ranges NYI\n");
1015 case 0x05: /* Age */
1019 proto_tree_add_uint (tree, hf_wsp_header_age, header_buff, offset, headerLen, tvb_get_guint8 (value_buff, 0));
1022 proto_tree_add_uint (tree, hf_wsp_header_age, header_buff, offset, headerLen, tvb_get_ntohs (value_buff, 0));
1025 proto_tree_add_uint (tree, hf_wsp_header_age, header_buff, offset, headerLen, tvb_get_ntoh24 (value_buff, 0));
1028 proto_tree_add_uint (tree, hf_wsp_header_age, header_buff, offset, headerLen, tvb_get_ntohl (value_buff, 0));
1033 case 0x08: /* Cache-Control */
1036 if (valueLen == 1) /* Well-known value */
1038 proto_tree_add_uint (tree, hf_wsp_header_cache_control, header_buff, offset, headerLen, peek);
1042 if ((peek == 0x82) || (peek == 0x83) || (peek == 0x84)) /* Delta seconds value to follow */
1044 value = tvb_get_guint8 (value_buff, 1);
1047 proto_tree_add_text (tree, header_buff, 0,
1048 headerLen, "Cache-Control: %s %d (0x%02X)",
1049 val_to_str (peek, vals_cache_control,
1050 "Unknown (0x%02x)"),
1051 (value & 0x7F), peek);
1055 fprintf (stderr, "dissect_wsp: Cache-Control integer value Delta seconds NYI\n");
1058 else if ((peek == 0x80) || (peek == 0x87)) /* Fields to follow */
1060 fprintf (stderr, "dissect_wsp: Cache-Control field values NYI\n");
1064 fprintf (stderr, "dissect_wsp: Cache-Control cache extension NYI\n");
1070 fprintf (stderr, "dissect_wsp: Cache-Control cache extension NYI\n");
1074 case 0x0D: /* Content-Length */
1080 proto_tree_add_uint (tree,
1081 hf_wsp_header_content_length, header_buff, offset,
1082 headerLen, tvb_get_guint8 (value_buff, 1) );
1085 proto_tree_add_uint (tree,
1086 hf_wsp_header_content_length, header_buff, offset,
1087 headerLen, tvb_get_ntohs (value_buff, 1) );
1090 proto_tree_add_uint (tree,
1091 hf_wsp_header_content_length, header_buff, offset,
1092 headerLen, (tvb_get_ntohs (value_buff, 1) << 8) +
1093 tvb_get_guint8 (value_buff, 3) );
1096 proto_tree_add_uint (tree,
1097 hf_wsp_header_content_length, header_buff, offset,
1098 headerLen, tvb_get_ntohl (value_buff, 1) );
1101 fprintf (stderr, "dissect_wsp: accept-charset size %d NYI\n", peek);
1104 else if (peek & 0x80)
1106 proto_tree_add_uint (tree, hf_wsp_header_content_length, header_buff, offset, headerLen, (peek & 0x7F));
1110 fprintf (stderr, "dissect_wsp: Content-Length long-integer size NYI\n");
1114 case 0x12: /* Date */
1115 add_date_value (value_buff, 0, tree,
1116 hf_wsp_header_date, header_buff, offset,
1117 headerLen, &timeValue, "Date");
1120 case 0x13: /* Etag */
1121 ti = proto_tree_add_string (tree, hf_wsp_header_etag,header_buff,offset,headerLen,tvb_get_ptr (value_buff, 0, valueLen));
1124 case 0x14: /* Expires */
1125 add_date_value (value_buff, 0, tree,
1126 hf_wsp_header_expires, header_buff, offset,
1127 headerLen, &timeValue, "Expires");
1130 case 0x17: /* If-Modified-Since */
1131 add_date_value (value_buff, 0, tree,
1132 hf_wsp_header_if_modified_since, header_buff, offset,
1133 headerLen, &timeValue, "If-Modified-Since");
1136 case 0x1C: /* Location */
1137 ti = proto_tree_add_string (tree, hf_wsp_header_location,header_buff,offset,headerLen,tvb_get_ptr (value_buff, 0, valueLen));
1140 case 0x1D: /* Last-Modified */
1141 add_date_value (value_buff, 0, tree,
1142 hf_wsp_header_last_modified, header_buff, offset,
1143 headerLen, &timeValue, "Last-Modified");
1146 case 0x1F: /* Pragma */
1149 proto_tree_add_text (tree, header_buff, 0, headerLen, "Pragma: No-cache");
1153 proto_tree_add_text (tree, header_buff, 0, headerLen, "Unsupported Header (0x%02X)", (tvb_get_guint8 (header_buff, 0) & 0x7F));
1157 case 0x26: /* Server */
1158 ti = proto_tree_add_string (tree, hf_wsp_header_server,header_buff,offset,headerLen,tvb_get_ptr (value_buff, 0, valueLen));
1161 case 0x27: /* Transfer encoding */
1164 proto_tree_add_uint (tree, hf_wsp_header_transfer_encoding,
1165 header_buff, offset, headerLen, peek);
1169 proto_tree_add_string (tree,
1170 hf_wsp_header_transfer_encoding_str, header_buff, offset,
1171 headerLen,tvb_get_ptr (value_buff, 0, valueLen));
1175 case 0x29: /* User-Agent */
1176 ti = proto_tree_add_string (tree, hf_wsp_header_user_agent,header_buff,offset,headerLen,tvb_get_ptr (value_buff, 0, valueLen));
1179 case 0x2B: /* Via */
1180 ti = proto_tree_add_string (tree, hf_wsp_header_via, header_buff,
1181 offset, headerLen, tvb_get_ptr (value_buff, 0, valueLen));
1185 ti = proto_tree_add_text (tree, header_buff, 0, headerLen, "Unsupported Header (0x%02X)", (tvb_get_guint8 (header_buff, 0) & 0x7F));
1191 /* Special case header X-WAP.TOD that is sometimes followed
1192 * by a 4-byte date value */
1193 if (strncasecmp ("x-wap.tod", tvb_get_ptr (header_buff, 0, headerLen), 9) == 0)
1195 if (tvb_reported_length (value_buff) == 4) /* Probably a date value */
1197 timeValue.tv_sec = tvb_get_ntohl (value_buff, 0);
1198 ti = proto_tree_add_time (tree, hf_wsp_header_x_wap_tod, header_buff, offset, headerLen, &timeValue);
1200 else if (tvb_reported_length (value_buff) == 5) /* Probably a date */
1202 add_date_value (value_buff, 0, tree,
1203 hf_wsp_header_x_wap_tod, header_buff, offset,
1204 headerLen, &timeValue, "X-Wap.Tod");
1208 ti = proto_tree_add_text (tree, header_buff, 0, headerLen, "%s: %s", tvb_get_ptr (header_buff, 0, headerLen), tvb_get_ptr (value_buff, 0, valueLen));
1213 ti = proto_tree_add_text (tree, header_buff, 0, headerLen, "%s: %s", tvb_get_ptr (header_buff, 0, headerLen), tvb_get_ptr (value_buff, 0, valueLen));
1220 get_value_length (tvbuff_t *tvb, guint offset, guint *nextOffset)
1224 guint octet = tvb_get_guint8 (tvb, offset);
1226 if (octet <= 30) /* Short length */
1229 *nextOffset = offset+1;
1231 else if (octet == 31)
1233 value = tvb_get_guintvar (tvb, offset+1, &count);
1234 *nextOffset = offset+1+count;
1238 fprintf (stderr, "dissect_wsp: get_value_length: case NYI\n");
1245 add_content_type (proto_tree *tree, tvbuff_t *tvb, guint offset, guint *contentType)
1247 proto_tree *contentTypeTree;
1248 guint nextOffset = offset;
1249 guint fieldLength = 0;
1250 guint octet = tvb_get_guint8 (tvb, offset);
1251 guint totalSizeOfField = 0;
1255 fieldLength = get_value_length (tvb, offset, &nextOffset);
1256 totalSizeOfField = (nextOffset-offset)+fieldLength;
1258 else if (octet & 0x80)
1261 totalSizeOfField = 1;
1265 fprintf (stderr, "dissect-wsp: Content-type is un-supported\n");
1268 *contentType = (tvb_get_guint8 (tvb, nextOffset) & 0x7F);
1269 contentTypeTree = proto_tree_add_uint (tree, hf_wsp_content_type, tvb, offset, totalSizeOfField, (tvb_get_guint8(tvb,nextOffset++) & 0x7F));
1271 while (nextOffset < (offset+totalSizeOfField))
1274 nextOffset = add_parameter (contentTypeTree, tvb, nextOffset);
1277 return (offset+totalSizeOfField);
1280 /* Utility function to extract date values from the packet */
1282 get_date_value (tvbuff_t *buffer, guint offset, struct timeval *timeValue)
1284 guint ShortLength = 0;
1286 /* Initialise time values */
1287 timeValue->tv_sec=0;
1288 timeValue->tv_usec = 0;
1290 /* Date values are encoded as: Short-length Multi-octet-integer
1291 * Where Short-length = 0-30
1293 ShortLength = tvb_get_guint8 (buffer, offset++);
1294 if (ShortLength > 30)
1296 fprintf (stderr, "dissect_wsp: Invalid Date-value (Short-length=%d)\n",
1301 switch (ShortLength)
1304 timeValue->tv_sec = tvb_get_guint8 (buffer, offset);
1307 timeValue->tv_sec = tvb_get_ntohs (buffer, offset);
1310 timeValue->tv_sec = tvb_get_ntoh24 (buffer, offset);
1313 timeValue->tv_sec = tvb_get_ntohl (buffer, offset);
1316 fprintf (stderr, "dissect_wsp: Date-value Short-length of %d NYI\n",
1325 /* Utility function to add a date value to the protocol tree */
1327 add_date_value (tvbuff_t *buffer, guint offset, proto_tree *tree,
1328 int header, tvbuff_t *headerBuffer, guint headerOffset,
1329 guint headerLen, struct timeval *timeValue, const char *fieldName)
1331 /* Attempt to get the date value from the buffer */
1332 if (get_date_value (buffer, offset, timeValue) == 0)
1334 /* If successful, add it to the protocol tree */
1335 proto_tree_add_time (tree, header, headerBuffer, headerOffset,
1336 headerLen, timeValue);
1340 fprintf (stderr, "dissect_wsp: Invalid %s value\n", fieldName);
1345 add_parameter (proto_tree *tree, tvbuff_t *tvb, guint offset)
1347 guint octet = tvb_get_guint8 (tvb, offset);
1348 if (octet & 0x80) /* Short integer */
1351 octet = octet & 0x7F;
1355 offset = add_parameter_charset (tree, tvb, offset, offset-1);
1359 fprintf (stderr, "dissect-wsp: add_parameter octet=0x%02x\n", octet);
1364 fprintf (stderr, "dissect-wsp: add_parameter octet=0x%02x\n", octet);
1371 add_parameter_charset (proto_tree *tree, tvbuff_t *tvb, guint offset, guint startOffset)
1373 guint octet = tvb_get_guint8 (tvb, offset);
1377 proto_tree_add_item (tree, hf_wsp_parameter_well_known_charset, tvb, startOffset+1, octet, bo_big_endian);
1379 else if (octet & 0x80)
1382 proto_tree_add_uint (tree, hf_wsp_parameter_well_known_charset, tvb, startOffset, offset-startOffset, (octet & 0x7F));
1389 add_post_data (proto_tree *tree, tvbuff_t *tvb, guint contentType)
1392 guint variableStart = 0;
1393 guint variableEnd = 0;
1394 guint valueStart = 0;
1399 /* VERIFY ti = proto_tree_add_item (tree, hf_wsp_post_data,tvb,offset,END_OF_FRAME,bo_little_endian); */
1400 ti = proto_tree_add_item (tree, hf_wsp_post_data,tvb,offset,tvb_reported_length(tvb),bo_little_endian);
1402 if (contentType == 0x12) /* URL Encoded data */
1404 /* Iterate through post data */
1405 for (offset = 0; offset < tvb_reported_length (tvb); offset++)
1407 peek = tvb_get_guint8 (tvb, offset);
1410 variableEnd = offset;
1411 valueStart = offset+1;
1413 else if (peek == '&')
1415 if (variableEnd > 0)
1417 add_post_variable (ti, tvb, variableStart, variableEnd, valueStart, offset);
1419 variableStart = offset+1;
1426 /* See if there's outstanding data */
1427 if (variableEnd > 0)
1429 add_post_variable (ti, tvb, variableStart, variableEnd, valueStart, offset);
1435 add_post_variable (proto_tree *tree, tvbuff_t *tvb, guint variableStart, guint variableEnd, guint valueStart, guint valueEnd)
1437 int variableLength = variableEnd-variableStart;
1438 int valueLength = 0;
1439 char *variableBuffer;
1442 variableBuffer = g_malloc (variableLength+1);
1443 strncpy (variableBuffer, tvb_get_ptr (tvb, variableStart, variableLength), variableLength);
1444 variableBuffer[variableLength] = 0;
1446 if (valueEnd < valueStart)
1448 valueBuffer = g_malloc (1);
1450 valueEnd = valueStart;
1454 valueLength = valueEnd-valueStart;
1455 valueBuffer = g_malloc (valueLength+1);
1456 strncpy (valueBuffer, tvb_get_ptr (tvb, valueStart, valueLength), valueLength);
1457 valueBuffer[valueLength] = 0;
1460 /* Check for variables with no value */
1461 if (valueStart >= tvb_reported_length (tvb))
1463 valueStart = tvb_reported_length (tvb);
1464 valueEnd = valueStart;
1466 valueLength = valueEnd-valueStart;
1468 proto_tree_add_text (tree, tvb, variableStart, valueEnd-variableStart, "%s: %s", variableBuffer, valueBuffer);
1470 g_free (variableBuffer);
1471 g_free (valueBuffer);
1474 /* Register the protocol with Ethereal */
1476 proto_register_wsp(void)
1479 /* Setup list of header fields */
1480 static hf_register_info hf[] = {
1481 { &hf_wsp_header_tid,
1482 { "Transmission ID",
1484 FT_UINT8, BASE_HEX, NULL, 0x00,
1488 { &hf_wsp_header_pdu_type,
1491 FT_UINT8, BASE_HEX, VALS( vals_pdu_type ), 0x00,
1495 { &hf_wsp_version_major,
1496 { "Version (Major)",
1497 "wsp.version.major",
1498 FT_UINT8, BASE_DEC, NULL, 0xF0,
1502 { &hf_wsp_version_minor,
1503 { "Version (Minor)",
1504 "wsp.version.minor",
1505 FT_UINT8, BASE_DEC, NULL, 0x0F,
1509 { &hf_wsp_capability_length,
1510 { "Capability Length",
1511 "wsp.capability.length",
1512 FT_UINT32, BASE_DEC, NULL, 0x00,
1516 { &hf_wsp_header_length,
1518 "wsp.headers_length",
1519 FT_UINT32, BASE_DEC, NULL, 0x00,
1523 { &hf_wsp_capabilities_section,
1526 FT_NONE, BASE_DEC, NULL, 0x00,
1530 { &hf_wsp_headers_section,
1533 FT_NONE, BASE_DEC, NULL, 0x00,
1539 "wsp.headers.header",
1540 FT_NONE, BASE_DEC, NULL, 0x00,
1544 { &hf_wsp_header_uri_len,
1547 FT_UINT32, BASE_DEC, NULL, 0x00,
1551 { &hf_wsp_header_uri,
1554 FT_STRING, BASE_NONE, NULL, 0x00,
1558 { &hf_wsp_server_session_id,
1559 { "Server Session ID",
1560 "wsp.server.session_id",
1561 FT_UINT32, BASE_DEC, NULL, 0x00,
1565 { &hf_wsp_header_status,
1568 FT_UINT8, BASE_HEX, VALS( vals_status ), 0x00,
1572 { &hf_wsp_content_type,
1574 "wsp.content_type.type",
1575 FT_UINT8, BASE_HEX, VALS ( vals_content_types ), 0x00,
1579 { &hf_wsp_parameter_well_known_charset,
1581 "wsp.content_type.parameter.charset",
1582 FT_UINT16, BASE_HEX, VALS ( vals_character_sets ), 0x00,
1586 { &hf_wsp_reply_data,
1589 FT_NONE, BASE_NONE, NULL, 0x00,
1593 { &hf_wsp_header_accept,
1595 "wsp.header.accept",
1596 /*FT_NONE, BASE_DEC, NULL, 0x00,*/
1597 FT_UINT8, BASE_HEX, VALS ( vals_content_types ), 0x00,
1601 { &hf_wsp_header_accept_str,
1603 "wsp.header.accept.string",
1604 FT_STRING, BASE_NONE, NULL, 0x00,
1608 { &hf_wsp_header_accept_charset,
1610 "wsp.header.accept_charset",
1611 FT_UINT16, BASE_HEX, VALS ( vals_character_sets ), 0x00,
1615 { &hf_wsp_header_accept_charset_str,
1617 "wsp.header.accept_charset.string",
1618 FT_STRING, BASE_NONE, NULL, 0x00,
1622 { &hf_wsp_header_accept_language,
1623 { "Accept-Language",
1624 "wsp.header.accept_language",
1625 FT_UINT8, BASE_HEX, VALS ( vals_languages ), 0x00,
1629 { &hf_wsp_header_accept_language_str,
1630 { "Accept-Language",
1631 "wsp.header.accept_language.string",
1632 FT_STRING, BASE_NONE, NULL, 0x00,
1636 { &hf_wsp_header_accept_ranges,
1638 "wsp.header.accept_ranges",
1639 FT_UINT8, BASE_HEX, VALS ( vals_accept_ranges ), 0x00,
1643 { &hf_wsp_header_age,
1646 FT_UINT32, BASE_DEC, NULL, 0x00,
1650 { &hf_wsp_header_cache_control,
1652 "wsp.header.cache_control",
1653 FT_UINT8, BASE_HEX, VALS ( vals_cache_control ), 0x00,
1657 { &hf_wsp_header_content_length,
1659 "wsp.header.content_length",
1660 FT_UINT32, BASE_DEC, NULL, 0x00,
1664 { &hf_wsp_header_date,
1667 FT_ABSOLUTE_TIME, BASE_NONE, NULL, 0x0,
1671 { &hf_wsp_header_etag,
1674 /*FT_NONE, BASE_DEC, NULL, 0x00,*/
1675 FT_STRING, BASE_NONE, NULL, 0x00,
1679 { &hf_wsp_header_expires,
1681 "wsp.header.expires",
1682 FT_ABSOLUTE_TIME, BASE_NONE, NULL, 0x0,
1686 { &hf_wsp_header_last_modified,
1688 "wsp.header.last_modified",
1689 FT_ABSOLUTE_TIME, BASE_NONE, NULL, 0x0,
1693 { &hf_wsp_header_location,
1695 "wsp.header.location",
1696 FT_STRING, BASE_NONE, NULL, 0x00,
1700 { &hf_wsp_header_if_modified_since,
1701 { "If-Modified-Since",
1702 "wsp.header.if_modified_since",
1703 FT_ABSOLUTE_TIME, BASE_NONE, NULL, 0x0,
1707 { &hf_wsp_header_server,
1709 "wsp.header.server",
1710 /*FT_NONE, BASE_DEC, NULL, 0x00,*/
1711 FT_STRING, BASE_NONE, NULL, 0x00,
1715 { &hf_wsp_header_transfer_encoding,
1716 { "Transfer Encoding",
1717 "wsp.header.transfer_enc",
1718 /*FT_NONE, BASE_DEC, NULL, 0x00,*/
1719 FT_UINT8, BASE_HEX, VALS ( vals_transfer_encoding ), 0x00,
1723 { &hf_wsp_header_transfer_encoding_str,
1724 { "Transfer Encoding",
1725 "wsp.header.transfer_enc_str",
1726 FT_STRING, BASE_NONE, NULL, 0x00,
1730 { &hf_wsp_header_user_agent,
1732 "wsp.header.user_agent",
1733 /*FT_NONE, BASE_DEC, NULL, 0x00,*/
1734 FT_STRING, BASE_NONE, NULL, 0x00,
1738 { &hf_wsp_header_via,
1741 FT_STRING, BASE_NONE, NULL, 0x00,
1745 { &hf_wsp_header_application_header,
1746 { "Application Header",
1747 "wsp.header.application_header",
1748 FT_STRING, BASE_NONE, NULL, 0x00,
1749 "Application Header"
1752 { &hf_wsp_header_application_value,
1753 { "Application Header Value",
1754 "wsp.header.application_header.value",
1755 FT_STRING, BASE_NONE, NULL, 0x00,
1756 "Application Header Value"
1759 { &hf_wsp_header_x_wap_tod,
1761 "wsp.header.x_wap_tod",
1762 FT_ABSOLUTE_TIME, BASE_NONE, NULL, 0x0,
1766 { &hf_wsp_post_data,
1769 FT_NONE, BASE_NONE, NULL, 0x00,
1775 /* Setup protocol subtree array */
1776 static gint *ett[] = {
1784 /* Register the protocol name and description */
1785 proto_wsp = proto_register_protocol(
1786 "Wireless Session Protocol", /* protocol name for use by ethereal */
1787 "WSP", /* short version of name */
1788 "wap-wsp" /* Abbreviated protocol name, should Match IANA
1789 < URL:http://www.isi.edu/in-notes/iana/assignments/port-numbers/ >
1793 /* Required function calls to register the header fields and subtrees used */
1794 proto_register_field_array(proto_wsp, hf, array_length(hf));
1795 proto_register_subtree_array(ett, array_length(ett));
1797 register_dissector("wsp", dissect_wsp, proto_wsp);
1801 proto_reg_handoff_wsp(void)
1804 * Get a handle for the WMLC dissector
1806 wmlc_handle = find_dissector("wmlc"); /* Coming soon :) */
1808 /* Only connection-less WSP has no previous handler */
1809 dissector_add("udp.port", UDP_PORT_WSP, dissect_wsp, proto_wsp);
1811 /* This dissector is also called from the WTP and WTLS dissectors */