0bc09c958083da67191026a0f205e8ca54f1c7a9
[controller.git] / third-party / openflowj_netty / src / main / java / org / openflow / protocol / action / OFActionTransportLayer.java
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_tp_port
28  * @author David Erickson (daviderickson@cs.stanford.edu) - Mar 11, 2010
29  */
30 public abstract class OFActionTransportLayer extends OFAction {
31     public static int MINIMUM_LENGTH = 8;
32
33     protected short transportPort;
34
35     /**
36      * @return the transportPort
37      */
38     public short getTransportPort() {
39         return transportPort;
40     }
41
42     /**
43      * @param transportPort the transportPort to set
44      */
45     public void setTransportPort(short transportPort) {
46         this.transportPort = transportPort;
47     }
48
49     @Override
50     public void readFrom(ChannelBuffer data) {
51         super.readFrom(data);
52         this.transportPort = data.readShort();
53         data.readShort();
54     }
55
56     @Override
57     public void writeTo(ChannelBuffer data) {
58         super.writeTo(data);
59         data.writeShort(this.transportPort);
60         data.writeShort((short) 0);
61     }
62
63     @Override
64     public int hashCode() {
65         final int prime = 373;
66         int result = super.hashCode();
67         result = prime * result + transportPort;
68         return result;
69     }
70
71     @Override
72     public boolean equals(Object obj) {
73         if (this == obj) {
74             return true;
75         }
76         if (!super.equals(obj)) {
77             return false;
78         }
79         if (!(obj instanceof OFActionTransportLayer)) {
80             return false;
81         }
82         OFActionTransportLayer other = (OFActionTransportLayer) obj;
83         if (transportPort != other.transportPort) {
84             return false;
85         }
86         return true;
87     }
88 }