Search in sources :

Example 16 with AddMapping

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.AddMapping in project lispflowmapping by opendaylight.

the class DataStoreBackEndTest method addMappingTest.

/**
 * Tests {@link DataStoreBackEnd#addMapping} method.
 */
@Test
public void addMappingTest() {
    final Mapping mapping = new MappingBuilder().setMappingRecord(getDefaultMappingRecordBuilder().build()).setOrigin(MappingOrigin.Northbound).build();
    dataStoreBackEnd.addMapping(mapping);
    Mockito.verify(wTxMock).put(Mockito.eq(LogicalDatastoreType.CONFIGURATION), iidCaptorMapping.capture(), Mockito.eq(mapping), Mockito.eq(true));
    // result
    MappingKey result = iidCaptorMapping.getValue().firstKeyOf(Mapping.class);
    assertEquals("ipv4:" + IPV4_STRING_1, result.getEidUri().getValue());
    assertEquals(MappingOrigin.Northbound, result.getOrigin());
}
Also used : XtrIdMappingBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.mapping.XtrIdMappingBuilder) MappingBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.MappingBuilder) Mapping(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.Mapping) XtrIdMapping(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.mapping.XtrIdMapping) MappingKey(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.MappingKey) XtrIdMappingKey(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.mapping.XtrIdMappingKey) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 17 with AddMapping

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.AddMapping in project lispflowmapping by opendaylight.

the class LispMappingService method onAddMapping.

@Override
public void onAddMapping(AddMapping mapRegisterNotification) {
    Pair<MapNotify, List<TransportAddress>> result = handleMapRegister(mapRegisterNotification.getMapRegister());
    if (result != null && result.getLeft() != null) {
        MapNotify mapNotify = result.getLeft();
        List<TransportAddress> rlocs = result.getRight();
        if (rlocs == null) {
            TransportAddressBuilder tab = new TransportAddressBuilder();
            tab.setIpAddress(mapRegisterNotification.getTransportAddress().getIpAddress());
            tab.setPort(new PortNumber(LispMessage.PORT_NUM));
            sendMapNotify(mapNotify, tab.build());
        } else {
            for (TransportAddress ta : rlocs) {
                sendMapNotify(mapNotify, ta);
            }
        }
    } else {
        LOG.debug("Not sending Map-Notify");
    }
}
Also used : TransportAddress(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transport.address.TransportAddress) GotMapNotify(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapNotify) MapNotify(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapNotify) List(java.util.List) PortNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber) TransportAddressBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transport.address.TransportAddressBuilder)

Example 18 with AddMapping

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.AddMapping in project lispflowmapping by opendaylight.

the class LispSouthboundHandlerTest method mapRegister__Ipv6Rloc.

@Test
public void mapRegister__Ipv6Rloc() throws Exception {
    // P bit (Proxy-Map-Reply): Set
    // M bit (Want-Map-Notify): Set
    // Record Counter: 1
    // Nonce: 0
    // Key ID: 1
    // AuthLength: 20
    // Authentication Data: 5bc4d44a57e2a55d577a6f89779c004f5da713fb
    // EID prefix: 2610:d0:ffff:192::1/128, TTL: 10, Authoritative,
    // No-Action
    // Local RLOC: 10.0.58.156, Reachable, Priority/Weight: 1/100, Multicast
    // Priority/Weight: 255/0
    mapRegisterPacket = extractWSUdpByteArray("0000   00 0c 29 34 3e 1b 00 0c 29 f6 d6 0d 08 00 45 00 " + "0010   00 68 00 00 40 00 40 11 ea c3 0a 00 3a 9c 0a 00 " + "0020   01 26 10 f6 10 f6 00 54 f5 9a 38 00 03 01 00 00 " + "0030   00 00 00 00 00 00 00 01 00 14 22 97 ff 61 ec d8 " + "0040   0f 91 c6 c4 01 ef 7f bb 77 58 39 5c 92 23 00 00 " + "0050   00 0a 01 80 10 00 00 00 00 02 26 10 00 d0 ff ff " + "0060   01 92 00 00 00 00 00 00 00 01 01 64 ff 00 00 05 " + "0070   00 01 0a 00 3a 9c");
    ArgumentCaptor<AddMapping> captor = ArgumentCaptor.forClass(AddMapping.class);
    handleMapRegisterPacket(mapRegisterPacket);
    Mockito.verify(mockLispSouthboundPlugin).sendNotificationIfPossible(captor.capture());
    MappingRecord eidToLocatorRecord = captor.getValue().getMapRegister().getMappingRecordItem().get(0).getMappingRecord();
    assertEquals(LispAddressUtil.asIpv6PrefixBinaryEid("2610:d0:ffff:192:0:0:0:1/128"), eidToLocatorRecord.getEid());
    assertEquals(Ipv6PrefixBinaryAfi.class, eidToLocatorRecord.getEid().getAddressType());
    assertEquals(LispAddressUtil.asIpv4Rloc("10.0.58.156"), eidToLocatorRecord.getLocatorRecord().get(0).getRloc());
}
Also used : AddMapping(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.AddMapping) MappingRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord) Test(org.junit.Test)

Example 19 with AddMapping

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.AddMapping in project lispflowmapping by opendaylight.

the class LispSouthboundHandlerTest method mapRegister__VerifyBasicFields.

@Test
public void mapRegister__VerifyBasicFields() throws Exception {
    ArgumentCaptor<AddMapping> captor = ArgumentCaptor.forClass(AddMapping.class);
    handleMapRegisterPacket(mapRegisterPacket);
    Mockito.verify(mockLispSouthboundPlugin).sendNotificationIfPossible(captor.capture());
    MappingRecord eidToLocator = captor.getValue().getMapRegister().getMappingRecordItem().get(0).getMappingRecord();
    assertEquals(LispAddressUtil.asIpv4PrefixBinaryEid("153.16.254.1/32"), eidToLocator.getEid());
    assertEquals(1, eidToLocator.getLocatorRecord().size());
    assertEquals(LispAddressUtil.asIpv4Rloc("192.168.136.10"), eidToLocator.getLocatorRecord().get(0).getRloc());
}
Also used : AddMapping(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.AddMapping) MappingRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord) Test(org.junit.Test)

Example 20 with AddMapping

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.AddMapping in project lispflowmapping by opendaylight.

the class SimpleMapCache method addMapping.

@Override
public void addMapping(Eid key, XtrId xtrId, Object value) {
    Eid eid = MaskUtil.normalize(key);
    ILispDAO table = getOrInstantiateVniTable(key);
    ILispDAO xtrIdDao = getOrInstantiateXtrIdTable(eid, table);
    xtrIdDao.put(xtrId, new MappingEntry<>(SubKeys.RECORD, value));
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) ILispDAO(org.opendaylight.lispflowmapping.interfaces.dao.ILispDAO)

Aggregations

Test (org.junit.Test)21 MappingData (org.opendaylight.lispflowmapping.lisp.type.MappingData)8 AddMapping (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.AddMapping)8 MappingRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord)7 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)7 AddMappingInput (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.AddMappingInput)6 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)5 Mapping (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.Mapping)4 Ignore (org.junit.Ignore)3 DataTreeModification (org.opendaylight.controller.md.sal.binding.api.DataTreeModification)3 ILispDAO (org.opendaylight.lispflowmapping.interfaces.dao.ILispDAO)3 MappingChanged (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingChanged)3 MappingBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.MappingBuilder)3 GotMapNotify (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapNotify)2 MapNotify (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapNotify)2 MapRegisterCacheKey (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.map.register.cache.key.container.MapRegisterCacheKey)2 MapNotifyBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapnotifymessage.MapNotifyBuilder)2 MappingRecordBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder)2 MappingRecordItem (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem)2 MappingRecordItemBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder)2