From: Denis Ovsienko Date: Sat, 26 Sep 2020 21:54:23 +0000 (+0100) Subject: OpenFlow: Rename and move a function. X-Git-Tag: tcpdump-4.99-bp~188 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/8bd8cb7c591feb05ced9b078d900d6102ebf55f4 OpenFlow: Rename and move a function. Rename of10_data_print() to of_data_print(), move it to print-openflow.c and declare it in openflow.h. --- diff --git a/openflow.h b/openflow.h index f35648a5..0b89008e 100644 --- a/openflow.h +++ b/openflow.h @@ -53,9 +53,12 @@ #define ONF_EXP_OTRANS 0xff000007 extern const struct tok onf_exp_str[]; +extern const char * of_vendor_name(const uint32_t); +extern void of_data_print(netdissect_options *ndo, + const u_char *, const u_int); + /* * Routines to print packets for various versions of OpenFlow. */ extern void of10_header_body_print(netdissect_options *ndo, const u_char *, const uint8_t, uint16_t, const uint32_t); -extern const char * of_vendor_name(const uint32_t); diff --git a/print-openflow-1.0.c b/print-openflow-1.0.c index c699c683..473a8dc3 100644 --- a/print-openflow-1.0.c +++ b/print-openflow-1.0.c @@ -721,20 +721,6 @@ of10_bitmap_print(netdissect_options *ndo, ND_PRINT((v & u) ? ") (bogus)" : ")"); } -static void -of10_data_print(netdissect_options *ndo, - const u_char *cp, const u_int len) -{ - if (len == 0) - return; - /* data */ - ND_PRINT("\n\t data (%u octets)", len); - if (ndo->ndo_vflag >= 2) - hex_and_ascii_print(ndo, "\n\t ", cp, len); - else - ND_TCHECK_LEN(cp, len); -} - static void of10_bsn_message_print(netdissect_options *ndo, const u_char *cp, u_int len) @@ -995,7 +981,7 @@ of10_vendor_action_print(netdissect_options *ndo, /* data */ decoder = vendor == OUI_BSN ? of10_bsn_actions_print : - of10_data_print; + of_data_print; decoder(ndo, cp, len); return; @@ -1020,7 +1006,7 @@ of10_vendor_message_print(netdissect_options *ndo, /* data */ decoder = vendor == OUI_BSN ? of10_bsn_message_print : - of10_data_print; + of_data_print; decoder(ndo, cp, len); return; @@ -1043,7 +1029,7 @@ of10_vendor_data_print(netdissect_options *ndo, OF_FWD(4); ND_PRINT(", vendor 0x%08x (%s)", vendor, of_vendor_name(vendor)); /* data */ - of10_data_print(ndo, cp, len); + of_data_print(ndo, cp, len); return; invalid: /* skip the undersized data */ @@ -2080,7 +2066,7 @@ of10_error_print(netdissect_options *ndo, else ND_PRINT(", code invalid (0x%04x)", code); /* data */ - of10_data_print(ndo, cp, len); + of_data_print(ndo, cp, len); } void @@ -2190,7 +2176,7 @@ of10_header_body_print(netdissect_options *ndo, case OFPT_ECHO_REPLY: /* [OF10] Section 5.5.3 */ if (ndo->ndo_vflag < 1) break; - of10_data_print(ndo, cp, len); + of_data_print(ndo, cp, len); return; /* OpenFlow header, fixed-size message body and variable-size data. */ diff --git a/print-openflow.c b/print-openflow.c index f56b0a35..f6cd31ac 100644 --- a/print-openflow.c +++ b/print-openflow.c @@ -66,6 +66,20 @@ of_vendor_name(const uint32_t vendor) return tok2str(table, "unknown", vendor); } +void +of_data_print(netdissect_options *ndo, + const u_char *cp, const u_int len) +{ + if (len == 0) + return; + /* data */ + ND_PRINT("\n\t data (%u octets)", len); + if (ndo->ndo_vflag >= 2) + hex_and_ascii_print(ndo, "\n\t ", cp, len); + else + ND_TCHECK_LEN(cp, len); +} + static void of_header_print(netdissect_options *ndo, const uint8_t version, const uint8_t type, const uint16_t length, const uint32_t xid)