IANA assigned port number 6653 to OpenFlow. However, applications

(e.g. opendaylight, nox, openvswitch, etc) still use legacy port
numbers.  The most common are 6633 and 6634.  This patch adds a
simple heuristic logic and uses the current uint preference as
additional input.  In most cases no user intervention is needed and
OpenFlow is automatically detected/dissected.

Change-Id: Iebf09b7b870efe9d52421b9acc238208d25d4565
Signed-off-by: Francesco Fondelli <francesco.fondelli@gmail.com>
Reviewed-on: https://code.wireshark.org/review/921
Reviewed-by: Hadriel Kaplan <hadrielk@yahoo.com>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
This commit is contained in:
Francesco Fondelli 2014-04-02 14:12:01 +02:00 committed by Alexis La Goutte
parent 564730120e
commit e60ed4fc30
2 changed files with 44 additions and 11 deletions

View File

@ -2369,6 +2369,7 @@ Francesco Fondelli <francesco.fondelli[AT]gmail.com> {
Support for Exclude Routes (XRO) in RSVP-TE, RFC 4874 Support for Exclude Routes (XRO) in RSVP-TE, RFC 4874
Support for Shared Use of Experimental TCP Options Support for Shared Use of Experimental TCP Options
Support for TCP Fast Open Support for TCP Fast Open
OpenFlow heuristic logic
} }
Artem Tamazov <artem.tamazov[AT]tellabs.com> { Artem Tamazov <artem.tamazov[AT]tellabs.com> {

View File

@ -36,8 +36,13 @@
void proto_register_openflow(void); void proto_register_openflow(void);
void proto_reg_handoff_openflow(void); void proto_reg_handoff_openflow(void);
static int g_openflow_port = 0; #define OFP_LEGACY_PORT 6633
#define OFP_LEGACY2_PORT 6634
#define OFP_IANA_PORT 6653
static int g_openflow_port = OFP_IANA_PORT;
static gboolean openflow_heur_enabled = TRUE;
static dissector_handle_t openflow_handle;
static dissector_handle_t openflow_v1_handle; static dissector_handle_t openflow_v1_handle;
static dissector_handle_t openflow_v4_handle; static dissector_handle_t openflow_v4_handle;
static dissector_handle_t openflow_v5_handle; static dissector_handle_t openflow_v5_handle;
@ -63,14 +68,12 @@ static const value_string openflow_version_values[] = {
{ 0, NULL } { 0, NULL }
}; };
static guint static guint
get_openflow_pdu_length(packet_info *pinfo _U_, tvbuff_t *tvb, int offset) get_openflow_pdu_length(packet_info *pinfo _U_, tvbuff_t *tvb, int offset)
{ {
return tvb_get_ntohs(tvb, offset + 2); return tvb_get_ntohs(tvb, offset + 2);
} }
static int static int
dissect_openflow_tcp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) dissect_openflow_tcp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{ {
@ -100,14 +103,37 @@ dissect_openflow_tcp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, vo
return tvb_length(tvb); return tvb_length(tvb);
} }
#define OFP_HEADER_LEN 8 #define OFP_HEADER_LEN 8
static int static int
dissect_openflow(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) dissect_openflow(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
{ {
tcp_dissect_pdus(tvb, pinfo, tree, openflow_desegment, OFP_HEADER_LEN, tcp_dissect_pdus(tvb, pinfo, tree, openflow_desegment, OFP_HEADER_LEN,
get_openflow_pdu_length, dissect_openflow_tcp_pdu, data); get_openflow_pdu_length, dissect_openflow_tcp_pdu, data);
return tvb_length(tvb); return tvb_captured_length(tvb);
}
static gboolean
dissect_openflow_heur(tvbuff_t *tvb, packet_info *pinfo,
proto_tree *tree, void *data)
{
conversation_t *conversation = NULL;
if (!openflow_heur_enabled) {
return FALSE;
}
if ((pinfo->destport != OFP_LEGACY_PORT) &&
(pinfo->destport != OFP_LEGACY2_PORT) &&
(pinfo->destport != OFP_IANA_PORT) &&
(pinfo->destport != (guint32)g_openflow_port)) {
return FALSE;
}
conversation = find_or_create_conversation(pinfo);
conversation_set_dissector(conversation, openflow_handle);
dissect_openflow(tvb, pinfo, tree, data);
return TRUE;
} }
/* /*
@ -138,9 +164,17 @@ proto_register_openflow(void)
openflow_module = prefs_register_protocol(proto_openflow, proto_reg_handoff_openflow); openflow_module = prefs_register_protocol(proto_openflow, proto_reg_handoff_openflow);
/* Register port preference */ /* Register port preference */
prefs_register_uint_preference(openflow_module, "tcp.port", "openflow TCP Port", prefs_register_uint_preference(openflow_module, "tcp.port", "OpenFlow TCP port",
" openflow TCP port if other than the default", " OpenFlow TCP port (6653 is the IANA assigned port)",
10, &g_openflow_port); 10, &g_openflow_port);
/* Register heuristic preference */
prefs_register_bool_preference(openflow_module, "heuristic",
"Try to decode OpenFlow on other common ports",
"Try to decode OpenFlow on several common "
"ports in addition to the one supplied by "
"user above (6653 is the IANA assigned port).",
&openflow_heur_enabled);
/* Register desegment preference */ /* Register desegment preference */
prefs_register_bool_preference(openflow_module, "desegment", prefs_register_bool_preference(openflow_module, "desegment",
@ -154,13 +188,12 @@ void
proto_reg_handoff_openflow(void) proto_reg_handoff_openflow(void)
{ {
static gboolean initialized = FALSE; static gboolean initialized = FALSE;
static dissector_handle_t openflow_handle;
static int currentPort; static int currentPort;
if (!initialized) { if (!initialized) {
openflow_handle = new_create_dissector_handle(dissect_openflow, proto_openflow); openflow_handle = new_create_dissector_handle(dissect_openflow, proto_openflow);
heur_dissector_add("tcp", dissect_openflow_heur, proto_openflow);
initialized = TRUE; initialized = TRUE;
} else { } else {
dissector_delete_uint("tcp.port", currentPort, openflow_handle); dissector_delete_uint("tcp.port", currentPort, openflow_handle);
} }
@ -174,7 +207,6 @@ proto_reg_handoff_openflow(void)
openflow_v5_handle = find_dissector("openflow_v5"); openflow_v5_handle = find_dissector("openflow_v5");
} }
/* /*
* Editor modelines - http://www.wireshark.org/tools/modelines.html * Editor modelines - http://www.wireshark.org/tools/modelines.html
* *