Fix: Remove the dependencies between LISP provider and driver

LISP mapping provider should not be aware of LISP driver, and
LISP specific LCAF to Mapping Extension conversion will be realized
in LISP extension address interpreter which is located in protocol.

Change-Id: Idc38c13e084e323f9e07a62fcfac846d6b3d9a56
diff --git a/providers/lisp/mapping/BUCK b/providers/lisp/mapping/BUCK
index ea1cd66..7e4bb9d 100644
--- a/providers/lisp/mapping/BUCK
+++ b/providers/lisp/mapping/BUCK
@@ -3,7 +3,6 @@
     '//protocols/lisp/api:onos-protocols-lisp-api',
     '//protocols/lisp/msg:onos-protocols-lisp-msg',
     '//apps/mappingmanagement/api:onos-apps-mappingmanagement-api',
-    '//drivers/lisp:onos-drivers-lisp',
 ]
 
 TEST_DEPS = [
diff --git a/providers/lisp/mapping/pom.xml b/providers/lisp/mapping/pom.xml
index a8dfb24..dab2d75 100644
--- a/providers/lisp/mapping/pom.xml
+++ b/providers/lisp/mapping/pom.xml
@@ -53,11 +53,6 @@
             <version>${project.version}</version>
         </dependency>
         <dependency>
-            <groupId>org.onosproject</groupId>
-            <artifactId>onos-drivers-lisp</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-        <dependency>
             <groupId>org.easymock</groupId>
             <artifactId>easymock</artifactId>
             <scope>test</scope>
diff --git a/providers/lisp/mapping/src/main/java/org/onosproject/provider/lisp/mapping/util/MappingEntryBuilder.java b/providers/lisp/mapping/src/main/java/org/onosproject/provider/lisp/mapping/util/MappingEntryBuilder.java
index 7d45745..1a0ed09 100644
--- a/providers/lisp/mapping/src/main/java/org/onosproject/provider/lisp/mapping/util/MappingEntryBuilder.java
+++ b/providers/lisp/mapping/src/main/java/org/onosproject/provider/lisp/mapping/util/MappingEntryBuilder.java
@@ -19,15 +19,6 @@
 import org.onlab.packet.IpAddress;
 import org.onlab.packet.IpPrefix;
 import org.onlab.packet.MacAddress;
-import org.onosproject.drivers.lisp.extensions.LispGcAddress;
-import org.onosproject.drivers.lisp.extensions.LispNatAddress;
-import org.onosproject.drivers.lisp.extensions.LispSrcDstAddress;
-import org.onosproject.drivers.lisp.extensions.LispAppDataAddress;
-import org.onosproject.drivers.lisp.extensions.LispListAddress;
-import org.onosproject.drivers.lisp.extensions.LispMulticastAddress;
-import org.onosproject.drivers.lisp.extensions.LispNonceAddress;
-import org.onosproject.drivers.lisp.extensions.LispSegmentAddress;
-import org.onosproject.drivers.lisp.extensions.LispTeAddress;
 import org.onosproject.lisp.msg.protocols.LispLocator;
 import org.onosproject.lisp.msg.protocols.LispMapRecord;
 import org.onosproject.lisp.msg.types.LispAfiAddress;
@@ -36,17 +27,7 @@
 import org.onosproject.lisp.msg.types.LispIpv4Address;
 import org.onosproject.lisp.msg.types.LispIpv6Address;
 import org.onosproject.lisp.msg.types.LispMacAddress;
-import org.onosproject.lisp.msg.types.lcaf.LispMulticastLcafAddress;
-import org.onosproject.lisp.msg.types.lcaf.LispNonceLcafAddress;
-import org.onosproject.lisp.msg.types.lcaf.LispNatLcafAddress;
-import org.onosproject.lisp.msg.types.lcaf.LispGeoCoordinateLcafAddress;
-import org.onosproject.lisp.msg.types.lcaf.LispAsLcafAddress;
 import org.onosproject.lisp.msg.types.lcaf.LispLcafAddress;
-import org.onosproject.lisp.msg.types.lcaf.LispSegmentLcafAddress;
-import org.onosproject.lisp.msg.types.lcaf.LispAppDataLcafAddress;
-import org.onosproject.lisp.msg.types.lcaf.LispListLcafAddress;
-import org.onosproject.lisp.msg.types.lcaf.LispSourceDestLcafAddress;
-import org.onosproject.lisp.msg.types.lcaf.LispTeLcafAddress;
 import org.onosproject.mapping.DefaultMapping;
 import org.onosproject.mapping.DefaultMappingEntry;
 import org.onosproject.mapping.DefaultMappingKey;
@@ -60,7 +41,6 @@
 import org.onosproject.mapping.MappingValue;
 import org.onosproject.mapping.actions.MappingAction;
 import org.onosproject.mapping.actions.MappingActions;
-import org.onosproject.mapping.addresses.ExtensionMappingAddress;
 import org.onosproject.mapping.addresses.MappingAddress;
 import org.onosproject.mapping.addresses.MappingAddresses;
 import org.onosproject.net.DeviceId;
@@ -240,171 +220,8 @@
      */
     private MappingAddress lcaf2Extension(LispLcafAddress lcaf) {
 
-        ExtensionMappingAddress ema;
-
-        switch (lcaf.getType()) {
-            case LIST:
-                LispListLcafAddress lcafListAddress = (LispListLcafAddress) lcaf;
-                MappingAddress ipv4Ma =
-                        afi2MappingAddress(lcafListAddress.getAddresses().get(0));
-                MappingAddress ipv6Ma =
-                        afi2MappingAddress(lcafListAddress.getAddresses().get(1));
-
-                ema = new LispListAddress.Builder()
-                        .withIpv4(ipv4Ma)
-                        .withIpv6(ipv6Ma)
-                        .build();
-                return MappingAddresses.extensionMappingAddressWrapper(ema, deviceId);
-
-            case SEGMENT:
-                LispSegmentLcafAddress segmentLcafAddress = (LispSegmentLcafAddress) lcaf;
-
-                ema = new LispSegmentAddress.Builder()
-                        .withInstanceId(segmentLcafAddress.getInstanceId())
-                        .withAddress(getAddress(segmentLcafAddress.getAddress()))
-                        .build();
-
-                return MappingAddresses.extensionMappingAddressWrapper(ema, deviceId);
-
-            case AS:
-                LispAsLcafAddress asLcafAddress = (LispAsLcafAddress) lcaf;
-
-                ema = new org.onosproject.drivers.lisp.extensions.LispAsAddress.Builder()
-                        .withAsNumber(asLcafAddress.getAsNumber())
-                        .withAddress(getAddress(asLcafAddress.getAddress()))
-                        .build();
-
-                return MappingAddresses.extensionMappingAddressWrapper(ema, deviceId);
-
-            case APPLICATION_DATA:
-
-                LispAppDataLcafAddress appLcafAddress = (LispAppDataLcafAddress) lcaf;
-
-                ema = new LispAppDataAddress.Builder()
-                        .withProtocol(appLcafAddress.getProtocol())
-                        .withIpTos(appLcafAddress.getIpTos())
-                        .withLocalPortLow(appLcafAddress.getLocalPortLow())
-                        .withLocalPortHigh(appLcafAddress.getLocalPortHigh())
-                        .withRemotePortLow(appLcafAddress.getRemotePortLow())
-                        .withRemotePortHigh(appLcafAddress.getRemotePortHigh())
-                        .withAddress(getAddress(appLcafAddress.getAddress()))
-                        .build();
-
-                return MappingAddresses.extensionMappingAddressWrapper(ema, deviceId);
-
-            case GEO_COORDINATE:
-
-                LispGeoCoordinateLcafAddress gcLcafAddress = (LispGeoCoordinateLcafAddress) lcaf;
-
-                ema = new LispGcAddress.Builder()
-                        .withIsNorth(gcLcafAddress.isNorth())
-                        .withLatitudeDegree(gcLcafAddress.getLatitudeDegree())
-                        .withLatitudeMinute(gcLcafAddress.getLatitudeMinute())
-                        .withLatitudeSecond(gcLcafAddress.getLatitudeSecond())
-                        .withIsEast(gcLcafAddress.isEast())
-                        .withLongitudeDegree(gcLcafAddress.getLongitudeDegree())
-                        .withLongitudeMinute(gcLcafAddress.getLongitudeMinute())
-                        .withLongitudeSecond(gcLcafAddress.getLongitudeSecond())
-                        .withAltitude(gcLcafAddress.getAltitude())
-                        .withAddress(getAddress(gcLcafAddress.getAddress()))
-                        .build();
-
-                return MappingAddresses.extensionMappingAddressWrapper(ema, deviceId);
-
-            case NAT:
-
-                LispNatLcafAddress natLcafAddress = (LispNatLcafAddress) lcaf;
-
-                List<MappingAddress> mas = Lists.newArrayList();
-
-                natLcafAddress.getRtrRlocAddresses().forEach(rtr -> mas.add(getAddress(rtr)));
-
-                ema = new LispNatAddress.Builder()
-                        .withMsUdpPortNumber(natLcafAddress.getMsUdpPortNumber())
-                        .withEtrUdpPortNumber(natLcafAddress.getEtrUdpPortNumber())
-                        .withMsRlocAddress(getAddress(natLcafAddress.getMsRlocAddress()))
-                        .withGlobalEtrRlocAddress(getAddress(natLcafAddress.getGlobalEtrRlocAddress()))
-                        .withPrivateEtrRlocAddress(getAddress(natLcafAddress.getPrivateEtrRlocAddress()))
-                        .withRtrRlocAddresses(mas)
-                        .build();
-
-                return MappingAddresses.extensionMappingAddressWrapper(ema, deviceId);
-
-            case NONCE:
-
-                LispNonceLcafAddress nonceLcafAddress = (LispNonceLcafAddress) lcaf;
-
-                ema = new LispNonceAddress.Builder()
-                        .withNonce(nonceLcafAddress.getNonce())
-                        .withAddress(getAddress(nonceLcafAddress.getAddress()))
-                        .build();
-
-                return MappingAddresses.extensionMappingAddressWrapper(ema, deviceId);
-
-            case MULTICAST:
-
-                LispMulticastLcafAddress multiLcafAddress = (LispMulticastLcafAddress) lcaf;
-
-                ema = new LispMulticastAddress.Builder()
-                        .withInstanceId(multiLcafAddress.getInstanceId())
-                        .withSrcAddress(getAddress(multiLcafAddress.getSrcAddress()))
-                        .withSrcMaskLength(multiLcafAddress.getSrcMaskLength())
-                        .withGrpAddress(getAddress(multiLcafAddress.getGrpAddress()))
-                        .withGrpMaskLength(multiLcafAddress.getGrpMaskLength())
-                        .build();
-
-                return MappingAddresses.extensionMappingAddressWrapper(ema, deviceId);
-
-            case TRAFFIC_ENGINEERING:
-
-                LispTeLcafAddress teLcafAddress = (LispTeLcafAddress) lcaf;
-
-                List<LispTeAddress.TeRecord> records = Lists.newArrayList();
-
-                teLcafAddress.getTeRecords().forEach(record -> {
-                    LispTeAddress.TeRecord teRecord =
-                            new LispTeAddress.TeRecord.Builder()
-                                    .withIsLookup(record.isLookup())
-                                    .withIsRlocProbe(record.isRlocProbe())
-                                    .withIsStrict(record.isStrict())
-                                    .withRtrRlocAddress(getAddress(record.getRtrRlocAddress()))
-                                    .build();
-                    records.add(teRecord);
-                });
-
-                ema = new LispTeAddress.Builder()
-                        .withTeRecords(records)
-                        .build();
-
-                return MappingAddresses.extensionMappingAddressWrapper(ema, deviceId);
-
-            case SECURITY:
-
-                // TODO: need to implement security type later
-                log.warn("security type will be implemented later");
-
-                return null;
-
-            case SOURCE_DEST:
-
-                LispSourceDestLcafAddress srcDstLcafAddress = (LispSourceDestLcafAddress) lcaf;
-
-
-                ema = new LispSrcDstAddress.Builder()
-                        .withSrcPrefix(getAddress(srcDstLcafAddress.getSrcPrefix()))
-                        .withSrcMaskLength(srcDstLcafAddress.getSrcMaskLength())
-                        .withDstPrefix(getAddress(srcDstLcafAddress.getDstPrefix()))
-                        .withDstMaskLength(srcDstLcafAddress.getDstMaskLength())
-                        .build();
-
-                return MappingAddresses.extensionMappingAddressWrapper(ema, deviceId);
-
-            case UNSPECIFIED:
-            case UNKNOWN:
-            default:
-                log.error("Unsupported LCAF type {}", lcaf.getType());
-                return null;
-        }
+        // TODO: move LCAF to extension mapping to LISP Extension Interpreter
+        return null;
     }
 
     /**
diff --git a/providers/lisp/mapping/src/test/java/org/onosproject/provider/lisp/mapping/util/MappingEntryBuilderTest.java b/providers/lisp/mapping/src/test/java/org/onosproject/provider/lisp/mapping/util/MappingEntryBuilderTest.java
index b78f167..ad6d36a 100644
--- a/providers/lisp/mapping/src/test/java/org/onosproject/provider/lisp/mapping/util/MappingEntryBuilderTest.java
+++ b/providers/lisp/mapping/src/test/java/org/onosproject/provider/lisp/mapping/util/MappingEntryBuilderTest.java
@@ -21,14 +21,6 @@
 import org.onlab.packet.IpAddress;
 import org.onlab.packet.IpPrefix;
 import org.onlab.packet.MacAddress;
-import org.onosproject.drivers.lisp.extensions.LispAppDataAddress;
-import org.onosproject.drivers.lisp.extensions.LispGcAddress;
-import org.onosproject.drivers.lisp.extensions.LispListAddress;
-import org.onosproject.drivers.lisp.extensions.LispMulticastAddress;
-import org.onosproject.drivers.lisp.extensions.LispNatAddress;
-import org.onosproject.drivers.lisp.extensions.LispNonceAddress;
-import org.onosproject.drivers.lisp.extensions.LispSegmentAddress;
-import org.onosproject.drivers.lisp.extensions.LispSrcDstAddress;
 import org.onosproject.lisp.msg.protocols.DefaultLispLocator.DefaultLocatorBuilder;
 import org.onosproject.lisp.msg.protocols.DefaultLispMapNotify.DefaultNotifyBuilder;
 import org.onosproject.lisp.msg.protocols.DefaultLispMapRecord.DefaultMapRecordBuilder;
@@ -70,7 +62,6 @@
 import org.onosproject.mapping.addresses.ASMappingAddress;
 import org.onosproject.mapping.addresses.DNMappingAddress;
 import org.onosproject.mapping.addresses.EthMappingAddress;
-import org.onosproject.mapping.addresses.ExtensionMappingAddressWrapper;
 import org.onosproject.mapping.addresses.IPMappingAddress;
 import org.onosproject.mapping.addresses.MappingAddress;
 import org.onosproject.net.DeviceId;
@@ -213,106 +204,6 @@
     }
 
     @Test
-    public void testListLcafAddressConversion() {
-        LispListAddress address = (LispListAddress) ((ExtensionMappingAddressWrapper)
-                getMappingAddressByAfiType(LCAF, LIST)).extensionMappingAddress();
-        assertThat(((IPMappingAddress) address.getIpv4()).ip(), is(IPV4_MAPPING_ADDRESS_1));
-        assertThat(((IPMappingAddress) address.getIpv6()).ip(), is(IPV6_MAPPING_ADDRESS));
-    }
-
-    @Test
-    public void testSegmentLcafAddressConversion() {
-        LispSegmentAddress address = (LispSegmentAddress) ((ExtensionMappingAddressWrapper)
-                getMappingAddressByAfiType(LCAF, SEGMENT)).extensionMappingAddress();
-        assertThat(((IPMappingAddress) address.getAddress()).ip(), is(IPV4_MAPPING_ADDRESS_1));
-        assertThat(address.getInstanceId(), is(UNIQUE_INT));
-    }
-
-    @Test
-    public void testAsLcafAddressConversion() {
-        org.onosproject.drivers.lisp.extensions.LispAsAddress address =
-                (org.onosproject.drivers.lisp.extensions.LispAsAddress)
-                ((ExtensionMappingAddressWrapper)
-                        getMappingAddressByAfiType(LCAF,
-                                LispCanonicalAddressFormatEnum.AS)).extensionMappingAddress();
-        assertThat(((IPMappingAddress) address.getAddress()).ip(), is(IPV4_MAPPING_ADDRESS_1));
-        assertThat(address.getAsNumber(), is(UNIQUE_INT));
-    }
-
-    @Test
-    public void testAppDataLcafAddressConversion() {
-        LispAppDataAddress address = (LispAppDataAddress) ((ExtensionMappingAddressWrapper)
-                getMappingAddressByAfiType(LCAF, APPLICATION_DATA)).extensionMappingAddress();
-        assertThat(((IPMappingAddress) address.getAddress()).ip(), is(IPV4_MAPPING_ADDRESS_1));
-        assertThat(address.getProtocol(), is(UNIQUE_BYTE));
-        assertThat(address.getIpTos(), is(UNIQUE_INT));
-        assertThat(address.getLocalPortLow(), is(UNIQUE_SHORT));
-        assertThat(address.getLocalPortHigh(), is(UNIQUE_SHORT));
-        assertThat(address.getRemotePortLow(), is(UNIQUE_SHORT));
-        assertThat(address.getRemotePortHigh(), is(UNIQUE_SHORT));
-    }
-
-    @Test
-    public void testGcLcafAddressConversion() {
-        LispGcAddress address = (LispGcAddress) ((ExtensionMappingAddressWrapper)
-                getMappingAddressByAfiType(LCAF, GEO_COORDINATE)).extensionMappingAddress();
-        assertThat(((IPMappingAddress) address.getAddress()).ip(), is(IPV4_MAPPING_ADDRESS_1));
-        assertThat(address.isNorth(), is(UNIQUE_BOOLEAN));
-        assertThat(address.getLatitudeDegree(), is(UNIQUE_SHORT));
-        assertThat(address.getLatitudeMinute(), is(UNIQUE_BYTE));
-        assertThat(address.getLatitudeSecond(), is(UNIQUE_BYTE));
-        assertThat(address.isEast(), is(UNIQUE_BOOLEAN));
-        assertThat(address.getLongitudeDegree(), is(UNIQUE_SHORT));
-        assertThat(address.getLongitudeMinute(), is(UNIQUE_BYTE));
-        assertThat(address.getLongitudeSecond(), is(UNIQUE_BYTE));
-        assertThat(address.getAltitude(), is(UNIQUE_INT));
-    }
-
-    @Test
-    public void testNatLcafAddressConversion() {
-        LispNatAddress address = (LispNatAddress) ((ExtensionMappingAddressWrapper)
-                getMappingAddressByAfiType(LCAF, NAT)).extensionMappingAddress();
-        assertThat(((IPMappingAddress)
-                address.getPrivateEtrRlocAddress()).ip(), is(IPV4_MAPPING_ADDRESS_1));
-        assertThat(((IPMappingAddress)
-                address.getGlobalEtrRlocAddress()).ip(), is(IPV4_MAPPING_ADDRESS_1));
-        assertThat(((IPMappingAddress)
-                address.getMsRlocAddress()).ip(), is(IPV4_MAPPING_ADDRESS_1));
-        assertThat(address.getEtrUdpPortNumber(), is(UNIQUE_SHORT));
-        assertThat(address.getMsUdpPortNumber(), is(UNIQUE_SHORT));
-        // TODO: need to compare RtrRlocAddresses
-    }
-
-    @Test
-    public void testNonceLcafAddressConversion() {
-        LispNonceAddress address = (LispNonceAddress) ((ExtensionMappingAddressWrapper)
-                getMappingAddressByAfiType(LCAF, NONCE)).extensionMappingAddress();
-        assertThat(((IPMappingAddress) address.getAddress()).ip(), is(IPV4_MAPPING_ADDRESS_1));
-        assertThat(address.getNonce(), is(UNIQUE_INT));
-    }
-
-    @Test
-    public void testMulticastLcafAddressConversion() {
-        LispMulticastAddress address = (LispMulticastAddress) ((ExtensionMappingAddressWrapper)
-                getMappingAddressByAfiType(LCAF, MULTICAST)).extensionMappingAddress();
-        assertThat(((IPMappingAddress) address.getSrcAddress()).ip(), is(IPV4_MAPPING_ADDRESS_1));
-        assertThat(((IPMappingAddress) address.getGrpAddress()).ip(), is(IPV4_MAPPING_ADDRESS_1));
-        assertThat(address.getInstanceId(), is(UNIQUE_INT));
-        assertThat(address.getSrcMaskLength(), is(UNIQUE_BYTE));
-        assertThat(address.getGrpMaskLength(), is(UNIQUE_BYTE));
-    }
-
-    @Test
-    public void testSrcDstLcafAddressConversion() {
-        LispSrcDstAddress address = (LispSrcDstAddress) ((ExtensionMappingAddressWrapper)
-                getMappingAddressByAfiType(LCAF, SOURCE_DEST)).extensionMappingAddress();
-        assertThat(((IPMappingAddress) address.getSrcPrefix()).ip(), is(IPV4_MAPPING_ADDRESS_1));
-        assertThat(((IPMappingAddress) address.getDstPrefix()).ip(), is(IPV4_MAPPING_ADDRESS_2));
-        assertThat(address.getSrcMaskLength(), is(UNIQUE_BYTE));
-        assertThat(address.getDstMaskLength(), is(UNIQUE_BYTE));
-    }
-
-    @Test
     public void testTeLcafAddressConversion() {
         // TODO: need to compare TeRecord list
     }