下面列出了io.fabric8.kubernetes.api.model.EndpointSubset#org.onosproject.net.flow.TrafficTreatment 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public void run() {
TrafficSelector selector = DefaultTrafficSelector.emptySelector();
TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
List<Constraint> constraint = Lists.newArrayList();
List<Host> hosts = Lists.newArrayList(hostService.getHosts());
while (!hosts.isEmpty()) {
Host src = hosts.remove(0);
for (Host dst : hosts) {
HostToHostIntent intent = HostToHostIntent.builder()
.appId(appId)
.one(src.id())
.two(dst.id())
.selector(selector)
.treatment(treatment)
.constraints(constraint)
.build();
existingIntents.add(intent);
intentService.submit(intent);
}
}
}
/**
* Returns the next objective of type simple associated with the port on the
* device, given the treatment. Different treatments to the same port result
* in different next objectives. If no such objective exists, this method
* creates one (if requested) and returns the id. Optionally metadata can be passed in for
* the creation of the objective. Typically this is used for L2 and L3 forwarding
* to compute nodes and containers/VMs on the compute nodes directly attached
* to the switch.
*
* @param portNum the port number for the simple next objective
* @param treatment the actions to apply on the packets (should include outport)
* @param meta optional metadata passed into the creation of the next objective
* @param createIfMissing true if a next object should be created if not found
* @return int if found or created, -1 if there are errors during the
* creation of the next objective.
*/
public int getPortNextObjectiveId(PortNumber portNum, TrafficTreatment treatment,
TrafficSelector meta, boolean createIfMissing) {
Integer nextId = portNextObjStore
.get(new PortNextObjectiveStoreKey(deviceId, portNum, treatment, meta));
if (nextId != null) {
return nextId;
}
log.debug("getPortNextObjectiveId in device {}: Next objective id "
+ "not found for port: {} .. {}", deviceId, portNum,
(createIfMissing) ? "creating" : "aborting");
if (!createIfMissing) {
return -1;
}
// create missing next objective
createGroupFromPort(portNum, treatment, meta);
nextId = portNextObjStore.get(new PortNextObjectiveStoreKey(deviceId, portNum,
treatment, meta));
if (nextId == null) {
log.warn("getPortNextObjectiveId: unable to create next obj"
+ "for dev:{} port:{}", deviceId, portNum);
return -1;
}
return nextId;
}
private static TrafficTreatment nextIdOrTreatment(
ForwardingObjective obj, PiTableId tableId)
throws FabricPipelinerException {
if (obj.nextId() == null) {
return obj.treatment();
} else {
if (!NEXT_ID_ACTIONS.containsKey(tableId)) {
throw new FabricPipelinerException(format(
"BUG? no next_id action set for table %s", tableId));
}
return DefaultTrafficTreatment.builder()
.piTableAction(
setNextIdAction(obj.nextId(),
NEXT_ID_ACTIONS.get(tableId)))
.build();
}
}
/**
* Map treatment for hashed table to routing v4 action.
*/
@Test
public void testNextTreatmentHashedRoutingMpls() throws Exception {
TrafficTreatment treatment = DefaultTrafficTreatment.builder()
.setEthSrc(SRC_MAC)
.setEthDst(DST_MAC)
.setOutput(PORT_1)
.pushMpls()
.setMpls(MPLS_10)
.build();
PiAction mappedAction = interpreter.mapTreatment(
treatment, FabricConstants.FABRIC_INGRESS_NEXT_HASHED);
PiActionParam ethSrcParam = new PiActionParam(FabricConstants.SMAC, SRC_MAC.toBytes());
PiActionParam ethDstParam = new PiActionParam(FabricConstants.DMAC, DST_MAC.toBytes());
PiActionParam portParam = new PiActionParam(FabricConstants.PORT_NUM, PORT_1.toLong());
PiActionParam mplsParam = new PiActionParam(FabricConstants.LABEL, MPLS_10.toInt());
PiAction expectedAction = PiAction.builder()
.withId(FabricConstants.FABRIC_INGRESS_NEXT_MPLS_ROUTING_HASHED)
.withParameters(ImmutableList.of(ethSrcParam, ethDstParam, portParam, mplsParam))
.build();
assertEquals(expectedAction, mappedAction);
}
/**
* Tests adding a filtering objective.
*/
@Test
public void filteringObjective() {
TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
FilteringObjective filter =
DefaultFilteringObjective.builder()
.fromApp(NetTestTools.APP_ID)
.withMeta(treatment)
.makePermanent()
.deny()
.addCondition(Criteria.matchEthType(12))
.add(new ObjectiveContext() {
@Override
public void onSuccess(Objective objective) {
assertEquals("1 flowrule entry expected",
1,
flowRuleStore.getFlowRuleCount(vnet1.id()));
assertEquals("0 flowrule entry expected",
0,
flowRuleStore.getFlowRuleCount(vnet2.id()));
}
});
service1.filter(VDID1, filter);
}
/**
* Gets traffic treatment from a next objective.
* Merge traffic treatments from next objective if the next objective is
* BROADCAST type and contains multiple traffic treatments.
* Returns first treatment from next objective if the next objective is
* SIMPLE type and it contains only one treatment.
*
* @param nextObjective the next objective
* @return the treatment from next objective; null if not supported
*/
private TrafficTreatment getTreatment(NextObjective nextObjective) {
Collection<TrafficTreatment> treatments = nextObjective.next();
switch (nextObjective.type()) {
case SIMPLE:
if (treatments.size() != 1) {
log.error("Next Objectives of type SIMPLE should have only " +
"one traffic treatment. NexObjective: {}",
nextObjective.toString());
return null;
}
return treatments.iterator().next();
case BROADCAST:
TrafficTreatment.Builder builder = DefaultTrafficTreatment.builder();
treatments.forEach(builder::addTreatment);
return builder.build();
default:
log.error("Unsupported next objective type {}.", nextObjective.type());
return null;
}
}
private void setIcmpReplyRules(DeviceId deviceId, boolean install) {
// Sends ICMP response to controller for SNATing ingress traffic
TrafficSelector selector = DefaultTrafficSelector.builder()
.matchEthType(Ethernet.TYPE_IPV4)
.matchIPProtocol(IPv4.PROTOCOL_ICMP)
.matchIcmpType(ICMP.TYPE_ECHO_REPLY)
.build();
TrafficTreatment treatment = DefaultTrafficTreatment.builder()
.punt()
.build();
osFlowRuleService.setRule(
appId,
deviceId,
selector,
treatment,
PRIORITY_INTERNAL_ROUTING_RULE,
GW_COMMON_TABLE,
install);
}
@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());
}
}
private Group createSouthboundGroupEntry(GroupId gId,
List<PortNumber> ports,
long referenceCount, DeviceId deviceId) {
List<PortNumber> outPorts = new ArrayList<>();
outPorts.addAll(ports);
List<GroupBucket> buckets = new ArrayList<>();
for (PortNumber portNumber : outPorts) {
TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder();
tBuilder.setOutput(portNumber)
.setEthDst(MacAddress.valueOf("00:00:00:00:00:02"))
.setEthSrc(MacAddress.valueOf("00:00:00:00:00:01"))
.pushMpls()
.setMpls(MplsLabel.mplsLabel(106));
buckets.add(DefaultGroupBucket.createSelectGroupBucket(
tBuilder.build()));
}
GroupBuckets groupBuckets = new GroupBuckets(buckets);
StoredGroupEntry group = new DefaultGroup(
gId, deviceId, Group.Type.SELECT, groupBuckets);
group.setReferenceCount(referenceCount);
return group;
}
public static ForwardingObjective composeSequential(ForwardingObjective fo1,
ForwardingObjective fo2,
int priorityMultiplier) {
TrafficSelector revertTrafficSelector = revertTreatmentSelector(fo1.treatment(), fo2.selector());
if (revertTrafficSelector == null) {
return null;
}
TrafficSelector trafficSelector = intersectTrafficSelector(fo1.selector(), revertTrafficSelector);
if (trafficSelector == null) {
return null;
}
TrafficTreatment trafficTreatment = unionTrafficTreatment(fo1.treatment(), fo2.treatment());
return DefaultForwardingObjective.builder()
.fromApp(fo1.appId())
.makePermanent()
.withFlag(ForwardingObjective.Flag.VERSATILE)
.withPriority(fo1.priority() * priorityMultiplier + fo2.priority())
.withSelector(trafficSelector)
.withTreatment(trafficTreatment)
.add();
}
private List<Intent> generateIntents(ConnectPoint ingress, ConnectPoint egress) {
TrafficSelector.Builder selectorBldr = DefaultTrafficSelector.builder()
.matchEthType(Ethernet.TYPE_IPV4);
TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
List<Intent> intents = Lists.newArrayList();
for (long i = 0; i < count; i++) {
TrafficSelector selector = selectorBldr
.matchEthSrc(MacAddress.valueOf(i + keyOffset))
.build();
intents.add(
PointToPointIntent.builder()
.appId(appId())
.key(Key.of(i + keyOffset, appId()))
.selector(selector)
.treatment(treatment)
.filteredIngressPoint(new FilteredConnectPoint(ingress))
.filteredEgressPoint(new FilteredConnectPoint(egress))
.build());
}
return intents;
}
/**
* Tests whether the set rule method installs the flow rules properly.
*/
@Test
public void testSetRule() {
int testPriority = 10;
int testTableType = 10;
fros = Sets.newConcurrentHashSet();
TrafficSelector.Builder selectorBuilder = DefaultTrafficSelector.builder();
TrafficTreatment.Builder treatmentBuilder = DefaultTrafficTreatment.builder();
FlowRule.Builder flowRuleBuilder = DefaultFlowRule.builder()
.forDevice(DEVICE_ID)
.withSelector(selectorBuilder.build())
.withTreatment(treatmentBuilder.build())
.withPriority(testPriority)
.fromApp(TEST_APP_ID)
.forTable(testTableType)
.makePermanent();
target.setRule(TEST_APP_ID, DEVICE_ID, selectorBuilder.build(),
treatmentBuilder.build(), testPriority, testTableType, true);
validateFlowRule(flowRuleBuilder.build());
}
/**
* Generates the corresponding flow rules for the physical network.
*
* @param networkId The virtual network identifier
* @param ingressPoint The ingress point of the physical network
* @param egressPoint The egress point of the physical network
* @param commonSelector A common traffic selector between the virtual
* and physical flow rules
* @param commonTreatment A common traffic treatment between the virtual
* and physical flow rules
* @param flowRule The virtual flow rule to be translated
* @return A set of flow rules for the physical network
*/
private Set<FlowRule> generateRules(NetworkId networkId,
ConnectPoint ingressPoint,
ConnectPoint egressPoint,
TrafficSelector commonSelector,
TrafficTreatment commonTreatment,
FlowRule flowRule) {
if (ingressPoint.deviceId().equals(egressPoint.deviceId()) ||
egressPoint.port().isLogical()) {
return generateRuleForSingle(networkId, ingressPoint, egressPoint,
commonSelector, commonTreatment, flowRule);
} else {
return generateRuleForMulti(networkId, ingressPoint, egressPoint,
commonSelector, commonTreatment, flowRule);
}
}
@Override
public void setRule(ApplicationId appId, DeviceId deviceId,
TrafficSelector selector, TrafficTreatment treatment,
int priority, int tableType, boolean install) {
FlowRule.Builder flowRuleBuilder = DefaultFlowRule.builder()
.forDevice(deviceId)
.withSelector(selector)
.withTreatment(treatment)
.withPriority(priority)
.fromApp(appId)
.forTable(tableType);
if (priority == PRIORITY_SNAT_RULE) {
flowRuleBuilder.makeTemporary(TIMEOUT_SNAT_RULE);
} else {
flowRuleBuilder.makePermanent();
}
applyRule(flowRuleBuilder.build(), install);
}
private void processCosTable(boolean install) {
TrafficTreatment.Builder treatment = DefaultTrafficTreatment
.builder()
.transition(FIB_TABLE);
TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
FlowRule rule = DefaultFlowRule.builder()
.forDevice(deviceId)
.withSelector(selector.build())
.withTreatment(treatment.build())
.withPriority(DROP_PRIORITY)
.fromApp(appId)
.makePermanent()
.forTable(COS_MAP_TABLE).build();
processFlowRule(true, rule, "Provisioned cos table");
}
protected void processTaggedPackets(boolean install) {
TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
selector.matchVlanId(VlanId.ANY);
TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
treatment.transition(VLAN_MAC_XLATE_TABLE);
FlowRule rule = DefaultFlowRule.builder()
.forDevice(deviceId)
.withSelector(selector.build())
.withTreatment(treatment.build())
.withPriority(CONTROLLER_PRIORITY)
.fromApp(appId)
.makePermanent()
.forTable(VLAN_CHECK_TABLE).build();
processFlowRule(install, rule, "Provisioned vlan table tagged packets");
}
/**
* Pushes the flow rules for forwarding BGP TCP packets to controller.
* It is called when switches are connected and available.
*/
public void notifySwitchAvailable() {
// control plane OVS is available, push default flows
TrafficSelector selectorDst = DefaultTrafficSelector.builder()
.matchEthType(Ethernet.TYPE_IPV4)
.matchIPProtocol(IPv4.PROTOCOL_TCP)
.matchTcpDst(TpPort.tpPort(BGP_PORT))
.build();
TrafficSelector selectorSrc = DefaultTrafficSelector.builder()
.matchEthType(Ethernet.TYPE_IPV4)
.matchIPProtocol(IPv4.PROTOCOL_TCP)
.matchTcpSrc(TpPort.tpPort(BGP_PORT))
.build();
TrafficTreatment treatment = DefaultTrafficTreatment.builder()
.punt()
.build();
ForwardingObjective puntSrc = DefaultForwardingObjective.builder()
.fromApp(appId)
.makePermanent()
.withSelector(selectorSrc)
.withTreatment(treatment)
.withFlag(ForwardingObjective.Flag.VERSATILE)
.add();
flowObjectiveService.forward(bgpSpeaker.connectPoint().deviceId(),
puntSrc);
ForwardingObjective puntDst = DefaultForwardingObjective.builder()
.fromApp(appId)
.makePermanent()
.withSelector(selectorDst)
.withTreatment(treatment)
.withFlag(ForwardingObjective.Flag.VERSATILE)
.add();
flowObjectiveService.forward(bgpSpeaker.connectPoint().deviceId(),
puntDst);
log.info("Sent punt forwarding objective to {}", bgpSpeaker.connectPoint().deviceId());
}
@Test
public void removeVirtualizeFlowRule() {
TrafficSelector ts = DefaultTrafficSelector.builder().build();
TrafficTreatment tr = DefaultTrafficTreatment.builder()
.setOutput(PORT_NUM2).build();
FlowRule r1 = DefaultFlowRule.builder()
.forDevice(VDID)
.withSelector(ts)
.withTreatment(tr)
.withPriority(10)
.fromApp(vAppId)
.makeTemporary(TIMEOUT)
.build();
virtualProvider.removeFlowRule(VNET_ID, r1);
assertEquals("0 rules should exist", 0,
virtualProvider.flowRuleService.getFlowRuleCount());
}
private void setDefaultArpRuleForProxyMode(OpenstackNode osNode,
boolean install) {
TrafficSelector selector = DefaultTrafficSelector.builder()
.matchEthType(EthType.EtherType.ARP.ethType().toShort())
.build();
TrafficTreatment treatment = DefaultTrafficTreatment.builder()
.punt()
.build();
osFlowRuleService.setRule(
appId,
osNode.intgBridge(),
selector,
treatment,
PRIORITY_ARP_CONTROL_RULE,
GW_COMMON_TABLE,
install
);
}
private ForwardingObjective.Builder getMplsInBuilder(DeviceId deviceId,
Host host,
Label label) {
TrafficTreatment.Builder builder = DefaultTrafficTreatment.builder();
TrafficSelector selector = DefaultTrafficSelector.builder()
.matchInPort(getTunnlePort(deviceId))
.matchEthType(EthType.EtherType.MPLS_UNICAST.ethType()
.toShort())
.matchMplsBos(true)
.matchMplsLabel(MplsLabel.mplsLabel(label.getLabel())).build();
TrafficTreatment treatment = builder.popMpls(EthType
.EtherType
.IPV4.ethType())
.setOutput(host.location().port()).build();
return DefaultForwardingObjective
.builder().withTreatment(treatment).withSelector(selector)
.fromApp(appId).withFlag(ForwardingObjective.Flag.SPECIFIC)
.withPriority(60000);
}
private void processRouterPacket(boolean install) {
deviceService.getPorts(deviceId).forEach(port -> {
if (!port.number().isLogical()) {
TrafficSelector.Builder selector = DefaultTrafficSelector.builder()
.matchVlanId(VlanId.vlanId(NATIVE_VLAN))
.matchInPort(port.number());
TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder()
.setVlanPcp((byte) 0)
.setQueue(0)
.meter(defaultMeterId)
.transition(L3_IF_MAC_DA_TABLE);
FlowRule rule = DefaultFlowRule.builder()
.forDevice(deviceId)
.withSelector(selector.build())
.withTreatment(treatment.build())
.withPriority(CONTROLLER_PRIORITY)
.fromApp(appId)
.makePermanent()
.forTable(VLAN_CIRCUIT_TABLE).build();
processFlowRule(install, rule, "Provisioned vlan circuit table");
}
});
}
@Override
public FlowId createConnection(DeviceId deviceId, int priority, boolean isPermanent,
int timeout, PortNumber inPort, PortNumber outPort, OchSignal ochSignal) {
checkNotNull(deviceId);
checkNotNull(inPort);
checkNotNull(outPort);
//Creation of selector.
TrafficSelector selector = DefaultTrafficSelector.builder()
.add(Criteria.matchInPort(inPort))
.add(Criteria.matchOchSignalType(OchSignalType.FIXED_GRID))
.add(Criteria.matchLambda(ochSignal))
.build();
//Creation of treatment
TrafficTreatment treatment = DefaultTrafficTreatment.builder()
.add(Instructions.modL0Lambda(ochSignal))
.add(Instructions.createOutput(outPort))
.build();
FlowRule.Builder flowBuilder = DefaultFlowRule.builder()
.forDevice(deviceId)
.fromApp(appId)
.withPriority(priority)
.withSelector(selector)
.withTreatment(treatment);
if (isPermanent) {
flowBuilder.makePermanent();
} else {
flowBuilder.makeTemporary(timeout);
}
FlowRule flowRule = flowBuilder.build();
flowRuleService.applyFlowRules(flowRule);
log.info("Created connection from input port {} to output port {}",
inPort.toLong(), outPort.toLong());
return flowRule.id();
}
protected FlowRule.Builder processEthFiler(FilteringObjective filt, EthCriterion eth, PortCriterion port) {
log.debug("adding rule for MAC: {}", eth.mac());
TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
selector.matchEthDst(eth.mac());
treatment.transition(VLAN_MPLS_TABLE);
return DefaultFlowRule.builder()
.forDevice(deviceId)
.withSelector(selector.build())
.withTreatment(treatment.build())
.withPriority(CONTROLLER_PRIORITY)
.makePermanent()
.forTable(MAC_TABLE);
}
/**
* Forwards a BGP packet to another connect point.
*
* @param context the packet context of the incoming packet
*/
private void forward(PacketContext context) {
ConnectPoint outputPort = null;
IPv4 ipv4 = (IPv4) context.inPacket().parsed().getPayload();
IpAddress dstAddress = IpAddress.valueOf(ipv4.getDestinationAddress());
if (context.inPacket().receivedFrom().equals(bgpSpeaker.connectPoint())) {
if (bgpSpeaker.peers().contains(dstAddress)) {
Interface intf = interfaceService.getMatchingInterface(dstAddress);
if (intf != null) {
outputPort = intf.connectPoint();
}
}
} else {
Set<Interface> interfaces =
interfaceService.getInterfacesByPort(context.inPacket().receivedFrom());
if (interfaces.stream()
.flatMap(intf -> intf.ipAddressesList().stream())
.anyMatch(ia -> ia.ipAddress().equals(dstAddress))) {
outputPort = bgpSpeaker.connectPoint();
}
}
if (outputPort != null) {
TrafficTreatment t = DefaultTrafficTreatment.builder()
.setOutput(outputPort.port()).build();
OutboundPacket o = new DefaultOutboundPacket(
outputPort.deviceId(), t, context.inPacket().unparsed());
packetService.emit(o);
}
}
public MockFlowEntry(DeviceId deviceId, long id,
TrafficTreatment treatment,
TrafficSelector selector) {
this.deviceId = deviceId;
this.baseValue = id * 100;
this.treatment = treatment;
this.selector = selector;
}
@Override
protected void doExecute() {
IntentService service = get(IntentService.class);
ConnectPoint ingress = ConnectPoint.deviceConnectPoint(ingressDeviceString);
ConnectPoint egress = ConnectPoint.deviceConnectPoint(egressDeviceString);
TrafficSelector selector = buildTrafficSelector();
TrafficTreatment treatment = buildTrafficTreatment();
List<Constraint> constraints = buildConstraints();
if (backup) {
constraints.add(protection());
}
if (useProtected) {
constraints.add(ProtectedConstraint.useProtectedLink());
}
Intent intent = PointToPointIntent.builder()
.appId(appId())
.key(key())
.selector(selector)
.treatment(treatment)
.filteredIngressPoint(new FilteredConnectPoint(ingress))
.filteredEgressPoint(new FilteredConnectPoint(egress))
.constraints(constraints)
.priority(priority())
.resourceGroup(resourceGroup())
.build();
service.submit(intent);
print("Point to point intent submitted:\n%s", intent.toString());
}
/**
* Test program set vlan and output rule for Simple table.
*/
@Test
public void testSimpleOutputWithVlanTranslation() throws FabricPipelinerException {
TrafficTreatment treatment = DefaultTrafficTreatment.builder()
.setVlanId(VLAN_100)
.setOutput(PORT_1)
.build();
PiAction piAction = PiAction.builder()
.withId(FabricConstants.FABRIC_INGRESS_NEXT_OUTPUT_SIMPLE)
.withParameter(new PiActionParam(
FabricConstants.PORT_NUM, PORT_1.toLong()))
.build();
testSimple(treatment, piAction);
}
@Override
public ObjectNode encode(ForwardingObjective forwardingObjective, CodecContext context) {
checkNotNull(forwardingObjective, NOT_NULL_MESSAGE);
final JsonCodec<TrafficTreatment> trafficTreatmentCodec = context.codec(TrafficTreatment.class);
final JsonCodec<TrafficSelector> trafficSelectorCodec = context.codec(TrafficSelector.class);
// encode common properties
ObjectiveCodecHelper och = new ObjectiveCodecHelper();
ObjectNode result = och.encode(forwardingObjective, context);
// encode id
result.put(ID, forwardingObjective.id());
// encode flag
result.put(FLAG, forwardingObjective.flag().toString());
// encode op
result.put(OPERATION, forwardingObjective.op().toString());
// encode selector
ObjectNode trafficSelectorNode =
trafficSelectorCodec.encode(forwardingObjective.selector(), context);
result.set(SELECTOR, trafficSelectorNode);
// encode nextId
if (forwardingObjective.nextId() != null) {
result.put(NEXT_ID, forwardingObjective.nextId());
}
// encode treatment
if (forwardingObjective.treatment() != null) {
ObjectNode trafficTreatmentNode =
trafficTreatmentCodec.encode(forwardingObjective.treatment(), context);
result.set(TREATMENT, trafficTreatmentNode);
}
return result;
}
private ObjectNode jsonTreatment(FlowEntry flow) {
ObjectNode treat = objectNode();
TrafficTreatment treatment = flow.treatment();
List<Instruction> imm = Lists.newArrayList(treatment.immediate());
List<Instruction> def = treatment.deferred();
Set<Instructions.MeterInstruction> meter = treatment.meters();
Instructions.TableTypeTransition table = treatment.tableTransition();
Instructions.MetadataInstruction meta = treatment.writeMetadata();
if (!imm.isEmpty()) {
treat.set(IMMED, jsonInstrList(imm));
}
if (!def.isEmpty()) {
treat.set(DEFER, jsonInstrList(def));
}
if (!meter.isEmpty()) {
treat.set(METER, jsonInstrList(Lists.newArrayList(meter)));
}
if (table != null) {
treat.put(TABLE, table.toString());
}
if (meta != null) {
treat.put(META, meta.toString());
}
treat.put(CLEARDEF, treatment.clearedDeferred());
return treat;
}
private void provisionEapol(FilteringObjective filter,
EthTypeCriterion ethType,
Instructions.OutputInstruction output) {
TrafficSelector selector = buildSelector(filter.key(), ethType);
TrafficTreatment treatment = buildTreatment(output);
buildAndApplyRule(filter, selector, treatment, EAPOL_FLOW_PRIORITY);
}