X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/c0af6af3011d4c55bdadf3dd76cd5fc1115c50d0..a63600a1fc28dbc7ae7ce9f996829c49a25fb33c:/print-lldp.c diff --git a/print-lldp.c b/print-lldp.c index 34373996..6a41d187 100644 --- a/print-lldp.c +++ b/print-lldp.c @@ -136,19 +136,21 @@ static const struct tok lldp_cap_values[] = { #define LLDP_PRIVATE_8021_SUBTYPE_PROTOCOL_VLAN_ID 2 #define LLDP_PRIVATE_8021_SUBTYPE_VLAN_NAME 3 #define LLDP_PRIVATE_8021_SUBTYPE_PROTOCOL_IDENTITY 4 +#define LLDP_PRIVATE_8021_SUBTYPE_LINKAGGR 7 #define LLDP_PRIVATE_8021_SUBTYPE_CONGESTION_NOTIFICATION 8 #define LLDP_PRIVATE_8021_SUBTYPE_ETS_CONFIGURATION 9 #define LLDP_PRIVATE_8021_SUBTYPE_ETS_RECOMMENDATION 10 #define LLDP_PRIVATE_8021_SUBTYPE_PFC_CONFIGURATION 11 #define LLDP_PRIVATE_8021_SUBTYPE_APPLICATION_PRIORITY 12 #define LLDP_PRIVATE_8021_SUBTYPE_EVB 13 -#define LLDP_PRIVATE_8021_SUBTYPE_CDCP 14 +#define LLDP_PRIVATE_8021_SUBTYPE_CDCP 14 static const struct tok lldp_8021_subtype_values[] = { { LLDP_PRIVATE_8021_SUBTYPE_PORT_VLAN_ID, "Port VLAN Id"}, { LLDP_PRIVATE_8021_SUBTYPE_PROTOCOL_VLAN_ID, "Port and Protocol VLAN ID"}, { LLDP_PRIVATE_8021_SUBTYPE_VLAN_NAME, "VLAN name"}, { LLDP_PRIVATE_8021_SUBTYPE_PROTOCOL_IDENTITY, "Protocol Identity"}, + { LLDP_PRIVATE_8021_SUBTYPE_LINKAGGR, "Link aggregation"}, { LLDP_PRIVATE_8021_SUBTYPE_CONGESTION_NOTIFICATION, "Congestion Notification"}, { LLDP_PRIVATE_8021_SUBTYPE_ETS_CONFIGURATION, "ETS Configuration"}, { LLDP_PRIVATE_8021_SUBTYPE_ETS_RECOMMENDATION, "ETS Recommendation"}, @@ -509,10 +511,10 @@ static const struct tok lldp_pmd_capability_values[] = { #define LLDP_MDI_PAIR_CONTROL_ABILITY (1 << 3) static const struct tok lldp_mdi_values[] = { - { LLDP_MDI_PORT_CLASS, "PSE"}, - { LLDP_MDI_POWER_SUPPORT, "supported"}, - { LLDP_MDI_POWER_STATE, "enabled"}, - { LLDP_MDI_PAIR_CONTROL_ABILITY, "can be controlled"}, + { LLDP_MDI_PORT_CLASS, "PSE"}, + { LLDP_MDI_POWER_SUPPORT, "supported"}, + { LLDP_MDI_POWER_STATE, "enabled"}, + { LLDP_MDI_PAIR_CONTROL_ABILITY, "can be controlled"}, { 0, NULL} }; @@ -617,10 +619,10 @@ print_ets_priority_assignment_table(netdissect_options *ndo, ND_PRINT("\n\t Priority Assignment Table"); ND_PRINT("\n\t Priority : 0 1 2 3 4 5 6 7"); ND_PRINT("\n\t Value : %-3d %-3d %-3d %-3d %-3d %-3d %-3d %-3d", - EXTRACT_U_1(ptr) >> 4, EXTRACT_U_1(ptr) & 0x0f, - EXTRACT_U_1(ptr + 1) >> 4, EXTRACT_U_1(ptr + 1) & 0x0f, - EXTRACT_U_1(ptr + 2) >> 4, EXTRACT_U_1(ptr + 2) & 0x0f, - EXTRACT_U_1(ptr + 3) >> 4, EXTRACT_U_1(ptr + 3) & 0x0f); + GET_U_1(ptr) >> 4, GET_U_1(ptr) & 0x0f, + GET_U_1(ptr + 1) >> 4, GET_U_1(ptr + 1) & 0x0f, + GET_U_1(ptr + 2) >> 4, GET_U_1(ptr + 2) & 0x0f, + GET_U_1(ptr + 3) >> 4, GET_U_1(ptr + 3) & 0x0f); } static void @@ -630,9 +632,9 @@ print_tc_bandwidth_table(netdissect_options *ndo, ND_PRINT("\n\t TC Bandwidth Table"); ND_PRINT("\n\t TC%% : 0 1 2 3 4 5 6 7"); ND_PRINT("\n\t Value : %-3d %-3d %-3d %-3d %-3d %-3d %-3d %-3d", - EXTRACT_U_1(ptr), EXTRACT_U_1(ptr + 1), EXTRACT_U_1(ptr + 2), - EXTRACT_U_1(ptr + 3), EXTRACT_U_1(ptr + 4), EXTRACT_U_1(ptr + 5), - EXTRACT_U_1(ptr + 6), EXTRACT_U_1(ptr + 7)); + GET_U_1(ptr), GET_U_1(ptr + 1), GET_U_1(ptr + 2), + GET_U_1(ptr + 3), GET_U_1(ptr + 4), GET_U_1(ptr + 5), + GET_U_1(ptr + 6), GET_U_1(ptr + 7)); } static void @@ -642,9 +644,9 @@ print_tsa_assignment_table(netdissect_options *ndo, ND_PRINT("\n\t TSA Assignment Table"); ND_PRINT("\n\t Traffic Class: 0 1 2 3 4 5 6 7"); ND_PRINT("\n\t Value : %-3d %-3d %-3d %-3d %-3d %-3d %-3d %-3d", - EXTRACT_U_1(ptr), EXTRACT_U_1(ptr + 1), EXTRACT_U_1(ptr + 2), - EXTRACT_U_1(ptr + 3), EXTRACT_U_1(ptr + 4), EXTRACT_U_1(ptr + 5), - EXTRACT_U_1(ptr + 6), EXTRACT_U_1(ptr + 7)); + GET_U_1(ptr), GET_U_1(ptr + 1), GET_U_1(ptr + 2), + GET_U_1(ptr + 3), GET_U_1(ptr + 4), GET_U_1(ptr + 5), + GET_U_1(ptr + 6), GET_U_1(ptr + 7)); } /* @@ -663,7 +665,7 @@ lldp_private_8021_print(netdissect_options *ndo, if (tlv_len < 4) { return hexdump; } - subtype = EXTRACT_U_1(tptr + 3); + subtype = GET_U_1(tptr + 3); ND_PRINT("\n\t %s Subtype (%u)", tok2str(lldp_8021_subtype_values, "unknown", subtype), @@ -675,54 +677,64 @@ lldp_private_8021_print(netdissect_options *ndo, return hexdump; } ND_PRINT("\n\t port vlan id (PVID): %u", - EXTRACT_BE_U_2(tptr + 4)); + GET_BE_U_2(tptr + 4)); break; case LLDP_PRIVATE_8021_SUBTYPE_PROTOCOL_VLAN_ID: if (tlv_len < 7) { return hexdump; } ND_PRINT("\n\t port and protocol vlan id (PPVID): %u, flags [%s] (0x%02x)", - EXTRACT_BE_U_2(tptr + 5), - bittok2str(lldp_8021_port_protocol_id_values, "none", EXTRACT_U_1(tptr + 4)), - EXTRACT_U_1(tptr + 4)); + GET_BE_U_2(tptr + 5), + bittok2str(lldp_8021_port_protocol_id_values, "none", GET_U_1(tptr + 4)), + GET_U_1(tptr + 4)); break; case LLDP_PRIVATE_8021_SUBTYPE_VLAN_NAME: if (tlv_len < 6) { return hexdump; } - ND_PRINT("\n\t vlan id (VID): %u", EXTRACT_BE_U_2(tptr + 4)); + ND_PRINT("\n\t vlan id (VID): %u", GET_BE_U_2(tptr + 4)); if (tlv_len < 7) { return hexdump; } - sublen = EXTRACT_U_1(tptr + 6); + sublen = GET_U_1(tptr + 6); if (tlv_len < 7+sublen) { return hexdump; } ND_PRINT("\n\t vlan name: "); - (void)nd_printzp(ndo, tptr + 7, sublen, NULL); + nd_printjnp(ndo, tptr + 7, sublen); break; case LLDP_PRIVATE_8021_SUBTYPE_PROTOCOL_IDENTITY: if (tlv_len < 5) { return hexdump; } - sublen = EXTRACT_U_1(tptr + 4); + sublen = GET_U_1(tptr + 4); if (tlv_len < 5+sublen) { return hexdump; } ND_PRINT("\n\t protocol identity: "); - (void)nd_printzp(ndo, tptr + 5, sublen, NULL); + nd_printjnp(ndo, tptr + 5, sublen); break; + + case LLDP_PRIVATE_8021_SUBTYPE_LINKAGGR: + if (tlv_len < 9) { + return hexdump; + } + ND_PRINT("\n\t aggregation status [%s], aggregation port ID %u", + bittok2str(lldp_aggregation_values, "none", GET_U_1((tptr + 4))), + GET_BE_U_4(tptr + 5)); + break; + case LLDP_PRIVATE_8021_SUBTYPE_CONGESTION_NOTIFICATION: if(tlv_len> i) & 0x01); - tval=EXTRACT_U_1(tptr + 5); + tval=GET_U_1(tptr + 5); ND_PRINT("\n\t Pre-Priority Ready Indicator"); ND_PRINT("\n\t Priority : 0 1 2 3 4 5 6 7"); ND_PRINT("\n\t Value : "); @@ -734,7 +746,7 @@ lldp_private_8021_print(netdissect_options *ndo, if(tlv_len> 7, (tval >> 6) & 0x02, (tval >> 3) & 0x07, tval & 0x07); @@ -753,7 +765,7 @@ lldp_private_8021_print(netdissect_options *ndo, if(tlv_len> 7, (tval >> 6) & 0x01, (tval >> 4) & 0x03, (tval & 0x0f)); ND_PRINT("\n\t PFC Enable"); - tval=EXTRACT_U_1(tptr + 5); + tval=GET_U_1(tptr + 5); ND_PRINT("\n\t Priority : 0 1 2 3 4 5 6 7"); ND_PRINT("\n\t Value : "); for(i=0;i> 5, (tval >> 3) & 0x03, (tval & 0x07), - EXTRACT_BE_U_2(tptr + i + 5)); + GET_BE_U_2(tptr + i + 6)); i=i+3; } break; @@ -805,20 +817,20 @@ lldp_private_8021_print(netdissect_options *ndo, return hexdump; } ND_PRINT("\n\t EVB Bridge Status"); - tval=EXTRACT_U_1(tptr + 4); + tval=GET_U_1(tptr + 4); ND_PRINT("\n\t RES: %u, BGID: %u, RRCAP: %u, RRCTR: %u", tval >> 3, (tval >> 2) & 0x01, (tval >> 1) & 0x01, tval & 0x01); ND_PRINT("\n\t EVB Station Status"); - tval=EXTRACT_U_1(tptr + 5); + tval=GET_U_1(tptr + 5); ND_PRINT("\n\t RES: %u, SGID: %u, RRREQ: %u,RRSTAT: %u", tval >> 4, (tval >> 3) & 0x01, (tval >> 2) & 0x01, tval & 0x03); - tval=EXTRACT_U_1(tptr + 6); + tval=GET_U_1(tptr + 6); ND_PRINT("\n\t R: %u, RTE: %u, ",tval >> 5, tval & 0x1f); - tval=EXTRACT_U_1(tptr + 7); + tval=GET_U_1(tptr + 7); ND_PRINT("EVB Mode: %s [%u]", tok2str(lldp_evb_mode_values, "unknown", tval >> 6), tval >> 6); ND_PRINT("\n\t ROL: %u, RWD: %u, ", (tval >> 5) & 0x01, tval & 0x1f); - tval=EXTRACT_U_1(tptr + 8); + tval=GET_U_1(tptr + 8); ND_PRINT("RES: %u, ROL: %u, RKA: %u", tval >> 6, (tval >> 5) & 0x01, tval & 0x1f); break; @@ -826,17 +838,17 @@ lldp_private_8021_print(netdissect_options *ndo, if(tlv_len> 7, (tval >> 4) & 0x07, (tval >> 3) & 0x01); - ND_PRINT("ChnCap: %u", EXTRACT_BE_U_2(tptr + 6) & 0x0fff); + ND_PRINT("ChnCap: %u", GET_BE_U_2(tptr + 6) & 0x0fff); sublen=tlv_len-8; if(sublen%3!=0) { return hexdump; } i=0; while(i> 12, tval & 0x000fff); i=i+3; @@ -864,7 +876,7 @@ lldp_private_8023_print(netdissect_options *ndo, if (tlv_len < 4) { return hexdump; } - subtype = EXTRACT_U_1(tptr + 3); + subtype = GET_U_1(tptr + 3); ND_PRINT("\n\t %s Subtype (%u)", tok2str(lldp_8023_subtype_values, "unknown", subtype), @@ -876,14 +888,14 @@ lldp_private_8023_print(netdissect_options *ndo, return hexdump; } ND_PRINT("\n\t autonegotiation [%s] (0x%02x)", - bittok2str(lldp_8023_autonegotiation_values, "none", EXTRACT_U_1(tptr + 4)), - EXTRACT_U_1(tptr + 4)); + bittok2str(lldp_8023_autonegotiation_values, "none", GET_U_1(tptr + 4)), + GET_U_1(tptr + 4)); ND_PRINT("\n\t PMD autoneg capability [%s] (0x%04x)", - bittok2str(lldp_pmd_capability_values,"unknown", EXTRACT_BE_U_2(tptr + 5)), - EXTRACT_BE_U_2(tptr + 5)); + bittok2str(lldp_pmd_capability_values,"unknown", GET_BE_U_2(tptr + 5)), + GET_BE_U_2(tptr + 5)); ND_PRINT("\n\t MAU type %s (0x%04x)", - tok2str(lldp_mau_types_values, "unknown", EXTRACT_BE_U_2(tptr + 7)), - EXTRACT_BE_U_2(tptr + 7)); + tok2str(lldp_mau_types_values, "unknown", GET_BE_U_2(tptr + 7)), + GET_BE_U_2(tptr + 7)); break; case LLDP_PRIVATE_8023_SUBTYPE_MDIPOWER: @@ -891,9 +903,9 @@ lldp_private_8023_print(netdissect_options *ndo, return hexdump; } ND_PRINT("\n\t MDI power support [%s], power pair %s, power class %s", - bittok2str(lldp_mdi_values, "none", EXTRACT_U_1((tptr + 4))), - tok2str(lldp_mdi_power_pairs_values, "unknown", EXTRACT_U_1((tptr + 5))), - tok2str(lldp_mdi_power_class_values, "unknown", EXTRACT_U_1((tptr + 6)))); + bittok2str(lldp_mdi_values, "none", GET_U_1((tptr + 4))), + tok2str(lldp_mdi_power_pairs_values, "unknown", GET_U_1((tptr + 5))), + tok2str(lldp_mdi_power_class_values, "unknown", GET_U_1((tptr + 6)))); break; case LLDP_PRIVATE_8023_SUBTYPE_LINKAGGR: @@ -901,15 +913,15 @@ lldp_private_8023_print(netdissect_options *ndo, return hexdump; } ND_PRINT("\n\t aggregation status [%s], aggregation port ID %u", - bittok2str(lldp_aggregation_values, "none", EXTRACT_U_1((tptr + 4))), - EXTRACT_BE_U_4(tptr + 5)); + bittok2str(lldp_aggregation_values, "none", GET_U_1((tptr + 4))), + GET_BE_U_4(tptr + 5)); break; case LLDP_PRIVATE_8023_SUBTYPE_MTU: if (tlv_len < 6) { return hexdump; } - ND_PRINT("\n\t MTU size %u", EXTRACT_BE_U_2(tptr + 4)); + ND_PRINT("\n\t MTU size %u", GET_BE_U_2(tptr + 4)); break; default: @@ -924,12 +936,12 @@ lldp_private_8023_print(netdissect_options *ndo, * Extract 34bits of latitude/longitude coordinates. */ static uint64_t -lldp_extract_latlon(const u_char *tptr) +lldp_extract_latlon(netdissect_options *ndo, const u_char *tptr) { uint64_t latlon; - latlon = EXTRACT_U_1(tptr) & 0x3; - latlon = (latlon << 32) | EXTRACT_BE_U_4(tptr + 1); + latlon = GET_U_1(tptr) & 0x3; + latlon = (latlon << 32) | GET_BE_U_4(tptr + 1); return latlon; } @@ -949,7 +961,7 @@ lldp_private_iana_print(netdissect_options *ndo, if (tlv_len < 8) { return hexdump; } - subtype = EXTRACT_U_1(tptr + 3); + subtype = GET_U_1(tptr + 3); ND_PRINT("\n\t %s Subtype (%u)", tok2str(lldp_iana_subtype_values, "unknown", subtype), @@ -958,7 +970,7 @@ lldp_private_iana_print(netdissect_options *ndo, switch (subtype) { case LLDP_IANA_SUBTYPE_MUDURL: ND_PRINT("\n\t MUD-URL="); - (void)nd_printn(ndo, tptr+4, tlv_len-4, NULL); + nd_printjn(ndo, tptr+4, tlv_len-4); break; default: hexdump=TRUE; @@ -986,7 +998,7 @@ lldp_private_tia_print(netdissect_options *ndo, if (tlv_len < 4) { return hexdump; } - subtype = EXTRACT_U_1(tptr + 3); + subtype = GET_U_1(tptr + 3); ND_PRINT("\n\t %s Subtype (%u)", tok2str(lldp_tia_subtype_values, "unknown", subtype), @@ -999,10 +1011,10 @@ lldp_private_tia_print(netdissect_options *ndo, } ND_PRINT("\n\t Media capabilities [%s] (0x%04x)", bittok2str(lldp_tia_capabilities_values, "none", - EXTRACT_BE_U_2(tptr + 4)), EXTRACT_BE_U_2(tptr + 4)); + GET_BE_U_2(tptr + 4)), GET_BE_U_2(tptr + 4)); ND_PRINT("\n\t Device type [%s] (0x%02x)", - tok2str(lldp_tia_device_type_values, "unknown", EXTRACT_U_1(tptr + 6)), - EXTRACT_U_1(tptr + 6)); + tok2str(lldp_tia_device_type_values, "unknown", GET_U_1(tptr + 6)), + GET_U_1(tptr + 6)); break; case LLDP_PRIVATE_TIA_SUBTYPE_NETWORK_POLICY: @@ -1010,23 +1022,23 @@ lldp_private_tia_print(netdissect_options *ndo, return hexdump; } ND_PRINT("\n\t Application type [%s] (0x%02x)", - tok2str(lldp_tia_application_type_values, "none", EXTRACT_U_1(tptr + 4)), - EXTRACT_U_1(tptr + 4)); + tok2str(lldp_tia_application_type_values, "none", GET_U_1(tptr + 4)), + GET_U_1(tptr + 4)); ND_PRINT(", Flags [%s]", bittok2str( - lldp_tia_network_policy_bits_values, "none", EXTRACT_U_1((tptr + 5)))); + lldp_tia_network_policy_bits_values, "none", GET_U_1((tptr + 5)))); ND_PRINT("\n\t Vlan id %u", - LLDP_EXTRACT_NETWORK_POLICY_VLAN(EXTRACT_BE_U_2(tptr + 5))); + LLDP_EXTRACT_NETWORK_POLICY_VLAN(GET_BE_U_2(tptr + 5))); ND_PRINT(", L2 priority %u", - LLDP_EXTRACT_NETWORK_POLICY_L2_PRIORITY(EXTRACT_BE_U_2(tptr + 6))); + LLDP_EXTRACT_NETWORK_POLICY_L2_PRIORITY(GET_BE_U_2(tptr + 6))); ND_PRINT(", DSCP value %u", - LLDP_EXTRACT_NETWORK_POLICY_DSCP(EXTRACT_BE_U_2(tptr + 6))); + LLDP_EXTRACT_NETWORK_POLICY_DSCP(GET_BE_U_2(tptr + 6))); break; case LLDP_PRIVATE_TIA_SUBTYPE_LOCAL_ID: if (tlv_len < 5) { return hexdump; } - location_format = EXTRACT_U_1(tptr + 4); + location_format = GET_U_1(tptr + 4); ND_PRINT("\n\t Location data format %s (0x%02x)", tok2str(lldp_tia_location_data_format_values, "unknown", location_format), location_format); @@ -1037,25 +1049,27 @@ lldp_private_tia_print(netdissect_options *ndo, return hexdump; } ND_PRINT("\n\t Latitude resolution %u, latitude value %" PRIu64, - (EXTRACT_U_1(tptr + 5) >> 2), lldp_extract_latlon(tptr + 5)); + (GET_U_1(tptr + 5) >> 2), + lldp_extract_latlon(ndo, tptr + 5)); ND_PRINT("\n\t Longitude resolution %u, longitude value %" PRIu64, - (EXTRACT_U_1(tptr + 10) >> 2), lldp_extract_latlon(tptr + 10)); + (GET_U_1(tptr + 10) >> 2), + lldp_extract_latlon(ndo, tptr + 10)); ND_PRINT("\n\t Altitude type %s (%u)", - tok2str(lldp_tia_location_altitude_type_values, "unknown",EXTRACT_U_1(tptr + 15) >> 4), - (EXTRACT_U_1(tptr + 15) >> 4)); + tok2str(lldp_tia_location_altitude_type_values, "unknown",GET_U_1(tptr + 15) >> 4), + (GET_U_1(tptr + 15) >> 4)); ND_PRINT("\n\t Altitude resolution %u, altitude value 0x%x", - (EXTRACT_BE_U_2(tptr + 15)>>6)&0x3f, - (EXTRACT_BE_U_4(tptr + 16) & 0x3fffffff)); + (GET_BE_U_2(tptr + 15)>>6)&0x3f, + (GET_BE_U_4(tptr + 16) & 0x3fffffff)); ND_PRINT("\n\t Datum %s (0x%02x)", - tok2str(lldp_tia_location_datum_type_values, "unknown", EXTRACT_U_1(tptr + 20)), - EXTRACT_U_1(tptr + 20)); + tok2str(lldp_tia_location_datum_type_values, "unknown", GET_U_1(tptr + 20)), + GET_U_1(tptr + 20)); break; case LLDP_TIA_LOCATION_DATA_FORMAT_CIVIC_ADDRESS: if (tlv_len < 6) { return hexdump; } - lci_len = EXTRACT_U_1(tptr + 5); + lci_len = GET_U_1(tptr + 5); if (lci_len < 3) { return hexdump; } @@ -1064,11 +1078,11 @@ lldp_private_tia_print(netdissect_options *ndo, } ND_PRINT("\n\t LCI length %u, LCI what %s (0x%02x), Country-code ", lci_len, - tok2str(lldp_tia_location_lci_what_values, "unknown", EXTRACT_U_1(tptr + 6)), - EXTRACT_U_1(tptr + 6)); + tok2str(lldp_tia_location_lci_what_values, "unknown", GET_U_1(tptr + 6)), + GET_U_1(tptr + 6)); /* Country code */ - (void)nd_printzp(ndo, tptr + 7, 2, NULL); + nd_printjnp(ndo, tptr + 7, 2); lci_len = lci_len-3; tptr = tptr + 9; @@ -1078,8 +1092,8 @@ lldp_private_tia_print(netdissect_options *ndo, if (lci_len < 2) { return hexdump; } - ca_type = EXTRACT_U_1(tptr); - ca_len = EXTRACT_U_1(tptr + 1); + ca_type = GET_U_1(tptr); + ca_len = GET_U_1(tptr + 1); tptr += 2; lci_len -= 2; @@ -1096,7 +1110,7 @@ lldp_private_tia_print(netdissect_options *ndo, return hexdump; } - (void)nd_printzp(ndo, tptr, ca_len, NULL); + nd_printjnp(ndo, tptr, ca_len); tptr += ca_len; lci_len -= ca_len; } @@ -1104,7 +1118,7 @@ lldp_private_tia_print(netdissect_options *ndo, case LLDP_TIA_LOCATION_DATA_FORMAT_ECS_ELIN: ND_PRINT("\n\t ECS ELIN id "); - (void)nd_printzp(ndo, tptr + 5, tlv_len - 5, NULL); + nd_printjnp(ndo, tptr + 5, tlv_len - 5); break; default: @@ -1118,13 +1132,13 @@ lldp_private_tia_print(netdissect_options *ndo, return hexdump; } ND_PRINT("\n\t Power type [%s]", - (EXTRACT_U_1(tptr + 4) & 0xC0 >> 6) ? "PD device" : "PSE device"); + (GET_U_1(tptr + 4) & 0xC0 >> 6) ? "PD device" : "PSE device"); ND_PRINT(", Power source [%s]", - tok2str(lldp_tia_power_source_values, "none", (EXTRACT_U_1((tptr + 4)) & 0x30) >> 4)); + tok2str(lldp_tia_power_source_values, "none", (GET_U_1((tptr + 4)) & 0x30) >> 4)); ND_PRINT("\n\t Power priority [%s] (0x%02x)", - tok2str(lldp_tia_power_priority_values, "none", EXTRACT_U_1(tptr + 4) & 0x0f), - EXTRACT_U_1(tptr + 4) & 0x0f); - power_val = EXTRACT_BE_U_2(tptr + 5); + tok2str(lldp_tia_power_priority_values, "none", GET_U_1(tptr + 4) & 0x0f), + GET_U_1(tptr + 4) & 0x0f); + power_val = GET_BE_U_2(tptr + 5); if (power_val < LLDP_TIA_POWER_VAL_MAX) { ND_PRINT(", Power %.1f Watts", ((float)power_val) / 10); } else { @@ -1141,7 +1155,7 @@ lldp_private_tia_print(netdissect_options *ndo, case LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_ASSET_ID: ND_PRINT("\n\t %s ", tok2str(lldp_tia_inventory_values, "unknown", subtype)); - (void)nd_printzp(ndo, tptr + 4, tlv_len - 4, NULL); + nd_printjnp(ndo, tptr + 4, tlv_len - 4); break; default: @@ -1161,16 +1175,17 @@ lldp_private_dcbx_print(netdissect_options *ndo, { int hexdump = FALSE; u_int subtype; - uint8_t tval; + uint16_t tval; uint16_t tlv; uint32_t i, pgval, uval; - u_int tlen, tlv_type, tlv_len; + u_int tlen, tlv_type; + uint16_t tlv_len; const u_char *tptr, *mptr; if (len < 4) { return hexdump; } - subtype = EXTRACT_U_1(pptr + 3); + subtype = GET_U_1(pptr + 3); ND_PRINT("\n\t %s Subtype (%u)", tok2str(lldp_dcbx_subtype_values, "unknown", subtype), @@ -1187,7 +1202,7 @@ lldp_private_dcbx_print(netdissect_options *ndo, ND_TCHECK_LEN(tptr, sizeof(tlv)); - tlv = EXTRACT_BE_U_2(tptr); + tlv = GET_BE_U_2(tptr); tlv_type = LLDP_EXTRACT_TYPE(tlv); tlv_len = LLDP_EXTRACT_LEN(tlv); @@ -1214,11 +1229,11 @@ lldp_private_dcbx_print(netdissect_options *ndo, } ND_PRINT("\n\t Control - Protocol Control (type 0x%x, length %u)", LLDP_DCBX_CONTROL_TLV, tlv_len); - ND_PRINT("\n\t Oper_Version: %u", EXTRACT_U_1(tptr)); - ND_PRINT("\n\t Max_Version: %u", EXTRACT_U_1(tptr + 1)); - ND_PRINT("\n\t Sequence Number: %u", EXTRACT_BE_U_4(tptr + 2)); + ND_PRINT("\n\t Oper_Version: %u", GET_U_1(tptr)); + ND_PRINT("\n\t Max_Version: %u", GET_U_1(tptr + 1)); + ND_PRINT("\n\t Sequence Number: %u", GET_BE_U_4(tptr + 2)); ND_PRINT("\n\t Acknowledgement Number: %u", - EXTRACT_BE_U_4(tptr + 6)); + GET_BE_U_4(tptr + 6)); break; case LLDP_DCBX_PRIORITY_GROUPS_TLV: if (tlv_len < 17) { @@ -1226,29 +1241,30 @@ lldp_private_dcbx_print(netdissect_options *ndo, } ND_PRINT("\n\t Feature - Priority Group (type 0x%x, length %u)", LLDP_DCBX_PRIORITY_GROUPS_TLV, tlv_len); - ND_PRINT("\n\t Oper_Version: %u", EXTRACT_U_1(tptr)); - ND_PRINT("\n\t Max_Version: %u", EXTRACT_U_1(tptr + 1)); - ND_PRINT("\n\t Info block(0x%02X): ", EXTRACT_U_1(tptr + 2)); - tval = EXTRACT_U_1(tptr + 2); + ND_PRINT("\n\t Oper_Version: %u", GET_U_1(tptr)); + ND_PRINT("\n\t Max_Version: %u", GET_U_1(tptr + 1)); + ND_PRINT("\n\t Info block(0x%02X): ", GET_U_1(tptr + 2)); + tval = GET_U_1(tptr + 2); ND_PRINT("Enable bit: %u, Willing bit: %u, Error Bit: %u", (tval & 0x80) ? 1 : 0, (tval & 0x40) ? 1 : 0, (tval & 0x20) ? 1 : 0); - ND_PRINT("\n\t SubType: %u", EXTRACT_U_1(tptr + 3)); + ND_PRINT("\n\t SubType: %u", GET_U_1(tptr + 3)); ND_PRINT("\n\t Priority Allocation"); /* * Array of 8 4-bit priority group ID values; we fetch all * 32 bits and extract each nibble. */ - pgval = EXTRACT_BE_U_4(tptr + 4); + pgval = GET_BE_U_4(tptr + 4); for (i = 0; i <= 7; i++) { ND_PRINT("\n\t PgId_%u: %u", i, (pgval >> (28 - 4 * i)) & 0xF); } ND_PRINT("\n\t Priority Group Allocation"); for (i = 0; i <= 7; i++) - ND_PRINT("\n\t Pg percentage[%u]: %u", i, EXTRACT_U_1(tptr + 8 + i)); - ND_PRINT("\n\t NumTCsSupported: %u", EXTRACT_U_1(tptr + 8 + 8)); + ND_PRINT("\n\t Pg percentage[%u]: %u", i, + GET_U_1(tptr + 8 + i)); + ND_PRINT("\n\t NumTCsSupported: %u", GET_U_1(tptr + 8 + 8)); break; case LLDP_DCBX_PRIORITY_FLOW_CONTROL_TLV: if (tlv_len < 6) { @@ -1257,20 +1273,20 @@ lldp_private_dcbx_print(netdissect_options *ndo, ND_PRINT("\n\t Feature - Priority Flow Control"); ND_PRINT(" (type 0x%x, length %u)", LLDP_DCBX_PRIORITY_FLOW_CONTROL_TLV, tlv_len); - ND_PRINT("\n\t Oper_Version: %u", EXTRACT_U_1(tptr)); - ND_PRINT("\n\t Max_Version: %u", EXTRACT_U_1(tptr + 1)); - ND_PRINT("\n\t Info block(0x%02X): ", EXTRACT_U_1(tptr + 2)); - tval = EXTRACT_U_1(tptr + 2); + ND_PRINT("\n\t Oper_Version: %u", GET_U_1(tptr)); + ND_PRINT("\n\t Max_Version: %u", GET_U_1(tptr + 1)); + ND_PRINT("\n\t Info block(0x%02X): ", GET_U_1(tptr + 2)); + tval = GET_U_1(tptr + 2); ND_PRINT("Enable bit: %u, Willing bit: %u, Error Bit: %u", (tval & 0x80) ? 1 : 0, (tval & 0x40) ? 1 : 0, (tval & 0x20) ? 1 : 0); - ND_PRINT("\n\t SubType: %u", EXTRACT_U_1(tptr + 3)); - tval = EXTRACT_U_1(tptr + 4); - ND_PRINT("\n\t PFC Config (0x%02X)", EXTRACT_U_1(tptr + 4)); + ND_PRINT("\n\t SubType: %u", GET_U_1(tptr + 3)); + tval = GET_U_1(tptr + 4); + ND_PRINT("\n\t PFC Config (0x%02X)", GET_U_1(tptr + 4)); for (i = 0; i <= 7; i++) ND_PRINT("\n\t Priority Bit %u: %s", i, (tval & (1 << i)) ? "Enabled" : "Disabled"); - ND_PRINT("\n\t NumTCPFCSupported: %u", EXTRACT_U_1(tptr + 5)); + ND_PRINT("\n\t NumTCPFCSupported: %u", GET_U_1(tptr + 5)); break; case LLDP_DCBX_APPLICATION_TLV: if (tlv_len < 4) { @@ -1278,26 +1294,27 @@ lldp_private_dcbx_print(netdissect_options *ndo, } ND_PRINT("\n\t Feature - Application (type 0x%x, length %u)", LLDP_DCBX_APPLICATION_TLV, tlv_len); - ND_PRINT("\n\t Oper_Version: %u", EXTRACT_U_1(tptr)); - ND_PRINT("\n\t Max_Version: %u", EXTRACT_U_1(tptr + 1)); - ND_PRINT("\n\t Info block(0x%02X): ", EXTRACT_U_1(tptr + 2)); - tval = EXTRACT_U_1(tptr + 2); + ND_PRINT("\n\t Oper_Version: %u", GET_U_1(tptr)); + ND_PRINT("\n\t Max_Version: %u", GET_U_1(tptr + 1)); + ND_PRINT("\n\t Info block(0x%02X): ", GET_U_1(tptr + 2)); + tval = GET_U_1(tptr + 2); ND_PRINT("Enable bit: %u, Willing bit: %u, Error Bit: %u", (tval & 0x80) ? 1 : 0, (tval & 0x40) ? 1 : 0, (tval & 0x20) ? 1 : 0); - ND_PRINT("\n\t SubType: %u", EXTRACT_U_1(tptr + 3)); + ND_PRINT("\n\t SubType: %u", GET_U_1(tptr + 3)); tval = tlv_len - 4; mptr = tptr + 4; while (tval >= 6) { ND_PRINT("\n\t Application Value"); ND_PRINT("\n\t Application Protocol ID: 0x%04x", - EXTRACT_BE_U_2(mptr)); - uval = EXTRACT_BE_U_3(mptr + 2); + GET_BE_U_2(mptr)); + uval = GET_BE_U_3(mptr + 2); ND_PRINT("\n\t SF (0x%x) Application Protocol ID is %s", (uval >> 22), (uval >> 22) ? "Socket Number" : "L2 EtherType"); ND_PRINT("\n\t OUI: 0x%06x", uval & 0x3fffff); - ND_PRINT("\n\t User Priority Map: 0x%02x", EXTRACT_U_1(mptr + 5)); + ND_PRINT("\n\t User Priority Map: 0x%02x", + GET_U_1(mptr + 5)); tval = tval - 6; mptr = mptr + 6; } @@ -1330,22 +1347,20 @@ lldp_network_addr_print(netdissect_options *ndo, const u_char *tptr, u_int len) if (len < 1) return NULL; len--; - af = EXTRACT_U_1(tptr); + af = GET_U_1(tptr); switch (af) { - case AFNUM_INET: - if (len < 4) + case AFNUM_IP: + if (len < sizeof(nd_ipv4)) return NULL; - /* This cannot be assigned to ipaddr_string(), which is a macro. */ pfunc = ipaddr_string; break; - case AFNUM_INET6: - if (len < 16) + case AFNUM_IP6: + if (len < sizeof(nd_ipv6)) return NULL; - /* This cannot be assigned to ip6addr_string(), which is a macro. */ pfunc = ip6addr_string; break; case AFNUM_802: - if (len < 6) + if (len < MAC_ADDR_LEN) return NULL; pfunc = etheraddr_string; break; @@ -1355,10 +1370,10 @@ lldp_network_addr_print(netdissect_options *ndo, const u_char *tptr, u_int len) } if (!pfunc) { - nd_snprintf(buf, sizeof(buf), "AFI %s (%u), no AF printer !", + snprintf(buf, sizeof(buf), "AFI %s (%u), no AF printer !", tok2str(af_values, "Unknown", af), af); } else { - nd_snprintf(buf, sizeof(buf), "AFI %s (%u): %s", + snprintf(buf, sizeof(buf), "AFI %s (%u): %s", tok2str(af_values, "Unknown", af), af, (*pfunc)(ndo, tptr+1)); } @@ -1380,7 +1395,7 @@ lldp_mgmt_addr_tlv_print(netdissect_options *ndo, if (tlen < 1) { return 0; } - mgmt_addr_len = EXTRACT_U_1(tptr); + mgmt_addr_len = GET_U_1(tptr); tptr++; tlen--; @@ -1401,11 +1416,11 @@ lldp_mgmt_addr_tlv_print(netdissect_options *ndo, return 0; } - intf_num_subtype = EXTRACT_U_1(tptr); + intf_num_subtype = GET_U_1(tptr); ND_PRINT("\n\t %s Interface Numbering (%u): %u", tok2str(lldp_intf_numb_subtype_values, "Unknown", intf_num_subtype), intf_num_subtype, - EXTRACT_BE_U_4(tptr + 1)); + GET_BE_U_4(tptr + 1)); tptr += LLDP_INTF_NUM_LEN; tlen -= LLDP_INTF_NUM_LEN; @@ -1414,14 +1429,14 @@ lldp_mgmt_addr_tlv_print(netdissect_options *ndo, * The OID is optional. */ if (tlen) { - oid_len = EXTRACT_U_1(tptr); + oid_len = GET_U_1(tptr); if (tlen < 1U + oid_len) { return 0; } if (oid_len) { ND_PRINT("\n\t OID length %u", oid_len); - (void)nd_printzp(ndo, tptr + 1, oid_len, NULL); + nd_printjnp(ndo, tptr + 1, oid_len); } } @@ -1448,7 +1463,7 @@ lldp_print(netdissect_options *ndo, ND_TCHECK_LEN(tptr, sizeof(tlv)); - tlv = EXTRACT_BE_U_2(tptr); + tlv = GET_BE_U_2(tptr); tlv_type = LLDP_EXTRACT_TYPE(tlv); tlv_len = LLDP_EXTRACT_LEN(tlv); @@ -1480,7 +1495,7 @@ lldp_print(netdissect_options *ndo, if (tlv_len < 2) { goto trunc; } - subtype = EXTRACT_U_1(tptr); + subtype = GET_U_1(tptr); ND_PRINT("\n\t Subtype %s (%u): ", tok2str(lldp_chassis_subtype_values, "Unknown", subtype), subtype); @@ -1490,7 +1505,7 @@ lldp_print(netdissect_options *ndo, if (tlv_len < 1+6) { goto trunc; } - ND_PRINT("%s", etheraddr_string(ndo, tptr + 1)); + ND_PRINT("%s", GET_ETHERADDR_STRING(tptr + 1)); break; case LLDP_CHASSIS_INTF_NAME_SUBTYPE: /* fall through */ @@ -1498,7 +1513,7 @@ lldp_print(netdissect_options *ndo, case LLDP_CHASSIS_CHASSIS_COMP_SUBTYPE: case LLDP_CHASSIS_INTF_ALIAS_SUBTYPE: case LLDP_CHASSIS_PORT_COMP_SUBTYPE: - (void)nd_printzp(ndo, tptr + 1, tlv_len - 1, NULL); + nd_printjnp(ndo, tptr + 1, tlv_len - 1); break; case LLDP_CHASSIS_NETWORK_ADDR_SUBTYPE: @@ -1521,7 +1536,7 @@ lldp_print(netdissect_options *ndo, if (tlv_len < 2) { goto trunc; } - subtype = EXTRACT_U_1(tptr); + subtype = GET_U_1(tptr); ND_PRINT("\n\t Subtype %s (%u): ", tok2str(lldp_port_subtype_values, "Unknown", subtype), subtype); @@ -1531,7 +1546,7 @@ lldp_print(netdissect_options *ndo, if (tlv_len < 1+6) { goto trunc; } - ND_PRINT("%s", etheraddr_string(ndo, tptr + 1)); + ND_PRINT("%s", GET_ETHERADDR_STRING(tptr + 1)); break; case LLDP_PORT_INTF_NAME_SUBTYPE: /* fall through */ @@ -1539,7 +1554,7 @@ lldp_print(netdissect_options *ndo, case LLDP_PORT_AGENT_CIRC_ID_SUBTYPE: case LLDP_PORT_INTF_ALIAS_SUBTYPE: case LLDP_PORT_PORT_COMP_SUBTYPE: - (void)nd_printzp(ndo, tptr + 1, tlv_len - 1, NULL); + nd_printjnp(ndo, tptr + 1, tlv_len - 1); break; case LLDP_PORT_NETWORK_ADDR_SUBTYPE: @@ -1562,14 +1577,14 @@ lldp_print(netdissect_options *ndo, if (tlv_len < 2) { goto trunc; } - ND_PRINT(": TTL %us", EXTRACT_BE_U_2(tptr)); + ND_PRINT(": TTL %us", GET_BE_U_2(tptr)); } break; case LLDP_PORT_DESCR_TLV: if (ndo->ndo_vflag) { ND_PRINT(": "); - (void)nd_printzp(ndo, tptr, tlv_len, NULL); + nd_printjnp(ndo, tptr, tlv_len); } break; @@ -1579,13 +1594,13 @@ lldp_print(netdissect_options *ndo, * similar to the CDP printer. */ ND_PRINT(": "); - (void)nd_printzp(ndo, tptr, tlv_len, NULL); + nd_printjnp(ndo, tptr, tlv_len); break; case LLDP_SYSTEM_DESCR_TLV: if (ndo->ndo_vflag) { ND_PRINT("\n\t "); - (void)nd_printzp(ndo, tptr, tlv_len, NULL); + nd_printjnp(ndo, tptr, tlv_len); } break; @@ -1600,8 +1615,8 @@ lldp_print(netdissect_options *ndo, if (tlv_len < 4) { goto trunc; } - cap = EXTRACT_BE_U_2(tptr); - ena_cap = EXTRACT_BE_U_2(tptr + 2); + cap = GET_BE_U_2(tptr); + ena_cap = GET_BE_U_2(tptr + 2); ND_PRINT("\n\t System Capabilities [%s] (0x%04x)", bittok2str(lldp_cap_values, "none", cap), cap); ND_PRINT("\n\t Enabled Capabilities [%s] (0x%04x)", @@ -1622,7 +1637,7 @@ lldp_print(netdissect_options *ndo, if (tlv_len < 3) { goto trunc; } - oui = EXTRACT_BE_U_3(tptr); + oui = GET_BE_U_3(tptr); ND_PRINT(": OUI %s (0x%06x)", tok2str(oui_values, "Unknown", oui), oui); switch (oui) {