Skip to content

Commit

Permalink
Merge pull request #93 from batfish/unstable
Browse files Browse the repository at this point in the history
prepare for 0.15.0
  • Loading branch information
arifogel committed Apr 8, 2017
2 parents f2716d1 + b52ef14 commit 71e6ae2
Show file tree
Hide file tree
Showing 52 changed files with 2,912 additions and 1,163 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public final class Version {

private static final String UNKNOWN_VERSION = "0.0.0";

private static final String VERSION = "0.14.0";
private static final String VERSION = "0.15.0";

public static void checkCompatibleVersion(String myName, String otherName,
String otherVersion) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public final class Flow implements Comparable<Flow> {

private static final String IP_PROTOCOL_VAR = "ipProtocol";

private static final String PACKET_LENGTH_VAR = "packetLength";

private static final String SRC_IP_VAR = "srcIp";

private static final String SRC_PORT_VAR = "srcPort";
Expand Down Expand Up @@ -72,6 +74,8 @@ public final class Flow implements Comparable<Flow> {

private final IpProtocol _ipProtocol;

private final int _packetLength;

private final Ip _srcIp;

private final int _srcPort;
Expand Down Expand Up @@ -107,6 +111,7 @@ public Flow(@JsonProperty(INGRESS_NODE_VAR) String ingressNode,
@JsonProperty(FRAGMENT_OFFSET_VAR) int fragmentOffset,
@JsonProperty(ICMP_TYPE_VAR) int icmpType,
@JsonProperty(ICMP_CODE_VAR) int icmpCode,
@JsonProperty(PACKET_LENGTH_VAR) int packetLength,
@JsonProperty(STATE_VAR) State state,
@JsonProperty(TCP_FLAGS_CWR_VAR) int tcpFlagsCwr,
@JsonProperty(TCP_FLAGS_ECE_VAR) int tcpFlagsEce,
Expand All @@ -129,6 +134,7 @@ public Flow(@JsonProperty(INGRESS_NODE_VAR) String ingressNode,
_fragmentOffset = fragmentOffset;
_icmpType = icmpType;
_icmpCode = icmpCode;
_packetLength = packetLength;
_state = state;
_tcpFlagsCwr = tcpFlagsCwr;
_tcpFlagsEce = tcpFlagsEce;
Expand Down Expand Up @@ -192,6 +198,10 @@ public int compareTo(Flow rhs) {
if (ret != 0) {
return ret;
}
ret = Integer.compare(_packetLength, rhs._packetLength);
if (ret != 0) {
return ret;
}
ret = _state.compareTo(rhs._state);
if (ret != 0) {
return ret;
Expand Down Expand Up @@ -266,6 +276,9 @@ public boolean equals(Object obj) {
if (_icmpCode != other._icmpCode) {
return false;
}
if (_packetLength != other._packetLength) {
return false;
}
if (_state != other._state) {
return false;
}
Expand Down Expand Up @@ -346,6 +359,11 @@ public IpProtocol getIpProtocol() {
return _ipProtocol;
}

@JsonProperty(PACKET_LENGTH_VAR)
public int getPacketLength() {
return _packetLength;
}

@JsonProperty(SRC_IP_VAR)
public Ip getSrcIp() {
return _srcIp;
Expand Down Expand Up @@ -422,6 +440,7 @@ public int hashCode() {
result = prime * result + _srcPort;
result = prime * result + _icmpType;
result = prime * result + _icmpCode;
result = prime * result + _packetLength;
result = prime * result + _state.hashCode();
result = prime * result + _tag.hashCode();
result = prime * result + _tcpFlagsCwr;
Expand Down Expand Up @@ -460,10 +479,11 @@ public String prettyPrint(String prefixString) {
String dscpStr = (_dscp != 0) ? " dscp:" + _dscp : "";
String ecnStr = (_ecn != 0) ? " ecn:" + _ecn : "";

return prefixString + "Flow: ingress:" + _ingressNode + " " + "vrf:"
return prefixString + "Flow: ingress:" + _ingressNode + " vrf:"
+ _ingressVrf + " " + _srcIp + "->" + _dstIp + " " + _ipProtocol
+ srcPortStr + dstPortStr + dscpStr + ecnStr + icmpTypeStr
+ icmpCodeStr + " state:" + _state + tcpFlagsStr;
+ icmpCodeStr + " packetLength:" + _packetLength + " state:"
+ _state + tcpFlagsStr;
}

@Override
Expand Down Expand Up @@ -493,7 +513,7 @@ public String toString() {
+ " srcIp:" + _srcIp + " dstIp:" + _dstIp + " ipProtocol:"
+ _ipProtocol + srcPortStr + dstPortStr + " dscp: " + _dscp
+ " ecn:" + _ecn + " fragmentOffset:" + _fragmentOffset
+ icmpTypeStr + icmpCodeStr + " state:" + _state + tcpFlagsStr
+ " tag:" + _tag + ">";
+ icmpTypeStr + icmpCodeStr + " packetLength:" + _packetLength
+ " state:" + _state + tcpFlagsStr + " tag:" + _tag + ">";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public class FlowBuilder {

private IpProtocol _ipProtocol;

private Integer _packetLength;

private Ip _srcIp;

private Integer _srcPort;
Expand Down Expand Up @@ -60,6 +62,7 @@ public FlowBuilder() {
_icmpType = IcmpType.UNSET;
_icmpCode = IcmpCode.UNSET;
_ingressVrf = Configuration.DEFAULT_VRF_NAME;
_packetLength = 0;
_state = State.NEW;
_tcpFlagsCwr = 0;
_tcpFlagsEce = 0;
Expand All @@ -81,9 +84,9 @@ public Flow build() {
}
return new Flow(_ingressNode, _ingressVrf, _srcIp, _dstIp, _srcPort,
_dstPort, _ipProtocol, _dscp, _ecn, _fragmentOffset, _icmpType,
_icmpCode, _state, _tcpFlagsCwr, _tcpFlagsEce, _tcpFlagsUrg,
_tcpFlagsAck, _tcpFlagsPsh, _tcpFlagsRst, _tcpFlagsSyn,
_tcpFlagsFin, _tag);
_icmpCode, _packetLength, _state, _tcpFlagsCwr, _tcpFlagsEce,
_tcpFlagsUrg, _tcpFlagsAck, _tcpFlagsPsh, _tcpFlagsRst,
_tcpFlagsSyn, _tcpFlagsFin, _tag);
}

public Integer getDscp() {
Expand Down Expand Up @@ -122,6 +125,10 @@ public IpProtocol getIpProtocol() {
return _ipProtocol;
}

public Integer getPacketLength() {
return _packetLength;
}

public Ip getSrcIp() {
return _srcIp;
}
Expand Down Expand Up @@ -214,6 +221,10 @@ public void setIpProtocol(IpProtocol ipProtocol) {
_ipProtocol = ipProtocol;
}

public void setPacketLength(Integer packetLength) {
_packetLength = packetLength;
}

public void setSrcIp(Ip srcIp) {
_srcIp = srcIp;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,16 @@ private static boolean wildcardsContain(Collection<IpWildcard> wildcards,

private SortedSet<IpProtocol> _notIpProtocols;

private SortedSet<SubRange> _notPacketLengths;

private SortedSet<IpWildcard> _notSrcIps;

private SortedSet<SubRange> _notSrcPorts;

private SortedSet<Protocol> _notSrcProtocols;

private SortedSet<SubRange> _packetLengths;

private SortedSet<IpWildcard> _srcIps;

private SortedSet<IpWildcard> _srcOrDstIps;
Expand All @@ -103,6 +107,7 @@ public HeaderSpace() {
_ecns = new TreeSet<>();
_fragmentOffsets = new TreeSet<>();
_ipProtocols = new TreeSet<>();
_packetLengths = new TreeSet<>();
_srcIps = new TreeSet<>();
_srcOrDstIps = new TreeSet<>();
_srcOrDstPorts = new TreeSet<>();
Expand All @@ -122,6 +127,7 @@ public HeaderSpace() {
_notIcmpCodes = new TreeSet<>();
_notIcmpTypes = new TreeSet<>();
_notIpProtocols = new TreeSet<>();
_notPacketLengths = new TreeSet<>();
_notSrcIps = new TreeSet<>();
_notSrcPorts = new TreeSet<>();
_notSrcProtocols = new TreeSet<>();
Expand Down Expand Up @@ -190,6 +196,9 @@ public boolean equals(Object obj) {
if (!_notIpProtocols.equals(other._notIpProtocols)) {
return false;
}
if (!_notPacketLengths.equals(other._notPacketLengths)) {
return false;
}
if (!_notSrcIps.equals(other._notSrcIps)) {
return false;
}
Expand All @@ -199,6 +208,9 @@ public boolean equals(Object obj) {
if (!_notSrcProtocols.equals(other._notSrcProtocols)) {
return false;
}
if (!_packetLengths.equals(other._packetLengths)) {
return false;
}
if (!_srcIps.equals(other._srcIps)) {
return false;
}
Expand Down Expand Up @@ -319,6 +331,10 @@ public SortedSet<IpProtocol> getNotIpProtocols() {
return _notIpProtocols;
}

public SortedSet<SubRange> getNotPacketLengths() {
return _notPacketLengths;
}

@JsonPropertyDescription("A space of unacceptable source IP addresses for a packet")
public SortedSet<IpWildcard> getNotSrcIps() {
return _notSrcIps;
Expand All @@ -333,6 +349,10 @@ public SortedSet<Protocol> getNotSrcProtocols() {
return _notSrcProtocols;
}

public SortedSet<SubRange> getPacketLengths() {
return _packetLengths;
}

@JsonPropertyDescription("A space of acceptable source IP addresses for a packet")
public SortedSet<IpWildcard> getSrcIps() {
return _srcIps;
Expand Down Expand Up @@ -464,6 +484,14 @@ && rangesContain(_notIcmpTypes, flow.getFragmentOffset())) {
&& _notIpProtocols.contains(flow.getIpProtocol())) {
return false;
}
if (!_packetLengths.isEmpty()
&& !rangesContain(_packetLengths, flow.getPacketLength())) {
return false;
}
if (!_notPacketLengths.isEmpty()
&& rangesContain(_notPacketLengths, flow.getPacketLength())) {
return false;
}
if (!_srcOrDstIps.isEmpty()
&& !(wildcardsContain(_srcOrDstIps, flow.getSrcIp())
|| wildcardsContain(_srcOrDstIps, flow.getDstIp()))) {
Expand Down Expand Up @@ -666,6 +694,10 @@ public void setNotIpProtocols(SortedSet<IpProtocol> notIpProtocols) {
_notIpProtocols = notIpProtocols;
}

public void setNotPacketLengths(SortedSet<SubRange> notPacketLengths) {
_notPacketLengths = notPacketLengths;
}

public void setNotSrcIps(SortedSet<IpWildcard> notSrcIps) {
_notSrcIps = notSrcIps;
}
Expand All @@ -678,6 +710,10 @@ public void setNotSrcProtocols(SortedSet<Protocol> notSrcProtocols) {
_notSrcProtocols = notSrcProtocols;
}

public void setPacketLengths(SortedSet<SubRange> packetLengths) {
_packetLengths = packetLengths;
}

public void setSrcIps(SortedSet<IpWildcard> srcIps) {
_srcIps = srcIps;
}
Expand Down Expand Up @@ -727,8 +763,10 @@ public String toString() {
+ _fragmentOffsets.toString() + ", NotFragmentOffsets: "
+ _notFragmentOffsets.toString() + ", IcmpType:" + _icmpTypes
+ ", NotIcmpType:" + _notIcmpTypes + ", IcmpCode:" + _icmpCodes
+ ", NotIcmpCode:" + _notIcmpCodes + ", States:"
+ _states.toString() + ", TcpFlags:" + _tcpFlags.toString() + "]";
+ ", NotIcmpCode:" + _notIcmpCodes + ", PacketLengths:"
+ _packetLengths.toString() + ", NotPacketLengths:"
+ _notPacketLengths + ", States:" + _states.toString()
+ ", TcpFlags:" + _tcpFlags.toString() + "]";
}

public final boolean unrestricted() {
Expand All @@ -740,7 +778,8 @@ public final boolean unrestricted() {
&& _notFragmentOffsets.isEmpty() && _icmpCodes.isEmpty()
&& _notIcmpCodes.isEmpty() && _icmpTypes.isEmpty()
&& _notIcmpTypes.isEmpty() && _ipProtocols.isEmpty()
&& _notIpProtocols.isEmpty() && _srcIps.isEmpty()
&& _notIpProtocols.isEmpty() && _packetLengths.isEmpty()
&& _notPacketLengths.isEmpty() && _srcIps.isEmpty()
&& _notSrcIps.isEmpty() && _srcOrDstIps.isEmpty()
&& _srcOrDstPorts.isEmpty() && _srcOrDstProtocols.isEmpty()
&& _srcPorts.isEmpty() && _notSrcPorts.isEmpty()
Expand Down

0 comments on commit 71e6ae2

Please sign in to comment.