/** * Generate a flow builder given some set of packet header constraints. * * @param constraints {@link PacketHeaderConstraints} * @throws IllegalArgumentException if the {@code constraints} cannot be resolved to a single * value. */ private Flow.Builder headerConstraintsToFlow( PacketHeaderConstraints constraints, Location srcLocation) throws IllegalArgumentException { Flow.Builder builder = PacketHeaderConstraintsUtil.toFlow(constraints); // Extract and source IP from header constraints, setSrcIp(constraints, srcLocation, builder); setDstIp(constraints, builder); // Set defaults for protocol, and ports and packet lengths: if (builder.getIpProtocol() == null || builder.getIpProtocol() == IpProtocol.IP) { builder.setIpProtocol(IpProtocol.UDP); } if (builder.getDstPort() == 0) { builder.setDstPort(TRACEROUTE_PORT); } if (builder.getSrcPort() == 0) { builder.setSrcPort(NamedPort.EPHEMERAL_LOWEST.number()); } return builder; }
/** * Generate a flow builder given some set of packet header constraints. * * @param constraints {@link PacketHeaderConstraints} * @throws IllegalArgumentException if the {@code constraints} cannot be resolved to a single * value. */ private Flow.Builder headerConstraintsToFlow( PacketHeaderConstraints constraints, Location srcLocation) throws IllegalArgumentException { Flow.Builder builder = PacketHeaderConstraintsUtil.toFlow(constraints); setSrcIp(constraints, srcLocation, builder); setDstIp(constraints, builder); // Set defaults for protocol, and ports and packet lengths: if (builder.getIpProtocol() == null || builder.getIpProtocol() == IpProtocol.IP) { builder.setIpProtocol(IpProtocol.TCP); } if (builder.getDstPort() == 0) { builder.setDstPort(NamedPort.HTTP.number()); } if (builder.getSrcPort() == 0) { builder.setSrcPort(NamedPort.EPHEMERAL_LOWEST.number()); } return builder; }