2000-11-09 10:04:48 +00:00
|
|
|
/* packet-mgcp.c
|
|
|
|
* Routines for mgcp packet disassembly
|
|
|
|
* RFC 2705
|
|
|
|
*
|
2003-12-05 09:25:41 +00:00
|
|
|
* $Id: packet-mgcp.c,v 1.43 2003/12/05 09:25:41 guy Exp $
|
2002-08-28 20:41:00 +00:00
|
|
|
*
|
2000-11-09 10:04:48 +00:00
|
|
|
* Copyright (c) 2000 by Ed Warnicke <hagbard@physics.rutgers.edu>
|
|
|
|
*
|
|
|
|
* Ethereal - Network traffic analyzer
|
2001-12-03 04:00:26 +00:00
|
|
|
* By Gerald Combs <gerald@ethereal.com>
|
2000-11-09 10:04:48 +00:00
|
|
|
* Copyright 1999 Gerald Combs
|
2001-12-03 04:00:26 +00:00
|
|
|
*
|
2000-11-09 10:04:48 +00:00
|
|
|
* 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
|
|
|
|
|
Add a Makefile.nmake for the MGCP plugin, and update
"plugins/Makefile.nmake" to build that plugin.
Add to the table of routines callable from plugins
"old_dissector_add()", "old_dissect_data()", and
"proto_is_protocol_enabled()", so that the Gryphon dissector can build
on Windows.
Move the includes of "plugins/plugin_api.h" and "moduleinfo.h" before
all the other includes, except for "config.h", in "plugin-mgcp.c", to
match what the Gryphon dissector does; "plugins_api.h" must be included
before any of the routines whose names it #defines in order for the
plugin to build on Windows. (It still doesn't build on Windows, as
still more routines need to be added to the table of routines callable
from plugins, but tomorrow is another day. Making libethereal a DLL may
obviate the need for that table, *if* all the routines called from a
plugin are in libethereal, as I think routines in a DLL, even a
run-time-loaded DLL, can call routines from another DLL as long as those
routines are exported from the other DLL.)
svn path=/trunk/; revision=2622
2000-11-12 11:08:46 +00:00
|
|
|
#include "plugins/plugin_api.h"
|
|
|
|
|
|
|
|
#include "moduleinfo.h"
|
|
|
|
|
2000-11-09 10:04:48 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2000-11-29 09:49:30 +00:00
|
|
|
#include <gmodule.h>
|
2000-11-09 10:04:48 +00:00
|
|
|
#include <ctype.h>
|
|
|
|
#include <time.h>
|
|
|
|
#include <string.h>
|
2002-01-21 07:37:49 +00:00
|
|
|
#include <epan/packet.h>
|
|
|
|
#include <epan/resolv.h>
|
2000-11-09 10:04:48 +00:00
|
|
|
#include "prefs.h"
|
2002-01-21 07:37:49 +00:00
|
|
|
#include <epan/strutil.h>
|
2003-03-06 09:01:47 +00:00
|
|
|
#include <epan/conversation.h>
|
|
|
|
#include "packet-mgcp.h"
|
2000-11-09 10:04:48 +00:00
|
|
|
|
2001-10-31 10:40:58 +00:00
|
|
|
#include "plugins/plugin_api_defs.h"
|
|
|
|
|
2003-09-05 07:44:50 +00:00
|
|
|
#ifndef ENABLE_STATIC
|
2000-11-29 09:49:30 +00:00
|
|
|
G_MODULE_EXPORT const gchar version[] = VERSION;
|
2001-07-08 21:51:34 +00:00
|
|
|
#endif
|
2000-11-09 10:04:48 +00:00
|
|
|
|
|
|
|
#define TCP_PORT_MGCP_GATEWAY 2427
|
|
|
|
#define UDP_PORT_MGCP_GATEWAY 2427
|
|
|
|
#define TCP_PORT_MGCP_CALLAGENT 2727
|
|
|
|
#define UDP_PORT_MGCP_CALLAGENT 2727
|
|
|
|
|
2001-07-04 22:01:22 +00:00
|
|
|
void proto_reg_handoff_mgcp(void);
|
2000-11-09 10:04:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Define the mgcp proto */
|
|
|
|
static int proto_mgcp = -1;
|
|
|
|
|
|
|
|
/* Define many many headers for mgcp */
|
|
|
|
static int hf_mgcp_req = -1;
|
|
|
|
static int hf_mgcp_req_verb = -1;
|
|
|
|
static int hf_mgcp_req_endpoint = -1;
|
2003-03-06 09:01:47 +00:00
|
|
|
static int hf_mgcp_req_frame = -1;
|
2000-11-09 10:04:48 +00:00
|
|
|
static int hf_mgcp_rsp = -1;
|
2003-03-06 09:01:47 +00:00
|
|
|
static int hf_mgcp_rsp_frame = -1;
|
|
|
|
static int hf_mgcp_time = -1;
|
2000-11-09 10:04:48 +00:00
|
|
|
static int hf_mgcp_transid = -1;
|
|
|
|
static int hf_mgcp_version = -1;
|
|
|
|
static int hf_mgcp_rsp_rspcode = -1;
|
|
|
|
static int hf_mgcp_rsp_rspstring = -1;
|
|
|
|
static int hf_mgcp_param_rspack = -1;
|
|
|
|
static int hf_mgcp_param_bearerinfo = -1;
|
|
|
|
static int hf_mgcp_param_callid = -1;
|
|
|
|
static int hf_mgcp_param_connectionid = -1;
|
|
|
|
static int hf_mgcp_param_secondconnectionid = -1;
|
|
|
|
static int hf_mgcp_param_notifiedentity = -1;
|
|
|
|
static int hf_mgcp_param_requestid = -1;
|
|
|
|
static int hf_mgcp_param_localconnoptions = -1;
|
|
|
|
static int hf_mgcp_param_connectionmode = -1;
|
|
|
|
static int hf_mgcp_param_reqevents = -1;
|
|
|
|
static int hf_mgcp_param_restartmethod = -1;
|
|
|
|
static int hf_mgcp_param_restartdelay = -1;
|
|
|
|
static int hf_mgcp_param_signalreq = -1;
|
|
|
|
static int hf_mgcp_param_digitmap = -1;
|
|
|
|
static int hf_mgcp_param_observedevent = -1;
|
|
|
|
static int hf_mgcp_param_connectionparam = -1;
|
|
|
|
static int hf_mgcp_param_reasoncode = -1;
|
|
|
|
static int hf_mgcp_param_eventstates = -1;
|
|
|
|
static int hf_mgcp_param_specificendpoint = -1;
|
|
|
|
static int hf_mgcp_param_secondendpointid = -1;
|
|
|
|
static int hf_mgcp_param_reqinfo = -1;
|
|
|
|
static int hf_mgcp_param_quarantinehandling = -1;
|
|
|
|
static int hf_mgcp_param_detectedevents = -1;
|
|
|
|
static int hf_mgcp_param_capabilities = -1;
|
|
|
|
static int hf_mgcp_param_extention = -1;
|
|
|
|
static int hf_mgcp_param_invalid = -1;
|
2001-03-04 00:43:56 +00:00
|
|
|
static int hf_mgcp_messagecount = -1;
|
2003-03-06 09:01:47 +00:00
|
|
|
static int hf_mgcp_dup = -1;
|
|
|
|
static int hf_mgcp_req_dup = -1;
|
|
|
|
static int hf_mgcp_rsp_dup = -1;
|
2000-11-09 10:04:48 +00:00
|
|
|
|
2002-08-28 20:41:00 +00:00
|
|
|
/*
|
2000-11-09 10:04:48 +00:00
|
|
|
* Define the trees for mgcp
|
|
|
|
* We need one for MGCP itself and one for the MGCP paramters
|
|
|
|
*/
|
|
|
|
static int ett_mgcp = -1;
|
|
|
|
static int ett_mgcp_param = -1;
|
|
|
|
|
2003-03-06 09:01:47 +00:00
|
|
|
/*
|
|
|
|
* Define the tap for mgcp
|
|
|
|
*/
|
|
|
|
static int mgcp_tap = -1;
|
2000-11-09 10:04:48 +00:00
|
|
|
|
2002-08-28 20:41:00 +00:00
|
|
|
/*
|
|
|
|
* Here are the global variables associated with
|
2000-11-09 10:04:48 +00:00
|
|
|
* the various user definable characteristics of the dissection
|
|
|
|
*
|
|
|
|
* MGCP has two kinds of "agents", gateways and callagents. Callagents
|
|
|
|
* control gateways in a master/slave sort of arrangement. Since gateways
|
2002-08-28 20:41:00 +00:00
|
|
|
* and callagents have different well known ports and could both
|
|
|
|
* operate under either udp or tcp we have rather a lot of port info to
|
2000-11-09 10:04:48 +00:00
|
|
|
* specify.
|
|
|
|
*
|
|
|
|
* global_mgcp_raw_text determines whether we are going to display
|
|
|
|
* the raw text of the mgcp message, much like the HTTP dissector does.
|
|
|
|
*
|
|
|
|
* global_mgcp_dissect_tree determines whether we are going to display
|
|
|
|
* a detailed tree that expresses a somewhat more semantically meaningful
|
|
|
|
* decode.
|
|
|
|
*/
|
|
|
|
static int global_mgcp_gateway_tcp_port = TCP_PORT_MGCP_GATEWAY;
|
|
|
|
static int global_mgcp_gateway_udp_port = UDP_PORT_MGCP_GATEWAY;
|
|
|
|
static int global_mgcp_callagent_tcp_port = TCP_PORT_MGCP_CALLAGENT;
|
|
|
|
static int global_mgcp_callagent_udp_port = UDP_PORT_MGCP_CALLAGENT;
|
|
|
|
static gboolean global_mgcp_raw_text = FALSE;
|
|
|
|
static gboolean global_mgcp_dissect_tree = TRUE;
|
2001-03-04 00:43:56 +00:00
|
|
|
static gboolean global_mgcp_message_count = FALSE;
|
2000-11-09 10:04:48 +00:00
|
|
|
|
|
|
|
/*
|
2002-08-28 20:41:00 +00:00
|
|
|
* Variables to allow for proper deletion of dissector registration when
|
|
|
|
* the user changes port from the gui.
|
2000-11-09 10:04:48 +00:00
|
|
|
*/
|
|
|
|
static int gateway_tcp_port = 0;
|
|
|
|
static int gateway_udp_port = 0;
|
|
|
|
static int callagent_tcp_port = 0;
|
|
|
|
static int callagent_udp_port = 0;
|
|
|
|
|
|
|
|
/* Some basic utility functions that are specific to this dissector */
|
2002-08-28 20:41:00 +00:00
|
|
|
static gboolean is_mgcp_verb(tvbuff_t *tvb, gint offset, gint maxlength);
|
2000-11-09 10:04:48 +00:00
|
|
|
static gboolean is_mgcp_rspcode(tvbuff_t *tvb, gint offset, gint maxlength);
|
2002-08-28 20:41:00 +00:00
|
|
|
static gint tvb_parse_param(tvbuff_t *tvb, gint offset, gint maxlength,
|
2000-11-09 10:04:48 +00:00
|
|
|
int** hf);
|
|
|
|
|
2002-08-28 20:41:00 +00:00
|
|
|
/*
|
|
|
|
* The various functions that either dissect some
|
|
|
|
* subpart of MGCP. These aren't really proto dissectors but they
|
2000-11-09 10:04:48 +00:00
|
|
|
* are written in the same style.
|
2002-08-28 20:41:00 +00:00
|
|
|
*/
|
|
|
|
static void dissect_mgcp_message(tvbuff_t *tvb, packet_info *pinfo,
|
2001-03-04 03:38:20 +00:00
|
|
|
proto_tree *tree,proto_tree *mgcp_tree, proto_tree *ti);
|
2003-03-06 09:01:47 +00:00
|
|
|
static void dissect_mgcp_firstline(tvbuff_t *tvb, packet_info *pinfo,
|
|
|
|
proto_tree *tree, mgcp_info_t *mi);
|
2002-08-28 20:41:00 +00:00
|
|
|
static void dissect_mgcp_params(tvbuff_t *tvb,
|
2000-11-09 10:04:48 +00:00
|
|
|
proto_tree *tree);
|
2002-04-30 10:37:37 +00:00
|
|
|
static void mgcp_raw_text_add(tvbuff_t *tvb,
|
2000-11-09 10:04:48 +00:00
|
|
|
proto_tree *tree);
|
|
|
|
|
2002-08-28 20:41:00 +00:00
|
|
|
/*
|
|
|
|
* Some functions which should be moved to a library
|
|
|
|
* as I think that people may find them of general usefulness.
|
2000-11-09 10:04:48 +00:00
|
|
|
*/
|
|
|
|
static gint tvb_skip_wsp(tvbuff_t* tvb, gint offset, gint maxlength);
|
2000-11-21 05:38:51 +00:00
|
|
|
static gint tvb_find_null_line(tvbuff_t* tvb, gint offset, gint len,
|
2002-08-28 20:41:00 +00:00
|
|
|
gint* next_offset);
|
|
|
|
static gint tvb_find_dot_line(tvbuff_t* tvb, gint offset,
|
2001-03-04 00:43:56 +00:00
|
|
|
gint len, gint* next_offset);
|
2000-11-10 04:58:29 +00:00
|
|
|
static gboolean is_rfc2234_alpha(guint8 c);
|
2000-11-09 10:04:48 +00:00
|
|
|
|
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
2000-11-15 07:07:52 +00:00
|
|
|
static dissector_handle_t sdp_handle;
|
|
|
|
|
2003-03-06 09:01:47 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Init Hash table stuff
|
|
|
|
*/
|
2003-04-16 07:25:12 +00:00
|
|
|
|
2003-03-06 09:01:47 +00:00
|
|
|
typedef struct _mgcp_call_info_key {
|
|
|
|
guint32 transid;
|
|
|
|
conversation_t *conversation;
|
|
|
|
} mgcp_call_info_key;
|
|
|
|
|
|
|
|
static GMemChunk *mgcp_call_info_key_chunk;
|
|
|
|
|
|
|
|
static GMemChunk *mgcp_call_info_value_chunk;
|
|
|
|
|
|
|
|
static GHashTable *mgcp_calls;
|
|
|
|
|
|
|
|
/* compare 2 keys */
|
|
|
|
static gint
|
|
|
|
mgcp_call_equal(gconstpointer k1, gconstpointer k2)
|
|
|
|
{
|
|
|
|
const mgcp_call_info_key* key1 = (const mgcp_call_info_key*) k1;
|
|
|
|
const mgcp_call_info_key* key2 = (const mgcp_call_info_key*) k2;
|
|
|
|
|
|
|
|
return (key1->transid == key2->transid &&
|
|
|
|
key1->conversation == key2->conversation);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* calculate a hash key */
|
|
|
|
static guint
|
|
|
|
mgcp_call_hash(gconstpointer k)
|
|
|
|
{
|
|
|
|
const mgcp_call_info_key* key = (const mgcp_call_info_key*) k;
|
|
|
|
|
|
|
|
return key->transid + (guint32)(key->conversation);
|
|
|
|
}
|
|
|
|
|
2000-11-09 10:04:48 +00:00
|
|
|
/*
|
|
|
|
* dissect_mgcp - The dissector for the Media Gateway Control Protocol
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
|
|
|
dissect_mgcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|
|
|
{
|
|
|
|
gint sectionlen;
|
2001-03-04 00:43:56 +00:00
|
|
|
guint32 num_messages;
|
2000-11-09 10:04:48 +00:00
|
|
|
gint tvb_sectionend,tvb_sectionbegin, tvb_len, tvb_current_len;
|
2001-03-04 03:38:20 +00:00
|
|
|
proto_tree *mgcp_tree, *ti;
|
2000-11-09 10:04:48 +00:00
|
|
|
|
2000-11-21 05:38:51 +00:00
|
|
|
/* Initialize variables */
|
2000-11-09 10:04:48 +00:00
|
|
|
tvb_sectionend = 0;
|
|
|
|
tvb_sectionbegin = tvb_sectionend;
|
|
|
|
sectionlen = 0;
|
|
|
|
tvb_len = tvb_length(tvb);
|
|
|
|
tvb_current_len = tvb_len;
|
2001-03-04 00:43:56 +00:00
|
|
|
num_messages = 0;
|
2001-03-04 03:38:20 +00:00
|
|
|
mgcp_tree = NULL;
|
|
|
|
ti = NULL;
|
2002-08-28 20:41:00 +00:00
|
|
|
|
2001-01-22 08:54:08 +00:00
|
|
|
/*
|
|
|
|
* Set the columns now, so that they'll be set correctly if we throw
|
|
|
|
* an exception. We can set them later as well....
|
|
|
|
*/
|
2001-12-10 00:26:21 +00:00
|
|
|
if (check_col(pinfo->cinfo, COL_PROTOCOL))
|
|
|
|
col_add_str(pinfo->cinfo, COL_PROTOCOL, "MGCP");
|
|
|
|
if (check_col(pinfo->cinfo, COL_INFO))
|
|
|
|
col_clear(pinfo->cinfo, COL_INFO);
|
2001-01-22 08:54:08 +00:00
|
|
|
|
2002-08-28 20:41:00 +00:00
|
|
|
/*
|
|
|
|
* Check to see whether we're really dealing with MGCP by looking
|
2000-11-21 05:38:51 +00:00
|
|
|
* for a valid MGCP verb or response code. This isn't infallible,
|
|
|
|
* but its cheap and its better than nothing.
|
2000-11-09 10:04:48 +00:00
|
|
|
*/
|
|
|
|
if(is_mgcp_verb(tvb,0,tvb_len) || is_mgcp_rspcode(tvb,0,tvb_len)){
|
2003-12-05 09:25:41 +00:00
|
|
|
/*
|
|
|
|
* Loop through however many mgcp messages may be stuck in
|
|
|
|
* this packet using piggybacking
|
|
|
|
*/
|
|
|
|
do{
|
|
|
|
num_messages++;
|
|
|
|
if(tree){
|
|
|
|
/* Create out mgcp subtree */
|
|
|
|
ti = proto_tree_add_item(tree,proto_mgcp,tvb,0,0, FALSE);
|
|
|
|
mgcp_tree = proto_item_add_subtree(ti, ett_mgcp);
|
|
|
|
}
|
2000-11-09 10:04:48 +00:00
|
|
|
|
2003-12-05 09:25:41 +00:00
|
|
|
sectionlen = tvb_find_dot_line(tvb, tvb_sectionbegin, -1,
|
|
|
|
&tvb_sectionend);
|
|
|
|
if( sectionlen != -1){
|
|
|
|
dissect_mgcp_message(tvb_new_subset(tvb, tvb_sectionbegin,
|
|
|
|
sectionlen, -1),
|
|
|
|
pinfo, tree, mgcp_tree,ti);
|
|
|
|
tvb_sectionbegin = tvb_sectionend;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
break;
|
2001-03-04 03:38:20 +00:00
|
|
|
}
|
2003-12-05 09:25:41 +00:00
|
|
|
} while(tvb_sectionend < tvb_len );
|
|
|
|
if(mgcp_tree){
|
|
|
|
proto_tree_add_uint_hidden(mgcp_tree, hf_mgcp_messagecount, tvb,
|
|
|
|
0 ,0 , num_messages);
|
2002-08-28 20:41:00 +00:00
|
|
|
}
|
2001-03-04 00:43:56 +00:00
|
|
|
|
2002-08-28 20:41:00 +00:00
|
|
|
/*
|
|
|
|
* Add our column information we do this after dissecting SDP
|
2001-03-04 00:43:56 +00:00
|
|
|
* in order to prevent the column info changing to reflect the SDP.
|
2003-12-05 09:25:41 +00:00
|
|
|
* XXX - can we do this with a fence?
|
2001-03-04 00:43:56 +00:00
|
|
|
*/
|
|
|
|
tvb_sectionbegin = 0;
|
2001-12-10 00:26:21 +00:00
|
|
|
if (check_col(pinfo->cinfo, COL_PROTOCOL)){
|
2001-03-04 00:43:56 +00:00
|
|
|
if( global_mgcp_message_count == TRUE ){
|
|
|
|
if(num_messages > 1){
|
2001-12-10 00:26:21 +00:00
|
|
|
col_add_fstr(pinfo->cinfo, COL_PROTOCOL, "MGCP (%i messages)",num_messages);
|
2001-03-04 00:43:56 +00:00
|
|
|
}
|
|
|
|
else {
|
2001-12-10 00:26:21 +00:00
|
|
|
col_add_fstr(pinfo->cinfo, COL_PROTOCOL, "MGCP (%i message)",num_messages);
|
2001-03-04 00:43:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2001-12-10 00:26:21 +00:00
|
|
|
col_add_str(pinfo->cinfo, COL_PROTOCOL, "MGCP");
|
2001-03-04 00:43:56 +00:00
|
|
|
}
|
|
|
|
}
|
2002-08-28 20:41:00 +00:00
|
|
|
|
2001-12-10 00:26:21 +00:00
|
|
|
if (check_col(pinfo->cinfo, COL_INFO) ){
|
2001-03-04 00:43:56 +00:00
|
|
|
sectionlen = tvb_find_line_end(tvb, tvb_sectionbegin,-1,
|
2002-07-17 06:55:29 +00:00
|
|
|
&tvb_sectionend,FALSE);
|
2003-03-06 09:01:47 +00:00
|
|
|
col_prepend_fstr(pinfo->cinfo, COL_INFO, "%s",
|
2001-03-04 00:43:56 +00:00
|
|
|
tvb_format_text(tvb,tvb_sectionbegin,sectionlen));
|
2002-08-28 20:41:00 +00:00
|
|
|
}
|
|
|
|
}
|
2001-03-04 00:43:56 +00:00
|
|
|
}
|
|
|
|
|
2002-08-28 20:41:00 +00:00
|
|
|
static void
|
|
|
|
dissect_mgcp_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
|
2001-03-04 03:38:20 +00:00
|
|
|
proto_tree *mgcp_tree, proto_tree *ti){
|
2001-03-04 00:43:56 +00:00
|
|
|
|
|
|
|
/* Declare variables */
|
|
|
|
gint sectionlen;
|
|
|
|
gint tvb_sectionend,tvb_sectionbegin, tvb_len, tvb_current_len;
|
|
|
|
tvbuff_t *next_tvb;
|
2003-03-06 09:01:47 +00:00
|
|
|
static mgcp_info_t mi;
|
2003-04-16 07:25:12 +00:00
|
|
|
|
2001-03-04 00:43:56 +00:00
|
|
|
/* Initialize variables */
|
|
|
|
tvb_sectionend = 0;
|
|
|
|
tvb_sectionbegin = tvb_sectionend;
|
|
|
|
sectionlen = 0;
|
|
|
|
tvb_len = tvb_length(tvb);
|
|
|
|
tvb_current_len = tvb_len;
|
|
|
|
|
2002-08-28 20:41:00 +00:00
|
|
|
/*
|
|
|
|
* Check to see whether we're really dealing with MGCP by looking
|
2001-03-04 00:43:56 +00:00
|
|
|
* for a valid MGCP verb or response code. This isn't infallible,
|
|
|
|
* but its cheap and its better than nothing.
|
|
|
|
*/
|
|
|
|
if(is_mgcp_verb(tvb,0,tvb_len) || is_mgcp_rspcode(tvb,0,tvb_len)){
|
2003-12-05 09:25:41 +00:00
|
|
|
/* dissect first line */
|
|
|
|
tvb_sectionbegin = 0;
|
|
|
|
tvb_current_len = tvb_len;
|
|
|
|
tvb_sectionend = tvb_sectionbegin;
|
|
|
|
sectionlen = tvb_find_line_end(tvb,0,-1,&tvb_sectionend,FALSE);
|
|
|
|
if( sectionlen > 0){
|
|
|
|
dissect_mgcp_firstline(tvb_new_subset(tvb, tvb_sectionbegin,
|
|
|
|
sectionlen,-1), pinfo,
|
|
|
|
mgcp_tree, &mi);
|
|
|
|
}
|
|
|
|
tvb_sectionbegin = tvb_sectionend;
|
|
|
|
|
|
|
|
/* dissect params */
|
|
|
|
if(tvb_sectionbegin < tvb_len){
|
|
|
|
sectionlen = tvb_find_null_line(tvb, tvb_sectionbegin, -1,
|
|
|
|
&tvb_sectionend);
|
|
|
|
dissect_mgcp_params(tvb_new_subset(tvb, tvb_sectionbegin,
|
|
|
|
sectionlen, -1),
|
|
|
|
mgcp_tree);
|
2000-11-21 05:38:51 +00:00
|
|
|
tvb_sectionbegin = tvb_sectionend;
|
2003-12-05 09:25:41 +00:00
|
|
|
}
|
2000-11-21 05:38:51 +00:00
|
|
|
|
2003-12-05 09:25:41 +00:00
|
|
|
/* set the mgcp payload length correctly so we don't include the
|
|
|
|
* encapsulated SDP
|
|
|
|
*/
|
|
|
|
sectionlen = tvb_sectionend;
|
|
|
|
proto_item_set_len(ti,sectionlen);
|
2000-11-09 10:04:48 +00:00
|
|
|
|
2003-12-05 09:25:41 +00:00
|
|
|
/* Display the raw text of the mgcp message if desired */
|
2000-11-09 10:04:48 +00:00
|
|
|
|
2003-12-05 09:25:41 +00:00
|
|
|
/* Do we want to display the raw text of our MGCP packet? */
|
|
|
|
if(global_mgcp_raw_text) {
|
|
|
|
if (tree)
|
2003-09-02 21:26:22 +00:00
|
|
|
mgcp_raw_text_add(tvb, mgcp_tree);
|
2003-12-05 09:25:41 +00:00
|
|
|
}
|
2000-11-09 10:04:48 +00:00
|
|
|
|
2003-12-05 09:25:41 +00:00
|
|
|
/* dissect sdp payload */
|
|
|
|
if( tvb_sectionend < tvb_len){
|
|
|
|
next_tvb = tvb_new_subset(tvb, tvb_sectionend, -1, -1);
|
|
|
|
call_dissector(sdp_handle, next_tvb, pinfo, tree);
|
2000-11-09 10:04:48 +00:00
|
|
|
}
|
2001-03-04 00:43:56 +00:00
|
|
|
}
|
2000-11-09 10:04:48 +00:00
|
|
|
}
|
|
|
|
|
2001-03-04 00:43:56 +00:00
|
|
|
|
2002-08-28 20:41:00 +00:00
|
|
|
/*
|
|
|
|
* Add the raw text of the message to the dissect tree if appropriate
|
2002-04-30 10:37:37 +00:00
|
|
|
* preferences are specified.
|
2000-11-09 10:04:48 +00:00
|
|
|
*/
|
|
|
|
|
2002-04-30 10:37:37 +00:00
|
|
|
static void mgcp_raw_text_add(tvbuff_t *tvb, proto_tree *tree){
|
2000-11-09 10:04:48 +00:00
|
|
|
|
2000-11-21 05:38:51 +00:00
|
|
|
gint tvb_linebegin,tvb_lineend,tvb_len,linelen;
|
2000-11-09 10:04:48 +00:00
|
|
|
|
|
|
|
tvb_linebegin = 0;
|
2000-11-21 05:38:51 +00:00
|
|
|
tvb_len = tvb_length(tvb);
|
|
|
|
|
2001-03-04 00:43:56 +00:00
|
|
|
do {
|
2002-07-17 06:55:29 +00:00
|
|
|
tvb_find_line_end(tvb,tvb_linebegin,-1,&tvb_lineend,FALSE);
|
2000-11-21 05:38:51 +00:00
|
|
|
linelen = tvb_lineend - tvb_linebegin;
|
2002-08-28 20:41:00 +00:00
|
|
|
proto_tree_add_text(tree, tvb, tvb_linebegin, linelen,
|
|
|
|
"%s", tvb_format_text(tvb,tvb_linebegin,
|
2000-11-21 05:38:51 +00:00
|
|
|
linelen));
|
|
|
|
tvb_linebegin = tvb_lineend;
|
2001-03-04 00:43:56 +00:00
|
|
|
} while ( tvb_lineend < tvb_len );
|
2000-11-09 10:04:48 +00:00
|
|
|
}
|
|
|
|
|
2003-03-06 09:01:47 +00:00
|
|
|
/* Discard and init any state we've saved */
|
|
|
|
|
|
|
|
static void
|
|
|
|
mgcp_init_protocol(void)
|
|
|
|
{
|
|
|
|
if (mgcp_calls != NULL) {
|
|
|
|
g_hash_table_destroy(mgcp_calls);
|
|
|
|
mgcp_calls = NULL;
|
|
|
|
}
|
|
|
|
if (mgcp_call_info_key_chunk != NULL) {
|
|
|
|
g_mem_chunk_destroy(mgcp_call_info_key_chunk);
|
|
|
|
mgcp_call_info_key_chunk = NULL;
|
|
|
|
}
|
|
|
|
if (mgcp_call_info_value_chunk != NULL) {
|
|
|
|
g_mem_chunk_destroy(mgcp_call_info_value_chunk);
|
|
|
|
mgcp_call_info_value_chunk = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
mgcp_calls = g_hash_table_new(mgcp_call_hash, mgcp_call_equal);
|
|
|
|
mgcp_call_info_key_chunk = g_mem_chunk_new("call_info_key_chunk",
|
|
|
|
sizeof(mgcp_call_info_key),
|
|
|
|
200 * sizeof(mgcp_call_info_key),
|
|
|
|
G_ALLOC_ONLY);
|
|
|
|
mgcp_call_info_value_chunk = g_mem_chunk_new("call_info_value_chunk",
|
|
|
|
sizeof(mgcp_call_t),
|
|
|
|
200 * sizeof(mgcp_call_t),
|
2003-04-16 07:25:12 +00:00
|
|
|
G_ALLOC_ONLY);
|
2003-03-06 09:01:47 +00:00
|
|
|
}
|
|
|
|
|
2000-11-09 10:04:48 +00:00
|
|
|
/* Register all the bits needed with the filtering engine */
|
|
|
|
|
2002-08-28 20:41:00 +00:00
|
|
|
void
|
2000-11-09 10:04:48 +00:00
|
|
|
proto_register_mgcp(void)
|
|
|
|
{
|
|
|
|
static hf_register_info hf[] = {
|
|
|
|
{ &hf_mgcp_req,
|
2002-08-28 20:41:00 +00:00
|
|
|
{ "Request", "mgcp.req", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
|
2001-06-18 02:18:27 +00:00
|
|
|
"True if MGCP request", HFILL }},
|
2000-11-09 10:04:48 +00:00
|
|
|
{ &hf_mgcp_rsp,
|
2002-08-28 20:41:00 +00:00
|
|
|
{ "Response", "mgcp.rsp", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
|
2001-06-18 02:18:27 +00:00
|
|
|
"TRUE if MGCP response", HFILL }},
|
2003-04-16 07:25:12 +00:00
|
|
|
{ &hf_mgcp_req_frame,
|
2003-03-06 09:01:47 +00:00
|
|
|
{ "Request Frame", "mgcp.reqframe", FT_FRAMENUM, BASE_NONE, NULL, 0,
|
|
|
|
"Request Frame", HFILL }},
|
2003-04-16 07:25:12 +00:00
|
|
|
{ &hf_mgcp_rsp_frame,
|
2003-03-06 09:01:47 +00:00
|
|
|
{ "Response Frame", "mgcp.rspframe", FT_FRAMENUM, BASE_NONE, NULL, 0,
|
|
|
|
"Response Frame", HFILL }},
|
|
|
|
{ &hf_mgcp_time,
|
|
|
|
{ "Time from request", "mgcp.time", FT_RELATIVE_TIME, BASE_NONE, NULL, 0,
|
|
|
|
"Timedelta between Request and Response", HFILL }},
|
2000-11-09 10:04:48 +00:00
|
|
|
{ &hf_mgcp_req_verb,
|
2002-08-28 20:41:00 +00:00
|
|
|
{ "Verb", "mgcp.req.verb", FT_STRING, BASE_DEC, NULL, 0x0,
|
2001-06-18 02:18:27 +00:00
|
|
|
"Name of the verb", HFILL }},
|
2000-11-09 10:04:48 +00:00
|
|
|
{ &hf_mgcp_req_endpoint,
|
|
|
|
{ "Endpoint", "mgcp.req.endpoint", FT_STRING, BASE_DEC, NULL, 0x0,
|
2001-06-18 02:18:27 +00:00
|
|
|
"Endpoint referenced by the message", HFILL }},
|
2000-11-09 10:04:48 +00:00
|
|
|
{ &hf_mgcp_transid,
|
|
|
|
{ "Transaction ID", "mgcp.transid", FT_STRING, BASE_DEC, NULL, 0x0,
|
2001-06-18 02:18:27 +00:00
|
|
|
"Transaction ID of this message", HFILL }},
|
2002-08-28 20:41:00 +00:00
|
|
|
{ &hf_mgcp_version,
|
2000-11-09 10:04:48 +00:00
|
|
|
{ "Version", "mgcp.version", FT_STRING, BASE_DEC, NULL, 0x0,
|
2001-06-18 02:18:27 +00:00
|
|
|
"MGCP Version", HFILL }},
|
2002-08-28 20:41:00 +00:00
|
|
|
{ &hf_mgcp_rsp_rspcode,
|
2000-11-09 10:04:48 +00:00
|
|
|
{ "Response Code", "mgcp.rsp.rspcode", FT_STRING, BASE_DEC, NULL, 0x0,
|
2001-06-18 02:18:27 +00:00
|
|
|
"Response Code", HFILL }},
|
2000-11-09 10:04:48 +00:00
|
|
|
{ &hf_mgcp_rsp_rspstring,
|
2002-08-28 20:41:00 +00:00
|
|
|
{ "Response String", "mgcp.rsp.rspstring", FT_STRING, BASE_DEC, NULL,
|
2001-06-18 02:18:27 +00:00
|
|
|
0x0, "Response String", HFILL }},
|
2000-11-09 10:04:48 +00:00
|
|
|
{ &hf_mgcp_param_rspack,
|
|
|
|
{ "ResponseAck (K)", "mgcp.param.rspack", FT_STRING, BASE_DEC, NULL,
|
2001-06-18 02:18:27 +00:00
|
|
|
0x0, "Response Ack", HFILL }},
|
2000-11-09 10:04:48 +00:00
|
|
|
{ &hf_mgcp_param_bearerinfo,
|
2002-08-28 20:41:00 +00:00
|
|
|
{ "BearerInformation (B)", "mgcp.param.bearerinfo", FT_STRING, BASE_DEC,
|
2001-06-18 02:18:27 +00:00
|
|
|
NULL, 0x0, "Bearer Information", HFILL }},
|
2000-11-09 10:04:48 +00:00
|
|
|
{ &hf_mgcp_param_callid,
|
|
|
|
{ "CallId (C)", "mgcp.param.callid", FT_STRING, BASE_DEC, NULL, 0x0,
|
2001-06-18 02:18:27 +00:00
|
|
|
"Call Id", HFILL }},
|
2000-11-09 10:04:48 +00:00
|
|
|
{ &hf_mgcp_param_connectionid,
|
2002-08-28 20:41:00 +00:00
|
|
|
{"ConnectionIdentifier (I)", "mgcp.param.connectionid", FT_STRING,
|
2001-06-18 02:18:27 +00:00
|
|
|
BASE_DEC, NULL, 0x0, "Connection Identifier", HFILL }},
|
2000-11-09 10:04:48 +00:00
|
|
|
{ &hf_mgcp_param_secondconnectionid,
|
2002-08-28 20:41:00 +00:00
|
|
|
{ "SecondConnectionID (I2)", "mgcp.param.secondconnectionid", FT_STRING,
|
2001-06-18 02:18:27 +00:00
|
|
|
BASE_DEC, NULL, 0x0, "Second Connection Identifier", HFILL }},
|
2000-11-09 10:04:48 +00:00
|
|
|
{ &hf_mgcp_param_notifiedentity,
|
|
|
|
{ "NotifiedEntity (N)", "mgcp.param.notifiedentity", FT_STRING, BASE_DEC,
|
2001-06-18 02:18:27 +00:00
|
|
|
NULL, 0x0, "Notified Entity", HFILL }},
|
2000-11-09 10:04:48 +00:00
|
|
|
{ &hf_mgcp_param_requestid,
|
|
|
|
{ "RequestIdentifier (X)", "mgcp.param.requestid", FT_STRING, BASE_DEC,
|
2001-06-18 02:18:27 +00:00
|
|
|
NULL, 0x0, "Request Identifier", HFILL }},
|
2000-11-09 10:04:48 +00:00
|
|
|
{ &hf_mgcp_param_localconnoptions,
|
2002-08-28 20:41:00 +00:00
|
|
|
{ "LocalConnectionOptions (L)", "mgcp.param.localconnectionoptions",
|
2001-06-18 02:18:27 +00:00
|
|
|
FT_STRING, BASE_DEC, NULL, 0x0, "Local Connection Options", HFILL }},
|
2000-11-09 10:04:48 +00:00
|
|
|
{ &hf_mgcp_param_connectionmode,
|
|
|
|
{ "ConnectionMode (M)", "mgcp.param.connectionmode", FT_STRING, BASE_DEC,
|
2001-06-18 02:18:27 +00:00
|
|
|
NULL, 0x0, "Connection Mode", HFILL }},
|
2000-11-09 10:04:48 +00:00
|
|
|
{ &hf_mgcp_param_reqevents,
|
|
|
|
{ "RequestedEvents (R)", "mgcp.param.reqevents", FT_STRING, BASE_DEC,
|
2001-06-18 02:18:27 +00:00
|
|
|
NULL, 0x0, "Requested Events", HFILL }},
|
2000-11-09 10:04:48 +00:00
|
|
|
{ &hf_mgcp_param_signalreq,
|
|
|
|
{ "SignalRequests (S)", "mgcp.param.signalreq", FT_STRING, BASE_DEC,
|
2001-06-18 02:18:27 +00:00
|
|
|
NULL, 0x0, "Signal Request", HFILL }},
|
2002-08-28 20:41:00 +00:00
|
|
|
{ &hf_mgcp_param_restartmethod,
|
2000-11-09 10:04:48 +00:00
|
|
|
{ "RestartMethod (RM)", "mgcp.param.restartmethod", FT_STRING, BASE_DEC,
|
2001-06-18 02:18:27 +00:00
|
|
|
NULL, 0x0, "Restart Method", HFILL }},
|
2000-11-09 10:04:48 +00:00
|
|
|
{ &hf_mgcp_param_restartdelay,
|
|
|
|
{ "RestartDelay (RD)", "mgcp.param.restartdelay", FT_STRING, BASE_DEC,
|
2001-06-18 02:18:27 +00:00
|
|
|
NULL, 0x0, "Restart Delay", HFILL }},
|
2002-08-28 20:41:00 +00:00
|
|
|
{ &hf_mgcp_param_digitmap,
|
2000-11-09 10:04:48 +00:00
|
|
|
{ "DigitMap (D)", "mgcp.param.digitmap", FT_STRING, BASE_DEC, NULL, 0x0,
|
2001-06-18 02:18:27 +00:00
|
|
|
"Digit Map", HFILL }},
|
2002-08-28 20:41:00 +00:00
|
|
|
{ &hf_mgcp_param_observedevent,
|
|
|
|
{ "ObservedEvents (O)", "mgcp.param.observedevents", FT_STRING,
|
2001-06-18 02:18:27 +00:00
|
|
|
BASE_DEC, NULL, 0x0, "Observed Events", HFILL }},
|
2000-11-09 10:04:48 +00:00
|
|
|
{ &hf_mgcp_param_connectionparam,
|
2002-08-28 20:41:00 +00:00
|
|
|
{ "ConnectionParameters (P)", "mgcp.param.connectionparam", FT_STRING,
|
2001-06-18 02:18:27 +00:00
|
|
|
BASE_DEC, NULL, 0x0, "Connection Parameters", HFILL }},
|
2000-11-09 10:04:48 +00:00
|
|
|
{ &hf_mgcp_param_reasoncode,
|
|
|
|
{ "ReasonCode (E)", "mgcp.param.reasoncode", FT_STRING, BASE_DEC,
|
2001-06-18 02:18:27 +00:00
|
|
|
NULL, 0x0, "Reason Code", HFILL }},
|
2000-11-09 10:04:48 +00:00
|
|
|
{ &hf_mgcp_param_eventstates,
|
|
|
|
{ "EventStates (ES)", "mgcp.param.eventstates", FT_STRING, BASE_DEC,
|
2001-06-18 02:18:27 +00:00
|
|
|
NULL, 0x0, "Event States", HFILL }},
|
2000-11-09 10:04:48 +00:00
|
|
|
{ &hf_mgcp_param_specificendpoint,
|
|
|
|
{ "SpecificEndpointID (Z)", "mgcp.param.specificendpointid", FT_STRING,
|
2001-06-18 02:18:27 +00:00
|
|
|
BASE_DEC, NULL, 0x0, "Specific Endpoint ID", HFILL }},
|
2000-11-09 10:04:48 +00:00
|
|
|
{ &hf_mgcp_param_secondendpointid,
|
|
|
|
{ "SecondEndpointID (Z2)", "mgcp.param.secondendpointid", FT_STRING,
|
2001-06-18 02:18:27 +00:00
|
|
|
BASE_DEC, NULL, 0x0, "Second Endpoing ID", HFILL }},
|
2000-11-09 10:04:48 +00:00
|
|
|
{ &hf_mgcp_param_reqinfo,
|
2002-08-28 20:41:00 +00:00
|
|
|
{ "RequestedInfo (F)", "mgcp.param.reqinfo", FT_STRING, BASE_DEC,
|
2001-06-18 02:18:27 +00:00
|
|
|
NULL, 0x0,"Requested Info", HFILL }},
|
2002-08-28 20:41:00 +00:00
|
|
|
{ &hf_mgcp_param_quarantinehandling,
|
2000-11-09 10:04:48 +00:00
|
|
|
{ "QuarantineHandling (Q)", "mgcp.param.quarantinehandling", FT_STRING,
|
2001-06-18 02:18:27 +00:00
|
|
|
BASE_DEC, NULL, 0x0, "Quarantine Handling", HFILL }},
|
2000-11-09 10:04:48 +00:00
|
|
|
{ &hf_mgcp_param_detectedevents,
|
|
|
|
{ "DetectedEvents (T)", "mgcp.param.detectedevents", FT_STRING, BASE_DEC,
|
2001-06-18 02:18:27 +00:00
|
|
|
NULL, 0x0, "Detected Events", HFILL }},
|
2000-11-09 10:04:48 +00:00
|
|
|
{ &hf_mgcp_param_capabilities,
|
|
|
|
{ "Capabilities (A)", "mgcp.param.capabilities", FT_STRING, BASE_DEC,
|
2001-06-18 02:18:27 +00:00
|
|
|
NULL, 0x0, "Capabilities", HFILL }},
|
2000-11-09 10:04:48 +00:00
|
|
|
{ &hf_mgcp_param_extention,
|
2002-08-28 20:41:00 +00:00
|
|
|
{ "Extention Parameter (X-*)", "mgcp.param.extention", FT_STRING,
|
2001-06-18 02:18:27 +00:00
|
|
|
BASE_DEC, NULL, 0x0, "Extension Parameter", HFILL }},
|
2000-11-09 10:04:48 +00:00
|
|
|
{ &hf_mgcp_param_invalid,
|
2002-08-28 20:41:00 +00:00
|
|
|
{ "Invalid Parameter", "mgcp.param.invalid", FT_STRING,
|
2001-06-18 02:18:27 +00:00
|
|
|
BASE_DEC, NULL, 0x0, "Invalid Parameter", HFILL }},
|
2002-08-28 20:41:00 +00:00
|
|
|
{ &hf_mgcp_messagecount,
|
|
|
|
{ "MGCP Message Count", "mgcp.messagecount", FT_UINT32,
|
2001-06-18 02:18:27 +00:00
|
|
|
BASE_DEC, NULL, 0x0, "Number of MGCP message in a packet", HFILL }},
|
2003-03-06 09:01:47 +00:00
|
|
|
{ &hf_mgcp_dup,
|
|
|
|
{ "Duplicate Message", "mgcp.dup", FT_UINT32, BASE_DEC,
|
|
|
|
NULL, 0, "Duplicate Message", HFILL }},
|
|
|
|
{ &hf_mgcp_req_dup,
|
|
|
|
{ "Duplicate Request", "mgcp.req.dup", FT_UINT32, BASE_DEC,
|
|
|
|
NULL, 0, "Duplicate Request", HFILL }},
|
|
|
|
{ &hf_mgcp_rsp_dup,
|
|
|
|
{ "Duplicate Response", "mgcp.rsp.dup", FT_UINT32, BASE_DEC,
|
|
|
|
NULL, 0, "Duplicate Response", HFILL }},
|
2000-11-09 10:04:48 +00:00
|
|
|
/* Add more fields here */
|
|
|
|
};
|
|
|
|
static gint *ett[] = {
|
|
|
|
&ett_mgcp,
|
|
|
|
&ett_mgcp_param,
|
|
|
|
};
|
2002-08-28 20:41:00 +00:00
|
|
|
module_t *mgcp_module;
|
2000-11-09 10:04:48 +00:00
|
|
|
|
2001-01-03 07:53:48 +00:00
|
|
|
proto_mgcp = proto_register_protocol("Media Gateway Control Protocol",
|
|
|
|
"MGCP", "mgcp");
|
|
|
|
|
|
|
|
proto_register_field_array(proto_mgcp, hf, array_length(hf));
|
|
|
|
proto_register_subtree_array(ett, array_length(ett));
|
2003-03-06 09:01:47 +00:00
|
|
|
register_init_routine(&mgcp_init_protocol);
|
2001-01-03 07:53:48 +00:00
|
|
|
|
2000-11-09 10:04:48 +00:00
|
|
|
/* Register our configuration options for , particularly our ports */
|
|
|
|
|
2001-01-03 07:53:48 +00:00
|
|
|
mgcp_module = prefs_register_protocol(proto_mgcp, proto_reg_handoff_mgcp);
|
2000-11-09 10:04:48 +00:00
|
|
|
|
2002-08-28 20:41:00 +00:00
|
|
|
prefs_register_uint_preference(mgcp_module, "tcp.gateway_port",
|
2000-11-09 10:04:48 +00:00
|
|
|
"MGCP Gateway TCP Port",
|
2000-12-25 09:37:35 +00:00
|
|
|
"Set the UDP port for gateway messages "
|
|
|
|
"(if other than the default of 2427)",
|
2000-11-09 10:04:48 +00:00
|
|
|
10, &global_mgcp_gateway_tcp_port);
|
|
|
|
|
2002-08-28 20:41:00 +00:00
|
|
|
prefs_register_uint_preference(mgcp_module, "udp.gateway_port",
|
2000-12-25 09:37:35 +00:00
|
|
|
"MGCP Gateway UDP Port",
|
|
|
|
"Set the TCP port for gateway messages "
|
|
|
|
"(if other than the default of 2427)",
|
2000-11-09 10:04:48 +00:00
|
|
|
10, &global_mgcp_gateway_udp_port);
|
|
|
|
|
2002-08-28 20:41:00 +00:00
|
|
|
prefs_register_uint_preference(mgcp_module, "tcp.callagent_port",
|
2000-11-09 10:04:48 +00:00
|
|
|
"MGCP Callagent TCP Port",
|
2000-12-25 09:37:35 +00:00
|
|
|
"Set the TCP port for callagent messages "
|
2000-11-09 10:04:48 +00:00
|
|
|
"(if other than the default of 2727)",
|
|
|
|
10, &global_mgcp_callagent_tcp_port);
|
|
|
|
|
2002-08-28 20:41:00 +00:00
|
|
|
prefs_register_uint_preference(mgcp_module, "udp.callagent_port",
|
2000-12-25 09:37:35 +00:00
|
|
|
"MGCP Callagent UDP Port",
|
|
|
|
"Set the UDP port for callagent messages "
|
2000-11-09 10:04:48 +00:00
|
|
|
"(if other than the default of 2727)",
|
|
|
|
10, &global_mgcp_callagent_udp_port);
|
|
|
|
|
|
|
|
|
2002-08-28 20:41:00 +00:00
|
|
|
prefs_register_bool_preference(mgcp_module, "display_raw_text",
|
|
|
|
"Display raw text for MGCP message",
|
2000-11-09 10:04:48 +00:00
|
|
|
"Specifies that the raw text of the "
|
|
|
|
"MGCP message should be displayed "
|
|
|
|
"instead of (or in addition to) the "
|
|
|
|
"dissection tree",
|
|
|
|
&global_mgcp_raw_text);
|
|
|
|
|
2002-08-28 20:41:00 +00:00
|
|
|
prefs_register_bool_preference(mgcp_module, "display_dissect_tree",
|
|
|
|
"Display tree dissection for MGCP message",
|
2000-11-09 10:04:48 +00:00
|
|
|
"Specifies that the dissection tree of the "
|
|
|
|
"MGCP message should be displayed "
|
|
|
|
"instead of (or in addition to) the "
|
|
|
|
"raw text",
|
|
|
|
&global_mgcp_dissect_tree);
|
|
|
|
|
2002-08-28 20:41:00 +00:00
|
|
|
prefs_register_bool_preference(mgcp_module, "display_mgcp_message_count",
|
|
|
|
"Display the number of MGCP messages",
|
2002-01-20 23:25:55 +00:00
|
|
|
"Display the number of MGCP messages "
|
2001-03-04 00:43:56 +00:00
|
|
|
"found in a packet in the protocol column.",
|
|
|
|
&global_mgcp_message_count);
|
2003-04-16 07:25:12 +00:00
|
|
|
|
2003-03-06 09:01:47 +00:00
|
|
|
mgcp_tap = register_tap("mgcp");
|
2000-11-09 10:04:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* The registration hand-off routine */
|
2001-07-04 22:01:22 +00:00
|
|
|
void
|
2000-11-09 10:04:48 +00:00
|
|
|
proto_reg_handoff_mgcp(void)
|
|
|
|
{
|
|
|
|
static int mgcp_prefs_initialized = FALSE;
|
2001-12-03 04:00:26 +00:00
|
|
|
static dissector_handle_t mgcp_handle;
|
2000-11-09 10:04:48 +00:00
|
|
|
|
2001-07-04 22:01:22 +00:00
|
|
|
/*
|
|
|
|
* Get a handle for the SDP dissector.
|
|
|
|
*/
|
|
|
|
sdp_handle = find_dissector("sdp");
|
|
|
|
|
2001-12-03 04:00:26 +00:00
|
|
|
if (!mgcp_prefs_initialized) {
|
|
|
|
mgcp_handle = create_dissector_handle(dissect_mgcp, proto_mgcp);
|
|
|
|
mgcp_prefs_initialized = TRUE;
|
2000-11-09 10:04:48 +00:00
|
|
|
}
|
|
|
|
else {
|
2001-12-03 04:00:26 +00:00
|
|
|
dissector_delete("tcp.port", gateway_tcp_port, mgcp_handle);
|
|
|
|
dissector_delete("udp.port", gateway_udp_port, mgcp_handle);
|
|
|
|
dissector_delete("tcp.port", callagent_tcp_port, mgcp_handle);
|
|
|
|
dissector_delete("udp.port", callagent_udp_port, mgcp_handle);
|
2000-11-09 10:04:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Set our port number for future use */
|
|
|
|
|
|
|
|
gateway_tcp_port = global_mgcp_gateway_tcp_port;
|
|
|
|
gateway_udp_port = global_mgcp_gateway_udp_port;
|
|
|
|
|
|
|
|
callagent_tcp_port = global_mgcp_callagent_tcp_port;
|
|
|
|
callagent_udp_port = global_mgcp_callagent_udp_port;
|
|
|
|
|
2001-12-03 04:00:26 +00:00
|
|
|
dissector_add("tcp.port", global_mgcp_gateway_tcp_port, mgcp_handle);
|
|
|
|
dissector_add("udp.port", global_mgcp_gateway_udp_port, mgcp_handle);
|
|
|
|
dissector_add("tcp.port", global_mgcp_callagent_tcp_port, mgcp_handle);
|
|
|
|
dissector_add("udp.port", global_mgcp_callagent_udp_port, mgcp_handle);
|
2000-11-09 10:04:48 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2002-08-28 20:41:00 +00:00
|
|
|
/*
|
|
|
|
* is_mgcp_verb - A function for determining whether there is a
|
2000-11-09 10:04:48 +00:00
|
|
|
* MGCP verb at offset in tvb
|
|
|
|
*
|
|
|
|
* Parameter:
|
|
|
|
* tvb - The tvbuff in which we are looking for an MGCP verb
|
|
|
|
* offset - The offset in tvb at which we are looking for a MGCP verb
|
2002-08-28 20:41:00 +00:00
|
|
|
* maxlength - The maximum distance from offset we may look for the
|
|
|
|
* characters that make up a MGCP verb.
|
2000-11-09 10:04:48 +00:00
|
|
|
*
|
|
|
|
* Return: TRUE if there is an MGCP verb at offset in tvb, otherwise FALSE
|
|
|
|
*/
|
|
|
|
|
|
|
|
static gboolean is_mgcp_verb(tvbuff_t *tvb, gint offset, gint maxlength){
|
|
|
|
int returnvalue = FALSE;
|
|
|
|
guint8 word[5];
|
|
|
|
|
2003-04-30 02:35:28 +00:00
|
|
|
if(( maxlength >= 4) && tvb_get_nstringz0(tvb,offset,sizeof(word),word)){
|
2000-11-09 10:04:48 +00:00
|
|
|
if (strncasecmp(word, "EPCF", 4) == 0 ||
|
|
|
|
strncasecmp(word, "CRCX", 4) == 0 ||
|
|
|
|
strncasecmp(word, "MDCX", 4) == 0 ||
|
|
|
|
strncasecmp(word, "DLCX", 4) == 0 ||
|
|
|
|
strncasecmp(word, "RQNT", 4) == 0 ||
|
|
|
|
strncasecmp(word, "NTFY", 4) == 0 ||
|
|
|
|
strncasecmp(word, "AUEP", 4) == 0 ||
|
|
|
|
strncasecmp(word, "AUCX", 4) == 0 ||
|
|
|
|
strncasecmp(word, "RSIP", 4) == 0 ||
|
2000-11-10 04:58:29 +00:00
|
|
|
(word[0] == 'X' && is_rfc2234_alpha(word[1]) && is_rfc2234_alpha(word[2]) &&
|
|
|
|
is_rfc2234_alpha(word[3]))
|
2000-11-09 10:04:48 +00:00
|
|
|
){
|
|
|
|
returnvalue = TRUE;
|
|
|
|
}
|
|
|
|
}
|
2002-08-28 20:41:00 +00:00
|
|
|
if( returnvalue && maxlength >= 5 &&
|
2000-11-09 10:04:48 +00:00
|
|
|
(word[0] = tvb_get_guint8(tvb,4)) != ' ' && word[0] != '\t'){
|
|
|
|
returnvalue = FALSE;
|
|
|
|
}
|
|
|
|
return returnvalue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2002-08-28 20:41:00 +00:00
|
|
|
* is_mgcp_rspcode - A function for determining whether something which
|
|
|
|
* looks roughly like a MGCP response code is at
|
2000-11-09 10:04:48 +00:00
|
|
|
* offset in tvb
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* tvb - The tvbuff in which we are looking for an MGCP response code
|
|
|
|
* offset - The offset in tvb at which we are looking for a MGCP response code
|
2002-08-28 20:41:00 +00:00
|
|
|
* maxlength - The maximum distance from offset we may look for the
|
|
|
|
* characters that make up a MGCP response code.
|
2000-11-09 10:04:48 +00:00
|
|
|
*
|
2002-08-28 20:41:00 +00:00
|
|
|
* Return: TRUE if there is an MGCP response code at offset in tvb,
|
2000-11-09 10:04:48 +00:00
|
|
|
* otherwise FALSE
|
|
|
|
*/
|
|
|
|
|
|
|
|
static gboolean is_mgcp_rspcode(tvbuff_t *tvb, gint offset, gint maxlength){
|
|
|
|
int returnvalue = FALSE;
|
|
|
|
guint8 word[4];
|
2002-08-28 20:41:00 +00:00
|
|
|
if(maxlength >= 3){
|
2003-04-30 02:35:28 +00:00
|
|
|
tvb_get_nstringz0(tvb,offset,sizeof(word),word);
|
2000-11-10 04:58:29 +00:00
|
|
|
if( isdigit(word[0]) &&
|
|
|
|
isdigit(word[1]) &&
|
2002-08-28 20:41:00 +00:00
|
|
|
isdigit(word[2])){
|
2000-11-09 10:04:48 +00:00
|
|
|
returnvalue = TRUE;
|
|
|
|
}
|
|
|
|
}
|
2002-08-28 20:41:00 +00:00
|
|
|
if( returnvalue && maxlength >= 4 &&
|
2000-11-09 10:04:48 +00:00
|
|
|
(word[0] = tvb_get_guint8(tvb,3)) != ' ' && word[0] != '\t'){
|
|
|
|
returnvalue = FALSE;
|
|
|
|
}
|
|
|
|
return returnvalue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2002-08-28 20:41:00 +00:00
|
|
|
* is_rfc2234_alpha - Indicates whether the character c is an alphabetical
|
|
|
|
* character. This function is used instead of
|
2000-11-10 04:58:29 +00:00
|
|
|
* isalpha because isalpha may deviate from the rfc2234
|
|
|
|
* definition of ALPHA in some locales.
|
2002-08-28 20:41:00 +00:00
|
|
|
*
|
2000-11-09 10:04:48 +00:00
|
|
|
* Parameter:
|
|
|
|
* c - The character being checked for being an alphabetical character.
|
|
|
|
*
|
|
|
|
* Return: TRUE if c is an upper or lower case alphabetical character,
|
|
|
|
* FALSE otherwise.
|
|
|
|
*/
|
|
|
|
|
2000-11-10 04:58:29 +00:00
|
|
|
static gboolean is_rfc2234_alpha(guint8 c){
|
2000-11-09 10:04:48 +00:00
|
|
|
int returnvalue = FALSE;
|
|
|
|
if(( c <= 'Z' && c >= 'A' ) || (c <= 'z' && c >= 'a')){
|
|
|
|
returnvalue = TRUE;
|
|
|
|
}
|
|
|
|
return returnvalue;
|
|
|
|
}
|
2002-08-28 20:41:00 +00:00
|
|
|
|
2000-11-09 10:04:48 +00:00
|
|
|
/*
|
|
|
|
* tvb_parse_param - Parse the MGCP param into a type and a value.
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* tvb - The tvbuff containing the MGCP param we are to parse.
|
2002-08-28 20:41:00 +00:00
|
|
|
* offset - The offset in tvb at which we will begin looking for a
|
2000-11-09 10:04:48 +00:00
|
|
|
* MGCP parameter to parse.
|
|
|
|
* len - The maximum distance from offset in tvb that we can look for
|
|
|
|
* an MGCP parameter to parse.
|
2002-08-28 20:41:00 +00:00
|
|
|
* hf - The place to write a pointer to the integer representing the
|
2000-11-09 10:04:48 +00:00
|
|
|
* header field associated with the MGCP parameter parsed.
|
|
|
|
*
|
2002-08-28 20:41:00 +00:00
|
|
|
* Returns: The offset in tvb where the value of the MGCP parameter
|
2000-11-09 10:04:48 +00:00
|
|
|
* begins.
|
|
|
|
*/
|
|
|
|
static gint tvb_parse_param(tvbuff_t* tvb, gint offset, gint len, int** hf){
|
|
|
|
gint returnvalue, tvb_current_offset,counter;
|
|
|
|
guint8 tempchar;
|
|
|
|
tvb_current_offset = offset;
|
|
|
|
returnvalue = -1;
|
|
|
|
*hf = NULL;
|
|
|
|
if(len > 0){
|
|
|
|
tempchar = tvb_get_guint8(tvb,tvb_current_offset);
|
|
|
|
switch(tempchar){
|
|
|
|
case 'K':
|
|
|
|
*hf = &hf_mgcp_param_rspack;
|
|
|
|
break;
|
|
|
|
case 'B':
|
|
|
|
*hf = &hf_mgcp_param_bearerinfo;
|
|
|
|
break;
|
|
|
|
case 'C':
|
|
|
|
*hf = &hf_mgcp_param_callid;
|
|
|
|
break;
|
|
|
|
case 'I':
|
|
|
|
tvb_current_offset++;
|
2002-08-28 20:41:00 +00:00
|
|
|
if(len > (tvb_current_offset - offset) &&
|
|
|
|
(tempchar = tvb_get_guint8(tvb,tvb_current_offset)) == ':'){
|
2000-11-09 10:04:48 +00:00
|
|
|
*hf = &hf_mgcp_param_connectionid;
|
|
|
|
tvb_current_offset--;
|
|
|
|
}
|
|
|
|
else if ( tempchar == '2'){
|
|
|
|
*hf = &hf_mgcp_param_secondconnectionid;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'N':
|
|
|
|
*hf = &hf_mgcp_param_notifiedentity;
|
|
|
|
break;
|
|
|
|
case 'X':
|
|
|
|
tvb_current_offset++;
|
2002-08-28 20:41:00 +00:00
|
|
|
if(len > (tvb_current_offset - offset) &&
|
2000-11-09 10:04:48 +00:00
|
|
|
(tempchar = tvb_get_guint8(tvb,tvb_current_offset)) == ':'){
|
|
|
|
*hf = &hf_mgcp_param_requestid;
|
|
|
|
}
|
|
|
|
else if(len > (tvb_current_offset - offset) && (
|
2002-08-28 20:41:00 +00:00
|
|
|
(tempchar = tvb_get_guint8(tvb,tvb_current_offset)) == '-' ||
|
2000-11-09 10:04:48 +00:00
|
|
|
tempchar == '+')){
|
|
|
|
tvb_current_offset++;
|
|
|
|
for(counter = 1;(counter <= 6) && (len > (counter + tvb_current_offset
|
|
|
|
- offset))
|
2002-08-28 20:41:00 +00:00
|
|
|
&& ( is_rfc2234_alpha(tempchar =
|
2000-11-10 04:58:29 +00:00
|
|
|
tvb_get_guint8(tvb,
|
|
|
|
tvb_current_offset+counter))
|
|
|
|
|| isdigit(tempchar));counter++);
|
2000-11-09 10:04:48 +00:00
|
|
|
if(tempchar == ':'){
|
|
|
|
tvb_current_offset += counter;
|
|
|
|
*hf = &hf_mgcp_param_extention;
|
|
|
|
}
|
2002-08-28 20:41:00 +00:00
|
|
|
}
|
2000-11-09 10:04:48 +00:00
|
|
|
tvb_current_offset--;
|
|
|
|
break;
|
|
|
|
case 'L':
|
|
|
|
*hf = &hf_mgcp_param_localconnoptions;
|
|
|
|
break;
|
|
|
|
case 'M':
|
|
|
|
*hf = &hf_mgcp_param_connectionmode;
|
|
|
|
break;
|
|
|
|
case 'R':
|
|
|
|
tvb_current_offset++;
|
2002-08-28 20:41:00 +00:00
|
|
|
if(len > (tvb_current_offset - offset) &&
|
|
|
|
(tempchar = tvb_get_guint8(tvb,tvb_current_offset)) == ':'){
|
2000-11-09 10:04:48 +00:00
|
|
|
*hf = &hf_mgcp_param_reqevents;
|
|
|
|
tvb_current_offset--;
|
|
|
|
}
|
|
|
|
else if ( tempchar == 'M'){
|
|
|
|
*hf = &hf_mgcp_param_restartmethod;
|
|
|
|
}
|
|
|
|
else if ( tempchar == 'D'){
|
|
|
|
*hf = &hf_mgcp_param_restartdelay;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'S':
|
|
|
|
*hf = &hf_mgcp_param_signalreq;
|
|
|
|
break;
|
|
|
|
case 'D':
|
|
|
|
*hf = &hf_mgcp_param_digitmap;
|
|
|
|
break;
|
|
|
|
case 'O':
|
|
|
|
*hf = &hf_mgcp_param_observedevent;
|
|
|
|
break;
|
|
|
|
case 'P':
|
|
|
|
*hf = &hf_mgcp_param_connectionparam;
|
|
|
|
break;
|
|
|
|
case 'E':
|
|
|
|
tvb_current_offset++;
|
2002-08-28 20:41:00 +00:00
|
|
|
if(len > (tvb_current_offset - offset) &&
|
|
|
|
(tempchar = tvb_get_guint8(tvb,tvb_current_offset)) == ':'){
|
2000-11-09 10:04:48 +00:00
|
|
|
*hf = &hf_mgcp_param_reasoncode;
|
|
|
|
tvb_current_offset--;
|
|
|
|
}
|
|
|
|
else if ( tempchar == 'S'){
|
|
|
|
*hf = &hf_mgcp_param_eventstates;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'Z':
|
|
|
|
tvb_current_offset++;
|
2002-08-28 20:41:00 +00:00
|
|
|
if(len > (tvb_current_offset - offset) &&
|
|
|
|
(tempchar = tvb_get_guint8(tvb,tvb_current_offset)) == ':'){
|
2000-11-09 10:04:48 +00:00
|
|
|
*hf = &hf_mgcp_param_specificendpoint;
|
|
|
|
tvb_current_offset--;
|
|
|
|
}
|
|
|
|
else if ( tempchar == '2'){
|
|
|
|
*hf = &hf_mgcp_param_secondendpointid;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'F':
|
|
|
|
*hf = &hf_mgcp_param_reqinfo;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'Q':
|
|
|
|
*hf = &hf_mgcp_param_quarantinehandling;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'T':
|
|
|
|
*hf = &hf_mgcp_param_detectedevents;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'A':
|
|
|
|
*hf = &hf_mgcp_param_capabilities;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
*hf = &hf_mgcp_param_invalid;
|
|
|
|
break;
|
|
|
|
}
|
2002-08-28 20:41:00 +00:00
|
|
|
|
2000-11-09 10:04:48 +00:00
|
|
|
tvb_current_offset++;
|
2002-08-28 20:41:00 +00:00
|
|
|
if(*hf != NULL && len > (tvb_current_offset - offset) &&
|
2000-11-09 10:04:48 +00:00
|
|
|
(tempchar = tvb_get_guint8(tvb,tvb_current_offset)) == ':'){
|
|
|
|
tvb_current_offset++;
|
|
|
|
tvb_current_offset = tvb_skip_wsp(tvb,tvb_current_offset,
|
|
|
|
(len - tvb_current_offset + offset));
|
2001-07-05 04:27:10 +00:00
|
|
|
returnvalue = tvb_current_offset;
|
2000-11-09 10:04:48 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
*hf = &hf_mgcp_param_invalid;
|
|
|
|
}
|
|
|
|
}
|
2001-07-08 04:47:33 +00:00
|
|
|
else{
|
|
|
|
*hf = &hf_mgcp_param_invalid;
|
|
|
|
}
|
2000-11-09 10:04:48 +00:00
|
|
|
if(*hf == &hf_mgcp_param_invalid){
|
|
|
|
returnvalue = offset;
|
|
|
|
}
|
|
|
|
return returnvalue;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-28 20:41:00 +00:00
|
|
|
/*
|
2000-11-09 10:04:48 +00:00
|
|
|
* dissect_mgcp_firstline - Dissects the firstline of an MGCP message.
|
2002-08-28 20:41:00 +00:00
|
|
|
* Adds the appropriate headers fields to
|
|
|
|
* tree for the dissection of the first line
|
2000-11-09 10:04:48 +00:00
|
|
|
* of an MGCP message.
|
2002-08-28 20:41:00 +00:00
|
|
|
*
|
2000-11-09 10:04:48 +00:00
|
|
|
* Parameters:
|
2002-08-28 20:41:00 +00:00
|
|
|
* tvb - The tvb containing the first line of an MGCP message. This
|
|
|
|
* tvb is presumed to ONLY contain the first line of the MGCP
|
2000-11-09 10:04:48 +00:00
|
|
|
* message.
|
2002-08-28 20:41:00 +00:00
|
|
|
* pinfo - The packet info for the packet. This is not really used
|
|
|
|
* by this function but is passed through so as to retain the
|
2000-11-09 10:04:48 +00:00
|
|
|
* style of a dissector.
|
2002-08-28 20:41:00 +00:00
|
|
|
* tree - The tree from which to hang the structured information parsed
|
2000-11-09 10:04:48 +00:00
|
|
|
* from the first line of the MGCP message.
|
|
|
|
*/
|
2003-03-06 09:01:47 +00:00
|
|
|
static void dissect_mgcp_firstline(tvbuff_t *tvb, packet_info *pinfo,
|
|
|
|
proto_tree *tree, mgcp_info_t *mi){
|
2000-11-09 10:04:48 +00:00
|
|
|
gint tvb_current_offset,tvb_previous_offset,tvb_len,tvb_current_len;
|
|
|
|
gint tokennum, tokenlen;
|
2003-03-06 09:01:47 +00:00
|
|
|
char *transid = NULL;
|
|
|
|
char *code = NULL;
|
2000-11-09 10:04:48 +00:00
|
|
|
mgcp_type_t mgcp_type = MGCP_OTHERS;
|
2003-03-06 09:01:47 +00:00
|
|
|
conversation_t* conversation;
|
|
|
|
mgcp_call_info_key mgcp_call_key;
|
|
|
|
mgcp_call_info_key *new_mgcp_call_key = NULL;
|
|
|
|
mgcp_call_t *mgcp_call = NULL;
|
|
|
|
nstime_t delta;
|
2003-04-16 07:25:12 +00:00
|
|
|
|
2003-03-06 09:01:47 +00:00
|
|
|
static address null_address = { AT_NONE, 0, NULL };
|
2000-11-09 10:04:48 +00:00
|
|
|
proto_item* (*my_proto_tree_add_string)(proto_tree*, int, tvbuff_t*, gint,
|
|
|
|
gint, const char*);
|
|
|
|
tvb_previous_offset = 0;
|
|
|
|
tvb_len = tvb_length(tvb);
|
|
|
|
tvb_current_len = tvb_len;
|
|
|
|
tvb_current_offset = tvb_previous_offset;
|
2003-03-06 09:01:47 +00:00
|
|
|
mi->is_duplicate = FALSE;
|
|
|
|
mi->request_available = FALSE;
|
2000-11-09 10:04:48 +00:00
|
|
|
|
|
|
|
if(tree){
|
|
|
|
tokennum = 0;
|
|
|
|
|
|
|
|
if(global_mgcp_dissect_tree){
|
|
|
|
my_proto_tree_add_string = proto_tree_add_string;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
my_proto_tree_add_string = proto_tree_add_string_hidden;
|
|
|
|
}
|
|
|
|
|
2000-12-28 10:10:17 +00:00
|
|
|
do {
|
|
|
|
tvb_current_len = tvb_length_remaining(tvb,tvb_previous_offset);
|
|
|
|
tvb_current_offset = tvb_find_guint8(tvb, tvb_previous_offset,
|
|
|
|
tvb_current_len, ' ');
|
|
|
|
if(tvb_current_offset == -1){
|
|
|
|
tvb_current_offset = tvb_len;
|
|
|
|
tokenlen = tvb_current_len;
|
2002-08-28 20:41:00 +00:00
|
|
|
}
|
2000-12-28 10:10:17 +00:00
|
|
|
else{
|
|
|
|
tokenlen = tvb_current_offset - tvb_previous_offset;
|
|
|
|
}
|
2000-11-09 10:04:48 +00:00
|
|
|
if(tokennum == 0){
|
2003-03-06 09:01:47 +00:00
|
|
|
code = tvb_format_text(tvb,tvb_previous_offset,tokenlen);
|
|
|
|
strncpy(mi->code,code,4);
|
|
|
|
mi->code[4] = '\0';
|
2000-11-09 10:04:48 +00:00
|
|
|
if(is_mgcp_verb(tvb,tvb_previous_offset,tvb_current_len)){
|
|
|
|
mgcp_type = MGCP_REQUEST;
|
2002-08-28 20:41:00 +00:00
|
|
|
my_proto_tree_add_string(tree,hf_mgcp_req_verb, tvb,
|
|
|
|
tvb_previous_offset, tokenlen,
|
2003-03-06 09:01:47 +00:00
|
|
|
code);
|
2000-11-09 10:04:48 +00:00
|
|
|
}
|
|
|
|
else if (is_mgcp_rspcode(tvb,tvb_previous_offset,tvb_current_len)){
|
|
|
|
mgcp_type = MGCP_RESPONSE;
|
|
|
|
my_proto_tree_add_string(tree,hf_mgcp_rsp_rspcode, tvb,
|
|
|
|
tvb_previous_offset, tokenlen,
|
2003-03-06 09:01:47 +00:00
|
|
|
code);
|
2000-11-09 10:04:48 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(tokennum == 1){
|
2003-03-06 09:01:47 +00:00
|
|
|
transid = tvb_format_text(tvb,tvb_previous_offset,tokenlen);
|
2003-03-06 19:15:09 +00:00
|
|
|
/* XXX - what if this isn't a valid text string? */
|
2003-03-06 09:01:47 +00:00
|
|
|
mi->transid = atol(transid);
|
2000-11-09 10:04:48 +00:00
|
|
|
my_proto_tree_add_string(tree,hf_mgcp_transid, tvb,
|
2002-08-28 20:41:00 +00:00
|
|
|
tvb_previous_offset, tokenlen,
|
2003-03-06 09:01:47 +00:00
|
|
|
transid);
|
2000-11-09 10:04:48 +00:00
|
|
|
}
|
|
|
|
if(tokennum == 2){
|
|
|
|
if(mgcp_type == MGCP_REQUEST){
|
|
|
|
my_proto_tree_add_string(tree,hf_mgcp_req_endpoint, tvb,
|
2000-12-28 10:10:17 +00:00
|
|
|
tvb_previous_offset, tokenlen,
|
|
|
|
tvb_format_text(tvb, tvb_previous_offset,
|
|
|
|
tokenlen));
|
2000-11-09 10:04:48 +00:00
|
|
|
}
|
2000-11-21 05:38:51 +00:00
|
|
|
else if(mgcp_type == MGCP_RESPONSE){
|
2000-12-28 10:10:17 +00:00
|
|
|
if(tvb_current_offset < tvb_len){
|
2002-08-28 20:41:00 +00:00
|
|
|
tokenlen = tvb_find_line_end(tvb, tvb_previous_offset,
|
2002-07-17 06:55:29 +00:00
|
|
|
-1,&tvb_current_offset,FALSE);
|
2000-12-28 10:10:17 +00:00
|
|
|
}
|
|
|
|
else{
|
|
|
|
tokenlen = tvb_current_len;
|
|
|
|
}
|
|
|
|
my_proto_tree_add_string(tree, hf_mgcp_rsp_rspstring, tvb,
|
2000-11-09 10:04:48 +00:00
|
|
|
tvb_previous_offset, tokenlen,
|
2000-12-28 10:10:17 +00:00
|
|
|
tvb_format_text(tvb, tvb_previous_offset,
|
2000-11-09 10:04:48 +00:00
|
|
|
tokenlen));
|
2001-03-04 00:43:56 +00:00
|
|
|
break;
|
|
|
|
}
|
2000-11-09 10:04:48 +00:00
|
|
|
}
|
2000-11-21 05:38:51 +00:00
|
|
|
if( (tokennum == 3 && mgcp_type == MGCP_REQUEST) ){
|
2000-12-28 10:10:17 +00:00
|
|
|
if(tvb_current_offset < tvb_len ){
|
2002-08-28 20:41:00 +00:00
|
|
|
tokenlen = tvb_find_line_end(tvb, tvb_previous_offset,
|
2002-07-17 06:55:29 +00:00
|
|
|
-1,&tvb_current_offset,FALSE);
|
2000-12-28 10:10:17 +00:00
|
|
|
}
|
|
|
|
else{
|
|
|
|
tokenlen = tvb_current_len;
|
|
|
|
}
|
2000-11-09 10:04:48 +00:00
|
|
|
my_proto_tree_add_string(tree,hf_mgcp_version, tvb,
|
|
|
|
tvb_previous_offset, tokenlen,
|
|
|
|
tvb_format_text(tvb,tvb_previous_offset,
|
|
|
|
tokenlen));
|
|
|
|
break;
|
|
|
|
}
|
2000-12-28 10:10:17 +00:00
|
|
|
if(tvb_current_offset < tvb_len){
|
|
|
|
tvb_previous_offset = tvb_skip_wsp(tvb, tvb_current_offset,
|
|
|
|
tvb_current_len);
|
|
|
|
}
|
2000-11-09 10:04:48 +00:00
|
|
|
tokennum++;
|
2002-08-28 20:41:00 +00:00
|
|
|
} while( tvb_current_offset < tvb_len && tvb_previous_offset < tvb_len
|
2000-12-28 10:10:17 +00:00
|
|
|
&& tokennum <= 3);
|
2003-04-16 07:25:12 +00:00
|
|
|
|
2000-11-09 10:04:48 +00:00
|
|
|
switch (mgcp_type){
|
|
|
|
case MGCP_RESPONSE:
|
2003-03-06 09:01:47 +00:00
|
|
|
proto_tree_add_boolean_hidden(tree, hf_mgcp_rsp, tvb, 0, 0, TRUE);
|
|
|
|
/* Check for MGCP response. A response must match a call that
|
|
|
|
we've seen, and the response must be sent to the same
|
|
|
|
port and address that the call came from, and must
|
|
|
|
come from the port to which the call was sent.
|
|
|
|
|
|
|
|
If the transport is connection-oriented (we check, for
|
|
|
|
now, only for "pinfo->ptype" of PT_TCP), we take
|
|
|
|
into account the address from which the call was sent
|
|
|
|
and the address to which the call was sent, because
|
|
|
|
the addresses of the two endpoints should be the same
|
|
|
|
for all calls and replies.
|
|
|
|
|
|
|
|
If the transport is connectionless, we don't worry
|
|
|
|
about the address to which the call was sent and from
|
|
|
|
which the reply was sent, because there's no
|
|
|
|
guarantee that the reply will come from the address
|
|
|
|
to which the call was sent. */
|
|
|
|
if (pinfo->ptype == PT_TCP) {
|
|
|
|
conversation = find_conversation(&pinfo->src,
|
|
|
|
&pinfo->dst, pinfo->ptype, pinfo->srcport,
|
|
|
|
pinfo->destport, 0);
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* XXX - can we just use NO_ADDR_B? Unfortunately,
|
|
|
|
* you currently still have to pass a non-null
|
|
|
|
* pointer for the second address argument even
|
|
|
|
* if you do that.
|
|
|
|
*/
|
|
|
|
conversation = find_conversation(&null_address,
|
|
|
|
&pinfo->dst, pinfo->ptype, pinfo->srcport,
|
|
|
|
pinfo->destport, 0);
|
|
|
|
}
|
|
|
|
if (conversation != NULL) {
|
|
|
|
/* look only for matching request, if
|
|
|
|
matching conversation is available. */
|
|
|
|
mgcp_call_key.transid = mi->transid;
|
|
|
|
mgcp_call_key.conversation = conversation;
|
|
|
|
mgcp_call = g_hash_table_lookup(mgcp_calls, &mgcp_call_key);
|
|
|
|
if(mgcp_call) {
|
|
|
|
/* Indicate the frame to which this is a reply. */
|
|
|
|
if(mgcp_call->req_num){
|
|
|
|
mi->request_available = TRUE;
|
|
|
|
mgcp_call->responded = TRUE;
|
2003-04-16 07:25:12 +00:00
|
|
|
strcpy(mi->code,mgcp_call->code);
|
2003-03-06 09:01:47 +00:00
|
|
|
proto_tree_add_uint_format(tree, hf_mgcp_req_frame,
|
|
|
|
tvb, 0, 0, mgcp_call->req_num,
|
|
|
|
"This is a response to a request in frame %u",
|
|
|
|
mgcp_call->req_num);
|
|
|
|
delta.secs= pinfo->fd->abs_secs-mgcp_call->req_time.secs;
|
|
|
|
delta.nsecs=pinfo->fd->abs_usecs*1000-mgcp_call->req_time.nsecs;
|
|
|
|
if(delta.nsecs<0){
|
|
|
|
delta.nsecs+=1000000000;
|
|
|
|
delta.secs--;
|
|
|
|
}
|
|
|
|
proto_tree_add_time(tree, hf_mgcp_time, tvb, 0, 0,
|
|
|
|
&delta);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mgcp_call->rsp_num == 0) {
|
|
|
|
/* We have not yet seen a response to that call, so
|
|
|
|
this must be the first response; remember its
|
|
|
|
frame number. */
|
|
|
|
mgcp_call->rsp_num = pinfo->fd->num;
|
|
|
|
} else {
|
|
|
|
/* We have seen a response to this call - but was it
|
|
|
|
*this* response? */
|
|
|
|
if (mgcp_call->rsp_num != pinfo->fd->num) {
|
|
|
|
/* No, so it's a duplicate response.
|
|
|
|
Mark it as such. */
|
2003-04-16 07:25:12 +00:00
|
|
|
mi->is_duplicate = TRUE;
|
2003-03-06 09:01:47 +00:00
|
|
|
if (check_col(pinfo->cinfo, COL_INFO)) {
|
|
|
|
col_append_fstr(pinfo->cinfo, COL_INFO,
|
2003-03-06 19:15:09 +00:00
|
|
|
", Duplicate Response %u",mi->transid);
|
2003-03-06 09:01:47 +00:00
|
|
|
if (tree) {
|
|
|
|
proto_tree_add_uint_hidden(tree,
|
|
|
|
hf_mgcp_dup, tvb, 0,0, mi->transid);
|
|
|
|
proto_tree_add_uint_hidden(tree,
|
|
|
|
hf_mgcp_rsp_dup, tvb, 0,0, mi->transid);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-11-09 10:04:48 +00:00
|
|
|
break;
|
|
|
|
case MGCP_REQUEST:
|
2003-03-06 09:01:47 +00:00
|
|
|
proto_tree_add_boolean_hidden(tree, hf_mgcp_req, tvb, 0, 0, TRUE);
|
|
|
|
/* Keep track of the address and port whence the call came,
|
|
|
|
and the port to which the call is being sent, so that
|
|
|
|
we can match up calls with replies.
|
|
|
|
|
|
|
|
If the transport is connection-oriented (we check, for
|
|
|
|
now, only for "pinfo->ptype" of PT_TCP), we take
|
|
|
|
into account the address from which the call was sent
|
|
|
|
and the address to which the call was sent, because
|
|
|
|
the addresses of the two endpoints should be the same
|
|
|
|
for all calls and replies.
|
|
|
|
|
|
|
|
If the transport is connectionless, we don't worry
|
|
|
|
about the address to which the call was sent and from
|
|
|
|
which the reply was sent, because there's no
|
|
|
|
guarantee that the reply will come from the address
|
|
|
|
to which the call was sent. */
|
|
|
|
if (pinfo->ptype == PT_TCP) {
|
|
|
|
conversation = find_conversation(&pinfo->src,
|
|
|
|
&pinfo->dst, pinfo->ptype, pinfo->srcport,
|
|
|
|
pinfo->destport, 0);
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* XXX - can we just use NO_ADDR_B? Unfortunately,
|
|
|
|
* you currently still have to pass a non-null
|
|
|
|
* pointer for the second address argument even
|
|
|
|
* if you do that.
|
|
|
|
*/
|
|
|
|
conversation = find_conversation(&pinfo->src,
|
|
|
|
&null_address, pinfo->ptype, pinfo->srcport,
|
|
|
|
pinfo->destport, 0);
|
|
|
|
}
|
|
|
|
if (conversation == NULL) {
|
|
|
|
/* It's not part of any conversation - create a new
|
|
|
|
one. */
|
|
|
|
if (pinfo->ptype == PT_TCP) {
|
|
|
|
conversation = conversation_new(&pinfo->src,
|
|
|
|
&pinfo->dst, pinfo->ptype, pinfo->srcport,
|
|
|
|
pinfo->destport, 0);
|
|
|
|
} else {
|
|
|
|
conversation = conversation_new(&pinfo->src,
|
|
|
|
&null_address, pinfo->ptype, pinfo->srcport,
|
|
|
|
pinfo->destport, 0);
|
|
|
|
}
|
|
|
|
}
|
2003-04-16 07:25:12 +00:00
|
|
|
|
2003-03-06 09:01:47 +00:00
|
|
|
/* prepare the key data */
|
|
|
|
mgcp_call_key.transid = mi->transid;
|
|
|
|
mgcp_call_key.conversation = conversation;
|
2003-04-16 07:25:12 +00:00
|
|
|
|
2003-03-06 09:01:47 +00:00
|
|
|
/* look up the request */
|
|
|
|
mgcp_call = g_hash_table_lookup(mgcp_calls, &mgcp_call_key);
|
|
|
|
if (mgcp_call != NULL) {
|
|
|
|
/* We've seen a request with this TRANSID, with the same
|
|
|
|
source and destination, before - but was it
|
|
|
|
*this* request? */
|
|
|
|
if (pinfo->fd->num != mgcp_call->req_num) {
|
|
|
|
/* No, so it's a duplicate request.
|
|
|
|
Mark it as such. */
|
|
|
|
mi->is_duplicate = TRUE;
|
|
|
|
if (check_col(pinfo->cinfo, COL_INFO)) {
|
|
|
|
col_append_fstr(pinfo->cinfo, COL_INFO,
|
2003-04-16 07:25:12 +00:00
|
|
|
", Duplicate Request %u",mi->transid);
|
2003-03-06 09:01:47 +00:00
|
|
|
if (tree) {
|
2003-04-16 07:25:12 +00:00
|
|
|
proto_tree_add_uint_hidden(tree,
|
2003-03-06 09:01:47 +00:00
|
|
|
hf_mgcp_dup, tvb, 0,0, mi->transid);
|
2003-04-16 07:25:12 +00:00
|
|
|
proto_tree_add_uint_hidden(tree,
|
2003-03-06 09:01:47 +00:00
|
|
|
hf_mgcp_req_dup, tvb, 0,0, mi->transid);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* Prepare the value data.
|
|
|
|
"req_num" and "rsp_num" are frame numbers;
|
|
|
|
frame numbers are 1-origin, so we use 0
|
|
|
|
to mean "we don't yet know in which frame
|
|
|
|
the reply for this call appears". */
|
|
|
|
new_mgcp_call_key = g_mem_chunk_alloc(mgcp_call_info_key_chunk);
|
|
|
|
*new_mgcp_call_key = mgcp_call_key;
|
|
|
|
mgcp_call = g_mem_chunk_alloc(mgcp_call_info_value_chunk);
|
|
|
|
mgcp_call->req_num = pinfo->fd->num;
|
|
|
|
mgcp_call->rsp_num = 0;
|
|
|
|
mgcp_call->transid = mi->transid;
|
|
|
|
mgcp_call->responded = FALSE;
|
|
|
|
mgcp_call->req_time.secs=pinfo->fd->abs_secs;
|
|
|
|
mgcp_call->req_time.nsecs=pinfo->fd->abs_usecs*1000;
|
|
|
|
strcpy(mgcp_call->code,mi->code);
|
2003-04-16 07:25:12 +00:00
|
|
|
|
2003-03-06 09:01:47 +00:00
|
|
|
/* store it */
|
|
|
|
g_hash_table_insert(mgcp_calls, new_mgcp_call_key, mgcp_call);
|
|
|
|
}
|
|
|
|
if(mgcp_call && mgcp_call->rsp_num){
|
|
|
|
proto_tree_add_uint_format(tree, hf_mgcp_rsp_frame,
|
|
|
|
tvb, 0, 0, mgcp_call->rsp_num,
|
|
|
|
"The response to this request is in frame %u",
|
|
|
|
mgcp_call->rsp_num);
|
|
|
|
}
|
2000-11-09 10:04:48 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2003-03-06 09:01:47 +00:00
|
|
|
mi->mgcp_type = mgcp_type;
|
|
|
|
if(mgcp_call) {
|
|
|
|
mi->req_time.secs=mgcp_call->req_time.secs;
|
|
|
|
mi->req_time.nsecs=mgcp_call->req_time.nsecs;
|
|
|
|
}
|
2000-11-09 10:04:48 +00:00
|
|
|
}
|
2003-03-06 09:01:47 +00:00
|
|
|
tap_queue_packet(mgcp_tap, pinfo, mi);
|
2000-11-09 10:04:48 +00:00
|
|
|
}
|
|
|
|
|
2002-08-28 20:41:00 +00:00
|
|
|
/*
|
2000-11-09 10:04:48 +00:00
|
|
|
* dissect_mgcp_params - Dissects the parameters of an MGCP message.
|
2002-08-28 20:41:00 +00:00
|
|
|
* Adds the appropriate headers fields to
|
|
|
|
* tree for the dissection of the parameters
|
2000-11-09 10:04:48 +00:00
|
|
|
* of an MGCP message.
|
2002-08-28 20:41:00 +00:00
|
|
|
*
|
2000-11-09 10:04:48 +00:00
|
|
|
* Parameters:
|
2002-08-28 20:41:00 +00:00
|
|
|
* tvb - The tvb containing the parameters of an MGCP message. This
|
|
|
|
* tvb is presumed to ONLY contain the part of the MGCP
|
2000-11-09 10:04:48 +00:00
|
|
|
* message which contains the MGCP parameters.
|
2002-08-28 20:41:00 +00:00
|
|
|
* pinfo - The packet info for the packet. This is not really used
|
|
|
|
* by this function but is passed through so as to retain the
|
2000-11-09 10:04:48 +00:00
|
|
|
* style of a dissector.
|
2002-08-28 20:41:00 +00:00
|
|
|
* tree - The tree from which to hang the structured information parsed
|
2000-11-09 10:04:48 +00:00
|
|
|
* from the parameters of the MGCP message.
|
|
|
|
*/
|
2002-04-30 10:37:37 +00:00
|
|
|
static void dissect_mgcp_params(tvbuff_t *tvb, proto_tree *tree){
|
2000-11-09 10:04:48 +00:00
|
|
|
int linelen, tokenlen, *my_param;
|
|
|
|
gint tvb_lineend,tvb_current_len, tvb_linebegin,tvb_len;
|
|
|
|
gint tvb_tokenbegin;
|
|
|
|
proto_tree *mgcp_param_ti, *mgcp_param_tree;
|
|
|
|
proto_item* (*my_proto_tree_add_string)(proto_tree*, int, tvbuff_t*, gint,
|
|
|
|
gint, const char*);
|
|
|
|
|
|
|
|
tvb_len = tvb_length(tvb);
|
|
|
|
tvb_linebegin = 0;
|
|
|
|
tvb_current_len = tvb_length_remaining(tvb,tvb_linebegin);
|
|
|
|
tvb_lineend = tvb_linebegin;
|
|
|
|
|
|
|
|
if(tree){
|
|
|
|
if(global_mgcp_dissect_tree){
|
|
|
|
my_proto_tree_add_string = proto_tree_add_string;
|
2002-08-28 20:41:00 +00:00
|
|
|
mgcp_param_ti = proto_tree_add_item(tree, proto_mgcp, tvb,
|
2000-11-09 10:04:48 +00:00
|
|
|
tvb_linebegin, tvb_len, FALSE);
|
2000-11-21 05:38:51 +00:00
|
|
|
proto_item_set_text(mgcp_param_ti, "Parameters");
|
2000-11-09 10:04:48 +00:00
|
|
|
mgcp_param_tree = proto_item_add_subtree(mgcp_param_ti, ett_mgcp_param);
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
my_proto_tree_add_string = proto_tree_add_string_hidden;
|
|
|
|
mgcp_param_tree = tree;
|
|
|
|
mgcp_param_ti = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Parse the parameters */
|
2000-11-21 05:38:51 +00:00
|
|
|
while(tvb_lineend < tvb_len){
|
2002-07-17 06:55:29 +00:00
|
|
|
linelen = tvb_find_line_end(tvb, tvb_linebegin, -1,&tvb_lineend,FALSE);
|
2002-08-28 20:41:00 +00:00
|
|
|
tvb_tokenbegin = tvb_parse_param(tvb, tvb_linebegin, linelen,
|
2000-11-21 05:38:51 +00:00
|
|
|
&my_param);
|
|
|
|
if( my_param != NULL ){
|
2002-07-17 06:55:29 +00:00
|
|
|
tokenlen = tvb_find_line_end(tvb,tvb_tokenbegin,-1,&tvb_lineend,FALSE);
|
2000-11-09 10:04:48 +00:00
|
|
|
my_proto_tree_add_string(mgcp_param_tree,*my_param, tvb,
|
2002-08-28 20:41:00 +00:00
|
|
|
tvb_linebegin, linelen,
|
2000-11-09 10:04:48 +00:00
|
|
|
tvb_format_text(tvb,tvb_tokenbegin,
|
|
|
|
tokenlen));
|
|
|
|
}
|
2000-11-21 05:38:51 +00:00
|
|
|
tvb_linebegin = tvb_lineend;
|
2002-08-28 20:41:00 +00:00
|
|
|
}
|
2000-11-09 10:04:48 +00:00
|
|
|
}
|
2002-08-28 20:41:00 +00:00
|
|
|
}
|
|
|
|
|
2000-11-09 10:04:48 +00:00
|
|
|
/*
|
2002-08-28 20:41:00 +00:00
|
|
|
* tvb_skip_wsp - Returns the position in tvb of the first non-whitespace
|
2000-11-09 10:04:48 +00:00
|
|
|
* character following offset or offset + maxlength -1 whichever
|
|
|
|
* is smaller.
|
|
|
|
*
|
2002-08-28 20:41:00 +00:00
|
|
|
* Parameters:
|
2000-11-09 10:04:48 +00:00
|
|
|
* tvb - The tvbuff in which we are skipping whitespace.
|
|
|
|
* offset - The offset in tvb from which we begin trying to skip whitespace.
|
2002-08-28 20:41:00 +00:00
|
|
|
* maxlength - The maximum distance from offset that we may try to skip
|
2000-11-09 10:04:48 +00:00
|
|
|
* whitespace.
|
|
|
|
*
|
2002-08-28 20:41:00 +00:00
|
|
|
* Returns: The position in tvb of the first non-whitespace
|
2000-11-09 10:04:48 +00:00
|
|
|
* character following offset or offset + maxlength -1 whichever
|
|
|
|
* is smaller.
|
|
|
|
*/
|
|
|
|
static gint tvb_skip_wsp(tvbuff_t* tvb, gint offset, gint maxlength){
|
|
|
|
gint counter = offset;
|
2000-12-28 10:10:17 +00:00
|
|
|
gint end = offset + maxlength,tvb_len;
|
2000-11-09 10:04:48 +00:00
|
|
|
guint8 tempchar;
|
2000-12-28 10:10:17 +00:00
|
|
|
tvb_len = tvb_length(tvb);
|
|
|
|
end = offset + maxlength;
|
|
|
|
if(end >= tvb_len){
|
|
|
|
end = tvb_len;
|
|
|
|
}
|
2002-08-28 20:41:00 +00:00
|
|
|
for(counter = offset; counter < end &&
|
|
|
|
((tempchar = tvb_get_guint8(tvb,counter)) == ' ' ||
|
2000-11-09 10:04:48 +00:00
|
|
|
tempchar == '\t');counter++);
|
|
|
|
return (counter);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2000-11-21 05:38:51 +00:00
|
|
|
* tvb_find_null_line - Returns the length from offset to the first null
|
2002-08-28 20:41:00 +00:00
|
|
|
* line found (a null line is a line that begins
|
2000-11-21 05:38:51 +00:00
|
|
|
* with a CR or LF. The offset to the first character
|
|
|
|
* after the null line is written into the gint pointed
|
|
|
|
* to by next_offset.
|
2000-11-09 10:04:48 +00:00
|
|
|
*
|
2002-08-28 20:41:00 +00:00
|
|
|
* Parameters:
|
2000-11-09 10:04:48 +00:00
|
|
|
* tvb - The tvbuff in which we are looking for a null line.
|
2002-08-28 20:41:00 +00:00
|
|
|
* offset - The offset in tvb at which we will begin looking for
|
2000-11-09 10:04:48 +00:00
|
|
|
* a null line.
|
2002-08-28 20:41:00 +00:00
|
|
|
* len - The maximum distance from offset in tvb that we will look for
|
2000-11-21 05:38:51 +00:00
|
|
|
* a null line. If it is -1 we will look to the end of the buffer.
|
2000-11-09 10:04:48 +00:00
|
|
|
*
|
2002-08-28 20:41:00 +00:00
|
|
|
* next_offset - The location to write the offset of first character
|
|
|
|
* FOLLOWING the null line.
|
2000-11-21 05:38:51 +00:00
|
|
|
*
|
2002-08-28 20:41:00 +00:00
|
|
|
* Returns: The length from offset to the first character BEFORE
|
2000-11-21 05:38:51 +00:00
|
|
|
* the null line..
|
2000-11-09 10:04:48 +00:00
|
|
|
*/
|
2002-08-28 20:41:00 +00:00
|
|
|
static gint tvb_find_null_line(tvbuff_t* tvb, gint offset,
|
2000-11-21 05:38:51 +00:00
|
|
|
gint len, gint* next_offset){
|
|
|
|
gint tvb_lineend,tvb_current_len,tvb_linebegin,maxoffset;
|
2000-11-09 10:04:48 +00:00
|
|
|
guint tempchar;
|
2000-11-21 05:38:51 +00:00
|
|
|
|
2000-11-09 10:04:48 +00:00
|
|
|
tvb_linebegin = offset;
|
|
|
|
tvb_lineend = tvb_linebegin;
|
|
|
|
|
2002-08-28 20:41:00 +00:00
|
|
|
/* Simple setup to allow for the traditional -1 search to the end
|
|
|
|
* of the tvbuff
|
2000-12-20 05:45:27 +00:00
|
|
|
*/
|
2000-11-21 05:38:51 +00:00
|
|
|
if(len != -1){
|
|
|
|
tvb_current_len = len;
|
2002-08-28 20:41:00 +00:00
|
|
|
}
|
2000-11-21 05:38:51 +00:00
|
|
|
else{
|
|
|
|
tvb_current_len = tvb_length_remaining(tvb,offset);
|
|
|
|
}
|
2000-12-20 05:45:27 +00:00
|
|
|
maxoffset = (tvb_current_len - 1) + offset;
|
2000-11-09 10:04:48 +00:00
|
|
|
|
2000-12-20 05:45:27 +00:00
|
|
|
/*
|
|
|
|
* Loop around until we either find a line begining with a carriage return
|
|
|
|
* or newline character or until we hit the end of the tvbuff.
|
|
|
|
*/
|
2001-03-15 19:46:35 +00:00
|
|
|
do {
|
|
|
|
tvb_linebegin = tvb_lineend;
|
|
|
|
tvb_current_len = tvb_length_remaining(tvb,tvb_linebegin);
|
2002-07-17 06:55:29 +00:00
|
|
|
tvb_find_line_end(tvb, tvb_linebegin, tvb_current_len, &tvb_lineend,FALSE);
|
2001-03-15 19:46:35 +00:00
|
|
|
tempchar = tvb_get_guint8(tvb,tvb_linebegin);
|
2002-08-28 20:41:00 +00:00
|
|
|
}
|
2001-03-15 19:46:35 +00:00
|
|
|
while( tempchar != '\r' && tempchar != '\n' &&
|
|
|
|
tvb_lineend <= maxoffset);
|
|
|
|
|
|
|
|
*next_offset = tvb_lineend;
|
|
|
|
|
|
|
|
if( tvb_lineend <= maxoffset ) {
|
|
|
|
tvb_current_len = tvb_linebegin - offset;
|
2000-11-09 10:04:48 +00:00
|
|
|
}
|
2000-12-20 05:45:27 +00:00
|
|
|
else {
|
|
|
|
tvb_current_len = tvb_length_remaining(tvb,offset);
|
2001-03-15 19:46:35 +00:00
|
|
|
}
|
2000-12-20 05:45:27 +00:00
|
|
|
|
2000-11-21 05:38:51 +00:00
|
|
|
return (tvb_current_len);
|
2000-11-09 10:04:48 +00:00
|
|
|
}
|
|
|
|
|
2001-03-04 00:43:56 +00:00
|
|
|
/*
|
2002-08-28 20:41:00 +00:00
|
|
|
* tvb_find_dot_line - Returns the length from offset to the first line
|
|
|
|
* containing only a dot (.) character. A line
|
|
|
|
* containing only a dot is used to indicate a
|
|
|
|
* separation between multiple MGCP messages
|
2001-03-04 00:43:56 +00:00
|
|
|
* piggybacked in the same UDP packet.
|
|
|
|
*
|
2002-08-28 20:41:00 +00:00
|
|
|
* Parameters:
|
2001-03-04 00:43:56 +00:00
|
|
|
* tvb - The tvbuff in which we are looking for a dot line.
|
2002-08-28 20:41:00 +00:00
|
|
|
* offset - The offset in tvb at which we will begin looking for
|
2001-03-04 00:43:56 +00:00
|
|
|
* a dot line.
|
2002-08-28 20:41:00 +00:00
|
|
|
* len - The maximum distance from offset in tvb that we will look for
|
2001-03-04 00:43:56 +00:00
|
|
|
* a dot line. If it is -1 we will look to the end of the buffer.
|
|
|
|
*
|
2002-08-28 20:41:00 +00:00
|
|
|
* next_offset - The location to write the offset of first character
|
|
|
|
* FOLLOWING the dot line.
|
2001-03-04 00:43:56 +00:00
|
|
|
*
|
2002-08-28 20:41:00 +00:00
|
|
|
* Returns: The length from offset to the first character BEFORE
|
|
|
|
* the dot line or -1 if the character at offset is a .
|
2001-03-04 00:43:56 +00:00
|
|
|
* followed by a newline or a carriage return.
|
|
|
|
*/
|
2002-08-28 20:41:00 +00:00
|
|
|
static gint tvb_find_dot_line(tvbuff_t* tvb, gint offset,
|
2001-03-04 00:43:56 +00:00
|
|
|
gint len, gint* next_offset){
|
|
|
|
gint tvb_current_offset, tvb_current_len, maxoffset,tvb_len;
|
|
|
|
guint8 tempchar;
|
|
|
|
|
|
|
|
tvb_current_offset = offset;
|
|
|
|
tvb_current_len = len;
|
|
|
|
tvb_len = tvb_length(tvb);
|
|
|
|
|
|
|
|
if(len == -1){
|
|
|
|
maxoffset = ( tvb_len - 1 );
|
|
|
|
}
|
2002-08-28 20:41:00 +00:00
|
|
|
else {
|
2001-03-04 00:43:56 +00:00
|
|
|
maxoffset = (len - 1 ) + offset;
|
|
|
|
}
|
|
|
|
tvb_current_offset = offset -1;
|
|
|
|
do {
|
|
|
|
tvb_current_offset = tvb_find_guint8(tvb, tvb_current_offset+1,
|
|
|
|
tvb_current_len, '.');
|
|
|
|
tvb_current_len = maxoffset - tvb_current_offset + 1;
|
2002-08-28 20:41:00 +00:00
|
|
|
/*
|
2001-03-04 00:43:56 +00:00
|
|
|
* if we didn't find a . then break out of the loop
|
|
|
|
*/
|
|
|
|
if(tvb_current_offset == -1){
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* do we have and characters following the . ? */
|
2002-08-28 20:41:00 +00:00
|
|
|
if( tvb_current_offset < maxoffset ) {
|
2001-03-04 00:43:56 +00:00
|
|
|
tempchar = tvb_get_guint8(tvb,tvb_current_offset+1);
|
2002-08-28 20:41:00 +00:00
|
|
|
/*
|
|
|
|
* are the characters that follow the dot a newline or carriage return ?
|
2001-03-04 00:43:56 +00:00
|
|
|
*/
|
|
|
|
if(tempchar == '\r' || tempchar == '\n'){
|
|
|
|
/*
|
|
|
|
* do we have any charaters that proceed the . ?
|
|
|
|
*/
|
|
|
|
if( tvb_current_offset == 0 ){
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
tempchar = tvb_get_guint8(tvb,tvb_current_offset-1);
|
|
|
|
/*
|
2002-08-28 20:41:00 +00:00
|
|
|
* are the characters that follow the dot a newline or a carriage
|
2001-03-04 00:43:56 +00:00
|
|
|
* return ?
|
|
|
|
*/
|
|
|
|
if(tempchar == '\r' || tempchar == '\n'){
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( tvb_current_offset == maxoffset ) {
|
|
|
|
if( tvb_current_offset == 0 ){
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
tempchar = tvb_get_guint8(tvb,tvb_current_offset-1);
|
|
|
|
if(tempchar == '\r' || tempchar == '\n'){
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2002-08-28 20:41:00 +00:00
|
|
|
}
|
2001-03-04 00:43:56 +00:00
|
|
|
} while (tvb_current_offset < maxoffset);
|
2002-08-28 20:41:00 +00:00
|
|
|
/*
|
|
|
|
* so now we either have the tvb_current_offset of a . in a dot line
|
2001-03-04 00:43:56 +00:00
|
|
|
* or a tvb_current_offset of -1
|
|
|
|
*/
|
|
|
|
if(tvb_current_offset == -1){
|
|
|
|
tvb_current_offset = maxoffset +1;
|
|
|
|
*next_offset = maxoffset + 1;
|
|
|
|
}
|
|
|
|
else {
|
2002-07-17 06:55:29 +00:00
|
|
|
tvb_find_line_end(tvb,tvb_current_offset,tvb_current_len,next_offset,FALSE);
|
2001-03-04 00:43:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( tvb_current_offset == offset ){
|
|
|
|
tvb_current_len = -1;
|
2002-08-28 20:41:00 +00:00
|
|
|
}
|
2001-03-04 00:43:56 +00:00
|
|
|
else {
|
|
|
|
tvb_current_len = tvb_current_offset - offset;
|
|
|
|
}
|
2002-08-28 20:41:00 +00:00
|
|
|
return tvb_current_len;
|
2001-03-04 00:43:56 +00:00
|
|
|
}
|
|
|
|
|
2000-11-09 10:04:48 +00:00
|
|
|
/* Start the functions we need for the plugin stuff */
|
2001-07-08 21:51:34 +00:00
|
|
|
|
2003-09-05 07:44:50 +00:00
|
|
|
#ifndef ENABLE_STATIC
|
2001-07-08 21:51:34 +00:00
|
|
|
|
2000-11-29 09:49:30 +00:00
|
|
|
G_MODULE_EXPORT void
|
2000-11-22 06:22:35 +00:00
|
|
|
plugin_reg_handoff(void){
|
2000-11-09 10:04:48 +00:00
|
|
|
proto_reg_handoff_mgcp();
|
|
|
|
}
|
|
|
|
|
2000-11-29 09:49:30 +00:00
|
|
|
G_MODULE_EXPORT void
|
2002-04-30 10:37:37 +00:00
|
|
|
plugin_init(plugin_address_table_t *pat
|
|
|
|
#ifndef PLUGINS_NEED_ADDRESS_TABLE
|
|
|
|
_U_
|
|
|
|
#endif
|
|
|
|
){
|
2000-11-09 10:04:48 +00:00
|
|
|
/* initialise the table of pointers needed in Win32 DLLs */
|
|
|
|
plugin_address_table_init(pat);
|
|
|
|
/* register the new protocol, protocol fields, and subtrees */
|
|
|
|
if (proto_mgcp == -1) { /* execute protocol initialization only once */
|
|
|
|
proto_register_mgcp();
|
|
|
|
}
|
|
|
|
}
|
2001-07-08 21:51:34 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2000-11-09 10:04:48 +00:00
|
|
|
/* End the functions we need for plugin stuff */
|