-
Notifications
You must be signed in to change notification settings - Fork 1
/
Main.py
41 lines (34 loc) · 1.11 KB
/
Main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from VeriFlow.Network import Network
ROUTE_VIEW = 1;
BIT_BUCKET = 2;
def main():
print("Enter network configuration file name (eg.: file.txt):");
# filename = input("> ");
filename = "Topo1.txt"
network = Network();
network.parseNetworkFromFile(filename);
generatedECs = network.getECsFromTrie();
network.checkWellformedness();
network.log(generatedECs);
while True:
print(" ");
print("Add rule by entering A#switchIP-rulePrefix-nextHopIP (eg.A#127.0.0.1-128.0.0.0/2-127.0.0.2)");
print("Remove rule by entering R#switchIP-rulePrefix-nextHopIP (eg.R#127.0.0.1-128.0.0.0/2-127.0.0.2)");
print("To exit type exit");
affectedEcs = set()
inputline = input('> ')
if (inputline.startswith("A")):
affectedEcs = network.addRuleFromString(inputline[2:]);
network.checkWellformedness(affectedEcs);
elif (inputline.startswith("R")):
affectedEcs = network.deleteRuleFromString(inputline[2:]);
network.checkWellformedness(affectedEcs);
elif ("exit" in inputline):
break;
else:
print("Wrong input format!");
continue;
print("");
network.log(affectedEcs);
if __name__ == '__main__':
main()