Search in sources :

Example 1 with ExtensionTreatmentType

use of org.onosproject.net.flow.instructions.ExtensionTreatmentType in project onos by opennetworkinglab.

the class DefaultMoveExtensionTreatment method deserialize.

@Override
public void deserialize(byte[] data) {
    Map<String, Integer> values = appKryo.deserialize(data);
    srcOfs = values.get("srcOfs");
    dstOfs = values.get("dstOfs");
    nBits = values.get("nBits");
    src = values.get("src");
    dst = values.get("dst");
    type = new ExtensionTreatmentType(values.get("type").intValue());
}
Also used : ExtensionTreatmentType(org.onosproject.net.flow.instructions.ExtensionTreatmentType)

Example 2 with ExtensionTreatmentType

use of org.onosproject.net.flow.instructions.ExtensionTreatmentType in project onos by opennetworkinglab.

the class NiciraExtensionTreatmentInterpreter method encode.

@Override
public ObjectNode encode(ExtensionTreatment extensionTreatment, CodecContext context) {
    checkNotNull(extensionTreatment, "Extension treatment cannot be null");
    ExtensionTreatmentType type = extensionTreatment.type();
    ObjectNode root = context.mapper().createObjectNode();
    if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_TUNNEL_DST.type())) {
        NiciraSetTunnelDst tunnelDst = (NiciraSetTunnelDst) extensionTreatment;
        root.set(TUNNEL_DST, context.codec(NiciraSetTunnelDst.class).encode(tunnelDst, context));
    }
    if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_RESUBMIT.type())) {
        NiciraResubmit resubmit = (NiciraResubmit) extensionTreatment;
        root.set(RESUBMIT, context.codec(NiciraResubmit.class).encode(resubmit, context));
    }
    if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_RESUBMIT_TABLE.type())) {
        NiciraResubmitTable resubmitTable = (NiciraResubmitTable) extensionTreatment;
        root.set(RESUBMIT_TABLE, context.codec(NiciraResubmitTable.class).encode(resubmitTable, context));
    }
    if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_SPI.type())) {
        NiciraSetNshSpi niciraNshSpi = (NiciraSetNshSpi) extensionTreatment;
        root.set(NICIRA_NSH_SPI, context.codec(NiciraSetNshSpi.class).encode(niciraNshSpi, context));
    }
    if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_SI.type())) {
        NiciraSetNshSi niciraNshSi = (NiciraSetNshSi) extensionTreatment;
        root.set(NICIRA_NSH_SI, context.codec(NiciraSetNshSi.class).encode(niciraNshSi, context));
    }
    if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_CH1.type())) {
        NiciraSetNshContextHeader niciraNshch = (NiciraSetNshContextHeader) extensionTreatment;
        root.set(NICIRA_NSH_CH, context.codec(NiciraSetNshContextHeader.class).encode(niciraNshch, context));
    }
    if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_CH2.type())) {
        NiciraSetNshContextHeader niciraNshch = (NiciraSetNshContextHeader) extensionTreatment;
        root.set(NICIRA_NSH_CH, context.codec(NiciraSetNshContextHeader.class).encode(niciraNshch, context));
    }
    if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_CH3.type())) {
        NiciraSetNshContextHeader niciraNshch = (NiciraSetNshContextHeader) extensionTreatment;
        root.set(NICIRA_NSH_CH, context.codec(NiciraSetNshContextHeader.class).encode(niciraNshch, context));
    }
    if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_CH4.type())) {
        NiciraSetNshContextHeader niciraNshch = (NiciraSetNshContextHeader) extensionTreatment;
        root.set(NICIRA_NSH_CH, context.codec(NiciraSetNshContextHeader.class).encode(niciraNshch, context));
    }
    if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_MOV_ARP_SHA_TO_THA.type()) || type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_MOV_ARP_SPA_TO_TPA.type()) || type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_MOV_ETH_SRC_TO_DST.type()) || type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_MOV_IP_SRC_TO_DST.type())) {
        MoveExtensionTreatment mov = (MoveExtensionTreatment) extensionTreatment;
        root.set(NICIRA_MOVE, context.codec(MoveExtensionTreatment.class).encode(mov, context));
    }
    return root;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) OFActionNiciraResubmitTable(org.projectfloodlight.openflow.protocol.action.OFActionNiciraResubmitTable) ExtensionTreatmentType(org.onosproject.net.flow.instructions.ExtensionTreatmentType) OFActionNiciraResubmit(org.projectfloodlight.openflow.protocol.action.OFActionNiciraResubmit)

Example 3 with ExtensionTreatmentType

use of org.onosproject.net.flow.instructions.ExtensionTreatmentType in project onos by opennetworkinglab.

the class MoveExtensionTreatmentCodec method decode.

@Override
public MoveExtensionTreatment decode(ObjectNode json, CodecContext context) {
    if (json == null || !json.isObject()) {
        return null;
    }
    // parse extension treatment type
    ExtensionTreatmentType type = new ExtensionTreatmentType(nullIsIllegal(json.get(TYPE), TYPE + MISSING_MEMBER_MESSAGE).asInt());
    // parse src off set
    int srcOfs = nullIsIllegal(json.get(SRC_OFS), SRC_OFS + MISSING_MEMBER_MESSAGE).asInt();
    // parse dst off set
    int dstOfs = nullIsIllegal(json.get(DST_OFS), DST_OFS + MISSING_MEMBER_MESSAGE).asInt();
    // parse n bits
    int nBits = nullIsIllegal(json.get(N_BITS), N_BITS + MISSING_MEMBER_MESSAGE).asInt();
    // parse src
    int src = nullIsIllegal(json.get(SRC), SRC + MISSING_MEMBER_MESSAGE).asInt();
    // parse dst
    int dst = nullIsIllegal(json.get(DST), DST + MISSING_MEMBER_MESSAGE).asInt();
    return new DefaultMoveExtensionTreatment(srcOfs, dstOfs, nBits, src, dst, type);
}
Also used : DefaultMoveExtensionTreatment(org.onosproject.driver.extensions.DefaultMoveExtensionTreatment) ExtensionTreatmentType(org.onosproject.net.flow.instructions.ExtensionTreatmentType)

Example 4 with ExtensionTreatmentType

use of org.onosproject.net.flow.instructions.ExtensionTreatmentType in project onos by opennetworkinglab.

the class OfdpaExtensionTreatmentInterpreter method mapInstruction.

@Override
public OFAction mapInstruction(OFFactory factory, ExtensionTreatment extensionTreatment) {
    ExtensionTreatmentType type = extensionTreatment.type();
    if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.OFDPA_SET_VLAN_ID.type())) {
        VlanId vlanId = ((OfdpaSetVlanVid) extensionTreatment).vlanId();
        // NOTE: OFDPA requires isPresent bit set to zero.
        OFVlanVidMatch match = OFVlanVidMatch.ofRawVid(vlanId.toShort());
        return factory.actions().setField(factory.oxms().vlanVid(match));
    }
    throw new UnsupportedOperationException("Unexpected ExtensionTreatment: " + extensionTreatment.toString());
}
Also used : OFVlanVidMatch(org.projectfloodlight.openflow.types.OFVlanVidMatch) ExtensionTreatmentType(org.onosproject.net.flow.instructions.ExtensionTreatmentType) VlanId(org.onlab.packet.VlanId)

Example 5 with ExtensionTreatmentType

use of org.onosproject.net.flow.instructions.ExtensionTreatmentType in project onos by opennetworkinglab.

the class NiciraSetNshContextHeaderCodec method decode.

@Override
public NiciraSetNshContextHeader decode(ObjectNode json, CodecContext context) {
    if (json == null || !json.isObject()) {
        return null;
    }
    // parse nsh context header
    int contextHeaderInt = nullIsIllegal(json.get(NSH_CONTEXT_HEADER), NSH_CONTEXT_HEADER + MISSING_MEMBER_MESSAGE).asInt();
    NshContextHeader contextHeader = NshContextHeader.of(contextHeaderInt);
    // parse type
    int extensionTypeInt = nullIsIllegal(json.get(TYPE), TYPE + MISSING_MEMBER_MESSAGE).asInt();
    ExtensionTreatmentType type = new ExtensionTreatmentType(extensionTypeInt);
    return new NiciraSetNshContextHeader(contextHeader, type);
}
Also used : NiciraSetNshContextHeader(org.onosproject.driver.extensions.NiciraSetNshContextHeader) NshContextHeader(org.onosproject.net.NshContextHeader) NiciraSetNshContextHeader(org.onosproject.driver.extensions.NiciraSetNshContextHeader) ExtensionTreatmentType(org.onosproject.net.flow.instructions.ExtensionTreatmentType)

Aggregations

ExtensionTreatmentType (org.onosproject.net.flow.instructions.ExtensionTreatmentType)10 OFActionNiciraResubmit (org.projectfloodlight.openflow.protocol.action.OFActionNiciraResubmit)3 OFActionNiciraResubmitTable (org.projectfloodlight.openflow.protocol.action.OFActionNiciraResubmitTable)3 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 ExtensionTreatment (org.onosproject.net.flow.instructions.ExtensionTreatment)2 VlanId (org.onlab.packet.VlanId)1 ItemNotFoundException (org.onlab.util.ItemNotFoundException)1 DefaultMoveExtensionTreatment (org.onosproject.driver.extensions.DefaultMoveExtensionTreatment)1 NiciraSetNshContextHeader (org.onosproject.driver.extensions.NiciraSetNshContextHeader)1 DeviceId (org.onosproject.net.DeviceId)1 NshContextHeader (org.onosproject.net.NshContextHeader)1 ExtensionTreatmentResolver (org.onosproject.net.behaviour.ExtensionTreatmentResolver)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 UnresolvedExtensionTreatment (org.onosproject.net.flow.instructions.UnresolvedExtensionTreatment)1 OFAction (org.projectfloodlight.openflow.protocol.action.OFAction)1 OFActionNiciraCt (org.projectfloodlight.openflow.protocol.action.OFActionNiciraCt)1 OFActionNiciraLoad (org.projectfloodlight.openflow.protocol.action.OFActionNiciraLoad)1