Initial opendaylight infrastructure commit!!
[controller.git] / third-party / openflowj / src / main / java / org / openflow / protocol / OFSwitchConfig.java
1 package org.openflow.protocol;
2
3 import java.nio.ByteBuffer;
4
5 /**
6  * Base class representing ofp_switch_config based messages
7  * @author David Erickson (daviderickson@cs.stanford.edu)
8  */
9 public abstract class OFSwitchConfig extends OFMessage {
10     public static int MINIMUM_LENGTH = 12;
11
12     public enum OFConfigFlags {
13         OFPC_FRAG_NORMAL,
14         OFPC_FRAG_DROP,
15         OFPC_FRAG_REASM,
16         OFPC_FRAG_MASK
17     }
18
19     protected short flags;
20     protected short missSendLength;
21
22     public OFSwitchConfig() {
23         super();
24         super.setLengthU(MINIMUM_LENGTH);
25     }
26
27     /**
28      * @return the flags
29      */
30     public short getFlags() {
31         return flags;
32     }
33
34     /**
35      * @param flags the flags to set
36      */
37     public OFSwitchConfig setFlags(short flags) {
38         this.flags = flags;
39         return this;
40     }
41
42     /**
43      * @return the missSendLength
44      */
45     public short getMissSendLength() {
46         return missSendLength;
47     }
48
49     /**
50      * @param missSendLength the missSendLength to set
51      */
52     public OFSwitchConfig setMissSendLength(short missSendLength) {
53         this.missSendLength = missSendLength;
54         return this;
55     }
56
57     @Override
58     public void readFrom(ByteBuffer data) {
59         super.readFrom(data);
60         this.flags = data.getShort();
61         this.missSendLength = data.getShort();
62     }
63
64     @Override
65     public void writeTo(ByteBuffer 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 OFSwitchConfig)) {
89             return false;
90         }
91         OFSwitchConfig other = (OFSwitchConfig) obj;
92         if (flags != other.flags) {
93             return false;
94         }
95         if (missSendLength != other.missSendLength) {
96             return false;
97         }
98         return true;
99     }
100 }