1 package org.openflow.protocol;
3 import java.nio.ByteBuffer;
4 import java.util.Arrays;
6 import org.openflow.util.U16;
9 * Represents ofp_vendor_header
10 * @author David Erickson (daviderickson@cs.stanford.edu)
12 public class OFVendor extends OFMessage {
13 public static int MINIMUM_LENGTH = 12;
16 protected byte[] data;
20 this.type = OFType.VENDOR;
21 this.length = U16.t(MINIMUM_LENGTH);
27 public int getVendor() {
32 * @param vendor the vendor to set
34 public void setVendor(int vendor) {
39 public void readFrom(ByteBuffer data) {
41 this.vendor = data.getInt();
42 if (this.length > MINIMUM_LENGTH) {
43 this.data = new byte[this.length - MINIMUM_LENGTH];
49 public void writeTo(ByteBuffer data) {
51 data.putInt(this.vendor);
52 if (this.data != null)
59 public byte[] getData() {
64 * @param data the data to set
66 public void setData(byte[] data) {
71 * @see java.lang.Object#hashCode()
74 public int hashCode() {
75 final int prime = 337;
76 int result = super.hashCode();
77 result = prime * result + Arrays.hashCode(data);
78 result = prime * result + vendor;
83 * @see java.lang.Object#equals(java.lang.Object)
86 public boolean equals(Object obj) {
89 if (!super.equals(obj))
91 if (getClass() != obj.getClass())
93 OFVendor other = (OFVendor) obj;
94 if (!Arrays.equals(data, other.data))
96 if (vendor != other.vendor)