MessageDef DEFINITIONS AUTOMATIC TAGS ::= BEGIN
MessageWrapper ::= SEQUENCE {
header MsgHeader,
body OCTET STRING (SIZE (0..900000)) -- opaque payload - msg body (array of bytes)
-- arbitrary limit of roughly 0.9 MB
}
MsgHeader ::= SEQUENCE {
type TeletexString,
flags FlagsSet, -- flags for packet processing, next field present only if compressedFlag is TRUE
compressClass TeletexString (SIZE (1..80)) OPTIONAL
}
FlagsSet ::= SEQUENCE {
compressedFlag BOOLEAN,
encrypted BOOLEAN
}
END
Attempt to generate codecs in C or Rust result in:
$ asn1tools -v 2 generate_c_source MessageDef.asn
error: MessageDef.MsgHeader.type: Unsupported type 'TeletexString'.
$ asn1tools -v 2 generate_rust_source MessageDef.asn
error: unsupported operand type(s) for ** or pow(): 'int' and 'NoneType'
$
Needless to say, changing TeletexString to, e.g., OCTET STRING, does not help.
Here's Rust with debug:
$ asn1tools -v 2 -d generate_rust_source MessageDef.asn
Traceback (most recent call last):
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/bin/asn1tools", line 33, in <module>
sys.exit(load_entry_point('asn1tools==0.155.3', 'console_scripts', 'asn1tools')())
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/asn1tools/__init__.py", line 433, in _main
args.func(args)
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/asn1tools/__init__.py", line 318, in _do_generate_rust_source
source = rust.generate(compiled, args.codec)
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/asn1tools/source/rust/__init__.py", line 23, in generate
helpers, types_code = uper.generate(compiled)
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/asn1tools/source/rust/uper.py", line 781, in generate
return _Generator().generate(compiled)
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/asn1tools/source/rust/utils.py", line 507, in generate
definition = self.generate_definition(compiled_type)
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/asn1tools/source/rust/utils.py", line 478, in generate_definition
encode_lines, decode_lines = self.generate_definition_inner_process(
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/asn1tools/source/rust/uper.py", line 370, in generate_definition_inner_process
return self.format_sequence_inner(type_, checker)
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/asn1tools/source/rust/uper.py", line 459, in format_sequence_inner
member_decode_lines) = self.format_sequence_inner_member(
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/asn1tools/source/rust/utils.py", line 418, in format_sequence_inner_member
encode_lines, decode_lines = self.format_type_inner(
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/asn1tools/source/rust/uper.py", line 678, in format_type_inner
return self.format_octet_string_inner(type_, checker)
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/asn1tools/source/rust/uper.py", line 495, in format_octet_string_inner
if not does_bits_match_range(type_.number_of_bits,
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/asn1tools/source/rust/uper.py", line 292, in does_bits_match_range
return 2 ** number_of_bits == (maximum - minimum + 1)
TypeError: unsupported operand type(s) for ** or pow(): 'int' and 'NoneType'
$
Here's debug with C:
$ asn1tools -v 2 -d generate_c_source MessageDef.asn
Traceback (most recent call last):
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/bin/asn1tools", line 33, in <module>
sys.exit(load_entry_point('asn1tools==0.155.3', 'console_scripts', 'asn1tools')())
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/asn1tools/__init__.py", line 433, in _main
args.func(args)
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/asn1tools/__init__.py", line 278, in _do_generate_c_source
header, source, fuzzer_source, fuzzer_makefile = c.generate(
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/asn1tools/source/c/__init__.py", line 390, in generate
structs, declarations, helpers, definitions = oer.generate(
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/asn1tools/source/c/oer.py", line 1086, in generate
return _Generator(namespace).generate(compiled)
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/asn1tools/source/c/utils.py", line 661, in generate
type_declaration = self.generate_type_declaration(compiled_type)
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/asn1tools/source/c/utils.py", line 598, in generate_type_declaration
lines = self.generate_type_declaration_process(type_, checker)
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/asn1tools/source/c/oer.py", line 210, in generate_type_declaration_process
lines = self.format_sequence(type_, checker)[1:-1]
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/asn1tools/source/c/utils.py", line 447, in format_sequence
lines += self.add_sequence_member(member, checker)
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/asn1tools/source/c/utils.py", line 370, in add_sequence_member
member_lines = self.format_type(member, member_checker)
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/asn1tools/source/c/oer.py", line 170, in format_type
raise self.error(
asn1tools.errors.Error: MessageDef.MsgHeader.type: Unsupported type 'TeletexString'.
Simple ASN.1 file:
Attempt to generate codecs in C or Rust result in:
Needless to say, changing
TeletexString
to, e.g.,OCTET STRING
, does not help.Here's Rust with debug:
Here's debug with C:
In case it helps:
In case it matters, my platform is: