Search in sources :

Example 1 with SmrEvent

use of org.opendaylight.lispflowmapping.interfaces.lisp.SmrEvent 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

SmrEvent (org.opendaylight.lispflowmapping.interfaces.lisp.SmrEvent)1 MappingData (org.opendaylight.lispflowmapping.lisp.type.MappingData)1 IpAddressBinary (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.inet.binary.types.rev160303.IpAddressBinary)1 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)1 EidItem (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.list.EidItem)1 MappingRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord)1 MappingRecordItemBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder)1 MapReplyBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapreplymessage.MapReplyBuilder)1 ItrRloc (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRloc)1 Rloc (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.Rloc)1