2 * Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
5 * Licensed under the Apache License, Version 2.0 (the "License"); you may
6 * not use this file except in compliance with the License. You may obtain
7 * a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 * License for the specific language governing permissions and limitations
19 * @author David Erickson (daviderickson@cs.stanford.edu) - Mar 11, 2010
21 package org.openflow.protocol.action;
23 import java.util.Arrays;
27 import org.jboss.netty.buffer.ChannelBuffer;
28 import org.openflow.protocol.OFPhysicalPort;
31 * Represents an ofp_action_dl_addr
32 * @author David Erickson (daviderickson@cs.stanford.edu) - Mar 11, 2010
34 public abstract class OFActionDataLayer extends OFAction {
35 public static int MINIMUM_LENGTH = 16;
37 protected byte[] dataLayerAddress;
40 * @return the dataLayerAddress
42 public byte[] getDataLayerAddress() {
43 return dataLayerAddress;
47 * @param dataLayerAddress the dataLayerAddress to set
49 public void setDataLayerAddress(byte[] dataLayerAddress) {
50 this.dataLayerAddress = dataLayerAddress;
54 public void readFrom(ChannelBuffer data) {
56 if (this.dataLayerAddress == null)
57 this.dataLayerAddress = new byte[OFPhysicalPort.OFP_ETH_ALEN];
58 data.readBytes(this.dataLayerAddress);
64 public void writeTo(ChannelBuffer data) {
66 data.writeBytes(this.dataLayerAddress);
68 data.writeShort((short) 0);
72 public int hashCode() {
73 final int prime = 347;
74 int result = super.hashCode();
75 result = prime * result + Arrays.hashCode(dataLayerAddress);
80 public boolean equals(Object obj) {
84 if (!super.equals(obj)) {
87 if (!(obj instanceof OFActionDataLayer)) {
90 OFActionDataLayer other = (OFActionDataLayer) obj;
91 if (!Arrays.equals(dataLayerAddress, other.dataLayerAddress)) {