本文整理汇总了Java中org.onosproject.net.flow.instructions.Instructions.OutputInstruction方法的典型用法代码示例。如果您正苦于以下问题:Java Instructions.OutputInstruction方法的具体用法?Java Instructions.OutputInstruction怎么用?Java Instructions.OutputInstruction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.onosproject.net.flow.instructions.Instructions
的用法示例。
在下文中一共展示了Instructions.OutputInstruction方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: provisionEapol
import org.onosproject.net.flow.instructions.Instructions; //导入方法依赖的package包/类
private void provisionEapol(FilteringObjective filter,
EthTypeCriterion ethType,
Instructions.OutputInstruction output) {
TrafficSelector selector = buildSelector(filter.key(), ethType);
TrafficTreatment treatment = buildTreatment(output);
buildAndApplyRule(filter, selector, treatment);
}
示例2: provisionIgmp
import org.onosproject.net.flow.instructions.Instructions; //导入方法依赖的package包/类
private void provisionIgmp(FilteringObjective filter, EthTypeCriterion ethType,
IPProtocolCriterion ipProto,
Instructions.OutputInstruction output) {
TrafficSelector selector = buildSelector(filter.key(), ethType, ipProto);
TrafficTreatment treatment = buildTreatment(output);
buildAndApplyRule(filter, selector, treatment);
}
示例3: ofFlowStatsRequestFlowSend
import org.onosproject.net.flow.instructions.Instructions; //导入方法依赖的package包/类
private void ofFlowStatsRequestFlowSend(FlowEntry fe) {
// set find match
Match match = FlowModBuilder.builder(fe, sw.factory(), Optional.empty(),
Optional.of(driverService)).buildMatch();
// set find tableId
TableId tableId = TableId.of(fe.tableId());
// set output port
Instruction ins = fe.treatment().allInstructions().stream()
.filter(i -> (i.type() == Instruction.Type.OUTPUT))
.findFirst()
.orElse(null);
OFPort ofPort = OFPort.NO_MASK;
if (ins != null) {
Instructions.OutputInstruction out = (Instructions.OutputInstruction) ins;
ofPort = OFPort.of((int) ((out.port().toLong())));
}
OFFlowStatsRequest request = sw.factory().buildFlowStatsRequest()
.setMatch(match)
.setTableId(tableId)
.setOutPort(ofPort)
.build();
synchronized (this) {
if (getFlowMissingXid() != NO_FLOW_MISSING_XID) {
log.debug("ofFlowStatsRequestFlowSend: previous FlowStatsRequestAll does not be processed yet,"
+ " set no flow missing xid anyway, for {}",
sw.getStringId());
setFlowMissingXid(NO_FLOW_MISSING_XID);
}
sw.sendMsg(request);
}
}
示例4: verifyVlanEncapTreatment
import org.onosproject.net.flow.instructions.Instructions; //导入方法依赖的package包/类
private VlanId verifyVlanEncapTreatment(TrafficTreatment trafficTreatment,
ConnectPoint egress, boolean isIngress, boolean isEgress) {
Set<Instructions.OutputInstruction> ruleOutput = trafficTreatment.allInstructions().stream()
.filter(treat -> treat instanceof Instructions.OutputInstruction)
.map(treat -> (Instructions.OutputInstruction) treat)
.collect(Collectors.toSet());
assertThat(ruleOutput, hasSize(1));
assertThat((ruleOutput.iterator().next()).port(), is(egress.port()));
VlanId vlanToEncap = VlanId.NONE;
if (isIngress && !isEgress) {
Set<L2ModificationInstruction.ModVlanIdInstruction> vlanRules = trafficTreatment.allInstructions().stream()
.filter(treat -> treat instanceof L2ModificationInstruction.ModVlanIdInstruction)
.map(x -> (L2ModificationInstruction.ModVlanIdInstruction) x)
.collect(Collectors.toSet());
assertThat(vlanRules, hasSize(1));
L2ModificationInstruction.ModVlanIdInstruction vlanRule = vlanRules.iterator().next();
assertThat(vlanRule.vlanId().toShort(), greaterThan((short) 0));
vlanToEncap = vlanRule.vlanId();
} else if (!isIngress && !isEgress) {
assertThat(trafficTreatment.allInstructions().stream()
.filter(treat -> treat instanceof L2ModificationInstruction.ModVlanIdInstruction)
.collect(Collectors.toSet()), hasSize(0));
} else {
assertThat(trafficTreatment.allInstructions().stream()
.filter(treat -> treat instanceof L2ModificationInstruction.ModVlanIdInstruction)
.collect(Collectors.toSet()), hasSize(0));
assertThat(trafficTreatment.allInstructions().stream()
.filter(treat -> treat instanceof L2ModificationInstruction.PopVlanInstruction)
.collect(Collectors.toSet()), hasSize(1));
}
return vlanToEncap;
}
示例5: verifyMplsEncapTreatment
import org.onosproject.net.flow.instructions.Instructions; //导入方法依赖的package包/类
private MplsLabel verifyMplsEncapTreatment(TrafficTreatment trafficTreatment,
ConnectPoint egress, boolean isIngress, boolean isEgress) {
Set<Instructions.OutputInstruction> ruleOutput = trafficTreatment.allInstructions().stream()
.filter(treat -> treat instanceof Instructions.OutputInstruction)
.map(treat -> (Instructions.OutputInstruction) treat)
.collect(Collectors.toSet());
assertThat(ruleOutput, hasSize(1));
assertThat((ruleOutput.iterator().next()).port(), is(egress.port()));
MplsLabel mplsToEncap = MplsLabel.mplsLabel(0);
if (isIngress && !isEgress) {
Set<L2ModificationInstruction.ModMplsLabelInstruction> mplsRules =
trafficTreatment.allInstructions().stream()
.filter(treat -> treat instanceof L2ModificationInstruction.ModMplsLabelInstruction)
.map(x -> (L2ModificationInstruction.ModMplsLabelInstruction) x)
.collect(Collectors.toSet());
assertThat(mplsRules, hasSize(1));
L2ModificationInstruction.ModMplsLabelInstruction mplsRule = mplsRules.iterator().next();
assertThat(mplsRule.mplsLabel().toInt(), greaterThan(0));
mplsToEncap = mplsRule.mplsLabel();
} else if (!isIngress && !isEgress) {
assertThat(trafficTreatment.allInstructions().stream()
.filter(treat -> treat instanceof L2ModificationInstruction.ModMplsLabelInstruction)
.collect(Collectors.toSet()), hasSize(0));
} else {
assertThat(trafficTreatment.allInstructions().stream()
.filter(treat -> treat instanceof L2ModificationInstruction.ModMplsLabelInstruction)
.collect(Collectors.toSet()), hasSize(0));
assertThat(trafficTreatment.allInstructions().stream()
.filter(treat -> treat instanceof L2ModificationInstruction.PushHeaderInstructions)
.collect(Collectors.toSet()), hasSize(1));
}
return mplsToEncap;
}
示例6: outputInstructionTest
import org.onosproject.net.flow.instructions.Instructions; //导入方法依赖的package包/类
/**
* Tests the encoding of output instructions.
*/
@Test
public void outputInstructionTest() {
final Instructions.OutputInstruction instruction =
Instructions.createOutput(PortNumber.portNumber(22));
final ObjectNode instructionJson =
instructionCodec.encode(instruction, context);
assertThat(instructionJson, matchesInstruction(instruction));
}
示例7: getOutput
import org.onosproject.net.flow.instructions.Instructions; //导入方法依赖的package包/类
private PortNumber getOutput(FlowRule rule) {
for (Instruction i : rule.treatment().immediate()) {
if (i.type() == Instruction.Type.OUTPUT) {
Instructions.OutputInstruction out = (Instructions.OutputInstruction) i;
return out.port();
}
}
return null;
}
示例8: getOutput
import org.onosproject.net.flow.instructions.Instructions; //导入方法依赖的package包/类
private PortNumber getOutput(FlowRule rule) {
for (Instruction i : rule.treatment().allInstructions()) {
if (i.type() == Instruction.Type.OUTPUT) {
Instructions.OutputInstruction out = (Instructions.OutputInstruction) i;
return out.port();
}
}
return null;
}
示例9: installDownstreamRules
import org.onosproject.net.flow.instructions.Instructions; //导入方法依赖的package包/类
private void installDownstreamRules(ForwardingObjective fwd) {
List<Pair<Instruction, Instruction>> vlanOps =
vlanOps(fwd,
L2ModificationInstruction.L2SubType.VLAN_POP);
if (vlanOps == null) {
return;
}
Instructions.OutputInstruction output = (Instructions.OutputInstruction) fetchOutput(fwd, "downstream");
if (output == null) {
return;
}
Pair<Instruction, Instruction> popAndRewrite = vlanOps.remove(0);
TrafficSelector selector = fwd.selector();
Criterion outerVlan = selector.getCriterion(Criterion.Type.VLAN_VID);
Criterion innerVlan = selector.getCriterion(Criterion.Type.INNER_VLAN_VID);
Criterion inport = selector.getCriterion(Criterion.Type.IN_PORT);
Criterion bullshit = Criteria.matchMetadata(output.port().toLong());
if (outerVlan == null || innerVlan == null || inport == null) {
log.error("Forwarding objective is underspecified: {}", fwd);
fail(fwd, ObjectiveError.BADPARAMS);
return;
}
Criterion innerVid = Criteria.matchVlanId(((VlanIdCriterion) innerVlan).vlanId());
FlowRule.Builder outer = DefaultFlowRule.builder()
.fromApp(fwd.appId())
.forDevice(deviceId)
.makePermanent()
.withPriority(fwd.priority())
.withSelector(buildSelector(inport, outerVlan, bullshit))
.withTreatment(buildTreatment(popAndRewrite.getLeft(),
Instructions.transition(QQ_TABLE)));
FlowRule.Builder inner = DefaultFlowRule.builder()
.fromApp(fwd.appId())
.forDevice(deviceId)
.forTable(QQ_TABLE)
.makePermanent()
.withPriority(fwd.priority())
.withSelector(buildSelector(inport, innerVid))
.withTreatment(buildTreatment(popAndRewrite.getLeft(),
output));
applyRules(fwd, inner, outer);
}
示例10: CrossConnectFlowRule
import org.onosproject.net.flow.instructions.Instructions; //导入方法依赖的package包/类
public CrossConnectFlowRule(FlowRule rule, List<PortNumber> linePorts) {
super(rule);
Set<Criterion> criteria = rule.selector().criteria();
List<Instruction> instructions = rule.treatment().immediate();
// Proper cross connect has criteria for input port, OChSignal and OCh signal type.
// Instruction must be output to port.
checkArgument(criteria.size() == 3, "Wrong size of flow rule criteria for cross connect.");
checkArgument(instructions.size() == 1, "Wrong size of flow rule instructions for cross connect.");
// FIXME: Ensure criteria has exactly one of each match type
criteria.forEach(
c -> checkArgument(c instanceof OchSignalCriterion ||
c instanceof OchSignalTypeCriterion ||
c instanceof PortCriterion,
"Incompatible flow rule criteria for cross connect: " + criteria
)
);
checkArgument(instructions.get(0).type() == Instruction.Type.OUTPUT,
"Incompatible flow rule instructions for cross connect: " + instructions);
ochSignal = criteria.stream()
.filter(c -> c instanceof OchSignalCriterion)
.map(c -> ((OchSignalCriterion) c).lambda())
.findAny()
.orElse(null);
// Add or drop rule?
Instructions.OutputInstruction outInstruction = (Instructions.OutputInstruction) instructions.get(0);
if (linePorts.contains(outInstruction.port())) {
addDrop = criteria.stream()
.filter(c -> c instanceof PortCriterion)
.map(c -> ((PortCriterion) c).port())
.findAny()
.orElse(null);
isAddRule = true;
} else {
addDrop = outInstruction.port();
isAddRule = false;
}
}
示例11: buildActions
import org.onosproject.net.flow.instructions.Instructions; //导入方法依赖的package包/类
private List<OFAction> buildActions(TrafficTreatment treatment) {
if (treatment == null) {
return Collections.emptyList();
}
List<OFAction> actions = new LinkedList<>();
for (Instruction i : treatment.allInstructions()) {
switch (i.type()) {
case L0MODIFICATION:
actions.add(buildL0Modification(i));
break;
case L2MODIFICATION:
actions.add(buildL2Modification(i));
break;
case L3MODIFICATION:
actions.add(buildL3Modification(i));
break;
case OUTPUT:
Instructions.OutputInstruction out =
(Instructions.OutputInstruction) i;
OFActionOutput.Builder action = factory.actions().buildOutput()
.setPort(OFPort.of((int) out.port().toLong()));
if (out.port().equals(PortNumber.CONTROLLER)) {
action.setMaxLen(OFPCML_NO_BUFFER);
}
actions.add(action.build());
break;
case GROUP:
Instructions.GroupInstruction grp =
(Instructions.GroupInstruction) i;
OFActionGroup.Builder actgrp = factory.actions().buildGroup()
.setGroup(OFGroup.of(grp.groupId().id()));
actions.add(actgrp.build());
break;
case EXTENSION:
Instructions.ExtensionInstructionWrapper wrapper =
(Instructions.ExtensionInstructionWrapper) i;
actions.add(buildExtensionAction(
wrapper.extensionInstruction(), wrapper.deviceId()));
break;
default:
log.warn("Instruction type {} not yet implemented.", i.type());
}
}
return actions;
}
示例12: dfs
import org.onosproject.net.flow.instructions.Instructions; //导入方法依赖的package包/类
private boolean dfs(FlowEntry flow) {
if (ignoredFlows.contains(flow)) {
return false;
}
if ("Cycle".equals(label.get(flow)) ||
"Black Hole".equals(label.get(flow)) ||
"Cleared".equals(label.get(flow)) ||
"NA".equals(label.get(flow)) ||
"Cycle Critical Point".equals(label.get(flow))) {
// This flow has already been analyzed and there is no need to analyze it further
return !"Black Hole".equals(label.get(flow));
}
if ("Visiting".equals(label.get(flow))) {
//you've detected a cycle because you reached the same entry again during your dfs
//let it continue so you can label the whole cycle
label.put(flow, "Cycle");
} else {
//otherwise, mark off the current flow entry as currently being visited
label.put(flow, "Visiting");
}
boolean pointsToLiveEntry = false;
List<Instruction> instructions = flow.treatment().allInstructions();
for (Instruction i: instructions) {
if (i instanceof Instructions.OutputInstruction) {
pointsToLiveEntry |= analyzeInstruction(i, flow);
}
if ("NA".equals(label.get(flow))) {
return pointsToLiveEntry;
}
}
if (!pointsToLiveEntry) {
//this entry does not point to any "live" entries thus must be a black hole
label.put(flow, "Black Hole");
} else if ("Visiting".equals(label.get(flow))) {
//the flow is not in a cycle or in a black hole
label.put(flow, "Cleared");
}
return pointsToLiveEntry;
}
示例13: analyzeInstruction
import org.onosproject.net.flow.instructions.Instructions; //导入方法依赖的package包/类
private boolean analyzeInstruction(Instruction i, FlowEntry flow) {
boolean pointsToLiveEntry = false;
Instructions.OutputInstruction output = (Instructions.OutputInstruction) i;
PortNumber port = output.port();
PortNumber outPort = null;
DeviceId egress = null;
boolean hasHost = false;
ConnectPoint portPt = new ConnectPoint(flow.deviceId(), port);
for (Link l: linkService.getEgressLinks(portPt)) {
if (l.dst().elementId() instanceof DeviceId) {
egress = l.dst().deviceId();
outPort = l.dst().port();
} else if (l.dst().elementId() instanceof HostId) {
//the port leads to a host: therefore it is not a dead link
pointsToLiveEntry = true;
hasHost = true;
}
}
if (!topologyService.isInfrastructure(topologyService.currentTopology(), portPt) && egress == null) {
pointsToLiveEntry = true;
hasHost = true;
}
if (hasHost) {
return pointsToLiveEntry;
}
if (egress == null) {
//the port that the flow instructions tells you to send the packet
//to doesn't exist or is a controller port
label.put(flow, "NA");
return pointsToLiveEntry;
}
Iterable<FlowEntry> dstFlowTable = flowRuleService.getFlowEntries(egress);
Set<Criterion> flowCriteria = flow.selector().criteria();
//filter the criteria in order to remove port dependency
Set<Criterion> filteredCriteria = new HashSet<>();
for (Criterion criterion : flowCriteria) {
if (!(criterion instanceof PortCriterion)) {
filteredCriteria.add(criterion);
}
}
//ensure that the in port is equal to the port that it is coming in from
filteredCriteria.add(Criteria.matchInPort(outPort));
for (FlowEntry entry: dstFlowTable) {
if (ignoredFlows.contains(entry)) {
continue;
}
if (filteredCriteria.containsAll(entry.selector().criteria())) {
dfs(entry);
if (!"Black Hole".equals(label.get(entry))) {
//this entry is "live" i.e not a black hole
pointsToLiveEntry = true;
}
}
}
return pointsToLiveEntry;
}
示例14: encode
import org.onosproject.net.flow.instructions.Instructions; //导入方法依赖的package包/类
/**
* Encodes the given instruction into JSON.
*
* @return JSON object node representing the instruction
*/
public ObjectNode encode() {
final ObjectNode result = context.mapper().createObjectNode()
.put(InstructionCodec.TYPE, instruction.type().toString());
switch (instruction.type()) {
case OUTPUT:
final Instructions.OutputInstruction outputInstruction =
(Instructions.OutputInstruction) instruction;
result.put(InstructionCodec.PORT, outputInstruction.port().toString());
break;
case NOACTION:
break;
case GROUP:
final Instructions.GroupInstruction groupInstruction =
(Instructions.GroupInstruction) instruction;
result.put(InstructionCodec.GROUP_ID, groupInstruction.groupId().toString());
break;
case METER:
final Instructions.MeterInstruction meterInstruction =
(Instructions.MeterInstruction) instruction;
result.put(InstructionCodec.METER_ID, meterInstruction.meterId().toString());
break;
case TABLE:
final Instructions.TableTypeTransition tableTransitionInstruction =
(Instructions.TableTypeTransition) instruction;
result.put(InstructionCodec.TABLE_ID, tableTransitionInstruction.tableId().toString());
break;
case QUEUE:
final Instructions.SetQueueInstruction setQueueInstruction =
(Instructions.SetQueueInstruction) instruction;
result.put(InstructionCodec.QUEUE_ID, setQueueInstruction.queueId());
result.put(InstructionCodec.PORT, setQueueInstruction.port().toString());
break;
case L0MODIFICATION:
encodeL0(result);
break;
case L1MODIFICATION:
encodeL1(result);
break;
case L2MODIFICATION:
encodeL2(result);
break;
case L3MODIFICATION:
encodeL3(result);
break;
case L4MODIFICATION:
encodeL4(result);
break;
case EXTENSION:
encodeExtension(result);
break;
default:
log.info("Cannot convert instruction type of {}", instruction.type());
break;
}
return result;
}