Performacne improvements via adding a netty-based openflowj and openflow plugin;...
[controller.git] / third-party / openflowj_netty / src / main / java / org / openflow / protocol / OFSwitchConfig.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 package org.openflow.protocol;
19
20
21 import org.jboss.netty.buffer.ChannelBuffer;
22
23 /**
24  * Base class representing ofp_switch_config based messages
25  * @author David Erickson (daviderickson@cs.stanford.edu)
26  */
27 public abstract class OFSwitchConfig extends OFMessage {
28     public static int MINIMUM_LENGTH = 12;
29
30     public enum OFConfigFlags {
31         OFPC_FRAG_NORMAL,
32         OFPC_FRAG_DROP,
33         OFPC_FRAG_REASM,
34         OFPC_FRAG_MASK
35     }
36
37     protected short flags;
38     protected short missSendLength;
39
40     public OFSwitchConfig() {
41         super();
42         super.setLengthU(MINIMUM_LENGTH);
43     }
44
45     /**
46      * @return the flags
47      */
48     public short getFlags() {
49         return flags;
50     }
51
52     /**
53      * @param flags the flags to set
54      */
55     public OFSwitchConfig setFlags(short flags) {
56         this.flags = flags;
57         return this;
58     }
59
60     /**
61      * @return the missSendLength
62      */
63     public short getMissSendLength() {
64         return missSendLength;
65     }
66
67     /**
68      * @param missSendLength the missSendLength to set
69      */
70     public OFSwitchConfig setMissSendLength(short missSendLength) {
71         this.missSendLength = missSendLength;
72         return this;
73     }
74
75     @Override
76     public void readFrom(ChannelBuffer data) {
77         super.readFrom(data);
78         this.flags = data.readShort();
79         this.missSendLength = data.readShort();
80     }
81
82     @Override
83     public void writeTo(ChannelBuffer data) {
84         super.writeTo(data);
85         data.writeShort(this.flags);
86         data.writeShort(this.missSendLength);
87     }
88
89     @Override
90     public int hashCode() {
91         final int prime = 331;
92         int result = super.hashCode();
93         result = prime * result + flags;
94         result = prime * result + missSendLength;
95         return result;
96     }
97
98     @Override
99     public boolean equals(Object obj) {
100         if (this == obj) {
101             return true;
102         }
103         if (!super.equals(obj)) {
104             return false;
105         }
106         if (!(obj instanceof OFSwitchConfig)) {
107             return false;
108         }
109         OFSwitchConfig other = (OFSwitchConfig) obj;
110         if (flags != other.flags) {
111             return false;
112         }
113         if (missSendLength != other.missSendLength) {
114             return false;
115         }
116         return true;
117     }
118 }