X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/ee68aa36460d7efeca48747f33b7f2adc0900bfb..8d3c2ed39e1b365da42c3aa5d2c5d6a6a5796bac:/print-openflow-1.0.c diff --git a/print-openflow-1.0.c b/print-openflow-1.0.c index 12051992..71d8a7c1 100644 --- a/print-openflow-1.0.c +++ b/print-openflow-1.0.c @@ -6,7 +6,7 @@ * up bogus values of selected message fields and decodes partially captured * messages up to the snapshot end. It is based on the specification below: * - * [OF10] http://www.openflow.org/documents/openflow-spec-v1.0.0.pdf + * [OF10] https://web.archive.org/web/20160402132157/http://archive.openflow.org/documents/openflow-spec-v1.0.0.pdf * * Most functions in this file take 3 arguments into account: * * cp -- the pointer to the first octet to decode @@ -697,12 +697,11 @@ static const char * vlan_str(const uint16_t vid) { static char buf[sizeof("65535 (bogus)")]; - const char *fmt; if (vid == OFP_VLAN_NONE) return "NONE"; - fmt = (vid > 0 && vid < 0x0fff) ? "%u" : "%u (bogus)"; - nd_snprintf(buf, sizeof(buf), fmt, vid); + snprintf(buf, sizeof(buf), "%u%s", vid, + (vid > 0 && vid < 0x0fff) ? "" : " (bogus)"); return buf; } @@ -710,7 +709,8 @@ static const char * pcp_str(const uint8_t pcp) { static char buf[sizeof("255 (bogus)")]; - nd_snprintf(buf, sizeof(buf), pcp <= 7 ? "%u" : "%u (bogus)", pcp); + snprintf(buf, sizeof(buf), "%u%s", pcp, + pcp <= 7 ? "" : " (bogus)"); return buf; } @@ -813,7 +813,7 @@ of10_bsn_message_print(netdissect_options *ndo, cp += 3; /* mask */ ND_TCHECK_4(cp); - ND_PRINT(", mask %s", ipaddr_string(ndo, cp)); + ND_PRINT(", mask %s", GET_IPADDR_STRING(cp)); cp += 4; break; case BSN_SET_MIRRORING: @@ -1128,7 +1128,7 @@ of10_packet_data_print(netdissect_options *ndo, ND_TCHECK_LEN(cp, len); ndo->ndo_vflag -= 3; ND_PRINT(", frame decoding below\n"); - ether_print(ndo, cp, len, ndo->ndo_snapend - cp, NULL, NULL); + ether_print(ndo, cp, len, ND_BYTES_AVAILABLE_AFTER(cp), NULL, NULL); ndo->ndo_vflag += 3; return cp + len; @@ -1155,7 +1155,7 @@ of10_phy_ports_print(netdissect_options *ndo, cp += 2; /* hw_addr */ ND_TCHECK_LEN(cp, MAC_ADDR_LEN); - ND_PRINT(", hw_addr %s", etheraddr_string(ndo, cp)); + ND_PRINT(", hw_addr %s", GET_ETHERADDR_STRING(cp)); cp += MAC_ADDR_LEN; /* name */ ND_TCHECK_LEN(cp, OFP_MAX_PORT_NAME_LEN); @@ -1351,7 +1351,7 @@ of10_match_print(netdissect_options *ndo, uint32_t wildcards; uint16_t dl_type; uint8_t nw_proto; - u_char nw_bits; + u_int nw_bits; const char *field_name; /* wildcards */ @@ -1369,12 +1369,12 @@ of10_match_print(netdissect_options *ndo, /* dl_src */ ND_TCHECK_LEN(cp, MAC_ADDR_LEN); if (! (wildcards & OFPFW_DL_SRC)) - ND_PRINT("%smatch dl_src %s", pfx, etheraddr_string(ndo, cp)); + ND_PRINT("%smatch dl_src %s", pfx, GET_ETHERADDR_STRING(cp)); cp += MAC_ADDR_LEN; /* dl_dst */ ND_TCHECK_LEN(cp, MAC_ADDR_LEN); if (! (wildcards & OFPFW_DL_DST)) - ND_PRINT("%smatch dl_dst %s", pfx, etheraddr_string(ndo, cp)); + ND_PRINT("%smatch dl_dst %s", pfx, GET_ETHERADDR_STRING(cp)); cp += MAC_ADDR_LEN; /* dl_vlan */ ND_TCHECK_2(cp); @@ -1416,13 +1416,13 @@ of10_match_print(netdissect_options *ndo, ND_TCHECK_4(cp); nw_bits = (wildcards & OFPFW_NW_SRC_MASK) >> OFPFW_NW_SRC_SHIFT; if (nw_bits < 32) - ND_PRINT("%smatch nw_src %s/%u", pfx, ipaddr_string(ndo, cp), 32 - nw_bits); + ND_PRINT("%smatch nw_src %s/%u", pfx, GET_IPADDR_STRING(cp), 32 - nw_bits); cp += 4; /* nw_dst */ ND_TCHECK_4(cp); nw_bits = (wildcards & OFPFW_NW_DST_MASK) >> OFPFW_NW_DST_SHIFT; if (nw_bits < 32) - ND_PRINT("%smatch nw_dst %s/%u", pfx, ipaddr_string(ndo, cp), 32 - nw_bits); + ND_PRINT("%smatch nw_dst %s/%u", pfx, GET_IPADDR_STRING(cp), 32 - nw_bits); cp += 4; /* tp_src */ ND_TCHECK_2(cp); @@ -1546,7 +1546,7 @@ of10_actions_print(netdissect_options *ndo, case OFPAT_SET_DL_DST: /* dl_addr */ ND_TCHECK_LEN(cp, MAC_ADDR_LEN); - ND_PRINT(", dl_addr %s", etheraddr_string(ndo, cp)); + ND_PRINT(", dl_addr %s", GET_ETHERADDR_STRING(cp)); cp += MAC_ADDR_LEN; /* pad */ ND_TCHECK_6(cp); @@ -1556,7 +1556,7 @@ of10_actions_print(netdissect_options *ndo, case OFPAT_SET_NW_DST: /* nw_addr */ ND_TCHECK_4(cp); - ND_PRINT(", nw_addr %s", ipaddr_string(ndo, cp)); + ND_PRINT(", nw_addr %s", GET_IPADDR_STRING(cp)); cp += 4; break; case OFPAT_SET_NW_TOS: @@ -1727,7 +1727,7 @@ of10_port_mod_print(netdissect_options *ndo, cp += 2; /* hw_addr */ ND_TCHECK_LEN(cp, MAC_ADDR_LEN); - ND_PRINT(", hw_addr %s", etheraddr_string(ndo, cp)); + ND_PRINT(", hw_addr %s", GET_ETHERADDR_STRING(cp)); cp += MAC_ADDR_LEN; /* config */ ND_TCHECK_4(cp);