Search in sources :

Example 1 with LispMapRecord

use of org.onosproject.lisp.msg.protocols.LispMapRecord in project onos by opennetworkinglab.

the class LispExpireMapDatabase method getMapRecordByEidRecords.

@Override
public List<LispMapRecord> getMapRecordByEidRecords(List<LispEidRecord> eids, boolean proxyMapReply) {
    List<LispMapRecord> mapRecords = Lists.newArrayList();
    eids.forEach(eidRecord -> {
        LispMapRecord mapRecord = getMapRecordByEidRecord(eidRecord, proxyMapReply);
        if (mapRecord != null) {
            mapRecords.add(mapRecord);
        }
    });
    return ImmutableList.copyOf(mapRecords);
}
Also used : LispMapRecord(org.onosproject.lisp.msg.protocols.LispMapRecord)

Example 2 with LispMapRecord

use of org.onosproject.lisp.msg.protocols.LispMapRecord in project onos by opennetworkinglab.

the class LispMappingDatabaseTest method test12MaskRange.

@Test
public void test12MaskRange() {
    byte cidr32 = (byte) 32;
    LispIpv4Address eid = new LispIpv4Address(IpAddress.valueOf(EID_IP_PREFIX_1_32));
    LispEidRecord record32 = new LispEidRecord(cidr32, eid);
    LispMapRecord mapRecordExpireMap32 = expireMapDb.getMapRecordByEidRecord(record32, true);
    LispMapRecord mapRecordRadixTree32 = radixTreeDb.getMapRecordByEidRecord(record32, true);
    byte cidr24 = (byte) 24;
    LispIpv4Address eid24 = new LispIpv4Address(IpAddress.valueOf(EID_IP_PREFIX_1_24));
    LispEidRecord record24 = new LispEidRecord(cidr24, eid24);
    LispMapRecord mapRecordExpireMap24 = expireMapDb.getMapRecordByEidRecord(record24, true);
    LispMapRecord mapRecordRadixTree24 = radixTreeDb.getMapRecordByEidRecord(record32, true);
    byte cidr16 = (byte) 16;
    LispIpv4Address eid16 = new LispIpv4Address(IpAddress.valueOf(EID_IP_PREFIX_1_16));
    LispEidRecord record16 = new LispEidRecord(cidr16, eid16);
    LispMapRecord mapRecordExpireMap16 = expireMapDb.getMapRecordByEidRecord(record16, true);
    LispMapRecord mapRecordRadixTree16 = radixTreeDb.getMapRecordByEidRecord(record16, true);
    byte cidr12 = (byte) 12;
    LispIpv4Address eid12 = new LispIpv4Address(IpAddress.valueOf(EID_IP_PREFIX_1_12));
    LispEidRecord record12 = new LispEidRecord(cidr12, eid12);
    LispMapRecord mapRecordExpireMap12 = expireMapDb.getMapRecordByEidRecord(record12, true);
    LispMapRecord mapRecordRadixTree12 = radixTreeDb.getMapRecordByEidRecord(record12, true);
    assertThat("Failed to fetch the RLOCs with /32 EID record", mapRecordExpireMap32.getLocatorCount(), is(2));
    assertThat("Failed to fetch the RLOCs with /24 EID record", mapRecordExpireMap24.getLocatorCount(), is(2));
    assertThat("Failed to fetch the RLOCs with /16 EID record", mapRecordExpireMap16.getLocatorCount(), is(2));
    assertThat("Failed to fetch the RLOCs with /12 EID record", mapRecordExpireMap12.getLocatorCount(), is(1));
    assertThat("Failed to fetch the RLOCs with /32 EID record", mapRecordRadixTree32.getLocatorCount(), is(2));
    assertThat("Failed to fetch the RLOCs with /24 EID record", mapRecordRadixTree24.getLocatorCount(), is(2));
    assertThat("Failed to fetch the RLOCs with /16 EID record", mapRecordRadixTree16.getLocatorCount(), is(2));
    assertThat("Failed to fetch the RLOCs with /12 EID record", mapRecordRadixTree12.getLocatorCount(), is(1));
    LispIpv4Address wrongEid = new LispIpv4Address(IpAddress.valueOf(EID_IP_PREFIX_3_24));
    LispEidRecord wrongRecord = new LispEidRecord(cidr24, wrongEid);
    LispMapRecord nullRecord = expireMapDb.getMapRecordByEidRecord(wrongRecord, true);
    assertNull("The record should be null", nullRecord);
}
Also used : LispIpv4Address(org.onosproject.lisp.msg.types.LispIpv4Address) LispMapRecord(org.onosproject.lisp.msg.protocols.LispMapRecord) LispEidRecord(org.onosproject.lisp.msg.protocols.LispEidRecord) Test(org.junit.Test)

Example 3 with LispMapRecord

use of org.onosproject.lisp.msg.protocols.LispMapRecord in project onos by opennetworkinglab.

the class MappingEntryBuilderTest method getMappingAddressByAfiType.

private MappingAddress getMappingAddressByAfiType(AddressFamilyIdentifierEnum afiType, LispCanonicalAddressFormatEnum lcafType) {
    LispMapRecord record = getMapRecord(afiType, lcafType);
    MappingEntry entry = new MappingEntryBuilder(DEVICE_ID, record).build();
    return entry.value().treatments().get(0).address();
}
Also used : MappingEntry(org.onosproject.mapping.MappingEntry) LispMapRecord(org.onosproject.lisp.msg.protocols.LispMapRecord)

Example 4 with LispMapRecord

use of org.onosproject.lisp.msg.protocols.LispMapRecord in project onos by opennetworkinglab.

the class LispMapServer method processMapRegister.

/**
 * Handles map-register message and replies with map-notify message.
 *
 * @param message map-register message
 * @return map-notify message
 */
LispMapNotify processMapRegister(LispMessage message) {
    LispMapRegister register = (LispMapRegister) message;
    if (!checkMapRegisterAuthData(register)) {
        log.warn(INVALID_AUTHENTICATION_DATA_MSG, "Map-Register");
        return null;
    }
    register.getMapRecords().forEach(mapRecord -> {
        LispEidRecord eidRecord = new LispEidRecord(mapRecord.getMaskLength(), mapRecord.getEidPrefixAfi());
        LispMapRecord oldMapRecord = mapDb.getMapRecordByEidRecord(eidRecord, register.isProxyMapReply());
        if (oldMapRecord == null) {
            mapDb.putMapRecord(eidRecord, mapRecord, register.isProxyMapReply());
        } else {
            if (oldMapRecord.getMapVersionNumber() <= mapRecord.getMapVersionNumber()) {
                mapDb.putMapRecord(eidRecord, mapRecord, register.isProxyMapReply());
                if (enableSmr) {
                    sendSmrMessage(eidRecord);
                }
            }
        }
    });
    // otherwise, we do not acknowledge back to ETR
    if (register.isWantMapNotify()) {
        NotifyBuilder notifyBuilder = new DefaultNotifyBuilder();
        notifyBuilder.withKeyId(authConfig.lispAuthKeyId());
        notifyBuilder.withAuthDataLength(valueOf(authConfig.lispAuthKeyId()).getHashLength());
        notifyBuilder.withAuthKey(authConfig.lispAuthKey());
        notifyBuilder.withNonce(register.getNonce());
        notifyBuilder.withMapRecords(register.getMapRecords());
        LispMapNotify notify = notifyBuilder.build();
        InetSocketAddress address = new InetSocketAddress(register.getSender().getAddress(), MAP_NOTIFY_PORT);
        notify.configSender(address);
        return notify;
    }
    return null;
}
Also used : NotifyBuilder(org.onosproject.lisp.msg.protocols.LispMapNotify.NotifyBuilder) DefaultNotifyBuilder(org.onosproject.lisp.msg.protocols.DefaultLispMapNotify.DefaultNotifyBuilder) LispMapRegister(org.onosproject.lisp.msg.protocols.LispMapRegister) LispMapNotify(org.onosproject.lisp.msg.protocols.LispMapNotify) InetSocketAddress(java.net.InetSocketAddress) LispMapRecord(org.onosproject.lisp.msg.protocols.LispMapRecord) DefaultNotifyBuilder(org.onosproject.lisp.msg.protocols.DefaultLispMapNotify.DefaultNotifyBuilder) LispEidRecord(org.onosproject.lisp.msg.protocols.LispEidRecord)

Example 5 with LispMapRecord

use of org.onosproject.lisp.msg.protocols.LispMapRecord in project onos by opennetworkinglab.

the class LispRadixTreeDatabase method getMapRecordByEidRecords.

@Override
public List<LispMapRecord> getMapRecordByEidRecords(List<LispEidRecord> eids, boolean proxyMapReply) {
    final List<LispMapRecord> mapRecords = Lists.newArrayList();
    eids.parallelStream().forEach(eidRecord -> {
        final LispMapRecord mapRecord = getMapRecordByEidRecord(eidRecord, proxyMapReply);
        if (mapRecord != null) {
            mapRecords.add(mapRecord);
        }
    });
    return ImmutableList.copyOf(mapRecords);
}
Also used : LispMapRecord(org.onosproject.lisp.msg.protocols.LispMapRecord)

Aggregations

LispMapRecord (org.onosproject.lisp.msg.protocols.LispMapRecord)13 Test (org.junit.Test)6 LispEidRecord (org.onosproject.lisp.msg.protocols.LispEidRecord)5 LispIpv4Address (org.onosproject.lisp.msg.types.LispIpv4Address)4 DefaultNotifyBuilder (org.onosproject.lisp.msg.protocols.DefaultLispMapNotify.DefaultNotifyBuilder)3 LispMapNotify (org.onosproject.lisp.msg.protocols.LispMapNotify)3 NotifyBuilder (org.onosproject.lisp.msg.protocols.LispMapNotify.NotifyBuilder)3 InetSocketAddress (java.net.InetSocketAddress)2 DefaultMapRecordBuilder (org.onosproject.lisp.msg.protocols.DefaultLispMapRecord.DefaultMapRecordBuilder)2 DefaultReplyBuilder (org.onosproject.lisp.msg.protocols.DefaultLispMapReply.DefaultReplyBuilder)2 MapRecordBuilder (org.onosproject.lisp.msg.protocols.LispMapRecord.MapRecordBuilder)2 LispMapRegister (org.onosproject.lisp.msg.protocols.LispMapRegister)2 LispMapReply (org.onosproject.lisp.msg.protocols.LispMapReply)2 ReplyBuilder (org.onosproject.lisp.msg.protocols.LispMapReply.ReplyBuilder)2 Before (org.junit.Before)1 DefaultLocatorBuilder (org.onosproject.lisp.msg.protocols.DefaultLispLocator.DefaultLocatorBuilder)1 DefaultRegisterBuilder (org.onosproject.lisp.msg.protocols.DefaultLispMapRegister.DefaultRegisterBuilder)1 LispEncapsulatedControl (org.onosproject.lisp.msg.protocols.LispEncapsulatedControl)1 LispLocator (org.onosproject.lisp.msg.protocols.LispLocator)1 RegisterBuilder (org.onosproject.lisp.msg.protocols.LispMapRegister.RegisterBuilder)1