From Jens Osterkamp:
authorjake <jake@f5534014-38df-0310-8fa8-9805f1628bb7>
Sat, 7 May 2011 14:50:36 +0000 (14:50 +0000)
committerjake <jake@f5534014-38df-0310-8fa8-9805f1628bb7>
Sat, 7 May 2011 14:50:36 +0000 (14:50 +0000)
The following patch adds some code to decode the EVB TLV being standardized in
the upcoming IEEE 802.1Qbg draft 0.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@37014 f5534014-38df-0310-8fa8-9805f1628bb7

epan/dissectors/packet-lldp.c
epan/oui.h

index e1a5c003da59c54844630b9ba98e7d27e03ed110..af5699b2b61b89af0a8b0eec258f53c4ec980fd8 100644 (file)
@@ -80,6 +80,7 @@ static int hf_mgn_obj_id = -1;
 static int hf_org_spc_oui = -1;
 static int hf_ieee_802_1_subtype = -1;
 static int hf_ieee_802_3_subtype = -1;
+static int hf_ieee_802_1qbg_subtype = -1;
 static int hf_media_tlv_subtype = -1;
 static int hf_profinet_tlv_subtype = -1;
 static int hf_profinet_class2_port_status = -1;
@@ -125,6 +126,7 @@ static gint ett_802_3_flags = -1;
 static gint ett_802_3_autoneg_advertised = -1;
 static gint ett_802_3_power = -1;
 static gint ett_802_3_aggregation = -1;
+static gint ett_802_1qbg_capabilities_flags = -1;
 static gint ett_media_capabilities = -1;
 static gint ett_profinet_period = -1;
 static gint ett_cisco_fourwire_tlv = -1;
@@ -180,6 +182,7 @@ static const value_string tlv_oui_subtype_vals[] = {
        { OUI_MEDIA_ENDPOINT,   "TIA" },
        { OUI_PROFINET,         "PROFINET" },
        { OUI_CISCO_2,          "Cisco" },
+       { OUI_IEEE_802_1QBG,    "IEEE 802.1Qbg" },
        { 0, NULL }
 };
 
@@ -217,6 +220,14 @@ static const value_string media_subtypes[] = {
        { 0, NULL }
 };
 
+/* IEEE 802.1Qbg Subtypes */
+static const value_string ieee_802_1qbg_subtypes[] = {
+       { 0x00, "EVB" },
+       { 0x01, "CDCP" },
+       { 0, NULL }
+};
+
+
 /* Media Class Values */
 static const value_string media_class_values[] = {
        { 0,    "Type Not Defined" },
@@ -461,6 +472,13 @@ static const value_string operational_mau_type_values[] = {
 #define INV_AUTONEG_1000BASE_T         0x4000 /* b1000baseT(14),   -- 1000BASE-T half duplex mode */
 #define INV_AUTONEG_1000BASE_TFD       0x8000 /* b1000baseTFD(15)  -- 1000BASE-T full duplex mode */
 
+#define EVB_CAPA_STD           0x8000
+#define EVB_CAPA_RR            0x4000
+
+#define EVB_CAPA_RTE           0x0004
+#define EVB_CAPA_ECP           0x0002
+#define EVB_CAPA_VDP           0x0001
+
 #define MAX_MAC_LEN    6
 
 
@@ -1339,6 +1357,121 @@ dissect_ieee_802_1_tlv(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
        return;
 }
 
+/* Dissect IEEE 802.1Qbg TLVs */
+static void
+dissect_ieee_802_1qbg_tlv(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, guint32 offset)
+{
+       guint8 subType;
+       guint8 tempByte;
+       guint16 tempShort;
+       guint32 tempOffset = offset;
+
+       proto_tree *evb_capabilities_subtree = NULL;
+
+       proto_item *tf = NULL;
+
+       subType = tvb_get_guint8(tvb, tempOffset);
+
+       if (tree)
+               proto_tree_add_item(tree, hf_ieee_802_1qbg_subtype, tvb, tempOffset, 1, FALSE);
+
+       tempOffset++;
+
+       switch (subType) {
+               case 0x00:
+                       /* Get EVB capabilities */
+                       tempShort = tvb_get_ntohs(tvb, tempOffset);
+                       if (tree) {
+                               tf = proto_tree_add_text(tree, tvb, tempOffset, 2, "supported capabilities: 0x%04X", tempShort);
+                               evb_capabilities_subtree = proto_item_add_subtree(tf, ett_802_1qbg_capabilities_flags);
+
+                               if (tempShort & EVB_CAPA_STD)
+                                       proto_tree_add_text(evb_capabilities_subtree, tvb, (offset+2), 2, "%s",
+                                                               decode_boolean_bitfield(tempShort, EVB_CAPA_STD,
+                                                               16, "standard bridging (STD)", ""));
+
+                               if (tempShort & EVB_CAPA_RR)
+                                       proto_tree_add_text(evb_capabilities_subtree, tvb, (offset+2), 2, "%s",
+                                                               decode_boolean_bitfield(tempShort, EVB_CAPA_RR,
+                                                               16, "reflective relay (RR)", ""));
+
+                               if (tempShort & EVB_CAPA_RTE)
+                                       proto_tree_add_text(evb_capabilities_subtree, tvb, (offset+2), 2, "%s",
+                                                               decode_boolean_bitfield(tempShort, EVB_CAPA_RTE,
+                                                               16, "retransmission timer exponent (RTE)", ""));
+
+                               if (tempShort & EVB_CAPA_ECP)
+                                       proto_tree_add_text(evb_capabilities_subtree, tvb, (offset+2), 2, "%s",
+                                                               decode_boolean_bitfield(tempShort, EVB_CAPA_ECP,
+                                                               16, "edge control protocol (ECP)", ""));
+
+                               if (tempShort & EVB_CAPA_VDP)
+                                       proto_tree_add_text(evb_capabilities_subtree, tvb, (offset+2), 2, "%s",
+                                                               decode_boolean_bitfield(tempShort, EVB_CAPA_VDP,
+                                                               16, "VSI discovery protocol (VDP)", ""));
+                       }
+
+                       tempOffset += 2;
+
+                       tempShort = tvb_get_ntohs(tvb, tempOffset);
+                       if (tree) {
+                               tf = proto_tree_add_text(tree, tvb, tempOffset, 2, "configured capabilities: 0x%04X", tempShort);
+                               evb_capabilities_subtree = proto_item_add_subtree(tf, ett_802_1qbg_capabilities_flags);
+
+                               if (tempShort & EVB_CAPA_STD)
+                                       proto_tree_add_text(evb_capabilities_subtree, tvb, (offset+2), 2, "%s",
+                                                               decode_boolean_bitfield(tempShort, EVB_CAPA_STD,
+                                                               16, "standard bridging (STD)", ""));
+
+                               if (tempShort & EVB_CAPA_RR)
+                                       proto_tree_add_text(evb_capabilities_subtree, tvb, (offset+2), 2, "%s",
+                                                               decode_boolean_bitfield(tempShort, EVB_CAPA_RR,
+                                                               16, "reflective relay (RR)", ""));
+
+                               if (tempShort & EVB_CAPA_RTE)
+                                       proto_tree_add_text(evb_capabilities_subtree, tvb, (offset+2), 2, "%s",
+                                                               decode_boolean_bitfield(tempShort, EVB_CAPA_RTE,
+                                                               16, "retransmission timer exponent (RTE)", ""));
+
+                               if (tempShort & EVB_CAPA_ECP)
+                                       proto_tree_add_text(evb_capabilities_subtree, tvb, (offset+2), 2, "%s",
+                                                               decode_boolean_bitfield(tempShort, EVB_CAPA_ECP,
+                                                               16, "edge control protocol (ECP)", ""));
+
+                               if (tempShort & EVB_CAPA_VDP)
+                                       proto_tree_add_text(evb_capabilities_subtree, tvb, (offset+2), 2, "%s",
+                                                               decode_boolean_bitfield(tempShort, EVB_CAPA_VDP,
+                                                               16, "VSI discovery protocol (VDP)", ""));
+                       }
+
+                       tempOffset += 2;
+
+                       tempShort = tvb_get_ntohs(tvb, tempOffset);
+                       if (tree) {
+                               tf = proto_tree_add_text(tree, tvb, tempOffset, 2, "supported no. of VSIs: %04u", tempShort);
+                       }
+
+                       tempOffset += 2;
+
+                       tempShort = tvb_get_ntohs(tvb, tempOffset);
+                       if (tree) {
+                               tf = proto_tree_add_text(tree, tvb, tempOffset, 2, "configured no. of VSIs: %04u", tempShort);
+                       }
+
+                       tempOffset += 2;
+
+                       tempByte= tvb_get_guint8(tvb, tempOffset);
+                       if (tree) {
+                               tf = proto_tree_add_text(tree, tvb, tempOffset, 1, "retransmission timer exponent: %02u", tempByte);
+                       }
+
+                       break;
+       }
+
+       return;
+}
+
+
 /* Dissect IEEE 802.3 TLVs */
 static void
 dissect_ieee_802_3_tlv(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, guint32 offset, guint16 tlvLen)
@@ -2505,6 +2638,9 @@ dissect_organizational_specific_tlv(tvbuff_t *tvb, packet_info *pinfo, proto_tre
        case OUI_CISCO_2:
                subTypeStr = val_to_str(subType, cisco_subtypes, "Unknown subtype (0x%x)");
                break;
+       case OUI_IEEE_802_1QBG:
+               subTypeStr = val_to_str(subType, ieee_802_1qbg_subtypes, "Unknown subtype 0x%x");
+               break;
        default:
                subTypeStr = "Unknown";
                break;
@@ -2551,6 +2687,9 @@ dissect_organizational_specific_tlv(tvbuff_t *tvb, packet_info *pinfo, proto_tre
        case OUI_CISCO_2:
                dissect_cisco_tlv(tvb, pinfo, org_tlv_tree, (offset+5));
                break;
+       case OUI_IEEE_802_1QBG:
+               dissect_ieee_802_1qbg_tlv(tvb, pinfo, org_tlv_tree, (offset+5));
+               break;
        default:
                proto_tree_add_item(org_tlv_tree, hf_unknown_subtype, tvb, (offset+5), (guint16) (tempLen-3), FALSE);
        }
@@ -2774,16 +2913,20 @@ proto_register_lldp(void)
                        NULL, 0, NULL, HFILL }
                },
                { &hf_org_spc_oui,
-                       { "Organization Unique Code",   "lldp.orgtlv.oui", FT_UINT24, BASE_HEX,
-                       VALS(tlv_oui_subtype_vals), 0x0, NULL, HFILL }
+                       { "Organization Unique Code", "lldp.orgtlv.oui", FT_UINT24, BASE_HEX,
+                       VALS(tlv_oui_subtype_vals), 0x0, NULL, HFILL }
                },
                { &hf_ieee_802_1_subtype,
-                       { "IEEE 802.1 Subtype", "lldp.ieee.802_1.subtype", FT_UINT8, BASE_HEX,
-                       VALS(ieee_802_1_subtypes), 0x0, NULL, HFILL }
+                       { "IEEE 802.1 Subtype", "lldp.ieee.802_1.subtype", FT_UINT8, BASE_HEX,
+                       VALS(ieee_802_1_subtypes), 0x0, NULL, HFILL }
                },
                { &hf_ieee_802_3_subtype,
-                       { "IEEE 802.3 Subtype", "lldp.ieee.802_3.subtype", FT_UINT8, BASE_HEX,
-                       VALS(ieee_802_3_subtypes), 0x0, NULL, HFILL }
+                       { "IEEE 802.3 Subtype", "lldp.ieee.802_3.subtype", FT_UINT8, BASE_HEX,
+                       VALS(ieee_802_3_subtypes), 0x0, NULL, HFILL }
+               },
+               { &hf_ieee_802_1qbg_subtype,
+                       { "IEEE 802.1Qbg Subtype", "lldp.ieee.802_1qbg.subtype", FT_UINT8, BASE_HEX,
+                       VALS(ieee_802_1qbg_subtypes), 0x0, NULL, HFILL }
                },
                { &hf_media_tlv_subtype,
                        { "Media Subtype",      "lldp.media.subtype", FT_UINT8, BASE_HEX,
@@ -2907,6 +3050,7 @@ proto_register_lldp(void)
                &ett_802_3_autoneg_advertised,
                &ett_802_3_power,
                &ett_802_3_aggregation,
+               &ett_802_1qbg_capabilities_flags,
                &ett_media_capabilities,
                &ett_profinet_period,
                &ett_cisco_fourwire_tlv
index 52ee84681cc302ead6c0bbe648c25df4bb9ff19f..0cc6cf2ba9e2fadb3a9acf5786704ded40c3e93f 100644 (file)
@@ -60,6 +60,7 @@
 #define OUI_SONY_ERICSSON_6 0x0016B8    /* Sony Ericsson Mobile Communications AB */
 #define OUI_SONY_ERICSSON_7 0x001813    /* Sony Ericsson Mobile Communications AB */
 #define OUI_SONY_ERICSSON_8 0x001963    /* Sony Ericsson Mobile Communications AB */
+#define OUI_IEEE_802_1QBG   0x001B3F    /* IEEE 802.1 Qbg */
 #define OUI_TURBOCELL       0x0020F6    /* KarlNet, who brought you Turbocell */
 #define OUI_CISCOWL         0x004096    /* Cisco Wireless (Aironet) */
 #define OUI_MARVELL         0x005043    /* Marvell Semiconductor */