Skip to content

Commit

Permalink
PAN: application-override rule conversion (#6651)
Browse files Browse the repository at this point in the history
  • Loading branch information
sfraint committed Feb 23, 2021
1 parent e82ee5d commit e880043
Show file tree
Hide file tree
Showing 12 changed files with 1,182 additions and 35 deletions.
Expand Up @@ -11,6 +11,7 @@
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNullableByDefault;
import org.batfish.datamodel.IntegerSpace;
import org.batfish.datamodel.IpProtocol;
import org.batfish.datamodel.SubRange;

/** PAN datamodel component containing application-override rule configuration */
Expand All @@ -20,7 +21,8 @@ public final class ApplicationOverrideRule implements Serializable {
// Possible protocols for traffic to match an application-override rule
public enum Protocol {
TCP,
UDP
UDP,
UNSPECIFIED
}

// Name of the rule
Expand All @@ -45,7 +47,7 @@ public enum Protocol {
private boolean _negateDestination;

// Traffic characteristics to match
@Nullable private Protocol _protocol;
@Nonnull private Protocol _protocol;
@Nonnull private IntegerSpace _port;

@Nonnull private final Set<String> _tags;
Expand All @@ -61,6 +63,7 @@ public ApplicationOverrideRule(@Nonnull String name) {
_tags = new HashSet<>(1);
_name = name;
_port = IntegerSpace.EMPTY;
_protocol = Protocol.UNSPECIFIED;
}

@Nonnull
Expand Down Expand Up @@ -110,12 +113,25 @@ public boolean getNegateDestination() {
return _negateDestination;
}

@Nullable
@Nonnull
public Protocol getProtocol() {
return _protocol;
}

@Nullable
public IpProtocol getIpProtocol() {
switch (_protocol) {
case TCP:
return IpProtocol.TCP;
case UDP:
return IpProtocol.UDP;
case UNSPECIFIED:
default:
return null;
}
}

@Nonnull
public IntegerSpace getPort() {
return _port;
}
Expand Down Expand Up @@ -145,7 +161,7 @@ public void setNegateDestination(boolean negateDestination) {
_negateDestination = negateDestination;
}

public void setProtocol(Protocol protocol) {
public void setProtocol(@Nonnull Protocol protocol) {
_protocol = protocol;
}

Expand Down

0 comments on commit e880043

Please sign in to comment.