Ethereal-dev: [Ethereal-dev] Protocol definition table loaded (problems)

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

From: "Nicholas, John S" <John.Nicholas@xxxxxxxxxxxxxx>
Date: Wed, 7 Mar 2001 13:59:55 -0800
Hi,

I am writing a dissector for a protocol that is "in-work".  We want to use it to help
in the development phase of the protocol.  I have been trying to make this dissector
read a file that defines the fields (etc.) and "branches" (sub-dissectors?).  The protocol
has several layers of branches.  Anyway, enough background..........

Note:  I am using Ethereal .8.14

Instead of 
 static int hf_pep_FIELDABBREV = -1;

I am doing 
 static int hf_pep_dynamic_fields[MAX_NUM_FIELDS];

then later in a loop:
 hf_pep_dynamic_fields[x] = -1;


Also for field registration, instead of:
  static hf_register_info hf[] = {
    { &hf_pep_header_sync_pattern,
      {
        "SYNC Pattern",
        "pep.header_sync_pattern",
        FT_BYTES,
        BASE_HEX,
        NULL,
        0,
        "This field should always be D00BED00"
      }
    },
 .....etc.

I am doing:
  static hf_register_info hf[MAX_NUM_FIELDS];

then in a loop:
      /** initialize hf each field **/
      hf[hf_field_cnt].p_id = &hf_pep_dynamic_fields[hf_field_cnt];
      hf[hf_field_cnt].hfinfo.name = pep_data_struct[data_cnt].field[field_cnt]->descr;
      strcpy(abbrev_tmp,"pep.");
      strcat(abbrev_tmp,pep_data_struct[data_cnt].data_struct);
      strcat(abbrev_tmp,".");
      strcat(abbrev_tmp,(*pep_data_struct[data_cnt].field[field_cnt]).name);
      hf[hf_field_cnt].hfinfo.abbrev = abbrev_tmp;
      hf[hf_field_cnt].hfinfo.type = get_type(pep_data_struct[data_cnt].field[field_cnt]->type);
      hf[hf_field_cnt].hfinfo.display = get_display_type(pep_data_struct[data_cnt].field[field_cnt]->type);
      hf[hf_field_cnt].hfinfo.strings = NULL;
      hf[hf_field_cnt].hfinfo.bitmask = 0;
      hf[hf_field_cnt].hfinfo.blurb = "";
      hf_field_cnt++;

The following is my registration statement:
  proto_register_field_array(proto_pep, hf, array_length(hf));
(which should be same as the following)
  proto_register_field_array(proto_pep, hf, MAX_NUM_FIELDS);

I also tried:
 proto_register_field_array(proto_pep, hf, hf_field_cnt);
     where hf_field_cnt= # of elements in array actually used


I get a segmentation fault
Program received signal SIGSEGV, Segmentation fault.
proto_register_field_array (parent=1498, hf=0x1, num_records=1210329218) at proto.c:1534
1534	proto.c: No such file or directory.
(xxgdb) 

Granted the num_records argument looks screwed up...  not sure why yet.


But is it posible to do what I am trying to do?  Should the arguement for "proto_register_field_array"
be the total num,ber of elements in the array, or just the number of elements used?

Is there another dissector out there that does something similiar that I can look at?

Thanks

John

-----------------------------------------------------------------------------------------------
John S. Nicholas                                       The Boeing Company
    Stable: john.s.nicholas@xxxxxxxxxx       Phone: 206-662-0298
-----------------------------------------------------------------------------------------------