blob: 5bd0e0bda156cc34ac915ee29900e8a83b5cfbd0 [file] [log] [blame]
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -08001/**
2* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
3* University
4*
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
8*
9* http://www.apache.org/licenses/LICENSE-2.0
10*
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
15* under the License.
16**/
17
18/**
19 * @author David Erickson (daviderickson@cs.stanford.edu) - Mar 11, 2010
20 */
21package org.openflow.protocol.action;
22
23
24import org.jboss.netty.buffer.ChannelBuffer;
25
26/**
27 * Represents an ofp_action_vlan_vid
28 * @author David Erickson (daviderickson@cs.stanford.edu) - Mar 11, 2010
29 */
30public class OFActionVirtualLanIdentifier extends OFAction {
31 public static int MINIMUM_LENGTH = 8;
32
33 protected short virtualLanIdentifier;
34
35 public OFActionVirtualLanIdentifier() {
36 super.setType(OFActionType.SET_VLAN_ID);
37 super.setLength((short) MINIMUM_LENGTH);
38 }
39
40 public OFActionVirtualLanIdentifier(short vlanId) {
41 this();
42 this.virtualLanIdentifier = vlanId;
43 }
44
45 /**
46 * @return the virtualLanIdentifier
47 */
48 public short getVirtualLanIdentifier() {
49 return virtualLanIdentifier;
50 }
51
52 /**
53 * @param virtualLanIdentifier the virtualLanIdentifier to set
54 */
55 public void setVirtualLanIdentifier(short virtualLanIdentifier) {
56 this.virtualLanIdentifier = virtualLanIdentifier;
57 }
58
59 @Override
60 public void readFrom(ChannelBuffer data) {
61 super.readFrom(data);
62 this.virtualLanIdentifier = data.readShort();
63 data.readShort();
64 }
65
66 @Override
67 public void writeTo(ChannelBuffer data) {
68 super.writeTo(data);
69 data.writeShort(this.virtualLanIdentifier);
70 data.writeShort((short) 0);
71 }
72
73 @Override
74 public int hashCode() {
75 final int prime = 383;
76 int result = super.hashCode();
77 result = prime * result + virtualLanIdentifier;
78 return result;
79 }
80
81 @Override
82 public boolean equals(Object obj) {
83 if (this == obj) {
84 return true;
85 }
86 if (!super.equals(obj)) {
87 return false;
88 }
89 if (!(obj instanceof OFActionVirtualLanIdentifier)) {
90 return false;
91 }
92 OFActionVirtualLanIdentifier other = (OFActionVirtualLanIdentifier) obj;
93 if (virtualLanIdentifier != other.virtualLanIdentifier) {
94 return false;
95 }
96 return true;
97 }
98}