Search in sources :

Example 16 with LocatorRecord

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

the class MappingDataListener method convertToBinaryIfNecessary.

private static Mapping convertToBinaryIfNecessary(Mapping mapping) {
    MappingRecord originalRecord = mapping.getMappingRecord();
    List<LocatorRecord> originalLocators = originalRecord.getLocatorRecord();
    List<LocatorRecord> convertedLocators = null;
    if (originalLocators != null) {
        // If convertedLocators is non-null, while originalLocators is also non-null, conversion has been made
        convertedLocators = convertToBinaryIfNecessary(originalLocators);
    }
    if (LispAddressUtil.addressNeedsConversionToBinary(originalRecord.getEid().getAddress()) || (originalLocators != null && convertedLocators != null)) {
        MappingRecordBuilder mrb = new MappingRecordBuilder(originalRecord);
        mrb.setEid(LispAddressUtil.convertToBinary(originalRecord.getEid()));
        if (convertedLocators != null) {
            mrb.setLocatorRecord(convertedLocators);
        }
        return new MappingBuilder(mapping).setMappingRecord(mrb.build()).build();
    }
    return mapping;
}
Also used : MappingBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.MappingBuilder) MappingRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord) MappingRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder) LocatorRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord)

Example 17 with LocatorRecord

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

the class MultiSiteScenario method verifyIpv4Address.

private Ipv4AddressBinary verifyIpv4Address(final LocatorRecord locatorRecord) {
    assertNotNull(locatorRecord);
    final Rloc rloc = locatorRecord.getRloc();
    assertNotNull(rloc);
    final Address address = rloc.getAddress();
    assertTrue(address instanceof Ipv4Binary);
    return ((Ipv4Binary) address).getIpv4Binary();
}
Also used : Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address) MappingServiceIntegrationTest.ourAddress(org.opendaylight.lispflowmapping.integrationtest.MappingServiceIntegrationTest.ourAddress) Rloc(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.Rloc) Ipv4Binary(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv4Binary)

Example 18 with LocatorRecord

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

the class MultiSiteScenario method prepareMappingRecord.

private MappingRecordBuilder prepareMappingRecord(final EidType eidType, final Site srcSite, final Site... dstSites) {
    assertTrue(isEidEquals(dstSites));
    final MappingRecordBuilder mrb = prepareMappingRecordGeneral(eidType, srcSite, dstSites[0]);
    final List<LocatorRecord> locatorRecords = new ArrayList<>();
    if (!dstSites[0].isForDeletion) {
        for (Site dstSite : dstSites) {
            if (dstSite.getRloc() != null) {
                locatorRecords.add(provideLocatorRecord(LispAddressUtil.asIpv4Rloc(dstSite.getRloc()), dstSite.getRloc(), dstSite.getWeight(), dstSite.getPriority()));
            }
        }
    }
    mrb.setLocatorRecord(locatorRecords);
    return mrb;
}
Also used : Site(org.opendaylight.lispflowmapping.integrationtest.MultiSiteScenarioUtil.Site) MappingRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder) ArrayList(java.util.ArrayList) LocatorRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord)

Example 19 with LocatorRecord

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

the class LispSouthboundHandlerTest method before.

@Override
@Before
public void before() throws Exception {
    super.before();
    mockLispSouthboundPlugin = Mockito.mock(LispSouthboundPlugin.class);
    contextMockLispSouthboundPlugin = context.mock(LispSouthboundPlugin.class);
    Mockito.when(mockLispSouthboundPlugin.isMapRegisterCacheEnabled()).thenReturn(true);
    Mockito.when(mockLispSouthboundPlugin.getMapRegisterCacheTimeout()).thenReturn(CACHE_RECORD_TIMEOUT);
    mapRegisterCache = new MapRegisterCache();
    Mockito.when(mockLispSouthboundPlugin.getMapRegisterCache()).thenReturn(mapRegisterCache);
    Mockito.when(mockLispSouthboundPlugin.getDataBroker()).thenReturn(Mockito.mock(DataBroker.class));
    Mockito.when(mockLispSouthboundPlugin.getAkdb()).thenReturn(akdb);
    Mockito.when(mockLispSouthboundPlugin.getAuthenticationKeyDataListener()).thenReturn(akdl);
    ConcurrentLispSouthboundStats lispSouthboundStats = new ConcurrentLispSouthboundStats();
    Mockito.when(mockLispSouthboundPlugin.getStats()).thenReturn(lispSouthboundStats);
    testedLispService = new LispSouthboundHandler(mockLispSouthboundPlugin);
    // SRC: 127.0.0.1:58560 to 127.0.0.1:4342
    // LISP(Type = 8 - Encapsulated)
    // IP: 192.168.136.10 -> 1.2.3.4
    // UDP: 56756
    // LISP(Type = 1 Map-Request
    // Record Count: 1
    // ITR-RLOC count: 0
    // Source EID AFI: 0
    // Source EID not present
    // Nonce: 0x3d8d2acd39c8d608
    // ITR-RLOC AFI=1 Address=192.168.136.10
    // Record 1: 1.2.3.4/32
    mapRequestPacket = extractWSUdpByteArray("0000   00 00 00 00 00 00 00 00 00 00 00 00 08 00 45 00 " + "0010   00 58 00 00 40 00 40 11 3c 93 7f 00 00 01 7f 00 " + "0020   00 01 e4 c0 10 f6 00 44 fe 57 80 00 00 00 45 00 " + "0030   00 38 d4 31 00 00 ff 11 56 f3 c0 a8 88 0a 01 02 " + "0040   03 04 dd b4 10 f6 00 24 ef 3a 10 00 00 01 3d 8d " + "0050   2a cd 39 c8 d6 08 00 01 01 02 03 04 00 01 c0 a8 88 0a 00 20 " + "0060   00 01 01 02 03 04");
    mapReplyBuilder = new MapReplyBuilder();
    mapReplyBuilder.setMappingRecordItem(new ArrayList<MappingRecordItem>());
    mapReplyBuilder.setNonce((long) 0);
    mapReplyBuilder.setEchoNonceEnabled(false);
    mapReplyBuilder.setProbe(true);
    mapReplyBuilder.setSecurityEnabled(true);
    mappingRecordBuilder = new MappingRecordBuilder();
    String ip = "0.0.0.0";
    mappingRecordBuilder.setEid(LispAddressUtil.asIpv4PrefixEid(ip + "/0"));
    mappingRecordBuilder.setLocatorRecord(new ArrayList<LocatorRecord>());
    mappingRecordBuilder.setRecordTtl(10);
    mappingRecordBuilder.setMapVersion((short) 0);
    mappingRecordBuilder.setAction(Action.NativelyForward);
    mappingRecordBuilder.setAuthoritative(false);
    // eidToLocatorBuilder.setPrefix(new LispIpv4Address(0));
    // mapReply.addEidToLocator(eidToLocatorBuilder);
    // IP: 192.168.136.10 -> 128.223.156.35
    // UDP: 49289 -> 4342
    // LISP(Type = 3 Map-Register, P=1, M=1
    // Record Counter: 1
    // Nonce: 0
    // Key ID: 0x0001
    // AuthDataLength: 20 Data:
    // e8:f5:0b:c5:c5:f2:b0:21:27:a8:21:41:04:f3:46:5a:a5:68:89:ec
    // EID prefix: 153.16.254.1/32 (EID=0x9910FE01), TTL: 10, Authoritative,
    // No-Action
    // Local RLOC: 192.168.136.10 (RLOC=0xC0A8880A), Reachable,
    // Priority/Weight: 1/100, Multicast Priority/Weight:
    // 255/0
    // 
    mapRegisterPacket = extractWSUdpByteArray("0000   00 50 56 ee d1 4f 00 0c 29 7a ce 79 08 00 45 00 " + "0010   00 5c 00 00 40 00 40 11 d4 db c0 a8 88 0a 80 df " + "0020   9c 23 d6 40 10 f6 00 48 59 a4 38 00 01 01 00 00 " + "0030   00 00 00 00 00 00 00 01 00 14 0e a4 c6 d8 a4 06 " + "0040   71 7c 33 a4 5c 4a 83 1c de 74 53 03 0c ad 00 00 " + "0050   00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 " + "0060   ff 00 00 05 00 01 c0 a8 88 0a");
    mapNotifyBuilder = new MapNotifyBuilder();
    mapNotifyBuilder.setAuthenticationData(new byte[0]);
}
Also used : MappingRecordItem(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem) MappingRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder) MapReplyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapreplymessage.MapReplyBuilder) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) LocatorRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord) LispSouthboundPlugin(org.opendaylight.lispflowmapping.southbound.LispSouthboundPlugin) ConcurrentLispSouthboundStats(org.opendaylight.lispflowmapping.southbound.ConcurrentLispSouthboundStats) MapNotifyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapnotifymessage.MapNotifyBuilder) MapRegisterCache(org.opendaylight.lispflowmapping.southbound.lisp.cache.MapRegisterCache) Before(org.junit.Before)

Example 20 with LocatorRecord

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

the class MappingServiceIntegrationTest method runPrefixTest.

private void runPrefixTest(Eid registerEID, Eid matchedAddress, Eid unMatchedAddress) throws SocketTimeoutException {
    mapService.addAuthenticationKey(registerEID, NULL_AUTH_KEY);
    sleepForSeconds(1);
    MapRegisterBuilder mapRegister = new MapRegisterBuilder();
    mapRegister.setWantMapNotify(true);
    mapRegister.setNonce((long) 8);
    mapRegister.setWantMapNotify(true);
    mapRegister.setKeyId((short) 0);
    mapRegister.setAuthenticationData(new byte[0]);
    mapRegister.setNonce((long) 8);
    mapRegister.setProxyMapReply(false);
    MappingRecordBuilder etlr = new MappingRecordBuilder();
    etlr.setRecordTtl(254);
    etlr.setAction(Action.NoAction);
    etlr.setAuthoritative(false);
    etlr.setMapVersion((short) 0);
    etlr.setEid(registerEID);
    etlr.setRecordTtl(254);
    LocatorRecordBuilder record = new LocatorRecordBuilder();
    record.setRloc(LispAddressUtil.asIpv4Rloc("4.3.2.1"));
    record.setLocalLocator(false);
    record.setRlocProbed(false);
    record.setRouted(true);
    record.setMulticastPriority((short) 0);
    record.setMulticastWeight((short) 0);
    record.setPriority((short) 0);
    record.setWeight((short) 0);
    etlr.setLocatorRecord(new ArrayList<LocatorRecord>());
    etlr.getLocatorRecord().add(record.build());
    mapRegister.setMappingRecordItem(new ArrayList<MappingRecordItem>());
    mapRegister.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(etlr.build()).build());
    sendMapRegister(mapRegister.build());
    MapNotify mapNotify = receiveMapNotify();
    assertEquals(8, mapNotify.getNonce().longValue());
    sleepForSeconds(1);
    MapRequestBuilder mapRequest = new MapRequestBuilder();
    mapRequest.setNonce((long) 4);
    mapRequest.setSourceEid(new SourceEidBuilder().setEid(LispAddressUtil.asIpv4Eid(ourAddress)).build());
    mapRequest.setEidItem(new ArrayList<EidItem>());
    mapRequest.setAuthoritative(false);
    mapRequest.setMapDataPresent(false);
    mapRequest.setPitr(false);
    mapRequest.setProbe(false);
    mapRequest.setSmr(false);
    mapRequest.setSmrInvoked(false);
    mapRequest.getEidItem().add(new EidItemBuilder().setEid(matchedAddress).build());
    mapRequest.setItrRloc(new ArrayList<ItrRloc>());
    mapRequest.getItrRloc().add(new ItrRlocBuilder().setRloc(LispAddressUtil.asIpv4Rloc(ourAddress)).build());
    sendMapRequest(mapRequest.build());
    MapReply mapReply = receiveMapReply();
    assertEquals(4, mapReply.getNonce().longValue());
    assertEquals(record.getRloc(), mapReply.getMappingRecordItem().get(0).getMappingRecord().getLocatorRecord().get(0).getRloc());
    mapRequest.setEidItem(new ArrayList<EidItem>());
    mapRequest.getEidItem().add(new EidItemBuilder().setEid(unMatchedAddress).build());
    sendMapRequest(mapRequest.build());
    mapReply = receiveMapReply();
    assertEquals(0, mapReply.getMappingRecordItem().get(0).getMappingRecord().getLocatorRecord().size());
}
Also used : LocatorRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecordBuilder) MappingRecordItemBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder) MappingRecordItem(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem) MapReply(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply) GotMapReply(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapReply) MappingRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder) 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) MapRequestBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestnotification.MapRequestBuilder) EidItemBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.list.EidItemBuilder) EidItem(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.list.EidItem) MapRegisterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapregisternotification.MapRegisterBuilder) LocatorRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord) ItrRloc(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRloc) ItrRlocBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRlocBuilder) SourceEidBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.SourceEidBuilder)

Aggregations

LocatorRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord)28 MappingRecordBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder)16 LocatorRecordBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecordBuilder)13 Test (org.junit.Test)9 Rloc (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.Rloc)9 MappingRecordItem (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem)8 ArrayList (java.util.ArrayList)5 MappingRecordItemBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder)5 ByteBuffer (java.nio.ByteBuffer)4 MapRegister (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRegister)4 SimpleAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress)3 MapNotify (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapNotify)3 MapRegisterBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapregisternotification.MapRegisterBuilder)3 ItrRloc (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRloc)3 MapRequestBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestnotification.MapRequestBuilder)3 LinkedHashMap (java.util.LinkedHashMap)2 Site (org.opendaylight.lispflowmapping.integrationtest.MultiSiteScenarioUtil.Site)2 MappingData (org.opendaylight.lispflowmapping.lisp.type.MappingData)2 ExplicitLocatorPath (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.ExplicitLocatorPath)2 GotMapNotify (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapNotify)2