Huge thanks to our Platinum Members Endace and LiveAction,
and our Silver Member Veeam, for supporting the Wireshark Foundation and project.

Wireshark-dev: [Wireshark-dev] asn2wrs #.TABLE

From: "Graeme Lunt" <graeme@xxxxxxxxxxx>
Date: Mon, 26 Nov 2007 18:38:33 +0100
Tomas, Anders,

I am trying to make the new P7 dissector table driven using the #.TABLE
directives in the conformance file, based on what I can see in the camel
dissector.

I added the following to p7.cnf (it is commented out in the checked-in
version):

# This table creates the value_sting to name P7 operation codes and errors
# in file packet-p7-table.c which is included in the template file
#
#.TABLE_HDR
/* P7 ABSTRACT-OPERATIONS */
const value_string p7_opr_code_strings[] = {
#.TABLE_BODY ABSTRACT-OPERATION
        { %(&operationCode)s, "%(_ident)s" },
#.TABLE_FTR
  { 0, NULL }
;
#.END

ABSTRACT-OPERATION is defined as:

#.CLASS ABSTRACT-OPERATION 
&ArgumentType          
&argumentTypeOptional  BooleanType
&returnResult          BooleanType
&ResultType            
&resultTypeOptional    BooleanType
&Errors                ClassReference ERROR
&Linked                ClassReference OPERATION
&synchronous           BooleanType
&alwaysReturns         BooleanType
&InvokePriority        _FixedTypeValueSetFieldSpec
&ResultPriority        _FixedTypeValueSetFieldSpec
&operationCode         TypeReference Code
#.END

Now I know that I am building the table on "ABSTRACT-OPERATION" rather than
"OPERATION" and "OPERATION" seems to be hard-coded into ans2wrs, but I tried
anyway.

I get the following error (which I didn't before):

        env python "../../tools/asn2wrs.py"  -b -e -X -T  -p p7  -c p7.cnf
-s packet-p7-template   MSAbstractService.asn  MSGeneralAttributeTypes.asn
MSAccessProtocol.asn 
ASN.1 to Wireshark dissector compiler
Traceback (most recent call last):
  File "../../tools/asn2wrs.py", line 7671, in ?
    eth_main()
  File "../../tools/asn2wrs.py", line 7610, in eth_main
    ectx.eth_do_output()
  File "../../tools/asn2wrs.py", line 1987, in eth_do_output
    self.eth_output_table()
  File "../../tools/asn2wrs.py", line 1846, in eth_output_table
    raise sys.exc_type, "%s:%s invalid key %s for information object %s of
%s" % (rep['fn'], rep['lineno'], sys.exc_value, ident, var)
KeyError: "p7.cnf:199 invalid key '&operationCode' for information object
ms-bind of ABSTRACT-OPERATION"

This looks encouraging, as it seems to be saying that it doesn't like
ms-bind not having an operationCode. 
Bind doesn't have an operation code, so I comment out this
ABSTRACT-OPERATION:

-- MS-bind abstract-operation
--ms-bind ABSTRACT-OPERATION ::= {
--  ARGUMENT  MSBindArgument
--  RESULT    MSBindResult
--  ERRORS    {ms-bind-error}
--}

And try again:

        env python "../../tools/asn2wrs.py"  -b -e -X -T  -p p7  -c p7.cnf
-s packet-p7-template   MSAbstractService.asn  MSGeneralAttributeTypes.asn
MSAccessProtocol.asn 
ASN.1 to Wireshark dissector compiler
Traceback (most recent call last):
  File "../../tools/asn2wrs.py", line 7671, in ?
    eth_main()
  File "../../tools/asn2wrs.py", line 7610, in eth_main
    ectx.eth_do_output()
  File "../../tools/asn2wrs.py", line 1987, in eth_do_output
    self.eth_output_table()
  File "../../tools/asn2wrs.py", line 1838, in eth_output_table
    obj = self.get_obj_repr(ident, var_list)
  File "../../tools/asn2wrs.py", line 711, in get_obj_repr
    for f in val.keys():
AttributeError: 'str' object has no attribute 'keys'

It now seems to be trying to output the table - but something fundamental is
wrong.
(I'm afraid my python isn't up to debugging this.)

Any ideas where I am going wrong? Or is this not yet supported in asn2wrs?

Thanks,

Graeme