proxy arp application

Change-Id: Ic2136537a4104e75b64ae4731e1bae4f3a4c1661
diff --git a/apps/proxyarp/pom.xml b/apps/proxyarp/pom.xml
new file mode 100644
index 0000000..4051d19
--- /dev/null
+++ b/apps/proxyarp/pom.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.onlab.onos</groupId>
+        <artifactId>onos-apps</artifactId>
+        <version>1.0.0-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <artifactId>onos-app-proxyarp</artifactId>
+    <packaging>bundle</packaging>
+
+    <description>ONOS simple proxy arp module</description>
+
+</project>
diff --git a/apps/proxyarp/src/main/java/org/onlab/onos/proxyarp/ProxyArp.java b/apps/proxyarp/src/main/java/org/onlab/onos/proxyarp/ProxyArp.java
new file mode 100644
index 0000000..a06470f
--- /dev/null
+++ b/apps/proxyarp/src/main/java/org/onlab/onos/proxyarp/ProxyArp.java
@@ -0,0 +1,70 @@
+package org.onlab.onos.proxyarp;
+
+import static org.slf4j.LoggerFactory.getLogger;
+
+import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Deactivate;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.onlab.onos.ApplicationId;
+import org.onlab.onos.net.packet.PacketContext;
+import org.onlab.onos.net.packet.PacketProcessor;
+import org.onlab.onos.net.packet.PacketService;
+import org.onlab.onos.net.proxyarp.ProxyArpService;
+import org.slf4j.Logger;
+
+/**
+ * Sample reactive proxy arp application.
+ */
+@Component(immediate = true)
+public class ProxyArp {
+
+
+    private final Logger log = getLogger(getClass());
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected PacketService packetService;
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected ProxyArpService proxyArpService;
+
+    private ProxyArpProcessor processor = new ProxyArpProcessor();
+
+    private ApplicationId appId;
+
+    @Activate
+    public void activate() {
+        appId = ApplicationId.getAppId();
+        packetService.addProcessor(processor, PacketProcessor.ADVISOR_MAX + 1);
+        log.info("Started with Application ID {}", appId.id());
+    }
+
+    @Deactivate
+    public void deactivate() {
+        packetService.removeProcessor(processor);
+        processor = null;
+        log.info("Stopped");
+    }
+
+
+    /**
+     * Packet processor responsible for forwarding packets along their paths.
+     */
+    private class ProxyArpProcessor implements PacketProcessor {
+
+        @Override
+        public void process(PacketContext context) {
+            // Stop processing if the packet has been handled, since we
+            // can't do any more to it.
+            if (context.isHandled()) {
+                return;
+            }
+
+            //handle the arp packet.
+            proxyArpService.handleArp(context);
+        }
+    }
+}
+
+
diff --git a/apps/proxyarp/src/main/java/org/onlab/onos/proxyarp/package-info.java b/apps/proxyarp/src/main/java/org/onlab/onos/proxyarp/package-info.java
new file mode 100644
index 0000000..3f7da98
--- /dev/null
+++ b/apps/proxyarp/src/main/java/org/onlab/onos/proxyarp/package-info.java
@@ -0,0 +1,4 @@
+/**
+ * Proxy Arp  application that handles arp resolution for you.
+ */
+package org.onlab.onos.proxyarp;