diff options
author | Jaap Keuter <jaap.keuter@xs4all.nl> | 2011-01-16 21:32:39 +0000 |
---|---|---|
committer | Jaap Keuter <jaap.keuter@xs4all.nl> | 2011-01-16 21:32:39 +0000 |
commit | 8356fdd6ace657314237d86116a83268a6953a20 (patch) | |
tree | f2dc0ba0e2337b6ac272a9d5dce3266a0b8b7138 | |
parent | 8d32d2066a22a6e3b3970961af9fb9a2a64c2ae6 (diff) |
From Vaibhav Katkade:
Add support for newly defined LLDP Four-wire Power-via-MDI and
CDP Spare Pair PoE TLVs
svn path=/trunk/; revision=35559
-rw-r--r-- | epan/dissectors/packet-cdp.c | 58 | ||||
-rw-r--r-- | epan/dissectors/packet-lldp.c | 78 | ||||
-rw-r--r-- | epan/oui.h | 2 |
3 files changed, 134 insertions, 4 deletions
diff --git a/epan/dissectors/packet-cdp.c b/epan/dissectors/packet-cdp.c index 007a319427..7c5c6b86b4 100644 --- a/epan/dissectors/packet-cdp.c +++ b/epan/dissectors/packet-cdp.c @@ -74,6 +74,7 @@ static gint ett_cdp_tlv = -1; static gint ett_cdp_nrgyz_tlv = -1; static gint ett_cdp_address = -1; static gint ett_cdp_capabilities = -1; +static gint ett_cdp_spare_poe_tlv = -1; static gint ett_cdp_checksum = -1; static dissector_handle_t data_handle; @@ -86,6 +87,8 @@ static void dissect_nrgyz_tlv(tvbuff_t *tvb, int offset, guint16 length, guint16 num, proto_tree *tree); static void +dissect_spare_poe_tlv(tvbuff_t *tvb, int offset, int length, proto_tree *tree); +static void add_multi_line_string_to_tree(proto_tree *tree, tvbuff_t *tvb, gint start, gint len, const gchar *prefix); @@ -117,6 +120,7 @@ add_multi_line_string_to_tree(proto_tree *tree, tvbuff_t *tvb, gint start, #define TYPE_POWER_AVAILABLE 0x001a /* Power Available */ #define TYPE_PORT_UNIDIR 0x001b /* Port Unidirectional */ #define TYPE_NRGYZ 0x001d /* EnergyWise over CDP */ +#define TYPE_SPARE_POE 0x001f /* Spare Pair PoE */ static const value_string type_vals[] = { { TYPE_DEVICE_ID, "Device ID" }, @@ -145,6 +149,7 @@ static const value_string type_vals[] = { { TYPE_POWER_AVAILABLE, "Power Available" }, { TYPE_PORT_UNIDIR, "Port Unidirectional" }, { TYPE_NRGYZ, "EnergyWise" }, + { TYPE_SPARE_POE, "Spare PoE" }, { 0, NULL } }; @@ -886,6 +891,21 @@ dissect_cdp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) offset += length; break; + case TYPE_SPARE_POE: + if (tree) { + tlvi = proto_tree_add_text(cdp_tree, tvb, offset, length, + "Spare Pair PoE"); + tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv); + + proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, FALSE); + proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, FALSE); + } + offset += 4; + length -= 4; + dissect_spare_poe_tlv(tvb, offset, length, tlv_tree); + offset += length; + break; + default: if (tree) { tlvi = proto_tree_add_text(cdp_tree, tvb, offset, @@ -1156,6 +1176,41 @@ dissect_nrgyz_tlv(tvbuff_t *tvb, int offset, guint16 length, guint16 num, } static void +dissect_spare_poe_tlv(tvbuff_t *tvb, int offset, int length, + proto_tree *tree) +{ + proto_item *ti; + proto_tree *tlv_tree; + guint8 tlv_data; + + if (length == 0) { + return; + } + + tlv_data = tvb_get_guint8(tvb, offset); + ti = proto_tree_add_text(tree, tvb, offset, length, + "Spare Pair PoE: 0x%02x", tlv_data); + tlv_tree = proto_item_add_subtree(ti, ett_cdp_spare_poe_tlv); + + proto_tree_add_text(tlv_tree, tvb, offset, 1, "%s", + decode_boolean_bitfield(tlv_data, 0x01, 8, + "PSE Four-Wire PoE Supported", + "PSE Four-Wire PoE Not Supported")); + proto_tree_add_text(tlv_tree, tvb, offset, 1, "%s", + decode_boolean_bitfield(tlv_data, 0x02, 8, + "PD Spare Pair Architecture Shared", + "PD Spare Pair Architecture Independent")); + proto_tree_add_text(tlv_tree, tvb, offset, 1, "%s", + decode_boolean_bitfield(tlv_data, 0x04, 8, + "PD Request Spare Pair PoE On", + "PD Request Spare Pair PoE Off")); + proto_tree_add_text(tlv_tree, tvb, offset, 1, "%s", + decode_boolean_bitfield(tlv_data, 0x08, 8, + "PSE Spare Pair PoE On", + "PSE Spare Pair PoE Off")); +} + +static void add_multi_line_string_to_tree(proto_tree *tree, tvbuff_t *tvb, gint start, gint len, const gchar *prefix) { @@ -1233,7 +1288,8 @@ proto_register_cdp(void) &ett_cdp_nrgyz_tlv, &ett_cdp_address, &ett_cdp_capabilities, - &ett_cdp_checksum + &ett_cdp_checksum, + &ett_cdp_spare_poe_tlv }; proto_cdp = proto_register_protocol("Cisco Discovery Protocol", diff --git a/epan/dissectors/packet-lldp.c b/epan/dissectors/packet-lldp.c index 408326f85c..7f0f2dae7a 100644 --- a/epan/dissectors/packet-lldp.c +++ b/epan/dissectors/packet-lldp.c @@ -103,6 +103,7 @@ static int hf_profinet_orange_period_begin_valid = -1; static int hf_profinet_orange_period_begin_offset = -1; static int hf_profinet_green_period_begin_valid = -1; static int hf_profinet_green_period_begin_offset = -1; +static int hf_cisco_subtype = -1; static int hf_unknown_subtype = -1; /* Initialize the subtree pointers */ @@ -126,6 +127,7 @@ static gint ett_802_3_power = -1; static gint ett_802_3_aggregation = -1; static gint ett_media_capabilities = -1; static gint ett_profinet_period = -1; +static gint ett_cisco_fourwire_tlv = -1; static const value_string tlv_types[] = { { END_OF_LLDPDU_TLV_TYPE, "End of LLDPDU"}, @@ -177,6 +179,7 @@ static const value_string tlv_oui_subtype_vals[] = { { OUI_IEEE_802_3, "IEEE 802.3" }, { OUI_MEDIA_ENDPOINT, "TIA" }, { OUI_PROFINET, "PROFINET" }, + { OUI_CISCO_2, "Cisco" }, { 0, NULL } }; @@ -249,6 +252,12 @@ static const value_string profinet_subtypes[] = { { 0, NULL } }; +/* Cisco Subtypes */ +static const value_string cisco_subtypes[] = { + { 1, "Four-wire Power-via-MDI" }, + { 0, NULL } +}; + /* 802.3 Power Type */ static const value_string power_type_802_3[] = { { 0, "Type 2" }, @@ -1665,14 +1674,14 @@ dissect_ieee_802_3_tlv(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, tempOffset++; - /* Power Value: 1 to 255 expected */ + /* Power Value: 1 to 510 expected */ tempShort = tvb_get_ntohs(tvb, tempOffset); if (tree) proto_tree_add_text(tree, tvb, tempOffset, 2, "PD Requested Power Value: %u.%u Watt", tempShort/10, tempShort%10); tempOffset+=2; - /* Power Value: 1 to 255 expected */ + /* Power Value: 1 to 510 expected */ tempShort = tvb_get_ntohs(tvb, tempOffset); if (tree) proto_tree_add_text(tree, tvb, tempOffset, 2, "PSE Allocated Power Value: %u.%u Watt", tempShort/10, tempShort%10); @@ -2403,6 +2412,58 @@ dissect_profinet_tlv(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, gu } } +/* Dissect Cisco OUI TLVs */ +static void +dissect_cisco_tlv(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, guint32 offset) +{ + guint8 subType; + guint8 tempByte; + guint32 tempOffset = offset; + + proto_tree *fourwire_data = NULL; + proto_item *tf = NULL; + + /* Get subtype */ + subType = tvb_get_guint8(tvb, tempOffset); + + proto_tree_add_item(tree, hf_cisco_subtype, tvb, tempOffset, 1, FALSE); + + tempOffset++; + + switch (subType) + { + case 0x01: /* Four-Wire Power-via-MDI TLV */ + tempByte = tvb_get_guint8(tvb, tempOffset); + if (tree) { + tf = proto_tree_add_text(tree, tvb, tempOffset, 1, "Four-Wire Power-via-MDI: 0x%02x", tempByte); + fourwire_data = proto_item_add_subtree(tf, ett_cisco_fourwire_tlv); + + proto_tree_add_text(fourwire_data, tvb, tempOffset, 1, "%s", + decode_boolean_bitfield(tempByte, 0x01, 8, + "PSE Four-Wire PoE Supported", + "PSE Four-Wire PoE Not Supported")); + + proto_tree_add_text(fourwire_data, tvb, tempOffset, 1, "%s", + decode_boolean_bitfield(tempByte, 0x02, 8, + "PD Spare Pair Architecture Shared", + "PD Spare Pair Architecture Independent")); + + proto_tree_add_text(fourwire_data, tvb, tempOffset, 1, "%s", + decode_boolean_bitfield(tempByte, 0x04, 8, + "PD Request Spare Pair PoE On", + "PD Request Spare Pair PoE Off")); + + proto_tree_add_text(fourwire_data, tvb, tempOffset, 1, "%s", + decode_boolean_bitfield(tempByte, 0x08, 8, + "PSE Spare Pair PoE On", + "PSE Spare Pair PoE Off")); + } + break; + default: + proto_tree_add_item(tree, hf_unknown_subtype, tvb, offset, 1, FALSE); + break; + } +} /* Dissect Organizational Specific TLV */ static gint32 @@ -2443,6 +2504,9 @@ dissect_organizational_specific_tlv(tvbuff_t *tvb, packet_info *pinfo, proto_tre case OUI_PROFINET: subTypeStr = val_to_str(subType, profinet_subtypes, "Reserved (0x%x)"); break; + case OUI_CISCO_2: + subTypeStr = val_to_str(subType, cisco_subtypes, "Unknown subtype (0x%x)"); + break; default: subTypeStr = "Unknown"; break; @@ -2486,6 +2550,9 @@ dissect_organizational_specific_tlv(tvbuff_t *tvb, packet_info *pinfo, proto_tre case OUI_PROFINET: dissect_profinet_tlv(tvb, pinfo, org_tlv_tree, (offset+5), (guint16) (tempLen-3)); break; + case OUI_CISCO_2: + dissect_cisco_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); } @@ -2812,6 +2879,10 @@ proto_register_lldp(void) { "GreenPeriodBegin.Offset", "lldp.profinet.green_period_begin_offset", FT_UINT32, BASE_DEC, NULL, 0x7FFFFFFF, "Unrestricted period, offset to cycle begin in nanoseconds", HFILL } }, + { &hf_cisco_subtype, + { "Cisco Subtype", "lldp.cisco.subtype", FT_UINT8, BASE_HEX, + VALS(cisco_subtypes), 0x0, NULL, HFILL } + }, { &hf_unknown_subtype, { "Unknown Subtype Content","lldp.unknown_subtype", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } @@ -2839,7 +2910,8 @@ proto_register_lldp(void) &ett_802_3_power, &ett_802_3_aggregation, &ett_media_capabilities, - &ett_profinet_period + &ett_profinet_period, + &ett_cisco_fourwire_tlv }; /* Register the protocol name and description */ diff --git a/epan/oui.h b/epan/oui.h index 080250725d..97bf37192a 100644 --- a/epan/oui.h +++ b/epan/oui.h @@ -41,6 +41,8 @@ #define OUI_IANA 0x00005E /* the IANA */ #define OUI_NORTEL 0x000081 /* Nortel SONMP */ #define OUI_CISCO_90 0x0000F8 /* Cisco (IOS 9.0 and above?) */ +#define OUI_CISCO_2 0x000142 /* Cisco */ +#define OUI_CISCO_3 0x000143 /* Cisco */ #define OUI_FORCE10 0x0001E8 /* Force10 */ #define OUI_ERICSSON 0x0001EC /* Ericsson Group */ #define OUI_CATENA 0x00025A /* Catena Networks */ |