From: Denis Ovsienko Date: Sun, 4 Oct 2020 22:49:09 +0000 (+0100) Subject: OpenFlow: Use len in all type-specific functions. X-Git-Tag: tcpdump-4.99-bp~132 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/140fac9cf1cc24d15f47d8edf06277781301e8cd OpenFlow: Use len in all type-specific functions. Add an unused "len" argument to a number of type-specific functions so the main message body printing functions always call the next function with (ndo, cp, len) from uniform case blocks. --- diff --git a/print-openflow-1.0.c b/print-openflow-1.0.c index a71b111c..9001476f 100644 --- a/print-openflow-1.0.c +++ b/print-openflow-1.0.c @@ -1502,7 +1502,7 @@ invalid: /* skip the undersized trailing data */ /* [OF10] Section 5.3.2 */ static void of10_switch_config_msg_print(netdissect_options *ndo, - const u_char *cp) + const u_char *cp, u_int len _U_) { /* flags */ ND_PRINT("\n\t flags %s", @@ -1563,7 +1563,7 @@ of10_flow_mod_print(netdissect_options *ndo, /* ibid */ static void of10_port_mod_print(netdissect_options *ndo, - const u_char *cp) + const u_char *cp, u_int len _U_) { /* port_no */ ND_PRINT("\n\t port_no %s", tok2str(ofpp_str, "%u", GET_BE_U_2(cp))); @@ -1591,7 +1591,7 @@ of10_port_mod_print(netdissect_options *ndo, /* [OF10] Section 5.3.4 */ static void of10_queue_get_config_request_print(netdissect_options *ndo, - const u_char *cp) + const u_char *cp, u_int len _U_) { /* port */ ND_PRINT("\n\t port %s", tok2str(ofpp_str, "%u", GET_BE_U_2(cp))); @@ -2049,7 +2049,7 @@ of10_packet_in_print(netdissect_options *ndo, /* [OF10] Section 5.4.2 */ static void of10_flow_removed_print(netdissect_options *ndo, - const u_char *cp) + const u_char *cp, u_int len _U_) { /* match */ of10_match_print(ndo, "\n\t ", cp); @@ -2089,7 +2089,7 @@ of10_flow_removed_print(netdissect_options *ndo, /* [OF10] Section 5.4.3 */ static void of10_port_status_print(netdissect_options *ndo, - const u_char *cp) + const u_char *cp, u_int len _U_) { /* reason */ ND_PRINT("\n\t reason %s", @@ -2158,35 +2158,35 @@ of10_message_print(netdissect_options *ndo, goto invalid; if (ndo->ndo_vflag < 1) break; - of10_switch_config_msg_print(ndo, cp); + of10_switch_config_msg_print(ndo, cp, len); return; case OFPT_PORT_MOD: if (len != OF_PORT_MOD_FIXLEN) goto invalid; if (ndo->ndo_vflag < 1) break; - of10_port_mod_print(ndo, cp); + of10_port_mod_print(ndo, cp, len); return; case OFPT_QUEUE_GET_CONFIG_REQUEST: /* [OF10] Section 5.3.4 */ if (len != OF_QUEUE_GET_CONFIG_REQUEST_FIXLEN) goto invalid; if (ndo->ndo_vflag < 1) break; - of10_queue_get_config_request_print(ndo, cp); + of10_queue_get_config_request_print(ndo, cp, len); return; case OFPT_FLOW_REMOVED: if (len != OF_FLOW_REMOVED_FIXLEN) goto invalid; if (ndo->ndo_vflag < 1) break; - of10_flow_removed_print(ndo, cp); + of10_flow_removed_print(ndo, cp, len); return; case OFPT_PORT_STATUS: /* [OF10] Section 5.4.3 */ if (len != OF_PORT_STATUS_FIXLEN) goto invalid; if (ndo->ndo_vflag < 1) break; - of10_port_status_print(ndo, cp); + of10_port_status_print(ndo, cp, len); return; /* OpenFlow header, fixed-size message body and n * fixed-size data units. */ diff --git a/print-openflow-1.3.c b/print-openflow-1.3.c index 9b63ee4c..1f66d45f 100644 --- a/print-openflow-1.3.c +++ b/print-openflow-1.3.c @@ -743,7 +743,7 @@ of13_port_print(netdissect_options *ndo, /* [OF13] Section 7.3.1 */ static void of13_features_reply_print(netdissect_options *ndo, - const u_char *cp) + const u_char *cp, u_int len _U_) { /* datapath_id */ ND_PRINT("\n\t dpid 0x%016" PRIx64, GET_BE_U_8(cp)); @@ -770,7 +770,7 @@ of13_features_reply_print(netdissect_options *ndo, /* [OF13] Section 7.3.2 */ static void of13_switch_config_msg_print(netdissect_options *ndo, - const u_char *cp) + const u_char *cp, u_int len _U_) { /* flags */ ND_PRINT("\n\t flags %s", @@ -784,7 +784,7 @@ of13_switch_config_msg_print(netdissect_options *ndo, /* [OF13] Section 7.3.3 */ static void of13_table_mod_print(netdissect_options *ndo, - const u_char *cp) + const u_char *cp, u_int len _U_) { /* table_id */ ND_PRINT("\n\t table_id %s", tok2str(ofptt_str, "%u", GET_U_1(cp))); @@ -798,7 +798,7 @@ of13_table_mod_print(netdissect_options *ndo, /* [OF13] Section 7.3.9 */ static void of13_role_msg_print(netdissect_options *ndo, - const u_char *cp) + const u_char *cp, u_int len _U_) { /* role */ ND_PRINT("\n\t role %s", @@ -813,7 +813,7 @@ of13_role_msg_print(netdissect_options *ndo, /* [OF13] Section 7.3.10 */ static void of13_async_msg_print(netdissect_options *ndo, - const u_char *cp) + const u_char *cp, u_int len _U_) { /* packet_in_mask[0] */ ND_PRINT("\n\t packet_in_mask[EM] 0x%08x", GET_BE_U_4(cp)); @@ -843,7 +843,7 @@ of13_async_msg_print(netdissect_options *ndo, /* [OF13] Section 7.3.4.3 */ static void of13_port_mod_print(netdissect_options *ndo, - const u_char *cp) + const u_char *cp, u_int len _U_) { /* port_no */ ND_PRINT("\n\t port_no %s", tok2str(ofpp_str, "%u", GET_BE_U_4(cp))); @@ -875,7 +875,7 @@ of13_port_mod_print(netdissect_options *ndo, /* [OF13] Section 7.4.3 */ static void of13_port_status_print(netdissect_options *ndo, - const u_char *cp) + const u_char *cp, u_int len _U_) { /* reason */ ND_PRINT("\n\t reason %s", @@ -963,7 +963,7 @@ of13_experimenter_message_print(netdissect_options *ndo, /* [OF13] Section A.3.6 */ static void of13_queue_get_config_request_print(netdissect_options *ndo, - const u_char *cp) + const u_char *cp, u_int len _U_) { /* port */ ND_PRINT("\n\t port %s", tok2str(ofpp_str, "%u", GET_BE_U_4(cp))); @@ -1020,14 +1020,14 @@ of13_message_print(netdissect_options *ndo, goto invalid; if (ndo->ndo_vflag < 1) break; - of13_features_reply_print(ndo, cp); + of13_features_reply_print(ndo, cp, len); return; case OFPT_QUEUE_GET_CONFIG_REQUEST: /* [OF13] Section A.3.6 */ if (len != OF_QUEUE_GET_CONFIG_REQUEST_FIXLEN) goto invalid; if (ndo->ndo_vflag < 1) break; - of13_queue_get_config_request_print(ndo, cp); + of13_queue_get_config_request_print(ndo, cp, len); return; case OFPT_GET_CONFIG_REPLY: /* [OF13] Section 7.3.2 */ case OFPT_SET_CONFIG: /* ibid */ @@ -1035,14 +1035,14 @@ of13_message_print(netdissect_options *ndo, goto invalid; if (ndo->ndo_vflag < 1) break; - of13_switch_config_msg_print(ndo, cp); + of13_switch_config_msg_print(ndo, cp, len); return; case OFPT_PORT_MOD: /* [OF13] Section 7.3.4.3 */ if (len != OF_PORT_MOD_FIXLEN) goto invalid; if (ndo->ndo_vflag < 1) break; - of13_port_mod_print(ndo, cp); + of13_port_mod_print(ndo, cp, len); return; case OFPT_ROLE_REQUEST: /* [OF13] Section 7.3.9 */ case OFPT_ROLE_REPLY: /* ibid */ @@ -1050,21 +1050,21 @@ of13_message_print(netdissect_options *ndo, goto invalid; if (ndo->ndo_vflag < 1) break; - of13_role_msg_print(ndo, cp); + of13_role_msg_print(ndo, cp, len); return; case OFPT_PORT_STATUS: /* [OF13] Section 7.4.3 */ if (len != OF_PORT_STATUS_FIXLEN) goto invalid; if (ndo->ndo_vflag < 1) break; - of13_port_status_print(ndo, cp); + of13_port_status_print(ndo, cp, len); return; case OFPT_TABLE_MOD: /* [OF13] Section 7.3.3 */ if (len != OF_TABLE_MOD_FIXLEN) goto invalid; if (ndo->ndo_vflag < 1) break; - of13_table_mod_print(ndo, cp); + of13_table_mod_print(ndo, cp, len); return; case OFPT_SET_ASYNC: /* [OF13] Section 7.3.10 */ case OFPT_GET_ASYNC_REPLY: /* ibid */ @@ -1072,7 +1072,7 @@ of13_message_print(netdissect_options *ndo, goto invalid; if (ndo->ndo_vflag < 1) break; - of13_async_msg_print(ndo, cp); + of13_async_msg_print(ndo, cp, len); return; /* OpenFlow header and variable-size data. */