Search in sources :

Example 11 with LispAfiAddress

use of org.onosproject.lisp.msg.types.LispAfiAddress in project onos by opennetworkinglab.

the class LispExtensionMappingAddressInterpreter method mapMappingAddress.

@Override
public LispLcafAddress mapMappingAddress(ExtensionMappingAddress mappingAddress) {
    ExtensionMappingAddressType type = mappingAddress.type();
    if (type.equals(LIST_ADDRESS.type())) {
        LispListAddress listAddress = (LispListAddress) mappingAddress;
        LispAfiAddress ipv4 = mapping2afi(listAddress.getIpv4());
        LispAfiAddress ipv6 = mapping2afi(listAddress.getIpv6());
        if (ipv4 != null && ipv6 != null) {
            return new LispListLcafAddress(ImmutableList.of(ipv4, ipv6));
        } else {
            return new LispListLcafAddress(ImmutableList.of());
        }
    }
    if (type.equals(SEGMENT_ADDRESS.type())) {
        LispSegmentAddress segmentAddress = (LispSegmentAddress) mappingAddress;
        return new LispSegmentLcafAddress.SegmentAddressBuilder().withInstanceId(segmentAddress.getInstanceId()).withAddress(getAfiAddress(segmentAddress.getAddress())).build();
    }
    if (type.equals(AS_ADDRESS.type())) {
        LispAsAddress asAddress = (LispAsAddress) mappingAddress;
        return new LispAsLcafAddress.AsAddressBuilder().withAsNumber(asAddress.getAsNumber()).withAddress(getAfiAddress(asAddress.getAddress())).build();
    }
    if (type.equals(APPLICATION_DATA_ADDRESS.type())) {
        LispAppDataAddress appDataAddress = (LispAppDataAddress) mappingAddress;
        return new LispAppDataLcafAddress.AppDataAddressBuilder().withProtocol(appDataAddress.getProtocol()).withIpTos(appDataAddress.getIpTos()).withLocalPortLow(appDataAddress.getLocalPortLow()).withLocalPortHigh(appDataAddress.getLocalPortHigh()).withRemotePortLow(appDataAddress.getRemotePortLow()).withRemotePortHigh(appDataAddress.getRemotePortHigh()).withAddress(getAfiAddress(appDataAddress.getAddress())).build();
    }
    if (type.equals(GEO_COORDINATE_ADDRESS.type())) {
        LispGcAddress gcAddress = (LispGcAddress) mappingAddress;
        return new LispGeoCoordinateLcafAddress.GeoCoordinateAddressBuilder().withIsNorth(gcAddress.isNorth()).withLatitudeDegree(gcAddress.getLatitudeDegree()).withLatitudeMinute(gcAddress.getLatitudeMinute()).withLatitudeSecond(gcAddress.getLatitudeSecond()).withIsEast(gcAddress.isEast()).withLongitudeDegree(gcAddress.getLongitudeDegree()).withLongitudeMinute(gcAddress.getLongitudeMinute()).withLongitudeSecond(gcAddress.getLongitudeSecond()).withAltitude(gcAddress.getAltitude()).withAddress(getAfiAddress(gcAddress.getAddress())).build();
    }
    if (type.equals(NAT_ADDRESS.type())) {
        LispNatAddress natAddress = (LispNatAddress) mappingAddress;
        List<LispAfiAddress> aas = Lists.newArrayList();
        natAddress.getRtrRlocAddresses().forEach(rtr -> aas.add(getAfiAddress(rtr)));
        return new LispNatLcafAddress.NatAddressBuilder().withMsUdpPortNumber(natAddress.getMsUdpPortNumber()).withEtrUdpPortNumber(natAddress.getEtrUdpPortNumber()).withMsRlocAddress(getAfiAddress(natAddress.getMsRlocAddress())).withGlobalEtrRlocAddress(getAfiAddress(natAddress.getGlobalEtrRlocAddress())).withPrivateEtrRlocAddress(getAfiAddress(natAddress.getPrivateEtrRlocAddress())).withRtrRlocAddresses(aas).build();
    }
    if (type.equals(NONCE_ADDRESS.type())) {
        LispNonceAddress nonceAddress = (LispNonceAddress) mappingAddress;
        return new LispNonceLcafAddress.NonceAddressBuilder().withNonce(nonceAddress.getNonce()).withAddress(getAfiAddress(nonceAddress.getAddress())).build();
    }
    if (type.equals(MULTICAST_ADDRESS.type())) {
        LispMulticastAddress multicastAddress = (LispMulticastAddress) mappingAddress;
        return new LispMulticastLcafAddress.MulticastAddressBuilder().withInstanceId(multicastAddress.getInstanceId()).withSrcAddress(getAfiAddress(multicastAddress.getSrcAddress())).withSrcMaskLength(multicastAddress.getSrcMaskLength()).withGrpAddress(getAfiAddress(multicastAddress.getGrpAddress())).withGrpMaskLength(multicastAddress.getGrpMaskLength()).build();
    }
    if (type.equals(TRAFFIC_ENGINEERING_ADDRESS.type())) {
        LispTeAddress teAddress = (LispTeAddress) mappingAddress;
        List<LispTeRecord> records = Lists.newArrayList();
        teAddress.getTeRecords().forEach(record -> {
            LispTeRecord teRecord = new LispTeRecord.TeRecordBuilder().withIsLookup(record.isLookup()).withIsRlocProbe(record.isRlocProbe()).withIsStrict(record.isStrict()).withRtrRlocAddress(getAfiAddress(record.getAddress())).build();
            records.add(teRecord);
        });
        return new LispTeLcafAddress.TeAddressBuilder().withTeRecords(records).build();
    }
    if (type.equals(SOURCE_DEST_ADDRESS.type())) {
        LispSrcDstAddress srcDstAddress = (LispSrcDstAddress) mappingAddress;
        return new LispSourceDestLcafAddress.SourceDestAddressBuilder().withSrcPrefix(getAfiAddress(srcDstAddress.getSrcPrefix())).withSrcMaskLength(srcDstAddress.getSrcMaskLength()).withDstPrefix(getAfiAddress(srcDstAddress.getDstPrefix())).withDstMaskLength(srcDstAddress.getDstMaskLength()).build();
    }
    log.error("Unsupported extension mapping address type {}", mappingAddress.type());
    return null;
}
Also used : ExtensionMappingAddressType(org.onosproject.mapping.addresses.ExtensionMappingAddressType) LispNatLcafAddress(org.onosproject.lisp.msg.types.lcaf.LispNatLcafAddress) LispAfiAddress(org.onosproject.lisp.msg.types.LispAfiAddress) LispNonceLcafAddress(org.onosproject.lisp.msg.types.lcaf.LispNonceLcafAddress) LispTeRecord(org.onosproject.lisp.msg.types.lcaf.LispTeRecord) LispListLcafAddress(org.onosproject.lisp.msg.types.lcaf.LispListLcafAddress) LispAsLcafAddress(org.onosproject.lisp.msg.types.lcaf.LispAsLcafAddress) LispGeoCoordinateLcafAddress(org.onosproject.lisp.msg.types.lcaf.LispGeoCoordinateLcafAddress) LispSegmentLcafAddress(org.onosproject.lisp.msg.types.lcaf.LispSegmentLcafAddress) LispSourceDestLcafAddress(org.onosproject.lisp.msg.types.lcaf.LispSourceDestLcafAddress)

Example 12 with LispAfiAddress

use of org.onosproject.lisp.msg.types.LispAfiAddress in project onos by opennetworkinglab.

the class LispExtensionMappingAddressInterpreterTest method getLcafMappingAddress.

private LispLcafAddress getLcafMappingAddress(ExtensionMappingAddressType type) {
    LispLcafAddress address = null;
    LispAfiAddress ipv4Addr = new LispIpv4Address(IPV4_ADDRESS);
    LispAfiAddress ipv6Addr = new LispIpv6Address(IPV6_ADDRESS);
    if (type.equals(LIST_ADDRESS.type())) {
        address = new LispListLcafAddress(ImmutableList.of(ipv4Addr, ipv6Addr));
    }
    if (type.equals(SEGMENT_ADDRESS.type())) {
        address = new LispSegmentLcafAddress.SegmentAddressBuilder().withInstanceId(UNIQUE_INT).withAddress(ipv4Addr).build();
    }
    if (type.equals(AS_ADDRESS.type())) {
        address = new LispAsLcafAddress.AsAddressBuilder().withAsNumber(UNIQUE_INT).withAddress(ipv4Addr).build();
    }
    if (type.equals(APPLICATION_DATA_ADDRESS.type())) {
        address = new LispAppDataLcafAddress.AppDataAddressBuilder().withProtocol(UNIQUE_BYTE).withIpTos(UNIQUE_INT).withLocalPortLow(UNIQUE_SHORT).withLocalPortHigh(UNIQUE_SHORT).withRemotePortLow(UNIQUE_SHORT).withRemotePortHigh(UNIQUE_SHORT).withAddress(ipv4Addr).build();
    }
    if (type.equals(GEO_COORDINATE_ADDRESS.type())) {
        address = new LispGeoCoordinateLcafAddress.GeoCoordinateAddressBuilder().withIsNorth(UNIQUE_BOOLEAN).withLatitudeDegree(UNIQUE_SHORT).withLatitudeMinute(UNIQUE_BYTE).withLatitudeSecond(UNIQUE_BYTE).withIsEast(UNIQUE_BOOLEAN).withLongitudeDegree(UNIQUE_SHORT).withLongitudeMinute(UNIQUE_BYTE).withLongitudeSecond(UNIQUE_BYTE).withAltitude(UNIQUE_INT).withAddress(ipv4Addr).build();
    }
    if (type.equals(NAT_ADDRESS.type())) {
        address = new LispNatLcafAddress.NatAddressBuilder().withMsUdpPortNumber(UNIQUE_SHORT).withEtrUdpPortNumber(UNIQUE_SHORT).withGlobalEtrRlocAddress(ipv4Addr).withMsRlocAddress(ipv4Addr).withPrivateEtrRlocAddress(ipv4Addr).withRtrRlocAddresses(ImmutableList.of(ipv4Addr, ipv6Addr)).build();
    }
    if (type.equals(NONCE_ADDRESS.type())) {
        address = new LispNonceLcafAddress.NonceAddressBuilder().withNonce(UNIQUE_INT).withAddress(ipv4Addr).build();
    }
    if (type.equals(MULTICAST_ADDRESS.type())) {
        address = new LispMulticastLcafAddress.MulticastAddressBuilder().withInstanceId(UNIQUE_INT).withSrcMaskLength(UNIQUE_BYTE).withSrcAddress(ipv4Addr).withGrpMaskLength(UNIQUE_BYTE).withGrpAddress(ipv4Addr).build();
    }
    if (type.equals(TRAFFIC_ENGINEERING_ADDRESS.type())) {
        LispTeRecord tr = new LispTeRecord.TeRecordBuilder().withIsLookup(UNIQUE_BOOLEAN).withIsRlocProbe(UNIQUE_BOOLEAN).withIsStrict(UNIQUE_BOOLEAN).withRtrRlocAddress(ipv4Addr).build();
        address = new LispTeLcafAddress.TeAddressBuilder().withTeRecords(ImmutableList.of(tr)).build();
    }
    if (type.equals(SOURCE_DEST_ADDRESS.type())) {
        address = new LispSourceDestLcafAddress.SourceDestAddressBuilder().withSrcMaskLength(UNIQUE_BYTE).withSrcPrefix(ipv4Addr).withDstMaskLength(UNIQUE_BYTE).withDstPrefix(ipv4Addr).build();
    }
    return address;
}
Also used : LispTeRecord(org.onosproject.lisp.msg.types.lcaf.LispTeRecord) LispListLcafAddress(org.onosproject.lisp.msg.types.lcaf.LispListLcafAddress) LispMulticastLcafAddress(org.onosproject.lisp.msg.types.lcaf.LispMulticastLcafAddress) LispAfiAddress(org.onosproject.lisp.msg.types.LispAfiAddress) LispLcafAddress(org.onosproject.lisp.msg.types.lcaf.LispLcafAddress) LispIpv6Address(org.onosproject.lisp.msg.types.LispIpv6Address) LispIpv4Address(org.onosproject.lisp.msg.types.LispIpv4Address) LispAppDataLcafAddress(org.onosproject.lisp.msg.types.lcaf.LispAppDataLcafAddress) LispTeLcafAddress(org.onosproject.lisp.msg.types.lcaf.LispTeLcafAddress)

Example 13 with LispAfiAddress

use of org.onosproject.lisp.msg.types.LispAfiAddress in project onos by opennetworkinglab.

the class MappingEntryBuilderTest method getLcafAddress.

/**
 * Obtains the LCAF address with respect to the LCAF type.
 *
 * @param type LCAF type
 * @return LCAF address instance
 */
private LispLcafAddress getLcafAddress(LispCanonicalAddressFormatEnum type) {
    List<LispAfiAddress> afiAddresses = ImmutableList.of(IPV4_ADDRESS_1, IPV6_ADDRESS);
    switch(type) {
        case LIST:
            return new LispListLcafAddress(afiAddresses);
        case SEGMENT:
            return new LispSegmentLcafAddress.SegmentAddressBuilder().withIdMaskLength(UNIQUE_BYTE).withInstanceId(UNIQUE_INT).withAddress(IPV4_ADDRESS_1).build();
        case AS:
            return new LispAsLcafAddress.AsAddressBuilder().withAsNumber(UNIQUE_INT).withAddress(IPV4_ADDRESS_1).build();
        case APPLICATION_DATA:
            return new LispAppDataLcafAddress.AppDataAddressBuilder().withProtocol(UNIQUE_BYTE).withIpTos(UNIQUE_SHORT).withLocalPortLow(UNIQUE_SHORT).withLocalPortHigh(UNIQUE_SHORT).withRemotePortLow(UNIQUE_SHORT).withRemotePortHigh(UNIQUE_SHORT).withAddress(IPV4_ADDRESS_1).build();
        case GEO_COORDINATE:
            return new LispGeoCoordinateLcafAddress.GeoCoordinateAddressBuilder().withIsNorth(UNIQUE_BOOLEAN).withLatitudeDegree(UNIQUE_SHORT).withLatitudeMinute(UNIQUE_BYTE).withLatitudeSecond(UNIQUE_BYTE).withIsEast(UNIQUE_BOOLEAN).withLongitudeDegree(UNIQUE_SHORT).withLongitudeMinute(UNIQUE_BYTE).withLongitudeSecond(UNIQUE_BYTE).withAltitude(UNIQUE_INT).withAddress(IPV4_ADDRESS_1).build();
        case NAT:
            return new LispNatLcafAddress.NatAddressBuilder().withLength(UNIQUE_SHORT).withMsUdpPortNumber(UNIQUE_SHORT).withEtrUdpPortNumber(UNIQUE_SHORT).withGlobalEtrRlocAddress(IPV4_ADDRESS_1).withMsRlocAddress(IPV4_ADDRESS_1).withPrivateEtrRlocAddress(IPV4_ADDRESS_1).withRtrRlocAddresses(afiAddresses).build();
        case NONCE:
            return new LispNonceLcafAddress.NonceAddressBuilder().withNonce(UNIQUE_INT).withAddress(IPV4_ADDRESS_1).build();
        case MULTICAST:
            return new LispMulticastLcafAddress.MulticastAddressBuilder().withInstanceId(UNIQUE_INT).withSrcMaskLength(UNIQUE_BYTE).withGrpMaskLength(UNIQUE_BYTE).withSrcAddress(IPV4_ADDRESS_1).withGrpAddress(IPV4_ADDRESS_1).build();
        case TRAFFIC_ENGINEERING:
            LispTeRecord.TeRecordBuilder recordBuilder1 = new LispTeRecord.TeRecordBuilder();
            recordBuilder1.withIsLookup(UNIQUE_BOOLEAN);
            recordBuilder1.withIsRlocProbe(UNIQUE_BOOLEAN);
            recordBuilder1.withIsStrict(UNIQUE_BOOLEAN);
            recordBuilder1.withRtrRlocAddress(IPV4_ADDRESS_1);
            LispTeRecord record1 = recordBuilder1.build();
            LispTeRecord.TeRecordBuilder recordBuilder2 = new LispTeRecord.TeRecordBuilder();
            recordBuilder2.withIsLookup(UNIQUE_BOOLEAN);
            recordBuilder2.withIsRlocProbe(UNIQUE_BOOLEAN);
            recordBuilder2.withIsStrict(UNIQUE_BOOLEAN);
            recordBuilder2.withRtrRlocAddress(IPV4_ADDRESS_2);
            LispTeRecord record2 = recordBuilder2.build();
            return new LispTeLcafAddress.TeAddressBuilder().withTeRecords(ImmutableList.of(record1, record2)).build();
        case SOURCE_DEST:
            return new LispSourceDestLcafAddress.SourceDestAddressBuilder().withReserved(UNIQUE_SHORT).withSrcMaskLength(UNIQUE_BYTE).withDstMaskLength(UNIQUE_BYTE).withSrcPrefix(IPV4_ADDRESS_1).withDstPrefix(IPV4_ADDRESS_2).build();
        case UNKNOWN:
        case UNSPECIFIED:
        default:
            return null;
    }
}
Also used : LispTeRecord(org.onosproject.lisp.msg.types.lcaf.LispTeRecord) LispListLcafAddress(org.onosproject.lisp.msg.types.lcaf.LispListLcafAddress) LispAsLcafAddress(org.onosproject.lisp.msg.types.lcaf.LispAsLcafAddress) LispGeoCoordinateLcafAddress(org.onosproject.lisp.msg.types.lcaf.LispGeoCoordinateLcafAddress) LispAfiAddress(org.onosproject.lisp.msg.types.LispAfiAddress) LispNonceLcafAddress(org.onosproject.lisp.msg.types.lcaf.LispNonceLcafAddress)

Example 14 with LispAfiAddress

use of org.onosproject.lisp.msg.types.LispAfiAddress in project onos by opennetworkinglab.

the class LispListLcafAddressTest method setup.

@Before
public void setup() {
    LispAfiAddress ipv4Address1 = new LispIpv4Address(IpAddress.valueOf("192.168.1.1"));
    LispAfiAddress ipv6Address1 = new LispIpv6Address(IpAddress.valueOf("1111:2222:3333:4444:5555:6666:7777:8885"));
    List<LispAfiAddress> afiAddresses1 = Lists.newArrayList();
    afiAddresses1.add(ipv4Address1);
    afiAddresses1.add(ipv6Address1);
    address1 = new LispListLcafAddress(afiAddresses1);
    sameAsAddress1 = new LispListLcafAddress(afiAddresses1);
    LispAfiAddress ipv4Address2 = new LispIpv4Address(IpAddress.valueOf("192.168.2.1"));
    LispAfiAddress ipv6Address2 = new LispIpv6Address(IpAddress.valueOf("1111:2222:3333:4444:5555:6666:7777:8886"));
    List<LispAfiAddress> afiAddresses2 = Lists.newArrayList();
    afiAddresses2.add(ipv4Address2);
    afiAddresses2.add(ipv6Address2);
    address2 = new LispListLcafAddress(afiAddresses2);
}
Also used : LispIpv6Address(org.onosproject.lisp.msg.types.LispIpv6Address) LispIpv4Address(org.onosproject.lisp.msg.types.LispIpv4Address) LispAfiAddress(org.onosproject.lisp.msg.types.LispAfiAddress) Before(org.junit.Before)

Example 15 with LispAfiAddress

use of org.onosproject.lisp.msg.types.LispAfiAddress in project onos by opennetworkinglab.

the class LispListLcafAddressTest method testConstruction.

@Test
public void testConstruction() {
    LispListLcafAddress listLcafAddress = address1;
    LispAfiAddress ipv4Address1 = new LispIpv4Address(IpAddress.valueOf("192.168.1.1"));
    LispAfiAddress ipv6Address1 = new LispIpv6Address(IpAddress.valueOf("1111:2222:3333:4444:5555:6666:7777:8885"));
    List<LispAfiAddress> afiAddresses1 = Lists.newArrayList();
    afiAddresses1.add(ipv4Address1);
    afiAddresses1.add(ipv6Address1);
    assertThat(listLcafAddress.getAddresses(), is(afiAddresses1));
}
Also used : LispIpv6Address(org.onosproject.lisp.msg.types.LispIpv6Address) LispIpv4Address(org.onosproject.lisp.msg.types.LispIpv4Address) LispAfiAddress(org.onosproject.lisp.msg.types.LispAfiAddress) Test(org.junit.Test)

Aggregations

LispAfiAddress (org.onosproject.lisp.msg.types.LispAfiAddress)16 LispIpv4Address (org.onosproject.lisp.msg.types.LispIpv4Address)10 Before (org.junit.Before)4 LispIpv6Address (org.onosproject.lisp.msg.types.LispIpv6Address)4 LispListLcafAddress (org.onosproject.lisp.msg.types.lcaf.LispListLcafAddress)3 LispTeRecord (org.onosproject.lisp.msg.types.lcaf.LispTeRecord)3 UnknownHostException (java.net.UnknownHostException)2 Test (org.junit.Test)2 DefaultRequestBuilder (org.onosproject.lisp.msg.protocols.DefaultLispMapRequest.DefaultRequestBuilder)2 LispLocator (org.onosproject.lisp.msg.protocols.LispLocator)2 RequestBuilder (org.onosproject.lisp.msg.protocols.LispMapRequest.RequestBuilder)2 LispAsLcafAddress (org.onosproject.lisp.msg.types.lcaf.LispAsLcafAddress)2 LispGeoCoordinateLcafAddress (org.onosproject.lisp.msg.types.lcaf.LispGeoCoordinateLcafAddress)2 NatAddressBuilder (org.onosproject.lisp.msg.types.lcaf.LispNatLcafAddress.NatAddressBuilder)2 LispNonceLcafAddress (org.onosproject.lisp.msg.types.lcaf.LispNonceLcafAddress)2 IpAddress (org.onlab.packet.IpAddress)1 LispRouter (org.onosproject.lisp.ctl.LispRouter)1 LispRouterFactory (org.onosproject.lisp.ctl.LispRouterFactory)1 DefaultInfoReplyBuilder (org.onosproject.lisp.msg.protocols.DefaultLispInfoReply.DefaultInfoReplyBuilder)1 DefaultInfoRequestBuilder (org.onosproject.lisp.msg.protocols.DefaultLispInfoRequest.DefaultInfoRequestBuilder)1