Search in sources :

Example 1 with ExtensionSelectorResolver

use of org.onosproject.net.behaviour.ExtensionSelectorResolver in project onos by opennetworkinglab.

the class RulePopulatorUtil method buildCtExtensionSelector.

/**
 * Builds OVS ConnTrack matches.
 *
 * @param driverService driver service
 * @param deviceId device ID
 * @param ctState connection tracking sate masking value
 * @param ctSateMask connection tracking sate masking value
 * @return OVS ConnTrack extension match
 */
public static ExtensionSelector buildCtExtensionSelector(DriverService driverService, DeviceId deviceId, long ctState, long ctSateMask) {
    DriverHandler handler = driverService.createHandler(deviceId);
    ExtensionSelectorResolver esr = handler.behaviour(ExtensionSelectorResolver.class);
    ExtensionSelector extensionSelector = esr.getExtensionSelector(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_CONNTRACK_STATE.type());
    try {
        extensionSelector.setPropertyValue(CT_STATE, ctState);
        extensionSelector.setPropertyValue(CT_STATE_MASK, ctSateMask);
    } catch (Exception e) {
        log.error("Failed to set nicira match CT state because of {}", e);
        return null;
    }
    return extensionSelector;
}
Also used : ExtensionSelector(org.onosproject.net.flow.criteria.ExtensionSelector) DriverHandler(org.onosproject.net.driver.DriverHandler) ExtensionSelectorResolver(org.onosproject.net.behaviour.ExtensionSelectorResolver) ExtensionPropertyException(org.onosproject.net.flow.instructions.ExtensionPropertyException)

Example 2 with ExtensionSelectorResolver

use of org.onosproject.net.behaviour.ExtensionSelectorResolver in project onos by opennetworkinglab.

the class RulePopulatorUtil method buildCtExtensionSelector.

/**
 * Builds OVS ConnTrack matches.
 *
 * @param driverService driver service
 * @param deviceId device ID
 * @param ctState connection tracking sate masking value
 * @param ctSateMask connection tracking sate masking value
 * @return OVS ConnTrack extension match
 */
public static ExtensionSelector buildCtExtensionSelector(DriverService driverService, DeviceId deviceId, long ctState, long ctSateMask) {
    DriverHandler handler = driverService.createHandler(deviceId);
    ExtensionSelectorResolver esr = handler.behaviour(ExtensionSelectorResolver.class);
    ExtensionSelector extensionSelector = esr.getExtensionSelector(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_CONNTRACK_STATE.type());
    try {
        extensionSelector.setPropertyValue(CT_STATE, ctState);
        extensionSelector.setPropertyValue(CT_STATE_MASK, ctSateMask);
    } catch (Exception e) {
        log.error("Failed to set nicira match CT state", e);
        return null;
    }
    return extensionSelector;
}
Also used : ExtensionSelector(org.onosproject.net.flow.criteria.ExtensionSelector) DriverHandler(org.onosproject.net.driver.DriverHandler) ExtensionSelectorResolver(org.onosproject.net.behaviour.ExtensionSelectorResolver) ExtensionPropertyException(org.onosproject.net.flow.instructions.ExtensionPropertyException)

Example 3 with ExtensionSelectorResolver

use of org.onosproject.net.behaviour.ExtensionSelectorResolver in project onos by opennetworkinglab.

the class RulePopulatorUtil method buildCtExtensionSelector.

/**
 * Builds OVS ConnTrack matches.
 *
 * @param driverService driver service
 * @param deviceId device ID
 * @param ctState connection tracking sate masking value
 * @param ctSateMask connection tracking sate masking value
 * @return OVS ConnTrack extension match
 */
public static ExtensionSelector buildCtExtensionSelector(DriverService driverService, DeviceId deviceId, long ctState, long ctSateMask) {
    DriverHandler handler = driverService.createHandler(deviceId);
    ExtensionSelectorResolver esr = handler.behaviour(ExtensionSelectorResolver.class);
    ExtensionSelector extensionSelector = esr.getExtensionSelector(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_CONNTRACK_STATE.type());
    try {
        extensionSelector.setPropertyValue(CT_STATE, ctState);
        extensionSelector.setPropertyValue(CT_STATE_MASK, ctSateMask);
    } catch (Exception e) {
        log.error("Failed to set nicira match CT state because of {}", e);
        return null;
    }
    return extensionSelector;
}
Also used : ExtensionSelector(org.onosproject.net.flow.criteria.ExtensionSelector) DriverHandler(org.onosproject.net.driver.DriverHandler) ExtensionSelectorResolver(org.onosproject.net.behaviour.ExtensionSelectorResolver) ExtensionPropertyException(org.onosproject.net.flow.instructions.ExtensionPropertyException)

Example 4 with ExtensionSelectorResolver

use of org.onosproject.net.behaviour.ExtensionSelectorResolver in project onos by opennetworkinglab.

the class ExtensionCriterionSerializer method read.

@Override
public ExtensionCriterion read(Kryo kryo, Input input, Class<ExtensionCriterion> type) {
    ExtensionSelectorType exType = (ExtensionSelectorType) kryo.readClassAndObject(input);
    DeviceId deviceId = (DeviceId) kryo.readClassAndObject(input);
    DriverService driverService = DefaultServiceDirectory.getService(DriverService.class);
    byte[] bytes = (byte[]) kryo.readClassAndObject(input);
    ExtensionSelector selector;
    try {
        DriverHandler handler = new DefaultDriverHandler(new DefaultDriverData(driverService.getDriver(deviceId), deviceId));
        ExtensionSelectorResolver resolver = handler.behaviour(ExtensionSelectorResolver.class);
        selector = resolver.getExtensionSelector(exType);
        selector.deserialize(bytes);
    } catch (ItemNotFoundException | IllegalArgumentException e) {
        selector = new UnresolvedExtensionSelector(bytes, exType);
    }
    return Criteria.extension(selector, deviceId);
}
Also used : UnresolvedExtensionSelector(org.onosproject.net.flow.criteria.UnresolvedExtensionSelector) ExtensionSelector(org.onosproject.net.flow.criteria.ExtensionSelector) DeviceId(org.onosproject.net.DeviceId) DefaultDriverHandler(org.onosproject.net.driver.DefaultDriverHandler) ExtensionSelectorResolver(org.onosproject.net.behaviour.ExtensionSelectorResolver) UnresolvedExtensionSelector(org.onosproject.net.flow.criteria.UnresolvedExtensionSelector) DriverHandler(org.onosproject.net.driver.DriverHandler) DefaultDriverHandler(org.onosproject.net.driver.DefaultDriverHandler) ExtensionSelectorType(org.onosproject.net.flow.criteria.ExtensionSelectorType) DriverService(org.onosproject.net.driver.DriverService) DefaultDriverData(org.onosproject.net.driver.DefaultDriverData) ItemNotFoundException(org.onlab.util.ItemNotFoundException)

Aggregations

ExtensionSelectorResolver (org.onosproject.net.behaviour.ExtensionSelectorResolver)4 DriverHandler (org.onosproject.net.driver.DriverHandler)4 ExtensionSelector (org.onosproject.net.flow.criteria.ExtensionSelector)4 ExtensionPropertyException (org.onosproject.net.flow.instructions.ExtensionPropertyException)3 ItemNotFoundException (org.onlab.util.ItemNotFoundException)1 DeviceId (org.onosproject.net.DeviceId)1 DefaultDriverData (org.onosproject.net.driver.DefaultDriverData)1 DefaultDriverHandler (org.onosproject.net.driver.DefaultDriverHandler)1 DriverService (org.onosproject.net.driver.DriverService)1 ExtensionSelectorType (org.onosproject.net.flow.criteria.ExtensionSelectorType)1 UnresolvedExtensionSelector (org.onosproject.net.flow.criteria.UnresolvedExtensionSelector)1