Search in sources :

Example 1 with LispLocator

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

the class MappingEntryBuilder method buildTreatments.

/**
 * Builds a collection of mapping treatments.
 *
 * @param record LISP map record
 * @return a collection of mapping treatments
 */
private List<MappingTreatment> buildTreatments(LispMapRecord record) {
    List<LispLocator> locators = record.getLocators();
    List<MappingTreatment> treatments = Lists.newArrayList();
    for (LispLocator locator : locators) {
        MappingTreatment.Builder builder = DefaultMappingTreatment.builder();
        LispAfiAddress address = locator.getLocatorAfi();
        final MappingAddress mappingAddress = getAddress(deviceService, deviceId, address);
        if (mappingAddress != null) {
            builder.withAddress(mappingAddress);
        }
        builder.setUnicastWeight(locator.getWeight()).setUnicastPriority(locator.getPriority()).setMulticastWeight(locator.getMulticastWeight()).setMulticastPriority(locator.getMulticastPriority());
        // TODO: need to convert specific properties to
        // abstracted extension properties
        treatments.add(builder.build());
    }
    return treatments;
}
Also used : MappingAddress(org.onosproject.mapping.addresses.MappingAddress) LispLocator(org.onosproject.lisp.msg.protocols.LispLocator) LispAfiAddress(org.onosproject.lisp.msg.types.LispAfiAddress) MappingTreatment(org.onosproject.mapping.MappingTreatment) DefaultMappingTreatment(org.onosproject.mapping.DefaultMappingTreatment)

Example 2 with LispLocator

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

the class MappingEntryBuilderTest method getMapRecord.

/**
 * Obtains a MapRecord instance.
 *
 * @param afiType   AFI address type
 * @param lcafType  LCAF address type
 * @return a MapRecord instance
 */
private LispMapRecord getMapRecord(AddressFamilyIdentifierEnum afiType, LispCanonicalAddressFormatEnum lcafType) {
    MapRecordBuilder recordBuilder = new DefaultMapRecordBuilder();
    LispIpv4Address recordAddress = new LispIpv4Address(IpAddress.valueOf(IP_RECORD_ADDRESS));
    LocatorBuilder locatorBuilder = new DefaultLocatorBuilder();
    LispAfiAddress locatorAddress = getAfiAddress(afiType, lcafType);
    LispLocator locator = locatorBuilder.withPriority(UNIQUE_BYTE).withWeight(UNIQUE_BYTE).withMulticastPriority(UNIQUE_BYTE).withMulticastWeight(UNIQUE_BYTE).withLocalLocator(true).withRlocProbed(false).withRouted(true).withLocatorAfi(locatorAddress).build();
    return recordBuilder.withRecordTtl(UNIQUE_INT).withIsAuthoritative(true).withMapVersionNumber(UNIQUE_SHORT).withMaskLength((byte) IP_RECORD_MASK_LENGTH).withAction(LispMapReplyAction.NativelyForward).withEidPrefixAfi(recordAddress).withLocators(ImmutableList.of(locator)).build();
}
Also used : MapRecordBuilder(org.onosproject.lisp.msg.protocols.LispMapRecord.MapRecordBuilder) DefaultMapRecordBuilder(org.onosproject.lisp.msg.protocols.DefaultLispMapRecord.DefaultMapRecordBuilder) DefaultLocatorBuilder(org.onosproject.lisp.msg.protocols.DefaultLispLocator.DefaultLocatorBuilder) LispIpv4Address(org.onosproject.lisp.msg.types.LispIpv4Address) LispLocator(org.onosproject.lisp.msg.protocols.LispLocator) DefaultMapRecordBuilder(org.onosproject.lisp.msg.protocols.DefaultLispMapRecord.DefaultMapRecordBuilder) LispAfiAddress(org.onosproject.lisp.msg.types.LispAfiAddress) LocatorBuilder(org.onosproject.lisp.msg.protocols.LispLocator.LocatorBuilder) DefaultLocatorBuilder(org.onosproject.lisp.msg.protocols.DefaultLispLocator.DefaultLocatorBuilder)

Example 3 with LispLocator

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

the class LispMappingDatabaseTest method setup.

@Before
public void setup() {
    byte cidr1 = (byte) 32;
    LispIpv4Address eid1 = new LispIpv4Address(IpAddress.valueOf(EID_IP_1));
    LispEidRecord eidRecord1 = new LispEidRecord(cidr1, eid1);
    LispIpv4Address locator11 = new LispIpv4Address(IpAddress.valueOf(LOCATOR_IP_1_1));
    LispIpv4Address locator12 = new LispIpv4Address(IpAddress.valueOf(LOCATOR_IP_1_2));
    LispIpv4Address locator13 = new LispIpv4Address(IpAddress.valueOf(LOCATOR_IP_1_3));
    LispIpv4Address locator14 = new LispIpv4Address(IpAddress.valueOf(LOCATOR_IP_1_4));
    LispLocator locatorRecord11 = new DefaultLocatorBuilder().withLocatorAfi(locator11).build();
    LispLocator locatorRecord12 = new DefaultLocatorBuilder().withLocatorAfi(locator12).build();
    LispLocator locatorRecord13 = new DefaultLocatorBuilder().withLocatorAfi(locator13).build();
    LispLocator locatorRecord14 = new DefaultLocatorBuilder().withLocatorAfi(locator14).build();
    List<LispLocator> locatorRecords1 = ImmutableList.of(locatorRecord11, locatorRecord12, locatorRecord13, locatorRecord14);
    byte cidr2 = (byte) 24;
    LispIpv4Address eid2 = new LispIpv4Address(IpAddress.valueOf(EID_IP_2));
    LispEidRecord eidRecord2 = new LispEidRecord(cidr2, eid2);
    LispIpv4Address locator21 = new LispIpv4Address(IpAddress.valueOf(LOCATOR_IP_2_1));
    LispIpv4Address locator22 = new LispIpv4Address(IpAddress.valueOf(LOCATOR_IP_2_2));
    LispIpv4Address locator23 = new LispIpv4Address(IpAddress.valueOf(LOCATOR_IP_2_3));
    LispLocator locatorRecord21 = new DefaultLocatorBuilder().withLocatorAfi(locator21).build();
    LispLocator locatorRecord22 = new DefaultLocatorBuilder().withLocatorAfi(locator22).build();
    LispLocator locatorRecord23 = new DefaultLocatorBuilder().withLocatorAfi(locator23).build();
    List<LispLocator> locatorRecords2 = ImmutableList.of(locatorRecord21, locatorRecord22, locatorRecord23);
    byte cidr3 = (byte) 16;
    LispIpv4Address eid3 = new LispIpv4Address(IpAddress.valueOf(EID_IP_3));
    LispEidRecord eidRecord3 = new LispEidRecord(cidr3, eid3);
    LispIpv4Address locator31 = new LispIpv4Address(IpAddress.valueOf(LOCATOR_IP_3_1));
    LispIpv4Address locator32 = new LispIpv4Address(IpAddress.valueOf(LOCATOR_IP_3_2));
    LispLocator locatorRecord31 = new DefaultLocatorBuilder().withLocatorAfi(locator31).build();
    LispLocator locatorRecord32 = new DefaultLocatorBuilder().withLocatorAfi(locator32).build();
    List<LispLocator> locatorRecords3 = ImmutableList.of(locatorRecord31, locatorRecord32);
    byte cidr4 = (byte) 12;
    LispIpv4Address eid4 = new LispIpv4Address(IpAddress.valueOf(EID_IP_4));
    LispEidRecord eidRecord4 = new LispEidRecord(cidr4, eid4);
    LispIpv4Address locator41 = new LispIpv4Address(IpAddress.valueOf(LOCATOR_IP_4_1));
    LispLocator locatorRecord41 = new DefaultLocatorBuilder().withLocatorAfi(locator41).build();
    List<LispLocator> locatorRecords4 = ImmutableList.of(locatorRecord41);
    MapRecordBuilder builder1 = new DefaultMapRecordBuilder();
    builder1.withMaskLength(cidr1);
    builder1.withEidPrefixAfi(eid1);
    builder1.withLocators(locatorRecords1);
    builder1.withRecordTtl(RECORD_TTL);
    LispMapRecord mapRecord1 = builder1.build();
    MapRecordBuilder builder2 = new DefaultMapRecordBuilder();
    builder2.withMaskLength(cidr2);
    builder2.withEidPrefixAfi(eid2);
    builder2.withLocators(locatorRecords2);
    builder2.withRecordTtl(RECORD_TTL);
    LispMapRecord mapRecord2 = builder2.build();
    MapRecordBuilder builder3 = new DefaultMapRecordBuilder();
    builder3.withMaskLength(cidr3);
    builder3.withEidPrefixAfi(eid3);
    builder3.withLocators(locatorRecords3);
    builder3.withRecordTtl(RECORD_TTL);
    LispMapRecord mapRecord3 = builder3.build();
    MapRecordBuilder builder4 = new DefaultMapRecordBuilder();
    builder4.withMaskLength(cidr4);
    builder4.withEidPrefixAfi(eid4);
    builder4.withLocators(locatorRecords4);
    builder4.withRecordTtl(RECORD_TTL);
    LispMapRecord mapRecord4 = builder4.build();
    expireMapDb.putMapRecord(eidRecord1, mapRecord1, true);
    expireMapDb.putMapRecord(eidRecord2, mapRecord2, true);
    expireMapDb.putMapRecord(eidRecord3, mapRecord3, true);
    expireMapDb.putMapRecord(eidRecord4, mapRecord4, true);
    radixTreeDb.putMapRecord(eidRecord1, mapRecord1, true);
    radixTreeDb.putMapRecord(eidRecord2, mapRecord2, true);
    radixTreeDb.putMapRecord(eidRecord3, mapRecord3, true);
    radixTreeDb.putMapRecord(eidRecord4, mapRecord4, true);
}
Also used : MapRecordBuilder(org.onosproject.lisp.msg.protocols.LispMapRecord.MapRecordBuilder) DefaultMapRecordBuilder(org.onosproject.lisp.msg.protocols.DefaultLispMapRecord.DefaultMapRecordBuilder) DefaultLocatorBuilder(org.onosproject.lisp.msg.protocols.DefaultLispLocator.DefaultLocatorBuilder) LispIpv4Address(org.onosproject.lisp.msg.types.LispIpv4Address) LispLocator(org.onosproject.lisp.msg.protocols.LispLocator) DefaultMapRecordBuilder(org.onosproject.lisp.msg.protocols.DefaultLispMapRecord.DefaultMapRecordBuilder) LispMapRecord(org.onosproject.lisp.msg.protocols.LispMapRecord) LispEidRecord(org.onosproject.lisp.msg.protocols.LispEidRecord) Before(org.junit.Before)

Aggregations

LispLocator (org.onosproject.lisp.msg.protocols.LispLocator)3 DefaultLocatorBuilder (org.onosproject.lisp.msg.protocols.DefaultLispLocator.DefaultLocatorBuilder)2 DefaultMapRecordBuilder (org.onosproject.lisp.msg.protocols.DefaultLispMapRecord.DefaultMapRecordBuilder)2 MapRecordBuilder (org.onosproject.lisp.msg.protocols.LispMapRecord.MapRecordBuilder)2 LispAfiAddress (org.onosproject.lisp.msg.types.LispAfiAddress)2 LispIpv4Address (org.onosproject.lisp.msg.types.LispIpv4Address)2 Before (org.junit.Before)1 LispEidRecord (org.onosproject.lisp.msg.protocols.LispEidRecord)1 LocatorBuilder (org.onosproject.lisp.msg.protocols.LispLocator.LocatorBuilder)1 LispMapRecord (org.onosproject.lisp.msg.protocols.LispMapRecord)1 DefaultMappingTreatment (org.onosproject.mapping.DefaultMappingTreatment)1 MappingTreatment (org.onosproject.mapping.MappingTreatment)1 MappingAddress (org.onosproject.mapping.addresses.MappingAddress)1