Ethereal-dev: RE: [Ethereal-dev] FW: Ethereal MGCP plugin update

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Alejandro Vaquero <Alejandro.Vaquero@xxxxxxxxxxx>
Date: Wed, 4 Jul 2001 13:51:35 -0300
Ok, here are the changes...

For 1) in the tvb_parse_param function I only add a "="

 if(len >= tvb_current_offset - offset){
	returnvalue = tvb_current_offset;


For 2) I made a new variable (dsp_parameter) to concatenat all the MGCP
parameter and then display it. And a new global variable to set it from the
preference menu (global_mgcp_param). Here are the adds:

/*
 * Variable to concatenate the MGCP parameters to be displayed in the Info
Column.
 */
static char dsp_parameters[64] = "";

static gboolean global_mgcp_param = TRUE;


 prefs_register_bool_preference(mgcp_module, "display_mgcp_param",
                                 "Display MGCP parameters in Info column",
                                 "Display MGCP parameters in Info column.",
                                 &global_mgcp_param);



/*
 * dissect_mgcp - The dissector for the Media Gateway Control Protocol
 */


  /*
   * Check to see whether we're really dealing with MGCP by looking
   * 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)){

    /* Build the info tree if we've been given a root */
    if (tree || global_mgcp_message_count == TRUE) {
      /*
       * Loop through however many mgcp messages may be stuck in
       * this packet using piggybacking
       */
      do{
	num_messages++;
        dsp_parameters[0] = '\0';
	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);
	}

	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;
	}
      } while(tvb_sectionend < tvb_len );
      if(mgcp_tree){
	proto_tree_add_uint_hidden(mgcp_tree, hf_mgcp_messagecount, tvb,
				   0 ,0 , num_messages);
      }
    }

    /*
     * Add our column information we do this after dissecting SDP
     * in order to prevent the column info changing to reflect the SDP.
     */
    tvb_sectionbegin = 0;
    if (check_col(pinfo->fd, COL_PROTOCOL)){
      if( global_mgcp_message_count == TRUE ){
	if(num_messages > 1){
	  col_add_fstr(pinfo->fd, COL_PROTOCOL, "MGCP (%i messages)",num_messages);
	}
	else {
	  col_add_fstr(pinfo->fd, COL_PROTOCOL, "MGCP (%i message)",num_messages);
	}
      }
      else {
	  col_add_str(pinfo->fd, COL_PROTOCOL, "MGCP");
      }
    }

    if (check_col(pinfo->fd, COL_INFO) ){
      sectionlen = tvb_find_line_end(tvb, tvb_sectionbegin,-1,
				     &tvb_sectionend);
      if (global_mgcp_param == TRUE) {
        col_add_fstr(pinfo->fd,COL_INFO, "%s | %s",
		   tvb_format_text(tvb,tvb_sectionbegin,sectionlen), dsp_parameters);
      }
      else {
	col_add_fstr(pinfo->fd,COL_INFO, "%s",
		   tvb_format_text(tvb,tvb_sectionbegin,sectionlen));
      }
    }
  }
}


/*
 * dissect_mgcp_params - Dissects the parameters of an MGCP message.
 *                       Adds the appropriate headers fields to
 *                       tree for the dissection of the parameters
 *                       of an MGCP message.
 *
 * Parameters:
 * tvb - The tvb containing the parameters of an MGCP message.  This
 *       tvb is presumed to ONLY contain the part of the MGCP
 *       message which contains the MGCP parameters.
 * pinfo - The packet info for the packet.  This is not really used
 *         by this function but is passed through so as to retain the
 *         style of a dissector.
 * tree - The tree from which to hang the structured information parsed
 *        from the parameters of the MGCP message.
 */

    /* Parse the parameters */
    while(tvb_lineend < tvb_len){
      linelen = tvb_find_line_end(tvb, tvb_linebegin, -1,&tvb_lineend);
      tvb_tokenbegin = tvb_parse_param(tvb, tvb_linebegin, linelen,
				       &my_param);
      if( my_param != NULL ){
	tokenlen = tvb_find_line_end(tvb,tvb_tokenbegin,-1,&tvb_lineend);
	my_proto_tree_add_string(mgcp_param_tree,*my_param, tvb,
				 tvb_linebegin, linelen,
				 tvb_format_text(tvb,tvb_tokenbegin,
						 tokenlen));
      strcat(dsp_parameters, tvb_format_text(tvb,tvb_linebegin,linelen));
      strcat(dsp_parameters, " ");
      }
      tvb_linebegin = tvb_lineend;
    }
  }
}

Regards
Alejandro


-----Original Message-----
From: Ed Warnicke [mailto:hagbard@xxxxxxxxxxxxxxxxxxx]
Sent: Wednesday, July 04, 2001 13:25
To: Alejandro Vaquero
Cc: ethereal-dev@xxxxxxxxxxxx
Subject: Re: [Ethereal-dev] FW: Ethereal MGCP plugin update


If you could send a patch instead of the whole file that would
be a bit more useful...

Ed


On Wed, 4 Jul 2001, Alejandro Vaquero wrote:

> Im sending an updated MGCP plugin. I just send to Guy but he is on
> vacation. Please let me know if this is the correct way.
>
>
>
>
> -----Original Message-----
> From: Alejandro Vaquero [mailto:alejandro.vaquero@xxxxxxxxxxx]
> Sent: Wednesday, July 04, 2001 10:56
> To: guy@xxxxxxxxxxxx
> Subject: Ethereal MGCP plugin update
>
>
> Hi Guy,
>     I was using Ethereal for 4 month, and it is realy nice. Specially
> the MGCP plugin, because I work in Clarent a IP telephony company.
>     I made two changes in the MGCP plugin, but I don't know how to
> public it in the Ethereal page, so please let me know if this way is the
> correct. The changes are:
>
>     1) Allow to have "empty values" in the MGCP parameters. In the
> previous version it made a "malformed frame" for correct frames.
>     2) A new global parameter, to display the parameters in the "Info"
> column. This option is configurable from the Preference menu.
>
>     Attached is the packet-mgcp.c file.
>
> PD: Sorry for my english, I'm from Argentina!!!!
>
> Regards
> Ing. Alejandro Vaquero
> Mercosur Sales Engineer
>
> Clarent Corporation
> Av. Alicia M. de Justo 1148 Suite 410B
> (C1107AAX) Capital Federal - Argentina
> Direct: +54 11 4341-4589 (Ext:1502)
> Movile: +51 11 5407-9067
> Fax: +54 11 4341-4588
> www.clarent.com
>
>