1 package org.openflow.codec.protocol.statistics;
3 import java.io.Serializable;
4 import java.util.Arrays;
6 import org.openflow.codec.io.IDataBuffer;
9 * Represents an ofp_group_features structure
11 * @author Yugandhar Sarraju
13 public class OFPGroupFeatures implements OFPStatistics, Serializable {
15 private static final int MINIMUM_LENGTH = 40;
18 * represents ofp_group_capabilities
21 public enum OFGroupCapabilities {
22 OFPGFC_SELECT_WEIGHT(1 << 0), /* Support weight for select groups */
23 OFPGFC_SELECT_LIVENESS(1 << 1), /* Support liveness for select groups */
24 OFPGFC_CHAINING(1 << 2), /* Support chaining groups */
25 OFPGFC_CHAINING_CHECKS(1 << 3); /* Check chaining for loops and delete */
29 private OFGroupCapabilities(int value) {
36 public int getValue() {
41 private short length = MINIMUM_LENGTH;
43 private int capabilities;
44 private int[] max_groups;
45 private int[] actions;
47 public int getTypes() {
51 public void setTypes(int types) {
55 public int getCapabilities() {
59 public void setCapabilities(int capabilities) {
60 this.capabilities = capabilities;
63 public int[] getMax_groups() {
67 public void setMax_groups(int[] max_groups) {
68 if (max_groups.length != 4)
69 throw new RuntimeException("Max Groups must have length " + 4);
70 this.max_groups = max_groups;
73 public int[] getActions() {
77 public void setActions(int[] actions) {
78 if (actions.length != 4)
79 throw new RuntimeException("Actions must have length " + 4);
80 this.actions = actions;
84 public int getLength() {
89 public void readFrom(IDataBuffer data) {
91 this.types = data.getInt();
92 this.capabilities = data.getInt();
93 if (this.max_groups == null)
94 this.max_groups = new int[4];
95 for (int i = 0; i < 4; i++) {
96 this.max_groups[i] = data.getInt();
98 if (this.actions == null)
99 this.actions = new int[4];
100 for (int i = 0; i < 4; i++) {
101 this.actions[i] = data.getInt();
106 public void writeTo(IDataBuffer data) {
108 data.putInt(this.types);
109 data.putInt(this.capabilities);
110 for (int i = 0; i < 4; i++) {
111 data.putInt(this.max_groups[i]);
113 for (int i = 0; i < 4; i++) {
114 data.putInt(this.actions[i]);
119 public int hashCode() {
120 final int prime = 457;
122 result = prime * result + types;
123 result = prime * result + capabilities;
124 result = prime * Arrays.hashCode(getMax_groups());
125 result = prime * Arrays.hashCode(actions);
130 public boolean equals(Object obj) {
137 if (!(obj instanceof OFPGroupFeatures)) {
140 OFPGroupFeatures other = (OFPGroupFeatures) obj;
141 if (types != other.types) {
144 if (capabilities != other.capabilities) {
147 if (!Arrays.equals(max_groups, other.max_groups)) {
150 if (!Arrays.equals(actions, other.actions)) {