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.protocol.vendor;
20 import java.util.HashMap;
23 import org.jboss.netty.buffer.ChannelBuffer;
26 * Base class for the vendor ID corresponding to vendor extensions from a
27 * given vendor. It is responsible for knowing how to parse out some sort of
28 * data type value from the vendor data in an OFVendor message so that we can
29 * dispatch to the different subclasses of OFVendorData corresponding to the
30 * different formats of data for the vendor extensions.
32 * @author Rob Vaterlaus (rob.vaterlaus@bigswitch.com)
34 public abstract class OFVendorId {
35 static Map<Integer, OFVendorId> mapping = new HashMap<Integer, OFVendorId>();
38 * The vendor id value, typically the OUI of the vendor prefixed with 0.
43 * Register a new vendor id.
44 * @param vendorId the vendor id to register
46 public static void registerVendorId(OFVendorId vendorId) {
47 mapping.put(vendorId.getId(), vendorId);
51 * Lookup the OFVendorId instance corresponding to the given id value.
52 * @param id the integer vendor id value
53 * @return the corresponding OFVendorId that's been registered for the
54 * given value, or null if there id has not been registered.
56 public static OFVendorId lookupVendorId(int id) {
57 return mapping.get(id);
61 * Create an OFVendorId with the give vendor id value
64 public OFVendorId(int id) {
69 * @return the vendor id value
76 * This function parses enough of the data from the channel buffer to be
77 * able to determine the appropriate OFVendorDataType for the data.
79 * @param data the channel buffer containing the vendor data.
80 * @param length the length to the end of the enclosing message
81 * @return the OFVendorDataType that can be used to instantiate the
82 * appropriate subclass of OFVendorData.
84 public abstract OFVendorDataType parseVendorDataType(ChannelBuffer data, int length);