public static ForwardingObjective composeOverride(ForwardingObjective fo, int priorityAddend) { return DefaultForwardingObjective.builder() .fromApp(fo.appId()) .makePermanent() .withFlag(fo.flag()) .withPriority(fo.priority() + priorityAddend) .withSelector(fo.selector()) .withTreatment(fo.treatment()) .add(); }
private ForwardingObjective buildForwardingObjective(TrafficSelector selector, Integer nextId, int priority) { return DefaultForwardingObjective.builder() .withMeta(selector) .withSelector(selector) .nextStep(nextId) .fromApp(appId) .withPriority(priority) .withFlag(ForwardingObjective.Flag.SPECIFIC) .makePermanent() .add(); }
@Override public void removeSnatRules(DeviceId deviceId, TrafficSelector selector, TrafficTreatment treatment, int priority, Objective.Operation type) { ForwardingObjective.Builder objective = DefaultForwardingObjective .builder().withTreatment(treatment).withSelector(selector) .fromApp(appId).withFlag(Flag.SPECIFIC).withPriority(priority); if (type.equals(Objective.Operation.ADD)) { flowObjectiveService.forward(deviceId, objective.add()); } else { flowObjectiveService.forward(deviceId, objective.remove()); } } }
private void sendFilteringObjective(boolean install, FilteringObjective.Builder fob, Interface intf) { ObjectiveContext context = new DefaultObjectiveContext( (objective) -> log.info("Installed filter for interface {}", intf), (objective, error) -> log.error("Failed to install filter for interface {}: {}", intf, error)); FilteringObjective filter = install ? fob.add(context) : fob.remove(context); flowObjectiveService.filter(deviceId, filter); }
public static ForwardingObjective composeParallel(ForwardingObjective fo1, ForwardingObjective fo2) { TrafficSelector trafficSelector = intersectTrafficSelector(fo1.selector(), fo2.selector()); 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() + fo2.priority()) .withSelector(trafficSelector) .withTreatment(trafficTreatment) .add(); }
private synchronized void deleteRoute(ResolvedRoute route) { //Integer nextId = nextHops.get(route.nextHop()); /* Group group = deleteNextHop(route.prefix()); if (group == null) { log.warn("Group not found when deleting {}", route); return; }*/ flowObjectiveService.forward(deviceId, generateRibForwardingObj(route.prefix(), null).remove()); }