Adding broken version of netty-fied openflowj and openflow protocol plugin
[openflowplugin.git] / third-party / openflowj_netty / src / main / java / org / openflow / protocol / action / OFActionNetworkTypeOfService.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_enqueue
28  * @author David Erickson (daviderickson@cs.stanford.edu) - Mar 11, 2010
29  */
30 public class OFActionNetworkTypeOfService extends OFAction {
31     public static int MINIMUM_LENGTH = 8;
32
33     protected byte networkTypeOfService;
34
35     public OFActionNetworkTypeOfService() {
36         super.setType(OFActionType.SET_NW_TOS);
37         super.setLength((short) MINIMUM_LENGTH);
38     }
39     
40     public OFActionNetworkTypeOfService(byte tos) {
41         this();
42         this.networkTypeOfService = tos;
43     }
44     
45
46     /**
47      * @return the networkTypeOfService
48      */
49     public byte getNetworkTypeOfService() {
50         return networkTypeOfService;
51     }
52
53     /**
54      * @param networkTypeOfService the networkTypeOfService to set
55      */
56     public void setNetworkTypeOfService(byte networkTypeOfService) {
57         this.networkTypeOfService = networkTypeOfService;
58     }
59
60     @Override
61     public void readFrom(ChannelBuffer data) {
62         super.readFrom(data);
63         this.networkTypeOfService = data.readByte();
64         data.readShort();
65         data.readByte();
66     }
67
68     @Override
69     public void writeTo(ChannelBuffer data) {
70         super.writeTo(data);
71         data.writeByte(this.networkTypeOfService);
72         data.writeShort((short) 0);
73         data.writeByte((byte) 0);
74     }
75
76     @Override
77     public int hashCode() {
78         final int prime = 359;
79         int result = super.hashCode();
80         result = prime * result + networkTypeOfService;
81         return result;
82     }
83
84     @Override
85     public boolean equals(Object obj) {
86         if (this == obj) {
87             return true;
88         }
89         if (!super.equals(obj)) {
90             return false;
91         }
92         if (!(obj instanceof OFActionNetworkTypeOfService)) {
93             return false;
94         }
95         OFActionNetworkTypeOfService other = (OFActionNetworkTypeOfService) obj;
96         if (networkTypeOfService != other.networkTypeOfService) {
97             return false;
98         }
99         return true;
100     }
101 }