HA - ARPHandler Event sync
[controller.git] / opendaylight / arphandler / src / main / java / org / opendaylight / controller / arphandler / ARPReply.java
1
2 /*
3  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
4  *
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
8  */
9
10 package org.opendaylight.controller.arphandler;
11
12 import java.net.InetAddress;
13 import java.util.Arrays;
14
15 import org.opendaylight.controller.sal.core.NodeConnector;
16 /*
17  * ARP Reply event wrapper
18  */
19 public class ARPReply extends ARPEvent {
20
21     private final NodeConnector port;
22     private final byte[] tMac;
23     private final byte[] sMac;
24     private final InetAddress sIP;
25
26     @Override
27     public int hashCode() {
28         final int prime = 31;
29         int result = super.hashCode();
30         result = prime * result + ((sIP == null) ? 0 : sIP.hashCode());
31         result = prime * result + Arrays.hashCode(sMac);
32         result = prime * result + Arrays.hashCode(tMac);
33         return result;
34     }
35
36     @Override
37     public boolean equals(Object obj) {
38         if (this == obj) {
39             return true;
40         }
41         if (obj == null) {
42             return false;
43         }
44         if (!(obj instanceof ARPReply)) {
45             return false;
46         }
47         ARPReply other = (ARPReply) obj;
48         if (sIP == null) {
49             if (other.sIP != null) {
50                 return false;
51             }
52         } else if (!sIP.equals(other.sIP)) {
53             return false;
54         }
55         if (!Arrays.equals(sMac, other.sMac)) {
56             return false;
57         }
58         if (!Arrays.equals(tMac, other.tMac)) {
59             return false;
60         }
61         return true;
62     }
63
64     public ARPReply(NodeConnector port, InetAddress sIP, byte[] sMAC, InetAddress tIP, byte[] tMAC) {
65         super(tIP);
66         this.tMac = tMAC;
67         this.sIP = sIP;
68         this.sMac = sMAC;
69         this.port = port;
70     }
71
72     public ARPReply(InetAddress tIP, byte[] tMAC) {
73         super(tIP);
74         this.tMac = tMAC;
75         this.sIP = null;
76         this.sMac = null;
77         this.port = null;
78     }
79
80     public byte[] getTargetMac() {
81         return tMac;
82     }
83
84     public byte[] getSourceMac() {
85         return sMac;
86     }
87
88     public InetAddress getSourceIP() {
89         return sIP;
90     }
91
92     public NodeConnector getPort() {
93         return port;
94     }
95 }