Search in sources :

Example 1 with ExtensionSelectorType

use of org.onosproject.net.flow.criteria.ExtensionSelectorType in project onos by opennetworkinglab.

the class OfdpaExtensionSelectorInterpreter method mapSelector.

@Override
public OFOxm<?> mapSelector(OFFactory factory, ExtensionSelector extensionSelector) {
    ExtensionSelectorType type = extensionSelector.type();
    if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.OFDPA_MATCH_VLAN_VID.type())) {
        VlanId vlanId = ((OfdpaMatchVlanVid) extensionSelector).vlanId();
        // Special VLAN 0x0000/0x1FFF required by OFDPA
        if (vlanId.equals(VlanId.NONE)) {
            OFVlanVidMatch vid = OFVlanVidMatch.ofRawVid((short) 0x0000);
            OFVlanVidMatch mask = OFVlanVidMatch.ofRawVid((short) 0x1FFF);
            return factory.oxms().vlanVidMasked(vid, mask);
        // Normal case
        } else if (vlanId.equals(VlanId.ANY)) {
            return factory.oxms().vlanVidMasked(OFVlanVidMatch.PRESENT, OFVlanVidMatch.PRESENT);
        } else {
            return factory.oxms().vlanVid(OFVlanVidMatch.ofVlanVid(VlanVid.ofVlan(vlanId.toShort())));
        }
    } else if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.OFDPA_MATCH_ACTSET_OUTPUT.type())) {
        PortNumber port = ((OfdpaMatchActsetOutput) extensionSelector).port();
        return factory.oxms().ofdpaActsetOutput(U32.of(port.toLong()));
    } else if (type.equals(ExtensionSelectorTypes.OFDPA_MATCH_ALLOW_VLAN_TRANSLATION.type())) {
        Short allowVlanTranslation = ((OfdpaMatchAllowVlanTranslation) extensionSelector).allowVlanTranslation();
        return factory.oxms().ofdpaAllowVlanTranslation(U8.of(allowVlanTranslation));
    }
    throw new UnsupportedOperationException("Unexpected ExtensionSelector: " + extensionSelector.toString());
}
Also used : OFVlanVidMatch(org.projectfloodlight.openflow.types.OFVlanVidMatch) ExtensionSelectorType(org.onosproject.net.flow.criteria.ExtensionSelectorType) PortNumber(org.onosproject.net.PortNumber) VlanId(org.onlab.packet.VlanId)

Example 2 with ExtensionSelectorType

use of org.onosproject.net.flow.criteria.ExtensionSelectorType 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

ExtensionSelectorType (org.onosproject.net.flow.criteria.ExtensionSelectorType)2 VlanId (org.onlab.packet.VlanId)1 ItemNotFoundException (org.onlab.util.ItemNotFoundException)1 DeviceId (org.onosproject.net.DeviceId)1 PortNumber (org.onosproject.net.PortNumber)1 ExtensionSelectorResolver (org.onosproject.net.behaviour.ExtensionSelectorResolver)1 DefaultDriverData (org.onosproject.net.driver.DefaultDriverData)1 DefaultDriverHandler (org.onosproject.net.driver.DefaultDriverHandler)1 DriverHandler (org.onosproject.net.driver.DriverHandler)1 DriverService (org.onosproject.net.driver.DriverService)1 ExtensionSelector (org.onosproject.net.flow.criteria.ExtensionSelector)1 UnresolvedExtensionSelector (org.onosproject.net.flow.criteria.UnresolvedExtensionSelector)1 OFVlanVidMatch (org.projectfloodlight.openflow.types.OFVlanVidMatch)1