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());
}
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;
}
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);
}
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());
}
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);
}
Aggregations