2 * @author Yugandhar Sarraju (ysarraju@in.ibm.com) - July 21, 2013
4 package org.openflow.codec.protocol.action;
6 import org.openflow.codec.io.IDataBuffer;
7 import org.openflow.codec.protocol.OFBMatchFields;
8 import org.openflow.codec.protocol.OXMClass;
9 import org.openflow.codec.protocol.OXMField;
12 * Represents an action struct ofp_action_set_field
14 public class OFPActionSetField extends OFPAction {
15 public static int MINIMUM_LENGTH = 8;
21 public OFPActionSetField() {
22 super.setType(OFPActionType.SET_FIELD);
23 super.setLength((short) MINIMUM_LENGTH);
24 oxmtlvField = new OXMField();
27 public OFPActionSetField(OXMClass classType, OFBMatchFields matchField, boolean hasMask, byte[] data) {
28 oxmtlvField = new OXMField(classType, matchField, hasMask, data);
32 public OXMClass getOXMClassType() {
33 return this.oxmtlvField.getOXMClassType();
36 public void setOXMClassType(OXMClass OXMClassType) {
37 this.oxmtlvField.setOXMClassType(OXMClassType);
40 public OFBMatchFields getMatchField() {
41 return this.oxmtlvField.getMatchField();
44 public void setMatchField(OFBMatchFields matchField) {
45 this.oxmtlvField.setMatchField(matchField);
48 public boolean isHasMask() {
49 return this.oxmtlvField.isHasMask();
52 public void setHasMask(boolean hasMask) {
53 this.oxmtlvField.setHasMask(hasMask);
57 * to get the total length of match field (or TLV) including header in bytes
61 public byte getFieldLength() {
62 // Type + Lenghth + Value
63 return this.oxmtlvField.getLength();
66 public byte[] getData() {
67 return this.oxmtlvField.getData();
70 public void setData(byte[] data) {
71 this.oxmtlvField.setData(data);
75 public void readFrom(IDataBuffer data) {
77 if (oxmtlvField == null)
78 oxmtlvField = new OXMField();
79 oxmtlvField.readFrom(data);
83 public void writeTo(IDataBuffer data) {
85 oxmtlvField.writeTo(data);
89 public int hashCode() {
90 final int prime = 353;
91 int result = super.hashCode();
92 result = prime * result + (oxmtlvField == null ? 0 : oxmtlvField.hashCode());
97 public boolean equals(Object obj) {
101 if (!super.equals(obj)) {
104 if (!(obj instanceof OFPActionSetField)) {
107 OFPActionSetField other = (OFPActionSetField) obj;
108 if (this.oxmtlvField.getMatchField() != other.oxmtlvField.getMatchField()) {