Search in sources :

Example 1 with ExtensionMappingAddressType

use of org.onosproject.mapping.addresses.ExtensionMappingAddressType 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 2 with ExtensionMappingAddressType

use of org.onosproject.mapping.addresses.ExtensionMappingAddressType in project onos by opennetworkinglab.

the class LispExtensionMappingAddressInterpreter method encode.

@Override
public ObjectNode encode(ExtensionMappingAddress mappingAddress, CodecContext context) {
    checkNotNull(mappingAddress, "Extension mapping address cannot be null");
    ExtensionMappingAddressType type = mappingAddress.type();
    ObjectNode root = context.mapper().createObjectNode();
    if (type.equals(LIST_ADDRESS.type())) {
        LispListAddress listAddress = (LispListAddress) mappingAddress;
        root.set(LISP_LIST_ADDRESS, context.codec(LispListAddress.class).encode(listAddress, context));
    }
    if (type.equals(SEGMENT_ADDRESS.type())) {
        LispSegmentAddress segmentAddress = (LispSegmentAddress) mappingAddress;
        root.set(LISP_SEGMENT_ADDRESS, context.codec(LispSegmentAddress.class).encode(segmentAddress, context));
    }
    if (type.equals(AS_ADDRESS.type())) {
        LispAsAddress asAddress = (LispAsAddress) mappingAddress;
        root.set(LISP_AS_ADDRESS, context.codec(LispAsAddress.class).encode(asAddress, context));
    }
    if (type.equals(APPLICATION_DATA_ADDRESS.type())) {
        LispAppDataAddress appDataAddress = (LispAppDataAddress) mappingAddress;
        root.set(LISP_APPLICATION_DATA_ADDRESS, context.codec(LispAppDataAddress.class).encode(appDataAddress, context));
    }
    if (type.equals(GEO_COORDINATE_ADDRESS.type())) {
        LispGcAddress gcAddress = (LispGcAddress) mappingAddress;
        root.set(LISP_GEO_COORDINATE_ADDRESS, context.codec(LispGcAddress.class).encode(gcAddress, context));
    }
    if (type.equals(NAT_ADDRESS.type())) {
        LispNatAddress natAddress = (LispNatAddress) mappingAddress;
        root.set(LISP_NAT_ADDRESS, context.codec(LispNatAddress.class).encode(natAddress, context));
    }
    if (type.equals(NONCE_ADDRESS.type())) {
        LispNonceAddress nonceAddress = (LispNonceAddress) mappingAddress;
        root.set(LISP_NONCE_ADDRESS, context.codec(LispNonceAddress.class).encode(nonceAddress, context));
    }
    if (type.equals(MULTICAST_ADDRESS.type())) {
        LispMulticastAddress multicastAddress = (LispMulticastAddress) mappingAddress;
        root.set(LISP_MULTICAST_ADDRESS, context.codec(LispMulticastAddress.class).encode(multicastAddress, context));
    }
    if (type.equals(TRAFFIC_ENGINEERING_ADDRESS.type())) {
        LispTeAddress teAddress = (LispTeAddress) mappingAddress;
        root.set(LISP_TRAFFIC_ENGINEERING_ADDRESS, context.codec(LispTeAddress.class).encode(teAddress, context));
    }
    if (type.equals(SOURCE_DEST_ADDRESS.type())) {
        LispSrcDstAddress srcDstAddress = (LispSrcDstAddress) mappingAddress;
        root.set(LISP_SOURCE_DEST_ADDRESS, context.codec(LispSrcDstAddress.class).encode(srcDstAddress, context));
    }
    return root;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ExtensionMappingAddressType(org.onosproject.mapping.addresses.ExtensionMappingAddressType)

Aggregations

ExtensionMappingAddressType (org.onosproject.mapping.addresses.ExtensionMappingAddressType)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 LispAfiAddress (org.onosproject.lisp.msg.types.LispAfiAddress)1 LispAsLcafAddress (org.onosproject.lisp.msg.types.lcaf.LispAsLcafAddress)1 LispGeoCoordinateLcafAddress (org.onosproject.lisp.msg.types.lcaf.LispGeoCoordinateLcafAddress)1 LispListLcafAddress (org.onosproject.lisp.msg.types.lcaf.LispListLcafAddress)1 LispNatLcafAddress (org.onosproject.lisp.msg.types.lcaf.LispNatLcafAddress)1 LispNonceLcafAddress (org.onosproject.lisp.msg.types.lcaf.LispNonceLcafAddress)1 LispSegmentLcafAddress (org.onosproject.lisp.msg.types.lcaf.LispSegmentLcafAddress)1 LispSourceDestLcafAddress (org.onosproject.lisp.msg.types.lcaf.LispSourceDestLcafAddress)1 LispTeRecord (org.onosproject.lisp.msg.types.lcaf.LispTeRecord)1