Trema/Wireshark/OpenFlow Dissector関連情報
OpenFlow Dissector の使い分け
OpenFlow Message のおパケ見をしようとする場合、今のところ以下のツールを使い分ける必要があるようです。
- OpenFlow 1.0
- OpenFlow 1.2/1.3
- CPqD の ofdissector を使う
- CPqD/ofdissector
- Trema-edge + OVSでOpenFlow1.3テスト環境を作る - # cat /var/log/stereocat | tail -n3
これらは
- 共存できません。
- プロトコル別に使い分ける必要があります。
面倒ですね…。いや、CPqD の方は OF1.0 にも対応していて、コレ一つで ofdissector は全部足りるんだと思っていたのです。が、そうでもないようで。OF1.0 についてはデータ読めませんでした。CPqD ofdissector には OF1.2/1.3 のパケットを生成するテスト用のツールがあるんですが、このへんはちゃんとデータ読めてるし、前に trema-edge でも OF1.3 message が読めたのは確認できていたのですが。
まあ、よくよく読めば
TODO
Project wide
- Add support for the old OF 1.0 dissector in parallel
って書いてあるんだよね。まあ仕方ないね。
仕方がないので、~/.wireshark/plugin
には読みたいプロトコルバージョンに併せたプラグインをおいたりはずしたり。うへえ。
Build Stanford OF Dissector
Ubuntu server 13.10 で試してみたんですが、こういうパッチあててやればいけそうです。
diff --git a/utilities/wireshark_dissectors/openflow/Makefile b/utilities/wireshark_dissectors/openflow/Makefile index 8c533ce..74aa93e 100644 --- a/utilities/wireshark_dissectors/openflow/Makefile +++ b/utilities/wireshark_dissectors/openflow/Makefile @@ -1,4 +1,4 @@ -WIRESHARK_SRC_DIR = ../wireshark-1.0.0-includes +WIRESHARK_SRC_DIR = /usr/include/wireshark SRCS = packet-openflow.c plugin.c CC = gcc diff --git a/utilities/wireshark_dissectors/openflow/packet-openflow.c b/utilities/wireshark_dissectors/openflow/packet-openflow.c index aea00f8..febec1b 100644 --- a/utilities/wireshark_dissectors/openflow/packet-openflow.c +++ b/utilities/wireshark_dissectors/openflow/packet-openflow.c @@ -766,7 +766,7 @@ static gint ett_ofp_error_msg_data = -1; void proto_reg_handoff_openflow() { openflow_handle = create_dissector_handle(dissect_openflow, proto_openflow); - dissector_add(TCP_PORT_FILTER, global_openflow_proto, openflow_handle); + dissector_add_uint(TCP_PORT_FILTER, global_openflow_proto, openflow_handle); } #define NO_STRINGS NULL @@ -2232,7 +2232,7 @@ static void dissect_dl_type(proto_tree* tree, gint hf, tvbuff_t *tvb, guint32 *o /* get the datalink type */ guint16 dl_type = tvb_get_ntohs( tvb, *offset ); - const char* description = match_strval(dl_type, etype_vals); + const char* description = try_val_to_str(dl_type, etype_vals); /* put the string-representation in the GUI tree */ proto_tree_add_uint_format(tree, hf, tvb, *offset, 2, dl_type, diff --git a/utilities/wireshark_dissectors/wireshark-1.0.0-includes/epan/value_string.h b/utilities/wireshark_dissectors/wireshark-1.0.0-includes/epan/value_string.h index 86a2f1e..6e633b8 100644 --- a/utilities/wireshark_dissectors/wireshark-1.0.0-includes/epan/value_string.h +++ b/utilities/wireshark_dissectors/wireshark-1.0.0-includes/epan/value_string.h @@ -51,7 +51,7 @@ typedef struct _range_string { extern const gchar* match_strval_idx(guint32 val, const value_string *vs, gint *idx); /* Like match_strval_idx(), but doesn't return the index. */ -extern const gchar* match_strval(guint32 val, const value_string *vs); +extern const gchar* try_val_to_str(guint32 val, const value_string *vs); /* Tries to match val against each element in the value_string array vs. Returns the associated string ptr on a match.
Wireshark OpenFlow Dissector and TremaShark でも書きましたが、もともと trema/vendor/packet-openflow.diff
に dissector_add()
を dissector_add_uint()
にする patch があるのですが、Ubuntu server 13.10, wireshark/1.10.2 では match_strval
も無くなったか変わったかしたようで try_val_to_str()
に変えてやる必要があるようです。(この辺別に細かく調査したわけじゃないのでよくわかってませんが…。)
あと、Makefile で WIRESHARK_SRC_DIR
のパス書き換えてます。Stanford ofdissector には wireshark-1.0.0 でヘッダとか全部くっついてくるのでですが、それ使う必要ないよねもう、と。同梱ヘッダつかってると
packet-openflow.c: In function ?proto_reg_handoff_openflow?: packet-openflow.c:769:5: warning: implicit declaration of function ?dissector_add_uint? [-Wimplicit-function-declaration] dissector_add_uint(TCP_PORT_FILTER, global_openflow_proto, openflow_handle);
って言われるのでもう参照しないでいいじゃんと。(これはいじらなくても動くのは動いてましたけど。)
Build CPqD OF Dissector
Ubuntu13.10, gcc-4.6.1 でビルドしたらエラー
stereocat@oftest07:~/trema-official/ofdissector/src$ scons install | tee scons-install.log 2>&1 scons: Reading SConscript files ... scons: done reading SConscript files. scons: Building targets ... g++ -o openflow-common.os -c -fPIC -I. -I/usr/include/wireshark -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include openflow-common.cpp In file included from openflow-common.cpp:9:0: ./of13/openflow-130.hpp:12:0: warning: "PROTO_TAG_OPENFLOW_VER" redefined [enabled by default] #define PROTO_TAG_OPENFLOW_VER "OFP 1.3" ^ In file included from openflow-common.cpp:8:0: ./of12/openflow-120.hpp:13:0: note: this is the location of the previous definition #define PROTO_TAG_OPENFLOW_VER "OFP 1.2" ^ openflow-common.cpp: In function 'void proto_reg_handoff_openflow()': openflow-common.cpp:59:60: error: 'dissector_add' was not declared in this scope dissector_add("tcp.port", OFP_TCP_PORT, openflow_handle); ^ scons: *** [openflow-common.os] Error 1 scons: building terminated because of errors. stereocat@oftest07:~/trema-official/ofdissector/src$
これも直してやります。
diff --git a/src/openflow-common.cpp b/src/openflow-common.cpp index ef56e70..fecc1f6 100644 --- a/src/openflow-common.cpp +++ b/src/openflow-common.cpp @@ -56,8 +56,8 @@ proto_reg_handoff_openflow (void) { data_handle = find_dissector("data"); openflow_handle = create_dissector_handle(dissect_openflow, proto_openflow); - dissector_add("tcp.port", OFP_TCP_PORT, openflow_handle); - dissector_add("tcp.port", 43984, openflow_handle); + dissector_add_uint("tcp.port", OFP_TCP_PORT, openflow_handle); + dissector_add_uint("tcp.port", 43984, openflow_handle); OFP_100_NS::Context->setHandles(data_handle, openflow_handle); OFP_110_NS::Context->setHandles(data_handle, openflow_handle); OFP_120_NS::Context->setHandles(data_handle, openflow_handle);
/usr/include/wireshark/epan/packet.h
/* Add an entry to a uint dissector table. */ WS_DLL_PUBLIC void dissector_add_uint(const char *abbrev, const guint32 pattern, dissector_handle_t handle);
注意
とりあえず動けばいいやってだけの処置で、中身の構造とかを理解した上で正しい対応になってるのかどうかはわかってません。C/C++とかもう記憶が遠い彼方に行ってしまいました。なので、上記の内容には一切責任が持てませんのであしからず。