flowBuilder.setIngressNode(node); flowBuilder.setIngressInterface(null); flowBuilder.setIngressVrf(
break; case VRF: fb.setIngressVrf(loc.getVrf()); break; default:
switch (source.getType()) { case VRF: flow.setIngressVrf(source.getVrf()); break; case INTERFACE_LINK:
fb.setIngressVrf(initiator.getVrfName()); fb.setSrcIp(srcAddress); fb.setDstIp(dstAddress); fb.setIngressVrf(listener.getVrfName()); fb.setSrcIp(forwardFlow.getDstIp()); fb.setDstIp(forwardFlow.getSrcIp());
break; case VRF: flow.setIngressVrf(loc.getVrf()); break; default:
protected static Flow createFlow( IngressLocation ingressLocation, Map<String, Long> constraints, String tag) { Flow.Builder flowBuilder = new Flow.Builder(); switch (ingressLocation.getType()) { case INTERFACE_LINK: flowBuilder .setIngressNode(ingressLocation.getNode()) .setIngressInterface(ingressLocation.getInterface()); break; case VRF: flowBuilder .setIngressNode(ingressLocation.getNode()) .setIngressVrf(ingressLocation.getVrf()); break; default: throw new BatfishException("Unexpected IngressLocation Type: " + ingressLocation.getType()); } flowBuilder.setTag(tag); constraints.forEach( (name, value) -> { if (!flowBuilders.containsKey(name)) { return; } flowBuilders.get(name).accept(flowBuilder, value); }); return flowBuilder.build(); }
/** * Creates a return {@link Flow} for the input {@param forwardFlow}. Swaps the source/destination * IPs/ports, and sets the ingress node/vrf/interface. */ static Flow returnFlow( Flow forwardFlow, String returnIngressNode, @Nullable String returnIngressVrf, @Nullable String returnIngressIface) { checkArgument( returnIngressVrf == null ^ returnIngressIface == null, "Either returnIngressVrf or returnIngressIface required, but not both"); return forwardFlow .toBuilder() .setDstIp(forwardFlow.getSrcIp()) .setDstPort(forwardFlow.getSrcPort()) .setSrcIp(forwardFlow.getDstIp()) .setSrcPort(forwardFlow.getDstPort()) .setIngressNode(returnIngressNode) .setIngressVrf(returnIngressVrf) .setIngressInterface(returnIngressIface) .build(); }
@VisibleForTesting static Flow multipathInconsistencyToFlow( BDDPacket bddPacket, MultipathInconsistency violation, String flowTag) { Flow.Builder fb = bddPacket .getFlow(violation.getBDD()) .orElseGet( () -> { throw new BatfishException("MultipathConsistencyViolation with UNSAT predicate"); }); fb.setTag(flowTag); IngressLocation ingressLocation = violation.getIngressLocation(); if (ingressLocation.isIngressVrf()) { fb.setIngressNode(ingressLocation.getNode()); fb.setIngressVrf(ingressLocation.getVrf()); } else { fb.setIngressNode(ingressLocation.getNode()); fb.setIngressInterface(ingressLocation.getInterface()); } return fb.build(); } }
@Override public Void visitInterfaceLocation(@Nonnull InterfaceLocation interfaceLocation) { flowBuilder .setIngressInterface(null) .setIngressNode(interfaceLocation.getNodeName()) .setIngressVrf( c.getAllInterfaces() .get(interfaceLocation.getInterfaceName()) .getVrf() .getName()); return null; } });
@Override public Void visitInterfaceLocation(@Nonnull InterfaceLocation interfaceLocation) { flowBuilder .setIngressInterface(null) .setIngressNode(interfaceLocation.getNodeName()) .setIngressVrf( interfaceVrf( interfaceLocation.getNodeName(), interfaceLocation.getInterfaceName())); return null; } });
@Override public Void visitInterfaceLinkLocation( @Nonnull InterfaceLinkLocation interfaceLinkLocation) { flowBuilder .setIngressInterface(interfaceLinkLocation.getInterfaceName()) .setIngressNode(interfaceLinkLocation.getNodeName()) .setIngressVrf(null); return null; }
@Override public Void visitInterfaceLinkLocation( @Nonnull InterfaceLinkLocation interfaceLinkLocation) { flowBuilder .setIngressInterface(interfaceLinkLocation.getInterfaceName()) .setIngressNode(interfaceLinkLocation.getNodeName()) .setIngressVrf(null); return null; }