aboutsummaryrefslogtreecommitdiffstats
path: root/tools/asn2wrs.py
diff options
context:
space:
mode:
authorTomas Kukosa <tomas.kukosa@siemens.com>2007-05-24 07:19:21 +0000
committerTomas Kukosa <tomas.kukosa@siemens.com>2007-05-24 07:19:21 +0000
commit3f071c757a845efa85159cf5bfa925d84af763e5 (patch)
tree38ddeb7032752c17a0834fb889e4610ed3d56269 /tools/asn2wrs.py
parentf33ec966696baac1add2377b173c742f34a3e6a2 (diff)
- improvements in registering dissectors to OID table (value defined in ASN.1 can be used)
- new #.END_OF_CNF directive svn path=/trunk/; revision=21916
Diffstat (limited to 'tools/asn2wrs.py')
-rwxr-xr-xtools/asn2wrs.py29
1 files changed, 22 insertions, 7 deletions
diff --git a/tools/asn2wrs.py b/tools/asn2wrs.py
index 4e77b83aab..c72e7d2c43 100755
--- a/tools/asn2wrs.py
+++ b/tools/asn2wrs.py
@@ -1402,10 +1402,15 @@ class EthCtx:
fx = self.output.file_open('fn')
pos = fx.tell()
if (len(self.eth_hfpdu_ord)):
+ first_decl = True
for f in self.eth_hfpdu_ord:
if (self.eth_hf[f]['pdu'] and self.eth_hf[f]['pdu']['need_decl']):
+ if first_decl:
+ fx.write('/*--- PDUs declarations ---*/\n')
+ first_decl = False
fx.write(out_pdu_decl(f))
- fx.write('\n')
+ if not first_decl:
+ fx.write('\n')
if self.eth_dep_cycle:
fx.write('/*--- Cyclic dependencies ---*/\n\n')
i = 0
@@ -1519,7 +1524,8 @@ class EthCtx:
rport = self.value_get_eth(reg['rport'])
fx.write(' dissector_add%s("%s", %s, %s);\n' % (rstr, reg['rtable'], rport, hnd))
elif (reg['rtype'] in ('BER', 'PER')):
- fx.write(' %sregister_%s_oid_dissector(%s, dissect_%s, proto_%s, %s);\n' % (new_prefix, reg['rtype'].lower(), reg['roid'], f, self.eproto, reg['roidname']))
+ roid = self.value_get_eth(reg['roid'])
+ fx.write(' %sregister_%s_oid_dissector(%s, dissect_%s, proto_%s, %s);\n' % (new_prefix, reg['rtype'].lower(), roid, f, self.eproto, reg['roidname']))
fempty = False
fx.write('\n')
self.output.file_close(fx, discard=fempty)
@@ -1779,7 +1785,10 @@ class EthCnf:
elif (rtype in ('BER', 'PER')):
attr['roid'] = par[1]
attr['roidname'] = '""'
- if (len(par)>=3): attr['roidname'] = par[2]
+ if (len(par)>=3):
+ attr['roidname'] = par[2]
+ elif attr['roid'][0] != '"':
+ attr['roidname'] = '"' + attr['roid'] + '"'
rkey = '/'.join([rtype, attr['roid']])
self.add_item('REGISTER', rkey, attr=attr, fn=fn, lineno=lineno)
@@ -1852,10 +1861,14 @@ class EthCnf:
default_flags = 0x00
stack = []
while 1:
- line = f.readline()
- lineno += 1
+ if not f.closed:
+ line = f.readline()
+ lineno += 1
+ else:
+ line = None
if not line:
- f.close()
+ if not f.closed:
+ f.close()
if stack:
frec = stack.pop()
fn, f, lineno = frec['fn'], frec['f'], frec['lineno']
@@ -1865,7 +1878,9 @@ class EthCnf:
if comment.search(line): continue
result = directive.search(line)
if result: # directive
- if result.group('name') == 'OPT':
+ if result.group('name') == 'END_OF_CNF':
+ f.close()
+ elif result.group('name') == 'OPT':
ctx = result.group('name')
par = get_par(line[result.end():], 0, -1, fn=fn, lineno=lineno)
if not par: continue