use of org.onosproject.net.flow.instructions.ExtensionTreatmentType in project onos by opennetworkinglab.
the class OplinkExtensionTreatmentCodec method decode.
@Override
public ExtensionTreatment decode(ObjectNode objectNode, CodecContext context) {
if (objectNode == null || !objectNode.isObject()) {
return null;
}
int typeInt = nullIsIllegal(objectNode.get(TYPE), MISSING_TYPE).asInt();
ExtensionTreatmentType type = new ExtensionTreatmentType(typeInt);
if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.OPLINK_ATTENUATION.type())) {
return decodeTreatment(objectNode, context, OplinkAttenuation.class);
} else {
throw new UnsupportedOperationException(UNSUPPORTED_TYPE + type.toString());
}
}
use of org.onosproject.net.flow.instructions.ExtensionTreatmentType in project onos by opennetworkinglab.
the class ExtensionInstructionSerializer method read.
@Override
public Instructions.ExtensionInstructionWrapper read(Kryo kryo, Input input, Class<Instructions.ExtensionInstructionWrapper> type) {
ExtensionTreatmentType exType = (ExtensionTreatmentType) kryo.readClassAndObject(input);
DeviceId deviceId = (DeviceId) kryo.readClassAndObject(input);
String driverName = (String) kryo.readClassAndObject(input);
DriverService driverService = DefaultServiceDirectory.getService(DriverService.class);
byte[] bytes = (byte[]) kryo.readClassAndObject(input);
ExtensionTreatment instruction;
try {
DriverHandler handler = new DefaultDriverHandler(new DefaultDriverData(driverService.getDriver(driverName), deviceId));
ExtensionTreatmentResolver resolver = handler.behaviour(ExtensionTreatmentResolver.class);
instruction = resolver.getExtensionInstruction(exType);
instruction.deserialize(bytes);
} catch (ItemNotFoundException | IllegalArgumentException e) {
instruction = new UnresolvedExtensionTreatment(bytes, exType);
}
return Instructions.extension(instruction, deviceId);
}
use of org.onosproject.net.flow.instructions.ExtensionTreatmentType in project onos by opennetworkinglab.
the class NiciraExtensionTreatmentInterpreter method mapInstruction.
@Override
public OFAction mapInstruction(OFFactory factory, ExtensionTreatment extensionTreatment) {
ExtensionTreatmentType type = extensionTreatment.type();
if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_TUNNEL_DST.type())) {
NiciraSetTunnelDst tunnelDst = (NiciraSetTunnelDst) extensionTreatment;
return factory.actions().setField(factory.oxms().tunnelIpv4Dst(IPv4Address.of(tunnelDst.tunnelDst().toInt())));
}
if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_RESUBMIT.type())) {
NiciraResubmit resubmit = (NiciraResubmit) extensionTreatment;
return factory.actions().niciraResubmit((int) resubmit.inPort().toLong(), resubmit.table());
}
if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_RESUBMIT_TABLE.type())) {
NiciraResubmitTable resubmitTable = (NiciraResubmitTable) extensionTreatment;
return factory.actions().niciraResubmitTable((int) resubmitTable.inPort().toLong(), resubmitTable.table());
}
if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_SPI.type())) {
NiciraSetNshSpi niciraNshSpi = (NiciraSetNshSpi) extensionTreatment;
return factory.actions().setField(factory.oxms().nsp(U32.of(niciraNshSpi.nshSpi().servicePathId())));
}
if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_SI.type())) {
NiciraSetNshSi niciraNshSi = (NiciraSetNshSi) extensionTreatment;
return factory.actions().setField(factory.oxms().nsi(U8.of(niciraNshSi.nshSi().serviceIndex())));
}
if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_CH1.type())) {
NiciraSetNshContextHeader niciraNshch = (NiciraSetNshContextHeader) extensionTreatment;
return factory.actions().setField(factory.oxms().nshC1(U32.of(niciraNshch.nshCh().nshContextHeader())));
}
if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_CH2.type())) {
NiciraSetNshContextHeader niciraNshch = (NiciraSetNshContextHeader) extensionTreatment;
return factory.actions().setField(factory.oxms().nshC2(U32.of(niciraNshch.nshCh().nshContextHeader())));
}
if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_CH3.type())) {
NiciraSetNshContextHeader niciraNshch = (NiciraSetNshContextHeader) extensionTreatment;
return factory.actions().setField(factory.oxms().nshC3(U32.of(niciraNshch.nshCh().nshContextHeader())));
}
if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_CH4.type())) {
NiciraSetNshContextHeader niciraNshch = (NiciraSetNshContextHeader) extensionTreatment;
return factory.actions().setField(factory.oxms().nshC4(U32.of(niciraNshch.nshCh().nshContextHeader())));
}
if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_NSH_MDTYPE.type())) {
NiciraNshMdType niciraNshMdType = (NiciraNshMdType) extensionTreatment;
return factory.actions().setField(factory.oxms().nshMdtype(U8.of(niciraNshMdType.nshMdType())));
}
if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_NSH_NP.type())) {
NiciraNshNp niciraNshNp = (NiciraNshNp) extensionTreatment;
return factory.actions().setField(factory.oxms().nshNp(U8.of(niciraNshNp.nshNp())));
}
if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_ENCAP_ETH_SRC.type())) {
NiciraEncapEthSrc niciraEncapEthSrc = (NiciraEncapEthSrc) extensionTreatment;
return factory.actions().setField(factory.oxms().encapEthSrc(MacAddress.of(niciraEncapEthSrc.encapEthSrc().toBytes())));
}
if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_ENCAP_ETH_DST.type())) {
NiciraEncapEthDst niciraEncapEthDst = (NiciraEncapEthDst) extensionTreatment;
return factory.actions().setField(factory.oxms().encapEthDst(MacAddress.of(niciraEncapEthDst.encapEthDst().toBytes())));
}
if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_ENCAP_ETH_TYPE.type())) {
NiciraEncapEthType niciraEncapEthType = (NiciraEncapEthType) extensionTreatment;
return factory.actions().setField(factory.oxms().encapEthType(U16.of(niciraEncapEthType.encapEthType())));
}
if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_PUSH_NSH.type())) {
return factory.actions().niciraPushNsh();
}
if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_POP_NSH.type())) {
return factory.actions().niciraPopNsh();
}
if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_TUN_GPE_NP.type())) {
NiciraTunGpeNp niciraTunGpeNp = (NiciraTunGpeNp) extensionTreatment;
return factory.actions().setField(factory.oxms().tunGpeNp(U8.of(niciraTunGpeNp.tunGpeNp())));
}
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()) || type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_MOV_NSH_C1_TO_C1.type()) || type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_MOV_NSH_C2_TO_C2.type()) || type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_MOV_NSH_C3_TO_C3.type()) || type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_MOV_NSH_C4_TO_C4.type()) || type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_MOV_TUN_IPV4_DST_TO_TUN_IPV4_DST.type()) || type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_MOV_TUN_ID_TO_TUN_ID.type()) || type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_MOV_NSH_C2_TO_TUN_ID.type())) {
MoveExtensionTreatment mov = (MoveExtensionTreatment) extensionTreatment;
OFActionNiciraMove.Builder action = factory.actions().buildNiciraMove();
action.setDstOfs(mov.dstOffset());
action.setSrcOfs(mov.srcOffset());
action.setNBits(mov.nBits());
action.setSrc(mov.src());
action.setDst(mov.dst());
return action.build();
}
if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_LOAD.type())) {
NiciraLoad load = (NiciraLoad) extensionTreatment;
OFActionNiciraLoad.Builder action = factory.actions().buildNiciraLoad();
action.setOfsNbits(load.ofsNbits());
action.setDst(load.dst());
action.setValue(U64.of(load.value()));
return action.build();
}
if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_CT.type())) {
NiciraCt niciraCt = (NiciraCt) extensionTreatment;
OFActionNiciraCt.Builder ctAction = factory.actions().buildNiciraCt();
ctAction.setFlags(niciraCt.niciraCtFlags());
ctAction.setZoneSrc(niciraCt.niciraCtZoneSrc());
ctAction.setZone(niciraCt.niciraCtZone());
ctAction.setRecircTable(niciraCt.niciraCtRecircTable());
ctAction.setAlg(niciraCt.niciraCtAlg());
List<OFAction> actions = Lists.newArrayList();
for (ExtensionTreatment nestedTreatment : niciraCt.niciraCtNestActions()) {
if (nestedTreatment instanceof NiciraNat) {
NiciraNat niciraNat = (NiciraNat) nestedTreatment;
OFActionNiciraNat.Builder action = factory.actions().buildNiciraNat();
action.setFlags(niciraNat.niciraNatFlags());
int presetFlags = niciraNat.niciraNatPresentFlags();
action.setRangePresent(presetFlags);
List<IPv4Address> ipv4RangeList = Lists.newArrayList();
List<IPv6Address> ipv6RangeList = Lists.newArrayList();
List<U16> portRangeList = Lists.newArrayList();
List<U8> padList = Lists.newArrayList();
if ((presetFlags & NAT_RANGE_IPV4_MIN) != 0) {
ipv4RangeList.add(IPv4Address.of(niciraNat.niciraNatIpAddressMin().getIp4Address().toString()));
}
if ((presetFlags & NAT_RANGE_IPV4_MAX) != 0) {
ipv4RangeList.add(IPv4Address.of(niciraNat.niciraNatIpAddressMax().getIp4Address().toString()));
}
if ((presetFlags & NAT_RANGE_IPV6_MIN) != 0) {
ipv6RangeList.add(IPv6Address.of(niciraNat.niciraNatIpAddressMin().getIp6Address().toString()));
}
if ((presetFlags & NAT_RANGE_IPV6_MAX) != 0) {
ipv6RangeList.add(IPv6Address.of(niciraNat.niciraNatIpAddressMax().getIp6Address().toString()));
}
if ((presetFlags & NAT_RANGE_PROTO_MIN) != 0) {
portRangeList.add(U16.of(niciraNat.niciraNatPortMin()));
}
if ((presetFlags & NAT_RANGE_PROTO_MAX) != 0) {
portRangeList.add(U16.of(niciraNat.niciraNatPortMax()));
}
for (; (ipv6RangeList.size() * 16 + ipv4RangeList.size() * 4 + portRangeList.size() * 2 + padList.size()) % 8 != 0; ) {
padList.add(U8.ofRaw((byte) 0));
}
action.setIpv4Range(ipv4RangeList);
action.setIpv6Range(ipv6RangeList);
action.setPortRange(portRangeList);
action.setPad(padList);
// nat action must be nested in ct action
actions.add(action.build());
} else if (nestedTreatment instanceof NiciraLoad) {
NiciraLoad niciraLoad = (NiciraLoad) nestedTreatment;
OFActionNiciraLoad.Builder action = factory.actions().buildNiciraLoad();
action.setDst(niciraLoad.dst());
action.setOfsNbits(niciraLoad.ofsNbits());
action.setValue(U64.of(niciraLoad.value()));
actions.add(action.build());
}
}
ctAction.setActions(actions);
return ctAction.build();
}
if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_CT_CLEAR.type())) {
return factory.actions().niciraCtClear();
}
return null;
}
use of org.onosproject.net.flow.instructions.ExtensionTreatmentType in project onos by opennetworkinglab.
the class NiciraExtensionTreatmentInterpreter method decode.
@Override
public ExtensionTreatment decode(ObjectNode json, CodecContext context) {
if (json == null || !json.isObject()) {
return null;
}
// parse extension type
int typeInt = nullIsIllegal(json.get(TYPE), TYPE + MISSING_MEMBER_MESSAGE).asInt();
ExtensionTreatmentType type = new ExtensionTreatmentType(typeInt);
if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_TUNNEL_DST.type())) {
return context.codec(NiciraSetTunnelDst.class).decode(json, context);
}
if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_RESUBMIT.type())) {
return context.codec(NiciraResubmit.class).decode(json, context);
}
if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_RESUBMIT_TABLE.type())) {
return context.codec(NiciraResubmitTable.class).decode(json, context);
}
if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_SPI.type())) {
return context.codec(NiciraSetNshSpi.class).decode(json, context);
}
if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_SI.type())) {
return context.codec(NiciraSetNshSi.class).decode(json, context);
}
if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_CH1.type())) {
return context.codec(NiciraSetNshContextHeader.class).decode(json, context);
}
if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_CH2.type())) {
return context.codec(NiciraSetNshContextHeader.class).decode(json, context);
}
if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_CH3.type())) {
return context.codec(NiciraSetNshContextHeader.class).decode(json, context);
}
if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_CH4.type())) {
return context.codec(NiciraSetNshContextHeader.class).decode(json, 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())) {
return context.codec(MoveExtensionTreatment.class).decode(json, context);
}
throw new UnsupportedOperationException("Driver does not support extension type " + type.toString());
}
use of org.onosproject.net.flow.instructions.ExtensionTreatmentType in project onos by opennetworkinglab.
the class Ofdpa3ExtensionTreatmentInterpreter method encode.
@Override
public ObjectNode encode(ExtensionTreatment extensionTreatment, CodecContext context) {
checkNotNull(extensionTreatment, MISSING_TREATMENT_MESSAGE);
ExtensionTreatmentType type = extensionTreatment.type();
ObjectNode root = context.mapper().createObjectNode();
if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.OFDPA_SET_MPLS_TYPE.type())) {
Ofdpa3SetMplsType setMplsType = (Ofdpa3SetMplsType) extensionTreatment;
root.put(TYPE, ExtensionTreatmentType.ExtensionTreatmentTypes.OFDPA_SET_MPLS_TYPE.name());
root.setAll(context.codec(Ofdpa3SetMplsType.class).encode(setMplsType, context));
} else if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.OFDPA_SET_OVID.type())) {
Ofdpa3SetOvid setOvid = (Ofdpa3SetOvid) extensionTreatment;
root.put(TYPE, ExtensionTreatmentType.ExtensionTreatmentTypes.OFDPA_SET_OVID.name());
root.setAll(context.codec(Ofdpa3SetOvid.class).encode(setOvid, context));
} else if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.OFDPA_SET_MPLS_L2_PORT.type())) {
Ofdpa3SetMplsL2Port setMplsL2Port = (Ofdpa3SetMplsL2Port) extensionTreatment;
root.put(TYPE, ExtensionTreatmentType.ExtensionTreatmentTypes.OFDPA_SET_MPLS_L2_PORT.name());
root.setAll(context.codec(Ofdpa3SetMplsL2Port.class).encode(setMplsL2Port, context));
} else if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.OFDPA_SET_QOS_INDEX.type())) {
Ofdpa3SetQosIndex setQosIndex = (Ofdpa3SetQosIndex) extensionTreatment;
root.put(TYPE, ExtensionTreatmentType.ExtensionTreatmentTypes.OFDPA_SET_QOS_INDEX.name());
root.setAll(context.codec(Ofdpa3SetQosIndex.class).encode(setQosIndex, context));
} else if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.OFDPA_PUSH_L2_HEADER.type())) {
root.put(TYPE, ExtensionTreatmentType.ExtensionTreatmentTypes.OFDPA_PUSH_L2_HEADER.name());
} else if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.OFDPA_PUSH_CW.type())) {
root.put(TYPE, ExtensionTreatmentType.ExtensionTreatmentTypes.OFDPA_PUSH_CW.name());
} else if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.OFDPA_POP_L2_HEADER.type())) {
root.put(TYPE, ExtensionTreatmentType.ExtensionTreatmentTypes.OFDPA_POP_L2_HEADER.name());
} else if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.OFDPA_POP_CW.type())) {
root.put(TYPE, ExtensionTreatmentType.ExtensionTreatmentTypes.OFDPA_POP_CW.name());
} else if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.OFDPA_ALLOW_VLAN_TRANSLATION.type())) {
root.put(TYPE, ExtensionTreatmentType.ExtensionTreatmentTypes.OFDPA_ALLOW_VLAN_TRANSLATION.name());
} else if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.ONF_COPY_FIELD.type())) {
root.put(TYPE, ExtensionTreatmentType.ExtensionTreatmentTypes.ONF_COPY_FIELD.name());
}
return root;
}
Aggregations