General

The asn2wrs compiler can be used to create a dissector from an ASN.1 specification of a protocol. It is work in progress but has been used to create a number of dissectors.
It supports:

Limitations: Add text here

Inbuilt support for:

About ASN.1

The most useful first step in writing an ASN.1-based dissector is to learn about ASN.1. There are a number of free resources available to help with this. One collection of such resources is maintained on the ASN.1 Consortium's web site.

How to

The compiler needs 4 input files, an ASN.1 description of a protocol, a .cnf file, and two template files. An ASN.1 specification may have to be edited to work, however work is in progress to at least read all ASN1 specifications. Changing the ASN1 file is being depreciated as this creates problems when updating protocols. The H.248 Binary encoding dissector is a good example of a dissector with relatively small changes (work in progress) http://anonsvn.wireshark.org/viewvc/viewvc.cgi/trunk/asn1/h248/ ... add more here

A complete simple ASN1 UDP-based dissector is available.

Building an ASN.1-based plugin

The usual way to build an ASN.1-based dissector is to put it into the asn1 subtree. This works well and is somewhat simpler than building as a plugin, but there are two reasons one might want to build as a plugin:

Reasons one might not want to build as a plugin:

If you still think you'd like to build your module as a plugin, see Building ASN1 Plugins.

Understanding error messages

When running asn2wrs, you could get the following errors:

__main__.ParseError: LexToken(DOT,'.',71)

__main__.ParseError: LexToken(SEMICOLON,';',88)

Handmassaging the ASN file

This is being depreciated. Instead if something is unsupported then preferred way is to report it on the Wireshark dev-mailng list or in bugzilla so asn2wrs can be updated.

Commandline syntax

asn2wrs [-h|?] [-d dbg] [-b] [-p proto] [-c conform_file] [-e] input_file(s) ...

  -h|?          : usage
  -b            : BER (default is PER)
  -u            : unaligned (default is aligned)
  -p proto      : protocol name (implies -S)
                  default is module-name from input_file (renamed by #.MODULE if
 present)
  -F            : create 'field functions'
  -T            : tagged type support (experimental)
  -o name       : output files name core (default is <proto>)
  -O dir        : output directory
  -c conform_file : conformation file
  -I path       : path for conformance file includes
  -e            : create conformation file for exported types
  -S            : single output for multiple modules
  -s template   : single file output (template is input file without .c/.h exten
sion)
  -k            : keep intermediate files though single file output is used
  -L            : suppress #line directive from .cnf file
  -r prefix     : remove the prefix from type names
  input_file(s) : input ASN.1 file(s)

  -d dbg     : debug output, dbg = [l][y][p][s][a][t][c][m][o]
               l - lex
               y - yacc
               p - parsing
               s - internal ASN.1 structure
               a - list of assignments
               t - tables
               c - conformance values
               m - list of compiled modules with dependency
               o - list of output files

Generated files

Intermediate files created:

These files should be included in the template file as in the examples(some are optional).

Explanation for .cnf file and template file .cnf file keywords

Step by step instruction

Hints for using Asn2wrs

Simple ASN1 based dissector

Discussion

sy: Separate the page into two

Asn2wrs (last edited 2010-07-01 11:18:41 by GraemeLunt)