use of org.onosproject.net.flow.instructions.L1ModificationInstruction in project onos by opennetworkinglab.
the class EncodeInstructionCodecHelper method encodeL1.
/**
* Encode an L1 modification instruction.
*
* @param result json node that the instruction attributes are added to
*/
private void encodeL1(ObjectNode result) {
L1ModificationInstruction l1Instruction = (L1ModificationInstruction) instruction;
result.put(InstructionCodec.SUBTYPE, l1Instruction.subtype().name());
switch(l1Instruction.subtype()) {
case ODU_SIGID:
final L1ModificationInstruction.ModOduSignalIdInstruction oduSignalIdInstruction = (L1ModificationInstruction.ModOduSignalIdInstruction) l1Instruction;
OduSignalId oduSignalId = oduSignalIdInstruction.oduSignalId();
ObjectNode child = result.putObject("oduSignalId");
child.put(InstructionCodec.TRIBUTARY_PORT_NUMBER, oduSignalId.tributaryPortNumber());
child.put(InstructionCodec.TRIBUTARY_SLOT_LEN, oduSignalId.tributarySlotLength());
child.put(InstructionCodec.TRIBUTARY_SLOT_BITMAP, HexString.toHexString(oduSignalId.tributarySlotBitmap()));
break;
default:
log.info("Cannot convert L1 subtype of {}", l1Instruction.subtype());
break;
}
}
use of org.onosproject.net.flow.instructions.L1ModificationInstruction in project onos by opennetworkinglab.
the class FlowModBuilderVer13 method buildL1Modification.
protected OFAction buildL1Modification(Instruction i) {
L1ModificationInstruction l1m = (L1ModificationInstruction) i;
OFOxm<?> oxm = null;
switch(l1m.subtype()) {
case ODU_SIGID:
ModOduSignalIdInstruction modOduSignalIdInstruction = (ModOduSignalIdInstruction) l1m;
OduSignalId oduSignalId = modOduSignalIdInstruction.oduSignalId();
OduSignalID oduSignalID = new OduSignalID((short) oduSignalId.tributaryPortNumber(), (short) oduSignalId.tributarySlotLength(), oduSignalId.tributarySlotBitmap());
oxm = factory().oxms().expOduSigId(oduSignalID);
break;
default:
log.warn("Unimplemented action type {}.", l1m.subtype());
break;
}
if (oxm != null) {
return factory().actions().buildSetField().setField(oxm).build();
}
return null;
}
use of org.onosproject.net.flow.instructions.L1ModificationInstruction in project onos by opennetworkinglab.
the class FlowObjectiveCompositionUtil method revertTreatmentSelector.
public static TrafficSelector revertTreatmentSelector(TrafficTreatment trafficTreatment, TrafficSelector trafficSelector) {
TrafficSelector.Builder selectorBuilder = DefaultTrafficSelector.builder();
Map<Criterion.Type, Criterion> criterionMap = new HashMap<>();
for (Criterion criterion : trafficSelector.criteria()) {
criterionMap.put(criterion.type(), criterion);
}
for (Instruction instruction : trafficTreatment.allInstructions()) {
switch(instruction.type()) {
case OUTPUT:
break;
case GROUP:
break;
case L0MODIFICATION:
{
L0ModificationInstruction l0 = (L0ModificationInstruction) instruction;
switch(l0.subtype()) {
case OCH:
if (criterionMap.containsKey(Criterion.Type.OCH_SIGID)) {
if (((OchSignalCriterion) criterionMap.get((Criterion.Type.OCH_SIGID))).lambda().equals(((L0ModificationInstruction.ModOchSignalInstruction) l0).lambda())) {
criterionMap.remove(Criterion.Type.OCH_SIGID);
} else {
return null;
}
}
default:
break;
}
break;
}
case L1MODIFICATION:
{
L1ModificationInstruction l1 = (L1ModificationInstruction) instruction;
switch(l1.subtype()) {
case ODU_SIGID:
if (criterionMap.containsKey(Criterion.Type.ODU_SIGID)) {
if (((OduSignalIdCriterion) criterionMap.get((Criterion.Type.ODU_SIGID))).oduSignalId().equals(((L1ModificationInstruction.ModOduSignalIdInstruction) l1).oduSignalId())) {
criterionMap.remove(Criterion.Type.ODU_SIGID);
} else {
return null;
}
}
default:
break;
}
break;
}
case L2MODIFICATION:
{
L2ModificationInstruction l2 = (L2ModificationInstruction) instruction;
switch(l2.subtype()) {
case ETH_SRC:
if (criterionMap.containsKey(Criterion.Type.ETH_SRC)) {
if (((EthCriterion) criterionMap.get((Criterion.Type.ETH_SRC))).mac().equals(((L2ModificationInstruction.ModEtherInstruction) l2).mac())) {
criterionMap.remove(Criterion.Type.ETH_SRC);
} else {
return null;
}
} else {
break;
}
case ETH_DST:
if (criterionMap.containsKey(Criterion.Type.ETH_DST)) {
if (((EthCriterion) criterionMap.get((Criterion.Type.ETH_DST))).mac().equals(((L2ModificationInstruction.ModEtherInstruction) l2).mac())) {
criterionMap.remove(Criterion.Type.ETH_DST);
} else {
return null;
}
} else {
break;
}
case VLAN_ID:
if (criterionMap.containsKey(Criterion.Type.VLAN_VID)) {
if (((VlanIdCriterion) criterionMap.get((Criterion.Type.VLAN_VID))).vlanId().equals(((L2ModificationInstruction.ModVlanIdInstruction) l2).vlanId())) {
criterionMap.remove(Criterion.Type.VLAN_VID);
} else {
return null;
}
} else {
break;
}
case VLAN_PCP:
if (criterionMap.containsKey(Criterion.Type.VLAN_PCP)) {
if (((VlanPcpCriterion) criterionMap.get((Criterion.Type.VLAN_PCP))).priority() == ((L2ModificationInstruction.ModVlanPcpInstruction) l2).vlanPcp()) {
criterionMap.remove(Criterion.Type.VLAN_PCP);
} else {
return null;
}
} else {
break;
}
case MPLS_LABEL:
if (criterionMap.containsKey(Criterion.Type.MPLS_LABEL)) {
if (((MplsCriterion) criterionMap.get((Criterion.Type.MPLS_LABEL))).label().equals(((L2ModificationInstruction.ModMplsLabelInstruction) l2).label())) {
criterionMap.remove(Criterion.Type.ETH_DST);
} else {
return null;
}
} else {
break;
}
default:
break;
}
break;
}
case TABLE:
break;
case L3MODIFICATION:
{
L3ModificationInstruction l3 = (L3ModificationInstruction) instruction;
switch(l3.subtype()) {
case IPV4_SRC:
if (criterionMap.containsKey(Criterion.Type.IPV4_SRC)) {
if (((IPCriterion) criterionMap.get(Criterion.Type.IPV4_SRC)).ip().contains(((L3ModificationInstruction.ModIPInstruction) l3).ip())) {
criterionMap.remove(Criterion.Type.IPV4_SRC);
} else {
return null;
}
} else {
break;
}
case IPV4_DST:
if (criterionMap.containsKey(Criterion.Type.IPV4_DST)) {
if (((IPCriterion) criterionMap.get(Criterion.Type.IPV4_DST)).ip().contains(((L3ModificationInstruction.ModIPInstruction) l3).ip())) {
criterionMap.remove(Criterion.Type.IPV4_DST);
} else {
return null;
}
} else {
break;
}
case IPV6_SRC:
if (criterionMap.containsKey(Criterion.Type.IPV6_SRC)) {
if (((IPCriterion) criterionMap.get(Criterion.Type.IPV6_SRC)).ip().contains(((L3ModificationInstruction.ModIPInstruction) l3).ip())) {
criterionMap.remove(Criterion.Type.IPV6_SRC);
} else {
return null;
}
} else {
break;
}
case IPV6_DST:
if (criterionMap.containsKey(Criterion.Type.IPV6_DST)) {
if (((IPCriterion) criterionMap.get(Criterion.Type.IPV6_DST)).ip().contains(((L3ModificationInstruction.ModIPInstruction) l3).ip())) {
criterionMap.remove(Criterion.Type.IPV6_DST);
} else {
return null;
}
} else {
break;
}
case IPV6_FLABEL:
if (criterionMap.containsKey(Criterion.Type.IPV6_FLABEL)) {
if (((IPv6FlowLabelCriterion) criterionMap.get(Criterion.Type.IPV6_FLABEL)).flowLabel() == (((L3ModificationInstruction.ModIPv6FlowLabelInstruction) l3).flowLabel())) {
criterionMap.remove(Criterion.Type.IPV4_SRC);
} else {
return null;
}
} else {
break;
}
default:
break;
}
break;
}
case METADATA:
break;
default:
break;
}
}
for (Criterion criterion : criterionMap.values()) {
selectorBuilder.add(criterion);
}
return selectorBuilder.build();
}
Aggregations