Search in sources :

Example 1 with ExtensionMappingAddressInterpreter

use of org.onosproject.lisp.ctl.ExtensionMappingAddressInterpreter in project onos by opennetworkinglab.

the class MappingAddressBuilder method lcaf2extension.

/**
 * Converts LCAF address to extension mapping address.
 *
 * @param deviceService device service
 * @param deviceId      device identifier
 * @param lcaf          LCAF address
 * @return extension mapping address
 */
private static MappingAddress lcaf2extension(DeviceService deviceService, DeviceId deviceId, LispLcafAddress lcaf) {
    Device device = deviceService.getDevice(deviceId);
    ExtensionMappingAddressInterpreter addressInterpreter;
    ExtensionMappingAddress mappingAddress = null;
    if (device.is(ExtensionMappingAddressInterpreter.class)) {
        addressInterpreter = device.as(ExtensionMappingAddressInterpreter.class);
    } else {
        addressInterpreter = null;
    }
    switch(lcaf.getType()) {
        case LIST:
            if (addressInterpreter != null && addressInterpreter.supported(LIST_ADDRESS.type())) {
                mappingAddress = addressInterpreter.mapLcafAddress(lcaf);
            }
            break;
        case SEGMENT:
            if (addressInterpreter != null && addressInterpreter.supported(SEGMENT_ADDRESS.type())) {
                mappingAddress = addressInterpreter.mapLcafAddress(lcaf);
            }
            break;
        case AS:
            if (addressInterpreter != null && addressInterpreter.supported(AS_ADDRESS.type())) {
                mappingAddress = addressInterpreter.mapLcafAddress(lcaf);
            }
            break;
        case APPLICATION_DATA:
            if (addressInterpreter != null && addressInterpreter.supported(APPLICATION_DATA_ADDRESS.type())) {
                mappingAddress = addressInterpreter.mapLcafAddress(lcaf);
            }
            break;
        case GEO_COORDINATE:
            if (addressInterpreter != null && addressInterpreter.supported(GEO_COORDINATE_ADDRESS.type())) {
                mappingAddress = addressInterpreter.mapLcafAddress(lcaf);
            }
            break;
        case NAT:
            if (addressInterpreter != null && addressInterpreter.supported(NAT_ADDRESS.type())) {
                mappingAddress = addressInterpreter.mapLcafAddress(lcaf);
            }
            break;
        case NONCE:
            if (addressInterpreter != null && addressInterpreter.supported(NONCE_ADDRESS.type())) {
                mappingAddress = addressInterpreter.mapLcafAddress(lcaf);
            }
            break;
        case MULTICAST:
            if (addressInterpreter != null && addressInterpreter.supported(MULTICAST_ADDRESS.type())) {
                mappingAddress = addressInterpreter.mapLcafAddress(lcaf);
            }
            break;
        case TRAFFIC_ENGINEERING:
            if (addressInterpreter != null && addressInterpreter.supported(TRAFFIC_ENGINEERING_ADDRESS.type())) {
                mappingAddress = addressInterpreter.mapLcafAddress(lcaf);
            }
            break;
        case SOURCE_DEST:
            if (addressInterpreter != null && addressInterpreter.supported(SOURCE_DEST_ADDRESS.type())) {
                mappingAddress = addressInterpreter.mapLcafAddress(lcaf);
            }
            break;
        default:
            log.warn("Unsupported extension mapping address type {}", lcaf.getType());
            break;
    }
    return mappingAddress != null ? MappingAddresses.extensionMappingAddressWrapper(mappingAddress, deviceId) : null;
}
Also used : Device(org.onosproject.net.Device) ExtensionMappingAddressInterpreter(org.onosproject.lisp.ctl.ExtensionMappingAddressInterpreter) ExtensionMappingAddress(org.onosproject.mapping.addresses.ExtensionMappingAddress)

Aggregations

ExtensionMappingAddressInterpreter (org.onosproject.lisp.ctl.ExtensionMappingAddressInterpreter)1 ExtensionMappingAddress (org.onosproject.mapping.addresses.ExtensionMappingAddress)1 Device (org.onosproject.net.Device)1