1 package org.opendaylight.controller.protocol_plugin.openflow.vendorextension.v6extension;
3 import java.nio.ByteBuffer;
4 import java.util.Arrays;
6 import org.openflow.protocol.OFError;
8 public class V6Error extends OFError {
9 private static final long serialVersionUID = 1L;
10 public static int MINIMUM_LENGTH = 20;//OfHdr(8) + NXET_VENDOR(2) + NXEC_VENDOR_ERROR(2) + struct nx_vendor_error(8)
11 public static final short NICIRA_VENDOR_ERRORTYPE = (short)0xb0c2;
12 protected int V6VendorId;
13 protected short V6VendorErrorType;
14 protected short V6VendorErrorCode;
15 protected byte[] V6ErrorData;
17 public V6Error(OFError e) {
18 this.length = (short)e.getLengthU();
19 this.errorType = e.getErrorType();
20 this.errorCode = e.getErrorCode();
21 this.xid = e.getXid();
25 public void readFrom(ByteBuffer data) {
26 this.V6VendorId = data.getInt();
27 this.V6VendorErrorType = data.getShort();
28 this.V6VendorErrorCode = data.getShort();
29 int dataLength = this.getLengthU() - MINIMUM_LENGTH;
31 this.V6ErrorData = new byte[dataLength];
32 data.get(this.V6ErrorData);
37 * @return the V6VendorId
39 public int getVendorId() {
44 * @return the V6VendorErrorType
46 public short getVendorErrorType() {
47 return V6VendorErrorType;
51 * @return the VendorErrorType
53 public short getVendorErrorCode() {
54 return V6VendorErrorCode;
58 * @return the Error Bytes
60 public byte[] getError() {
65 public int hashCode() {
67 int result = super.hashCode();
68 result = prime * result + Arrays.hashCode(V6ErrorData);
69 result = prime * result + V6VendorErrorCode;
70 result = prime * result + V6VendorErrorType;
71 result = prime * result + V6VendorId;
76 public String toString() {
77 return "V6Error [V6VendorId=" + V6VendorId + ", V6VendorErrorType="
78 + V6VendorErrorType + ", V6VendorErrorCode="
79 + V6VendorErrorCode + ", V6ErrorData="
80 + Arrays.toString(V6ErrorData) + ", errorType=" + errorType
81 + ", errorCode=" + errorCode + ", factory=" + factory
82 + ", error=" + Arrays.toString(error) + ", errorIsAscii="
83 + errorIsAscii + ", version=" + version + ", type=" + type
84 + ", length=" + length + ", xid=" + xid + "]";
88 public boolean equals(Object obj) {
91 if (!super.equals(obj))
93 if (getClass() != obj.getClass())
95 V6Error other = (V6Error) obj;
96 if (!Arrays.equals(V6ErrorData, other.V6ErrorData))
98 if (V6VendorErrorCode != other.V6VendorErrorCode)
100 if (V6VendorErrorType != other.V6VendorErrorType)
102 if (V6VendorId != other.V6VendorId)