use of org.projectfloodlight.openflow.protocol.instruction.OFInstructionWriteMetadata in project open-kilda by telstra.
the class OneSwitchFlowInstallFlowModFactory method makeMetadataInstructions.
@Override
protected List<OFInstruction> makeMetadataInstructions() {
RoutingMetadata metadata = RoutingMetadata.builder().oneSwitchFlowFlag(true).build(switchFeatures);
OFInstructionWriteMetadata writeMetadata = of.instructions().buildWriteMetadata().setMetadata(metadata.getValue()).setMetadataMask(metadata.getMask()).build();
return Lists.newArrayList(writeMetadata);
}
use of org.projectfloodlight.openflow.protocol.instruction.OFInstructionWriteMetadata in project open-kilda by telstra.
the class SwitchManager method buildArpInputCustomerFlow.
@Override
public OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port) throws SwitchNotFoundException {
IOFSwitch sw = lookupSwitch(dpid);
OFFactory ofFactory = sw.getOFFactory();
Match match = ofFactory.buildMatch().setExact(MatchField.IN_PORT, OFPort.of(port)).setExact(MatchField.ETH_TYPE, EthType.ARP).build();
RoutingMetadata metadata = buildMetadata(RoutingMetadata.builder().arpFlag(true), sw);
OFInstructionWriteMetadata writeMetadata = ofFactory.instructions().buildWriteMetadata().setMetadata(metadata.getValue()).setMetadataMask(metadata.getMask()).build();
OFInstructionGotoTable goToTable = ofFactory.instructions().gotoTable(TableId.of(PRE_INGRESS_TABLE_ID));
return prepareFlowModBuilder(ofFactory, Cookie.encodeArpInputCustomer(port), ARP_INPUT_CUSTOMER_PRIORITY, INPUT_TABLE_ID).setMatch(match).setInstructions(ImmutableList.of(goToTable, writeMetadata)).build();
}
use of org.projectfloodlight.openflow.protocol.instruction.OFInstructionWriteMetadata in project open-kilda by telstra.
the class OfInstructionsConverter method convertToRuleManagerInstructions.
/**
* Convert instructions.
*/
public Instructions convertToRuleManagerInstructions(List<OFInstruction> ofInstructions) {
InstructionsBuilder builder = Instructions.builder();
for (OFInstruction ofInstruction : ofInstructions) {
if (ofInstruction instanceof OFInstructionApplyActions) {
List<OFAction> ofActions = ((OFInstructionApplyActions) ofInstruction).getActions();
List<Action> actions = ofActions.stream().map(this::convertToRuleManagerAction).collect(Collectors.toList());
builder.applyActions(actions);
} else if (ofInstruction instanceof OFInstructionWriteActions) {
List<OFAction> ofActions = ((OFInstructionWriteActions) ofInstruction).getActions();
Set<Action> actions = ofActions.stream().map(this::convertToRuleManagerAction).collect(Collectors.toSet());
builder.writeActions(actions);
} else if (ofInstruction instanceof OFInstructionMeter) {
final long meterId = ((OFInstructionMeter) ofInstruction).getMeterId();
builder.goToMeter(new MeterId(meterId));
} else if (ofInstruction instanceof OFInstructionGotoTable) {
final short tableId = ((OFInstructionGotoTable) ofInstruction).getTableId().getValue();
builder.goToTable(OfTable.fromInt(tableId));
} else if (ofInstruction instanceof OFInstructionWriteMetadata) {
final long metadata = ((OFInstructionWriteMetadata) ofInstruction).getMetadata().getValue();
final long metadataMask = ((OFInstructionWriteMetadata) ofInstruction).getMetadataMask().getValue();
builder.writeMetadata(new OfMetadata(metadata, metadataMask));
}
}
return builder.build();
}
use of org.projectfloodlight.openflow.protocol.instruction.OFInstructionWriteMetadata in project open-kilda by telstra.
the class SwitchManager method buildLldpInputCustomerFlow.
@Override
public OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port) throws SwitchNotFoundException {
IOFSwitch sw = lookupSwitch(dpid);
OFFactory ofFactory = sw.getOFFactory();
Match match = ofFactory.buildMatch().setExact(MatchField.IN_PORT, OFPort.of(port)).setExact(MatchField.ETH_TYPE, EthType.LLDP).build();
RoutingMetadata metadata = buildMetadata(RoutingMetadata.builder().lldpFlag(true), sw);
OFInstructionWriteMetadata writeMetadata = ofFactory.instructions().buildWriteMetadata().setMetadata(metadata.getValue()).setMetadataMask(metadata.getMask()).build();
OFInstructionGotoTable goToTable = ofFactory.instructions().gotoTable(TableId.of(PRE_INGRESS_TABLE_ID));
return prepareFlowModBuilder(ofFactory, Cookie.encodeLldpInputCustomer(port), LLDP_INPUT_CUSTOMER_PRIORITY, INPUT_TABLE_ID).setMatch(match).setInstructions(ImmutableList.of(goToTable, writeMetadata)).build();
}
Aggregations