Wireshark-dev: Re: [Wireshark-dev] Wireshark support for UK ISUP
From: Jeff Morriss <jeff.morriss@xxxxxxxxxxx>
Date: Wed, 19 Jul 2006 09:12:48 +0800
Hi,

I was looking at adding support for UK ISUP (UK PNO/ISC Spec ND1007:2004/11) to Ethereal. The UK national version of ISUP consists of additional/modified parameters and field values so should not be that difficult to implement but it looks as if I am in danger of working at cross purposes with other developments.

I am a tester not a programmer and any programming I do tends to take a long time but, as far as I can see, I have two basic problems: 1. getting the hooks into the dissector to support several different national options - the latest version of my code (based on 0.10.14) is attached which could support multiple options based on a user preference. Is this a sensible way to go and could it co-exist with the ANSI support? Is there any requirement to support more than one variant at a time?

I think having a "National Variant" (or maybe just "Variant" since IIRC there is at least one vendor-specific variant out there) preference is probably a good idea. The current ISUP dissector chooses ANSI or ITU by following the MTP3 dissector's preference and I, at least, would prefer to keep the "Variant" option separate (and in the ISUP dissector).

I think supporting just one variant at a time is reasonable.

BTW, support for national variants of ISUP is #11 under Dissector specific items on the Wishlist. It would be great if you could finish your changes and they could be rolled into the Wireshark source. :-)

2. is there a better way to do this than having lots of switch statements? This may be OK for the parameters where you only execute the code when the parameter is present but something like it needs to be in the code to decode a lot of the field values which could affect performance. Is there a better way than changing

g_snprintf(param_name, NAME_SIZE, val_to_str(upgraded_parameter, isup_parameter_type_value, "unknown"));

to something like

     switch(isup_national){
     case NATIONAL_UKISUP:
           if(upgraded_parameter>=PARAM_TYPE_NATIONAL_244
          && upgraded_parameter<=PARAM_TYPE_NATIONAL_254)
g_snprintf(param_name, NAME_SIZE, val_to_str(upgraded_parameter, isup_uknational_parameter_type_value, "unknown"));
          else
g_snprintf(param_name, NAME_SIZE, val_to_str(upgraded_parameter, isup_parameter_type_value, "unknown"));
          break;

     <<<repeat for any other national options>>>

     default:
g_snprintf(param_name, NAME_SIZE, val_to_str(upgraded_parameter, isup_parameter_type_value, "unknown"));
      }

All advice, comments and suggestions welcome.

That's probably a good way to do it, though you might want to put NATIONAL_NONE (or VARIANT_NONE) at the top of the switch statement since it's the most likely code path.