2 * Copyright 2012, Andrew Ferguson, Brown University
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may
5 * not use this file except in compliance with the License. You may obtain
6 * a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations
17 package org.openflow.vendor.openflow;
19 import org.jboss.netty.buffer.ChannelBuffer;
20 import org.openflow.protocol.vendor.OFVendorData;
23 * Base class for vendor data corresponding to extensions to OpenFlow 1.0.
24 * Based on org.openflow.vendor.nicira
26 * @author Andrew Ferguson (adf@cs.brown.edu)
28 public class OFOpenFlowVendorData implements OFVendorData {
30 public static final int OF_VENDOR_ID = 0x000026e1;
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) OpenFlow vendor data.
40 public OFOpenFlowVendorData() {
44 * Construct OpenFlow vendor data with the specified data type
45 * @param dataType the data type value at the beginning of the vendor data.
47 public OFOpenFlowVendorData(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);