Skip to content

Commit

Permalink
prepare for 0.10.0
Browse files Browse the repository at this point in the history
- added filemap question
- added application protocols to headerspace/reachability/tracerout
- refactoring, cleanup
- update refs
  • Loading branch information
arifogel committed Mar 14, 2017
1 parent 325dc5e commit f525a60
Show file tree
Hide file tree
Showing 30 changed files with 1,316 additions and 533 deletions.
4 changes: 1 addition & 3 deletions demos/java/commands
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,8 @@ echo ################
echo # more interestingly, we can also ask questions about data flow, i.e., the end-to-end impact of all configuration

echo # for example, we can see how host1 reaches a particular IP address
echo # the query will take time if the dataplane has not been comptued before
echo # the query will take time if the dataplane has not been computed before
get #traceroute host1 1.0.2.2
echo # (the macro above expands to "get traceroute ingressNode=host1 | dstIp=1.0.2.2")
echo # --> unlike a regular traceroute we show multipath and interface information

echo # suppose host1 (2.128.0.101) is running DNS and we want to ensure that the server is reachable
Expand All @@ -68,7 +67,6 @@ echo # while the above could be done using testing/emulation, we alone can be co

echo # for example, find *all* (starting node, packet header) combinations where the DNS server is unreachable
get #checkreachability 2.128.0.101 dns
echo # (macro expands to "get reachability dstPrefixes=["2.128.0.101/32"] | dstPortRange=["53-53"] | ipProtoRange=["17-17"] | actions=["drop"])
echo # --> the output shows outsiders with spoofed source addresses cannot reach the DNS server (good)
echo # --> but also shows that a bad ACL on host2 is blocking access (bad)

Expand Down
504 changes: 345 additions & 159 deletions demos/java/commands.ref

Large diffs are not rendered by default.

40 changes: 0 additions & 40 deletions projects/batfish-client/src/org/batfish/client/MyApplication.java

This file was deleted.

49 changes: 16 additions & 33 deletions projects/batfish-client/src/org/batfish/client/QuestionHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@

import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.function.Supplier;

import org.batfish.common.BatfishException;
import org.batfish.datamodel.ForwardingAction;
import org.batfish.datamodel.Ip;
import org.batfish.datamodel.IpProtocol;
import org.batfish.datamodel.IpWildcard;
import org.batfish.datamodel.SubRange;
import org.batfish.datamodel.Protocol;
import org.batfish.datamodel.questions.*;

import com.fasterxml.jackson.annotation.JsonCreator;
Expand Down Expand Up @@ -96,47 +95,34 @@ public static String getQuestionString(String questionTypeStr,
}

public static IQuestion getReachabilityQuestion(String dstIp,
String protocol, String ingressNodeRegex, ForwardingAction action,
String protocolStr, String ingressNodeRegex, ForwardingAction action,
Map<String, Supplier<Question>> questions) {
IReachabilityQuestion question = (IReachabilityQuestion) questions
.get(IReachabilityQuestion.NAME).get();

question.setDstIps(Collections.singleton(new IpWildcard(new Ip(dstIp))));
question.setDstIps(new TreeSet<>(
Collections.singleton(new IpWildcard(new Ip(dstIp)))));

boolean inverted = false;

if (protocol.startsWith("!")) {
if (protocolStr.startsWith("!")) {
inverted = true;
protocol = protocol.replace("!", "");
protocolStr = protocolStr.substring(1);
}

MyApplication application = new MyApplication(protocol);

IpProtocol ipProtocol = application.getIpProtocol();
SortedSet<Protocol> protocols = new TreeSet<>(
Collections.singleton(Protocol.fromString(protocolStr)));
if (inverted) {
question.setNotIpProtocols(Collections.singleton(ipProtocol));
question.setNotDstProtocols(protocols);
}
else {
question.setIpProtocols(Collections.singleton(ipProtocol));
}

if (application.getPort() != null) {
int portNum = application.getPort();
Set<SubRange> portRanges = Collections
.singleton(new SubRange(portNum));
if (inverted) {
question.setNotDstPorts(portRanges);
}
else {
question.setDstPorts(portRanges);
}
question.setDstProtocols(protocols);
}

if (ingressNodeRegex != null) {
question.setIngressNodeRegex(ingressNodeRegex);
}

Set<ForwardingAction> actionSet = new HashSet<>();
SortedSet<ForwardingAction> actionSet = new TreeSet<>();
actionSet.add(action);
question.setActions(actionSet);

Expand Down Expand Up @@ -193,12 +179,9 @@ public static String resolveMacro(String macroName, String paramsLine,
question.setDstIp(new Ip(dstIp));

if (words.length == 3) {
String protocol = words[2];
MyApplication application = new MyApplication(protocol);
question.setIpProtocol(application.getIpProtocol());
if (application.getPort() != null) {
question.setDstPort(application.getPort());
}
String protocolStr = words[2];
Protocol protocol = Protocol.fromString(protocolStr);
question.setDstProtocol(protocol);
}
// else {
// question.setIpProtocol(IpProtocol.ICMP);
Expand Down
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.9.0";
private static final String VERSION = "0.10.0";

public static void checkCompatibleVersion(String myName, String otherName,
String otherVersion) {
Expand Down

0 comments on commit f525a60

Please sign in to comment.