2 * Copyright 2011, Big Switch Networks, Inc.
3 * Originally created by David Erickson & Rob Sherwood, Stanford University
5 * Licensed under the Apache License, Version 2.0 (the "License"); you may
6 * not use this file except in compliance with the License. You may obtain
7 * a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 * License for the specific language governing permissions and limitations
18 package org.openflow.vendor.nicira;
20 import org.jboss.netty.buffer.ChannelBuffer;
21 import org.openflow.protocol.vendor.OFVendorData;
24 * Base class for vendor data corresponding to a Nicira vendor extension.
25 * Nicira vendor data always starts with a 4-byte integer data type value.
27 * @author Rob Vaterlaus (rob.vaterlaus@bigswitch.com)
29 public class OFNiciraVendorData implements OFVendorData {
31 public static final int NX_VENDOR_ID = 0x00002320;
33 * The value of the integer data type at the beginning of the vendor data
35 protected int dataType;
38 * Construct empty (i.e. unspecified data type) Nicira vendor data.
40 public OFNiciraVendorData() {
44 * Contruct Nicira vendor data with the specified data type
45 * @param dataType the data type value at the beginning of the vendor data.
47 public OFNiciraVendorData(int dataType) {
48 this.dataType = dataType;
52 * Get the data type value at the beginning of the vendor data
53 * @return the integer data type value
55 public int getDataType() {
60 * Set the data type value
61 * @param dataType the integer data type value at the beginning of the
64 public void setDataType(int dataType) {
65 this.dataType = dataType;
69 * Get the length of the vendor data. This implementation will normally
70 * be the superclass for another class that will override this to return
71 * the overall vendor data length. This implementation just returns the
72 * length of the part that includes the 4-byte integer data type value
73 * at the beginning of the vendor data.
76 public int getLength() {
81 * Read the vendor data from the ChannelBuffer
82 * @param data the channel buffer from which we're deserializing
83 * @param length the length to the end of the enclosing message
86 public void readFrom(ChannelBuffer data, int length) {
87 dataType = data.readInt();
91 * Write the vendor data to the ChannelBuffer
92 * @param data the channel buffer to which we're serializing
95 public void writeTo(ChannelBuffer data) {
96 data.writeInt(dataType);