-/* packet-wtp.c (c) 2000 Neil Hunter
- * Base on original work by Ben Fowler
+/* packet-wtp.c
*
* Routines to dissect WTP component of WAP traffic.
*
- * $Id: packet-wtp.c,v 1.9 2001/01/09 06:31:45 guy Exp $
+ * $Id: packet-wtp.c,v 1.22 2001/12/03 03:59:43 guy Exp $
*
* Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@zing.org>
- * Copyright 1998 Didier Jorand
+ * By Gerald Combs <gerald@ethereal.com>
+ * Copyright 1998 Gerald Combs
+ *
+ * WAP dissector based on original work by Ben Fowler
+ * Updated by Neil Hunter <neil.hunter@energis-squared.com>
+ * WTLS support by Alexandre P. Ferreira (Splice IP)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
{ 0, NULL }
};
-static const value_string vals_transmission_trailer[] = {
+static const value_string vals_transaction_trailer[] = {
{ 0, "Not last packet" },
{ 1, "Last packet of message" },
{ 2, "Last packet of group" },
{ 0x00, NULL }
};
+static const value_string vals_transaction_classes[] = {
+ { 0x00, "Unreliable Invoke without Result" },
+ { 0x01, "Reliable Invoke without Result" },
+ { 0x02, "Reliable Invoke with Reliable Result" },
+ { 0x00, NULL }
+};
+
/* File scoped variables for the protocol and registered fields */
static int proto_wtp = HF_EMPTY;
/* These fields used by fixed part of header */
static int hf_wtp_header_fixed_part = HF_EMPTY;
+static int hf_wtp_header_sub_pdu_size = HF_EMPTY;
static int hf_wtp_header_flag_continue = HF_EMPTY;
static int hf_wtp_header_pdu_type = HF_EMPTY;
static int hf_wtp_header_flag_Trailer = HF_EMPTY;
static gint ett_wtp = ETT_EMPTY;
static gint ett_header = ETT_EMPTY;
+/* Handle for WSP dissector */
static dissector_handle_t wsp_handle;
/* Declarations */
/* Code to actually dissect the packets */
static void
-dissect_wtp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
+dissect_wtp_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
frame_data *fdata = pinfo->fd;
unsigned char b0 = pd[offset + 0];
unsigned char b3 = pd[offset + 3];
*/
- unsigned char b0 = tvb_get_guint8 (tvb, offCur + 0);
+ unsigned char b0;
/* continuation flag */
- unsigned char fCon = b0 & 0x80;
- unsigned char fRID = retransmission_indicator( b0 );
- int cbHeader = 0;
+ unsigned char fCon;
+ unsigned char fRID;
+ guint cbHeader = 0;
+ guint vHeader = 0;
int abortType = 0;
/* Set up structures we will need to add the protocol subtree and manage it */
proto_item *ti;
- proto_tree *wtp_tree;
+ proto_tree *wtp_tree = NULL;
proto_tree *wtp_header_fixed;
- char pdut = pdu_type( b0 );
+ char pdut;
char clsTransaction = ' ';
int cchInfo;
int numMissing = 0; /* Number of missing packets in a negative ack */
int i;
tvbuff_t *wsp_tvb = NULL;
- CHECK_DISPLAY_AS_DATA(proto_wtp, tvb, pinfo, tree);
-
- pinfo->current_proto = "WTP";
-
-/* Make entries in Protocol column and Info column of summary display */
-
#ifdef DEBUG
fprintf( stderr, "dissect_wtp: (Entering) Frame data at %p\n", fdata );
fprintf( stderr, "dissect_wtp: tvb length is %d\n", tvb_reported_length( tvb ) );
#endif
- /* Display protocol type depending on the port */
- if (check_col(fdata, COL_PROTOCOL))
- {
- switch ( pinfo->match_port )
- {
- case UDP_PORT_WTP_WSP:
- col_add_fstr(fdata, COL_PROTOCOL, "WTP+WSP" );
- break;
- case UDP_PORT_WTLS_WTP_WSP:
- col_add_fstr(fdata, COL_PROTOCOL, "WTLS+WTP+WSP" );
- break;
- default:
- break;
+ b0 = tvb_get_guint8 (tvb, offCur + 0);
+ /* Discover Concatenated PDUs */
+ if (b0 == 0) {
+ if (tree) {
+ wtp_tree = proto_tree_add_item(tree, proto_wtp, tvb, offCur, 1, bo_little_endian);
}
+ offCur = 1;
+ i = 1;
+ while (offCur < (int) tvb_reported_length (tvb)) {
+ b0 = tvb_get_guint8 (tvb, offCur + 0);
+ if (b0 & 0x80) {
+ vHeader = 2;
+ cbHeader = ((b0 & 0x7f) << 8) |
+ tvb_get_guint8 (tvb, offCur + 1);
+ } else {
+ vHeader = 1;
+ cbHeader = b0;
+ }
+ if (tree) {
+ proto_tree_add_item(wtp_tree, hf_wtp_header_sub_pdu_size, tvb, offCur, vHeader, bo_big_endian);
+ }
+ if (i > 1 && check_col(fdata, COL_INFO)) {
+ col_append_str (fdata, COL_INFO, ", ");
+ }
+ wsp_tvb = tvb_new_subset(tvb,
+ offCur + vHeader, -1, cbHeader);
+ dissect_wtp_common (wsp_tvb, pinfo, wtp_tree);
+ offCur += vHeader + cbHeader;
+ i++;
+ }
+ return;
}
-
+ fCon = b0 & 0x80;
+ fRID = retransmission_indicator( b0 );
+ pdut = pdu_type( b0 );
+
/* Develop the string to put in the Info column */
- cchInfo = snprintf( szInfo, sizeof( szInfo ), "WTP %s", vals_pdu_type[ ( int )pdut ].strptr );
+ cchInfo = snprintf( szInfo, sizeof( szInfo ), "WTP %s",
+ val_to_str(pdut, vals_pdu_type, "Unknown PDU type 0x%x"));
switch( pdut ) {
case INVOKE:
if( fRID ) {
strcat( szInfo, " R" );
};
+ if( fCon ) {
+ unsigned char tCon;
+ unsigned char tByte;
+
+ do {
+ tByte = tvb_get_guint8(tvb, offCur + cbHeader + vHeader);
+ tCon = tByte & 0x80;
+ if (tByte & 0x04)
+ vHeader = vHeader + tvb_get_guint8(tvb,
+ offCur + cbHeader + vHeader + 1) + 2;
+ else
+ vHeader = vHeader + (tByte & 0x03) + 1;
+ } while (tCon);
+ }
#ifdef DEBUG
fprintf( stderr, "dissect_wtp: cbHeader = %d\n", cbHeader );
/* This field shows up as the "Info" column in the display; you should make
it, if possible, summarize what's in the packet, so that a user looking
at the list of packets can tell what type of packet it is. */
- if (check_col(fdata, COL_INFO)) {
+ if (check_col(fdata, COL_INFO) &&
+ tvb_reported_length (tvb) <= cbHeader + vHeader) {
#ifdef DEBUG
fprintf( stderr, "dissect_wtp: (6) About to set info_col header to %s\n", szInfo );
#endif
- col_add_str(fdata, COL_INFO, szInfo );
+ col_append_str(fdata, COL_INFO, szInfo );
};
/* In the interest of speed, if "tree" is NULL, don't do any work not
necessary to generate protocol tree items. */
#ifdef DEBUG
fprintf( stderr, "dissect_wtp: cbHeader = %d\n", cbHeader );
#endif
- ti = proto_tree_add_item(tree, proto_wtp, tvb, offCur, cbHeader, bo_little_endian);
+ ti = proto_tree_add_item(tree, proto_wtp, tvb, offCur, cbHeader + vHeader, bo_little_endian);
#ifdef DEBUG
fprintf( stderr, "dissect_wtp: (7) Returned from proto_tree_add_item\n" );
#endif
wtp_tree, /* tree */
hf_wtp_header_variable_part, /* id */
tvb,
- offCur + 4, /* start */
- 4, /* length */
+ offCur + cbHeader, /* start */
+ vHeader, /* length */
"What should go here!", /* value */
"Header (Variable part) %02X %02X %02X %02X" , /* format */
0, 1, 2, 3
fprintf( stderr, "dissect_wtp: (4) tree was %p\n", tree );
#endif
}
-
- /* Any remaining data ought to be WSP data, so hand off to the WSP dissector */
- if (tvb_reported_length (tvb) > cbHeader)
+
+ /* Any remaining data ought to be WSP data,
+ * so hand off to the WSP dissector */
+ if (tvb_reported_length (tvb) > cbHeader + vHeader)
{
- wsp_tvb = tvb_new_subset(tvb, cbHeader, -1, tvb_reported_length (tvb)-cbHeader);
+ wsp_tvb = tvb_new_subset(tvb, cbHeader + vHeader, -1,
+ tvb_reported_length (tvb)-cbHeader-vHeader);
call_dissector(wsp_handle, wsp_tvb, pinfo, tree);
}
#endif
}
+/*
+ * Called directly from UDP.
+ * Put "WTP+WSP" into the "Protocol" column.
+ */
+static void
+dissect_wtp_fromudp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
+{
+ if (check_col(pinfo->fd, COL_PROTOCOL))
+ col_set_str(pinfo->fd, COL_PROTOCOL, "WTP+WSP" );
+ if (check_col(pinfo->fd, COL_INFO)) {
+ col_clear(pinfo->fd, COL_INFO);
+ }
+
+ dissect_wtp_common(tvb, pinfo, tree);
+}
+
+/*
+ * Called from a higher-level WAP dissector, presumably WTLS.
+ * Put "WTLS+WSP+WTP" to the "Protocol" column.
+ *
+ * XXX - is this supposed to be called from WTLS? If so, we're not
+ * calling it....
+ *
+ * XXX - can this be called from any other dissector?
+ */
+static void
+dissect_wtp_fromwap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
+{
+ if (check_col(pinfo->fd, COL_PROTOCOL))
+ col_set_str(pinfo->fd, COL_PROTOCOL, "WTLS+WTP+WSP" );
+ if (check_col(pinfo->fd, COL_INFO)) {
+ col_clear(pinfo->fd, COL_INFO);
+ }
+
+ dissect_wtp_common(tvb, pinfo, tree);
+}
+
static char pdu_type(unsigned char octet)
{
char ch = (octet >> 3) & 0x0F;
static char retransmission_indicator(unsigned char octet)
{
- char ch = (octet >> 0) & 0x01; /* ......,X */
- return ch;
+ switch ( pdu_type(octet) ) {
+ case INVOKE:
+ case RESULT:
+ case ACK:
+ case SEGMENTED_INVOKE:
+ case SEGMENTED_RESULT:
+ case NEGATIVE_ACK:
+ return (octet >> 0) & 0x01; /* ......,X */
+ default:
+ return 0;
+ }
};
/* Register the protocol with Ethereal */
{ "Header",
"wtp.header_fixed_part",
FT_BYTES, BASE_HEX, NULL, 0x0,
- "Fixed part of the header"
+ "Fixed part of the header", HFILL
+ }
+ },
+ { &hf_wtp_header_sub_pdu_size,
+ { "Sub PDU size",
+ "wtp.sub_pdu_size",
+ FT_BYTES, BASE_HEX, NULL, 0x0,
+ "Size of Sub-PDU", HFILL
}
},
{ &hf_wtp_header_flag_continue,
{ "Continue Flag",
- "wtp.continue-flag",
+ "wtp.continue_flag",
FT_BOOLEAN, 8, TFS( &continue_truth ), 0x80,
- "Continue Flag"
+ "Continue Flag", HFILL
}
},
{ &hf_wtp_header_pdu_type,
{ "PDU Type",
- "wtp.pdu-type",
+ "wtp.pdu_type",
FT_UINT8, BASE_HEX, VALS( vals_pdu_type ), 0x78,
- "PDU Type"
+ "PDU Type", HFILL
}
},
{ &hf_wtp_header_flag_Trailer,
{ "Trailer Flags",
- "wtp.trailer-flags",
- FT_UINT8, BASE_HEX, VALS( vals_transmission_trailer ), 0x06,
- "PDU Type"
+ "wtp.trailer_flags",
+ FT_UINT8, BASE_HEX, VALS( vals_transaction_trailer ), 0x06,
+ "Trailer Flags", HFILL
}
},
{ &hf_wtp_header_flag_RID,
{ "Re-transmission Indicator",
"wtp.RID",
FT_BOOLEAN, 8, TFS( &RID_truth ), 0x01,
- "Re-transmission Indicator"
+ "Re-transmission Indicator", HFILL
}
},
{ &hf_wtp_header_flag_TID_response,
{ "TID Response",
"wtp.TID.response",
FT_BOOLEAN, 16, TFS( &tid_response_truth ), 0x8000,
- "TID Response"
+ "TID Response", HFILL
}
},
{ &hf_wtp_header_flag_TID,
- { "Transmission ID",
+ { "Transaction ID",
"wtp.TID",
FT_UINT16, BASE_HEX, NULL, 0x7FFF,
- "Transmission ID"
+ "Transaction ID", HFILL
}
},
{ &hf_wtp_header_Inv_version,
{ "Version",
"wtp.header.version",
FT_UINT8, BASE_HEX, VALS( vals_version ), 0xC0,
- "Version"
+ "Version", HFILL
}
},
{ &hf_wtp_header_Inv_flag_TIDNew,
{ "TIDNew",
"wtp.header.TIDNew",
FT_BOOLEAN, 8, TFS( &TIDNew_truth ), 0x20,
- "TIDNew"
+ "TIDNew", HFILL
}
},
{ &hf_wtp_header_Inv_flag_UP,
{ "U/P flag",
"wtp.header.UP",
FT_BOOLEAN, 8, TFS( &UP_truth ), 0x10,
- "U/P Flag"
+ "U/P Flag", HFILL
}
},
{ &hf_wtp_header_Inv_Reserved,
{ "Reserved",
"wtp.inv.reserved",
FT_UINT8, BASE_HEX, NULL, 0x0C,
- "Reserved"
+ "Reserved", HFILL
}
},
{ &hf_wtp_header_Inv_TransactionClass,
{ "Transaction Class",
- "wtp.inv.transaction-class",
- FT_UINT8, BASE_HEX, NULL, 0x03,
- "Transaction Class"
+ "wtp.inv.transaction_class",
+ FT_UINT8, BASE_HEX, VALS( vals_transaction_classes ), 0x03,
+ "Transaction Class", HFILL
}
},
{ &hf_wtp_header_Ack_flag_TVETOK,
{ "Tve/Tok flag",
"wtp.ack.tvetok",
FT_BOOLEAN, 8, TFS( &TVETOK_truth ), 0x04,
- "Tve/Tok flag"
+ "Tve/Tok flag", HFILL
}
},
{ &hf_wtp_header_Abort_type,
{ "Abort Type",
"wtp.abort.type",
FT_UINT8, BASE_HEX, VALS ( vals_abort_type ), 0x07,
- "Abort Type"
+ "Abort Type", HFILL
}
},
{ &hf_wtp_header_Abort_reason_provider,
{ "Abort Reason",
"wtp.abort.reason.provider",
FT_UINT8, BASE_HEX, VALS ( vals_abort_reason_provider ), 0x00,
- "Abort Reason"
+ "Abort Reason", HFILL
}
},
/* Assume WSP is the user and use its reason codes */
{ "Abort Reason",
"wtp.abort.reason.user",
FT_UINT8, BASE_HEX, VALS ( vals_wsp_reason_codes ), 0x00,
- "Abort Reason"
+ "Abort Reason", HFILL
}
},
{ &hf_wtp_header_sequence_number,
{ "Packet Sequence Number",
"wtp.header.sequence",
FT_UINT8, BASE_HEX, NULL, 0x00,
- "Packet Sequence Number"
+ "Packet Sequence Number", HFILL
}
},
{ &hf_wtp_header_missing_packets,
{ "Missing Packets",
"wtp.header.missing_packets",
FT_UINT8, BASE_HEX, NULL, 0x00,
- "Missing Packets"
+ "Missing Packets", HFILL
}
},
{ &hf_wtp_header_variable_part,
{ "Header: Variable part",
"wtp.header_variable_part",
FT_BYTES, BASE_HEX, NULL, 0x0,
- "Variable part of the header"
+ "Variable part of the header", HFILL
}
},
{ &hf_wtp_data,
{ "Data",
"wtp.header_data",
FT_BYTES, BASE_HEX, NULL, 0x0,
- "Data"
+ "Data", HFILL
}
},
};
proto_wtp = proto_register_protocol(
"Wireless Transaction Protocol", /* protocol name for use by ethereal */
"WTP", /* short version of name */
- "wap-wsp-wtp" /* Abbreviated protocol name, should Match IANA
+ "wap-wsp-wtp" /* Abbreviated protocol name, should Match IANA
< URL:http://www.isi.edu/in-notes/iana/assignments/port-numbers/ >
*/
);
/* Required function calls to register the header fields and subtrees used */
proto_register_field_array(proto_wtp, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
+
+ register_dissector("wtp", dissect_wtp_fromwap, proto_wtp);
+ register_dissector("wtp-udp", dissect_wtp_fromudp, proto_wtp);
};
void
proto_reg_handoff_wtp(void)
{
+ dissector_handle_t wtp_fromudp_handle;
+
/*
- * Get a handle for the IP WSP dissector.
+ * Get a handle for the connection-oriented WSP dissector - if WTP
+ * PDUs have data, it is WSP.
*/
- wsp_handle = find_dissector("wsp");
+ wsp_handle = find_dissector("wsp-co");
- dissector_add("udp.port", UDP_PORT_WTP_WSP, dissect_wtp, proto_wtp);
- /* dissector_add("udp.port", UDP_PORT_WTLS_WTP_WSP, dissect_wsp, proto_wsp); */
+ wtp_fromudp_handle = find_dissector("wtp-udp");
+ dissector_add("udp.port", UDP_PORT_WTP_WSP, wtp_fromudp_handle);
}