[Spice-devel] [PATCH v3 00/51] Implements partial wireshark dissector from protocol specifications

Frediano Ziglio fziglio at redhat.com
Tue Jul 21 09:45:30 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 since v2:
Patches changes:
- generate packet-spice.h automatically from spice.proto;
- additional checks for flags and arrays;
- use proper index using ws_txt_n attribute;
- do not override text to wrong tree if there are nested level;
- support ws_txt and ws_txt_n attribute on flags;
- updated some comment on attributes (Christophe);
- replace some tabs with spaces as all code is indented with spaces (Christophe);
- updated some description (similar to old dissector).
Patches added:
- check that we used all strings (ws_desc and so on) in spice.proto;
- allow to specify a field name for enumerators;
- allow to specify ws_as attribute for messages;
- additional tests;
- agent dissecting;
- initial image (now Quic) dissecting.

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 (51):
  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
  test: Add check on output strings
  Allows to specify wireshark name for enumerators
  Allows to specify ws_as attribute for messages
  Improve agent dissectors
  Test we don't override text handling other fields
  Allow ws_as attribute on switch members
  Allow to use bytes_count and bytes array length in dissector
  Describe Quic image format from dissector

 Makefile.am                     |    2 +-
 codegen/Makefile.am             |   74 +++
 codegen/check_dissector         |   71 +++
 codegen/check_strings           |   33 ++
 codegen/data_base1              |  Bin 0 -> 44 bytes
 codegen/data_empty              |    0
 codegen/data_struct2            |  Bin 0 -> 9 bytes
 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_flags1.txt          |  107 ++++
 codegen/out_struct1.txt         |   10 +
 codegen/out_struct2.txt         |   28 +
 codegen/test.proto              |  132 +++++
 common/Makefile.am              |    1 +
 configure.ac                    |    2 +
 python_modules/Makefile.am      |    1 +
 python_modules/codegen.py       |   10 +-
 python_modules/dissector.py     | 1093 +++++++++++++++++++++++++++++++++++++++
 python_modules/marshal.py       |   29 +-
 python_modules/ptypes.py        |  220 +++++---
 python_modules/spice_parser.py  |   41 +-
 spice.proto                     |  563 ++++++++++++--------
 spice_codegen.py                |   17 +-
 30 files changed, 3247 insertions(+), 312 deletions(-)
 create mode 100644 codegen/Makefile.am
 create mode 100755 codegen/check_dissector
 create mode 100755 codegen/check_strings
 create mode 100644 codegen/data_base1
 create mode 100644 codegen/data_empty
 create mode 100644 codegen/data_struct2
 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_flags1.txt
 create mode 100644 codegen/out_struct1.txt
 create mode 100644 codegen/out_struct2.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