X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Fofp-print.c;h=c5312a38dbe87b774aed884b7a95a4701fcc86c1;hb=6c0386119d614d5e26ca08cc3d8e527806b87ef9;hp=30ecdbf876a7908ddd6fa1d94d6ea6fe4bf181d8;hpb=80d5aefd65b9dd953d873f9995b949bc8b8d19d5;p=openvswitch diff --git a/lib/ofp-print.c b/lib/ofp-print.c index 30ecdbf8..c5312a38 100644 --- a/lib/ofp-print.c +++ b/lib/ofp-print.c @@ -80,24 +80,6 @@ ofp_packet_to_string(const void *data, size_t len) return ds_cstr(&ds); } -static const char * -ofp_packet_in_reason_to_string(enum ofp_packet_in_reason reason) -{ - static char s[32]; - - switch (reason) { - case OFPR_NO_MATCH: - return "no_match"; - case OFPR_ACTION: - return "action"; - case OFPR_INVALID_TTL: - return "invalid_ttl"; - default: - sprintf(s, "%d", (int) reason); - return s; - } -} - static void ofp_print_packet_in(struct ds *string, const struct ofp_header *oh, int verbosity) @@ -140,7 +122,7 @@ ofp_print_packet_in(struct ds *string, const struct ofp_header *oh, } ds_put_format(string, " (via %s)", - ofp_packet_in_reason_to_string(pin.reason)); + ofputil_packet_in_reason_to_string(pin.reason)); ds_put_format(string, " data_len=%zu", pin.packet_len); if (pin.buffer_id == UINT32_MAX) { @@ -194,6 +176,8 @@ ofp_print_action(struct ds *s, const union ofp_action *a, const struct nx_action_multipath *nam; const struct nx_action_autopath *naa; const struct nx_action_output_reg *naor; + const struct nx_action_fin_timeout *naft; + const struct nx_action_controller *nac; struct mf_subfield subfield; uint16_t port; @@ -356,6 +340,38 @@ ofp_print_action(struct ds *s, const union ofp_action *a, ds_put_cstr(s, "exit"); break; + case OFPUTIL_NXAST_FIN_TIMEOUT: + naft = (const struct nx_action_fin_timeout *) a; + ds_put_cstr(s, "fin_timeout("); + if (naft->fin_idle_timeout) { + ds_put_format(s, "idle_timeout=%"PRIu16",", + ntohs(naft->fin_idle_timeout)); + } + if (naft->fin_hard_timeout) { + ds_put_format(s, "hard_timeout=%"PRIu16",", + ntohs(naft->fin_hard_timeout)); + } + ds_chomp(s, ','); + ds_put_char(s, ')'); + break; + + case OFPUTIL_NXAST_CONTROLLER: + nac = (const struct nx_action_controller *) a; + ds_put_cstr(s, "controller("); + if (nac->reason != OFPR_ACTION) { + ds_put_format(s, "reason=%s,", + ofputil_packet_in_reason_to_string(nac->reason)); + } + if (nac->max_len != htons(UINT16_MAX)) { + ds_put_format(s, "max_len=%"PRIu16",", ntohs(nac->max_len)); + } + if (nac->controller_id != htons(0)) { + ds_put_format(s, "id=%"PRIu16",", ntohs(nac->controller_id)); + } + ds_chomp(s, ','); + ds_put_char(s, ')'); + break; + default: break; } @@ -410,7 +426,7 @@ ofp_print_packet_out(struct ds *string, const struct ofp_packet_out *opo, ofp_print_actions(string, po.actions, po.n_actions); if (po.buffer_id == UINT32_MAX) { - ds_put_format(string, " data_len=%d", po.packet_len); + ds_put_format(string, " data_len=%zu", po.packet_len); if (verbosity > 0 && po.packet_len > 0) { char *packet = ofp_packet_to_string(po.packet, po.packet_len); ds_put_char(string, '\n'); @@ -768,7 +784,7 @@ ofp_print_flow_mod(struct ds *s, const struct ofp_header *oh, bool need_priority; enum ofperr error; - error = ofputil_decode_flow_mod(&fm, oh, true); + error = ofputil_decode_flow_mod(&fm, oh, OFPUTIL_P_OF10_TID); if (error) { ofp_print_error(s, error); return; @@ -1303,8 +1319,8 @@ ofp_print_nxt_set_flow_format(struct ds *string, uint32_t format = ntohl(nsff->format); ds_put_cstr(string, " format="); - if (ofputil_flow_format_is_valid(format)) { - ds_put_cstr(string, ofputil_flow_format_to_string(format)); + if (ofputil_nx_flow_format_is_valid(format)) { + ds_put_cstr(string, ofputil_nx_flow_format_to_string(format)); } else { ds_put_format(string, "%"PRIu32, format); } @@ -1360,7 +1376,7 @@ ofp_print_nxt_set_async_config(struct ds *string, for (j = 0; j < 32; j++) { if (nac->packet_in_mask[i] & htonl(1u << j)) { ds_put_format(string, " %s", - ofp_packet_in_reason_to_string(j)); + ofputil_packet_in_reason_to_string(j)); } } if (!nac->packet_in_mask[i]) { @@ -1393,6 +1409,13 @@ ofp_print_nxt_set_async_config(struct ds *string, } } +static void +ofp_print_nxt_set_controller_id(struct ds *string, + const struct nx_controller_id *nci) +{ + ds_put_format(string, " id=%"PRIu16, ntohs(nci->controller_id)); +} + static void ofp_to_string__(const struct ofp_header *oh, const struct ofputil_msg_type *type, struct ds *string, @@ -1401,8 +1424,18 @@ ofp_to_string__(const struct ofp_header *oh, enum ofputil_msg_code code; const void *msg = oh; - ds_put_format(string, "%s (xid=0x%"PRIx32"):", - ofputil_msg_type_name(type), ntohl(oh->xid)); + ds_put_cstr(string, ofputil_msg_type_name(type)); + switch (oh->version) { + case OFP10_VERSION: + break; + case OFP11_VERSION: + ds_put_cstr(string, " (OF1.1)"); + break; + default: + ds_put_format(string, " (OF 0x%02"PRIx8")", oh->version); + break; + } + ds_put_format(string, " (xid=0x%"PRIx32"):", ntohl(oh->xid)); code = ofputil_msg_type_code(type); switch (code) { @@ -1552,6 +1585,10 @@ ofp_to_string__(const struct ofp_header *oh, case OFPUTIL_NXT_FLOW_AGE: break; + case OFPUTIL_NXT_SET_CONTROLLER_ID: + ofp_print_nxt_set_controller_id(string, msg); + break; + case OFPUTIL_NXT_SET_ASYNC_CONFIG: ofp_print_nxt_set_async_config(string, msg); break; @@ -1610,91 +1647,6 @@ ofp_to_string(const void *oh_, size_t len, int verbosity) ds_put_hex_dump(&string, oh, len, 0, true); return ds_steal_cstr(&string); } - -/* Returns the name for the specified OpenFlow message type as a string, - * e.g. "OFPT_FEATURES_REPLY". If no name is known, the string returned is a - * hex number, e.g. "0x55". - * - * The caller must free the returned string when it is no longer needed. */ -char * -ofp_message_type_to_string(uint8_t type) -{ - const char *name; - - switch (type) { - case OFPT_HELLO: - name = "HELLO"; - break; - case OFPT_ERROR: - name = "ERROR"; - break; - case OFPT_ECHO_REQUEST: - name = "ECHO_REQUEST"; - break; - case OFPT_ECHO_REPLY: - name = "ECHO_REPLY"; - break; - case OFPT_VENDOR: - name = "VENDOR"; - break; - case OFPT_FEATURES_REQUEST: - name = "FEATURES_REQUEST"; - break; - case OFPT_FEATURES_REPLY: - name = "FEATURES_REPLY"; - break; - case OFPT_GET_CONFIG_REQUEST: - name = "GET_CONFIG_REQUEST"; - break; - case OFPT_GET_CONFIG_REPLY: - name = "GET_CONFIG_REPLY"; - break; - case OFPT_SET_CONFIG: - name = "SET_CONFIG"; - break; - case OFPT_PACKET_IN: - name = "PACKET_IN"; - break; - case OFPT_FLOW_REMOVED: - name = "FLOW_REMOVED"; - break; - case OFPT_PORT_STATUS: - name = "PORT_STATUS"; - break; - case OFPT_PACKET_OUT: - name = "PACKET_OUT"; - break; - case OFPT_FLOW_MOD: - name = "FLOW_MOD"; - break; - case OFPT_PORT_MOD: - name = "PORT_MOD"; - break; - case OFPT_STATS_REQUEST: - name = "STATS_REQUEST"; - break; - case OFPT_STATS_REPLY: - name = "STATS_REPLY"; - break; - case OFPT_BARRIER_REQUEST: - name = "BARRIER_REQUEST"; - break; - case OFPT_BARRIER_REPLY: - name = "BARRIER_REPLY"; - break; - case OFPT_QUEUE_GET_CONFIG_REQUEST: - name = "QUEUE_GET_CONFIG_REQUEST"; - break; - case OFPT_QUEUE_GET_CONFIG_REPLY: - name = "QUEUE_GET_CONFIG_REPLY"; - break; - default: - name = NULL; - break; - } - - return name ? xasprintf("OFPT_%s", name) : xasprintf("0x%02"PRIx8, type); -} static void print_and_free(FILE *stream, char *string)