[SEBA-593] Splitting dhcpl2relay app in implementation and api bundles

Change-Id: Ia9c060eeac3d74dc6829d774d32d288da0df203e
diff --git a/api/pom.xml b/api/pom.xml
new file mode 100644
index 0000000..e9a9fe1
--- /dev/null
+++ b/api/pom.xml
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Copyright 2016-present Open Networking Foundation
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+<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/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>dhcpl2relay</artifactId>
+        <groupId>org.opencord</groupId>
+        <version>1.6.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>dhcpl2relay-api</artifactId>
+
+    <packaging>bundle</packaging>
+
+    <description>DHCP L2 Relay application API</description>
+
+    <properties>
+        <sadis.api.version>3.0.0</sadis.api.version>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onlab-junit</artifactId>
+            <version>${onos.version}</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-core-serializers</artifactId>
+            <version>${onos.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.opencord</groupId>
+            <artifactId>sadis-api</artifactId>
+            <version>${sadis.api.version}</version>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+            </plugin>
+        </plugins>
+    </build>
+</project>
\ No newline at end of file
diff --git a/api/src/main/java/org/opencord/dhcpl2relay/DhcpAllocationInfo.java b/api/src/main/java/org/opencord/dhcpl2relay/DhcpAllocationInfo.java
new file mode 100755
index 0000000..f87c5b0
--- /dev/null
+++ b/api/src/main/java/org/opencord/dhcpl2relay/DhcpAllocationInfo.java
@@ -0,0 +1,109 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.opencord.dhcpl2relay;
+
+import org.onlab.packet.DHCP;
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.MacAddress;
+import org.onosproject.net.ConnectPoint;
+
+import java.time.Instant;
+
+/**
+ * Information about DHCP Allocations.
+ */
+public class DhcpAllocationInfo {
+
+    private ConnectPoint location;
+    private String circuitId;
+    private MacAddress macAddress;
+    private IpAddress ip;
+    private Instant allocationTime;
+    private DHCP.MsgType type;
+
+    /**
+     * Creates a new DHCP allocation info record.
+     *
+     * @param location connect point the requestor was seen on
+     * @param type last known message type
+     * @param circuitId option 82 information
+     * @param macAddress MAC address of client
+     * @param ip IP of client if allocated
+     */
+    public DhcpAllocationInfo(ConnectPoint location, DHCP.MsgType type,
+                              String circuitId, MacAddress macAddress, IpAddress ip) {
+        this.location = location;
+        this.type = type;
+        this.circuitId = circuitId;
+        this.macAddress = macAddress;
+        this.ip = ip;
+        this.allocationTime = Instant.now();
+    }
+
+    /**
+     * Location the requestor was seen on.
+     *
+     * @return connect point
+     */
+    public ConnectPoint location() {
+        return location;
+    }
+
+    /**
+     * Last seen message type of the DHCP exchange.
+     *
+     * @return DHCP message type
+     */
+    public DHCP.MsgType type() {
+        return type;
+    }
+
+    /**
+     * Option 82 information.
+     *
+     * @return circuit ID
+     */
+    public String circuitId() {
+        return circuitId;
+    }
+
+    /**
+     * MAC address of client.
+     *
+     * @return mac address
+     */
+    public  MacAddress macAddress() {
+        return  macAddress;
+    }
+
+    /**
+     * IP address of client if it has one.
+     *
+     * @return client IP
+     */
+    public IpAddress ipAddress() {
+        return ip;
+    }
+
+    /**
+     * Timestamp when the last DHCP message was seen.
+     *
+     * @return time
+     */
+    public Instant allocationTime() {
+        return allocationTime;
+    }
+}
diff --git a/api/src/main/java/org/opencord/dhcpl2relay/DhcpL2RelayEvent.java b/api/src/main/java/org/opencord/dhcpl2relay/DhcpL2RelayEvent.java
new file mode 100644
index 0000000..364197d
--- /dev/null
+++ b/api/src/main/java/org/opencord/dhcpl2relay/DhcpL2RelayEvent.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.opencord.dhcpl2relay;
+
+import org.onosproject.event.AbstractEvent;
+import org.onosproject.net.ConnectPoint;
+
+/**
+ * Dhcp L2 relay event.
+ */
+public class DhcpL2RelayEvent extends AbstractEvent<DhcpL2RelayEvent.Type, DhcpAllocationInfo> {
+
+    private final ConnectPoint connectPoint;
+
+    /**
+     * Type of the event.
+     */
+    public enum Type {
+        /**
+         * DHCP lease was updated.
+         */
+        UPDATED,
+
+        /**
+         * DHCP lease was removed.
+         */
+        REMOVED
+    }
+
+    /**
+     * Creates a new event.
+     *
+     * @param type type of the event
+     * @param allocationInfo DHCP allocation info
+     * @param connectPoint connect point the client is on
+     */
+    public DhcpL2RelayEvent(Type type, DhcpAllocationInfo allocationInfo, ConnectPoint connectPoint) {
+        super(type, allocationInfo);
+        this.connectPoint = connectPoint;
+    }
+
+    /**
+     * Gets the DHCP client connect point.
+     *
+     * @return connect point
+     */
+    public ConnectPoint connectPoint() {
+        return connectPoint;
+    }
+}
diff --git a/api/src/main/java/org/opencord/dhcpl2relay/DhcpL2RelayListener.java b/api/src/main/java/org/opencord/dhcpl2relay/DhcpL2RelayListener.java
new file mode 100644
index 0000000..7f18d5a
--- /dev/null
+++ b/api/src/main/java/org/opencord/dhcpl2relay/DhcpL2RelayListener.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.opencord.dhcpl2relay;
+
+import org.onosproject.event.EventListener;
+
+/**
+ * Listener for DHCP relay events.
+ */
+public interface DhcpL2RelayListener extends EventListener<DhcpL2RelayEvent> {
+}
diff --git a/api/src/main/java/org/opencord/dhcpl2relay/DhcpL2RelayService.java b/api/src/main/java/org/opencord/dhcpl2relay/DhcpL2RelayService.java
new file mode 100644
index 0000000..76957ab
--- /dev/null
+++ b/api/src/main/java/org/opencord/dhcpl2relay/DhcpL2RelayService.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.opencord.dhcpl2relay;
+
+import org.onosproject.event.ListenerService;
+
+/**
+ * DHCP L2 relay service.
+ */
+public interface DhcpL2RelayService extends
+        ListenerService<DhcpL2RelayEvent, DhcpL2RelayListener> {
+}
diff --git a/api/src/main/java/org/opencord/dhcpl2relay/package-info.java b/api/src/main/java/org/opencord/dhcpl2relay/package-info.java
new file mode 100755
index 0000000..5acda83
--- /dev/null
+++ b/api/src/main/java/org/opencord/dhcpl2relay/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ *  DHCP-L2RELAY application.
+ */
+package org.opencord.dhcpl2relay;