2 * Routines for wbxml dissection
3 * Copyright 2003, Olivier Biot <olivier.biot (ad) siemens.com>
5 * $Id: packet-wbxml.c,v 1.11 2003/06/26 18:28:12 guy Exp $
7 * Ethereal - Network traffic analyzer
8 * By Gerald Combs <gerald@ethereal.com>
9 * Copyright 1998 Gerald Combs
11 * WAP Binary XML decoding functionality provided by Olivier Biot.
13 * The WAP specifications are found at the WAP Forum:
14 * http://www.wapforum.org/what/Technical.htm
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License
18 * as published by the Free Software Foundation; either version 2
19 * of the License, or (at your option) any later version.
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31 /* Edit this file with 4-space tabulation */
43 #ifdef NEED_SNPRINTF_H
44 # include "snprintf.h"
47 #include <epan/packet.h>
49 /* We need the function tvb_get_guintvar() */
50 #include "packet-wap.h"
52 /* The code in this source file dissects the WAP Binary XML content,
53 * and if possible renders it. WBXML mappings are defined in the
54 * "wbxml_map[]" array.
58 * - Code page switches only apply to the following token. In the WBXML/1.x
59 * ABNF notation, it can be proven that the switch_page can only precede
60 * the following tokens:
61 * o stag : TAG | LITERAL | LITERAL_A | LITERAL_C | LITERAL_AC
62 * o attr : ATTRSTART | ATTRVALUE
63 * o extension : EXT_I | EXT_T | EXT
64 * Code page switches are displayed in a separate column. The only allowed
65 * code page switches are from code page 0 to another codepage (by means of
66 * a SWITCH_PAGE token), and from this other code page back to code page 0
67 * (this happens automatically).
69 * - In order to render the XML content, recursion is inevitable at some
70 * point (when a tag with content occurs in the content of a tag with
71 * content). The code will however not recurse if this is not strictly
72 * required (e.g., tag without content in the content of a tag with
75 * - I found it useful to display the XML nesting level as a first "column",
76 * followed by the abbreviated WBXML token interpretation. When a mapping
77 * is defined for the parsed WBXML content, then the XML rendering is
78 * displayed with appropriate indentation (maximum nesting level = 255,
79 * after which the nesting and level will safely roll-over to 0).
81 * - The WAP Forum defines the order of precedence for finding out the
82 * WBXML content type (same rules for charset) as follows:
83 * 1. Look in the Content-Type WSP header
84 * 2. Look in the WBXML header
85 * Currently there is no means of using content type parameters:
87 * o Charset=<charset_of_the_content>
88 * So it is possible some WBXML content types are incorrectly parsed.
89 * This would only be the case when the content type declaration in the
90 * WSP Content-Type header would be different (or would have parameters
91 * which are relevant to the WBXML decoding) from the content type
92 * identifier specified in the WBXML header.
93 * TODO: investigate this and provide correct decoding at all times.
96 typedef struct _value_valuestring {
98 const value_string *valstrptr;
101 /* Tries to match val against each element in the value_value_string array vvs.
102 * Returns the associated value_string ptr on a match, or NULL on failure. */
103 static const value_string *
104 val_to_valstr(guint32 val, const value_valuestring *vvs)
108 while (vvs[i].valstrptr) {
109 if (vvs[i].value == val)
110 return(vvs[i].valstrptr);
118 /************************** Variable declarations **************************/
121 /* Initialize the protocol and registered fields */
122 static int proto_wbxml = -1;
123 static int hf_wbxml_version = -1;
124 static int hf_wbxml_public_id_known = -1;
125 static int hf_wbxml_public_id_literal = -1;
126 static int hf_wbxml_charset = -1;
128 /* Initialize the subtree pointers */
129 static gint ett_wbxml = -1;
130 static gint ett_wbxml_str_tbl = -1;
131 static gint ett_wbxml_content = -1;
134 /**************** WBXML related declarations and definitions ****************/
137 /* WBXML public ID mappings. For an up-to-date list, see
138 * http://www.wapforum.org/wina/wbxml-public-docid.htm */
139 static const value_string vals_wbxml_public_ids[] = {
140 /* 0x00 = literal public identifier */
141 { 0x01, "Unknown / missing Public Identifier" },
142 { 0x02, "-//WAPFORUM//DTD WML 1.0//EN (WML 1.0)" },
143 { 0x03, "-//WAPFORUM//DTD WTA 1.0//EN (WTA Event 1.0) - Deprecated" },
144 { 0x04, "-//WAPFORUM//DTD WML 1.1//EN (WML 1.1)" },
145 { 0x05, "-//WAPFORUM//DTD SI 1.0//EN (Service Indication 1.0)" },
146 { 0x06, "-//WAPFORUM//DTD SL 1.0//EN (Service Loading 1.0)" },
147 { 0x07, "-//WAPFORUM//DTD CO 1.0//EN (Cache Operation 1.0)" },
148 { 0x08, "-//WAPFORUM//DTD CHANNEL 1.0//EN (Channel 1.1)" },
149 { 0x09, "-//WAPFORUM//DTD WML 1.2//EN (WML 1.2)" },
150 { 0x0a, "-//WAPFORUM//DTD WML 1.3//EN (WML 1.3)" },
151 { 0x0b, "-//WAPFORUM//DTD PROV 1.0//EN (Provisioning 1.0)" },
152 { 0x0c, "-//WAPFORUM//DTD WTA-WML 1.2//EN (WTA-WML 1.2)" },
153 { 0x0d, "-//WAPFORUM//DTD EMN 1.0//EN (Email Notification 1.0)" },
154 { 0x0e, "-//WAPFORUM//DTD DRMREL 1.0//EN (DRMREL 1.0)" },
156 /* Registered values - www.syncml.org */
157 { 0x0fd1, "-//SYNCML//DTD SyncML 1.0//EN (SyncML 1.0)" },
158 { 0x0fd3, "-//SYNCML//DTD SyncML 1.1//EN (SyncML 1.1)" },
160 /* Registered values - www.wapforum.org/wina/ */
161 { 0x1100, "-//PHONE.COM//DTD ALERT 1.0//EN" },
162 { 0x1101, "-//PHONE.COM//DTD CACHE-OPERATION 1.0//EN" },
163 { 0x1102, "-//PHONE.COM//DTD SIGNAL 1.0//EN" },
164 { 0x1103, "-//PHONE.COM//DTD LIST 1.0//EN" },
165 { 0x1104, "-//PHONE.COM//DTD LISTCMD 1.0//EN" },
166 { 0x1105, "-//PHONE.COM//DTD CHANNEL 1.0//EN" },
167 { 0x1106, "-//PHONE.COM//DTD MMC 1.0//EN" },
168 { 0x1107, "-//PHONE.COM//DTD BEARER-CHOICE 1.0//EN" },
169 { 0x1108, "-//PHONE.COM//DTD WML 1.1//EN (WML+ 1.1)" },
170 { 0x1109, "-//PHONE.COM//DTD CHANNEL 1.1//EN" },
171 { 0x110a, "-//PHONE.COM//DTD LIST 1.1//EN" },
172 { 0x110b, "-//PHONE.COM//DTD LISTCMD 1.1//EN" },
173 { 0x110c, "-//PHONE.COM//DTD MMC 1.1//EN" },
174 { 0x110d, "-//PHONE.COM//DTD WML 1.3//EN (WML+ 1.3)" },
175 { 0x110e, "-//PHONE.COM//DTD MMC 2.0//EN" },
180 static const value_string vals_wbxml_versions[] = {
181 { 0x00, "1.0" }, /* WAP-104-WBXML */
182 { 0x01, "1.1" }, /* WAP-135-WBXML */
183 { 0x02, "1.2" }, /* WAP-154-WBXML */
184 { 0x03, "1.3" }, /* WAP-192-WBXML */
189 /* WBXML 1.0 global tokens: WAP-104-WBXML
190 * Same token mapping as in vals_wbxml1x_global_tokens, but:
191 * { 0xC3, "RESERVED_2" }
194 /* WBXML 1.x (x>0) global tokens: WAP-135-WBXML, WAP-154-WBXML, WAP-192-WBXML
196 static const value_string vals_wbxml1x_global_tokens[] = {
197 { 0x00, "SWITCH_PAGE" },
207 { 0x44, "LITERAL_C" },
213 { 0x84, "LITERAL_A" },
219 { 0xC4, "LITERAL_AC" },
225 /********************** WBXML token mapping definition **********************/
230 * Wireless Markup Language
231 ***************************************/
233 /***** Global extension tokens *****/
234 static const value_string wbxml_wmlc10_global_cp0[] = {
235 { 0x40, "Variable substitution - escaped" },
236 { 0x41, "Variable substitution - unescaped" },
237 { 0x42, "Variable substitution - no transformation" },
238 { 0x80, "Variable substitution - escaped" },
239 { 0x81, "Variable substitution - unescaped" },
240 { 0x82, "Variable substitution - no transformation" },
241 { 0xC0, "Reserved" },
242 { 0xC1, "Reserved" },
243 { 0xC2, "Reserved" },
248 /***** Tag tokens *****/
249 static const value_string wbxml_wmlc10_tags_cp0[] = {
250 /* 0x00 -- 0x04 GLOBAL */
260 { 0xEA, "FIELDSET" },
270 { 0xF4, "OPTGROUP" },
277 { 0xFB, "TEMPLATE" },
286 /***** Attribute Start tokens *****/
287 static const value_string wbxml_wmlc10_attrStart_cp0[] = {
288 /* 0x00 -- 0x04 GLOBAL */
289 { 0x05, "ACCEPT-CHARSET=" },
290 { 0x06, "ALIGN='BOTTOM'" },
291 { 0x07, "ALIGN='CENTER'" },
292 { 0x08, "ALIGN='LEFT'" },
293 { 0x09, "ALIGN='MIDDLE'" },
294 { 0x0A, "ALIGN='RIGHT'" },
295 { 0x0B, "ALIGN='TOP'" },
297 { 0x0D, "CONTENT=" },
298 { 0x0E, "DEFAULT=" },
300 { 0x10, "EMPTYOK='FALSE'" },
301 { 0x11, "EMPTYOK='TRUE'" },
305 { 0x15, "IDEFAULT=" },
309 { 0x19, "LOCALSRC=" },
310 { 0x1A, "MAXLENGTH=" },
311 { 0x1B, "METHOD='GET'" },
312 { 0x1C, "METHOD='POST'" },
313 { 0x1D, "MODE='NOWRAP'" },
314 { 0x1E, "MODE='WRAP'" },
315 { 0x1F, "MULTIPLE='FALSE'" },
316 { 0x20, "MULTIPLE='TRUE'" },
318 { 0x22, "NEWCONTEXT='FALSE'" },
319 { 0x23, "NEWCONTEXT='TRUE'" },
320 { 0x24, "ONCLICK=" },
321 { 0x25, "ONENTERBACKWARD=" },
322 { 0x26, "ONENTERFORWARD=" },
323 { 0x27, "ONTIMER=" },
324 { 0x28, "OPTIONAL='FALSE'" },
325 { 0x29, "OPTIONAL='TRUE'" },
327 { 0x2B, "POSTDATA=" },
328 { 0x2C, "PUBLIC='FALSE'" },
329 { 0x2D, "PUBLIC='TRUE'" },
331 { 0x2F, "SENDREFERER='FALSE'" },
332 { 0x30, "SENDREFERER='TRUE'" },
335 { 0x33, "STYLE='LIST'" },
336 { 0x34, "STYLE='SET'" },
337 { 0x35, "TABINDEX=" },
340 { 0x38, "TYPE='ACCEPT'" },
341 { 0x39, "TYPE='DELETE'" },
342 { 0x3A, "TYPE='HELP'" },
343 { 0x3B, "TYPE='PASSWORD'" },
344 { 0x3C, "TYPE='ONCLICK'" },
345 { 0x3D, "TYPE='ONENTERBACKWARD'" },
346 { 0x3E, "TYPE='ONENTERFORWARD'" },
347 { 0x3F, "TYPE='ONTIMER'" },
348 /* 0x40 -- 0x44 GLOBAL */
349 { 0x45, "TYPE='OPTIONS'" },
350 { 0x46, "TYPE='PREV'" },
351 { 0x47, "TYPE='RESET'" },
352 { 0x48, "TYPE='TEXT'" },
353 { 0x49, "TYPE='vnd.'" },
355 { 0x4B, "URL='http://'" },
356 { 0x4C, "URL='https://'" },
357 { 0x4D, "USER-AGENT=" },
361 { 0x51, "xml:lang=" },
366 /***** Attribute Value tokens *****/
367 static const value_string wbxml_wmlc10_attrValue_cp0[] = {
368 /* 0x80 -- 0x84 GLOBAL */
373 { 0x89, "'ACCEPT'" },
374 { 0x8A, "'BOTTOM'" },
376 { 0x8C, "'DELETE'" },
378 { 0x8E, "'http://'" },
379 { 0x8F, "'http://www.'" },
380 { 0x90, "'https://'" },
381 { 0x91, "'https://www.'" },
383 { 0x93, "'MIDDLE'" },
384 { 0x94, "'NOWRAP'" },
385 { 0x95, "'ONCLICK'" },
386 { 0x96, "'ONENTERBACKWARD'" },
387 { 0x97, "'ONENTERFORWARD'" },
388 { 0x98, "'ONTIMER'" },
389 { 0x99, "'OPTIONS'" },
390 { 0x9A, "'PASSWORD'" },
395 { 0x9F, "'UNKNOWN'" },
402 /***** Token code page aggregation *****/
403 static const value_valuestring wbxml_wmlc10_global[] = {
404 { 0, wbxml_wmlc10_global_cp0 },
408 static const value_valuestring wbxml_wmlc10_tags[] = {
409 { 0, wbxml_wmlc10_tags_cp0 },
413 static const value_valuestring wbxml_wmlc10_attrStart[] = {
414 { 0, wbxml_wmlc10_attrStart_cp0 },
418 static const value_valuestring wbxml_wmlc10_attrValue[] = {
419 { 0, wbxml_wmlc10_attrValue_cp0 },
429 * Wireless Markup Language
430 ***************************************/
432 /***** Global extension tokens *****/
433 /* Same as in WML 1.0 */
435 /***** Tag tokens *****/
436 static const value_string wbxml_wmlc11_tags_cp0[] = {
437 /* 0x00 -- 0x04 GLOBAL */
444 { 0x21, "postfield" },
453 { 0x2A, "fieldset" },
463 { 0x34, "optgroup" },
470 { 0x3B, "template" },
479 /***** Attribute Start tokens *****/
480 static const value_string wbxml_wmlc11_attrStart_cp0[] = {
481 /* 0x00 -- 0x04 GLOBAL */
482 { 0x05, "accept-charset=" },
483 { 0x06, "align='bottom'" },
484 { 0x07, "align='center'" },
485 { 0x08, "align='left'" },
486 { 0x09, "align='middle'" },
487 { 0x0A, "align='right'" },
488 { 0x0B, "align='top'" },
490 { 0x0D, "content=" },
493 { 0x10, "emptyok='false'" },
494 { 0x11, "emptyok='true'" },
502 { 0x19, "localsrc=" },
503 { 0x1A, "maxlength=" },
504 { 0x1B, "method='get'" },
505 { 0x1C, "method='post'" },
506 { 0x1D, "mode='nowrap'" },
507 { 0x1E, "mode='wrap'" },
508 { 0x1F, "multiple='false'" },
509 { 0x20, "multiple='true'" },
511 { 0x22, "newcontext='false'" },
512 { 0x23, "newcontext='true'" },
514 { 0x25, "onenterbackward=" },
515 { 0x26, "onenterforward=" },
516 { 0x27, "ontimer=" },
517 { 0x28, "optional='false'" },
518 { 0x29, "optional='true'" },
522 { 0x2F, "sendreferer='false'" },
523 { 0x30, "sendreferer='true'" },
526 { 0x33, "ordered='false'" },
527 { 0x34, "ordered='true'" },
528 { 0x35, "tabindex=" },
531 { 0x38, "type='accept'" },
532 { 0x39, "type='delete'" },
533 { 0x3A, "type='help'" },
534 { 0x3B, "type='password'" },
535 { 0x3C, "type='onpick'" },
536 { 0x3D, "type='onenterbackward'" },
537 { 0x3E, "type='onenterforward'" },
538 { 0x3F, "type='ontimer'" },
539 /* 0x40 -- 0x44 GLOBAL */
540 { 0x45, "type='options'" },
541 { 0x46, "type='prev'" },
542 { 0x47, "type='reset'" },
543 { 0x48, "type='text'" },
544 { 0x49, "type='vnd.'" },
546 { 0x4B, "href='http://'" },
547 { 0x4C, "href='https://'" },
551 { 0x50, "xml:lang=" },
554 { 0x53, "columns=" },
557 { 0x56, "forua='false'" },
558 { 0x57, "forua='true'" },
559 { 0x58, "src='http://'" },
560 { 0x59, "src='https://'" },
561 { 0x5A, "http-equiv=" },
562 { 0x5B, "http-equiv='Content-Type'" },
563 { 0x5C, "content='application/vnd.wap.wmlc;charset='" },
564 { 0x5D, "http-equiv='Expires'" },
569 /***** Attribute Value tokens *****/
570 static const value_string wbxml_wmlc11_attrValue_cp0[] = {
571 /* 0x80 -- 0x84 GLOBAL */
576 { 0x89, "'accept'" },
577 { 0x8A, "'bottom'" },
579 { 0x8C, "'delete'" },
581 { 0x8E, "'http://'" },
582 { 0x8F, "'http://www.'" },
583 { 0x90, "'https://'" },
584 { 0x91, "'https://www.'" },
586 { 0x93, "'middle'" },
587 { 0x94, "'nowrap'" },
588 { 0x95, "'onpick'" },
589 { 0x96, "'onenterbackward'" },
590 { 0x97, "'onenterforward'" },
591 { 0x98, "'ontimer'" },
592 { 0x99, "'options'" },
593 { 0x9A, "'password'" },
598 { 0x9F, "'unknown'" },
605 /***** Token code page aggregation *****/
606 static const value_valuestring wbxml_wmlc11_global[] = {
607 { 0, wbxml_wmlc10_global_cp0 }, /* Same as WML 1.0 */
611 static const value_valuestring wbxml_wmlc11_tags[] = {
612 { 0, wbxml_wmlc11_tags_cp0 },
616 static const value_valuestring wbxml_wmlc11_attrStart[] = {
617 { 0, wbxml_wmlc11_attrStart_cp0 },
621 static const value_valuestring wbxml_wmlc11_attrValue[] = {
622 { 0, wbxml_wmlc11_attrValue_cp0 },
632 * Wireless Markup Language
633 ***************************************/
635 /***** Global extension tokens *****/
636 /* Same as in WML 1.0 */
638 /***** Tag tokens *****/
639 static const value_string wbxml_wmlc12_tags_cp0[] = {
640 /* 0x00 -- 0x04 GLOBAL */
648 { 0x21, "postfield" },
657 { 0x2A, "fieldset" },
667 { 0x34, "optgroup" },
674 { 0x3B, "template" },
683 /***** Attribute Start tokens *****/
684 static const value_string wbxml_wmlc12_attrStart_cp0[] = {
685 /* 0x00 -- 0x04 GLOBAL */
686 { 0x05, "accept-charset=" },
687 { 0x06, "align='bottom'" },
688 { 0x07, "align='center'" },
689 { 0x08, "align='left'" },
690 { 0x09, "align='middle'" },
691 { 0x0A, "align='right'" },
692 { 0x0B, "align='top'" },
694 { 0x0D, "content=" },
697 { 0x10, "emptyok='false'" },
698 { 0x11, "emptyok='true'" },
706 { 0x19, "localsrc=" },
707 { 0x1A, "maxlength=" },
708 { 0x1B, "method='get'" },
709 { 0x1C, "method='post'" },
710 { 0x1D, "mode='nowrap'" },
711 { 0x1E, "mode='wrap'" },
712 { 0x1F, "multiple='false'" },
713 { 0x20, "multiple='true'" },
715 { 0x22, "newcontext='false'" },
716 { 0x23, "newcontext='true'" },
718 { 0x25, "onenterbackward=" },
719 { 0x26, "onenterforward=" },
720 { 0x27, "ontimer=" },
721 { 0x28, "optional='false'" },
722 { 0x29, "optional='true'" },
726 { 0x2F, "sendreferer='false'" },
727 { 0x30, "sendreferer='true'" },
730 { 0x33, "ordered='false'" },
731 { 0x34, "ordered='true'" },
732 { 0x35, "tabindex=" },
735 { 0x38, "type='accept'" },
736 { 0x39, "type='delete'" },
737 { 0x3A, "type='help'" },
738 { 0x3B, "type='password'" },
739 { 0x3C, "type='onpick'" },
740 { 0x3D, "type='onenterbackward'" },
741 { 0x3E, "type='onenterforward'" },
742 { 0x3F, "type='ontimer'" },
743 /* 0x40 -- 0x44 GLOBAL */
744 { 0x45, "type='options'" },
745 { 0x46, "type='prev'" },
746 { 0x47, "type='reset'" },
747 { 0x48, "type='text'" },
748 { 0x49, "type='vnd.'" },
750 { 0x4B, "href='http://'" },
751 { 0x4C, "href='https://'" },
755 { 0x50, "xml:lang=" },
758 { 0x53, "columns=" },
761 { 0x56, "forua='false'" },
762 { 0x57, "forua='true'" },
763 { 0x58, "src='http://'" },
764 { 0x59, "src='https://'" },
765 { 0x5A, "http-equiv=" },
766 { 0x5B, "http-equiv='Content-Type'" },
767 { 0x5C, "content='application/vnd.wap.wmlc;charset='" },
768 { 0x5D, "http-equiv='Expires'" },
769 { 0x5E, "accesskey=" },
770 { 0x5F, "enctype=" },
771 { 0x60, "enctype='application/x-www-form-urlencoded'" },
772 { 0x61, "enctype='multipart/form-data'" },
777 /***** Attribute Value tokens *****/
778 /* Same as in WML 1.1 */
780 /***** Token code page aggregation *****/
781 static const value_valuestring wbxml_wmlc12_global[] = {
782 { 0, wbxml_wmlc10_global_cp0 }, /* Same as WML 1.0 */
786 static const value_valuestring wbxml_wmlc12_tags[] = {
787 { 0, wbxml_wmlc12_tags_cp0 },
791 static const value_valuestring wbxml_wmlc12_attrStart[] = {
792 { 0, wbxml_wmlc12_attrStart_cp0 },
796 static const value_valuestring wbxml_wmlc12_attrValue[] = {
797 { 0, wbxml_wmlc11_attrValue_cp0 }, /* Same as WML 1.1 */
807 * Wireless Markup Language
808 ***************************************/
810 /***** Global extension tokens *****/
811 /* Same as in WML 1.0 */
813 /***** Tag tokens *****/
814 /* Same as in WML 1.2 */
816 /***** Attribute Start tokens *****/
817 static const value_string wbxml_wmlc13_attrStart_cp0[] = {
818 /* 0x00 -- 0x04 GLOBAL */
819 { 0x05, "accept-charset=" },
820 { 0x06, "align='bottom'" },
821 { 0x07, "align='center'" },
822 { 0x08, "align='left'" },
823 { 0x09, "align='middle'" },
824 { 0x0A, "align='right'" },
825 { 0x0B, "align='top'" },
827 { 0x0D, "content=" },
830 { 0x10, "emptyok='false'" },
831 { 0x11, "emptyok='true'" },
839 { 0x19, "localsrc=" },
840 { 0x1A, "maxlength=" },
841 { 0x1B, "method='get'" },
842 { 0x1C, "method='post'" },
843 { 0x1D, "mode='nowrap'" },
844 { 0x1E, "mode='wrap'" },
845 { 0x1F, "multiple='false'" },
846 { 0x20, "multiple='true'" },
848 { 0x22, "newcontext='false'" },
849 { 0x23, "newcontext='true'" },
851 { 0x25, "onenterbackward=" },
852 { 0x26, "onenterforward=" },
853 { 0x27, "ontimer=" },
854 { 0x28, "optional='false'" },
855 { 0x29, "optional='true'" },
859 { 0x2F, "sendreferer='false'" },
860 { 0x30, "sendreferer='true'" },
863 { 0x33, "ordered='false'" },
864 { 0x34, "ordered='true'" },
865 { 0x35, "tabindex=" },
868 { 0x38, "type='accept'" },
869 { 0x39, "type='delete'" },
870 { 0x3A, "type='help'" },
871 { 0x3B, "type='password'" },
872 { 0x3C, "type='onpick'" },
873 { 0x3D, "type='onenterbackward'" },
874 { 0x3E, "type='onenterforward'" },
875 { 0x3F, "type='ontimer'" },
876 /* 0x40 -- 0x44 GLOBAL */
877 { 0x45, "type='options'" },
878 { 0x46, "type='prev'" },
879 { 0x47, "type='reset'" },
880 { 0x48, "type='text'" },
881 { 0x49, "type='vnd.'" },
883 { 0x4B, "href='http://'" },
884 { 0x4C, "href='https://'" },
888 { 0x50, "xml:lang=" },
891 { 0x53, "columns=" },
894 { 0x56, "forua='false'" },
895 { 0x57, "forua='true'" },
896 { 0x58, "src='http://'" },
897 { 0x59, "src='https://'" },
898 { 0x5A, "http-equiv=" },
899 { 0x5B, "http-equiv='Content-Type'" },
900 { 0x5C, "content='application/vnd.wap.wmlc;charset='" },
901 { 0x5D, "http-equiv='Expires'" },
902 { 0x5E, "accesskey=" },
903 { 0x5F, "enctype=" },
904 { 0x60, "enctype='application/x-www-form-urlencoded'" },
905 { 0x61, "enctype='multipart/form-data'" },
906 { 0x62, "xml:space='preserve'" },
907 { 0x63, "xml:space='default'" },
908 { 0x64, "cache-control='no-cache'" },
913 /***** Attribute Value tokens *****/
914 /* Same as in WML 1.1 */
916 /***** Token code page aggregation *****/
917 static const value_valuestring wbxml_wmlc13_global[] = {
918 { 0, wbxml_wmlc10_global_cp0 }, /* Same as WML 1.0 */
922 static const value_valuestring wbxml_wmlc13_tags[] = {
923 { 0, wbxml_wmlc12_tags_cp0 },
927 static const value_valuestring wbxml_wmlc13_attrStart[] = {
928 { 0, wbxml_wmlc13_attrStart_cp0 },
932 static const value_valuestring wbxml_wmlc13_attrValue[] = {
933 { 0, wbxml_wmlc11_attrValue_cp0 }, /* Same as WML 1.1 */
944 ***************************************/
946 /***** Global extension tokens *****/
948 /***** Tag tokens *****/
949 static const value_string wbxml_sic10_tags_cp0[] = {
950 /* 0x00 -- 0x04 GLOBAL */
952 { 0x06, "indication" },
959 /***** Attribute Start tokens *****/
960 static const value_string wbxml_sic10_attrStart_cp0[] = {
961 /* 0x00 -- 0x04 GLOBAL */
962 { 0x05, "action='signal-none'" },
963 { 0x06, "action='signal-low'" },
964 { 0x07, "action='signal-medium'" },
965 { 0x08, "action='signal-high'" },
966 { 0x09, "action='delete'" },
967 { 0x0a, "created=" },
969 { 0x0c, "href='http://'" },
970 { 0x0d, "href='http://www.'" },
971 { 0x0e, "href='https://'" },
972 { 0x0f, "href='https://www.'" },
973 { 0x10, "si-expires=" },
980 /***** Attribute Value tokens *****/
981 static const value_string wbxml_sic10_attrValue_cp0[] = {
982 /* 0x80 -- 0x84 GLOBAL */
991 /***** Token code page aggregation *****/
992 static const value_valuestring wbxml_sic10_tags[] = {
993 { 0, wbxml_sic10_tags_cp0 },
997 static const value_valuestring wbxml_sic10_attrStart[] = {
998 { 0, wbxml_sic10_attrStart_cp0 },
1002 static const value_valuestring wbxml_sic10_attrValue[] = {
1003 { 0, wbxml_sic10_attrValue_cp0 },
1014 ***************************************/
1016 /***** Global extension tokens *****/
1018 /***** Tag tokens *****/
1019 static const value_string wbxml_slc10_tags_cp0[] = {
1020 /* 0x00 -- 0x04 GLOBAL */
1026 /***** Attribute Start tokens *****/
1027 static const value_string wbxml_slc10_attrStart_cp0[] = {
1028 /* 0x00 -- 0x04 GLOBAL */
1029 { 0x05, "action='execute-low'" },
1030 { 0x06, "action='execute-high'" },
1031 { 0x07, "action='cache'" },
1033 { 0x09, "href='http://'" },
1034 { 0x0a, "href='http://www.'" },
1035 { 0x0b, "href='https://'" },
1036 { 0x0c, "href='https://www.'" },
1041 /***** Attribute Value tokens *****/
1042 /* Same as in SI 1.0 */
1044 /***** Token code page aggregation *****/
1045 static const value_valuestring wbxml_slc10_tags[] = {
1046 { 0, wbxml_slc10_tags_cp0 },
1050 static const value_valuestring wbxml_slc10_attrStart[] = {
1051 { 0, wbxml_slc10_attrStart_cp0 },
1055 static const value_valuestring wbxml_slc10_attrValue[] = {
1056 { 0, wbxml_sic10_attrValue_cp0 }, /* Same as SI 1.0 */
1067 ***************************************/
1069 /***** Global extension tokens *****/
1071 /***** Tag tokens *****/
1072 static const value_string wbxml_coc10_tags_cp0[] = {
1073 /* 0x00 -- 0x04 GLOBAL */
1075 { 0x06, "invalidate-object" },
1076 { 0x07, "invalidate-service" },
1081 /***** Attribute Start tokens *****/
1082 static const value_string wbxml_coc10_attrStart_cp0[] = {
1083 /* 0x00 -- 0x04 GLOBAL */
1085 { 0x06, "uri='http://'" },
1086 { 0x07, "uri='http://www.'" },
1087 { 0x08, "uri='https://'" },
1088 { 0x09, "uri='https://www.'" },
1093 /***** Attribute Value tokens *****/
1094 /* Same as in SI 1.0 */
1096 /***** Token code page aggregation *****/
1097 static const value_valuestring wbxml_coc10_tags[] = {
1098 { 0, wbxml_coc10_tags_cp0 },
1102 static const value_valuestring wbxml_coc10_attrStart[] = {
1103 { 0, wbxml_coc10_attrStart_cp0 },
1107 static const value_valuestring wbxml_coc10_attrValue[] = {
1108 { 0, wbxml_sic10_attrValue_cp0 }, /* Same as SI 1.0 */
1118 * Client Provisioning
1119 ***************************************/
1121 /***** Global extension tokens *****/
1123 /***** Tag tokens *****/
1124 static const value_string wbxml_provc10_tags_cp0[] = {
1125 /* 0x00 -- 0x04 GLOBAL */
1126 { 0x05, "wap-provisioningdoc" },
1127 { 0x06, "characteristic" },
1133 /***** Attribute Start tokens *****/
1134 static const value_string wbxml_provc10_attrStart_cp0[] = {
1135 /* 0x00 -- 0x04 GLOBAL */
1138 { 0x07, "name='NAME'" },
1139 { 0x08, "name='NAP-ADDRESS'" },
1140 { 0x09, "name='NAP-ADDRTYPE'" },
1141 { 0x0A, "name='CALLTYPE'" },
1142 { 0x0B, "name='VALIDUNTIL'" },
1143 { 0x0C, "name='AUTHTYPE'" },
1144 { 0x0D, "name='AUTHNAME'" },
1145 { 0x0E, "name='AUTHSECRET'" },
1146 { 0x0F, "name='LINGER'" },
1147 { 0x10, "name='BEARER'" },
1148 { 0x11, "name='NAPID'" },
1149 { 0x12, "name='COUNTRY'" },
1150 { 0x13, "name='NETWORK'" },
1151 { 0x14, "name='INTERNET'" },
1152 { 0x15, "name='PROXY-ID'" },
1153 { 0x16, "name='PROXY-PROVIDER-ID'" },
1154 { 0x17, "name='DOMAIN'" },
1155 { 0x18, "name='PROVURL'" },
1156 { 0x19, "name='PXAUTH-TYPE'" },
1157 { 0x1A, "name='PXAUTH-ID'" },
1158 { 0x1B, "name='PXAUTH-PW'" },
1159 { 0x1C, "name='STARTPAGE'" },
1160 { 0x1D, "name='BASAUTH-ID'" },
1161 { 0x1E, "name='BASAUTH-PW'" },
1162 { 0x1F, "name='PUSHENABLED'" },
1163 { 0x20, "name='PXADDR'" },
1164 { 0x21, "name='PXADDRTYPE'" },
1165 { 0x22, "name='TO-NAPID'" },
1166 { 0x23, "name='PORTNBR'" },
1167 { 0x24, "name='SERVICE'" },
1168 { 0x25, "name='LINKSPEED'" },
1169 { 0x26, "name='DNLINKSPEED'" },
1170 { 0x27, "name='LOCAL-ADDR'" },
1171 { 0x28, "name='LOCAL-ADDRTYPE'" },
1172 { 0x29, "name='CONTEXT-ALLOW'" },
1173 { 0x2A, "name='TRUST'" },
1174 { 0x2B, "name='MASTER'" },
1175 { 0x2C, "name='SID'" },
1176 { 0x2D, "name='SOC'" },
1177 { 0x2E, "name='WSP-VERSION'" },
1178 { 0x2F, "name='PHYSICAL-PROXY-ID'" },
1179 { 0x30, "name='CLIENT-ID'" },
1180 { 0x31, "name='DELIVERY-ERR-SDU'" },
1181 { 0x32, "name='DELIVERY-ORDER'" },
1182 { 0x33, "name='TRAFFIC-CLASS'" },
1183 { 0x34, "name='MAX-SDU-SIZE'" },
1184 { 0x35, "name='MAX-BITRATE-UPLINK'" },
1185 { 0x36, "name='MAX-BITRATE-DNLINK'" },
1186 { 0x37, "name='RESIDUAL-BER'" },
1187 { 0x38, "name='SDU-ERROR-RATIO'" },
1188 { 0x39, "name='TRAFFIC-HANDL-PRIO'" },
1189 { 0x3A, "name='TRANSFER-DELAY'" },
1190 { 0x3B, "name='GUARANTEED-BITRATE-UPLINK'" },
1191 { 0x3C, "name='GUARANTEED-BITRATE-DNLINK'" },
1193 /* 0x40 -- 0x44 GLOBAL */
1194 { 0x45, "version=" },
1195 { 0x46, "version='1.0'" },
1198 { 0x51, "type='PXLOGICAL'" },
1199 { 0x52, "type='PXPHYSICAL'" },
1200 { 0x53, "type='PORT'" },
1201 { 0x54, "type='VALIDITY'" },
1202 { 0x55, "type='NAPDEF'" },
1203 { 0x56, "type='BOOTSTRAP'" },
1204 { 0x57, "type='VENDORCONFIG'" },
1205 { 0x58, "type='CLIENTIDENTITY'" },
1206 { 0x59, "type='PXAUTHINFO'" },
1207 { 0x5A, "type='NAPAUTHINFO'" },
1212 /***** Attribute Start tokens *****/
1213 static const value_string wbxml_provc10_attrValue_cp0[] = {
1214 /* 0x80 -- 0x84 GLOBAL */
1218 { 0x88, "'ALPHA'" },
1220 { 0x8A, "'SCODE'" },
1221 { 0x8B, "'TETRA-ITSI'" },
1224 { 0x90, "'ANALOG-MODEM'" },
1225 { 0x91, "'V.120'" },
1226 { 0x92, "'V.110'" },
1228 { 0x94, "'BIT-TRANSPARENT'" },
1229 { 0x95, "'DIRECT-ASYNCHRONOUS-DATA-SERVICE'" },
1233 { 0x9C, "'HTTP-BASIC'" },
1234 { 0x9D, "'HTTP-DIGEST'" },
1235 { 0x9E, "'WTLS-SS'" },
1237 { 0xA2, "'GSM-USSD'" },
1238 { 0xA3, "'GSM-SMS'" },
1239 { 0xA4, "'ANSI-136-GUTS'" },
1240 { 0xA5, "'IS-95-CDMA-SMS'" },
1241 { 0xA6, "'IS-95-CDMA-CSD'" },
1242 { 0xA7, "'IS-95-CDMA-PACKET'" },
1243 { 0xA8, "'ANSI-136-CSD'" },
1244 { 0xA9, "'ANSI-136-GPRS'" },
1245 { 0xAA, "'GSM-CSD'" },
1246 { 0xAB, "'GSM-GPRS'" },
1247 { 0xAC, "'AMPS-CDPD'" },
1248 { 0xAD, "'PDC-CSD'" },
1249 { 0xAE, "'PDC-PACKET'" },
1250 { 0xAF, "'IDEN-SMS'" },
1251 { 0xB0, "'IDEN-CSD'" },
1252 { 0xB1, "'IDEN-PACKET'" },
1253 { 0xB2, "'FLEX/REFLEX'" },
1254 { 0xB3, "'PHS-SMS'" },
1255 { 0xB4, "'PHS-CSD'" },
1256 { 0xB5, "'TETRA-SDS'" },
1257 { 0xB6, "'TETRA-PACKET'" },
1258 { 0xB7, "'ANSI-136-GHOST'" },
1259 { 0xB8, "'MOBITEX-MPAK'" },
1261 /* 0xC0 -- 0xC4 GLOBAL */
1262 { 0xC5, "'AUTOBAUDING'" },
1264 { 0xCA, "'CL-WSP'" },
1265 { 0xCB, "'CO-WSP'" },
1266 { 0xCC, "'CL-SEC-WSP'" },
1267 { 0xCD, "'CO-SEC-WSP'" },
1268 { 0xCE, "'CL-SEC-WTA'" },
1269 { 0xCF, "'CO-SEC-WTA'" },
1274 /***** Token code page aggregation *****/
1275 static const value_valuestring wbxml_provc10_tags[] = {
1276 { 0, wbxml_provc10_tags_cp0 },
1280 static const value_valuestring wbxml_provc10_attrStart[] = {
1281 { 0, wbxml_provc10_attrStart_cp0 },
1285 static const value_valuestring wbxml_provc10_attrValue[] = {
1286 { 0, wbxml_provc10_attrValue_cp0 },
1296 * Email Notification
1297 ***************************************/
1299 /***** Global extension tokens *****/
1301 /***** Tag tokens *****/
1302 static const value_string wbxml_emnc10_tags_cp0[] = {
1303 /* 0x00 -- 0x04 GLOBAL */
1309 /***** Attribute Start tokens *****/
1310 static const value_string wbxml_emnc10_attrStart_cp0[] = {
1311 /* 0x00 -- 0x04 GLOBAL */
1312 { 0x05, "timestamp=" },
1313 { 0x06, "mailbox=" },
1314 { 0x07, "mailbox='mailat:'" },
1315 { 0x08, "mailbox='pop://'" },
1316 { 0x09, "mailbox='imap://'" },
1317 { 0x0a, "mailbox='http://'" },
1318 { 0x0b, "mailbox='http://www.'" },
1319 { 0x0c, "mailbox='https://'" },
1320 { 0x0D, "mailbox='https://www.'" },
1325 /***** Attribute Value tokens *****/
1326 /* Same as in SI 1.0 */
1328 /***** Token code page aggregation *****/
1329 static const value_valuestring wbxml_emnc10_tags[] = {
1330 { 0, wbxml_emnc10_tags_cp0 },
1334 static const value_valuestring wbxml_emnc10_attrStart[] = {
1335 { 0, wbxml_emnc10_attrStart_cp0 },
1339 static const value_valuestring wbxml_emnc10_attrValue[] = {
1340 { 0, wbxml_sic10_attrValue_cp0 }, /* Same as SI 1.0 */
1350 * SyncML Representation Protocol
1351 ***************************************/
1353 /***** Global extension tokens *****/
1355 /***** Tag tokens *****/
1356 static const value_string wbxml_syncmlc10_tags_cp0[] = { /* SyncML 1.0 */
1357 /* 0x00 -- 0x04 GLOBAL */
1360 { 0x07, "Archive" },
1375 { 0x16, "LocName" },
1378 { 0x19, "MapItem" },
1383 { 0x1E, "NoResults" },
1385 { 0x20, "Replace" },
1386 { 0x21, "RespURI" },
1387 { 0x22, "Results" },
1389 { 0x24, "Sequence" },
1390 { 0x25, "SessionID" },
1393 { 0x28, "SourceRef" },
1396 { 0x2B, "SyncBody" },
1397 { 0x2C, "SyncHdr" },
1400 { 0x2F, "TargetRef" },
1401 /* 0x30 - Reserved */
1403 { 0x32, "VerProto" },
1408 static const value_string wbxml_syncmlc10_tags_cp1[] = { /* MetInf 1.0 */
1409 /* 0x00 -- 0x04 GLOBAL */
1414 { 0x09, "FreeMem" },
1417 { 0x0C, "MaxMsgSize" },
1421 { 0x10, "NextNonce" },
1422 { 0x11, "SharedMem" },
1425 { 0x14, "Version" },
1430 /***** Attribute Start tokens *****/
1432 /***** Attribute Value tokens *****/
1434 /***** Token code page aggregation *****/
1435 static const value_valuestring wbxml_syncmlc10_tags[] = {
1436 { 0, wbxml_syncmlc10_tags_cp0 }, /* -//SYNCML//DTD SyncML 1.0//EN */
1437 { 0, wbxml_syncmlc10_tags_cp1 }, /* -//SYNCML//DTD MetInf 1.0//EN */
1447 * SyncML Representation Protocol
1448 ***************************************/
1450 /***** Global extension tokens *****/
1452 /***** Tag tokens *****/
1453 static const value_string wbxml_syncmlc11_tags_cp0[] = { /* SyncML 1.1 */
1454 /* 0x00 -- 0x04 GLOBAL */
1457 { 0x07, "Archive" },
1472 { 0x16, "LocName" },
1475 { 0x19, "MapItem" },
1480 { 0x1e, "NoResults" },
1482 { 0x20, "Replace" },
1483 { 0x21, "RespURI" },
1484 { 0x22, "Results" },
1486 { 0x24, "Sequence" },
1487 { 0x25, "SessionID" },
1490 { 0x28, "SourceRef" },
1493 { 0x2b, "SyncBody" },
1494 { 0x2c, "SyncHdr" },
1497 { 0x2f, "TargetRef" },
1498 /* 0x30 - Reserved */
1500 { 0x32, "VerProto" },
1501 { 0x33, "NumberOfChanges" },
1502 { 0x34, "MoreData" },
1507 static const value_string wbxml_syncmlc11_tags_cp1[] = { /* MetInf 1.1 */
1508 /* 0x00 -- 0x04 GLOBAL */
1513 { 0x09, "FreeMem" },
1516 { 0x0C, "MaxMsgSize" },
1520 { 0x10, "NextNonce" },
1521 { 0x11, "SharedMem" },
1524 { 0x14, "Version" },
1525 { 0x15, "MaxObjSize" },
1530 /***** Attribute Start tokens *****/
1532 /***** Attribute Value tokens *****/
1534 /***** Token code page aggregation *****/
1535 static const value_valuestring wbxml_syncmlc11_tags[] = {
1536 { 0, wbxml_syncmlc11_tags_cp0 }, /* -//SYNCML//DTD SyncML 1.1//EN */
1537 { 0, wbxml_syncmlc11_tags_cp1 }, /* -//SYNCML//DTD MetInf 1.1//EN */
1548 ***************************************/
1550 /***** Global extension tokens *****/
1552 /***** Tag tokens *****/
1553 static const value_string wbxml_channelc10_tags_cp0[] = {
1554 /* 0x00 -- 0x04 GLOBAL */
1555 { 0x05, "channel" },
1557 { 0x07, "abstract" },
1558 { 0x08, "resource" },
1563 /***** Attribute Start tokens *****/
1564 static const value_string wbxml_channelc10_attrStart_cp0[] = {
1565 /* 0x00 -- 0x04 GLOBAL */
1566 { 0x05, "maxspace" },
1569 { 0x08, "href='http://'" },
1570 { 0x09, "href='https://'" },
1571 { 0x0A, "lastmod" },
1574 { 0x0D, "success" },
1575 { 0x0E, "success='http://'" },
1576 { 0x0F, "success='https://'" },
1577 { 0x10, "failure" },
1578 { 0x11, "failure='http://'" },
1579 { 0x12, "failure='https://'" },
1580 { 0x13, "EventId" },
1585 /***** Attribute Value tokens *****/
1587 /***** Token code page aggregation *****/
1588 static const value_valuestring wbxml_channelc10_tags[] = {
1589 { 0, wbxml_channelc10_tags_cp0 },
1593 static const value_valuestring wbxml_channelc10_attrStart[] = {
1594 { 0, wbxml_channelc10_attrStart_cp0 },
1602 /********************** WBXML token mapping aggregation **********************/
1605 /* The following structure links content types to their token mapping and
1606 * contains arrays of pointers to value_string arrays (one per code page).
1608 typedef struct _wbxml_token_map {
1609 const guint32 publicid; /* WBXML DTD number - see WINA */
1610 const guint8 defined; /* Are there mapping tables defined */
1611 const value_valuestring *global; /* Global token map */
1612 const value_valuestring *tags; /* Tag token map */
1613 const value_valuestring *attrStart; /* Attribute Start token map */
1614 const value_valuestring *attrValue; /* Attribute Value token map */
1617 static const wbxml_token_map *wbxml_content_map (guint32 publicid);
1620 ** Aggregation of content type and aggregated code pages
1621 ** Content type map lookup will stop at the 1st entry with 2nd member = FALSE
1623 static const wbxml_token_map map[] = {
1624 #ifdef Test_the_WBXML_parser_without_token_mappings
1625 { 0, FALSE, NULL, NULL, NULL, NULL },
1627 { 0x02, TRUE, /* WML 1.0 */
1628 wbxml_wmlc10_global,
1630 wbxml_wmlc10_attrStart,
1631 wbxml_wmlc10_attrValue
1633 #ifdef remove_directive_and_set_TRUE_if_mapping_available
1634 { 0x03, FALSE, /* WTA 1.0 (deprecated) */
1635 NULL, NULL, NULL, NULL
1638 { 0x04, TRUE, /* WML 1.1 */
1639 wbxml_wmlc11_global,
1641 wbxml_wmlc11_attrStart,
1642 wbxml_wmlc11_attrValue
1644 { 0x05, TRUE, /* SI 1.0 */
1645 NULL, /* wbxml_sic10_global - does not exist */
1647 wbxml_sic10_attrStart,
1648 wbxml_sic10_attrValue
1650 { 0x06, TRUE, /* SL 1.0 */
1651 NULL, /* wbxml_slc10_global - does not exist */
1653 wbxml_slc10_attrStart,
1654 wbxml_slc10_attrValue
1656 { 0x07, TRUE, /* CO 1.0 */
1657 NULL, /* wbxml_coc10_global - does not exist */
1659 wbxml_coc10_attrStart,
1660 wbxml_coc10_attrValue
1662 { 0x08, TRUE, /* CHANNEL 1.0 (deprecated) */
1663 NULL, /* wbxml_channelc10_global - does not exist */
1664 wbxml_channelc10_tags,
1665 wbxml_channelc10_attrStart,
1666 NULL, /* wbxml_channelc10_attrValue - does not exist */
1668 { 0x09, TRUE, /* WML 1.2 */
1669 wbxml_wmlc12_global,
1671 wbxml_wmlc12_attrStart,
1672 wbxml_wmlc12_attrValue
1674 { 0x0A, TRUE, /* WML 1.3 */
1675 wbxml_wmlc13_global,
1677 wbxml_wmlc13_attrStart,
1678 wbxml_wmlc13_attrValue
1680 { 0x0B, TRUE, /* PROV 1.0 */
1681 NULL, /* wbxml_provc10_global - does not exist */
1683 wbxml_provc10_attrStart,
1684 wbxml_provc10_attrValue
1686 #ifdef remove_directive_and_set_TRUE_if_mapping_available
1687 { 0x0C, FALSE, /* WTA-WML 1.2 */
1688 NULL, NULL, NULL, NULL
1691 { 0x0D, TRUE, /* EMN 1.0 */
1692 NULL, /* wbxml_emnc10_global - does not exist */
1694 wbxml_emnc10_attrStart,
1695 wbxml_emnc10_attrValue
1697 #ifdef remove_directive_and_set_TRUE_if_mapping_available
1698 { 0x0E, FALSE, /* DRMREL 1.0 */
1699 NULL, NULL, NULL, NULL
1702 { 0x0FD1, TRUE, /* SyncML 1.0 */
1703 NULL, /* wbxml_syncmlc10_global - does not exist */
1704 wbxml_syncmlc10_tags,
1705 NULL, /* wbxml_syncmlc10_attrStart - does not exist */
1706 NULL, /* wbxml_syncmlc10_attrValue - does not exist */
1708 { 0x0FD3, TRUE, /* SyncML 1.1 */
1709 NULL, /* wbxml_syncmlc11_global - does not exist */
1710 wbxml_syncmlc11_tags,
1711 NULL, /* wbxml_syncmlc11_attrStart - does not exist */
1712 NULL, /* wbxml_syncmlc11_attrValue - does not exist */
1714 { 0x1108, TRUE, /* Phone.com - WML+ 1.1 */
1715 /* Note: I assumed WML+ 1.1 would be not that different from WML 1.1,
1716 * the real mapping should come from Phone.com (OpenWave)! */
1717 wbxml_wmlc11_global, /* Not 100% true */
1718 wbxml_wmlc11_tags, /* Not 100% true */
1719 wbxml_wmlc11_attrStart, /* Not 100% true */
1720 wbxml_wmlc11_attrValue /* Not 100% true */
1722 { 0x110D, TRUE, /* Phone.com - WML+ 1.3 */
1723 /* Note: I assumed WML+ 1.3 would be not that different from WML 1.3,
1724 * the real mapping should come from Phone.com (OpenWave)! */
1725 wbxml_wmlc13_global, /* Not 100% true */
1726 wbxml_wmlc13_tags, /* Not 100% true */
1727 wbxml_wmlc13_attrStart, /* Not 100% true */
1728 wbxml_wmlc13_attrValue /* Not 100% true */
1731 { 0, FALSE, NULL, NULL, NULL, NULL }
1735 /* WBXML content token mapping depends on the following parameters:
1736 * - Content type (guint32)
1737 * - Token type (global, tags, attrStart, attrValue)
1738 * - Code page for tag and attribute
1740 * This results in the following steps:
1741 * 1. Retrieve content type mapping
1742 * 2. If exists, retrieve token type mapping
1743 * 3. If exists, retrieve required code page
1744 * 4. If exists, retrieve token mapping
1747 /* Return token mapping for a given content mapping entry. */
1749 map_token (const value_valuestring *token_map, guint8 codepage, guint8 token) {
1750 const value_string *vs;
1753 if (token_map) { /* Found map */
1754 if ((vs = val_to_valstr (codepage, token_map))) {
1755 /* Found codepage map */
1756 s = match_strval (token, vs);
1757 if (s) /* Found valid token */
1759 /* No valid token mapping in specified code page of token map */
1760 return "(Requested token not defined for this content type)";
1762 /* There is no token map entry for the requested code page */
1763 return "(Requested token code page not defined for this content type)";
1765 /* The token map does not exist */
1766 return "(Requested token map not defined for this content type)";
1770 /* Returns a pointer to the WBXML token map for the given WBXML public
1771 * identifier value (see WINA for a table with defined identifiers). */
1772 static const wbxml_token_map *wbxml_content_map (guint32 publicid) {
1775 while (map[i].defined) {
1776 if (map[i].publicid == publicid)
1784 /************************** Function prototypes **************************/
1788 dissect_wbxml(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
1791 proto_register_wbxml(void);
1793 /* Parse and display the WBXML string table */
1795 show_wbxml_string_table (proto_tree *tree, tvbuff_t *tvb, guint32 str_tbl,
1796 guint32 str_tbl_len);
1798 /* Parse data while in STAG state */
1800 parse_wbxml_tag (proto_tree *tree, tvbuff_t *tvb, guint32 offset,
1801 guint32 str_tbl, guint8 *level,
1802 guint32 *parsed_length);
1804 /* Parse data while in STAG state;
1805 * interpret tokens as defined by content type */
1807 parse_wbxml_tag_defined (proto_tree *tree, tvbuff_t *tvb, guint32 offset,
1808 guint32 str_tbl, guint8 *level,
1809 guint32 *parsed_length,
1810 const wbxml_token_map *map);
1812 /* Parse data while in ATTR state */
1814 parse_wbxml_attribute_list (proto_tree *tree, tvbuff_t *tvb,
1815 guint32 offset, guint32 str_tbl, guint8 level,
1816 guint32 *parsed_length);
1818 /* Parse data while in ATTR state;
1819 * interpret tokens as defined by content type */
1821 parse_wbxml_attribute_list_defined (proto_tree *tree, tvbuff_t *tvb,
1822 guint32 offset, guint32 str_tbl, guint8 level,
1823 guint32 *parsed_length,
1824 const wbxml_token_map *map);
1827 /****************** WBXML protocol dissection functions ******************/
1830 /* Code to actually dissect the packets */
1832 dissect_wbxml(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1834 /* Set up structures needed to add the protocol subtree and manage it */
1836 proto_tree *wbxml_tree; /* Main WBXML tree */
1837 proto_tree *wbxml_str_tbl_tree; /* String table subtree */
1838 proto_tree *wbxml_content_tree; /* Content subtree */
1843 guint32 charset_len;
1845 guint32 publicid_index = 0;
1846 guint32 publicid_len;
1848 guint32 str_tbl_len;
1849 guint8 level = 0; /* WBXML recursion level */
1850 const wbxml_token_map *content_map = NULL;
1854 * Version 1.0: version publicid strtbl BODY
1855 * Version 1.x: version publicid charset strtbl BODY
1857 * Last valid format: WBXML 1.3
1859 switch ( version = tvb_get_guint8 (tvb, 0) ) {
1860 case 0x00: /* WBXML/1.0 */
1863 case 0x01: /* WBXML/1.1 */
1864 case 0x02: /* WBXML/1.2 */
1865 case 0x03: /* WBXML/1.3 */
1872 if (check_col(pinfo->cinfo, COL_INFO))
1873 col_append_fstr(pinfo->cinfo, COL_INFO, " (WBXML %s:",
1874 match_strval (version, vals_wbxml_versions));
1876 /* In the interest of speed, if "tree" is NULL, don't do any work not
1877 necessary to generate protocol tree items. */
1879 /* create display subtree for the protocol */
1880 ti = proto_tree_add_item (tree, proto_wbxml, tvb, 0, -1, FALSE);
1881 wbxml_tree = proto_item_add_subtree(ti, ett_wbxml);
1884 proto_tree_add_uint (wbxml_tree, hf_wbxml_version,
1885 tvb, 0, 1, version);
1888 publicid = tvb_get_guintvar(tvb, 1, &publicid_len);
1889 if (publicid) { /* Known Public ID */
1890 if (check_col(pinfo->cinfo, COL_INFO))
1891 col_append_fstr(pinfo->cinfo, COL_INFO, " Public ID \"%s\")",
1892 match_strval (publicid, vals_wbxml_public_ids));
1893 proto_tree_add_uint(wbxml_tree, hf_wbxml_public_id_known,
1894 tvb, 1, publicid_len, publicid);
1895 } else { /* Public identifier in string table */
1896 publicid_index = tvb_get_guintvar (tvb, 1+publicid_len, &len);
1897 publicid_len += len;
1899 offset = 1 + publicid_len;
1901 /* Version-specific handling of Charset */
1902 switch ( version ) {
1903 case 0x00: /* WBXML/1.0 */
1907 case 0x01: /* WBXML/1.1 */
1908 case 0x02: /* WBXML/1.2 */
1909 case 0x03: /* WBXML/1.3 */
1911 charset = tvb_get_guintvar (tvb, offset, &charset_len);
1912 offset += charset_len;
1915 default: /* Impossible since return already earlier */
1919 /* String table: read string table length in bytes */
1920 str_tbl_len = tvb_get_guintvar (tvb, offset, &len);
1921 str_tbl = offset + len; /* Start of 1st string in string table */
1923 /* Now we can add public ID, charset (if available),
1924 * and string table */
1925 if ( ! publicid ) { /* Read Public ID from string table */
1926 len = tvb_strsize (tvb, str_tbl+publicid_index);
1927 if (check_col(pinfo->cinfo, COL_INFO))
1928 col_append_fstr(pinfo->cinfo, COL_INFO, " Public ID \"%s\")",
1929 tvb_format_text (tvb,
1930 str_tbl+publicid_index,
1932 proto_tree_add_item (wbxml_tree, hf_wbxml_public_id_literal,
1933 tvb, 1, publicid_len, FALSE);
1935 if ( version ) { /* Charset */
1936 proto_tree_add_uint (wbxml_tree, hf_wbxml_charset,
1937 tvb, 1+publicid_len, charset_len, charset);
1940 ti = proto_tree_add_text(wbxml_tree,
1941 tvb, offset, len + str_tbl_len, "String table: %u bytes",
1944 if (wbxml_tree && str_tbl_len) { /* Display string table as subtree */
1945 wbxml_str_tbl_tree = proto_item_add_subtree (ti,
1947 show_wbxml_string_table (wbxml_str_tbl_tree, tvb,
1948 str_tbl, str_tbl_len);
1951 /* Data starts HERE */
1952 offset += len + str_tbl_len;
1954 /* The WBXML BODY starts here */
1955 ti = proto_tree_add_text (wbxml_tree, tvb, offset, -1,
1956 "Data representation");
1957 wbxml_content_tree = proto_item_add_subtree (ti, ett_wbxml_content);
1959 /* The parse_wbxml_X() functions will process the content correctly,
1960 * irrespective of the WBXML version used. For the WBXML body, this
1961 * means that there is a different processing for the global token
1962 * RESERVED_2 (WBXML 1.0) or OPAQUE (WBXML 1.x with x > 0). */
1963 if (wbxml_tree) { /* Show only if visible */
1965 /* Retrieve the content token mapping if available */
1966 content_map = wbxml_content_map (publicid);
1968 /* Is there a defined token mapping for publicid? */
1969 if (content_map->defined) {
1970 proto_tree_add_text (wbxml_content_tree, tvb,
1972 "Level | State | Codepage "
1973 "| WBXML Token Description "
1975 parse_wbxml_tag_defined (wbxml_content_tree,
1976 tvb, offset, str_tbl, &level,
1981 proto_tree_add_text (wbxml_content_tree, tvb,
1983 "[Rendering of this content type"
1984 " not (yet) supported]");
1986 /* Default: WBXML only, no interpretation of the content */
1987 proto_tree_add_text (wbxml_content_tree, tvb, offset, -1,
1988 "Level | State | Codepage "
1989 "| WBXML Token Description "
1991 parse_wbxml_tag (wbxml_content_tree, tvb, offset,
1992 str_tbl, &level, &len);
2000 /* Parse and display the WBXML string table (in a 3-column table format).
2001 * This function displays:
2002 * - the offset in the string table,
2003 * - the length of the string
2007 show_wbxml_string_table (proto_tree *tree, tvbuff_t *tvb, guint32 str_tbl,
2008 guint32 str_tbl_len)
2010 guint32 off = str_tbl;
2012 guint32 end = str_tbl + str_tbl_len;
2014 proto_tree_add_text (tree, tvb, off, end,
2015 "Start | Length | String");
2017 len = tvb_strsize (tvb, off);
2018 proto_tree_add_text (tree, tvb, off, len,
2021 tvb_format_text (tvb, off, len-1));
2027 /* Indentation code is based on a static const array of space characters.
2028 * At least one single space is returned */
2029 static const char indent_buffer[514] = " "
2038 ; /* Generate XML indentation (length = 1 + 2 * 256 + 1 for '\0') */
2040 static const char * Indent (guint8 level) {
2041 return indent_buffer + (512 - 2 * (level));
2045 /********************
2046 * WBXML tag tokens *
2047 ********************
2049 * Bit Mask : Example
2050 * -------------------
2051 * 00.. .... : <tag />
2058 * atrtribute1="value1"
2059 * atrtribute2="value2"
2063 * atrtribute1="value1"
2064 * atrtribute2="value2"
2070 * - An XML PI is parsed as an attribute list (same syntax).
2071 * - A code page switch only applies to the single token that follows.
2075 /* This function parses the WBXML and maps known token interpretations
2076 * to the WBXML tokens. As a result, the original XML document can be
2077 * recreated. Indentation is generated in order to ease reading.
2079 * Attribute parsing is done in parse_wbxml_attribute_list_defined().
2081 * The wbxml_token_map entry *map contains the actual token mapping.
2083 * NOTE: In order to parse the content, some recursion is required.
2084 * However, for performance reasons, recursion has been avoided
2085 * where possible (tags without content within tags with content).
2086 * This is achieved by means of the parsing_tag_content and tag_save*
2089 * NOTE: See above for known token mappings.
2091 * NOTE: As tags can be opened and closed, a tag representation lookup
2092 * may happen once or twice for a given tag. For efficiency reasons,
2093 * the literal tag value is stored and used throughout the code.
2094 * With the introduction of code page support, this solution is robust
2095 * as the lookup only occurs once, removing the need for storage of
2096 * the used code page.
2099 parse_wbxml_tag_defined (proto_tree *tree, tvbuff_t *tvb, guint32 offset,
2100 guint32 str_tbl, guint8 *level,
2101 guint32 *parsed_length,
2102 const wbxml_token_map *map)
2104 guint32 tvb_len = tvb_reported_length (tvb);
2105 guint32 off = offset;
2111 guint32 tag_len; /* Length of the index (uintvar) from a LITERAL tag */
2112 guint8 tag_save_known = 0; /* Will contain peek & 0x3F (tag identity) */
2113 guint8 tag_new_known = 0; /* Will contain peek & 0x3F (tag identity) */
2114 const char *tag_save_literal; /* Will contain the LITERAL tag identity */
2115 const char *tag_new_literal; /* Will contain the LITERAL tag identity */
2116 guint8 codepage_stag = 0; /* Initial codepage in state = STAG */
2117 guint8 parsing_tag_content = FALSE; /* Are we parsing content from a
2118 tag with content: <x>Content</x>
2120 The initial state is FALSE.
2121 This state will trigger recursion. */
2122 tag_save_literal = NULL; /* Prevents compiler warning */
2125 printf ("WBXML - parse_wbxml_tag_defined (level = %d, offset = %d)\n",
2128 while (off < tvb_len) {
2129 peek = tvb_get_guint8 (tvb, off);
2131 printf("WBXML - STAG: level = %3d, peek = 0x%02X, off = %d, "
2133 *level, peek, off, tvb_len);
2135 if ((peek & 0x3F) < 4) switch (peek) { /* Global tokens in state = STAG
2136 but not the LITERAL tokens */
2137 case 0x00: /* SWITCH_PAGE */
2138 codepage_stag = tvb_get_guint8 (tvb, off+1);
2139 proto_tree_add_text (tree, tvb, off, 2,
2140 " | Tag | T 0->%3d "
2141 "| SWITCH_PAGE (Tag code page) "
2146 case 0x01: /* END: only possible for Tag with Content */
2147 if (tag_save_known) { /* Known TAG */
2148 proto_tree_add_text (tree, tvb, off, 1,
2150 "| END (Known Tag 0x%02X) "
2152 *level, tag_save_known, Indent (*level),
2153 tag_save_literal); /* We already looked it up! */
2154 } else { /* Literal TAG */
2155 proto_tree_add_text (tree, tvb, off, 1,
2157 "| END (Literal Tag) "
2159 *level, Indent (*level),
2164 *parsed_length = off - offset;
2165 /* Reset code page: not needed as return from recursion */
2168 case 0x02: /* ENTITY */
2169 ent = tvb_get_guintvar (tvb, off+1, &len);
2170 proto_tree_add_text (tree, tvb, off, 1+len,
2174 *level, Indent (*level), ent);
2177 case 0x03: /* STR_I */
2178 len = tvb_strsize (tvb, off+1);
2179 proto_tree_add_text (tree, tvb, off, 1+len,
2181 "| STR_I (Inline string) "
2183 *level, Indent(*level),
2184 tvb_format_text (tvb, off+1, len-1));
2187 case 0x40: /* EXT_I_0 */
2188 case 0x41: /* EXT_I_1 */
2189 case 0x42: /* EXT_I_2 */
2190 /* Extension tokens */
2191 len = tvb_strsize (tvb, off+1);
2192 if (codepage_stag) { /* Not default code page */
2193 proto_tree_add_text (tree, tvb, off, 1+len,
2194 " %3d | Tag | T %3d->0 "
2195 "| EXT_I_%1x (Extension Token) "
2197 *level, codepage_stag, peek & 0x0f, Indent (*level),
2198 map_token (map->global, codepage_stag, peek),
2199 tvb_format_text (tvb, off+1, len-1));
2200 /* Reset code page */
2202 } else { /* Code page 0 */
2203 proto_tree_add_text (tree, tvb, off, 1+len,
2205 "| EXT_I_%1x (Extension Token) "
2207 *level, peek & 0x0f, Indent (*level),
2208 map_token (map->global, codepage_stag, peek),
2209 tvb_format_text (tvb, off+1, len-1));
2214 proto_tree_add_text (tree, tvb, off, 1,
2216 "| PI (XML Processing Instruction) "
2218 *level, Indent (*level));
2219 parse_wbxml_attribute_list_defined (tree, tvb, off, str_tbl,
2222 proto_tree_add_text (tree, tvb, off-1, 1,
2226 *level, Indent (*level));
2228 case 0x80: /* EXT_T_0 */
2229 case 0x81: /* EXT_T_1 */
2230 case 0x82: /* EXT_T_2 */
2231 /* Extension tokens */
2232 index = tvb_get_guintvar (tvb, off+1, &len);
2233 str_len = tvb_strsize (tvb, str_tbl+index);
2234 if (codepage_stag) { /* Not default code page */
2235 proto_tree_add_text (tree, tvb, off, 1+len,
2236 " %3d | Tag | T %3d->0 "
2237 "| EXT_T_%1x (Extension Token) "
2239 *level, codepage_stag, peek & 0x0f, Indent (*level),
2240 map_token (map->global, codepage_stag, peek),
2241 tvb_format_text (tvb, str_tbl+index, str_len-1));
2242 /* Reset code page */
2244 } else { /* Code page 0 */
2245 proto_tree_add_text (tree, tvb, off, 1+len,
2247 "| EXT_T_%1x (Extension Token) "
2249 *level, peek & 0x0f, Indent (*level),
2250 map_token (map->global, codepage_stag, peek),
2251 tvb_format_text (tvb, str_tbl+index, str_len-1));
2255 case 0x83: /* STR_T */
2256 index = tvb_get_guintvar (tvb, off+1, &len);
2257 str_len = tvb_strsize (tvb, str_tbl+index);
2258 proto_tree_add_text (tree, tvb, off, 1+len,
2260 "| STR_T (Tableref string) "
2262 *level, Indent (*level),
2263 tvb_format_text (tvb, str_tbl+index, str_len-1));
2266 case 0xC0: /* EXT_0 */
2267 case 0xC1: /* EXT_1 */
2268 case 0xC2: /* EXT_2 */
2269 /* Extension tokens */
2270 if (codepage_stag) { /* Not default code page */
2271 proto_tree_add_text (tree, tvb, off, 1,
2272 " %3d | Tag | T %3d->0 "
2273 "| EXT_%1x (Extension Token) "
2275 *level, codepage_stag, peek & 0x0f, Indent (*level),
2276 map_token (map->global, codepage_stag, peek));
2277 /* Reset code page */
2279 } else { /* Code page 0 */
2280 proto_tree_add_text (tree, tvb, off, 1,
2282 "| EXT_%1x (Extension Token) "
2284 *level, peek & 0x0f, Indent (*level),
2285 map_token (map->global, codepage_stag, peek));
2289 case 0xC3: /* OPAQUE - WBXML 1.1 and newer */
2290 if (tvb_get_guint8 (tvb, 0)) { /* WBXML 1.x (x > 0) */
2291 index = tvb_get_guintvar (tvb, off+1, &len);
2292 proto_tree_add_text (tree, tvb, off, 1 + len + index,
2294 "| OPAQUE (Opaque data) "
2295 "| %s(%d bytes of opaque data)",
2296 *level, Indent (*level), index);
2298 } else { /* WBXML 1.0 - RESERVED_2 token (invalid) */
2299 proto_tree_add_text (tree, tvb, off, 1,
2301 "| RESERVED_2 (Invalid Token!) "
2302 "| WBXML 1.0 parsing stops here.",
2304 /* Stop processing as it is impossible to parse now */
2306 *parsed_length = off - offset;
2311 /* No default clause, as all cases have been treated */
2312 } else { /* LITERAL or Known TAG */
2313 /* We must store the initial tag, and also retrieve the new tag.
2314 * For efficiency reasons, we store the literal tag representation
2315 * for known tags too, so we can easily close the tag without the
2316 * need of a new lookup and avoiding storage of token codepage.
2318 * There are 4 possibilities:
2320 * 1. Known tag followed by a known tag
2321 * 2. Known tag followed by a LITERAL tag
2322 * 3. LITERAL tag followed by Known tag
2323 * 4. LITERAL tag followed by LITERAL tag
2326 /* Store the new tag */
2328 if ((peek & 0x3F) == 4) { /* LITERAL */
2329 index = tvb_get_guintvar (tvb, off+1, &tag_len);
2330 str_len = tvb_strsize (tvb, str_tbl+index);
2331 tag_new_literal = tvb_get_ptr (tvb, str_tbl+index, str_len);
2332 tag_new_known = 0; /* invalidate known tag_new */
2333 } else { /* Known tag */
2334 tag_new_known = peek & 0x3F;
2335 tag_new_literal = map_token (map->tags, codepage_stag,
2337 /* Stored looked up tag name string */
2340 /* Parsing of TAG starts HERE */
2341 if (peek & 0x40) { /* Content present */
2343 * [!] An explicit END token is expected in these cases!
2344 * ==> Recursion possible if we encounter a tag with content;
2345 * recursion will return at the explicit END token.
2347 if (parsing_tag_content) { /* Recurse */
2349 printf ("WBXML: Tag in Tag - RECURSE! (off = %d)\n",off);
2351 /* Do not process the attribute list:
2352 * recursion will take care of it */
2354 parse_wbxml_tag_defined (tree, tvb, off, str_tbl, level,
2357 } else { /* Now we will have content to parse */
2358 /* Save the start tag so we can properly close it later. */
2359 if ((peek & 0x3F) == 4) { /* Literal tag */
2360 tag_save_literal = tag_new_literal;
2362 } else { /* Known tag */
2363 tag_save_known = tag_new_known;
2364 tag_save_literal = tag_new_literal;
2365 /* The last statement avoids needless lookups */
2367 /* Process the attribute list if present */
2368 if (peek & 0x80) { /* Content and Attribute list present */
2369 if (tag_new_known) { /* Known tag */
2370 if (codepage_stag) { /* Not default code page */
2371 proto_tree_add_text (tree, tvb, off, 1,
2372 " %3d | Tag | T %3d->0 "
2373 "| Known Tag 0x%02X (AC) "
2375 *level, codepage_stag, tag_new_known,
2376 Indent (*level), tag_new_literal);
2377 /* Tag string already looked up earlier! */
2378 /* Reset code page */
2380 } else { /* Code page 0 */
2381 proto_tree_add_text (tree, tvb, off, 1,
2383 "| Known Tag 0x%02X (AC) "
2385 *level, tag_new_known,
2386 Indent (*level), tag_new_literal);
2387 /* Tag string already looked up earlier! */
2390 } else { /* LITERAL tag */
2391 proto_tree_add_text (tree, tvb, off, 1,
2393 "| LITERAL_AC (Literal tag) (AC) "
2395 *level, Indent (*level), tag_new_literal);
2398 parse_wbxml_attribute_list_defined (tree, tvb,
2399 off, str_tbl, *level, &len, map);
2401 proto_tree_add_text (tree, tvb, off-1, 1,
2403 "| END (attribute list) "
2405 *level, Indent (*level));
2406 } else { /* Content, no Attribute list */
2407 if (tag_new_known) { /* Known tag */
2408 if (codepage_stag) { /* Not default code page */
2409 proto_tree_add_text (tree, tvb, off, 1,
2410 " %3d | Tag | T %3d->0 "
2411 "| Known Tag 0x%02X (.C) "
2413 *level, codepage_stag, tag_new_known,
2416 /* Tag string already looked up earlier! */
2417 /* Reset code page */
2419 } else { /* Code page 0 */
2420 proto_tree_add_text (tree, tvb, off, 1,
2422 "| Known Tag 0x%02X (.C) "
2424 *level, tag_new_known,
2427 /* Tag string already looked up earlier! */
2430 } else { /* LITERAL tag */
2431 proto_tree_add_text (tree, tvb, off, 1,
2433 "| LITERAL_C (Literal Tag) (.C) "
2435 *level, Indent (*level), tag_new_literal);
2439 /* The data that follows in the parsing process
2440 * represents content for the opening tag
2441 * we've just processed in the lines above.
2442 * Next time we encounter a tag with content: recurse
2444 parsing_tag_content = TRUE;
2446 printf ("WBXML: Tag in Tag - No recursion this time! "
2447 "(off = %d)\n", off);
2450 } else { /* No Content */
2452 printf ("WBXML: <Tag/> in Tag - No recursion! "
2453 "(off = %d)\n", off);
2456 if (peek & 0x80) { /* No Content, Attribute list present */
2457 if (tag_new_known) { /* Known tag */
2458 if (codepage_stag) { /* Not default code page */
2459 proto_tree_add_text (tree, tvb, off, 1,
2460 " %3d | Tag | T %3d->0 "
2461 "| Known Tag 0x%02X (A.) "
2463 *level, codepage_stag, tag_new_known,
2464 Indent (*level), tag_new_literal);
2465 /* Tag string already looked up earlier! */
2466 /* Reset code page */
2468 } else { /* Code page 0 */
2469 proto_tree_add_text (tree, tvb, off, 1,
2471 "| Known Tag 0x%02X (A.) "
2473 *level, tag_new_known,
2474 Indent (*level), tag_new_literal);
2475 /* Tag string already looked up earlier! */
2478 parse_wbxml_attribute_list_defined (tree, tvb,
2479 off, str_tbl, *level, &len, map);
2481 proto_tree_add_text (tree, tvb, off-1, 1,
2483 "| END (Known Tag) "
2485 *level, Indent (*level));
2486 } else { /* LITERAL tag */
2487 proto_tree_add_text (tree, tvb, off, 1,
2489 "| LITERAL_A (Literal Tag) (A.) "
2491 *level, Indent (*level), tag_new_literal);
2493 parse_wbxml_attribute_list_defined (tree, tvb,
2494 off, str_tbl, *level, &len, map);
2496 proto_tree_add_text (tree, tvb, off-1, 1,
2498 "| END (Literal Tag) "
2500 *level, Indent (*level));
2502 } else { /* No Content, No Attribute list */
2503 if (tag_new_known) { /* Known tag */
2504 if (codepage_stag) { /* Not default code page */
2505 proto_tree_add_text (tree, tvb, off, 1,
2506 " %3d | Tag | T %3d->0 "
2507 "| Known Tag 0x%02x (..) "
2509 *level, codepage_stag, tag_new_known,
2510 Indent (*level), tag_new_literal);
2511 /* Tag string already looked up earlier! */
2512 /* Reset code page */
2514 } else { /* Code page 0 */
2515 proto_tree_add_text (tree, tvb, off, 1,
2517 "| Known Tag 0x%02x (..) "
2519 *level, tag_new_known,
2520 Indent (*level), tag_new_literal);
2521 /* Tag string already looked up earlier! */
2524 } else { /* LITERAL tag */
2525 proto_tree_add_text (tree, tvb, off, 1,
2527 "| LITERAL (Literal Tag) (..) "
2529 *level, Indent (*level), tag_new_literal);
2534 /* TODO: Do I have to reset code page here? */
2536 } /* if (tag & 0x3F) >= 5 */
2541 /* This function performs the WBXML decoding as in parse_wbxml_tag_defined()
2542 * but this time no WBXML mapping is performed.
2544 * Attribute parsing is done in parse_wbxml_attribute_list().
2547 parse_wbxml_tag (proto_tree *tree, tvbuff_t *tvb, guint32 offset,
2548 guint32 str_tbl, guint8 *level,
2549 guint32 *parsed_length)
2551 guint32 tvb_len = tvb_reported_length (tvb);
2552 guint32 off = offset;
2558 guint32 tag_len; /* Length of the index (uintvar) from a LITERAL tag */
2559 guint8 tag_save_known = 0; /* Will contain peek & 0x3F (tag identity) */
2560 guint8 tag_new_known = 0; /* Will contain peek & 0x3F (tag identity) */
2561 const char *tag_save_literal; /* Will contain the LITERAL tag identity */
2562 const char *tag_new_literal; /* Will contain the LITERAL tag identity */
2563 char tag_save_buf[10]; /* Will contain "tag_0x%02X" */
2564 char tag_new_buf[10]; /* Will contain "tag_0x%02X" */
2565 guint8 codepage_stag = 0; /* Initial codepage in state = STAG */
2566 guint8 parsing_tag_content = FALSE; /* Are we parsing content from a
2567 tag with content: <x>Content</x>
2569 The initial state is FALSE.
2570 This state will trigger recursion. */
2571 tag_save_literal = NULL; /* Prevents compiler warning */
2574 printf ("WBXML - parse_wbxml_tag (level = %d, offset = %d)\n",
2577 while (off < tvb_len) {
2578 peek = tvb_get_guint8 (tvb, off);
2580 printf("WBXML - STAG: level = %3d, peek = 0x%02X, off = %d, "
2582 *level, peek, off, tvb_len);
2584 if ((peek & 0x3F) < 4) switch (peek) { /* Global tokens in state = STAG
2585 but not the LITERAL tokens */
2586 case 0x00: /* SWITCH_PAGE */
2587 codepage_stag = tvb_get_guint8 (tvb, off+1);
2588 proto_tree_add_text (tree, tvb, off, 2,
2589 " | Tag | T 0->%3d "
2590 "| SWITCH_PAGE (Tag code page) "
2595 case 0x01: /* END: only possible for Tag with Content */
2596 if (tag_save_known) { /* Known TAG */
2597 proto_tree_add_text (tree, tvb, off, 1,
2599 "| END (Known Tag 0x%02X) "
2601 *level, tag_save_known, Indent (*level),
2602 tag_save_literal); /* We already looked it up! */
2603 } else { /* Literal TAG */
2604 proto_tree_add_text (tree, tvb, off, 1,
2606 "| END (Literal Tag) "
2608 *level, Indent (*level),
2613 *parsed_length = off - offset;
2614 /* Reset code page: not needed as return from recursion */
2617 case 0x02: /* ENTITY */
2618 ent = tvb_get_guintvar (tvb, off+1, &len);
2619 proto_tree_add_text (tree, tvb, off, 1+len,
2623 *level, Indent (*level), ent);
2626 case 0x03: /* STR_I */
2627 len = tvb_strsize (tvb, off+1);
2628 proto_tree_add_text (tree, tvb, off, 1+len,
2630 "| STR_I (Inline string) "
2632 *level, Indent(*level),
2633 tvb_format_text (tvb, off+1, len-1));
2636 case 0x40: /* EXT_I_0 */
2637 case 0x41: /* EXT_I_1 */
2638 case 0x42: /* EXT_I_2 */
2639 /* Extension tokens */
2640 len = tvb_strsize (tvb, off+1);
2641 if (codepage_stag) { /* Not default code page */
2642 proto_tree_add_text (tree, tvb, off, 1+len,
2643 " %3d | Tag | T %3d->0 "
2644 "| EXT_I_%1x (Extension Token) "
2645 "| %s(Inline string extension: \'%s\')",
2646 *level, codepage_stag, peek & 0x0f, Indent (*level),
2647 tvb_format_text (tvb, off+1, len-1));
2648 /* Reset code page */
2650 } else { /* Code page 0 */
2651 proto_tree_add_text (tree, tvb, off, 1+len,
2653 "| EXT_I_%1x (Extension Token) "
2654 "| %s(Inline string extension: \'%s\')",
2655 *level, peek & 0x0f, Indent (*level),
2656 tvb_format_text (tvb, off+1, len-1));
2661 proto_tree_add_text (tree, tvb, off, 1,
2663 "| PI (XML Processing Instruction) "
2665 *level, Indent (*level));
2666 parse_wbxml_attribute_list (tree, tvb, off, str_tbl,
2669 proto_tree_add_text (tree, tvb, off-1, 1,
2673 *level, Indent (*level));
2675 case 0x80: /* EXT_T_0 */
2676 case 0x81: /* EXT_T_1 */
2677 case 0x82: /* EXT_T_2 */
2678 /* Extension tokens */
2679 index = tvb_get_guintvar (tvb, off+1, &len);
2680 str_len = tvb_strsize (tvb, str_tbl+index);
2681 if (codepage_stag) { /* Not default code page */
2682 proto_tree_add_text (tree, tvb, off, 1+len,
2683 " %3d | Tag | T %3d->0 "
2684 "| EXT_T_%1x (Extension Token) "
2685 "| %s(Tableref string extension: \'%s\')",
2686 *level, codepage_stag, peek & 0x0f, Indent (*level),
2687 tvb_format_text (tvb, str_tbl+index, str_len-1));
2688 /* Reset code page */
2690 } else { /* Code page 0 */
2691 proto_tree_add_text (tree, tvb, off, 1+len,
2693 "| EXT_T_%1x (Extension Token) "
2694 "| %s(Tableref string extension: \'%s\')",
2695 *level, peek & 0x0f, Indent (*level),
2696 tvb_format_text (tvb, str_tbl+index, str_len-1));
2700 case 0x83: /* STR_T */
2701 index = tvb_get_guintvar (tvb, off+1, &len);
2702 str_len = tvb_strsize (tvb, str_tbl+index);
2703 proto_tree_add_text (tree, tvb, off, 1+len,
2705 "| STR_T (Tableref string) "
2707 *level, Indent (*level),
2708 tvb_format_text (tvb, str_tbl+index, str_len-1));
2711 case 0xC0: /* EXT_0 */
2712 case 0xC1: /* EXT_1 */
2713 case 0xC2: /* EXT_2 */
2714 /* Extension tokens */
2715 if (codepage_stag) { /* Not default code page */
2716 proto_tree_add_text (tree, tvb, off, 1,
2717 " %3d | Tag | T %3d->0 "
2718 "| EXT_%1x (Extension Token) "
2719 "| %s(Single-byte extension)",
2720 *level, codepage_stag, peek & 0x0f,
2722 /* Reset code page */
2724 } else { /* Code page 0 */
2725 proto_tree_add_text (tree, tvb, off, 1,
2727 "| EXT_%1x (Extension Token) "
2728 "| %s(Single-byte extension)",
2729 *level, peek & 0x0f, Indent (*level));
2733 case 0xC3: /* OPAQUE - WBXML 1.1 and newer */
2734 if (tvb_get_guint8 (tvb, 0)) { /* WBXML 1.x (x > 0) */
2735 index = tvb_get_guintvar (tvb, off+1, &len);
2736 proto_tree_add_text (tree, tvb, off, 1 + len + index,
2738 "| OPAQUE (Opaque data) "
2739 "| %s(%d bytes of opaque data)",
2740 *level, Indent (*level), index);
2742 } else { /* WBXML 1.0 - RESERVED_2 token (invalid) */
2743 proto_tree_add_text (tree, tvb, off, 1,
2745 "| RESERVED_2 (Invalid Token!) "
2746 "| WBXML 1.0 parsing stops here.",
2748 /* Stop processing as it is impossible to parse now */
2750 *parsed_length = off - offset;
2755 /* No default clause, as all cases have been treated */
2756 } else { /* LITERAL or Known TAG */
2757 /* We must store the initial tag, and also retrieve the new tag.
2758 * For efficiency reasons, we store the literal tag representation
2759 * for known tags too, so we can easily close the tag without the
2760 * need of a new lookup and avoiding storage of token codepage.
2762 * There are 4 possibilities:
2764 * 1. Known tag followed by a known tag
2765 * 2. Known tag followed by a LITERAL tag
2766 * 3. LITERAL tag followed by Known tag
2767 * 4. LITERAL tag followed by LITERAL tag
2770 /* Store the new tag */
2772 if ((peek & 0x3F) == 4) { /* LITERAL */
2773 index = tvb_get_guintvar (tvb, off+1, &tag_len);
2774 str_len = tvb_strsize (tvb, str_tbl+index);
2775 tag_new_literal = tvb_get_ptr (tvb, str_tbl+index, str_len);
2776 tag_new_known = 0; /* invalidate known tag_new */
2777 } else { /* Known tag */
2778 tag_new_known = peek & 0x3F;
2779 sprintf (tag_new_buf, "Tag_0x%02X",
2781 tag_new_literal = tag_new_buf;
2782 /* Stored looked up tag name string */
2785 /* Parsing of TAG starts HERE */
2786 if (peek & 0x40) { /* Content present */
2788 * [!] An explicit END token is expected in these cases!
2789 * ==> Recursion possible if we encounter a tag with content;
2790 * recursion will return at the explicit END token.
2792 if (parsing_tag_content) { /* Recurse */
2794 printf ("WBXML: Tag in Tag - RECURSE! (off = %d)\n",off);
2796 /* Do not process the attribute list:
2797 * recursion will take care of it */
2799 parse_wbxml_tag (tree, tvb, off, str_tbl, level,
2802 } else { /* Now we will have content to parse */
2803 /* Save the start tag so we can properly close it later. */
2804 if ((peek & 0x3F) == 4) { /* Literal tag */
2805 tag_save_literal = tag_new_literal;
2807 } else { /* Known tag */
2808 tag_save_known = tag_new_known;
2809 sprintf (tag_save_buf, "Tag_0x%02X",
2811 tag_save_literal = tag_save_buf;
2812 /* The last statement avoids needless lookups */
2814 /* Process the attribute list if present */
2815 if (peek & 0x80) { /* Content and Attribute list present */
2816 if (tag_new_known) { /* Known tag */
2817 if (codepage_stag) { /* Not default code page */
2818 proto_tree_add_text (tree, tvb, off, 1,
2819 " %3d | Tag | T %3d->0 "
2820 "| Known Tag 0x%02X (AC) "
2822 *level, codepage_stag, tag_new_known,
2823 Indent (*level), tag_new_literal);
2824 /* Tag string already looked up earlier! */
2825 /* Reset code page */
2827 } else { /* Code page 0 */
2828 proto_tree_add_text (tree, tvb, off, 1,
2830 "| Known Tag 0x%02X (AC) "
2832 *level, tag_new_known,
2833 Indent (*level), tag_new_literal);
2834 /* Tag string already looked up earlier! */
2837 } else { /* LITERAL tag */
2838 proto_tree_add_text (tree, tvb, off, 1,
2840 "| LITERAL_AC (Literal tag) (AC) "
2842 *level, Indent (*level), tag_new_literal);
2845 parse_wbxml_attribute_list (tree, tvb,
2846 off, str_tbl, *level, &len);
2848 proto_tree_add_text (tree, tvb, off-1, 1,
2850 "| END (attribute list) "
2852 *level, Indent (*level));
2853 } else { /* Content, no Attribute list */
2854 if (tag_new_known) { /* Known tag */
2855 if (codepage_stag) { /* Not default code page */
2856 proto_tree_add_text (tree, tvb, off, 1,
2857 " %3d | Tag | T %3d->0 "
2858 "| Known Tag 0x%02X (.C) "
2860 *level, codepage_stag, tag_new_known,
2863 /* Tag string already looked up earlier! */
2864 /* Reset code page */
2866 } else { /* Code page 0 */
2867 proto_tree_add_text (tree, tvb, off, 1,
2869 "| Known Tag 0x%02X (.C) "
2871 *level, tag_new_known,
2874 /* Tag string already looked up earlier! */
2877 } else { /* LITERAL tag */
2878 proto_tree_add_text (tree, tvb, off, 1,
2880 "| LITERAL_C (Literal Tag) (.C) "
2882 *level, Indent (*level), tag_new_literal);
2886 /* The data that follows in the parsing process
2887 * represents content for the opening tag
2888 * we've just processed in the lines above.
2889 * Next time we encounter a tag with content: recurse
2891 parsing_tag_content = TRUE;
2893 printf ("WBXML: Tag in Tag - No recursion this time! "
2894 "(off = %d)\n", off);
2897 } else { /* No Content */
2899 printf ("WBXML: <Tag/> in Tag - No recursion! "
2900 "(off = %d)\n", off);
2903 if (peek & 0x80) { /* No Content, Attribute list present */
2904 if (tag_new_known) { /* Known tag */
2905 if (codepage_stag) { /* Not default code page */
2906 proto_tree_add_text (tree, tvb, off, 1,
2907 " %3d | Tag | T %3d->0 "
2908 "| Known Tag 0x%02X (A.) "
2910 *level, codepage_stag, tag_new_known,
2911 Indent (*level), tag_new_literal);
2912 /* Tag string already looked up earlier! */
2913 /* Reset code page */
2915 } else { /* Code page 0 */
2916 proto_tree_add_text (tree, tvb, off, 1,
2918 "| Known Tag 0x%02X (A.) "
2920 *level, tag_new_known,
2921 Indent (*level), tag_new_literal);
2922 /* Tag string already looked up earlier! */
2925 parse_wbxml_attribute_list (tree, tvb,
2926 off, str_tbl, *level, &len);
2928 proto_tree_add_text (tree, tvb, off-1, 1,
2930 "| END (Known Tag) "
2932 *level, Indent (*level));
2933 } else { /* LITERAL tag */
2934 proto_tree_add_text (tree, tvb, off, 1,
2936 "| LITERAL_A (Literal Tag) (A.) "
2938 *level, Indent (*level), tag_new_literal);
2940 parse_wbxml_attribute_list (tree, tvb,
2941 off, str_tbl, *level, &len);
2943 proto_tree_add_text (tree, tvb, off-1, 1,
2945 "| END (Literal Tag) "
2947 *level, Indent (*level));
2949 } else { /* No Content, No Attribute list */
2950 if (tag_new_known) { /* Known tag */
2951 if (codepage_stag) { /* Not default code page */
2952 proto_tree_add_text (tree, tvb, off, 1,
2953 " %3d | Tag | T %3d->0 "
2954 "| Known Tag 0x%02x (..) "
2956 *level, codepage_stag, tag_new_known,
2957 Indent (*level), tag_new_literal);
2958 /* Tag string already looked up earlier! */
2959 /* Reset code page */
2961 } else { /* Code page 0 */
2962 proto_tree_add_text (tree, tvb, off, 1,
2964 "| Known Tag 0x%02x (..) "
2966 *level, tag_new_known,
2967 Indent (*level), tag_new_literal);
2968 /* Tag string already looked up earlier! */
2971 } else { /* LITERAL tag */
2972 proto_tree_add_text (tree, tvb, off, 1,
2974 "| LITERAL (Literal Tag) (..) "
2976 *level, Indent (*level), tag_new_literal);
2981 /* TODO: Do I have to reset code page here? */
2983 } /* if (tag & 0x3F) >= 5 */
2988 /**************************
2989 * WBXML Attribute tokens *
2990 **************************
2991 * Bit Mask : Example
2992 * -------------------
2993 * 0... .... : attr= (attribute name)
2994 * href='http://' (attribute name with start of attribute value)
2995 * 1... .... : 'www.' (attribute value, or part of it)
3000 /* This function parses the WBXML and maps known token interpretations
3001 * to the WBXML tokens. As a result, the original XML document can be
3002 * recreated. Indentation is generated in order to ease reading.
3004 * This function performs attribute list parsing.
3006 * The wbxml_token_map entry *map contains the actual token mapping.
3008 * NOTE: See above for known token mappings.
3011 parse_wbxml_attribute_list_defined (proto_tree *tree, tvbuff_t *tvb,
3012 guint32 offset, guint32 str_tbl, guint8 level,
3013 guint32 *parsed_length,
3014 const wbxml_token_map *map)
3016 guint32 tvb_len = tvb_reported_length (tvb);
3017 guint32 off = offset;
3023 guint8 codepage_attr = 0; /* Initial codepage in state = ATTR */
3026 printf ("WBXML - parse_wbxml_attr_defined (level = %d, offset = %d)\n",
3029 /* Parse attributes */
3030 while (off < tvb_len) {
3031 peek = tvb_get_guint8 (tvb, off);
3033 printf("WBXML - ATTR: level = %3d, peek = 0x%02X, off = %d, "
3035 level, peek, off, tvb_len);
3037 if ((peek & 0x3F) < 5) switch (peek) { /* Global tokens
3039 case 0x00: /* SWITCH_PAGE */
3040 codepage_attr = tvb_get_guint8 (tvb, off+1);
3041 proto_tree_add_text (tree, tvb, off, 2,
3042 " | Attr | A 0->%3d "
3043 "| SWITCH_PAGE (Attr code page) |",
3047 case 0x01: /* END */
3049 * The Attribute END token means either ">" or "/>"
3050 * and as a consequence both must be treated separately.
3051 * This is done in the TAG state parser.
3054 *parsed_length = off - offset;
3056 case 0x02: /* ENTITY */
3057 ent = tvb_get_guintvar (tvb, off+1, &len);
3058 proto_tree_add_text (tree, tvb, off, 1+len,
3062 level, Indent (level), ent);
3065 case 0x03: /* STR_I */
3066 len = tvb_strsize (tvb, off+1);
3067 proto_tree_add_text (tree, tvb, off, 1+len,
3069 "| STR_I (Inline string) "
3071 level, Indent (level),
3072 tvb_format_text (tvb, off+1, len-1));
3075 case 0x04: /* LITERAL */
3076 index = tvb_get_guintvar (tvb, off+1, &len);
3077 str_len = tvb_strsize (tvb, str_tbl+index);
3078 proto_tree_add_text (tree, tvb, off, 1+len,
3080 "| LITERAL (Literal Attribute) "
3082 level, Indent (level),
3083 tvb_format_text (tvb, str_tbl+index, str_len-1));
3086 case 0x40: /* EXT_I_0 */
3087 case 0x41: /* EXT_I_1 */
3088 case 0x42: /* EXT_I_2 */
3089 /* Extension tokens */
3090 len = tvb_strsize (tvb, off+1);
3091 if (codepage_attr) { /* Not default code page */
3092 proto_tree_add_text (tree, tvb, off, 1+len,
3093 " %3d | Attr | A %3d->0 "
3094 "| EXT_I_%1x (Extension Token) "
3096 level, codepage_attr, peek & 0x0f, Indent (level),
3097 map_token (map->global, codepage_attr, peek),
3098 tvb_format_text (tvb, off+1, len-1));
3099 /* Reset code page */
3101 } else { /* Code page 0 */
3102 proto_tree_add_text (tree, tvb, off, 1+len,
3104 "| EXT_I_%1x (Extension Token) "
3106 level, peek & 0x0f, Indent (level),
3107 map_token (map->global, codepage_attr, peek),
3108 tvb_format_text (tvb, off+1, len-1));
3112 /* 0x43 impossible in ATTR state */
3113 /* 0x44 impossible in ATTR state */
3114 case 0x80: /* EXT_T_0 */
3115 case 0x81: /* EXT_T_1 */
3116 case 0x82: /* EXT_T_2 */
3117 /* Extension tokens */
3118 index = tvb_get_guintvar (tvb, off+1, &len);
3119 str_len = tvb_strsize (tvb, str_tbl+index);
3120 if (codepage_attr) { /* Not default code page */
3121 proto_tree_add_text (tree, tvb, off, 1+len,
3122 " %3d | Attr | A %3d->0 "
3123 "| EXT_T_%1x (Extension Token) "
3125 level, codepage_attr, peek & 0x0f, Indent (level),
3126 map_token (map->global, codepage_attr, peek),
3127 tvb_format_text (tvb, str_tbl+index, str_len-1));
3128 /* Reset code page */
3130 } else { /* Code page 0 */
3131 proto_tree_add_text (tree, tvb, off, 1+len,
3133 "| EXT_T_%1x (Extension Token) "
3135 level, peek & 0x0f, Indent (level),
3136 map_token (map->global, codepage_attr, peek),
3137 tvb_format_text (tvb, str_tbl+index, str_len-1));
3141 case 0x83: /* STR_T */
3142 index = tvb_get_guintvar (tvb, off+1, &len);
3143 str_len = tvb_strsize (tvb, str_tbl+index);
3144 proto_tree_add_text (tree, tvb, off, 1+len,
3146 "| STR_T (Tableref string) "
3148 level, Indent (level),
3149 tvb_format_text (tvb, str_tbl+index, str_len-1));
3152 /* 0x84 impossible in ATTR state */
3153 case 0xC0: /* EXT_0 */
3154 case 0xC1: /* EXT_1 */
3155 case 0xC2: /* EXT_2 */
3156 /* Extension tokens */
3157 if (codepage_attr) { /* Not default code page */
3158 proto_tree_add_text (tree, tvb, off, 1,
3159 " %3d | Attr | A %3d->0 "
3160 "| EXT_%1x (Extension Token) "
3162 level, codepage_attr, peek & 0x0f, Indent (level),
3163 map_token (map->global, codepage_attr, peek));
3164 /* Reset code page */
3166 } else { /* Code page 0 */
3167 proto_tree_add_text (tree, tvb, off, 1,
3169 "| EXT_%1x (Extension Token) "
3171 level, peek & 0x0f, Indent (level),
3172 map_token (map->global, codepage_attr, peek));
3176 case 0xC3: /* OPAQUE - WBXML 1.1 and newer */
3177 if (tvb_get_guint8 (tvb, 0)) { /* WBXML 1.x (x > 0) */
3178 index = tvb_get_guintvar (tvb, off+1, &len);
3179 proto_tree_add_text (tree, tvb, off, 1 + len + index,
3181 "| OPAQUE (Opaque data) "
3182 "| %s(%d bytes of opaque data)",
3183 level, Indent (level), index);
3185 } else { /* WBXML 1.0 - RESERVED_2 token (invalid) */
3186 proto_tree_add_text (tree, tvb, off, 1,
3188 "| RESERVED_2 (Invalid Token!) "
3189 "| WBXML 1.0 parsing stops here.",
3191 /* Stop processing as it is impossible to parse now */
3193 *parsed_length = off - offset;
3197 /* 0xC4 impossible in ATTR state */
3199 proto_tree_add_text (tree, tvb, off, 1,
3201 "| %-10s (Invalid Token!) "
3202 "| WBXML parsing stops here.",
3203 level, match_strval (peek, vals_wbxml1x_global_tokens));
3204 /* Move to end of buffer */
3207 } else { /* Known atribute token */
3208 if (peek & 0x80) { /* attrValue */
3209 if (codepage_attr) { /* Not default code page */
3210 proto_tree_add_text (tree, tvb, off, 1,
3211 " %3d | Attr | A %3d->0 "
3212 "| Known attrValue 0x%02X "
3214 level, codepage_attr, peek & 0x7f, Indent (level),
3215 map_token (map->attrValue, codepage_attr, peek));
3216 /* Reset code page */
3218 } else { /* Code page 0 */
3219 proto_tree_add_text (tree, tvb, off, 1,
3221 "| Known attrValue 0x%02X "
3223 level, peek & 0x7f, Indent (level),
3224 map_token (map->attrValue, codepage_attr, peek));
3227 } else { /* attrStart */
3228 if (codepage_attr) { /* Not default code page */
3229 proto_tree_add_text (tree, tvb, off, 1,
3230 " %3d | Attr | A %3d->0 "
3231 "| Known attrStart 0x%02X "
3233 level, codepage_attr, peek & 0x7f, Indent (level),
3234 map_token (map->attrStart, codepage_attr, peek));
3235 /* Reset code page */
3237 } else { /* Code page 0 */
3238 proto_tree_add_text (tree, tvb, off, 1,
3240 "| Known attrStart 0x%02X "
3242 level, peek & 0x7f, Indent (level),
3243 map_token (map->attrStart, codepage_attr, peek));
3252 /* This function performs the WBXML attribute decoding as in
3253 * parse_wbxml_attribute_list_defined() but this time no WBXML mapping
3256 * This function performs attribute list parsing.
3258 * NOTE: Code page switches not yet processed in the code!
3261 parse_wbxml_attribute_list (proto_tree *tree, tvbuff_t *tvb,
3262 guint32 offset, guint32 str_tbl, guint8 level,
3263 guint32 *parsed_length)
3265 guint32 tvb_len = tvb_reported_length (tvb);
3266 guint32 off = offset;
3272 guint8 codepage_attr = 0; /* Initial codepage in state = ATTR */
3275 printf ("WBXML - parse_wbxml_attr (level = %d, offset = %d)\n",
3278 /* Parse attributes */
3279 while (off < tvb_len) {
3280 peek = tvb_get_guint8 (tvb, off);
3282 printf("WBXML - ATTR: level = %3d, peek = 0x%02X, off = %d, "
3284 level, peek, off, tvb_len);
3286 if ((peek & 0x3F) < 5) switch (peek) { /* Global tokens
3288 case 0x00: /* SWITCH_PAGE */
3289 codepage_attr = tvb_get_guint8 (tvb, off+1);
3290 proto_tree_add_text (tree, tvb, off, 2,
3291 " | Attr | A 0->%3d "
3292 "| SWITCH_PAGE (Attr code page) |",
3296 case 0x01: /* END */
3298 * The Attribute END token means either ">" or "/>"
3299 * and as a consequence both must be treated separately.
3300 * This is done in the TAG state parser.
3303 *parsed_length = off - offset;
3305 case 0x02: /* ENTITY */
3306 ent = tvb_get_guintvar (tvb, off+1, &len);
3307 proto_tree_add_text (tree, tvb, off, 1+len,
3311 level, Indent (level), ent);
3314 case 0x03: /* STR_I */
3315 len = tvb_strsize (tvb, off+1);
3316 proto_tree_add_text (tree, tvb, off, 1+len,
3318 "| STR_I (Inline string) "
3320 level, Indent (level),
3321 tvb_format_text (tvb, off+1, len-1));
3324 case 0x04: /* LITERAL */
3325 index = tvb_get_guintvar (tvb, off+1, &len);
3326 str_len = tvb_strsize (tvb, str_tbl+index);
3327 proto_tree_add_text (tree, tvb, off, 1+len,
3329 "| LITERAL (Literal Attribute) "
3331 level, Indent (level),
3332 tvb_format_text (tvb, str_tbl+index, str_len-1));
3335 case 0x40: /* EXT_I_0 */
3336 case 0x41: /* EXT_I_1 */
3337 case 0x42: /* EXT_I_2 */
3338 /* Extension tokens */
3339 len = tvb_strsize (tvb, off+1);
3340 if (codepage_attr) { /* Not default code page */
3341 proto_tree_add_text (tree, tvb, off, 1+len,
3342 " %3d | Attr | A %3d->0 "
3343 "| EXT_I_%1x (Extension Token) "
3344 "| %s(Inline string extension: \'%s\')",
3345 level, codepage_attr, peek & 0x0f, Indent (level),
3346 tvb_format_text (tvb, off+1, len-1));
3347 /* Reset code page */
3349 } else { /* Code page 0 */
3350 proto_tree_add_text (tree, tvb, off, 1+len,
3352 "| EXT_I_%1x (Extension Token) "
3353 "| %s(Inline string extension: \'%s\')",
3354 level, peek & 0x0f, Indent (level),
3355 tvb_format_text (tvb, off+1, len-1));
3359 /* 0x43 impossible in ATTR state */
3360 /* 0x44 impossible in ATTR state */
3361 case 0x80: /* EXT_T_0 */
3362 case 0x81: /* EXT_T_1 */
3363 case 0x82: /* EXT_T_2 */
3364 /* Extension tokens */
3365 index = tvb_get_guintvar (tvb, off+1, &len);
3366 str_len = tvb_strsize (tvb, str_tbl+index);
3367 if (codepage_attr) { /* Not default code page */
3368 proto_tree_add_text (tree, tvb, off, 1+len,
3369 " %3d | Attr | A %3d->0 "
3370 "| EXT_T_%1x (Extension Token) "
3371 "| %s(Tableref string extension: \'%s\')",
3372 level, codepage_attr, peek & 0x0f, Indent (level),
3373 tvb_format_text (tvb, str_tbl+index, str_len-1));
3374 /* Reset code page */
3376 } else { /* Code page 0 */
3377 proto_tree_add_text (tree, tvb, off, 1+len,
3379 "| EXT_T_%1x (Extension Token) "
3380 "| %s(Tableref string extension: \'%s\')",
3381 level, peek & 0x0f, Indent (level),
3382 tvb_format_text (tvb, str_tbl+index, str_len-1));
3386 case 0x83: /* STR_T */
3387 index = tvb_get_guintvar (tvb, off+1, &len);
3388 str_len = tvb_strsize (tvb, str_tbl+index);
3389 proto_tree_add_text (tree, tvb, off, 1+len,
3391 "| STR_T (Tableref string) "
3393 level, Indent (level),
3394 tvb_format_text (tvb, str_tbl+index, str_len-1));
3397 /* 0x84 impossible in ATTR state */
3398 case 0xC0: /* EXT_0 */
3399 case 0xC1: /* EXT_1 */
3400 case 0xC2: /* EXT_2 */
3401 /* Extension tokens */
3402 if (codepage_attr) { /* Not default code page */
3403 proto_tree_add_text (tree, tvb, off, 1,
3404 " %3d | Attr | A %3d->0 "
3405 "| EXT_%1x (Extension Token) "
3406 "| %s(Single-byte extension)",
3407 level, codepage_attr, peek & 0x0f, Indent (level));
3408 /* Reset code page */
3410 } else { /* Code page 0 */
3411 proto_tree_add_text (tree, tvb, off, 1,
3413 "| EXT_%1x (Extension Token) "
3414 "| %s(Single-byte extension)",
3415 level, peek & 0x0f, Indent (level));
3419 case 0xC3: /* OPAQUE - WBXML 1.1 and newer */
3420 if (tvb_get_guint8 (tvb, 0)) { /* WBXML 1.x (x > 0) */
3421 index = tvb_get_guintvar (tvb, off+1, &len);
3422 proto_tree_add_text (tree, tvb, off, 1 + len + index,
3424 "| OPAQUE (Opaque data) "
3425 "| %s(%d bytes of opaque data)",
3426 level, Indent (level), index);
3428 } else { /* WBXML 1.0 - RESERVED_2 token (invalid) */
3429 proto_tree_add_text (tree, tvb, off, 1,
3431 "| RESERVED_2 (Invalid Token!) "
3432 "| WBXML 1.0 parsing stops here.",
3434 /* Stop processing as it is impossible to parse now */
3436 *parsed_length = off - offset;
3440 /* 0xC4 impossible in ATTR state */
3442 proto_tree_add_text (tree, tvb, off, 1,
3444 "| %-10s (Invalid Token!) "
3445 "| WBXML parsing stops here.",
3446 level, match_strval (peek, vals_wbxml1x_global_tokens));
3447 /* Move to end of buffer */
3450 } else { /* Known atribute token */
3451 if (peek & 0x80) { /* attrValue */
3452 if (codepage_attr) { /* Not default code page */
3453 proto_tree_add_text (tree, tvb, off, 1,
3454 " %3d | Attr | A %3d->0 "
3455 "| Known attrValue 0x%02X "
3456 "| %sattrValue_0x%02X",
3457 level, codepage_attr, peek & 0x7f, Indent (level),
3459 /* Reset code page */
3461 } else { /* Code page 0 */
3462 proto_tree_add_text (tree, tvb, off, 1,
3464 "| Known attrValue 0x%02X "
3465 "| %sattrValue_0x%02X",
3466 level, peek & 0x7f, Indent (level),
3470 } else { /* attrStart */
3471 if (codepage_attr) { /* Not default code page */
3472 proto_tree_add_text (tree, tvb, off, 1,
3473 " %3d | Attr | A %3d->0 "
3474 "| Known attrStart 0x%02X "
3475 "| %sattrStart_0x%02X",
3476 level, codepage_attr, peek & 0x7f, Indent (level),
3478 /* Reset code page */
3480 } else { /* Code page 0 */
3481 proto_tree_add_text (tree, tvb, off, 1,
3483 "| Known attrStart 0x%02X "
3484 "| %sattrStart_0x%02X",
3485 level, peek & 0x7f, Indent (level),
3495 /****************** Register the protocol with Ethereal ******************/
3498 /* This format is required because a script is used to build the C function
3499 * that calls the protocol registration. */
3502 proto_register_wbxml(void)
3503 { /* Setup list of header fields. See Section 1.6.1 for details. */
3504 static hf_register_info hf[] = {
3505 { &hf_wbxml_version,
3509 VALS ( vals_wbxml_versions ), 0x00,
3510 "WBXML Version", HFILL }
3512 { &hf_wbxml_public_id_known,
3513 { "Public Identifier (known)",
3514 "wbxml.public_id.known",
3515 FT_UINT32, BASE_HEX,
3516 VALS ( vals_wbxml_public_ids ), 0x00,
3517 "WBXML Known Public Identifier (integer)", HFILL }
3519 { &hf_wbxml_public_id_literal,
3520 { "Public Identifier (literal)",
3521 "wbxml.public_id.literal",
3522 FT_STRING, BASE_NONE,
3524 "WBXML Literal Public Identifier (text string)", HFILL }
3526 { &hf_wbxml_charset,
3529 FT_UINT32, BASE_HEX,
3530 VALS ( vals_character_sets ), 0x00,
3531 "WBXML Character Set", HFILL }
3535 /* Setup protocol subtree array */
3536 static gint *ett[] = {
3542 /* Register the protocol name and description */
3543 proto_wbxml = proto_register_protocol(
3549 /* Required function calls to register the header fields
3550 * and subtrees used */
3551 proto_register_field_array(proto_wbxml, hf, array_length(hf));
3552 proto_register_subtree_array(ett, array_length(ett));
3554 register_dissector("wbxml", dissect_wbxml, proto_wbxml);
3559 proto_reg_handoff_wbxml(void)
3561 dissector_handle_t wbxml_handle;
3563 /* Heuristic dissectors would be declared by means of:
3564 * heur_dissector_add("wsp", dissect_wbxml_heur, proto_wbxml);
3567 wbxml_handle = create_dissector_handle(dissect_wbxml, proto_wbxml);
3569 /* Register the WSP content types (defined as protocol port)
3570 * for WBXML dissection.
3572 * See http://www.wapforum.org/wina/wsp-content-type.htm
3575 /**** Well-known WBXML WSP Content-Type values ****/
3577 /* application/vnd.wap.wmlc */
3578 dissector_add("wsp.content_type.type", 0x14, wbxml_handle);
3580 /* application/vnd.wap.wta-eventc */
3581 dissector_add("wsp.content_type.type", 0x16, wbxml_handle);
3583 /* application/vnd.wap.wbxml */
3584 dissector_add("wsp.content_type.type", 0x29, wbxml_handle);
3586 /* application/vnd.wap.sic */
3587 dissector_add("wsp.content_type.type", 0x2E, wbxml_handle);
3589 /* application/vnd.wap.slc */
3590 dissector_add("wsp.content_type.type", 0x30, wbxml_handle);
3592 /* application/vnd.wap.coc */
3593 dissector_add("wsp.content_type.type", 0x32, wbxml_handle);
3595 /* application/vnd.wap.connectivity-wbxml */
3596 dissector_add("wsp.content_type.type", 0x36, wbxml_handle);
3598 /* application/vnd.wap.locc+wbxml */
3599 dissector_add("wsp.content_type.type", 0x40, wbxml_handle);
3601 /* application/vnd.syncml.dm+wbxml */
3602 dissector_add("wsp.content_type.type", 0x42, wbxml_handle);
3604 /* application/vnd.oma.drm.rights+wbxml */
3605 dissector_add("wsp.content_type.type", 0x4B, wbxml_handle);
3607 #ifdef WSP_DISSECTOR_REGISTERS_ContentType_AS_FourByteGuint
3609 /**** Registered WBXML WSP Content-Type values ****/
3611 /* application/vnd.uplanet.cacheop-wbxml */
3612 dissector_add("wsp.content_type.type", 0x0201, wbxml_handle);
3614 /* application/vnd.uplanet.alert-wbxml */
3615 dissector_add("wsp.content_type.type", 0x0203, wbxml_handle);
3617 /* application/vnd.uplanet.list-wbxml */
3618 dissector_add("wsp.content_type.type", 0x0204, wbxml_handle);
3620 /* application/vnd.uplanet.listcmd-wbxml */
3621 dissector_add("wsp.content_type.type", 0x0205, wbxml_handle);
3623 /* application/vnd.uplanet.channel-wbxml */
3624 dissector_add("wsp.content_type.type", 0x0206, wbxml_handle);
3626 /* application/vnd.uplanet.bearer-choice-wbxml */
3627 dissector_add("wsp.content_type.type", 0x0209, wbxml_handle);
3629 /* application/vnd.phonecom.mmc-wbxml */
3630 dissector_add("wsp.content_type.type", 0x020A, wbxml_handle);
3632 /* application/vnd.nokia.syncset+wbxml */
3633 dissector_add("wsp.content_type.type", 0x020B, wbxml_handle);