]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-openflow-1.0.c
Handle rpcaps:// URLs as well, for rpcap-over-TLS.
[tcpdump] / print-openflow-1.0.c
index ac58d7b3f8529bf1489b0a94161a2450395b4d7e..d019f492460db7d9de9028502daaa5eb1f22d950 100644 (file)
@@ -72,7 +72,6 @@
 #include "oui.h"
 #include "openflow.h"
 
-static const char tstr[] = " [|openflow]";
 
 #define OFPT_HELLO                    0x00
 #define OFPT_ERROR                    0x01
@@ -703,7 +702,7 @@ vlan_str(const uint16_t vid)
        if (vid == OFP_VLAN_NONE)
                return "NONE";
        fmt = (vid > 0 && vid < 0x0fff) ? "%u" : "%u (bogus)";
-       snprintf(buf, sizeof(buf), fmt, vid);
+       nd_snprintf(buf, sizeof(buf), fmt, vid);
        return buf;
 }
 
@@ -711,7 +710,7 @@ static const char *
 pcp_str(const uint8_t pcp)
 {
        static char buf[sizeof("255 (bogus)")];
-       snprintf(buf, sizeof(buf), pcp <= 7 ? "%u" : "%u (bogus)", pcp);
+       nd_snprintf(buf, sizeof(buf), pcp <= 7 ? "%u" : "%u (bogus)", pcp);
        return buf;
 }
 
@@ -747,7 +746,7 @@ of10_data_print(netdissect_options *ndo,
        return cp + len;
 
 trunc:
-       ND_PRINT("%s", tstr);
+       nd_print_trunc(ndo);
        return ep;
 }
 
@@ -895,7 +894,7 @@ of10_bsn_message_print(netdissect_options *ndo,
                cp += 4;
                /* data */
                ND_PRINT(", data '");
-               if (fn_printn(ndo, cp, len - 8, ep)) {
+               if (nd_printn(ndo, cp, len - 8, ep)) {
                        ND_PRINT("'");
                        goto trunc;
                }
@@ -916,7 +915,7 @@ of10_bsn_message_print(netdissect_options *ndo,
                /* already checked that len >= 4 */
                /* data */
                ND_PRINT(", data '");
-               if (fn_printn(ndo, cp, len - 4, ep)) {
+               if (nd_printn(ndo, cp, len - 4, ep)) {
                        ND_PRINT("'");
                        goto trunc;
                }
@@ -948,11 +947,11 @@ of10_bsn_message_print(netdissect_options *ndo,
        return cp;
 
 invalid: /* skip the undersized data */
-       ND_PRINT("%s", istr);
+       nd_print_invalid(ndo);
        ND_TCHECK_LEN(cp0, len);
        return cp0 + len;
 trunc:
-       ND_PRINT("%s", tstr);
+       nd_print_trunc(ndo);
        return ep;
 }
 
@@ -1022,11 +1021,11 @@ of10_bsn_actions_print(netdissect_options *ndo,
        return cp;
 
 invalid:
-       ND_PRINT("%s", istr);
+       nd_print_invalid(ndo);
        ND_TCHECK_LEN(cp0, len);
        return cp0 + len;
 trunc:
-       ND_PRINT("%s", tstr);
+       nd_print_trunc(ndo);
        return ep;
 }
 
@@ -1051,11 +1050,11 @@ of10_vendor_action_print(netdissect_options *ndo,
        return decoder(ndo, cp, ep, len - 4);
 
 invalid: /* skip the undersized data */
-       ND_PRINT("%s", istr);
+       nd_print_invalid(ndo);
        ND_TCHECK_LEN(cp, len);
        return cp + len;
 trunc:
-       ND_PRINT("%s", tstr);
+       nd_print_trunc(ndo);
        return ep;
 }
 
@@ -1080,11 +1079,11 @@ of10_vendor_message_print(netdissect_options *ndo,
        return decoder(ndo, cp, ep, len - 4);
 
 invalid: /* skip the undersized data */
-       ND_PRINT("%s", istr);
+       nd_print_invalid(ndo);
        ND_TCHECK_LEN(cp, len);
        return cp + len;
 trunc:
-       ND_PRINT("%s", tstr);
+       nd_print_trunc(ndo);
        return ep;
 }
 
@@ -1106,11 +1105,11 @@ of10_vendor_data_print(netdissect_options *ndo,
        return of10_data_print(ndo, cp, ep, len - 4);
 
 invalid: /* skip the undersized data */
-       ND_PRINT("%s", istr);
+       nd_print_invalid(ndo);
        ND_TCHECK_LEN(cp, len);
        return cp + len;
 trunc:
-       ND_PRINT("%s", tstr);
+       nd_print_trunc(ndo);
        return ep;
 }
 
@@ -1132,7 +1131,7 @@ of10_packet_data_print(netdissect_options *ndo,
        return cp + len;
 
 trunc:
-       ND_PRINT("%s", tstr);
+       nd_print_trunc(ndo);
        return ep;
 }
 
@@ -1158,7 +1157,7 @@ of10_phy_ports_print(netdissect_options *ndo,
                /* name */
                ND_TCHECK_LEN(cp, OFP_MAX_PORT_NAME_LEN);
                ND_PRINT(", name '");
-               fn_print(ndo, cp, cp + OFP_MAX_PORT_NAME_LEN);
+               nd_print(ndo, cp, cp + OFP_MAX_PORT_NAME_LEN);
                ND_PRINT("'");
                cp += OFP_MAX_PORT_NAME_LEN;
 
@@ -1209,11 +1208,11 @@ next_port:
        return cp;
 
 invalid: /* skip the undersized trailing data */
-       ND_PRINT("%s", istr);
+       nd_print_invalid(ndo);
        ND_TCHECK_LEN(cp0, len0);
        return cp0 + len0;
 trunc:
-       ND_PRINT("%s", tstr);
+       nd_print_trunc(ndo);
        return ep;
 }
 
@@ -1285,11 +1284,11 @@ next_property:
        return cp;
 
 invalid: /* skip the rest of queue properties */
-       ND_PRINT("%s", istr);
+       nd_print_invalid(ndo);
        ND_TCHECK_LEN(cp0, len0);
        return cp0 + len0;
 trunc:
-       ND_PRINT("%s", tstr);
+       nd_print_trunc(ndo);
        return ep;
 }
 
@@ -1333,11 +1332,11 @@ next_queue:
        return cp;
 
 invalid: /* skip the rest of queues */
-       ND_PRINT("%s", istr);
+       nd_print_invalid(ndo);
        ND_TCHECK_LEN(cp0, len0);
        return cp0 + len0;
 trunc:
-       ND_PRINT("%s", tstr);
+       nd_print_trunc(ndo);
        return ep;
 }
 
@@ -1441,7 +1440,7 @@ of10_match_print(netdissect_options *ndo,
        return cp + 2;
 
 trunc:
-       ND_PRINT("%s", tstr);
+       nd_print_trunc(ndo);
        return ep;
 }
 
@@ -1604,11 +1603,11 @@ next_action:
        return cp;
 
 invalid: /* skip the rest of actions */
-       ND_PRINT("%s", istr);
+       nd_print_invalid(ndo);
        ND_TCHECK_LEN(cp0, len0);
        return cp0 + len0;
 trunc:
-       ND_PRINT("%s", tstr);
+       nd_print_trunc(ndo);
        return ep;
 }
 
@@ -1647,7 +1646,7 @@ of10_features_reply_print(netdissect_options *ndo,
        return of10_phy_ports_print(ndo, cp, ep, len - OF_SWITCH_FEATURES_LEN);
 
 trunc:
-       ND_PRINT("%s", tstr);
+       nd_print_trunc(ndo);
        return ep;
 }
 
@@ -1705,7 +1704,7 @@ of10_flow_mod_print(netdissect_options *ndo,
        return of10_actions_print(ndo, "\n\t ", cp, ep, len - OF_FLOW_MOD_LEN);
 
 trunc:
-       ND_PRINT("%s", tstr);
+       nd_print_trunc(ndo);
        return ep;
 }
 
@@ -1742,7 +1741,7 @@ of10_port_mod_print(netdissect_options *ndo,
        return cp + 4;
 
 trunc:
-       ND_PRINT("%s", tstr);
+       nd_print_trunc(ndo);
        return ep;
 }
 
@@ -1822,11 +1821,11 @@ of10_stats_request_print(netdissect_options *ndo,
        return cp;
 
 invalid: /* skip the message body */
-       ND_PRINT("%s", istr);
+       nd_print_invalid(ndo);
        ND_TCHECK_LEN(cp0, len0);
        return cp0 + len0;
 trunc:
-       ND_PRINT("%s", tstr);
+       nd_print_trunc(ndo);
        return ep;
 }
 
@@ -1840,40 +1839,40 @@ of10_desc_stats_reply_print(netdissect_options *ndo,
        /* mfr_desc */
        ND_TCHECK_LEN(cp, DESC_STR_LEN);
        ND_PRINT("\n\t  mfr_desc '");
-       fn_print(ndo, cp, cp + DESC_STR_LEN);
+       nd_print(ndo, cp, cp + DESC_STR_LEN);
        ND_PRINT("'");
        cp += DESC_STR_LEN;
        /* hw_desc */
        ND_TCHECK_LEN(cp, DESC_STR_LEN);
        ND_PRINT("\n\t  hw_desc '");
-       fn_print(ndo, cp, cp + DESC_STR_LEN);
+       nd_print(ndo, cp, cp + DESC_STR_LEN);
        ND_PRINT("'");
        cp += DESC_STR_LEN;
        /* sw_desc */
        ND_TCHECK_LEN(cp, DESC_STR_LEN);
        ND_PRINT("\n\t  sw_desc '");
-       fn_print(ndo, cp, cp + DESC_STR_LEN);
+       nd_print(ndo, cp, cp + DESC_STR_LEN);
        ND_PRINT("'");
        cp += DESC_STR_LEN;
        /* serial_num */
        ND_TCHECK_LEN(cp, SERIAL_NUM_LEN);
        ND_PRINT("\n\t  serial_num '");
-       fn_print(ndo, cp, cp + SERIAL_NUM_LEN);
+       nd_print(ndo, cp, cp + SERIAL_NUM_LEN);
        ND_PRINT("'");
        cp += SERIAL_NUM_LEN;
        /* dp_desc */
        ND_TCHECK_LEN(cp, DESC_STR_LEN);
        ND_PRINT("\n\t  dp_desc '");
-       fn_print(ndo, cp, cp + DESC_STR_LEN);
+       nd_print(ndo, cp, cp + DESC_STR_LEN);
        ND_PRINT("'");
        return cp + DESC_STR_LEN;
 
 invalid: /* skip the message body */
-       ND_PRINT("%s", istr);
+       nd_print_invalid(ndo);
        ND_TCHECK_LEN(cp, len);
        return cp + len;
 trunc:
-       ND_PRINT("%s", tstr);
+       nd_print_trunc(ndo);
        return ep;
 }
 
@@ -1950,11 +1949,11 @@ of10_flow_stats_reply_print(netdissect_options *ndo,
        return cp;
 
 invalid: /* skip the rest of flow statistics entries */
-       ND_PRINT("%s", istr);
+       nd_print_invalid(ndo);
        ND_TCHECK_LEN(cp0, len0);
        return cp0 + len0;
 trunc:
-       ND_PRINT("%s", tstr);
+       nd_print_trunc(ndo);
        return ep;
 }
 
@@ -1983,11 +1982,11 @@ of10_aggregate_stats_reply_print(netdissect_options *ndo,
        return cp + 4;
 
 invalid: /* skip the message body */
-       ND_PRINT("%s", istr);
+       nd_print_invalid(ndo);
        ND_TCHECK_LEN(cp, len);
        return cp + len;
 trunc:
-       ND_PRINT("%s", tstr);
+       nd_print_trunc(ndo);
        return ep;
 }
 
@@ -2012,7 +2011,7 @@ of10_table_stats_reply_print(netdissect_options *ndo,
                /* name */
                ND_TCHECK_LEN(cp, OFP_MAX_TABLE_NAME_LEN);
                ND_PRINT(", name '");
-               fn_print(ndo, cp, cp + OFP_MAX_TABLE_NAME_LEN);
+               nd_print(ndo, cp, cp + OFP_MAX_TABLE_NAME_LEN);
                ND_PRINT("'");
                cp += OFP_MAX_TABLE_NAME_LEN;
                /* wildcards */
@@ -2043,11 +2042,11 @@ of10_table_stats_reply_print(netdissect_options *ndo,
        return cp;
 
 invalid: /* skip the undersized trailing data */
-       ND_PRINT("%s", istr);
+       nd_print_invalid(ndo);
        ND_TCHECK_LEN(cp0, len0);
        return cp0 + len0;
 trunc:
-       ND_PRINT("%s", tstr);
+       nd_print_trunc(ndo);
        return ep;
 }
 
@@ -2128,11 +2127,11 @@ next_port:
        return cp;
 
 invalid: /* skip the undersized trailing data */
-       ND_PRINT("%s", istr);
+       nd_print_invalid(ndo);
        ND_TCHECK_LEN(cp0, len0);
        return cp0 + len0;
 trunc:
-       ND_PRINT("%s", tstr);
+       nd_print_trunc(ndo);
        return ep;
 }
 
@@ -2176,11 +2175,11 @@ of10_queue_stats_reply_print(netdissect_options *ndo,
        return cp;
 
 invalid: /* skip the undersized trailing data */
-       ND_PRINT("%s", istr);
+       nd_print_invalid(ndo);
        ND_TCHECK_LEN(cp0, len0);
        return cp0 + len0;
 trunc:
-       ND_PRINT("%s", tstr);
+       nd_print_trunc(ndo);
        return ep;
 }
 
@@ -2221,7 +2220,7 @@ of10_stats_reply_print(netdissect_options *ndo,
        return cp0 + len;
 
 trunc:
-       ND_PRINT("%s", tstr);
+       nd_print_trunc(ndo);
        return ep;
 }
 
@@ -2255,11 +2254,11 @@ of10_packet_out_print(netdissect_options *ndo,
        return of10_packet_data_print(ndo, cp, ep, len - OF_PACKET_OUT_LEN - actions_len);
 
 invalid: /* skip the rest of the message body */
-       ND_PRINT("%s", istr);
+       nd_print_invalid(ndo);
        ND_TCHECK_LEN(cp0, len0);
        return cp0 + len0;
 trunc:
-       ND_PRINT("%s", tstr);
+       nd_print_trunc(ndo);
        return ep;
 }
 
@@ -2292,7 +2291,7 @@ of10_packet_in_print(netdissect_options *ndo,
        return of10_packet_data_print(ndo, cp, ep, len - (OF_PACKET_IN_LEN - 2));
 
 trunc:
-       ND_PRINT("%s", tstr);
+       nd_print_trunc(ndo);
        return ep;
 }
 
@@ -2346,7 +2345,7 @@ of10_flow_removed_print(netdissect_options *ndo,
        return cp + 8;
 
 trunc:
-       ND_PRINT("%s", tstr);
+       nd_print_trunc(ndo);
        return ep;
 }
 
@@ -2379,7 +2378,7 @@ of10_error_print(netdissect_options *ndo,
        return of10_data_print(ndo, cp, ep, len - OF_ERROR_MSG_LEN);
 
 trunc:
-       ND_PRINT("%s", tstr);
+       nd_print_trunc(ndo);
        return ep;
 }
 
@@ -2558,11 +2557,11 @@ of10_header_body_print(netdissect_options *ndo,
        goto next_message;
 
 invalid: /* skip the message body */
-       ND_PRINT("%s", istr);
+       nd_print_invalid(ndo);
 next_message:
        ND_TCHECK_LEN(cp0, len0 - OF_HEADER_LEN);
        return cp0 + len0 - OF_HEADER_LEN;
 trunc:
-       ND_PRINT("%s", tstr);
+       nd_print_trunc(ndo);
        return ep;
 }