Search in sources :

Example 11 with IpAddressBinary

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.inet.binary.types.rev160303.IpAddressBinary in project lispflowmapping by opendaylight.

the class MapResolver method resolveRloc.

private Rloc resolveRloc(List<ItrRloc> itrRlocList, IpAddressBinary srcRloc) {
    if (srcRloc == null) {
        return itrRlocList.get(0).getRloc();
    }
    byte[] srcRlocByte;
    if (srcRloc.getIpv4AddressBinary() != null) {
        srcRlocByte = srcRloc.getIpv4AddressBinary().getValue();
    } else {
        srcRlocByte = srcRloc.getIpv6AddressBinary().getValue();
    }
    Rloc equalIpvRloc = null;
    for (ItrRloc itrRloc : itrRlocList) {
        final Rloc rloc = itrRloc.getRloc();
        final byte[] itrRlocByte = LispAddressUtil.ipAddressToByteArray(rloc.getAddress());
        // return an Rloc equal to the source Rloc
        if (itrRlocByte != null && LispAddressUtil.compareIpAddressByteArrays(srcRlocByte, itrRlocByte) == 0) {
            return rloc;
        }
        // else lookup the first Rloc with identical Ip version
        if (equalIpvRloc == null && isEqualIpVersion(srcRloc, rloc)) {
            equalIpvRloc = rloc;
        }
    }
    if (equalIpvRloc != null) {
        return equalIpvRloc;
    } else {
        // if none of the above, return the first Rloc
        return itrRlocList.get(0).getRloc();
    }
}
Also used : ItrRloc(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRloc) 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)

Example 12 with IpAddressBinary

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.inet.binary.types.rev160303.IpAddressBinary in project lispflowmapping by opendaylight.

the class LispAddressUtilTest method addressBinaryFromInet_Inet4Address.

/**
 * Tests {@link LispAddressUtil#addressBinaryFromInet(InetAddress)} method with Inet4Address.
 */
@Test
public void addressBinaryFromInet_Inet4Address() throws UnknownHostException {
    final InetAddress inet4Address = InetAddress.getByName(IPV4_ADDRESS_VALUE_TEST);
    assertEquals(new IpAddressBinary(IPV4_ADDRESS_BINARY_TEST), LispAddressUtil.addressBinaryFromInet(inet4Address));
}
Also used : IpAddressBinary(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.inet.binary.types.rev160303.IpAddressBinary) InetAddress(java.net.InetAddress) Test(org.junit.Test)

Example 13 with IpAddressBinary

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.inet.binary.types.rev160303.IpAddressBinary in project lispflowmapping by opendaylight.

the class LispSouthboundPlugin method getInetAddress.

private InetAddress getInetAddress(TransportAddress address) {
    Preconditions.checkNotNull(address, "TransportAddress must not be null");
    IpAddressBinary ip = address.getIpAddress();
    try {
        if (ip.getIpv4AddressBinary() != null) {
            return InetAddress.getByAddress(ip.getIpv4AddressBinary().getValue());
        } else if (ip.getIpv6AddressBinary() != null) {
            return InetAddress.getByAddress(ip.getIpv6AddressBinary().getValue());
        }
    } catch (UnknownHostException e) {
        LOG.debug("Could not convert TransportAddress {} to InetAddress", address, e);
    }
    return null;
}
Also used : UnknownHostException(java.net.UnknownHostException) IpAddressBinary(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.inet.binary.types.rev160303.IpAddressBinary)

Example 14 with IpAddressBinary

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.inet.binary.types.rev160303.IpAddressBinary in project lispflowmapping by opendaylight.

the class MappingSystem method handleMergedMapping.

private MappingData handleMergedMapping(Eid key) {
    LOG.trace("Merging mappings for EID {}", LispAddressStringifier.getString(key));
    List<MappingData> expiredMappingDataList = new ArrayList<>();
    Set<IpAddressBinary> sourceRlocs = new HashSet<>();
    MappingData mergedMappingData = MappingMergeUtil.mergeXtrIdMappings(smc.getAllXtrIdMappings(key), expiredMappingDataList, sourceRlocs);
    for (MappingData mappingData : expiredMappingDataList) {
        removeSbXtrIdSpecificMapping(key, mappingData.getXtrId(), mappingData);
    }
    if (mergedMappingData != null) {
        smc.addMapping(key, mergedMappingData, sourceRlocs);
        dsbe.addMapping(DSBEInputUtil.toMapping(MappingOrigin.Southbound, key, mergedMappingData));
        addOrRefreshMappingInTimeoutService(key, mergedMappingData);
    } else {
        removeSbMapping(key, mergedMappingData);
    }
    return mergedMappingData;
}
Also used : IpAddressBinary(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.inet.binary.types.rev160303.IpAddressBinary) ArrayList(java.util.ArrayList) MappingData(org.opendaylight.lispflowmapping.lisp.type.MappingData) HashSet(java.util.HashSet)

Example 15 with IpAddressBinary

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.inet.binary.types.rev160303.IpAddressBinary 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

IpAddressBinary (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.inet.binary.types.rev160303.IpAddressBinary)16 TransportAddress (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transport.address.TransportAddress)11 Test (org.junit.Test)10 PortNumber (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber)10 TransportAddressBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transport.address.TransportAddressBuilder)10 MappingData (org.opendaylight.lispflowmapping.lisp.type.MappingData)4 InetAddress (java.net.InetAddress)3 ArrayList (java.util.ArrayList)3 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)3 MappingRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord)3 HashSet (java.util.HashSet)2 MappingRecordItemBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder)2 ItrRloc (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRloc)2 Rloc (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.Rloc)2 UnknownHostException (java.net.UnknownHostException)1 Date (java.util.Date)1 Iterator (java.util.Iterator)1 Set (java.util.Set)1 ILispDAO (org.opendaylight.lispflowmapping.interfaces.dao.ILispDAO)1 SmrEvent (org.opendaylight.lispflowmapping.interfaces.lisp.SmrEvent)1