2 * Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
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
19 * @author David Erickson (daviderickson@cs.stanford.edu) - Mar 11, 2010
21 package org.openflow.protocol.action;
24 import org.jboss.netty.buffer.ChannelBuffer;
27 * Represents an ofp_action_vlan_vid
28 * @author David Erickson (daviderickson@cs.stanford.edu) - Mar 11, 2010
30 public class OFActionVirtualLanIdentifier extends OFAction {
31 public static int MINIMUM_LENGTH = 8;
33 protected short virtualLanIdentifier;
35 public OFActionVirtualLanIdentifier() {
36 super.setType(OFActionType.SET_VLAN_ID);
37 super.setLength((short) MINIMUM_LENGTH);
40 public OFActionVirtualLanIdentifier(short vlanId) {
42 this.virtualLanIdentifier = vlanId;
46 * @return the virtualLanIdentifier
48 public short getVirtualLanIdentifier() {
49 return virtualLanIdentifier;
53 * @param virtualLanIdentifier the virtualLanIdentifier to set
55 public void setVirtualLanIdentifier(short virtualLanIdentifier) {
56 this.virtualLanIdentifier = virtualLanIdentifier;
60 public void readFrom(ChannelBuffer data) {
62 this.virtualLanIdentifier = data.readShort();
67 public void writeTo(ChannelBuffer data) {
69 data.writeShort(this.virtualLanIdentifier);
70 data.writeShort((short) 0);
74 public int hashCode() {
75 final int prime = 383;
76 int result = super.hashCode();
77 result = prime * result + virtualLanIdentifier;
82 public boolean equals(Object obj) {
86 if (!super.equals(obj)) {
89 if (!(obj instanceof OFActionVirtualLanIdentifier)) {
92 OFActionVirtualLanIdentifier other = (OFActionVirtualLanIdentifier) obj;
93 if (virtualLanIdentifier != other.virtualLanIdentifier) {