Don't base the protocol column setting in the WSP and WTP dissectors on

the port - instead, base it on whether the dissector was called directly
from UDP or called from another WAP dissector.

That way, if you explicitly say "decode this as WTP" because there was a
redirection (or if, in the future, the WSP dissector handles
redirections for you, although that won't handle the case of a capture
where the redirection wasn't captured), the column doesn't say "UDP", it
says the right thing.

Don't register the WTLS dissector by name - nobody calls it through a
handle.

Register the WTP dissector by name, as the WTLS dissector tries to get a
handle for it - although it doesn't actually call it, or the WSP
dissector, through a handle.

svn path=/trunk/; revision=3647
This commit is contained in:
Guy Harris 2001-07-03 09:53:22 +00:00
parent b1156c9e32
commit c4bd63678c
3 changed files with 67 additions and 42 deletions

View File

@ -2,7 +2,7 @@
*
* Routines to dissect WSP component of WAP traffic.
*
* $Id: packet-wsp.c,v 1.22 2001/06/18 22:27:30 guy Exp $
* $Id: packet-wsp.c,v 1.23 2001/07/03 09:53:21 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -434,7 +434,7 @@ static guint get_uintvar (tvbuff_t *, guint, guint);
/* Code to actually dissect the packets */
static void
dissect_wsp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
dissect_wsp_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
frame_data *fdata = pinfo->fd;
int offset = 0;
@ -463,20 +463,6 @@ dissect_wsp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
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. */
/* Display protocol type depending on the port */
if (check_col(fdata, COL_PROTOCOL))
{
switch ( pinfo->match_port )
{
case UDP_PORT_WSP:
col_set_str(fdata, COL_PROTOCOL, "WSP" );
break;
case UDP_PORT_WTLS_WSP:
col_set_str(fdata, COL_PROTOCOL, "WTLS+WSP" );
break;
}
}
/* Clear the Info column before we fetch anything from the packet */
if (check_col(fdata, COL_INFO))
{
@ -675,6 +661,30 @@ dissect_wsp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
}
}
/*
* Called directly from UDP.
* Put "WSP" into the "Protocol" column.
*/
static void
dissect_wsp_fromudp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
if (check_col(pinfo->fd, COL_PROTOCOL))
col_set_str(pinfo->fd, COL_PROTOCOL, "WSP" );
dissect_wsp_common(tvb, pinfo, tree);
}
/*
* Called from a higher-level WAP dissector.
* Leave the "Protocol" column alone - the dissector calling us should
* have set it.
*/
static void
dissect_wsp_fromwap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
dissect_wsp_common(tvb, pinfo, tree);
}
static void
add_uri (proto_tree *tree, tvbuff_t *tvb, guint URILenOffset, guint URIOffset)
{
@ -2130,7 +2140,7 @@ proto_register_wsp(void)
proto_register_field_array(proto_wsp, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
register_dissector("wsp", dissect_wsp, proto_wsp);
register_dissector("wsp", dissect_wsp_fromwap, proto_wsp);
};
void
@ -2142,7 +2152,7 @@ proto_reg_handoff_wsp(void)
wmlc_handle = find_dissector("wmlc"); /* Coming soon :) */
/* Only connection-less WSP has no previous handler */
dissector_add("udp.port", UDP_PORT_WSP, dissect_wsp, proto_wsp);
dissector_add("udp.port", UDP_PORT_WSP, dissect_wsp_fromudp, proto_wsp);
/* This dissector is also called from the WTP and WTLS dissectors */
}

View File

@ -2,7 +2,7 @@
*
* Routines to dissect WTLS component of WAP traffic.
*
* $Id: packet-wtls.c,v 1.9 2001/06/18 02:17:54 guy Exp $
* $Id: packet-wtls.c,v 1.10 2001/07/03 09:53:22 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -1631,8 +1631,6 @@ proto_register_wtls(void)
/* Required function calls to register the header fields and subtrees used */
proto_register_field_array(proto_wtls, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
register_dissector("wtls", dissect_wtls, proto_wtls);
}
void

View File

@ -2,7 +2,7 @@
*
* Routines to dissect WTP component of WAP traffic.
*
* $Id: packet-wtp.c,v 1.14 2001/06/18 02:17:54 guy Exp $
* $Id: packet-wtp.c,v 1.15 2001/07/03 09:53:22 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -180,7 +180,7 @@ static char retransmission_indicator(unsigned char octet);
/* 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;
@ -212,27 +212,10 @@ dissect_wtp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
int i;
tvbuff_t *wsp_tvb = NULL;
/* 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;
}
}
if (check_col(fdata, COL_INFO)) {
col_clear(fdata, COL_INFO);
};
@ -428,7 +411,7 @@ dissect_wtp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
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)
@ -443,6 +426,37 @@ dissect_wtp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *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" );
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" );
dissect_wtp_common(tvb, pinfo, tree);
}
static char pdu_type(unsigned char octet)
{
char ch = (octet >> 3) & 0x0F;
@ -639,6 +653,8 @@ proto_register_wtp(void)
/* 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);
};
void
@ -649,5 +665,6 @@ proto_reg_handoff_wtp(void)
*/
wsp_handle = find_dissector("wsp");
dissector_add("udp.port", UDP_PORT_WTP_WSP, dissect_wtp, proto_wtp);
dissector_add("udp.port", UDP_PORT_WTP_WSP, dissect_wtp_fromudp,
proto_wtp);
}