/*
- * Copyright (c) 2008, 2009, 2010, 2011 Nicira Networks.
+ * Copyright (c) 2008, 2009, 2010, 2011, 2012 Nicira Networks.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include "learn.h"
#include "multipath.h"
#include "nx-match.h"
+#include "ofp-errors.h"
#include "ofp-util.h"
#include "ofpbuf.h"
#include "openflow/openflow.h"
#include "util.h"
static void ofp_print_queue_name(struct ds *string, uint32_t port);
-static void ofp_print_error(struct ds *, int error);
+static void ofp_print_error(struct ds *, enum ofperr);
/* Returns a string that represents the contents of the Ethernet frame in the
}
}
- if (pin.reason == OFPR_ACTION) {
+ switch (pin.reason) {
+ case OFPR_NO_MATCH:
+ ds_put_cstr(string, " (via no_match)");
+ break;
+ case OFPR_ACTION:
ds_put_cstr(string, " (via action)");
- } else if (pin.reason != OFPR_NO_MATCH) {
+ break;
+ case OFPR_INVALID_TTL:
+ ds_put_cstr(string, " (via invalid_ttl)");
+ break;
+ default:
ds_put_format(string, " (***reason %"PRIu8"***)", pin.reason);
+ break;
}
ds_put_format(string, " data_len=%zu", pin.packet_len);
learn_format((const struct nx_action_learn *) a, s);
break;
+ case OFPUTIL_NXAST_DEC_TTL:
+ ds_put_cstr(s, "dec_ttl");
+ break;
+
case OFPUTIL_NXAST_EXIT:
ds_put_cstr(s, "exit");
break;
static void
ofp_print_switch_config(struct ds *string, const struct ofp_switch_config *osc)
{
- uint16_t flags;
+ enum ofp_config_flags flags;
flags = ntohs(osc->flags);
ds_put_format(string, " frags=%s", ofputil_frag_handling_to_string(flags));
flags &= ~OFPC_FRAG_MASK;
+ if (flags & OFPC_INVALID_TTL_TO_CONTROLLER) {
+ ds_put_format(string, " invalid_ttl_to_controller");
+ flags &= ~OFPC_INVALID_TTL_TO_CONTROLLER;
+ }
+
if (flags) {
ds_put_format(string, " ***unknown flags 0x%04"PRIx16"***", flags);
}
{
struct ofputil_flow_mod fm;
bool need_priority;
- int error;
+ enum ofperr error;
error = ofputil_decode_flow_mod(&fm, oh, true);
if (error) {
ofp_print_flow_removed(struct ds *string, const struct ofp_header *oh)
{
struct ofputil_flow_removed fr;
- int error;
+ enum ofperr error;
error = ofputil_decode_flow_removed(&fr, oh);
if (error) {
}
static void
-ofp_print_error(struct ds *string, int error)
+ofp_print_error(struct ds *string, enum ofperr error)
{
if (string->length) {
ds_put_char(string, ' ');
}
- ds_put_cstr(string, "***decode error: ");
- ofputil_format_error(string, error);
- ds_put_cstr(string, "***\n");
+ ds_put_format(string, "***decode error: %s***\n", ofperr_get_name(error));
}
static void
size_t len = ntohs(oem->header.length);
size_t payload_ofs, payload_len;
const void *payload;
- int error;
+ enum ofperr error;
char *s;
- error = ofputil_decode_error_msg(&oem->header, &payload_ofs);
- if (!is_ofp_error(error)) {
- ofp_print_error(string, error);
+ error = ofperr_decode_msg(&oem->header, &payload_ofs);
+ if (!error) {
+ ds_put_cstr(string, "***decode error***");
ds_put_hex_dump(string, oem->data, len - sizeof *oem, 0, true);
return;
}
- ds_put_char(string, ' ');
- ofputil_format_error(string, error);
- ds_put_char(string, '\n');
+ ds_put_format(string, " %s\n", ofperr_get_name(error));
payload = (const uint8_t *) oem + payload_ofs;
payload_len = len - payload_ofs;
- switch (get_ofp_err_type(error)) {
- case OFPET_HELLO_FAILED:
+ if (error == OFPERR_OFPHFC_INCOMPATIBLE || error == OFPERR_OFPHFC_EPERM) {
ds_put_printable(string, payload, payload_len);
- break;
-
- default:
+ } else {
s = ofp_to_string(payload, payload_len, 1);
ds_put_cstr(string, s);
free(s);
- break;
}
}
const struct ofp_stats_msg *osm)
{
struct ofputil_flow_stats_request fsr;
- int error;
+ enum ofperr error;
error = ofputil_decode_flow_stats_request(&fsr, &osm->header);
if (error) {
static void
ofp_print_nxt_flow_mod_table_id(struct ds *string,
- const struct nxt_flow_mod_table_id *nfmti)
+ const struct nx_flow_mod_table_id *nfmti)
{
ds_put_format(string, " %s", nfmti->set ? "enable" : "disable");
}
static void
ofp_print_nxt_set_flow_format(struct ds *string,
- const struct nxt_set_flow_format *nsff)
+ const struct nx_set_flow_format *nsff)
{
uint32_t format = ntohl(nsff->format);
static void
ofp_print_nxt_set_packet_in_format(struct ds *string,
- const struct nxt_set_packet_in_format *nspf)
+ const struct nx_set_packet_in_format *nspf)
{
uint32_t format = ntohl(nspf->format);
} else if (len < sizeof(struct ofp_header)) {
ds_put_format(&string, "OpenFlow packet too short (only %zu bytes):\n",
len);
- } else if (oh->version != OFP_VERSION) {
- ds_put_format(&string, "Bad OpenFlow version %"PRIu8":\n",
- oh->version);
} else if (ntohs(oh->length) > len) {
ds_put_format(&string,
"(***truncated to %zu bytes from %"PRIu16"***)\n",
ntohs(oh->length), len);
} else {
const struct ofputil_msg_type *type;
- int error;
+ enum ofperr error;
error = ofputil_decode_msg_type(oh, &type);
if (!error) {