Skip to content
Snippets Groups Projects
Commit 3c2538e3 authored by Andreas Wundsam's avatar Andreas Wundsam
Browse files

openflow/OFError: add convenience constructor + whitespace

parent 928c293a
No related branches found
No related tags found
No related merge requests found
/** /**
* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior * Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
* University * University
* *
* Licensed under the Apache License, Version 2.0 (the "License"); you may * Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain * not use this file except in compliance with the License. You may obtain
* a copy of the License at * a copy of the License at
...@@ -29,7 +29,7 @@ import org.openflow.util.U16; ...@@ -29,7 +29,7 @@ import org.openflow.util.U16;
/** /**
* Represents an ofp_error_msg * Represents an ofp_error_msg
* *
* @author David Erickson (daviderickson@cs.stanford.edu) * @author David Erickson (daviderickson@cs.stanford.edu)
* @author Rob Sherwood (rob.sherwood@stanford.edu) * @author Rob Sherwood (rob.sherwood@stanford.edu)
*/ */
...@@ -39,22 +39,22 @@ public class OFError extends OFMessage implements OFMessageFactoryAware { ...@@ -39,22 +39,22 @@ public class OFError extends OFMessage implements OFMessageFactoryAware {
public enum OFErrorType { public enum OFErrorType {
// OFPET_VENDOR_ERROR is an extension that was added in Open vSwitch and isn't // OFPET_VENDOR_ERROR is an extension that was added in Open vSwitch and isn't
// in the OF 1.0 spec, but it was easier to add it here instead of adding // in the OF 1.0 spec, but it was easier to add it here instead of adding
// generic support for extensible vendor-defined error messages. // generic support for extensible vendor-defined error messages.
// It uses the random value 0xb0c2 to avoid conflicts with other possible new // It uses the random value 0xb0c2 to avoid conflicts with other possible new
// error types. Support for vendor-defined extended errors has been standardized // error types. Support for vendor-defined extended errors has been standardized
// in the OF 1.2 spec, so this workaround is only needed for 1.0. // in the OF 1.2 spec, so this workaround is only needed for 1.0.
OFPET_HELLO_FAILED, OFPET_BAD_REQUEST, OFPET_BAD_ACTION, OFPET_FLOW_MOD_FAILED, OFPET_PORT_MOD_FAILED, OFPET_QUEUE_OP_FAILED, OFPET_VENDOR_ERROR((short)0xb0c2); OFPET_HELLO_FAILED, OFPET_BAD_REQUEST, OFPET_BAD_ACTION, OFPET_FLOW_MOD_FAILED, OFPET_PORT_MOD_FAILED, OFPET_QUEUE_OP_FAILED, OFPET_VENDOR_ERROR((short)0xb0c2);
protected short value; protected short value;
private OFErrorType() { private OFErrorType() {
this.value = (short) this.ordinal(); this.value = (short) this.ordinal();
} }
private OFErrorType(short value) { private OFErrorType(short value) {
this.value = value; this.value = value;
} }
public short getValue() { public short getValue() {
return value; return value;
} }
...@@ -99,6 +99,12 @@ public class OFError extends OFMessage implements OFMessageFactoryAware { ...@@ -99,6 +99,12 @@ public class OFError extends OFMessage implements OFMessageFactoryAware {
this.length = U16.t(MINIMUM_LENGTH); this.length = U16.t(MINIMUM_LENGTH);
} }
/** convenience constructor */
public OFError(OFErrorType errorType) {
this();
setErrorType(errorType);
}
/** /**
* @return the errorType * @return the errorType
*/ */
...@@ -124,7 +130,7 @@ public class OFError extends OFMessage implements OFMessageFactoryAware { ...@@ -124,7 +130,7 @@ public class OFError extends OFMessage implements OFMessageFactoryAware {
public boolean isVendorError() { public boolean isVendorError() {
return errorType == OFErrorType.OFPET_VENDOR_ERROR.getValue(); return errorType == OFErrorType.OFPET_VENDOR_ERROR.getValue();
} }
/** /**
* @return the errorCode * @return the errorCode
*/ */
...@@ -167,19 +173,19 @@ public class OFError extends OFMessage implements OFMessageFactoryAware { ...@@ -167,19 +173,19 @@ public class OFError extends OFMessage implements OFMessageFactoryAware {
public int getVendorErrorType() { public int getVendorErrorType() {
return vendorErrorType; return vendorErrorType;
} }
public void setVendorErrorType(int vendorErrorType) { public void setVendorErrorType(int vendorErrorType) {
this.vendorErrorType = vendorErrorType; this.vendorErrorType = vendorErrorType;
} }
public short getVendorErrorCode() { public short getVendorErrorCode() {
return vendorErrorCode; return vendorErrorCode;
} }
public void setVendorErrorCode(short vendorErrorCode) { public void setVendorErrorCode(short vendorErrorCode) {
this.vendorErrorCode = vendorErrorCode; this.vendorErrorCode = vendorErrorCode;
} }
public OFMessage getOffendingMsg() throws MessageParseException { public OFMessage getOffendingMsg() throws MessageParseException {
// should only have one message embedded; if more than one, just // should only have one message embedded; if more than one, just
// grab first // grab first
...@@ -197,7 +203,7 @@ public class OFError extends OFMessage implements OFMessageFactoryAware { ...@@ -197,7 +203,7 @@ public class OFError extends OFMessage implements OFMessageFactoryAware {
/** /**
* Write this offending message into the payload of the Error message * Write this offending message into the payload of the Error message
* *
* @param offendingMsg * @param offendingMsg
*/ */
...@@ -277,7 +283,7 @@ public class OFError extends OFMessage implements OFMessageFactoryAware { ...@@ -277,7 +283,7 @@ public class OFError extends OFMessage implements OFMessageFactoryAware {
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see java.lang.Object#hashCode() * @see java.lang.Object#hashCode()
*/ */
@Override @Override
...@@ -293,7 +299,7 @@ public class OFError extends OFMessage implements OFMessageFactoryAware { ...@@ -293,7 +299,7 @@ public class OFError extends OFMessage implements OFMessageFactoryAware {
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see java.lang.Object#equals(java.lang.Object) * @see java.lang.Object#equals(java.lang.Object)
*/ */
@Override @Override
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment