本文整理汇总了Java中org.onosproject.net.flow.instructions.Instructions类的典型用法代码示例。如果您正苦于以下问题:Java Instructions类的具体用法?Java Instructions怎么用?Java Instructions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Instructions类属于org.onosproject.net.flow.instructions包,在下文中一共展示了Instructions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processNextTreatment
import org.onosproject.net.flow.instructions.Instructions; //导入依赖的package包/类
@Override
protected TrafficTreatment processNextTreatment(TrafficTreatment treatment) {
TrafficTreatment.Builder tb = DefaultTrafficTreatment.builder();
tb.add(Instructions.popVlan());
treatment.immediate().stream()
.filter(i -> {
switch (i.type()) {
case L2MODIFICATION:
L2ModificationInstruction l2i = (L2ModificationInstruction) i;
if (l2i.subtype() == VLAN_ID ||
l2i.subtype() == VLAN_POP ||
l2i.subtype() == VLAN_POP ||
l2i.subtype() == ETH_DST ||
l2i.subtype() == ETH_SRC) {
return true;
}
case OUTPUT:
return true;
default:
return false;
}
}).forEach(i -> tb.add(i));
return tb.build();
}
示例2: getFlowRulesFrom
import org.onosproject.net.flow.instructions.Instructions; //导入依赖的package包/类
private Set<FlowEntry> getFlowRulesFrom(ConnectPoint egress) {
ImmutableSet.Builder<FlowEntry> builder = ImmutableSet.builder();
flowRuleService.getFlowEntries(egress.deviceId()).forEach(r -> {
if (r.appId() == appId.id()) {
r.treatment().allInstructions().forEach(i -> {
if (i.type() == Instruction.Type.OUTPUT) {
if (((Instructions.OutputInstruction) i).port().equals(egress.port())) {
builder.add(r);
}
}
});
}
});
return builder.build();
}
示例3: programLocalIn
import org.onosproject.net.flow.instructions.Instructions; //导入依赖的package包/类
@Override
public void programLocalIn(DeviceId deviceId,
SegmentationId segmentationId, PortNumber inPort,
MacAddress srcMac, ApplicationId appid,
Objective.Operation type) {
TrafficSelector selector = DefaultTrafficSelector.builder()
.matchInPort(inPort).matchEthSrc(srcMac).build();
TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
treatment.add(Instructions
.modTunnelId(Long.parseLong(segmentationId.toString())));
ForwardingObjective.Builder objective = DefaultForwardingObjective
.builder().withTreatment(treatment.build())
.withSelector(selector).fromApp(appId).makePermanent()
.withFlag(Flag.SPECIFIC).withPriority(L2_CLASSIFIER_PRIORITY);
if (type.equals(Objective.Operation.ADD)) {
log.debug("programLocalIn-->ADD");
flowObjectiveService.forward(deviceId, objective.add());
} else {
log.debug("programLocalIn-->REMOVE");
flowObjectiveService.forward(deviceId, objective.remove());
}
}
示例4: programExportPortArpClassifierRules
import org.onosproject.net.flow.instructions.Instructions; //导入依赖的package包/类
@Override
public void programExportPortArpClassifierRules(Port exportPort,
DeviceId deviceId,
Operation type) {
TrafficSelector selector = DefaultTrafficSelector.builder()
.matchEthType(EtherType.ARP.ethType().toShort())
.matchInPort(exportPort.number()).build();
TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
treatment.add(Instructions.createOutput(PortNumber.CONTROLLER));
ForwardingObjective.Builder objective = DefaultForwardingObjective
.builder().withTreatment(treatment.build())
.withSelector(selector).fromApp(appId).withFlag(Flag.SPECIFIC)
.withPriority(L3_CLASSIFIER_PRIORITY);
if (type.equals(Objective.Operation.ADD)) {
flowObjectiveService.forward(deviceId, objective.add());
} else {
flowObjectiveService.forward(deviceId, objective.remove());
}
}
示例5: programRouteRules
import org.onosproject.net.flow.instructions.Instructions; //导入依赖的package包/类
@Override
public void programRouteRules(DeviceId deviceId, SegmentationId l3Vni,
IpAddress dstVmIP, SegmentationId dstVni,
MacAddress dstVmGwMac, MacAddress dstVmMac,
Operation type) {
TrafficSelector selector = DefaultTrafficSelector.builder()
.matchEthType(IP_TYPE)
.matchTunnelId(Long.parseLong(l3Vni.segmentationId()))
.matchIPDst(IpPrefix.valueOf(dstVmIP, PREFIX_LENGTH)).build();
TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
treatment.setEthSrc(dstVmGwMac)
.setEthDst(dstVmMac)
.add(Instructions.modTunnelId(Long.parseLong(dstVni
.segmentationId())));
ForwardingObjective.Builder objective = DefaultForwardingObjective
.builder().withTreatment(treatment.build())
.withSelector(selector).fromApp(appId).withFlag(Flag.SPECIFIC)
.withPriority(L3FWD_PRIORITY);
if (type.equals(Objective.Operation.ADD)) {
log.debug("RouteRules-->ADD");
flowObjectiveService.forward(deviceId, objective.add());
} else {
log.debug("RouteRules-->REMOVE");
flowObjectiveService.forward(deviceId, objective.remove());
}
}
示例6: programSnatSameSegmentUploadControllerRules
import org.onosproject.net.flow.instructions.Instructions; //导入依赖的package包/类
@Override
public void programSnatSameSegmentUploadControllerRules(DeviceId deviceId,
SegmentationId matchVni,
IpAddress srcIP,
IpAddress dstIP,
IpPrefix prefix,
Operation type) {
TrafficSelector selector = DefaultTrafficSelector.builder()
.matchEthType(Ethernet.TYPE_IPV4)
.matchTunnelId(Long.parseLong(matchVni.segmentationId()))
.matchIPSrc(IpPrefix.valueOf(srcIP, PREFIC_LENGTH))
.matchIPDst(IpPrefix.valueOf(dstIP, prefix.prefixLength()))
.build();
TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
treatment.add(Instructions.createOutput(PortNumber.CONTROLLER));
ForwardingObjective.Builder objective = DefaultForwardingObjective
.builder().withTreatment(treatment.build())
.withSelector(selector).fromApp(appId).withFlag(Flag.SPECIFIC)
.withPriority(SNAT_SAME_SEG_CON_PRIORITY);
if (type.equals(Objective.Operation.ADD)) {
flowObjectiveService.forward(deviceId, objective.add());
} else {
flowObjectiveService.forward(deviceId, objective.remove());
}
}
示例7: nextBatch
import org.onosproject.net.flow.instructions.Instructions; //导入依赖的package包/类
private List<FlowRule> nextBatch(int size) {
List<FlowRule> rules = Lists.newArrayList();
for (int i = 0; i < size; ++i) {
Device device = devices.next();
long srcMac = macIndex.incrementAndGet();
long dstMac = srcMac + 1;
TrafficSelector selector = DefaultTrafficSelector.builder()
.matchEthSrc(MacAddress.valueOf(srcMac))
.matchEthDst(MacAddress.valueOf(dstMac))
.matchInPort(PortNumber.portNumber(2))
.build();
TrafficTreatment treatment = DefaultTrafficTreatment.builder()
.add(Instructions.createOutput(PortNumber.portNumber(3))).build();
FlowRule rule = new DefaultFlowRule(device.id(),
selector,
treatment,
100,
appId,
50000,
true,
null);
rules.add(rule);
}
return rules;
}
示例8: DefaultTrafficTreatment
import org.onosproject.net.flow.instructions.Instructions; //导入依赖的package包/类
/**
* Creates a new traffic treatment from the specified list of instructions.
*
* @param deferred deferred instructions
* @param immediate immediate instructions
* @param table table transition instruction
* @param clear instruction to clear the deferred actions list
*/
private DefaultTrafficTreatment(List<Instruction> deferred,
List<Instruction> immediate,
Instructions.TableTypeTransition table,
boolean clear,
Instructions.MetadataInstruction meta,
Instructions.MeterInstruction meter) {
this.immediate = ImmutableList.copyOf(checkNotNull(immediate));
this.deferred = ImmutableList.copyOf(checkNotNull(deferred));
this.all = new ImmutableList.Builder<Instruction>()
.addAll(immediate)
.addAll(deferred)
.build();
this.table = table;
this.meta = meta;
this.hasClear = clear;
this.meter = meter;
}
示例9: read
import org.onosproject.net.flow.instructions.Instructions; //导入依赖的package包/类
@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);
DriverService driverService = DefaultServiceDirectory.getService(DriverService.class);
DriverHandler handler = new DefaultDriverHandler(
new DefaultDriverData(driverService.getDriver(deviceId), deviceId));
ExtensionTreatmentResolver resolver = handler.behaviour(ExtensionTreatmentResolver.class);
ExtensionTreatment instruction = resolver.getExtensionInstruction(exType);
byte[] bytes = (byte[]) kryo.readClassAndObject(input);
instruction.deserialize(bytes);
return Instructions.extension(instruction, deviceId);
}
示例10: encodeExtension
import org.onosproject.net.flow.instructions.Instructions; //导入依赖的package包/类
/**
* Encodes a extension instruction.
*
* @param result json node that the instruction attributes are added to
*/
private void encodeExtension(ObjectNode result) {
final Instructions.ExtensionInstructionWrapper extensionInstruction =
(Instructions.ExtensionInstructionWrapper) instruction;
DeviceId deviceId = extensionInstruction.deviceId();
ServiceDirectory serviceDirectory = new DefaultServiceDirectory();
DeviceService deviceService = serviceDirectory.get(DeviceService.class);
Device device = deviceService.getDevice(deviceId);
if (device.is(ExtensionTreatmentCodec.class)) {
ExtensionTreatmentCodec treatmentCodec = device.as(ExtensionTreatmentCodec.class);
ObjectNode node = treatmentCodec.encode(extensionInstruction.extensionInstruction(), context);
result.set(InstructionCodec.EXTENSION, node);
} else {
log.warn("There is no codec to encode extension for device {}", deviceId.toString());
}
}
示例11: decodeL1
import org.onosproject.net.flow.instructions.Instructions; //导入依赖的package包/类
/**
* Decodes a Layer 1 instruction.
*
* @return instruction object decoded from the JSON
* @throws IllegalArgumentException if the JSON is invalid
*/
private Instruction decodeL1() {
String subType = json.get(InstructionCodec.SUBTYPE).asText();
if (subType.equals(L1ModificationInstruction.L1SubType.ODU_SIGID.name())) {
int tributaryPortNumber = nullIsIllegal(json.get(InstructionCodec.TRIBUTARY_PORT_NUMBER),
InstructionCodec.TRIBUTARY_PORT_NUMBER + InstructionCodec.MISSING_MEMBER_MESSAGE).asInt();
int tributarySlotLen = nullIsIllegal(json.get(InstructionCodec.TRIBUTARY_SLOT_LEN),
InstructionCodec.TRIBUTARY_SLOT_LEN + InstructionCodec.MISSING_MEMBER_MESSAGE).asInt();
byte[] tributarySlotBitmap = null;
tributarySlotBitmap = HexString.fromHexString(
nullIsIllegal(json.get(InstructionCodec.TRIBUTARY_SLOT_BITMAP),
InstructionCodec.TRIBUTARY_SLOT_BITMAP + InstructionCodec.MISSING_MEMBER_MESSAGE).asText());
return Instructions.modL1OduSignalId(OduSignalId.oduSignalId(tributaryPortNumber, tributarySlotLen,
tributarySlotBitmap));
}
throw new IllegalArgumentException("L1 Instruction subtype "
+ subType + " is not supported");
}
示例12: decodeExtension
import org.onosproject.net.flow.instructions.Instructions; //导入依赖的package包/类
/**
* Decodes a extension instruction.
*
* @return extension treatment
*/
private Instruction decodeExtension() {
ObjectNode node = (ObjectNode) json.get(InstructionCodec.EXTENSION);
if (node != null) {
DeviceId deviceId = getDeviceId();
ServiceDirectory serviceDirectory = new DefaultServiceDirectory();
DeviceService deviceService = serviceDirectory.get(DeviceService.class);
Device device = deviceService.getDevice(deviceId);
if (device.is(ExtensionTreatmentCodec.class)) {
ExtensionTreatmentCodec treatmentCodec = device.as(ExtensionTreatmentCodec.class);
ExtensionTreatment treatment = treatmentCodec.decode(node, null);
return Instructions.extension(treatment, deviceId);
} else {
log.warn("There is no codec to decode extension for device {}", deviceId.toString());
}
}
return null;
}
示例13: codecSimpleFlowTest
import org.onosproject.net.flow.instructions.Instructions; //导入依赖的package包/类
/**
* Checks that a simple rule decodes properly.
*
* @throws IOException if the resource cannot be processed
*/
@Test
public void codecSimpleFlowTest() throws IOException {
FlowRule rule = getRule("simple-flow.json");
checkCommonData(rule);
assertThat(rule.selector().criteria().size(), is(1));
Criterion criterion1 = rule.selector().criteria().iterator().next();
assertThat(criterion1.type(), is(Criterion.Type.ETH_TYPE));
assertThat(((EthTypeCriterion) criterion1).ethType(), is(new EthType(2054)));
assertThat(rule.treatment().allInstructions().size(), is(1));
Instruction instruction1 = rule.treatment().allInstructions().get(0);
assertThat(instruction1.type(), is(Instruction.Type.OUTPUT));
assertThat(((Instructions.OutputInstruction) instruction1).port(), is(PortNumber.CONTROLLER));
}
示例14: testTrafficTreatmentEncode
import org.onosproject.net.flow.instructions.Instructions; //导入依赖的package包/类
/**
* Tests encoding of a traffic treatment object.
*/
@Test
public void testTrafficTreatmentEncode() {
Instruction output = Instructions.createOutput(PortNumber.portNumber(0));
Instruction modL2Src = Instructions.modL2Src(MacAddress.valueOf("11:22:33:44:55:66"));
Instruction modL2Dst = Instructions.modL2Dst(MacAddress.valueOf("44:55:66:77:88:99"));
MeterId meterId = MeterId.meterId(0);
Instruction meter = Instructions.meterTraffic(meterId);
Instruction transition = Instructions.transition(1);
TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder();
TrafficTreatment treatment = tBuilder
.add(output)
.add(modL2Src)
.add(modL2Dst)
.add(meter)
.add(transition)
.build();
ObjectNode treatmentJson = trafficTreatmentCodec.encode(treatment, context);
assertThat(treatmentJson, TrafficTreatmentJsonMatcher.matchesTrafficTreatment(treatment));
}
示例15: 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;
}