2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.protocol_plugin.openflow.vendorextension.v6extension;
10 import java.nio.ByteBuffer;
11 import java.util.Arrays;
13 import org.openflow.protocol.OFError;
15 public class V6Error extends OFError {
16 private static final long serialVersionUID = 1L;
17 public static int MINIMUM_LENGTH = 20;//OfHdr(8) + NXET_VENDOR(2) + NXEC_VENDOR_ERROR(2) + struct nx_vendor_error(8)
18 public static final short NICIRA_VENDOR_ERRORTYPE = (short)0xb0c2;
19 protected int V6VendorId;
20 protected short V6VendorErrorType;
21 protected short V6VendorErrorCode;
22 protected byte[] V6ErrorData;
24 public V6Error(OFError e) {
25 this.length = (short)e.getLengthU();
26 this.errorType = e.getErrorType();
27 this.errorCode = e.getErrorCode();
28 this.xid = e.getXid();
32 public void readFrom(ByteBuffer data) {
33 this.V6VendorId = data.getInt();
34 this.V6VendorErrorType = data.getShort();
35 this.V6VendorErrorCode = data.getShort();
36 int dataLength = this.getLengthU() - MINIMUM_LENGTH;
38 this.V6ErrorData = new byte[dataLength];
39 data.get(this.V6ErrorData);
44 * @return the V6VendorId
46 public int getVendorId() {
51 * @return the V6VendorErrorType
53 public short getVendorErrorType() {
54 return V6VendorErrorType;
58 * @return the VendorErrorType
60 public short getVendorErrorCode() {
61 return V6VendorErrorCode;
65 * @return the Error Bytes
67 public byte[] getError() {
72 public int hashCode() {
74 int result = super.hashCode();
75 result = prime * result + Arrays.hashCode(V6ErrorData);
76 result = prime * result + V6VendorErrorCode;
77 result = prime * result + V6VendorErrorType;
78 result = prime * result + V6VendorId;
83 public String toString() {
84 return "V6Error [V6VendorId=" + V6VendorId + ", V6VendorErrorType="
85 + V6VendorErrorType + ", V6VendorErrorCode="
86 + V6VendorErrorCode + ", V6ErrorData="
87 + Arrays.toString(V6ErrorData) + ", errorType=" + errorType
88 + ", errorCode=" + errorCode + ", factory=" + factory
89 + ", error=" + Arrays.toString(error) + ", errorIsAscii="
90 + errorIsAscii + ", version=" + version + ", type=" + type
91 + ", length=" + length + ", xid=" + xid + "]";
95 public boolean equals(Object obj) {
98 if (!super.equals(obj))
100 if (getClass() != obj.getClass())
102 V6Error other = (V6Error) obj;
103 if (!Arrays.equals(V6ErrorData, other.V6ErrorData))
105 if (V6VendorErrorCode != other.V6VendorErrorCode)
107 if (V6VendorErrorType != other.V6VendorErrorType)
109 if (V6VendorId != other.V6VendorId)