Search in sources :

Example 11 with EidItem

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

the class MultiSiteScenario method emitMapRequestMessage.

private MapReply emitMapRequestMessage(final String siteFromEidPrefix, final String siteToEidPrefix, final InstanceIdType vniValue) {
    final MapRequestBuilder mapRequestBuilder = new MapRequestBuilder();
    final EidItemBuilder eidItemBuilder = new EidItemBuilder();
    Eid dstEid = toEid(siteToEidPrefix, vniValue, IP_MASK);
    eidItemBuilder.setEid(dstEid);
    eidItemBuilder.setEidItemId(siteFromEidPrefix + siteToEidPrefix);
    final List<EidItem> eidItem = Collections.singletonList(eidItemBuilder.build());
    final Eid srcEid = MappingServiceIntegrationTestUtil.removePrefixIfNecessary(toEid(siteFromEidPrefix, vniValue, IP_MASK));
    mapRequestBuilder.setSourceEid(new SourceEidBuilder().setEid(srcEid).build());
    mapRequestBuilder.setEidItem(eidItem);
    mapRequestBuilder.setItrRloc(MappingServiceIntegrationTestUtil.getDefaultItrRlocList(LispAddressUtil.asIpv4Rloc(ourAddress)));
    mapRequestBuilder.setSmrInvoked(false);
    return lms.handleMapRequest(mapRequestBuilder.build());
}
Also used : SourceEid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.SourceEid) Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) SourceEidBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.SourceEidBuilder) 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)

Example 12 with EidItem

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

the class MapRequestSerializationTest method serialize__SingleEidItem.

@Test
public void serialize__SingleEidItem() throws Exception {
    MapRequestBuilder mrBuilder = new MapRequestBuilder();
    mrBuilder.setEidItem(new ArrayList<EidItem>());
    mrBuilder.getEidItem().add(new EidItemBuilder().setEid(LispAddressUtil.asIpv4PrefixEid("1.2.3.4/32")).build());
    ByteBuffer expected = hexToByteBuffer(// 
    "10 00 00 01 00 00 " + "00 00 00 00 00 00 00 00 00 20 00 01 01 02 03 04");
    assertArrayEquals(expected.array(), MapRequestSerializer.getInstance().serialize(mrBuilder.build()).array());
}
Also used : 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) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 13 with EidItem

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

the class MapRequestSerializationTest method serialize__All.

@Test
public void serialize__All() throws Exception {
    MapRequestBuilder mrBuilder = new MapRequestBuilder();
    mrBuilder.setProbe(true);
    mrBuilder.setPitr(true);
    mrBuilder.setNonce((long) 13);
    mrBuilder.setSourceEid(new SourceEidBuilder().setEid(LispAddressUtil.asIpv4Eid(("10.0.0.1"))).build());
    mrBuilder.setItrRloc(new ArrayList<ItrRloc>());
    mrBuilder.getItrRloc().add(new ItrRlocBuilder().setRloc(LispAddressUtil.asIpv4Rloc("1.2.3.4")).build());
    mrBuilder.getItrRloc().add(new ItrRlocBuilder().setRloc(LispAddressUtil.asIpv6Rloc("1:2:3:4:5:6:7:8")).build());
    mrBuilder.setEidItem(new ArrayList<EidItem>());
    mrBuilder.getEidItem().add(new EidItemBuilder().setEid(LispAddressUtil.asIpv4PrefixEid("1.2.3.4/32")).build());
    ByteBuffer expected = hexToByteBuffer(// 
    "12 80 01 01 00 00 " + "00 00 00 00 00 0D 00 01 0a 00 00 01 00 01 01 02 03 04 00 02 00 01 00 02 00 03 00 04 00 05 00 06 " + "00 07 00 08 00 20 00 01 01 02 03 04");
    assertArrayEquals(expected.array(), MapRequestSerializer.getInstance().serialize(mrBuilder.build()).array());
}
Also used : 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) 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) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 14 with EidItem

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

the class MapRequestSerializationTest method serialize__AllWithMapReply.

@Test
public void serialize__AllWithMapReply() throws Exception {
    MapRequestBuilder mapRequestBuilder = new MapRequestBuilder();
    mapRequestBuilder.setProbe(true);
    mapRequestBuilder.setMapDataPresent(true);
    mapRequestBuilder.setPitr(true);
    mapRequestBuilder.setNonce((long) 13);
    mapRequestBuilder.setSourceEid(new SourceEidBuilder().setEid(LispAddressUtil.asIpv4Eid(("10.0.0.1"))).build());
    mapRequestBuilder.setItrRloc(new ArrayList<ItrRloc>());
    mapRequestBuilder.getItrRloc().add(new ItrRlocBuilder().setRloc(LispAddressUtil.asIpv4Rloc("1.2.3.4")).build());
    mapRequestBuilder.getItrRloc().add(new ItrRlocBuilder().setRloc(LispAddressUtil.asIpv6Rloc("1:2:3:4:5:6:7:8")).build());
    mapRequestBuilder.setEidItem(new ArrayList<EidItem>());
    mapRequestBuilder.getEidItem().add(new EidItemBuilder().setEid(LispAddressUtil.asIpv4PrefixEid("1.2.3.4/32")).build());
    MappingRecordBuilder recordBuilder = new MappingRecordBuilder();
    recordBuilder.setEid(LispAddressUtil.asIpv4PrefixEid("0.0.0.1/0"));
    recordBuilder.setLocatorRecord(new ArrayList<LocatorRecord>());
    LocatorRecordBuilder locatorBuilder = new LocatorRecordBuilder();
    locatorBuilder.setRloc(LispAddressUtil.asIpv4Rloc("0.0.0.2"));
    recordBuilder.getLocatorRecord().add(locatorBuilder.build());
    MapReplyBuilder mapreplyBuilder = new MapReplyBuilder();
    mapreplyBuilder.setMappingRecord(recordBuilder.build());
    mapRequestBuilder.setMapReply(mapreplyBuilder.build());
    ByteBuffer expected = hexToByteBuffer("16 80 01 01 00 00 " + "00 00 00 00 00 0D 00 01 0a 00 00 01 00 01 01 02 03 04 00 02 00 01 00 02 00 03 00 04 00 05 00 06 " + // map
    "00 07 00 08 00 20 00 01 01 02 03 04 " + "00 00 00 00 01 00 00 00 00 00 00 01 00 00 00 01 00 00 00 00 00 00 00 01 00 00 00 02");
    assertArrayEquals(expected.array(), MapRequestSerializer.getInstance().serialize(mapRequestBuilder.build()).array());
}
Also used : LocatorRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecordBuilder) 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.maprequest.MapReplyBuilder) 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) ByteBuffer(java.nio.ByteBuffer) 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) Test(org.junit.Test)

Example 15 with EidItem

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

the class MapResolver method handleMapRequest.

public void handleMapRequest(MapRequest request) {
    LOG.trace("Map-Request received: {}", request);
    // SMRs and RLOC probes are directed towards xTRs and we're a Map-Resolver here, so ignore them
    if (request.isSmr() != null && request.isSmr()) {
        LOG.debug("Map-Resolver ignoring incoming SMR control message.");
        return;
    }
    if (request.isProbe() != null && request.isProbe()) {
        LOG.debug("Map-Resolver ignoring incoming RLOC probe control message.");
        return;
    }
    if (request.isSmrInvoked()) {
        LOG.debug("SMR-invoked request received.");
        LOG.trace("Map-Request object: {}", request);
        for (EidItem eidItem : request.getEidItem()) {
            final SmrEvent event = new SmrEvent(subscriberListFromItrRlocs(request.getItrRloc(), request.getSourceEid().getEid()), eidItem.getEid(), request.getNonce());
            smrNotificationListener.onSmrInvokedReceived(event);
        }
    }
    Eid srcEid = null;
    if (request.getSourceEid() != null) {
        srcEid = request.getSourceEid().getEid();
    }
    MapReplyBuilder replyBuilder = new MapReplyBuilder();
    replyBuilder.setEchoNonceEnabled(false);
    replyBuilder.setProbe(false);
    replyBuilder.setSecurityEnabled(false);
    replyBuilder.setNonce(request.getNonce());
    replyBuilder.setMappingRecordItem(new ArrayList<>());
    List<ItrRloc> itrRlocs = request.getItrRloc();
    final IpAddressBinary sourceRloc = request.getSourceRloc();
    for (EidItem eidRecord : request.getEidItem()) {
        MappingData mappingData = mapService.getMapping(srcEid, eidRecord.getEid());
        MappingRecord mapping;
        if (mappingData == null) {
            mapping = mapService.addNegativeMapping(eidRecord.getEid()).getRecord();
        } else {
            mapping = mappingData.getRecord();
        }
        if (itrRlocs != null && itrRlocs.size() != 0) {
            if (subscriptionService && isValidSourceEidForSubscriber(srcEid)) {
                final Rloc resolvedRloc = resolveRloc(itrRlocs, sourceRloc);
                updateSubscribers(resolvedRloc, eidRecord.getEid(), mapping.getEid(), srcEid, mapping.getRecordTtl());
            }
            mapping = updateLocators(mapping, itrRlocs);
        }
        mapping = fixIfNotSDRequest(mapping, eidRecord.getEid());
        mapping = fixTtlIfSmrInvoked(request, mapping);
        replyBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(mapping).build());
    }
    requestHandler.handleMapReply(replyBuilder.build());
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) MappingRecordItemBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder) ItrRloc(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRloc) IpAddressBinary(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.inet.binary.types.rev160303.IpAddressBinary) SmrEvent(org.opendaylight.lispflowmapping.interfaces.lisp.SmrEvent) MappingRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord) Rloc(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.Rloc) ItrRloc(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRloc) MappingData(org.opendaylight.lispflowmapping.lisp.type.MappingData) MapReplyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapreplymessage.MapReplyBuilder) EidItem(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.list.EidItem)

Aggregations

EidItem (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.list.EidItem)15 EidItemBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.list.EidItemBuilder)11 MapRequestBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestnotification.MapRequestBuilder)11 ItrRloc (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRloc)8 SourceEidBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.SourceEidBuilder)8 Test (org.junit.Test)6 ItrRlocBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRlocBuilder)6 ByteBuffer (java.nio.ByteBuffer)5 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)5 LocatorRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord)2 LocatorRecordBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecordBuilder)2 MappingRecordBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder)2 MappingRecordItemBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder)2 SourceEid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.SourceEid)2 SmrEvent (org.opendaylight.lispflowmapping.interfaces.lisp.SmrEvent)1 LispAddressSerializerContext (org.opendaylight.lispflowmapping.lisp.serializer.address.LispAddressSerializerContext)1 LispSerializationException (org.opendaylight.lispflowmapping.lisp.serializer.exception.LispSerializationException)1 MappingData (org.opendaylight.lispflowmapping.lisp.type.MappingData)1 IpAddressBinary (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.inet.binary.types.rev160303.IpAddressBinary)1 Ipv4AddressBinary (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.inet.binary.types.rev160303.Ipv4AddressBinary)1