Merge "Updated pom.xml to build documentation only on jenkins merge-job"
[openflowjava.git] / third-party / openflow-codec / src / main / java / org / openflow / codec / protocol / OFPSwitchConfig.java
1 package org.openflow.codec.protocol;
2
3 import org.openflow.codec.io.IDataBuffer;
4
5 /**
6  * Base class representing ofp_switch_config based messages
7  *
8  * @author David Erickson (daviderickson@cs.stanford.edu)
9  */
10 public abstract class OFPSwitchConfig extends OFPMessage {
11     public static int MINIMUM_LENGTH = 12;
12
13     public enum OFConfigFlags {
14         OFPC_FRAG_NORMAL, OFPC_FRAG_DROP, OFPC_FRAG_REASM, OFPC_FRAG_MASK
15     }
16
17     protected short flags;
18     protected short missSendLength;
19
20     public OFPSwitchConfig() {
21         super();
22         super.setLengthU(MINIMUM_LENGTH);
23     }
24
25     /**
26      * @return the flags
27      */
28     public short getFlags() {
29         return flags;
30     }
31
32     /**
33      * @param flags
34      *            the flags to set
35      */
36     public OFPSwitchConfig setFlags(short flags) {
37         this.flags = flags;
38         return this;
39     }
40
41     /**
42      * @return the missSendLength
43      */
44     public short getMissSendLength() {
45         return missSendLength;
46     }
47
48     /**
49      * @param missSendLength
50      *            the missSendLength to set
51      */
52     public OFPSwitchConfig setMissSendLength(short missSendLength) {
53         this.missSendLength = missSendLength;
54         return this;
55     }
56
57     @Override
58     public void readFrom(IDataBuffer data) {
59         super.readFrom(data);
60         this.flags = data.getShort();
61         this.missSendLength = data.getShort();
62     }
63
64     @Override
65     public void writeTo(IDataBuffer data) {
66         super.writeTo(data);
67         data.putShort(this.flags);
68         data.putShort(this.missSendLength);
69     }
70
71     @Override
72     public int hashCode() {
73         final int prime = 331;
74         int result = super.hashCode();
75         result = prime * result + flags;
76         result = prime * result + missSendLength;
77         return result;
78     }
79
80     @Override
81     public boolean equals(Object obj) {
82         if (this == obj) {
83             return true;
84         }
85         if (!super.equals(obj)) {
86             return false;
87         }
88         if (!(obj instanceof OFPSwitchConfig)) {
89             return false;
90         }
91         OFPSwitchConfig other = (OFPSwitchConfig) obj;
92         if (flags != other.flags) {
93             return false;
94         }
95         if (missSendLength != other.missSendLength) {
96             return false;
97         }
98         return true;
99     }
100 }