summaryrefslogtreecommitdiff
path: root/epan/dissectors
diff options
context:
space:
mode:
authorPascal Quantin <pascal.quantin@gmail.com>2016-07-19 09:41:33 +0200
committerAnders Broman <a.broman58@gmail.com>2016-07-19 11:46:59 +0000
commitd75de9f7559f1e0417c06a5b09d0fa3cf775d92c (patch)
tree0b4f6b6fbae4a68d93a703c7f1d34f380cbeb41e /epan/dissectors
parent0da99953581b3c044e9dcf080b0374ace691189b (diff)
downloadwireshark-d75de9f7559f1e0417c06a5b09d0fa3cf775d92c.tar.gz
VXLAN: use the newly created vxlan.next_proto dissector table everywhere
Change-Id: Ib6f44e0f1d3d8c76d2b6e6c778af8c243af4389c Reviewed-on: https://code.wireshark.org/review/16543 Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com> Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/dissectors')
-rw-r--r--epan/dissectors/Makefile.am1
-rw-r--r--epan/dissectors/packet-eth.c3
-rw-r--r--epan/dissectors/packet-ip.c2
-rw-r--r--epan/dissectors/packet-ipv6.c2
-rw-r--r--epan/dissectors/packet-mpls.c2
-rw-r--r--epan/dissectors/packet-nsh.c2
-rw-r--r--epan/dissectors/packet-vxlan.c47
-rw-r--r--epan/dissectors/packet-vxlan.h37
8 files changed, 52 insertions, 44 deletions
diff --git a/epan/dissectors/Makefile.am b/epan/dissectors/Makefile.am
index 1f81ee9c31..5d641c167c 100644
--- a/epan/dissectors/Makefile.am
+++ b/epan/dissectors/Makefile.am
@@ -1752,6 +1752,7 @@ DISSECTOR_INCLUDES = \
packet-usb.h \
packet-usb-hid.h \
packet-usbip.h \
+ packet-vxlan.h \
packet-wap.h \
packet-wccp.h \
packet-windows-common.h \
diff --git a/epan/dissectors/packet-eth.c b/epan/dissectors/packet-eth.c
index 10fdc180ae..bfb6cc5270 100644
--- a/epan/dissectors/packet-eth.c
+++ b/epan/dissectors/packet-eth.c
@@ -42,6 +42,7 @@
#include "packet-juniper.h"
#include "packet-sflow.h"
#include "packet-l2tp.h"
+#include "packet-vxlan.h"
#include <epan/crc32-tvb.h>
#include <wiretap/erf.h>
@@ -1064,7 +1065,7 @@ proto_reg_handoff_eth(void)
dissector_add_uint("juniper.proto", JUNIPER_PROTO_ETHER, eth_withoutfcs_handle);
dissector_add_uint("sflow_245.header_protocol", SFLOW_245_HEADER_ETHERNET, eth_withoutfcs_handle);
dissector_add_uint("l2tp.pw_type", L2TPv3_PROTOCOL_ETH, eth_withoutfcs_handle);
-
+ dissector_add_uint("vxlan.next_proto", VXLAN_ETHERNET, eth_withoutfcs_handle);
dissector_add_uint("sll.ltype", LINUX_SLL_P_ETHERNET, eth_withoutfcs_handle);
/*
diff --git a/epan/dissectors/packet-ip.c b/epan/dissectors/packet-ip.c
index 1590d13cb2..aac46b2cd1 100644
--- a/epan/dissectors/packet-ip.c
+++ b/epan/dissectors/packet-ip.c
@@ -56,6 +56,7 @@
#include "packet-sflow.h"
#include "packet-gre.h"
#include "packet-l2tp.h"
+#include "packet-vxlan.h"
#ifdef HAVE_GEOIP
#include <GeoIP.h>
@@ -3205,6 +3206,7 @@ proto_reg_handoff_ip(void)
dissector_add_for_decode_as("pcli.payload", ip_handle);
dissector_add_uint("wtap_encap", WTAP_ENCAP_RAW_IP4, ip_handle);
dissector_add_uint("enc", BSD_AF_INET, ip_handle);
+ dissector_add_uint("vxlan.next_proto", VXLAN_IPV4, ip_handle);
heur_dissector_add("tipc", dissect_ip_heur, "IP over TIPC", "ip_tipc", proto_ip, HEURISTIC_ENABLE);
register_capture_dissector("ethertype", ETHERTYPE_IP, capture_ip, proto_ip);
diff --git a/epan/dissectors/packet-ipv6.c b/epan/dissectors/packet-ipv6.c
index 90f1bb2571..faba3b26a3 100644
--- a/epan/dissectors/packet-ipv6.c
+++ b/epan/dissectors/packet-ipv6.c
@@ -52,6 +52,7 @@
#include "packet-ip.h"
#include "packet-juniper.h"
#include "packet-sflow.h"
+#include "packet-vxlan.h"
#ifdef HAVE_GEOIP_V6
#include <GeoIP.h>
@@ -3232,6 +3233,7 @@ proto_reg_handoff_ipv6(void)
dissector_add_uint("sflow_245.header_protocol", SFLOW_245_HEADER_IPv6, ipv6_handle);
dissector_add_uint("wtap_encap", WTAP_ENCAP_RAW_IP6, ipv6_handle);
dissector_add_uint("enc", BSD_AF_INET6_BSD, ipv6_handle);
+ dissector_add_uint("vxlan.next_proto", VXLAN_IPV6, ipv6_handle);
dissector_add_for_decode_as("udp.port", ipv6_handle);
diff --git a/epan/dissectors/packet-mpls.c b/epan/dissectors/packet-mpls.c
index d5f9895c98..8ae02e25e9 100644
--- a/epan/dissectors/packet-mpls.c
+++ b/epan/dissectors/packet-mpls.c
@@ -67,6 +67,7 @@
#include "packet-juniper.h"
#include "packet-sflow.h"
#include "packet-l2tp.h"
+#include "packet-vxlan.h"
void proto_register_mpls(void);
void proto_reg_handoff_mpls(void);
@@ -645,6 +646,7 @@ proto_reg_handoff_mpls(void)
dissector_add_uint("sflow_245.header_protocol", SFLOW_245_HEADER_MPLS, mpls_handle);
dissector_add_uint("l2tp.pw_type", L2TPv3_PROTOCOL_MPLS, mpls_handle);
dissector_add_uint("udp.port", UDP_PORT_MPLS_OVER_UDP, mpls_handle);
+ dissector_add_uint("vxlan.next_proto", VXLAN_MPLS, mpls_handle);
mpls_pwcw_handle = create_dissector_handle( dissect_pw_mcw, proto_pw_mcw );
dissector_add_uint( "mpls.label", MPLS_LABEL_INVALID, mpls_pwcw_handle );
diff --git a/epan/dissectors/packet-nsh.c b/epan/dissectors/packet-nsh.c
index d7448205ff..d14a2188ca 100644
--- a/epan/dissectors/packet-nsh.c
+++ b/epan/dissectors/packet-nsh.c
@@ -34,10 +34,10 @@
#include <epan/prefs.h>
#include <epan/ipproto.h>
#include <epan/decode_as.h>
+#include "packet-vxlan.h"
#define MD_TYPE_1 1
#define MD_TYPE_2 2
-#define VXLAN_NSH 4
/* Prototypes */
void proto_reg_handoff_nsh(void);
diff --git a/epan/dissectors/packet-vxlan.c b/epan/dissectors/packet-vxlan.c
index 7f44a066da..5150e679c1 100644
--- a/epan/dissectors/packet-vxlan.c
+++ b/epan/dissectors/packet-vxlan.c
@@ -29,14 +29,10 @@
#include <epan/packet.h>
#include <epan/tfs.h>
+#include "packet-vxlan.h"
#define UDP_PORT_VXLAN 4789
#define UDP_PORT_VXLAN_GPE 4790
-#define VXLAN_IPV4 1
-#define VXLAN_IPV6 2
-#define VXLAN_ETHERNET 3
-#define VXLAN_NSH 4
-#define VXLAN_MPLS 5
void proto_register_vxlan(void);
void proto_reg_handoff_vxlan(void);
@@ -93,10 +89,6 @@ static const value_string vxlan_next_protocols[] = {
};
static dissector_handle_t eth_handle;
-static dissector_handle_t ip_handle;
-static dissector_handle_t ipv6_handle;
-static dissector_handle_t nsh_handle;
-static dissector_handle_t mpls_handle;
static dissector_table_t vxlan_dissector_table;
static int
@@ -106,7 +98,7 @@ dissect_vxlan_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int is
proto_item *ti;
tvbuff_t *next_tvb;
int offset = 0;
- int vxlan_next_proto=-1;
+ guint32 vxlan_next_proto;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "VxLAN");
col_clear(pinfo->cinfo, COL_INFO);
@@ -122,8 +114,7 @@ dissect_vxlan_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int is
proto_tree_add_item(vxlan_tree, hf_vxlan_gpe_reserved_16, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
- proto_tree_add_item(vxlan_tree, hf_vxlan_next_proto, tvb, offset, 1, ENC_BIG_ENDIAN);
- vxlan_next_proto = tvb_get_guint8(tvb, offset);
+ proto_tree_add_item_ret_uint(vxlan_tree, hf_vxlan_next_proto, tvb, offset, 1, ENC_BIG_ENDIAN, &vxlan_next_proto);
offset += 1;
} else {
proto_tree_add_bitmask(vxlan_tree, tvb, offset, hf_vxlan_flags, ett_vxlan_flags, flags_fields, ENC_BIG_ENDIAN);
@@ -142,32 +133,8 @@ dissect_vxlan_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int is
next_tvb = tvb_new_subset_remaining(tvb, offset);
if(is_gpe){
- switch(vxlan_next_proto){
-
- case VXLAN_IPV4 :
- call_dissector(ip_handle, next_tvb, pinfo, tree);
- break;
-
- case VXLAN_IPV6 :
- call_dissector(ipv6_handle, next_tvb, pinfo, tree);
- break;
-
- case VXLAN_ETHERNET :
- call_dissector(eth_handle, next_tvb, pinfo, tree);
- break;
-
- case VXLAN_NSH :
- if(!dissector_try_uint(vxlan_dissector_table, VXLAN_NSH, next_tvb, pinfo, tree))
- call_data_dissector(next_tvb, pinfo, vxlan_tree);
- break;
-
- case VXLAN_MPLS :
- call_dissector(mpls_handle, next_tvb, pinfo, tree);
- break;
-
- default:
- call_data_dissector(next_tvb, pinfo, vxlan_tree);
- break;
+ if(!dissector_try_uint(vxlan_dissector_table, vxlan_next_proto, next_tvb, pinfo, tree)) {
+ call_data_dissector(next_tvb, pinfo, vxlan_tree);
}
} else {
call_dissector(eth_handle, next_tvb, pinfo, tree);
@@ -336,10 +303,6 @@ proto_reg_handoff_vxlan(void)
* FCS.
*/
eth_handle = find_dissector_add_dependency("eth_withoutfcs", proto_vxlan);
- ip_handle = find_dissector_add_dependency("ip", proto_vxlan);
- ipv6_handle = find_dissector_add_dependency("ipv6", proto_vxlan);
- nsh_handle = find_dissector_add_dependency("nsh", proto_vxlan);
- mpls_handle = find_dissector_add_dependency("mpls", proto_vxlan);
vxlan_handle = create_dissector_handle(dissect_vxlan, proto_vxlan);
vxlan_gpe_handle = create_dissector_handle(dissect_vxlan_gpe, proto_vxlan_gpe);
diff --git a/epan/dissectors/packet-vxlan.h b/epan/dissectors/packet-vxlan.h
new file mode 100644
index 0000000000..624ee921d0
--- /dev/null
+++ b/epan/dissectors/packet-vxlan.h
@@ -0,0 +1,37 @@
+/* packet-vxlan.h
+ *
+ * Routines for Virtual eXtensible Local Area Network (VXLAN) packet dissection
+ * RFC 7348 plus draft-smith-vxlan-group-policy-01
+ *
+ * (c) Copyright 2016, Sumit Kumar Jha <sjha3@ncsu.edu>
+ * Support for VXLAN GPE (https://www.ietf.org/id/draft-ietf-nvo3-vxlan-gpe-02.txt)
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __PACKET_VXLAN_H__
+#define __PACKET_VXLAN_H__
+
+#define VXLAN_IPV4 1
+#define VXLAN_IPV6 2
+#define VXLAN_ETHERNET 3
+#define VXLAN_NSH 4
+#define VXLAN_MPLS 5
+
+#endif /* __PACKET_VXLAN_H__ */ \ No newline at end of file