HA - ARPHandler Event sync
[controller.git] / opendaylight / arphandler / src / main / java / org / opendaylight / controller / arphandler / ARPRequest.java
diff --git a/opendaylight/arphandler/src/main/java/org/opendaylight/controller/arphandler/ARPRequest.java b/opendaylight/arphandler/src/main/java/org/opendaylight/controller/arphandler/ARPRequest.java
new file mode 100644 (file)
index 0000000..7f88a25
--- /dev/null
@@ -0,0 +1,85 @@
+
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.arphandler;
+
+import java.net.InetAddress;
+
+import org.opendaylight.controller.arphandler.ARPEvent;
+import org.opendaylight.controller.hosttracker.hostAware.HostNodeConnector;
+import org.opendaylight.controller.switchmanager.Subnet;
+/*
+ * ARP Request event wrapper Consists of IP and Subnet (and a
+ * HostNodeConnector if is unicast) For unicast request, construct with a
+ * specified host
+ */
+public class ARPRequest extends ARPEvent {
+    private final Subnet subnet;
+    private final HostNodeConnector host;
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result + ((host == null) ? 0 : host.hashCode());
+        result = prime * result + ((subnet == null) ? 0 : subnet.hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null) {
+            return false;
+        }
+        if (!(obj instanceof ARPRequest)) {
+            return false;
+        }
+        ARPRequest other = (ARPRequest) obj;
+        if (host == null) {
+            if (other.host != null) {
+                return false;
+            }
+        } else if (!host.equals(other.host)) {
+            return false;
+        }
+        if (subnet == null) {
+            if (other.subnet != null) {
+                return false;
+            }
+        } else if (!subnet.equals(other.subnet)) {
+            return false;
+        }
+        return true;
+    }
+
+    // broadcast
+    public ARPRequest(InetAddress ip, Subnet subnet) {
+        super(ip);
+        this.subnet = subnet;
+        this.host = null;
+    }
+
+    // unicast
+    public ARPRequest(HostNodeConnector host, Subnet subnet) {
+        super(host.getNetworkAddress());
+        this.host = host;
+        this.subnet = subnet;
+    }
+
+    public Subnet getSubnet() {
+        return subnet;
+    }
+
+    public HostNodeConnector getHost() {
+        return host;
+    }
+}