[Spice-devel] [PATCH v2 00/43] Implements partial wireshark dissector from protocol specifications

Frediano Ziglio fziglio at redhat.com
Wed Jul 8 06:53:33 PDT 2015


As we have a file to specify the protocol and as is hard to align
wireshark dissector for each change we made I'm trying to do
part of this job to a code generator.

The idea is to have the dissector split in two part, one hand
written and the other automatic.

I tested that changing the code and protocol file the generated
code for marshalling/unmarshalling is still the same.
I have a small network capture to check that output is similar
to current dissector. I tried to copy wireshark field names,
formatting and descriptions.
A known issue is that the protocol did not contains some details
for images and VDAgent so these packet could look a bit poor.

First patches marked as "codegen:" are not really related to this
set but just minor changes.

The protocol file is mainly decorated with additional attributes
(all starting with "ws"), see patch "Allows to specify some new
attributes for wireshark".

I would like to have some comment on implementation, the
attributes used or anothing you can think of.

Changes from v1:
- better generation of header file;
- full support for ws_txt and ws_txt_n attributes;
- generate tree, not only flat list of endless items;
- automated tests during patches.

Frediano Ziglio (43):
  codegen: Import six module before first use
  codegen: Simplify if/else blocks
  codegen: Fix typo in variable name
  codegen: Optimize code indentation avoiding loop
  codegen: Remove duplicate variable initialization
  codegen: Reuse code to fix attribute from prototype file
  codegen: Do some check on attributes
  codegen: Remove old ptr32 attribute
  codegen: Check we don't pop too much indexes
  codegen: Allows to specify C type for index variable
  Start adding code to generate wireshark dissector
  Generate some definition for dissector
  Add new_ett function to be able to create new trees
  Decorate writer class to make easier ifdef/endif handling
  Generate scheleton for messages and channels
  Allows to specify some new attributes for wireshark
  Allows to specify descriptions for enumerations
  Allows to specify attributes for array items and pointers
  Decorate protocol file with attributes for wireshark
  Change code generated index type
  Add code to handle destination variable
  Parse containers
  Write function to write members
  Read values from primitive fields
  test: Allows to write items to tree and dump saved tree
  test: Add code to read input from a file (or stdin)
  Handle base fields
  show primitive as primitive
  Read array size
  Generate code to output parse structure
  Handle array
  Handle switch
  Implement ws_inline attribute
  Handle pointers
  Introduce a class to handle wireshark attributes
  Allow to override default values generated for the fields
  Allow to specify 'CHANNEL' as type
  Use a class to register wireshark fields
  Allows to have two type with different size to point to same field
    name
  Handle flags
  Handle text formatting of different elements
  Test decorated array
  Add some format checks with arrays

 Makefile.am                     |    2 +-
 codegen/Makefile.am             |   63 +++
 codegen/check_dissector         |   67 +++
 codegen/data_base1              |  Bin 0 -> 44 bytes
 codegen/data_empty              |    0
 codegen/data_u16s               |  Bin 0 -> 2000 bytes
 codegen/dissector_test.c        |  660 ++++++++++++++++++++++++
 codegen/out_array2.txt          |   28 ++
 codegen/out_array_primitive.txt |  110 ++++
 codegen/out_array_raw.txt       |   13 +
 codegen/out_array_struct.txt    |  158 ++++++
 codegen/out_base1.txt           |  148 ++++++
 codegen/out_channel.txt         |    7 +
 codegen/out_empty.txt           |    1 +
 codegen/out_struct1.txt         |   10 +
 codegen/test.proto              |  113 +++++
 common/Makefile.am              |    1 +
 configure.ac                    |    2 +
 python_modules/Makefile.am      |    1 +
 python_modules/codegen.py       |   10 +-
 python_modules/dissector.py     | 1060 +++++++++++++++++++++++++++++++++++++++
 python_modules/marshal.py       |   29 +-
 python_modules/ptypes.py        |  151 +++++-
 python_modules/spice_parser.py  |   37 +-
 spice.proto                     |  414 +++++++--------
 spice_codegen.py                |   17 +-
 26 files changed, 2844 insertions(+), 258 deletions(-)
 create mode 100644 codegen/Makefile.am
 create mode 100755 codegen/check_dissector
 create mode 100644 codegen/data_base1
 create mode 100644 codegen/data_empty
 create mode 100755 codegen/data_u16s
 create mode 100644 codegen/dissector_test.c
 create mode 100644 codegen/out_array2.txt
 create mode 100644 codegen/out_array_primitive.txt
 create mode 100644 codegen/out_array_raw.txt
 create mode 100644 codegen/out_array_struct.txt
 create mode 100644 codegen/out_base1.txt
 create mode 100644 codegen/out_channel.txt
 create mode 100644 codegen/out_empty.txt
 create mode 100644 codegen/out_struct1.txt
 create mode 100644 codegen/test.proto
 create mode 100644 python_modules/dissector.py

-- 
2.1.0



More information about the Spice-devel mailing list