/** * Traffic treatment builder function. * * @param container container need to be pushed. * @return the traffic treatment builder */ public TrafficTreatment.Builder packTrafficTreatment(ExtFlowContainer container) { TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); return treatment; }
@Override public void emitPacket(DeviceId deviceId, ByteBuffer data, Optional<TrafficTreatment> treatment) { TrafficTreatment.Builder builder = treatment.map(DefaultTrafficTreatment::builder) .orElse(DefaultTrafficTreatment.builder()); getEdgePoints(deviceId).forEach(p -> packetService.emit(packet(builder, p, data))); }
private TrafficTreatment buildTreatment(Instruction... instructions) { TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder(); for (Instruction i : instructions) { tBuilder.add(i); } return tBuilder.build(); }
@Override public void emitPacket(ByteBuffer data, Optional<TrafficTreatment> treatment) { checkPermission(PACKET_WRITE); TrafficTreatment.Builder builder = treatment.map(DefaultTrafficTreatment::builder) .orElse(DefaultTrafficTreatment.builder()); getEdgePoints().forEach(p -> packetService.emit(packet(builder, p, data))); }
private void sendPacketOut(DeviceId deviceId, PortNumber portNumber, Ethernet payload) { TrafficTreatment treatment = DefaultTrafficTreatment.builder() .setOutput(portNumber).build(); OutboundPacket packet = new DefaultOutboundPacket(deviceId, treatment, ByteBuffer .wrap(payload .serialize())); packetService.emit(packet); }
private TrafficTreatment buildFailoverTreatment(DeviceId srcDevice, GroupKey groupKey) { Group group = waitForGroup(srcDevice, groupKey); TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder(); TrafficTreatment trafficTreatment = tBuilder.group(group.id()).build(); return trafficTreatment; }
public static TrafficTreatment unionTrafficTreatment(TrafficTreatment tt1, TrafficTreatment tt2) { TrafficTreatment.Builder treatmentBuilder = DefaultTrafficTreatment.builder(); for (Instruction instruction : tt1.allInstructions()) { treatmentBuilder.add(instruction); } for (Instruction instruction : tt2.allInstructions()) { treatmentBuilder.add(instruction); } return treatmentBuilder.build(); }
private TrafficTreatment buildTreatment(List<OFAction> actions) { DriverHandler driverHandler = getDriver(dpid); TrafficTreatment.Builder builder = DefaultTrafficTreatment.builder(); // If this is a drop rule if (actions.size() == 0) { builder.drop(); return builder.build(); } return FlowEntryBuilder.configureTreatmentBuilder(actions, builder, driverHandler, DeviceId.deviceId(Dpid.uri(dpid))).build(); }
private void updateFailoverGroup(PointToPointIntent intent, List<Link> links) { GroupKey groupKey = makeGroupKey(intent.id()); TrafficTreatment.Builder tBuilderIn = DefaultTrafficTreatment.builder(); ConnectPoint src = links.get(0).src(); tBuilderIn.setOutput(src.port()); GroupBucket bucket = DefaultGroupBucket.createFailoverGroupBucket(tBuilderIn.build(), src.port(), null); GroupBuckets addBuckets = new GroupBuckets(Collections.singletonList(bucket)); groupService.addBucketsToGroup(src.deviceId(), groupKey, addBuckets, groupKey, intent.appId()); }
/** * Send packet back to classifier. * * @param context packet context */ private void sendPacket(PacketContext context) { ConnectPoint sourcePoint = context.inPacket().receivedFrom(); TrafficTreatment treatment = DefaultTrafficTreatment.builder().setOutput(PortNumber.TABLE).build(); OutboundPacket packet = new DefaultOutboundPacket(sourcePoint.deviceId(), treatment, context.inPacket() .unparsed()); packetService.emit(packet); log.trace("Sending packet: {}", packet); } }
private void setFlowRuleForTunnelTag(DeviceId deviceId, Port port, String vni) { TrafficSelector.Builder sBuilder = DefaultTrafficSelector.builder(); TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder(); sBuilder.matchEthType(Ethernet.TYPE_IPV4) .matchInPort(port.number()); tBuilder.setTunnelId(Long.parseLong(vni)); ForwardingObjective fo = DefaultForwardingObjective.builder() .withSelector(sBuilder.build()) .withTreatment(tBuilder.build()) .withPriority(TUNNELTAG_RULE_PRIORITY) .withFlag(ForwardingObjective.Flag.SPECIFIC) .fromApp(appId) .add(); flowObjectiveService.forward(deviceId, fo); }
private DefaultForwardingObjective.Builder createBuilder(PacketRequest request) { TrafficTreatment treatment = DefaultTrafficTreatment.builder() .punt() .wipeDeferred() .build(); return DefaultForwardingObjective.builder() .withPriority(request.priority().priorityValue()) .withSelector(request.selector()) .fromApp(appId) .withFlag(ForwardingObjective.Flag.VERSATILE) .withTreatment(treatment) .makePermanent(); }
private void processClassifierTable(boolean install) { TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); treatment.transition(MAC_TABLE); FlowRule rule; rule = DefaultFlowRule.builder().forDevice(deviceId) .withSelector(selector.build()) .withTreatment(treatment.build()) .withPriority(TABLE_MISS_PRIORITY).fromApp(appId) .makePermanent().forTable(CLASSIFIER_TABLE).build(); applyRules(install, rule); }
private void processArpTable(boolean install) { TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); treatment.transition(MAC_TABLE); FlowRule rule; rule = DefaultFlowRule.builder().forDevice(deviceId) .withSelector(selector.build()) .withTreatment(treatment.build()) .withPriority(TABLE_MISS_PRIORITY).fromApp(appId) .makePermanent().forTable(ARP_TABLE).build(); applyRules(install, rule); }
private void processL3fwdTable(boolean install) { TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); treatment.transition(SNAT_TABLE); FlowRule rule; rule = DefaultFlowRule.builder().forDevice(deviceId) .withSelector(selector.build()) .withTreatment(treatment.build()) .withPriority(TABLE_MISS_PRIORITY).fromApp(appId) .makePermanent().forTable(L3FWD_TABLE).build(); applyRules(install, rule); }
private void processDnatTable(boolean install) { TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); treatment.transition(MAC_TABLE); FlowRule rule; rule = DefaultFlowRule.builder().forDevice(deviceId) .withSelector(selector.build()) .withTreatment(treatment.build()) .withPriority(TABLE_MISS_PRIORITY).fromApp(appId) .makePermanent().forTable(DNAT_TABLE).build(); applyRules(install, rule); }
private void processMacTable(boolean install) { TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); treatment.drop(); FlowRule rule; rule = DefaultFlowRule.builder().forDevice(deviceId) .withSelector(selector.build()) .withTreatment(treatment.build()) .withPriority(TABLE_MISS_PRIORITY).fromApp(appId) .makePermanent().forTable(MAC_TABLE).build(); applyRules(install, rule); }
private void processVniTable(boolean install) { TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); treatment.transition(FORWARDING_TABLE); FlowRule flowRule = DefaultFlowRule.builder() .forDevice(deviceId) .withSelector(selector.build()) .withTreatment(treatment.build()) .withPriority(DROP_PRIORITY) .fromApp(appId) .makePermanent() .forTable(VNI_TABLE) .build(); applyRules(install, flowRule); }
private void processForwardingTable(boolean install) { TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); treatment.drop(); FlowRule flowRule = DefaultFlowRule.builder() .forDevice(deviceId) .withSelector(selector.build()) .withTreatment(treatment.build()) .withPriority(DROP_PRIORITY) .fromApp(appId) .makePermanent() .forTable(FORWARDING_TABLE) .build(); applyRules(install, flowRule); }
private void processSnatTable(boolean install) { TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); treatment.transition(MAC_TABLE); treatment.add(Instructions.createOutput(PortNumber.CONTROLLER)); FlowRule rule; rule = DefaultFlowRule.builder().forDevice(deviceId) .withSelector(selector.build()) .withTreatment(treatment.build()) .withPriority(TABLE_MISS_PRIORITY).fromApp(appId) .makePermanent().forTable(SNAT_TABLE).build(); applyRules(install, rule); }