2 * @author David Erickson (daviderickson@cs.stanford.edu) - Mar 11, 2010
4 package org.openflow.protocol.action;
6 import java.nio.ByteBuffer;
7 import java.util.Arrays;
9 import org.openflow.protocol.OFPhysicalPort;
12 * Represents an ofp_action_dl_addr
13 * @author David Erickson (daviderickson@cs.stanford.edu) - Mar 11, 2010
15 public abstract class OFActionDataLayer extends OFAction {
16 public static int MINIMUM_LENGTH = 16;
18 protected byte[] dataLayerAddress;
21 * @return the dataLayerAddress
23 public byte[] getDataLayerAddress() {
24 return dataLayerAddress;
28 * @param dataLayerAddress the dataLayerAddress to set
30 public void setDataLayerAddress(byte[] dataLayerAddress) {
31 this.dataLayerAddress = dataLayerAddress;
35 public void readFrom(ByteBuffer data) {
37 if (this.dataLayerAddress == null)
38 this.dataLayerAddress = new byte[OFPhysicalPort.OFP_ETH_ALEN];
39 data.get(this.dataLayerAddress);
45 public void writeTo(ByteBuffer data) {
47 data.put(this.dataLayerAddress, 0, OFPhysicalPort.OFP_ETH_ALEN);
49 data.putShort((short) 0);
53 public int hashCode() {
54 final int prime = 347;
55 int result = super.hashCode();
56 result = prime * result + Arrays.hashCode(dataLayerAddress);
61 public boolean equals(Object obj) {
65 if (!super.equals(obj)) {
68 if (!(obj instanceof OFActionDataLayer)) {
71 OFActionDataLayer other = (OFActionDataLayer) obj;
72 if (!Arrays.equals(dataLayerAddress, other.dataLayerAddress)) {