@Override public boolean equals(Object o) { if (o == this) { return true; } if (!(o instanceof Flow)) { return false; } Flow other = (Flow) o; return _dscp == other._dscp && _dstIp.equals(other._dstIp) && _dstPort == other._dstPort && _ecn == other._ecn && _fragmentOffset == other._fragmentOffset && _icmpCode == other._icmpCode && _icmpType == other._icmpType && _ingressNode.equals(other._ingressNode) && Objects.equals(_ingressInterface, other._ingressInterface) && Objects.equals(_ingressVrf, other._ingressVrf) && _ipProtocol.equals(other._ipProtocol) && _packetLength == other._packetLength && _srcIp.equals(other._srcIp) && _srcPort == other._srcPort && _state.equals(other._state) && _tag.equals(other._tag) && _tcpFlags.equals(other._tcpFlags); }
private static Map<Integer, FlowState> buildNumberMap() { ImmutableMap.Builder<Integer, FlowState> map = ImmutableMap.builder(); for (FlowState value : FlowState.values()) { map.put(value._num, value); } return map.build(); }
@Test public void test_state() { HeaderSpace headerSpace = HeaderSpace.builder() .setStates(ImmutableSet.of(FlowState.fromNum(0), FlowState.fromNum(1))) .build(); BDD bdd = _toBDD.toBDD(headerSpace); BDDInteger state = _pkt.getState(); BDD stateBDD = state.value(0).or(state.value(1)); assertThat(bdd, equalTo(stateBDD)); }
@Test public void testFlowStateAutocomplete() throws IOException { assertThat( _manager.autoComplete("network", "snapshot", Type.FLOW_STATE, "e", 5).stream() .map(AutocompleteSuggestion::getText) .collect(Collectors.toSet()), equalTo(ImmutableSet.of(ESTABLISHED.toString(), RELATED.toString(), NEW.toString()))); }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + _dscp; result = prime * result + _dstIp.hashCode(); result = prime * result + _dstPort; result = prime * result + _ecn; result = prime * result + _fragmentOffset; result = prime * result + _ingressNode.hashCode(); result = prime * result + _ipProtocol.ordinal(); result = prime * result + _srcIp.hashCode(); result = prime * result + _srcPort; result = prime * result + _icmpType; result = prime * result + _icmpCode; result = prime * result + _state.ordinal(); result = prime * result + _tag.hashCode(); result = prime * result + _tcpFlagsCwr; result = prime * result + _tcpFlagsEce; result = prime * result + _tcpFlagsUrg; result = prime * result + _tcpFlagsAck; result = prime * result + _tcpFlagsPsh; result = prime * result + _tcpFlagsRst; result = prime * result + _tcpFlagsSyn; result = prime * result + _tcpFlagsFin; return result; }
return ret; ret = _state.compareTo(rhs._state); if (ret != 0) { return ret;
public static BooleanExpr matchState(Set<FlowState> states) { return new OrExpr( states.stream() .map( state -> new EqExpr( new VarIntExpr(Field.STATE), new LitIntExpr(state.number(), Field.STATE.getSize()))) .collect(ImmutableList.toImmutableList())); }
String.format("A Batfish %s must be a JSON string", expectedType.getName())); FlowState.fromString(value.textValue()); break; case HEADER_CONSTRAINT:
PropertySpecifier.baseAutoComplete( query, Stream.of(FlowState.values()).map(FlowState::name).collect(Collectors.toSet())); break;
public Flow.Builder getFlowFromAssignment(BDD satAssignment) { checkArgument(isAssignment(satAssignment)); Flow.Builder fb = Flow.builder(); fb.setDstIp(Ip.create(_dstIp.satAssignmentToLong(satAssignment))); fb.setSrcIp(Ip.create(_srcIp.satAssignmentToLong(satAssignment))); fb.setDstPort(_dstPort.satAssignmentToLong(satAssignment).intValue()); fb.setSrcPort(_srcPort.satAssignmentToLong(satAssignment).intValue()); fb.setIpProtocol( IpProtocol.fromNumber(_ipProtocol.satAssignmentToLong(satAssignment).intValue())); fb.setIcmpCode(_icmpCode.satAssignmentToLong(satAssignment).intValue()); fb.setIcmpType(_icmpType.satAssignmentToLong(satAssignment).intValue()); fb.setTcpFlagsAck(_tcpAck.and(satAssignment).isZero() ? 0 : 1); fb.setTcpFlagsCwr(_tcpCwr.and(satAssignment).isZero() ? 0 : 1); fb.setTcpFlagsEce(_tcpEce.and(satAssignment).isZero() ? 0 : 1); fb.setTcpFlagsFin(_tcpFin.and(satAssignment).isZero() ? 0 : 1); fb.setTcpFlagsPsh(_tcpPsh.and(satAssignment).isZero() ? 0 : 1); fb.setTcpFlagsRst(_tcpRst.and(satAssignment).isZero() ? 0 : 1); fb.setTcpFlagsSyn(_tcpSyn.and(satAssignment).isZero() ? 0 : 1); fb.setTcpFlagsUrg(_tcpUrg.and(satAssignment).isZero() ? 0 : 1); fb.setDscp(_dscp.satAssignmentToLong(satAssignment).intValue()); fb.setEcn(_ecn.satAssignmentToLong(satAssignment).intValue()); fb.setFragmentOffset(_fragmentOffset.satAssignmentToLong(satAssignment).intValue()); fb.setState(FlowState.fromNum(_state.satAssignmentToLong(satAssignment).intValue())); return fb; }