aboutsummaryrefslogtreecommitdiffstats
path: root/packet-sip.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2000-11-15 07:07:52 +0000
committerGuy Harris <guy@alum.mit.edu>2000-11-15 07:07:52 +0000
commit77ad89b12ddbec16981b495c60c895d463850c8f (patch)
treeb2bb48ca0cc103556fb5908f6cc9ea9a9f278581 /packet-sip.c
parent7c3fcbac34993a39ed0f3ed753bfd72a5bcf3c5a (diff)
Add a mechanism by which a dissector can be registered by name, another
dissector can get a "handle" for that dissector by name and then call that dissector through the handle. This allows dissectors that can't be called through a port table or a heuristic table to be called from other dissectors without directly referring to the dissector function - dynamically-loaded modules, under Windows, cannot directly call functions in the main program, and non-plugin dissectors are in the main program and thus cannot be called from plugin dissectors unless either 1) a pointer to the dissector is put in the Big Transfer Vector or 2) some other mechanism for getting a pointer to the dissector is provided. This mechanism could also support registering old-style dissectors and calling them from new-style dissectors without the new-style dissector having to do the argument translation itself (I didn't add support for registering old-style dissectors because I'd prefer to have people tvbuffify their code if they have to register a dissector...). It could also, in the future, perhaps support disabling of protocols; setting "pinfo->current_proto"; inside "call_dissector()" - and inside "{old_}dissector_try_port()" and "{old_"dissector_try_heuristic()" - allowing a pile of stuff that currently has to be done in every dissector be done by common code. (I have some ideas about how to do this, by having "proto_register_protocol()" take an abbreviation - of the sort that would be put in, for example, "pinfo->current_proto" - as an argument; having the calls to register dissectors take an index returned by "proto_register_protocol()" as an argument. The abbreviation could be used elsewhere as well, e.g. in the "Decoding" tab of the "Edit->Protocols" dialog box, and in a GUI for constructing protocol filters. Watch this space.) Make "dissect_sdp()" the first client of this mechanism; it's now static to "packet-sdp.c", and all dissectors that call it - including the MGCP plugin - now call it through a dissector handle fetched by "find_dissector()". (Next step - see if Ethereal can now compile on Windows as a result of this.) svn path=/trunk/; revision=2647
Diffstat (limited to 'packet-sip.c')
-rw-r--r--packet-sip.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/packet-sip.c b/packet-sip.c
index 40ecf5047e..771c6bef4b 100644
--- a/packet-sip.c
+++ b/packet-sip.c
@@ -7,7 +7,7 @@
*
* Copyright 2000, Heikki Vatiainen <hessu@cs.tut.fi>
*
- * $Id: packet-sip.c,v 1.4 2000/11/13 09:04:27 guy Exp $
+ * $Id: packet-sip.c,v 1.5 2000/11/15 07:07:44 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -40,7 +40,6 @@
#include <glib.h>
#include "packet.h"
-#include "packet-sdp.h"
#define TCP_PORT_SIP 5060
#define UDP_PORT_SIP 5060
@@ -66,6 +65,8 @@ static const char *sip_methods[] = {
static int sip_is_request(tvbuff_t *tvb, guint32 offset);
static gint sip_get_msg_offset(tvbuff_t *tvb, guint32 offset);
+static dissector_handle_t sdp_handle;
+
/* Code to actually dissect the packets */
static void dissect_sip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
@@ -120,7 +121,7 @@ static void dissect_sip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
if (tvb_length_remaining(tvb, offset) > 0) {
next_tvb = tvb_new_subset(tvb, offset, -1, -1);
- dissect_sdp(next_tvb, pinfo, tree);
+ call_dissector(sdp_handle, next_tvb, pinfo, tree);
}
return;
@@ -195,4 +196,9 @@ proto_reg_handoff_sip(void)
{
dissector_add("tcp.port", TCP_PORT_SIP, dissect_sip);
dissector_add("udp.port", UDP_PORT_SIP, dissect_sip);
+
+ /*
+ * Get a handle for the SDP dissector.
+ */
+ sdp_handle = find_dissector("sdp");
}