[Spice-devel] [PATCH v6 02/42] dissector: Start adding code to generate wireshark dissector
Frediano Ziglio
fziglio at redhat.com
Thu Aug 13 06:11:41 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>
---
python_modules/Makefile.am | 1 +
python_modules/dissector.py | 14 ++++++++++++++
spice_codegen.py | 17 ++++++++++++++---
3 files changed, 29 insertions(+), 3 deletions(-)
create mode 100644 python_modules/dissector.py
diff --git a/python_modules/Makefile.am b/python_modules/Makefile.am
index 3a4515a..e370718 100644
--- a/python_modules/Makefile.am
+++ b/python_modules/Makefile.am
@@ -8,6 +8,7 @@ dist_python_codegen_DATA = \
marshal.py \
ptypes.py \
spice_parser.py \
+ dissector.py \
$(NULL)
DISTCLEANFILES = *.pyc
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 2f3dbff..0a6cefc 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):
@@ -116,7 +117,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,
@@ -124,6 +125,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")
@@ -219,8 +223,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.4.3
More information about the Spice-devel
mailing list