3 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
5 * This program and the accompanying materials are made available under the
6 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7 * and is available at http://www.eclipse.org/legal/epl-v10.html
10 package org.opendaylight.controller.arphandler;
12 import java.net.InetAddress;
13 import java.util.Arrays;
15 import org.opendaylight.controller.sal.core.NodeConnector;
16 import org.opendaylight.controller.sal.utils.HexEncode;
18 * ARP Reply event wrapper
20 public class ARPReply extends ARPEvent {
21 private static final long serialVersionUID = 1L;
22 private final NodeConnector port;
23 private final byte[] tMac;
24 private final byte[] sMac;
25 private final InetAddress sIP;
26 private final short vlan;
29 public int hashCode() {
31 int result = super.hashCode();
32 result = prime * result + ((port == null) ? 0 : port.hashCode());
33 result = prime * result + ((sIP == null) ? 0 : sIP.hashCode());
34 result = prime * result + Arrays.hashCode(sMac);
35 result = prime * result + Arrays.hashCode(tMac);
36 result = prime * result + vlan;
41 public boolean equals(Object obj) {
45 if (!super.equals(obj)) {
48 if (!(obj instanceof ARPReply)) {
51 ARPReply other = (ARPReply) obj;
53 if (other.port != null) {
56 } else if (!port.equals(other.port)) {
60 if (other.sIP != null) {
63 } else if (!sIP.equals(other.sIP)) {
66 if (!Arrays.equals(sMac, other.sMac)) {
69 if (!Arrays.equals(tMac, other.tMac)) {
72 if (vlan != other.vlan) {
78 public ARPReply(NodeConnector port, InetAddress sIP, byte[] sMAC, InetAddress tIP, byte[] tMAC, short vlan) {
87 public ARPReply(InetAddress tIP, byte[] tMAC, short vlan) {
96 public byte[] getTargetMac() {
100 public byte[] getSourceMac() {
104 public InetAddress getSourceIP() {
108 public NodeConnector getPort() {
112 public short getVlan() {
119 * @see java.lang.Object#toString()
122 public String toString() {
123 StringBuilder builder = new StringBuilder();
124 builder.append("ARPReply [");
126 builder.append("port=")
131 builder.append("tMac=")
132 .append(HexEncode.bytesToHexString(tMac))
136 builder.append("sMac=")
137 .append(HexEncode.bytesToHexString(sMac))
141 builder.append("sIP=")
145 builder.append(", vlan=")
149 return builder.toString();