[Spice-devel] [PATCH v2 37/43] Allow to specify 'CHANNEL' as type
Frediano Ziglio
fziglio at redhat.com
Wed Jul 8 06:54:10 PDT 2015
Type will be mapped to an enumerator containing all channel types.
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
codegen/check_dissector | 2 ++
codegen/out_channel.txt | 7 +++++++
codegen/test.proto | 15 +++++++++++++++
python_modules/dissector.py | 14 +++++++++-----
spice.proto | 2 +-
5 files changed, 34 insertions(+), 6 deletions(-)
create mode 100644 codegen/out_channel.txt
diff --git a/codegen/check_dissector b/codegen/check_dissector
index 20d83ff..e2d06b5 100755
--- a/codegen/check_dissector
+++ b/codegen/check_dissector
@@ -60,4 +60,6 @@ check data_u16s 1 100 out_array_primitive.txt --client
check data_u16s 1 101 out_array_raw.txt --client
check data_u16s 1 102 out_array_struct.txt --client
+check data_base1 1 2 out_channel.txt
+
exit 0
diff --git a/codegen/out_channel.txt b/codegen/out_channel.txt
new file mode 100644
index 0000000..5dac17c
--- /dev/null
+++ b/codegen/out_channel.txt
@@ -0,0 +1,7 @@
+--- tree
+ --- item
+ Text: TEST3 (130)
+ Name: channel
+ Abbrev: spice2.auto.msg_base_Channel_channel
+ Type: FT_UINT8
+ Base: BASE_DEC
diff --git a/codegen/test.proto b/codegen/test.proto
index b28520c..0f14125 100644
--- a/codegen/test.proto
+++ b/codegen/test.proto
@@ -64,6 +64,9 @@ channel BaseChannel {
F16 f16;
F32 f32;
} Base1 = 1;
+ message {
+ uint8 channel @ws_type(CHANNEL);
+ } Channel;
Empty empty = 100;
client:
@@ -76,6 +79,18 @@ channel BaseChannel {
ArrayStruct array_struct;
};
+channel Test1Channel: BaseChannel {
+};
+
+channel Test2Channel: BaseChannel {
+};
+
+channel Test3Channel: Test2Channel {
+};
+
protocol Spice {
BaseChannel base = 1;
+ Test1Channel test1;
+ Test2Channel test2;
+ Test3Channel test3 = 130;
};
diff --git a/python_modules/dissector.py b/python_modules/dissector.py
index 2df4723..5639baa 100644
--- a/python_modules/dissector.py
+++ b/python_modules/dissector.py
@@ -276,11 +276,15 @@ def write_wireshark_field(writer, container, member, t, ws, tree, size, encoding
# override type
if ws.type:
- f_type = 'FT_%s' % ws.type
- base = 'BASE_NONE'
- vals = 'NULL'
- if f_type == 'FT_BOOLEAN':
- vals = 'TFS(&tfs_set_notset)'
+ if ws.type == 'CHANNEL':
+ base = 'BASE_DEC'
+ vals = 'VALS(channel_types_vs)'
+ else:
+ f_type = 'FT_%s' % ws.type
+ base = 'BASE_NONE'
+ vals = 'NULL'
+ if f_type == 'FT_BOOLEAN':
+ vals = 'TFS(&tfs_set_notset)'
# override base
if ws.base:
diff --git a/spice.proto b/spice.proto
index 163215b..4ceceaa 100644
--- a/spice.proto
+++ b/spice.proto
@@ -199,7 +199,7 @@ channel BaseChannel {
};
struct ChannelId {
- uint8 type @ws("Channel type", channel_type);
+ uint8 type @ws("Channel type", channel_type) @ws_type(CHANNEL);
uint8 id @ws("Channel ID", channel_id);
} @ws_txt_n("channels[%u]", INDEX);
--
2.1.0
More information about the Spice-devel
mailing list