#.MODULE_IMPORT and #.INCLUDE

These directive in the Asn2wrs conformation file are used to manage references to external type definitions, i.e. IMPORTS.
(The examples below are all from the X.509 Authentication Framework : x509af dissector source code in Wireshark)

Example ASN

This is an example from the X509AF dissector which amongst other things imports definitions from X.509 InformationFramework :

  IMPORTS
    Name, ATTRIBUTE, AttributeType, MATCHING-RULE, Attribute
    FROM InformationFramework informationFramework

Which tells the Asn2wrs compiler that the types 'Name', 'ATTRIBUTE', 'AttributeType', 'MATCHING-RULE' and 'Attribute' are declared inside the external InformationFramework ASN module and that they are referenced from this module.
In order for Asn2wrs to generate correct code for the dissection it is neccesary to give it some help by telling what kind of types these are, i.e. are they INTEGERs or SEQUENCEs or something else.

(In order to be able to access these functions from this module it is important that these types have been declared as #.EXPORTS in the X509 InformationFramework dissector so that they are exported and that we can link to them.)

#.MODULE_IMPORT

First we need to tell Asn2wrs which protocol name Wireshark uses for the functions in this external import, so that Asn2wrs can generate suitable function call signatures to these external functions.
We do this by adding a directive to the conformation file :

  #.MODULE_IMPORT
  InformationFramework x509if

Where InformationFramework is the ASN name for the module used in the asn IMPORTS declaration and that x509if is the name we use inside Wireshark for this protocol.
This tells Asn2wrs that the function name to call to dissect Name would be dissect_x509if_Name(...). Without this knowledge Asn2wrs would not know which function name to generate.

#.INCLUDE

Second, in order for Asn2wrs to generate correct code it also needs to know the BER type and class of these types that are imported, since that would affect how they are to be encoded on the wire.
This information about what kind of BER attributes these imported types have are done using the #.INCLUDE directive in the conformance file:

  #.INCLUDE ../x509if/x509if_exp.cnf

See #.EXPORTS for a description and examples of these types of include files.

#.MODULE_IMPORT (last edited 2008-04-12 17:51:35 by localhost)