diff options
author | Anders Broman <anders.broman@ericsson.com> | 2004-09-18 21:28:28 +0000 |
---|---|---|
committer | Anders Broman <anders.broman@ericsson.com> | 2004-09-18 21:28:28 +0000 |
commit | 790e5244439a4cc3fb70cffc49fe3a444dda3994 (patch) | |
tree | 2c5cda35b133a0db7ec213a9d5134d9655700bf4 /plugins/megaco/packet-megaco.c | |
parent | af7b483f6ceab2f851a99a72b664467b2e6e4223 (diff) | |
download | wireshark-790e5244439a4cc3fb70cffc49fe3a444dda3994.tar.gz wireshark-790e5244439a4cc3fb70cffc49fe3a444dda3994.tar.bz2 wireshark-790e5244439a4cc3fb70cffc49fe3a444dda3994.zip |
Fix dissection of MEGACO over TCP, there will be a TPKT header included.
svn path=/trunk/; revision=12043
Diffstat (limited to 'plugins/megaco/packet-megaco.c')
-rw-r--r-- | plugins/megaco/packet-megaco.c | 63 |
1 files changed, 49 insertions, 14 deletions
diff --git a/plugins/megaco/packet-megaco.c b/plugins/megaco/packet-megaco.c index 9dd33514e9..a8ab911bd8 100644 --- a/plugins/megaco/packet-megaco.c +++ b/plugins/megaco/packet-megaco.c @@ -11,6 +11,10 @@ * Christoph Wiest, 2003/06/28 * Modified 2003 by Christoph Wiest * <ch.wiest@tesionmail.de> +* Modifyed 2004 by Anders Broman +* <anders.broman@ericsson.com> +* To handle TPKT headers if over TCP +* * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> * Copyright 1999 Gerald Combs @@ -49,6 +53,7 @@ #include "prefs.h" #include <epan/strutil.h> #include "sctpppids.h" +#include <epan/dissectors/packet-tpkt.h> #include "plugins/plugin_api_defs.h" @@ -125,6 +130,8 @@ static int ett_megaco_signalsdescriptor = -1; static int ett_megaco_requestedsignal = -1; static int ett_megaco_h245 = -1; +static dissector_handle_t megaco_text_handle; + /* * Here are the global variables associated with @@ -206,16 +213,42 @@ static void dissect_megaco_Packagesdescriptor(tvbuff_t *tvb, proto_tree *tree, gint tvb_next_offset, gint tvb_current_offset); static void tvb_raw_text_add(tvbuff_t *tvb, proto_tree *tree); +static void +dissect_megaco_text(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree); static dissector_handle_t sdp_handle; static dissector_handle_t h245_handle; static proto_tree *top_tree; - /* -* dissect_megaco_text - The dissector for the MEGACO Protocol, using -* text encoding. -*/ - + * dissect_megaco_text over TCP, there will be a TPKT header there + * + */ +static void dissect_megaco_text_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) +{ + int lv_tpkt_len; + + /* This code is copied from the Q.931 dissector, some parts skipped. + * Check whether this looks like a TPKT-encapsulated + * MEGACO packet. + * + * The minimum length of a MEGACO message is 6?: + * Re-assembly ? + */ + lv_tpkt_len = is_tpkt(tvb, 6); + if (lv_tpkt_len == -1) { + /* + * It's not a TPKT packet; + * Is in MEGACO ? + */ + dissect_megaco_text(tvb, pinfo, tree); + } + dissect_tpkt_encap(tvb, pinfo, tree, TRUE, + megaco_text_handle); +} +/* + * dissect_megaco_text - The dissector for the MEGACO Protocol, using + * text encoding. + */ static void dissect_megaco_text(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { @@ -255,12 +288,11 @@ dissect_megaco_text(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) * binary encodings. Bugfix add skipping of leading spaces. */ tvb_offset = tvb_skip_wsp(tvb, tvb_offset); - /* Quick fix for MEGACO not following the RFC, hopfully not breaking any thing - * If any of the first 5 chars is junk, skip them.Only works for M(EGACO) with capital m ( Hmm) + /* Quick fix for MEGACO not following the RFC, hopfully not breaking any thing + * Turned out to be TPKT in case of TCP, added some code to handle that. + * + * tvb_offset = tvb_find_guint8(tvb, tvb_offset, 5, 'M'); */ - tvb_next_offset = tvb_find_guint8(tvb, tvb_offset, 5, 'M'); - if ( tvb_next_offset != -1 ) - tvb_offset = tvb_next_offset; if(!tvb_get_nstringz0(tvb,tvb_offset,sizeof(word),word)) return; if (strncasecmp(word, "MEGACO", 6) != 0 && tvb_get_guint8(tvb, tvb_offset ) != '!'){ return; @@ -2619,7 +2651,7 @@ void proto_reg_handoff_megaco(void) { static int megaco_prefs_initialized = FALSE; - static dissector_handle_t megaco_text_handle; + static dissector_handle_t megaco_text_tcp_handle; sdp_handle = find_dissector("sdp"); h245_handle = find_dissector("h245dg"); @@ -2627,13 +2659,16 @@ proto_reg_handoff_megaco(void) if (!megaco_prefs_initialized) { megaco_text_handle = create_dissector_handle(dissect_megaco_text, proto_megaco); + megaco_text_tcp_handle = create_dissector_handle(dissect_megaco_text_tcp, + proto_megaco); + megaco_prefs_initialized = TRUE; } else { - dissector_delete("tcp.port", txt_tcp_port, megaco_text_handle); + dissector_delete("tcp.port", txt_tcp_port, megaco_text_tcp_handle); dissector_delete("udp.port", txt_udp_port, megaco_text_handle); #if 0 - dissector_delete("tcp.port", bin_tcp_port, megaco_bin_handle); + dissector_delete("tcp.port", bin_tcp_port, megaco_text_tcp_handle); dissector_delete("udp.port", bin_udp_port, megaco_bin_handle); #endif } @@ -2648,7 +2683,7 @@ proto_reg_handoff_megaco(void) bin_udp_port = global_megaco_bin_udp_port; #endif - dissector_add("tcp.port", global_megaco_txt_tcp_port, megaco_text_handle); + dissector_add("tcp.port", global_megaco_txt_tcp_port, megaco_text_tcp_handle); dissector_add("udp.port", global_megaco_txt_udp_port, megaco_text_handle); #if 0 dissector_add("tcp.port", global_megaco_bin_tcp_port, megaco_bin_handle); |