[Spice-devel] [PATCH v4 01/41] dissector: Start adding code to generate wireshark dissector
Frediano Ziglio
fziglio at redhat.com
Thu Jul 23 08:54:18 PDT 2015
Added a stub dissector.py code.
Added file to Makefiles.
Add option to call dissector and code to call it.
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
common/Makefile.am | 1 +
python_modules/Makefile.am | 1 +
python_modules/dissector.py | 14 ++++++++++++++
spice_codegen.py | 17 ++++++++++++++---
4 files changed, 30 insertions(+), 3 deletions(-)
create mode 100644 python_modules/dissector.py
diff --git a/common/Makefile.am b/common/Makefile.am
index b4384e8..5e1bffe 100644
--- a/common/Makefile.am
+++ b/common/Makefile.am
@@ -106,6 +106,7 @@ MARSHALLERS_DEPS = \
$(top_srcdir)/python_modules/marshal.py \
$(top_srcdir)/python_modules/ptypes.py \
$(top_srcdir)/python_modules/spice_parser.py \
+ $(top_srcdir)/python_modules/dissector.py \
$(top_srcdir)/spice_codegen.py \
$(NULL)
diff --git a/python_modules/Makefile.am b/python_modules/Makefile.am
index 50e1a71..5983d5b 100644
--- a/python_modules/Makefile.am
+++ b/python_modules/Makefile.am
@@ -7,6 +7,7 @@ PYTHON_MODULES = \
marshal.py \
ptypes.py \
spice_parser.py \
+ dissector.py \
$(NULL)
EXTRA_DIST = $(PYTHON_MODULES)
diff --git a/python_modules/dissector.py b/python_modules/dissector.py
new file mode 100644
index 0000000..90ba498
--- /dev/null
+++ b/python_modules/dissector.py
@@ -0,0 +1,14 @@
+
+from . import codegen
+
+def write_protocol_parser(writer, proto):
+ pass
+
+def write_includes(writer):
+ writer.newline()
+ writer.writeln('#include <epan/packet.h>')
+ writer.writeln('#include <epan/conversation.h>')
+ writer.writeln('#include <epan/expert.h>')
+ writer.newline()
+ writer.writeln('#include "packet-spice.h"')
+ writer.newline()
diff --git a/spice_codegen.py b/spice_codegen.py
index 569cccc..4f0d5cf 100755
--- a/spice_codegen.py
+++ b/spice_codegen.py
@@ -9,6 +9,7 @@ from python_modules import ptypes
from python_modules import codegen
from python_modules import demarshal
from python_modules import marshal
+from python_modules import dissector
import six
def write_channel_enums(writer, channel, client, describe):
@@ -110,7 +111,7 @@ parser.add_option("-e", "--generate-enums",
action="store_true", dest="generate_enums", default=False,
help="Generate enums")
parser.add_option("-w", "--generate-wireshark-dissector",
- action="store_true", dest="generate_dissector", default=False,
+ action="store_true", dest="generate_enum_dissector", default=False,
help="Generate Wireshark dissector definitions")
parser.add_option("-d", "--generate-demarshallers",
action="store_true", dest="generate_demarshallers", default=False,
@@ -118,6 +119,9 @@ parser.add_option("-d", "--generate-demarshallers",
parser.add_option("-m", "--generate-marshallers",
action="store_true", dest="generate_marshallers", default=False,
help="Generate message marshallers")
+parser.add_option("--generate-dissector",
+ action="store_true", dest="generate_dissector", default=False,
+ help="Generate dissector")
parser.add_option("-P", "--private-marshallers",
action="store_true", dest="private_marshallers", default=False,
help="Generate private message marshallers")
@@ -213,8 +217,15 @@ if options.includes:
writer.header.writeln('#include <%s>' % i)
writer.writeln('#include <%s>' % i)
-if options.generate_enums or options.generate_dissector:
- write_enums(writer, options.generate_dissector)
+if options.generate_enums or options.generate_enum_dissector:
+ write_enums(writer, options.generate_enum_dissector)
+
+if options.generate_dissector:
+ if options.generate_demarshallers:
+ print >> sys.stderr, "You can't specify --generate-demarshallers with --generate-dissector"
+ sys.exit(1)
+ dissector.write_includes(writer)
+ dissector.write_protocol_parser(writer, proto)
if options.generate_demarshallers:
if not options.server and not options.client:
--
2.1.0
More information about the Spice-devel
mailing list