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;
23 * Class that represents the vendor data in the role request
24 * extension implemented by Open vSwitch to support high availability.
26 * @author Rob Vaterlaus (rob.vaterlaus@bigswitch.com)
28 public class OFRoleVendorData extends OFNiciraVendorData {
31 * Role value indicating that the controller is in the OTHER role.
33 public static final int NX_ROLE_OTHER = 0;
36 * Role value indicating that the controller is in the MASTER role.
38 public static final int NX_ROLE_MASTER = 1;
41 * Role value indicating that the controller is in the SLAVE role.
43 public static final int NX_ROLE_SLAVE = 2;
48 * Construct an uninitialized OFRoleVendorData
50 public OFRoleVendorData() {
55 * Construct an OFRoleVendorData with the specified data type
56 * (i.e. either request or reply) and an unspecified role.
59 public OFRoleVendorData(int dataType) {
64 * Construct an OFRoleVendorData with the specified data type
65 * (i.e. either request or reply) and role (i.e. one of of
66 * master, slave, or other).
67 * @param dataType either role request or role reply data type
69 public OFRoleVendorData(int dataType, int role) {
74 * @return the role value of the role vendor data
76 public int getRole() {
81 * @param role the role value of the role vendor data
83 public void setRole(int role) {
88 * @return the total length of the role vendor data
91 public int getLength() {
92 return super.getLength() + 4;
96 * Read the role vendor data from the ChannelBuffer
97 * @param data the channel buffer from which we're deserializing
98 * @param length the length to the end of the enclosing message
100 public void readFrom(ChannelBuffer data, int length) {
101 super.readFrom(data, length);
102 role = data.readInt();
106 * Write the role vendor data to the ChannelBuffer
107 * @param data the channel buffer to which we're serializing
109 public void writeTo(ChannelBuffer data) {