@Override protected Ip featureValueOf(Flow flow) { return flow.getSrcIp(); } }
@Nullable private static Transformation sessionTransformation(Flow inputFlow, Flow currentFlow) { ImmutableList.Builder<TransformationStep> transformationStepsBuilder = ImmutableList.builder(); Ip origDstIp = inputFlow.getDstIp(); if (!origDstIp.equals(currentFlow.getDstIp())) { transformationStepsBuilder.add(assignSourceIp(origDstIp, origDstIp)); } Ip origSrcIp = inputFlow.getSrcIp(); if (!origSrcIp.equals(currentFlow.getSrcIp())) { transformationStepsBuilder.add(TransformationStep.assignDestinationIp(origSrcIp, origSrcIp)); } List<TransformationStep> transformationSteps = transformationStepsBuilder.build(); return transformationSteps.isEmpty() ? null : always().apply(transformationSteps).build(); }
/** Compute the differences between two flows */ public static SortedSet<FlowDiff> flowDiffs(@Nullable Flow flow1, @Nullable Flow flow2) { if (flow1 == null || flow2 == null || flow1.equals(flow2)) { return ImmutableSortedSet.of(); } checkArgument( flow1 .toBuilder() .setDstIp(flow2.getDstIp()) .setSrcIp(flow2.getSrcIp()) .build() .equals(flow2), "flowDiff only supports differences of src or dst Ip"); ImmutableSortedSet.Builder<FlowDiff> diffs = ImmutableSortedSet.naturalOrder(); if (!flow1.getDstIp().equals(flow2.getDstIp())) { diffs.add( new FlowDiff(PROP_DST_IP, flow1.getDstIp().toString(), flow2.getDstIp().toString())); } if (!flow1.getSrcIp().equals(flow2.getSrcIp())) { diffs.add( new FlowDiff(PROP_SRC_IP, flow1.getSrcIp().toString(), flow2.getSrcIp().toString())); } return diffs.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(); }
fb.setIngressVrf(listener.getVrfName()); fb.setSrcIp(forwardFlow.getDstIp()); fb.setDstIp(forwardFlow.getSrcIp()); fb.setSrcPort(forwardFlow.getDstPort()); fb.setDstPort(forwardFlow.getSrcPort());
&& !(_srcOrDstIps.containsIp(flow.getSrcIp(), namedIpSpaces) || _srcOrDstIps.containsIp(flow.getDstIp(), namedIpSpaces))) { return false; if (_srcIps != null && !_srcIps.containsIp(flow.getSrcIp(), namedIpSpaces)) { return false; if (_notSrcIps != null && _notSrcIps.containsIp(flow.getSrcIp(), namedIpSpaces)) { return false;
newTransformedFlow.getDstIp(), newTransformedFlow.getDstPort(), newTransformedFlow.getSrcIp(), newTransformedFlow.getSrcPort(), newTransformedFlow.getIpProtocol()),
&& !(traceSrcIp(headerSpace.getSrcOrDstIps(), _flow.getSrcIp()) || traceDstIp(headerSpace.getSrcOrDstIps(), _flow.getDstIp()))) { return false; if (headerSpace.getSrcIps() != null && !traceSrcIp(headerSpace.getSrcIps(), _flow.getSrcIp())) { return false; && traceSrcIp(headerSpace.getNotSrcIps(), _flow.getSrcIp())) { return false;