aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-gmhdr.c
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2013-01-11 19:20:39 +0000
committerMichael Mann <mmann78@netscape.net>2013-01-11 19:20:39 +0000
commit660e028212cc75397aaa78bf915e2556987e0430 (patch)
tree1cdcf2721471a1c64b2cfeaee1e573a141730bd0 /epan/dissectors/packet-gmhdr.c
parenta63b7f92649d9b4b8f55b6fc01cc87942c847a4b (diff)
Add support for expanded Gigamon Trailer format
from Sandeep Dahiya, bug 8191 (https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8191) svn path=/trunk/; revision=47033
Diffstat (limited to 'epan/dissectors/packet-gmhdr.c')
-rw-r--r--epan/dissectors/packet-gmhdr.c163
1 files changed, 121 insertions, 42 deletions
diff --git a/epan/dissectors/packet-gmhdr.c b/epan/dissectors/packet-gmhdr.c
index 82083cbeba..3e2ef78021 100644
--- a/epan/dissectors/packet-gmhdr.c
+++ b/epan/dissectors/packet-gmhdr.c
@@ -38,11 +38,13 @@
#include "packet-ieee8023.h"
#define GMHDR_FTYPE_PKTSIZE 1
-#define GMHDR_FTYPE_SRCPORT 2
+#define GMHDR_FTYPE_SRCPORT_G 2
#define GMHDR_FTYPE_TIMESTAMP_LOCAL 3
#define GMHDR_FTYPE_TIMESTAMP_NTP 4
#define GMHDR_FTYPE_TIMESTAMP_GPS 5
#define GMHDR_FTYPE_TIMESTAMP_1588 6
+#define GMHDR_FTYPE_FCS 7
+#define GMHDR_FTYPE_SRCPORT_H 8
static const value_string gmhdr_ftype_timestamp[] = {
{ GMHDR_FTYPE_TIMESTAMP_LOCAL, "Local" },
@@ -52,18 +54,33 @@ static const value_string gmhdr_ftype_timestamp[] = {
{ 0, NULL }
};
-#define GMHDR_SRCPORT_PLFM_MASK 0x00f80000
-#define GMHDR_SRCPORT_GID_MASK 0x00078000
-#define GMHDR_SRCPORT_BID_MASK 0x00007c00
-#define GMHDR_SRCPORT_PID_MASK 0x000003ff
-#define GMHDR_SRCPORT_PLFM_SHFT 19
-#define GMHDR_SRCPORT_GID_SHFT 15
-#define GMHDR_SRCPORT_BID_SHFT 10
-#define GMHDR_SRCPORT_PID_SHFT 0
+#define GMHDR_SRCPORT_G_PLFM_MASK 0x00f80000
+#define GMHDR_SRCPORT_G_GID_MASK 0x00078000
+#define GMHDR_SRCPORT_G_BID_MASK 0x00007c00
+#define GMHDR_SRCPORT_G_PID_MASK 0x000003ff
+#define GMHDR_SRCPORT_G_PLFM_SHFT 19
+#define GMHDR_SRCPORT_G_GID_SHFT 15
+#define GMHDR_SRCPORT_G_BID_SHFT 10
+#define GMHDR_SRCPORT_G_PID_SHFT 0
+
+#define GMHDR_SRCPORT_H_PLFM_MASK 0xFC000000
+#define GMHDR_SRCPORT_H_GID_MASK 0x03C00000
+#define GMHDR_SRCPORT_H_BID_MASK 0x003F0000
+#define GMHDR_SRCPORT_H_SID_MASK 0x0000FC00
+#define GMHDR_SRCPORT_H_PID_MASK 0x000003FF
+#define GMHDR_SRCPORT_H_PLFM_SHFT 26
+#define GMHDR_SRCPORT_H_GID_SHFT 20
+#define GMHDR_SRCPORT_H_BID_SHFT 16
+#define GMHDR_SRCPORT_H_SID_SHFT 10
+#define GMHDR_SRCPORT_H_PID_SHFT 0
static const value_string gmhdr_plfm_str[] = {
{ 0, "Reserved" },
{ 1, "GV-2404" },
+ { 2, "GV-420" },
+ { 3, "GV-MP" },
+ { 4, "HD4" },
+ { 5, "HD8" },
{ 0, NULL }
};
@@ -73,17 +90,24 @@ static gboolean gmhdr_decode_timestamp_trailer = TRUE;
static int proto_gmhdr = -1;
static int proto_gmtrailer = -1;
-static int hf_gmhdr_srcport = -1;
-static int hf_gmhdr_srcport_plfm = -1;
-static int hf_gmhdr_srcport_gid = -1;
-static int hf_gmhdr_srcport_bid = -1;
-static int hf_gmhdr_srcport_pid = -1;
+static int hf_gmhdr_srcport_g = -1;
+static int hf_gmhdr_srcport_g_plfm = -1;
+static int hf_gmhdr_srcport_g_gid = -1;
+static int hf_gmhdr_srcport_g_bid = -1;
+static int hf_gmhdr_srcport_g_pid = -1;
static int hf_gmhdr_pktsize = -1;
static int hf_gmhdr_timestamp = -1;
static int hf_gmhdr_generic = -1;
static int hf_gmhdr_etype = -1;
static int hf_gmhdr_len = -1;
static int hf_gmhdr_trailer = -1;
+static int hf_gmhdr_origcrc = -1;
+static int hf_gmhdr_srcport_h = -1;
+static int hf_gmhdr_srcport_h_plfm = -1;
+static int hf_gmhdr_srcport_h_gid = -1;
+static int hf_gmhdr_srcport_h_bid = -1;
+static int hf_gmhdr_srcport_h_sid = -1;
+static int hf_gmhdr_srcport_h_pid = -1;
static int hf_gmtrailer_origcrc = -1;
static int hf_gmtrailer_portid = -1;
@@ -109,7 +133,7 @@ dissect_gmtlv(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *gmhdr_tree, gui
fl = tl & 0xff;
switch (tl >> 8) {
- case GMHDR_FTYPE_SRCPORT: {
+ case GMHDR_FTYPE_SRCPORT_G: {
guint16 pid;
guint32 tv = tvb_get_ntohl(tvb, offset) >> 8; /* Only 24-bit field */
@@ -117,14 +141,14 @@ dissect_gmtlv(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *gmhdr_tree, gui
expert_add_info_format(pinfo, gmhdr_tree, PI_MALFORMED, PI_ERROR, "Field length %u invalid", fl);
break;
}
- ti = proto_tree_add_item(gmhdr_tree, hf_gmhdr_srcport, tvb, offset, fl, ENC_BIG_ENDIAN);
+ ti = proto_tree_add_item(gmhdr_tree, hf_gmhdr_srcport_g, tvb, offset, fl, ENC_BIG_ENDIAN);
srcport_tree = proto_item_add_subtree(ti, ett_srcport);
- proto_tree_add_item(srcport_tree, hf_gmhdr_srcport_plfm, tvb, offset, fl, ENC_BIG_ENDIAN);
- proto_tree_add_item(srcport_tree, hf_gmhdr_srcport_gid, tvb, offset, fl, ENC_BIG_ENDIAN);
- proto_tree_add_item(srcport_tree, hf_gmhdr_srcport_bid, tvb, offset, fl, ENC_BIG_ENDIAN);
- ti = proto_tree_add_item(srcport_tree, hf_gmhdr_srcport_pid, tvb, offset, fl, ENC_BIG_ENDIAN);
+ proto_tree_add_item(srcport_tree, hf_gmhdr_srcport_g_plfm, tvb, offset, fl, ENC_BIG_ENDIAN);
+ proto_tree_add_item(srcport_tree, hf_gmhdr_srcport_g_gid, tvb, offset, fl, ENC_BIG_ENDIAN);
+ proto_tree_add_item(srcport_tree, hf_gmhdr_srcport_g_bid, tvb, offset, fl, ENC_BIG_ENDIAN);
+ ti = proto_tree_add_item(srcport_tree, hf_gmhdr_srcport_g_pid, tvb, offset, fl, ENC_BIG_ENDIAN);
/* If not GV-2404, we need different formula here */
- pid = ((tv & GMHDR_SRCPORT_PID_MASK) >> GMHDR_SRCPORT_PID_SHFT) - 24;
+ pid = ((tv & GMHDR_SRCPORT_G_PID_MASK) >> GMHDR_SRCPORT_G_PID_SHFT) - 24;
if (pid >= 1 && pid <= 4) {
proto_item_append_text(ti, " (g%d)", pid);
}
@@ -148,6 +172,31 @@ dissect_gmtlv(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *gmhdr_tree, gui
ti = proto_tree_add_item(gmhdr_tree, hf_gmhdr_timestamp, tvb, offset, fl, ENC_TIME_TIMESPEC|ENC_BIG_ENDIAN);
proto_item_append_text(ti, "; Source: %s", val_to_str_const(tl>>8, gmhdr_ftype_timestamp, "Unknown"));
break;
+ case GMHDR_FTYPE_FCS: {
+ if (fl != 4) {
+ expert_add_info_format(pinfo, gmhdr_tree, PI_MALFORMED, PI_ERROR, "Field length %u invalid", fl);
+ break;
+ }
+ ti = proto_tree_add_item(gmhdr_tree, hf_gmhdr_origcrc, tvb, offset, 4, ENC_BIG_ENDIAN);
+ proto_item_append_text(ti, ", CRC (Not Verified)");
+ break;
+ }
+ case GMHDR_FTYPE_SRCPORT_H: {
+ guint32 tv = tvb_get_ntohl(tvb, offset);
+
+ if (fl != 4) {
+ expert_add_info_format(pinfo, gmhdr_tree, PI_MALFORMED, PI_ERROR, "Field length %u invalid", fl);
+ break;
+ }
+ ti = proto_tree_add_item(gmhdr_tree, hf_gmhdr_srcport_h, tvb, offset, fl, ENC_BIG_ENDIAN);
+ srcport_tree = proto_item_add_subtree(ti, ett_srcport);
+ proto_tree_add_item(srcport_tree, hf_gmhdr_srcport_h_plfm, tvb, offset, fl, ENC_BIG_ENDIAN);
+ proto_tree_add_item(srcport_tree, hf_gmhdr_srcport_h_gid, tvb, offset, fl, ENC_BIG_ENDIAN);
+ proto_tree_add_item(srcport_tree, hf_gmhdr_srcport_h_bid, tvb, offset, fl, ENC_BIG_ENDIAN);
+ proto_tree_add_item(srcport_tree, hf_gmhdr_srcport_h_sid, tvb, offset, fl, ENC_BIG_ENDIAN);
+ ti = proto_tree_add_item(srcport_tree, hf_gmhdr_srcport_h_pid, tvb, offset, fl, ENC_BIG_ENDIAN);
+ break;
+ }
default:
ti = proto_tree_add_item(gmhdr_tree, hf_gmhdr_generic, tvb, offset, fl, ENC_NA);
proto_item_append_text(ti, " [Id: %u, Length: %u]", tl >> 8, fl);
@@ -276,23 +325,29 @@ dissect_gmtrailer(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void
guint tvblen, length;
proto_tree *gmhdr_tree = NULL;
guint offset;
- guint16 cksum, comp_cksum;
+ guint16 cksum, comp_cksum, extra_trailer;
/* See if this packet has a Gigamon trailer, if yes, then decode it */
/* (Don't throw any exceptions while checking for the trailer). */
tvblen = tvb_length(tvb); /* end+1 */
if (tvblen < 5)
return 0;
- if (tvb_get_ntohs(tvb, tvblen-4) != ETHERTYPE_GIGAMON)
- return 0;
+ if (tvb_get_ntohs(tvb, tvblen-4) != ETHERTYPE_GIGAMON) {
+ extra_trailer = 0;
+ if (tvb_get_ntohs(tvb, tvblen-8) == ETHERTYPE_GIGAMON) {
+ extra_trailer = 4;
+ } else {
+ return 0;
+ }
+ }
- length = tvb_get_guint8(tvb, tvblen-5); /* length of Gigamon header */
- if ((tvblen-5) != length)
+ length = tvb_get_guint8(tvb, tvblen-extra_trailer-5); /* length of Gigamon header */
+ if ((tvblen-extra_trailer-5) != length)
return 0;
- offset = tvblen - 5 - length;
+ offset = tvblen - extra_trailer - 5 - length;
- cksum = tvb_get_ntohs(tvb, tvblen-2);
+ cksum = tvb_get_ntohs(tvb, tvblen-extra_trailer-2);
/* Verify the checksum; if not valid, it means that the trailer is not valid */
{
@@ -317,6 +372,9 @@ dissect_gmtrailer(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void
gmhdr_tree = proto_item_add_subtree(ti, ett_gmhdr);
dissect_gmtlv(tvb, pinfo, gmhdr_tree, offset, length);
+ if (extra_trailer) {
+ proto_tree_add_item(tree, hf_gmhdr_trailer, tvb, length + 5, extra_trailer, ENC_BIG_ENDIAN);
+ }
}
return tvblen;
}
@@ -325,21 +383,21 @@ void
proto_register_gmhdr(void)
{
static hf_register_info hf[] = {
- { &hf_gmhdr_srcport, {
- "Src Port", "gmhdr.srcport", FT_UINT24, BASE_HEX,
+ { &hf_gmhdr_srcport_g, {
+ "Src Port", "gmhdr.srcport_g", FT_UINT24, BASE_HEX,
NULL, 0, "Original Source Port", HFILL }},
- { &hf_gmhdr_srcport_plfm, {
- "Platform Id", "gmhdr.srcport_plfm", FT_UINT24, BASE_DEC,
- VALS(gmhdr_plfm_str), GMHDR_SRCPORT_PLFM_MASK, "Original Platform Id", HFILL }},
- { &hf_gmhdr_srcport_gid, {
- "Group Id", "gmhdr.srcport_gid", FT_UINT24, BASE_DEC,
- NULL, GMHDR_SRCPORT_GID_MASK, "Original Source Group Id", HFILL }},
- { &hf_gmhdr_srcport_bid, {
- "Box Id", "gmhdr.srcport_bid", FT_UINT24, BASE_DEC,
- NULL, GMHDR_SRCPORT_BID_MASK, "Original Source Box Id", HFILL }},
- { &hf_gmhdr_srcport_pid, {
- "Port Id", "gmhdr.srcport_pid", FT_UINT24, BASE_DEC,
- NULL, GMHDR_SRCPORT_PID_MASK, "Original Source Port Id", HFILL }},
+ { &hf_gmhdr_srcport_g_plfm, {
+ "Platform Id", "gmhdr.srcport_g_plfm", FT_UINT24, BASE_DEC,
+ VALS(gmhdr_plfm_str), GMHDR_SRCPORT_G_PLFM_MASK, "Original Platform Id", HFILL }},
+ { &hf_gmhdr_srcport_g_gid, {
+ "Group Id", "gmhdr.srcport_g_gid", FT_UINT24, BASE_DEC,
+ NULL, GMHDR_SRCPORT_G_GID_MASK, "Original Source Group Id", HFILL }},
+ { &hf_gmhdr_srcport_g_bid, {
+ "Box Id", "gmhdr.srcport_g_bid", FT_UINT24, BASE_DEC,
+ NULL, GMHDR_SRCPORT_G_BID_MASK, "Original Source Box Id", HFILL }},
+ { &hf_gmhdr_srcport_g_pid, {
+ "Port Id", "gmhdr.srcport_g_pid", FT_UINT24, BASE_DEC,
+ NULL, GMHDR_SRCPORT_G_PID_MASK, "Original Source Port Id", HFILL }},
{ &hf_gmhdr_pktsize, {
"Original Packet Size", "gmhdr.pktsize", FT_UINT16, BASE_DEC,
NULL, 0, NULL, HFILL }},
@@ -355,6 +413,27 @@ proto_register_gmhdr(void)
{ &hf_gmhdr_len, {
"Length", "gmhdr.len", FT_UINT16, BASE_DEC,
NULL, 0x0, NULL, HFILL }},
+ { &hf_gmhdr_origcrc, {
+ "Original CRC", "gmhdr.crc", FT_UINT32, BASE_HEX,
+ NULL, 0x0, "Original Packet CRC", HFILL }},
+ { &hf_gmhdr_srcport_h, {
+ "Src Port", "gmhdr.srcport", FT_UINT32, BASE_HEX,
+ NULL, 0, "Original Source Port", HFILL }},
+ { &hf_gmhdr_srcport_h_plfm, {
+ "Platform Id", "gmhdr.srcport_plfm", FT_UINT32, BASE_DEC,
+ VALS(gmhdr_plfm_str), GMHDR_SRCPORT_H_PLFM_MASK, "Original Platform Id", HFILL }},
+ { &hf_gmhdr_srcport_h_gid, {
+ "Group Id", "gmhdr.srcport_gid", FT_UINT32, BASE_DEC,
+ NULL, GMHDR_SRCPORT_H_GID_MASK, "Original Source Group Id", HFILL }},
+ { &hf_gmhdr_srcport_h_bid, {
+ "Box Id", "gmhdr.srcport_bid", FT_UINT32, BASE_DEC,
+ NULL, GMHDR_SRCPORT_H_BID_MASK, "Original Source Box Id", HFILL }},
+ { &hf_gmhdr_srcport_h_sid, {
+ "Slot Id", "gmhdr.srcport_sid", FT_UINT32, BASE_DEC,
+ NULL, GMHDR_SRCPORT_H_SID_MASK, "Original Source Slot Id", HFILL }},
+ { &hf_gmhdr_srcport_h_pid, {
+ "Port Id", "gmhdr.srcport_pid", FT_UINT32, BASE_DEC,
+ NULL, GMHDR_SRCPORT_H_PID_MASK, "Original Source Port Id", HFILL }},
{ &hf_gmhdr_trailer, {
"Trailer", "gmhdr.trailer", FT_BYTES, BASE_NONE,
NULL, 0x0, "GMHDR Trailer", HFILL }},