From Olivier Biot: WBXML/WMLC support.

svn path=/trunk/; revision=7084
This commit is contained in:
Guy Harris 2003-02-06 01:23:32 +00:00
parent 1576681f28
commit d48ec06a6a
6 changed files with 459 additions and 8 deletions

View File

@ -710,6 +710,7 @@ Inoue <inoue[AT]ainet.or.jp> {
Olivier Biot <Olivier.Biot[AT]siemens.atea.be> {
Various WTP fixes and enhancements
WBXML/WMLC support
}
Patrick Wolfe <pjw[AT]zocalo.cellular.ameritech.com> {

View File

@ -1,7 +1,7 @@
# Makefile.am
# Automake file for Ethereal
#
# $Id: Makefile.am,v 1.551 2003/02/04 20:16:57 guy Exp $
# $Id: Makefile.am,v 1.552 2003/02/06 01:23:32 guy Exp $
#
# Ethereal - Network traffic analyzer
# By Gerald Combs <gerald@ethereal.com>
@ -381,6 +381,7 @@ DISSECTOR_SRC = \
packet-vrrp.c \
packet-vtp.c \
packet-wap.c \
packet-wbxml.c \
packet-wccp.c \
packet-wcp.c \
packet-wfleet-hdlc.c \
@ -619,6 +620,7 @@ noinst_HEADERS = \
packet-vines.h \
packet-vlan.h \
packet-wap.h \
packet-wbxml.h \
packet-wccp.h \
packet-wlancap.h \
packet-wsp.h \

View File

@ -1,7 +1,7 @@
## Makefile for building ethereal.exe with Microsoft C and nmake
## Use: $(MAKE) /$(MAKEFLAGS) -f makefile.nmake
#
# $Id: Makefile.nmake,v 1.278 2003/02/04 20:16:57 guy Exp $
# $Id: Makefile.nmake,v 1.279 2003/02/06 01:23:32 guy Exp $
include config.nmake
include <win32.mak>
@ -324,6 +324,7 @@ DISSECTOR_SRC = \
packet-vrrp.c \
packet-vtp.c \
packet-wap.c \
packet-wbxml.c \
packet-wccp.c \
packet-wcp.c \
packet-wfleet-hdlc.c \

271
packet-wbxml.c Normal file
View File

@ -0,0 +1,271 @@
/* packet-wbxml.c
* Routines for wbxml dissection
* Copyright 2003, Olivier Biot <olivier.biot (ad) siemens.com>
*
* $Id: packet-wbxml.c,v 1.1 2003/02/06 01:23:32 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
* Copyright 1998 Gerald Combs
*
* Wap Binary XML decoding functionality provided by Olivier Biot.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#ifdef NEED_SNPRINTF_H
# include "snprintf.h"
#endif
#include <epan/packet.h>
#include "packet-wap.h"
#include "packet-wbxml.h"
/* Initialize the protocol and registered fields */
static int proto_wbxml = -1;
static int hf_wbxml_version = -1;
static int hf_wbxml_public_id_known = -1;
static int hf_wbxml_public_id_literal = -1;
static int hf_wbxml_charset = -1;
/* Initialize the subtree pointers */
static gint ett_wbxml = -1;
/*
* Function prototypes
*/
static void
dissect_wbxml(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
void
proto_register_wbxml(void);
void
add_wml_10 (proto_tree *tree, tvbuff_t *tvb, guint32 offset, guint8 version);
/* WBXML format
* Version 1.0: version publicid strtbl BODY
* Version 1.x: version publicid charset strtbl BODY
*/
/* Code to actually dissect the packets */
static void
dissect_wbxml(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
/* Set up structures needed to add the protocol subtree and manage it */
proto_item *ti;
proto_tree *wbxml_tree;
guint8 peek, version;
guint offset = 0;
const char *token;
int token_size;
guint32 index, len, type=0;
switch ( peek = tvb_get_guint8(tvb, 0) ) {
case 0x00: /* WBXML/1.0 */
break;
case 0x01: /* WBXML/1.1 */
case 0x02: /* WBXML/1.2 */
case 0x03: /* WBXML/1.3 */
break;
default:
break;
}
/* In the interest of speed, if "tree" is NULL, don't do any work not
necessary to generate protocol tree items. */
if (tree) {
/* create display subtree for the protocol */
ti = proto_tree_add_item(tree, proto_wbxml, tvb, 0, -1, FALSE);
wbxml_tree = proto_item_add_subtree(ti, ett_wbxml);
/* WBXML Version */
version = tvb_get_guint8(tvb, offset++);
proto_tree_add_uint(wbxml_tree, hf_wbxml_version,
tvb, 0, 1, version);
/* Public ID */
peek = tvb_get_guint8(tvb, offset++);
if (peek == 0) { /* Public identifier in string table */
/* TODO
* Check the value of index as String Table not yet parsed */
index = tvb_get_guintvar (tvb, offset, &len);
token_size = tvb_strsize(tvb, offset + len + index);
token = tvb_get_ptr(tvb, offset + len + index, token_size);
proto_tree_add_string(wbxml_tree, hf_wbxml_public_id_literal,
tvb, 1, len, token);
} else { /* Known public identifier */
if (peek < 0x80) {
type = peek;
proto_tree_add_uint(wbxml_tree, hf_wbxml_public_id_known,
tvb, 1, 1, type);
} else {
type = tvb_get_guintvar (tvb, offset, &len);
proto_tree_add_uint(wbxml_tree, hf_wbxml_public_id_known,
tvb, 1, len, type);
offset += len;
}
}
/* Version-specific handling of header */
switch ( version ) {
case 0x00: /* WBXML/1.0 */
break;
case 0x01: /* WBXML/1.1 */
case 0x02: /* WBXML/1.2 */
case 0x03: /* WBXML/1.3 */
/* Get charset */
index = tvb_get_guintvar (tvb, offset, &len);
proto_tree_add_uint(wbxml_tree, hf_wbxml_charset,
tvb, offset, len, index);
offset += len;
break;
default:
return;
}
/* String table */
index = tvb_get_guintvar (tvb, offset, &len);
proto_tree_add_text(wbxml_tree,
tvb, offset, 1+index, "String table: %u bytes", index);
offset += 1 + index;
/* The WBXML BODY starts here */
switch (type) {
case WBXML_WML_10:
add_wml_10 (wbxml_tree, tvb, offset, version);
break;
default:
break;
}
}
}
void
add_wml_10 (proto_tree *tree, tvbuff_t *tvb, guint32 offset, guint8 version)
{
guint32 size = tvb_reported_length(tvb) - offset;
if (version) { /* Not WBXML 1.0 */
;
} else { /* WBXML 1.0 */
;
}
/* TODO */
}
/* Register the protocol with Ethereal */
/* this format is require because a script is used to build the C function
that calls all the protocol registration.
*/
void
proto_register_wbxml(void)
{
/* Setup list of header fields See Section 1.6.1 for details*/
static hf_register_info hf[] = {
{ &hf_wbxml_version,
{ "Version",
"wbxml.version",
FT_UINT8, BASE_HEX,
VALS ( vals_wbxml_versions ), 0x00,
"WBXML version", HFILL }
},
{ &hf_wbxml_public_id_known,
{ "Public Identifier (known)",
"wbxml.public_id",
FT_UINT32, BASE_HEX,
VALS ( vals_wbxml_public_ids ), 0x00,
"WBXML Public Identifier (known)", HFILL }
},
{ &hf_wbxml_public_id_literal,
{ "Public Identifier (literal)",
"wbxml.public_id",
FT_STRING, BASE_NONE,
NULL, 0x00,
"WBXML Public Identifier (literal)", HFILL }
},
{ &hf_wbxml_charset,
{ "Character Set",
"wbxml.charset",
FT_UINT32, BASE_HEX,
VALS ( vals_character_sets ), 0x00,
"WBXML Character Set", HFILL }
},
};
/* Setup protocol subtree array */
static gint *ett[] = {
&ett_wbxml,
};
/* Register the protocol name and description */
proto_wbxml = proto_register_protocol(
"WAP Binary XML",
"WBXML",
"wbxml"
);
/* Required function calls to register the header fields and subtrees used */
proto_register_field_array(proto_wbxml, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
register_dissector("wbxml", dissect_wbxml, proto_wbxml);
/* register_init_routine(dissect_wbxml); */
/* wbxml_handle = find_dissector("wsp-co"); */
};
void
proto_reg_handoff_wbxml(void)
{
dissector_handle_t wbxml_handle;
/* heur_dissector_add("wsp", dissect_wbxml_heur, proto_wbxml); */
wbxml_handle = create_dissector_handle(dissect_wbxml, proto_wbxml);
dissector_add("wsp.content_type.type", 0x14, wbxml_handle); /* wmlc */
dissector_add("wsp.content_type.type", 0x16, wbxml_handle); /* channelc */
dissector_add("wsp.content_type.type", 0x2E, wbxml_handle); /* sic */
dissector_add("wsp.content_type.type", 0x30, wbxml_handle); /* slc */
dissector_add("wsp.content_type.type", 0x32, wbxml_handle); /* coc */
}

176
packet-wbxml.h Normal file
View File

@ -0,0 +1,176 @@
/* packet-wbxml.h
* Routines for wbxml dissection
* Copyright 2003, Olivier Biot <olivier.biot (ad) siemens.com>
*
* $Id: packet-wbxml.h,v 1.1 2003/02/06 01:23:32 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
* Copyright 1998 Gerald Combs
*
* Wap Binary XML decoding functionality provided by Olivier Biot.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef PACKET_WBXML_H
#define PACKET_WBXML_H
/* See http://www.wapforum.org/wina/ for an up-to-date list. */
#define WBXML_WML_10 0x02
#define WBXML_WTA_10 0x03
#define WBXML_WML_11 0x04
#define WBXML_SI_10 0x05
#define WBXML_SL_10 0x06
#define WBXML_CO_10 0x07
#define WBXML_CHANNEL_10 0x08
#define WBXML_WML_12 0x09
#define WBXML_WML_13 0x0a
#define WBXML_PROV_10 0x0b
#define WBXML_WTAWML_12 0x0c
#define WBXML_EMN_10 0x0d
#define WBXML_DRMREL_10 0x0e
static const value_string vals_wbxml_public_ids[] = {
/* 0x00 = literal public identifier */
{ 0x01, "Unknown / missing Public Identifier" },
{ 0x02, "-//WAPFORUM//DTD WML 1.0//EN (WML 1.0)" },
{ 0x03, "-//WAPFORUM//DTD WTA 1.0//EN (WTA Event 1.0) - Deprecated" },
{ 0x04, "-//WAPFORUM//DTD WML 1.1//EN (WML 1.1)" },
{ 0x05, "-//WAPFORUM//DTD SI 1.0//EN (Service Indication 1.0)" },
{ 0x06, "-//WAPFORUM//DTD SL 1.0//EN (Service Loading 1.0)" },
{ 0x07, "-//WAPFORUM//DTD CO 1.0//EN (Cache Operation 1.0)" },
{ 0x08, "-//WAPFORUM//DTD CHANNEL 1.0//EN (Channel 1.1)" },
{ 0x09, "-//WAPFORUM//DTD WML 1.2//EN (WML 1.2)" },
{ 0x0a, "-//WAPFORUM//DTD WML 1.3//EN (WML 1.3)" },
{ 0x0b, "-//WAPFORUM//DTD PROV 1.0//EN (Provisioning 1.0)" },
{ 0x0c, "-//WAPFORUM//DTD WTA-WML 1.2//EN (WTA-WML 1.2)" },
{ 0x0d, "-//WAPFORUM//DTD EMN 1.0//EN (Email Notification 1.0)" },
{ 0x0e, "-//WAPFORUM//DTD DRMREL 1.0//EN (DRMREL 1.0)" },
{ 0x00, NULL }
};
static const value_string vals_wbxml_versions[] = {
{ 0x00, "1.0" },
{ 0x01, "1.1" },
{ 0x02, "1.2" },
{ 0x03, "1.3" },
{ 0x00, NULL }
};
/* See WAP-104-WBXML */
static const value_string vals_wbxml10_global_tokens[] = {
{ 0x00, "SWITCH_PAGE" },
{ 0x01, "END" },
{ 0x02, "ENTITY" },
{ 0x03, "STR_I" },
{ 0x04, "LITERAL" },
{ 0x40, "EXT_I_0" },
{ 0x41, "EXT_I_1" },
{ 0x42, "EXT_I_2" },
{ 0x43, "PI" },
{ 0x44, "LITERAL_C" },
{ 0x80, "EXT_T_0" },
{ 0x81, "EXT_T_1" },
{ 0x82, "EXT_T_2" },
{ 0x83, "STR_T" },
{ 0x84, "LITERAL_A" },
{ 0xC0, "EXT_0" },
{ 0xC1, "EXT_1" },
{ 0xC2, "EXT_2" },
{ 0xC3, "RESERVED_2" },
{ 0xC4, "LITERAL_AC" },
{ 0x00, NULL }
};
/* See WAP-135-WBXML, WAP-154-WBXML, WAP-192-WBXML */
static const value_string vals_wbxml1x_global_tokens[] = {
{ 0x00, "SWITCH_PAGE" },
{ 0x01, "END" },
{ 0x02, "ENTITY" },
{ 0x03, "STR_I" },
{ 0x04, "LITERAL" },
{ 0x40, "EXT_I_0" },
{ 0x41, "EXT_I_1" },
{ 0x42, "EXT_I_2" },
{ 0x43, "PI" },
{ 0x44, "LITERAL_C" },
{ 0x80, "EXT_T_0" },
{ 0x81, "EXT_T_1" },
{ 0x82, "EXT_T_2" },
{ 0x83, "STR_T" },
{ 0x84, "LITERAL_A" },
{ 0xC0, "EXT_0" },
{ 0xC1, "EXT_1" },
{ 0xC2, "EXT_2" },
{ 0xC3, "OPAQUE" },
{ 0xC4, "LITERAL_AC" },
{ 0x00, NULL }
};
static const value_string vals_wmlc11_tags[] = {
{ 0x1C, "a" },
{ 0x1D, "td" },
{ 0x1E, "tr" },
{ 0x1F, "table" },
{ 0x20, "p" },
{ 0x21, "postfield" },
{ 0x22, "anchor" },
{ 0x23, "access" },
{ 0x24, "b" },
{ 0x25, "big" },
{ 0x26, "br" },
{ 0x27, "card" },
{ 0x28, "do" },
{ 0x29, "em" },
{ 0x2A, "fieldset" },
{ 0x2B, "go" },
{ 0x2C, "head" },
{ 0x2D, "i" },
{ 0x2E, "img" },
{ 0x2F, "input" },
{ 0x30, "meta" },
{ 0x31, "noop" },
{ 0x32, "prev" },
{ 0x33, "onevent" },
{ 0x34, "optgroup" },
{ 0x35, "option" },
{ 0x36, "refresh" },
{ 0x37, "select" },
{ 0x38, "small" },
{ 0x39, "strong" },
{ 0x3A, "" },
{ 0x3B, "template" },
{ 0x3C, "timer" },
{ 0x3D, "u" },
{ 0x3E, "setvar" },
{ 0x3F, "wml" },
{ 0x00, NULL }
};
#endif

View File

@ -2,7 +2,7 @@
*
* Routines to dissect WSP component of WAP traffic.
*
* $Id: packet-wsp.c,v 1.63 2002/09/25 00:01:18 jmayer Exp $
* $Id: packet-wsp.c,v 1.64 2003/02/06 01:23:32 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -205,8 +205,8 @@ static dissector_handle_t wsp_fromudp_handle;
/* Handle for WTP-over-UDP dissector */
static dissector_handle_t wtp_fromudp_handle;
/* Handle for WMLC dissector */
static dissector_handle_t wmlc_handle;
/* Handle for WBXML dissector */
static dissector_handle_t wbxml_handle;
static const value_string vals_pdu_type[] = {
{ 0x00, "Reserved" },
@ -1380,7 +1380,7 @@ dissect_wsp_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
}
offset += count+headersLength+1;
/* TODO: Data - decode WMLC */
/* TODO: Data - decode WBXML */
/* Runs from offset+1+count+headerLength+1 to end of frame */
if (tvb_reported_length_remaining (tvb, offset) > 0)
{
@ -4919,9 +4919,9 @@ void
proto_reg_handoff_wsp(void)
{
/*
* Get a handle for the WMLC dissector.
* Get a handle for the WBXML dissector.
*/
wmlc_handle = find_dissector("wmlc"); /* Coming soon :) */
wbxml_handle = find_dissector("wbxml");
/*
* And get a handle for the WTP-over-UDP dissector.