Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 1 | /** |
| 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 | */ |
| 21 | package org.openflow.protocol.action; |
| 22 | |
| 23 | |
| 24 | import org.jboss.netty.buffer.ChannelBuffer; |
| 25 | |
| 26 | /** |
| 27 | * Represents an ofp_action_vlan_pcp |
| 28 | * @author David Erickson (daviderickson@cs.stanford.edu) - Mar 11, 2010 |
| 29 | */ |
| 30 | public class OFActionVirtualLanPriorityCodePoint extends OFAction { |
| 31 | public static int MINIMUM_LENGTH = 8; |
| 32 | |
| 33 | protected byte virtualLanPriorityCodePoint; |
| 34 | |
| 35 | public OFActionVirtualLanPriorityCodePoint() { |
| 36 | super.setType(OFActionType.SET_VLAN_PCP); |
| 37 | super.setLength((short) MINIMUM_LENGTH); |
| 38 | } |
| 39 | |
| 40 | public OFActionVirtualLanPriorityCodePoint(byte priority) { |
| 41 | this(); |
| 42 | this.virtualLanPriorityCodePoint = priority; |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * @return the virtualLanPriorityCodePoint |
| 47 | */ |
| 48 | public byte getVirtualLanPriorityCodePoint() { |
| 49 | return virtualLanPriorityCodePoint; |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * @param virtualLanPriorityCodePoint the virtualLanPriorityCodePoint to set |
| 54 | */ |
| 55 | public void setVirtualLanPriorityCodePoint(byte virtualLanPriorityCodePoint) { |
| 56 | this.virtualLanPriorityCodePoint = virtualLanPriorityCodePoint; |
| 57 | } |
| 58 | |
| 59 | @Override |
| 60 | public void readFrom(ChannelBuffer data) { |
| 61 | super.readFrom(data); |
| 62 | this.virtualLanPriorityCodePoint = data.readByte(); |
| 63 | data.readShort(); // pad |
| 64 | data.readByte(); // pad |
| 65 | } |
| 66 | |
| 67 | @Override |
| 68 | public void writeTo(ChannelBuffer data) { |
| 69 | super.writeTo(data); |
| 70 | data.writeByte(this.virtualLanPriorityCodePoint); |
| 71 | data.writeShort((short) 0); |
| 72 | data.writeByte((byte) 0); |
| 73 | } |
| 74 | |
| 75 | @Override |
| 76 | public int hashCode() { |
| 77 | final int prime = 389; |
| 78 | int result = super.hashCode(); |
| 79 | result = prime * result + virtualLanPriorityCodePoint; |
| 80 | return result; |
| 81 | } |
| 82 | |
| 83 | @Override |
| 84 | public boolean equals(Object obj) { |
| 85 | if (this == obj) { |
| 86 | return true; |
| 87 | } |
| 88 | if (!super.equals(obj)) { |
| 89 | return false; |
| 90 | } |
| 91 | if (!(obj instanceof OFActionVirtualLanPriorityCodePoint)) { |
| 92 | return false; |
| 93 | } |
| 94 | OFActionVirtualLanPriorityCodePoint other = (OFActionVirtualLanPriorityCodePoint) obj; |
| 95 | if (virtualLanPriorityCodePoint != other.virtualLanPriorityCodePoint) { |
| 96 | return false; |
| 97 | } |
| 98 | return true; |
| 99 | } |
| 100 | } |