Initial commit for DHCPService 01/30701/5
authorVishal Thapar <vishal.thapar@ericsson.com>
Fri, 4 Dec 2015 09:13:38 +0000 (14:43 +0530)
committerVishal Thapar <vishal.thapar@ericsson.com>
Wed, 9 Dec 2015 11:57:42 +0000 (17:27 +0530)
This adds basic skeletal code for DHCP Service to be used
by VPNService modules.

Change-Id: I988d87d1d4cc3b6345ca7b47d2a7f38f1a4e7c5a
Signed-off-by: Vishal Thapar <vishal.thapar@ericsson.com>
17 files changed:
commons/config-parent/pom.xml
dhcpservice/dhcpservice-api/pom.xml [new file with mode: 0644]
dhcpservice/dhcpservice-api/src/main/java/org/opendaylight/vpnservice/dhcpservice/api/DHCPConstants.java [new file with mode: 0644]
dhcpservice/dhcpservice-api/src/main/java/org/opendaylight/vpnservice/dhcpservice/api/DHCPMConstants.java [new file with mode: 0644]
dhcpservice/dhcpservice-api/src/main/java/org/opendaylight/vpnservice/dhcpservice/api/DHCPUtils.java [new file with mode: 0644]
dhcpservice/dhcpservice-api/src/main/yang/dhcpservice-api.yang [new file with mode: 0644]
dhcpservice/dhcpservice-impl/pom.xml [new file with mode: 0644]
dhcpservice/dhcpservice-impl/src/main/config/default-config.xml [new file with mode: 0644]
dhcpservice/dhcpservice-impl/src/main/java/org/opendaylight/vpnservice/dhcpservice/DhcpPktHandler.java [new file with mode: 0644]
dhcpservice/dhcpservice-impl/src/main/java/org/opendaylight/vpnservice/dhcpservice/DhcpProvider.java [new file with mode: 0644]
dhcpservice/dhcpservice-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/dhcpservice/impl/rev150710/DhcpServiceImplModule.java [new file with mode: 0644]
dhcpservice/dhcpservice-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/dhcpservice/impl/rev150710/DhcpServiceImplModuleFactory.java [new file with mode: 0644]
dhcpservice/dhcpservice-impl/src/main/yang/dhcpservice-impl.yang [new file with mode: 0644]
dhcpservice/pom.xml [new file with mode: 0644]
features/pom.xml
features/src/main/features/features.xml
pom.xml

index 60c9534bce07697ef847a59a6eb5caaaa81a0f12..a3fff3a867789594a107034ccef69c52195ee293 100644 (file)
@@ -31,6 +31,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
     <openflowplugin.version>0.2.0-SNAPSHOT</openflowplugin.version>
     <vpns.ovsdb.version>1.2.1-SNAPSHOT</vpns.ovsdb.version>
     <liblldp.version>0.10.0-SNAPSHOT</liblldp.version>
+    <neutron.version>0.6.0-SNAPSHOT</neutron.version>
   </properties>
 
   <dependencyManagement>
diff --git a/dhcpservice/dhcpservice-api/pom.xml b/dhcpservice/dhcpservice-api/pom.xml
new file mode 100644 (file)
index 0000000..f40230d
--- /dev/null
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. 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
+-->
+<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>
+    <groupId>org.opendaylight.vpnservice</groupId>
+    <artifactId>binding-parent</artifactId>
+    <version>0.2.0-SNAPSHOT</version>
+    <relativePath>../../commons/binding-parent</relativePath>
+  </parent>
+
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.opendaylight.vpnservice</groupId>
+  <artifactId>dhcpservice-api</artifactId>
+  <version>${vpnservices.version}</version>
+  <packaging>bundle</packaging>
+
+</project>
diff --git a/dhcpservice/dhcpservice-api/src/main/java/org/opendaylight/vpnservice/dhcpservice/api/DHCPConstants.java b/dhcpservice/dhcpservice-api/src/main/java/org/opendaylight/vpnservice/dhcpservice/api/DHCPConstants.java
new file mode 100644 (file)
index 0000000..e5c751c
--- /dev/null
@@ -0,0 +1,130 @@
+/*
+ * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. 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.vpnservice.dhcpservice.api;
+
+public final class DHCPConstants {
+
+    // DHCP BOOTP CODES
+    public static final byte BOOTREQUEST    = 1;
+    public static final byte BOOTREPLY      = 2;
+
+    // DHCP HTYPE CODES
+    public static final byte HTYPE_ETHER    = 1;
+
+    // DHCP MESSAGE CODES
+    public static final byte MSG_DISCOVER   =  1;
+    public static final byte MSG_OFFER      =  2;
+    public static final byte MSG_REQUEST    =  3;
+    public static final byte MSG_DECLINE    =  4;
+    public static final byte MSG_ACK        =  5;
+    public static final byte MSG_NAK        =  6;
+    public static final byte MSG_RELEASE    =  7;
+    public static final byte MSG_INFORM     =  8;
+    public static final byte MSG_FORCERENEW =  9;
+
+    // DHCP OPTIONS CODE
+    public static final byte OPT_PAD                          =   0;
+    public static final byte OPT_SUBNET_MASK                  =   1;
+    public static final byte OPT_TIME_OFFSET                  =   2;
+    public static final byte OPT_ROUTERS                      =   3;
+    public static final byte OPT_TIME_SERVERS                 =   4;
+    public static final byte OPT_NAME_SERVERS                 =   5;
+    public static final byte OPT_DOMAIN_NAME_SERVERS          =   6;
+    public static final byte OPT_LOG_SERVERS                  =   7;
+    public static final byte OPT_COOKIE_SERVERS               =   8;
+    public static final byte OPT_LPR_SERVERS                  =   9;
+    public static final byte OPT_IMPRESS_SERVERS              =  10;
+    public static final byte OPT_RESOURCE_LOCATION_SERVERS    =  11;
+    public static final byte OPT_HOST_NAME                    =  12;
+    public static final byte OPT_BOOT_SIZE                    =  13;
+    public static final byte OPT_MERIT_DUMP                   =  14;
+    public static final byte OPT_DOMAIN_NAME                  =  15;
+    public static final byte OPT_SWAP_SERVER                  =  16;
+    public static final byte OPT_ROOT_PATH                    =  17;
+    public static final byte OPT_EXTENSIONS_PATH              =  18;
+    public static final byte OPT_IP_FORWARDING                =  19;
+    public static final byte OPT_NON_LOCAL_SOURCE_ROUTING     =  20;
+    public static final byte OPT_POLICY_FILTER                =  21;
+    public static final byte OPT_MAX_DGRAM_REASSEMBLY         =  22;
+    public static final byte OPT_DEFAULT_IP_TTL               =  23;
+    public static final byte OPT_PATH_MTU_AGING_TIMEOUT       =  24;
+    public static final byte OPT_PATH_MTU_PLATEAU_TABLE       =  25;
+    public static final byte OPT_INTERFACE_MTU                =  26;
+    public static final byte OPT_ALL_SUBNETS_LOCAL            =  27;
+    public static final byte OPT_BROADCAST_ADDRESS            =  28;
+    public static final byte OPT_PERFORM_MASK_DISCOVERY       =  29;
+    public static final byte OPT_MASK_SUPPLIER                =  30;
+    public static final byte OPT_ROUTER_DISCOVERY             =  31;
+    public static final byte OPT_ROUTER_SOLICITATION_ADDRESS  =  32;
+    public static final byte OPT_STATIC_ROUTES                =  33;
+    public static final byte OPT_TRAILER_ENCAPSULATION        =  34;
+    public static final byte OPT_ARP_CACHE_TIMEOUT            =  35;
+    public static final byte OPT_IEEE802_3_ENCAPSULATION      =  36;
+    public static final byte OPT_DEFAULT_TCP_TTL              =  37;
+    public static final byte OPT_TCP_KEEPALIVE_INTERVAL       =  38;
+    public static final byte OPT_TCP_KEEPALIVE_GARBAGE        =  39;
+    public static final byte OPT_NIS_SERVERS                  =  41;
+    public static final byte OPT_NTP_SERVERS                  =  42;
+    public static final byte OPT_VENDOR_ENCAPSULATED_OPTIONS  =  43;
+    public static final byte OPT_NETBIOS_NAME_SERVERS         =  44;
+    public static final byte OPT_NETBIOS_DD_SERVER            =  45;
+    public static final byte OPT_NETBIOS_NODE_TYPE            =  46;
+    public static final byte OPT_NETBIOS_SCOPE                =  47;
+    public static final byte OPT_FONT_SERVERS                 =  48;
+    public static final byte OPT_X_DISPLAY_MANAGER            =  49;
+    public static final byte OPT_REQUESTED_ADDRESS            =  50;
+    public static final byte OPT_LEASE_TIME                   =  51;
+    public static final byte OPT_OPTION_OVERLOAD              =  52;
+    public static final byte OPT_MESSAGE_TYPE                 =  53;
+    public static final byte OPT_SERVER_IDENTIFIER            =  54;
+    public static final byte OPT_PARAMETER_REQUEST_LIST       =  55;
+    public static final byte OPT_MESSAGE                      =  56;
+    public static final byte OPT_MAX_MESSAGE_SIZE             =  57;
+    public static final byte OPT_RENEWAL_TIME                 =  58;
+    public static final byte OPT_REBINDING_TIME               =  59;
+    public static final byte OPT_VENDOR_CLASS_IDENTIFIER      =  60;
+    public static final byte OPT_CLIENT_IDENTIFIER            =  61;
+    public static final byte OPT_NWIP_DOMAIN_NAME             =  62;
+    public static final byte OPT_NWIP_SUBOPTIONS              =  63;
+    public static final byte OPT_NISPLUS_DOMAIN               =  64;
+    public static final byte OPT_NISPLUS_SERVER               =  65;
+    public static final byte OPT_TFTP_SERVER                  =  66;
+    public static final byte OPT_BOOTFILE                     =  67;
+    public static final byte OPT_MOBILE_IP_HOME_AGENT         =  68;
+    public static final byte OPT_SMTP_SERVER                  =  69;
+    public static final byte OPT_POP3_SERVER                  =  70;
+    public static final byte OPT_NNTP_SERVER                  =  71;
+    public static final byte OPT_WWW_SERVER                   =  72;
+    public static final byte OPT_FINGER_SERVER                =  73;
+    public static final byte OPT_IRC_SERVER                   =  74;
+    public static final byte OPT_STREETTALK_SERVER            =  75;
+    public static final byte OPT_STDA_SERVER                  =  76;
+    public static final byte OPT_USER_CLASS                   =  77;
+    public static final byte OPT_FQDN                         =  81;
+    public static final byte OPT_AGENT_OPTIONS                =  82;
+    public static final byte OPT_NDS_SERVERS                  =  85;
+    public static final byte OPT_NDS_TREE_NAME                =  86;
+    public static final byte OPT_NDS_CONTEXT                  =  87;
+    public static final byte OPT_CLIENT_LAST_TRANSACTION_TIME =  91;
+    public static final byte OPT_ASSOCIATED_IP                =  92;
+    public static final byte OPT_USER_AUTHENTICATION_PROTOCOL =  98;
+    public static final byte OPT_AUTO_CONFIGURE               = 116;
+    public static final byte OPT_NAME_SERVICE_SEARCH          = 117;
+    public static final byte OPT_SUBNET_SELECTION             = 118;
+    public static final byte OPT_DOMAIN_SEARCH                = 119;
+    public static final byte OPT_CLASSLESS_ROUTE              = 121;
+    public static final byte OPT_END                          =  -1;
+
+    public static final int MAGIC_COOKIE = 0x63825363;
+
+    public static final int DHCP_MIN_SIZE        = 300;
+    public static final int DHCP_MAX_SIZE        = 576;
+
+    public static final int DHCP_NOOPT_HDR_SIZE        = 240;
+}
diff --git a/dhcpservice/dhcpservice-api/src/main/java/org/opendaylight/vpnservice/dhcpservice/api/DHCPMConstants.java b/dhcpservice/dhcpservice-api/src/main/java/org/opendaylight/vpnservice/dhcpservice/api/DHCPMConstants.java
new file mode 100644 (file)
index 0000000..9da75e9
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. 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.vpnservice.dhcpservice.api;
+
+import java.math.BigInteger;
+
+public final class DHCPMConstants {
+
+    // DHCP Service Table Ids
+    public static final short DHCP_TABLE = 0;
+    public static final short L3_FIB_TABLE = 20;
+
+    public static final long DHCP_TABLE_MAX_ENTRY = 10000;
+
+    public static final int DEFAULT_DHCP_FLOW_PRIORITY = 50;
+    public static final int ARP_FLOW_PRIORITY = 50;
+
+    public static final BigInteger COOKIE_DHCP_BASE = new BigInteger("6800000", 16);
+    public static final BigInteger METADATA_ALL_CLEAR_MASK = new BigInteger("0000000000000000", 16);
+    public static final BigInteger METADATA_ALL_SET_MASK = new BigInteger("FFFFFFFFFFFFFFFF", 16);
+
+    public static final String FLOWID_PREFIX = "DHCP.";
+    public static final String VMFLOWID_PREFIX = "DHCP.INTERFACE.";
+    public static final String BCAST_DEST_IP = "255.255.255.255";
+    public static final int BCAST_IP = 0xffffffff;
+
+    public static final short dhcpClientPort = 68;
+    public static final short dhcpServerPort = 67;
+
+    public static final int DEFAULT_LEASE_TIME = 86400;
+}
diff --git a/dhcpservice/dhcpservice-api/src/main/java/org/opendaylight/vpnservice/dhcpservice/api/DHCPUtils.java b/dhcpservice/dhcpservice-api/src/main/java/org/opendaylight/vpnservice/dhcpservice/api/DHCPUtils.java
new file mode 100644 (file)
index 0000000..167e807
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. 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.vpnservice.dhcpservice.api;
+
+
+import java.math.BigInteger;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.List;
+
+public abstract class DHCPUtils {
+
+    public static byte[] byteToByteArray(byte b) {
+        return new byte[] {b};
+    }
+
+    public static byte[] shortToByteArray(short s) {
+        return new byte[] { (byte) ((s >> 8) & 0xff), (byte) (s & 0xff) };
+    }
+
+    public static byte[] intToByteArray(int i ) {
+        return new byte[] { (byte) ((i >> 24) & 0xff), (byte) ((i >> 16) & 0xff), (byte) ((i >> 8) & 0xff),
+                        (byte) (i & 0xff) };
+    }
+
+    public static byte[] inetAddrToByteArray(InetAddress a) {
+        return a.getAddress();
+    }
+
+    public static byte[] strAddrToByteArray(String addr) {
+        try {
+            return InetAddress.getByName(addr).getAddress();
+        } catch (UnknownHostException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+            return null;
+        }
+    }
+
+    public static byte[] strListAddrsToByteArray(List<String> strList) {
+        byte[] result = new byte[strList.size() * 4];
+        byte[] addr = new byte[4];
+        try {
+        for (int i = 0; i < strList.size(); i++) {
+                    addr = InetAddress.getByName(strList.get(i)).getAddress();
+                System.arraycopy(addr, 0, result, i*4, 4);
+        }
+        } catch (UnknownHostException e) {
+            return null;
+        }
+        return result;
+    }
+
+    public static short byteArrayToShort(byte[] ba) {
+        if (ba == null || ba.length != 2) {
+            return 0;
+        }
+        return (short) ((0xff & ba[0]) << 8 | (0xff & ba[1]));
+    }
+
+    public static InetAddress byteArrayToInetAddr(byte[] ba) {
+        try {
+            return InetAddress.getByAddress(ba);
+        } catch (UnknownHostException e) {
+            return null;
+        }
+    }
+
+    public static byte[] strMacAddrtoByteArray(String macAddress) {
+        if(macAddress == null) {
+            return null;
+        }
+        String[] bytes = macAddress.split(":");
+        byte[] result = new byte[bytes.length];
+        for (int i = 0; i < bytes.length; i++) {
+            BigInteger temp = new BigInteger(bytes[i], 16);
+            byte[] raw = temp.toByteArray();
+            result[i] = raw[raw.length - 1];
+        }
+        return result;
+    }
+
+}
diff --git a/dhcpservice/dhcpservice-api/src/main/yang/dhcpservice-api.yang b/dhcpservice/dhcpservice-api/src/main/yang/dhcpservice-api.yang
new file mode 100644 (file)
index 0000000..6d45eed
--- /dev/null
@@ -0,0 +1,11 @@
+module dhcpservice-api {
+    yang-version 1;
+    namespace "urn:opendaylight:params:xml:ns:yang:dhcpservice:api";
+    prefix "dhcpservice-api";
+
+    revision "2015-07-10" {
+        description
+            "Initial revision for DHCP Service module";
+    }
+
+}
\ No newline at end of file
diff --git a/dhcpservice/dhcpservice-impl/pom.xml b/dhcpservice/dhcpservice-impl/pom.xml
new file mode 100644 (file)
index 0000000..d6c1c00
--- /dev/null
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: --><!--
+Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. 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
+-->
+<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>
+    <groupId>org.opendaylight.vpnservice</groupId>
+    <artifactId>config-parent</artifactId>
+    <version>0.2.0-SNAPSHOT</version>
+    <relativePath>../../commons/config-parent</relativePath>
+  </parent>
+
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.opendaylight.vpnservice</groupId>
+  <artifactId>dhcpservice-impl</artifactId>
+  <version>${vpnservices.version}</version>
+  <packaging>bundle</packaging>
+  <dependencies>
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>dhcpservice-api</artifactId>
+      <version>${vpnservices.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>sal-binding-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.openflowplugin.model</groupId>
+      <artifactId>model-flow-service</artifactId>
+      <version>${openflowplugin.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>mdsalutil-api</artifactId>
+      <version>${vpnservices.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.neutron</groupId>
+      <artifactId>model</artifactId>
+      <version>${neutron.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>commons-net</groupId>
+      <artifactId>commons-net</artifactId>
+    </dependency>
+   </dependencies>
+
+</project>
diff --git a/dhcpservice/dhcpservice-impl/src/main/config/default-config.xml b/dhcpservice/dhcpservice-impl/src/main/config/default-config.xml
new file mode 100644 (file)
index 0000000..64b2bfa
--- /dev/null
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
+<!--
+Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. 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
+-->
+<snapshot>
+  <required-capabilities>
+      <capability>urn:opendaylight:params:xml:ns:yang:dhcpservice:impl?module=dhcpservice-impl&amp;revision=2015-07-10</capability>
+      <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&amp;revision=2013-10-28</capability>
+      <capability>urn:opendaylight:params:xml:ns:yang:mdsalutil:api?module=odl-mdsalutil&amp;revision=2015-04-10</capability>
+  </required-capabilities>
+  <configuration>
+
+    <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+      <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
+        <module>
+          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:dhcpservice:impl">prefix:dhcpservice-impl</type>
+          <name>dhcpservice-default</name>
+          <broker>
+            <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-broker-osgi-registry</type>
+            <name>binding-osgi-broker</name>
+          </broker>
+          <rpcregistry>
+            <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-rpc-registry</type>
+            <name>binding-rpc-broker</name>
+          </rpcregistry>
+          <notification-service>
+             <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-notification-service</type>
+             <name>binding-notification-broker</name>
+          </notification-service>
+          <mdsalutil>
+            <type xmlns:mdsalutil="urn:opendaylight:params:xml:ns:yang:mdsalutil:api">mdsalutil:odl-mdsalutil</type>
+            <name>mdsalutil-service</name>
+          </mdsalutil>
+        </module>
+      </modules>
+    </data>
+  </configuration>
+</snapshot>
diff --git a/dhcpservice/dhcpservice-impl/src/main/java/org/opendaylight/vpnservice/dhcpservice/DhcpPktHandler.java b/dhcpservice/dhcpservice-impl/src/main/java/org/opendaylight/vpnservice/dhcpservice/DhcpPktHandler.java
new file mode 100644 (file)
index 0000000..16a2dc1
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. 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.vpnservice.dhcpservice;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceived;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingListener;
+
+public class DhcpPktHandler implements AutoCloseable, PacketProcessingListener {
+    
+    private static final Logger LOG = LoggerFactory.getLogger(DhcpPktHandler.class);
+    private final DataBroker dataBroker;
+
+    public DhcpPktHandler(final DataBroker broker) {
+        this.dataBroker = broker;
+    }
+
+    @Override
+    public void onPacketReceived(PacketReceived pktReceived) {
+        LOG.info("Pkt received: {}",pktReceived);
+    }
+
+    @Override
+    public void close() throws Exception {
+        // TODO Auto-generated method stub
+        
+    }
+
+}
diff --git a/dhcpservice/dhcpservice-impl/src/main/java/org/opendaylight/vpnservice/dhcpservice/DhcpProvider.java b/dhcpservice/dhcpservice-impl/src/main/java/org/opendaylight/vpnservice/dhcpservice/DhcpProvider.java
new file mode 100644 (file)
index 0000000..7c086c2
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. 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.vpnservice.dhcpservice;
+
+import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+
+import org.opendaylight.yangtools.concepts.Registration;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
+import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
+import org.opendaylight.vpnservice.mdsalutil.interfaces.IMdsalApiManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DhcpProvider implements BindingAwareProvider, AutoCloseable {
+
+    private static final Logger LOG = LoggerFactory.getLogger(DhcpProvider.class);
+    private IMdsalApiManager mdsalManager;
+    private DhcpPktHandler dhcpPktHandler;
+    private Registration packetListener = null;
+    private NotificationProviderService notificationService;
+
+    @Override
+    public void onSessionInitiated(ProviderContext session) {
+        LOG.info("DhcpProvider Session Initiated");
+        try {
+            final  DataBroker dataBroker = session.getSALService(DataBroker.class);
+            dhcpPktHandler = new DhcpPktHandler(dataBroker);
+            packetListener = notificationService.registerNotificationListener(dhcpPktHandler);
+            } catch (Exception e) {
+            LOG.error("Error initializing services", e);
+        }
+    }
+
+
+    public void setMdsalManager(IMdsalApiManager mdsalManager) {
+        this.mdsalManager = mdsalManager;
+    }
+
+    @Override
+    public void close() throws Exception {
+        if(packetListener != null) {
+            packetListener.close();
+        }
+        if(dhcpPktHandler != null) {
+            dhcpPktHandler.close();
+        }
+        LOG.info("DhcpProvider closed");
+    }
+
+    public void setNotificationProviderService(NotificationProviderService notificationServiceDependency) {
+        this.notificationService = notificationServiceDependency;
+    }
+
+}
diff --git a/dhcpservice/dhcpservice-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/dhcpservice/impl/rev150710/DhcpServiceImplModule.java b/dhcpservice/dhcpservice-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/dhcpservice/impl/rev150710/DhcpServiceImplModule.java
new file mode 100644 (file)
index 0000000..9fbd12c
--- /dev/null
@@ -0,0 +1,27 @@
+package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dhcpservice.impl.rev150710;
+
+import org.opendaylight.vpnservice.dhcpservice.DhcpProvider;
+
+public class DhcpServiceImplModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dhcpservice.impl.rev150710.AbstractDhcpServiceImplModule {
+    public DhcpServiceImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+        super(identifier, dependencyResolver);
+    }
+
+    public DhcpServiceImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dhcpservice.impl.rev150710.DhcpServiceImplModule oldModule, java.lang.AutoCloseable oldInstance) {
+        super(identifier, dependencyResolver, oldModule, oldInstance);
+    }
+
+    @Override
+    public void customValidation() {
+        // add custom validation form module attributes here.
+    }
+
+    @Override
+    public java.lang.AutoCloseable createInstance() {
+        DhcpProvider dhcpProvider = new DhcpProvider();
+        dhcpProvider.setNotificationProviderService(getNotificationServiceDependency());
+        getBrokerDependency().registerProvider(dhcpProvider);
+        return dhcpProvider;
+    }
+
+}
diff --git a/dhcpservice/dhcpservice-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/dhcpservice/impl/rev150710/DhcpServiceImplModuleFactory.java b/dhcpservice/dhcpservice-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/dhcpservice/impl/rev150710/DhcpServiceImplModuleFactory.java
new file mode 100644 (file)
index 0000000..09562b0
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+* Generated file
+*
+* Generated from: yang module name: dhcpservice-impl yang module local name: dhcpservice-impl
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Sat Jul 11 21:38:25 IST 2015
+*
+* Do not modify this file unless it is present under src/main directory
+*/
+package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dhcpservice.impl.rev150710;
+public class DhcpServiceImplModuleFactory extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dhcpservice.impl.rev150710.AbstractDhcpServiceImplModuleFactory {
+
+}
diff --git a/dhcpservice/dhcpservice-impl/src/main/yang/dhcpservice-impl.yang b/dhcpservice/dhcpservice-impl/src/main/yang/dhcpservice-impl.yang
new file mode 100644 (file)
index 0000000..dcbec02
--- /dev/null
@@ -0,0 +1,61 @@
+module dhcpservice-impl {
+    yang-version 1;
+    namespace "urn:opendaylight:params:xml:ns:yang:dhcpservice:impl";
+    prefix "dhcpservice-impl";
+
+    import config { prefix config; revision-date 2013-04-05; }
+    import opendaylight-md-sal-binding { prefix md-sal-binding; revision-date 2013-10-28;}
+    import odl-mdsalutil { prefix odl-mdsal; revision-date 2015-04-10;}
+
+    description
+        "Service definition for dhcpservice project";
+
+    revision "2015-07-10" {
+        description
+            "Initial revision";
+    }
+
+    identity dhcpservice-impl {
+        base config:module-type;
+        config:java-name-prefix DhcpServiceImpl;
+    }
+
+    augment "/config:modules/config:module/config:configuration" {
+        case dhcpservice-impl {
+            when "/config:modules/config:module/config:type = 'dhcpservice-impl'";
+            container broker {
+                uses config:service-ref {
+                    refine type {
+                        mandatory true;
+                        config:required-identity md-sal-binding:binding-broker-osgi-registry;
+                    }
+                }
+            }
+            container rpcregistry {
+                uses config:service-ref {
+                    refine type {
+                        mandatory true;
+                        config:required-identity md-sal-binding:binding-rpc-registry;
+                    }
+                }
+            }
+            container notification-service {
+                uses config:service-ref {
+                    refine type {
+                        mandatory true;
+                        config:required-identity md-sal-binding:binding-notification-service;
+                    }
+                }
+            }
+
+            container mdsalutil {
+                uses config:service-ref {
+                    refine type {
+                        mandatory true;
+                        config:required-identity odl-mdsal:odl-mdsalutil;
+                    }
+                }
+            }
+        }
+    }
+}
diff --git a/dhcpservice/pom.xml b/dhcpservice/pom.xml
new file mode 100644 (file)
index 0000000..dc16678
--- /dev/null
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. 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 INTERNAL
+-->
+<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>
+    <groupId>org.opendaylight.odlparent</groupId>
+    <artifactId>odlparent</artifactId>
+    <version>1.6.0-SNAPSHOT</version>
+    <relativePath/>
+  </parent>
+
+  <groupId>org.opendaylight.vpnservice</groupId>
+  <artifactId>dhcpservice-aggregator</artifactId>
+  <version>0.2.0-SNAPSHOT</version>
+  <name>dhcpservice</name>
+  <packaging>pom</packaging>
+  <modelVersion>4.0.0</modelVersion>
+  <prerequisites>
+    <maven>3.1.1</maven>
+  </prerequisites>
+  <modules>
+    <module>dhcpservice-api</module>
+    <module>dhcpservice-impl</module>
+  </modules>
+  <!-- DO NOT install or deploy the repo root pom as it's only needed to initiate a build -->
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-deploy-plugin</artifactId>
+        <configuration>
+          <skip>true</skip>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-install-plugin</artifactId>
+        <configuration>
+          <skip>true</skip>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>
index 4fae2518ad0fcb45fc2d99c48ba4bc89d46bd3a4..a16ee561a75ea5613c4e1cc6b29406c30ac9a6f7 100644 (file)
@@ -36,7 +36,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
     <fibmanager.version>${vpnservices.version}</fibmanager.version>
     <lockmanager.version>${vpnservices.version}</lockmanager.version>
     <idmanager.version>${vpnservices.version}</idmanager.version>
-       <itm.version>${vpnservices.version}</itm.version>
+    <itm.version>${vpnservices.version}</itm.version>
   </properties>
   <dependencyManagement>
     <dependencies>
@@ -196,7 +196,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
       <artifactId>model-bgp</artifactId>
       <version>2013.07.15.8-SNAPSHOT</version>
     </dependency>
-       <dependency>
+    <dependency>
       <groupId>${project.groupId}</groupId>
       <artifactId>nexthopmgr-impl</artifactId>
       <version>${nexthopmgr.version}</version>
@@ -213,7 +213,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
       <artifactId>nexthopmgr-api</artifactId>
       <version>${nexthopmgr.version}</version>
     </dependency>
-       <dependency>
+    <dependency>
       <groupId>${project.groupId}</groupId>
       <artifactId>fibmanager-impl</artifactId>
       <version>${fibmanager.version}</version>
@@ -264,7 +264,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
       <artifactId>idmanager-api</artifactId>
       <version>${idmanager.version}</version>
     </dependency>
-       <dependency>
+    <dependency>
       <groupId>org.opendaylight.vpnservice</groupId>
       <artifactId>itm-impl</artifactId>
       <version>${itm.version}</version>
@@ -276,6 +276,23 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
       <classifier>config</classifier>
       <type>xml</type>
     </dependency>
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>dhcpservice-impl</artifactId>
+      <version>${vpnservices.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>dhcpservice-impl</artifactId>
+      <version>${vpnservices.version}</version>
+      <classifier>config</classifier>
+      <type>xml</type>
+    </dependency>
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>dhcpservice-api</artifactId>
+      <version>${vpnservices.version}</version>
+    </dependency>
     <dependency>
       <groupId>org.apache.thrift</groupId>
       <artifactId>libthrift</artifactId>
index c7167833f29062941586472f0e72be7ced6ef50d..6f116b558732772837f1be7140a080bcd802e70f 100644 (file)
@@ -28,6 +28,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
     <bundle>mvn:org.opendaylight.vpnservice/nexthopmgr-api/${nexthopmgr.version}</bundle>
     <bundle>mvn:org.opendaylight.vpnservice/fibmanager-api/${fibmanager.version}</bundle>
     <bundle>mvn:org.opendaylight.vpnservice/itm-api/${itm.version}</bundle>
+    <bundle>mvn:org.opendaylight.vpnservice/dhcpservice-api/${vpnservices.version}</bundle>
   </feature>
   <feature name='odl-vpnservice-impl' version='${project.version}' description='OpenDaylight :: vpnservice :: impl '>
     <feature version='${mdsal.version}'>odl-mdsal-broker</feature>
@@ -48,12 +49,14 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
     <bundle>mvn:org.opendaylight.vpnservice/nexthopmgr-impl/${nexthopmgr.version}</bundle>
     <bundle>mvn:org.opendaylight.vpnservice/fibmanager-impl/${fibmanager.version}</bundle>
     <bundle>mvn:org.opendaylight.vpnservice/itm-impl/${itm.version}</bundle>
-    
+    <bundle>mvn:org.opendaylight.vpnservice/dhcpservice-impl/${vpnservices.version}</bundle>
+
     <!--<bundle>mvn:org.opendaylight.vpnservice.third-party/org.apache.thriftlib/1.0.1-SNAPSHOT</bundle>-->
     <bundle>wrap:mvn:org.apache.thrift/libthrift/0.9.1$overwrite=merge&amp;Bundle-Version=0.9.1&amp;Export-Package=*;-noimport:=true;version="0.9.1"</bundle>
     <!--<bundle>wrap:mvn:javax.servlet/servlet-api/2.5</bundle>-->
     <configfile finalname="lockmanager-impl-default-config.xml">mvn:org.opendaylight.vpnservice/lockmanager-impl/${lockmanager.version}/xml/config</configfile>
-       <configfile finalname="idmanager-impl-default-config.xml">mvn:org.opendaylight.vpnservice/idmanager-impl/${idmanager.version}/xml/config</configfile>
+    <configfile finalname="idmanager-impl-default-config.xml">mvn:org.opendaylight.vpnservice/idmanager-impl/${idmanager.version}/xml/config</configfile>
+    <configfile finalname="idmanager-impl-default-config.xml">mvn:org.opendaylight.vpnservice/idmanager-impl/${idmanager.version}/xml/config</configfile>
     <configfile finalname="bgpmanager-impl-default-config.xml">mvn:org.opendaylight.vpnservice/bgpmanager-impl/${vpnservices.version}/xml/config</configfile>
     <configfile finalname="mdsalutil-impl-default-config.xml">mvn:org.opendaylight.vpnservice/mdsalutil-impl/${interfacemgr.version}/xml/config</configfile>
     <configfile finalname="interfacemgr-impl-default-config.xml">mvn:org.opendaylight.vpnservice/interfacemgr-impl/${interfacemgr.version}/xml/config</configfile>
@@ -62,7 +65,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
     <configfile finalname="nexthopmgr-impl-default-config.xml">mvn:org.opendaylight.vpnservice/nexthopmgr-impl/${nexthopmgr.version}/xml/config</configfile>
     <configfile finalname="fibmanager-impl-default-config.xml">mvn:org.opendaylight.vpnservice/fibmanager-impl/${fibmanager.version}/xml/config</configfile>
     <configfile finalname="itm-impl-default-config.xml">mvn:org.opendaylight.vpnservice/itm-impl/${itm.version}/xml/config</configfile>
-
+    <configfile finalname="dhcpservice-impl-default-config.xml">mvn:org.opendaylight.vpnservice/dhcpservice-impl/${vpnservices.version}/xml/config</configfile>
   </feature>
   <feature name='odl-vpnservice-impl-rest' version='${project.version}' description='OpenDaylight :: vpnservice :: impl :: REST '>
     <feature version="${project.version}">odl-vpnservice-impl</feature>
diff --git a/pom.xml b/pom.xml
index 4e9b4dd3a4c8176a8151156f499e087569a061c1..8b3fc8bf82def40b9a695e69b1c4eee0e08417e6 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -28,6 +28,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
     <module>nexthopmgr</module>
     <module>fibmanager</module>
     <module>bgpmanager</module>
+    <module>dhcpservice</module>
     <module>itm</module>
     <module>distribution/karaf</module>
     <module>features</module>