From 77a25f27039f9cb67b81a040006664013934401f Mon Sep 17 00:00:00 2001 From: Anders Broman Date: Wed, 16 Feb 2005 22:40:56 +0000 Subject: From Tomas Kukosa: Fix problems with bitfields with dashed ("-") names svn path=/trunk/; revision=13416 --- tools/asn2eth.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'tools') diff --git a/tools/asn2eth.py b/tools/asn2eth.py index dea348da5e..995bfdab27 100644 --- a/tools/asn2eth.py +++ b/tools/asn2eth.py @@ -568,7 +568,7 @@ class EthCtx: if (bits): for (val, id) in bits: self.named_bit.append({'name' : id, 'val' : val, - 'ethname' : 'hf_%s_%s_%s' % (self.eproto, t, id), + 'ethname' : 'hf_%s_%s_%s' % (self.eproto, t, asn2c(id)), 'ftype' : 'FT_BOOLEAN', 'display' : '8', 'strings' : 'NULL', 'bitmask' : '0x'+('80','40','20','10','08','04','02','01')[val%8]}) @@ -765,7 +765,7 @@ class EthCtx: out += "static const " out += "asn_namedbit %s_bits[] = {\n" % (tname) for (val, id) in bits: - out += ' { %2d, &hf_%s_%s_%s, -1, -1, NULL, NULL },\n' % (val, self.eproto, tname, id) + out += ' { %2d, &hf_%s_%s_%s, -1, -1, NULL, NULL },\n' % (val, self.eproto, tname, asn2c(id)) out += " { 0, NULL, 0, 0, NULL, NULL }\n};\n" return out @@ -2746,8 +2746,7 @@ class RestrictedCharacterStringType (CharacterStringType): if (ectx.OPer()): body = ectx.eth_fn_call('dissect_per_restricted_character_string', ret='offset', par=(('tvb', 'offset', 'pinfo', 'tree', 'hf_index'), - (minv, maxv, alphabet, alphabet_length), - ('NULL', 'NULL'))) + (minv, maxv, alphabet, alphabet_length))) else: body = '#error Can not decode %s' % (tname) elif (ectx.NPer()): @@ -3074,11 +3073,9 @@ class BitStringType (Type): def eth_type_fn(self, proto, tname, ectx): out = '' - bits = [] + bits = self.eth_named_bits() bitsp = 'NULL' - if (self.named_list): - for e in (self.named_list): - bits.append((int(e.val), e.ident)) + if (bits): out += ectx.eth_bits(tname, bits) bitsp = tname + '_bits' out += ectx.eth_type_fn_hdr(tname) -- cgit v1.2.3