Search in sources :

Example 1 with LispAsLcafAddress

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

the class LispExtensionMappingAddressInterpreter method mapLcafAddress.

@Override
public ExtensionMappingAddress mapLcafAddress(LispLcafAddress lcafAddress) {
    switch(lcafAddress.getType()) {
        case LIST:
            LispListLcafAddress lcafListAddress = (LispListLcafAddress) lcafAddress;
            MappingAddress ipv4Ma = afi2mapping(lcafListAddress.getAddresses().get(0));
            MappingAddress ipv6Ma = afi2mapping(lcafListAddress.getAddresses().get(1));
            return new LispListAddress.Builder().withIpv4(ipv4Ma).withIpv6(ipv6Ma).build();
        case SEGMENT:
            LispSegmentLcafAddress segmentLcafAddress = (LispSegmentLcafAddress) lcafAddress;
            return new LispSegmentAddress.Builder().withInstanceId(segmentLcafAddress.getInstanceId()).withAddress(getMappingAddress(segmentLcafAddress.getAddress())).build();
        case AS:
            LispAsLcafAddress asLcafAddress = (LispAsLcafAddress) lcafAddress;
            return new org.onosproject.drivers.lisp.extensions.LispAsAddress.Builder().withAsNumber(asLcafAddress.getAsNumber()).withAddress(getMappingAddress(asLcafAddress.getAddress())).build();
        case APPLICATION_DATA:
            LispAppDataLcafAddress appLcafAddress = (LispAppDataLcafAddress) lcafAddress;
            return new LispAppDataAddress.Builder().withProtocol(appLcafAddress.getProtocol()).withIpTos(appLcafAddress.getIpTos()).withLocalPortLow(appLcafAddress.getLocalPortLow()).withLocalPortHigh(appLcafAddress.getLocalPortHigh()).withRemotePortLow(appLcafAddress.getRemotePortLow()).withRemotePortHigh(appLcafAddress.getRemotePortHigh()).withAddress(getMappingAddress(appLcafAddress.getAddress())).build();
        case GEO_COORDINATE:
            LispGeoCoordinateLcafAddress gcLcafAddress = (LispGeoCoordinateLcafAddress) lcafAddress;
            return new LispGcAddress.Builder().withIsNorth(gcLcafAddress.isNorth()).withLatitudeDegree(gcLcafAddress.getLatitudeDegree()).withLatitudeMinute(gcLcafAddress.getLatitudeMinute()).withLatitudeSecond(gcLcafAddress.getLatitudeSecond()).withIsEast(gcLcafAddress.isEast()).withLongitudeDegree(gcLcafAddress.getLongitudeDegree()).withLongitudeMinute(gcLcafAddress.getLongitudeMinute()).withLongitudeSecond(gcLcafAddress.getLongitudeSecond()).withAltitude(gcLcafAddress.getAltitude()).withAddress(getMappingAddress(gcLcafAddress.getAddress())).build();
        case NAT:
            LispNatLcafAddress natLcafAddress = (LispNatLcafAddress) lcafAddress;
            List<MappingAddress> mas = Lists.newArrayList();
            natLcafAddress.getRtrRlocAddresses().forEach(rtr -> mas.add(getMappingAddress(rtr)));
            return new LispNatAddress.Builder().withMsUdpPortNumber(natLcafAddress.getMsUdpPortNumber()).withEtrUdpPortNumber(natLcafAddress.getEtrUdpPortNumber()).withMsRlocAddress(getMappingAddress(natLcafAddress.getMsRlocAddress())).withGlobalEtrRlocAddress(getMappingAddress(natLcafAddress.getGlobalEtrRlocAddress())).withPrivateEtrRlocAddress(getMappingAddress(natLcafAddress.getPrivateEtrRlocAddress())).withRtrRlocAddresses(mas).build();
        case NONCE:
            LispNonceLcafAddress nonceLcafAddress = (LispNonceLcafAddress) lcafAddress;
            return new LispNonceAddress.Builder().withNonce(nonceLcafAddress.getNonce()).withAddress(getMappingAddress(nonceLcafAddress.getAddress())).build();
        case MULTICAST:
            LispMulticastLcafAddress multiLcafAddress = (LispMulticastLcafAddress) lcafAddress;
            return new LispMulticastAddress.Builder().withInstanceId(multiLcafAddress.getInstanceId()).withSrcAddress(getMappingAddress(multiLcafAddress.getSrcAddress())).withSrcMaskLength(multiLcafAddress.getSrcMaskLength()).withGrpAddress(getMappingAddress(multiLcafAddress.getGrpAddress())).withGrpMaskLength(multiLcafAddress.getGrpMaskLength()).build();
        case TRAFFIC_ENGINEERING:
            LispTeLcafAddress teLcafAddress = (LispTeLcafAddress) lcafAddress;
            List<LispTeAddress.TeRecord> records = Lists.newArrayList();
            teLcafAddress.getTeRecords().forEach(record -> {
                LispTeAddress.TeRecord teRecord = new LispTeAddress.TeRecord.Builder().withIsLookup(record.isLookup()).withIsRlocProbe(record.isRlocProbe()).withIsStrict(record.isStrict()).withRtrRlocAddress(getMappingAddress(record.getRtrRlocAddress())).build();
                records.add(teRecord);
            });
            return new LispTeAddress.Builder().withTeRecords(records).build();
        case SECURITY:
            // TODO: need to implement security type later
            log.warn("security type will be implemented later");
            return null;
        case SOURCE_DEST:
            LispSourceDestLcafAddress srcDstLcafAddress = (LispSourceDestLcafAddress) lcafAddress;
            return new LispSrcDstAddress.Builder().withSrcPrefix(getMappingAddress(srcDstLcafAddress.getSrcPrefix())).withSrcMaskLength(srcDstLcafAddress.getSrcMaskLength()).withDstPrefix(getMappingAddress(srcDstLcafAddress.getDstPrefix())).withDstMaskLength(srcDstLcafAddress.getDstMaskLength()).build();
        case UNSPECIFIED:
        case UNKNOWN:
        default:
            log.error("Unsupported LCAF type {}", lcafAddress.getType());
            return null;
    }
}
Also used : LispMulticastLcafAddress(org.onosproject.lisp.msg.types.lcaf.LispMulticastLcafAddress) LispNatLcafAddress(org.onosproject.lisp.msg.types.lcaf.LispNatLcafAddress) LispNonceLcafAddress(org.onosproject.lisp.msg.types.lcaf.LispNonceLcafAddress) LispTeLcafAddress(org.onosproject.lisp.msg.types.lcaf.LispTeLcafAddress) 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) ExtensionMappingAddress(org.onosproject.mapping.addresses.ExtensionMappingAddress) IPMappingAddress(org.onosproject.mapping.addresses.IPMappingAddress) MappingAddress(org.onosproject.mapping.addresses.MappingAddress) LispSegmentLcafAddress(org.onosproject.lisp.msg.types.lcaf.LispSegmentLcafAddress) LispAppDataLcafAddress(org.onosproject.lisp.msg.types.lcaf.LispAppDataLcafAddress) LispSourceDestLcafAddress(org.onosproject.lisp.msg.types.lcaf.LispSourceDestLcafAddress)

Aggregations

LispAppDataLcafAddress (org.onosproject.lisp.msg.types.lcaf.LispAppDataLcafAddress)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 LispMulticastLcafAddress (org.onosproject.lisp.msg.types.lcaf.LispMulticastLcafAddress)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 LispTeLcafAddress (org.onosproject.lisp.msg.types.lcaf.LispTeLcafAddress)1 LispTeRecord (org.onosproject.lisp.msg.types.lcaf.LispTeRecord)1 ExtensionMappingAddress (org.onosproject.mapping.addresses.ExtensionMappingAddress)1 IPMappingAddress (org.onosproject.mapping.addresses.IPMappingAddress)1 MappingAddress (org.onosproject.mapping.addresses.MappingAddress)1