forked from netgroup/Dreamer-Mininet-Extensions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ingress_classifications.py
99 lines (64 loc) · 2.66 KB
/
ingress_classifications.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/usr/bin/python
class IngressClassification (object):
prio_std_rules = 300
def __init__(self, eth, vi, name):
self.eth = eth
self.vi = vi
self.name = name
class IngrB_CoexA(IngressClassification):
tableIP =1
def __init__(self, eth, vi, coexData, name):
IngressClassification.__init__(self, eth, vi, name)
self.vlanIP = coexData
def getOVSRules(self):
rules = []
rules.append('ovs-ofctl add-flow %s "table=0,hard_timeout=0,priority=%s,in_port=%s,actions=mod_vlan_vid:%s,resubmit(,%s)"' %(self.name,
self.prio_std_rules, self.eth, self.vlanIP, self.tableIP))
rules.append('ovs-ofctl add-flow %s "table=%s,hard_timeout=0,priority=%s,in_port=%s,actions=strip_vlan,output:%s"' %(self.name, self.tableIP,
self.prio_std_rules, self.vi, self.eth))
return rules
class IngrB_CoexA_13(IngrB_CoexA):
def __init__(self, eth, vi, coexData, name):
IngrB_CoexA.__init__(self, eth, vi, coexData, name)
def getOVSRules(self):
rules = []
rules.append('ovs-ofctl -O OpenFlow13 add-flow %s "table=0,hard_timeout=0,priority=%s,in_port=%s,actions=mod_vlan_vid:%s,goto_table:%s"' %(self.name,
self.prio_std_rules, self.eth, self.vlanIP, self.tableIP))
rules.append('ovs-ofctl -O OpenFlow13 add-flow %s "table=%s,hard_timeout=0,priority=%s,in_port=%s,actions=strip_vlan,output:%s"' %(self.name, self.tableIP,
self.prio_std_rules, self.vi, self.eth))
return rules
class IngrB_CoexB(IngressClassification):
def __init__(self, eth, vi, name):
IngressClassification.__init__(self, eth, vi, name)
def getOVSRules(self):
rules = []
return rules
class IngrB_CoexH(IngressClassification):
def __init__(self, eth, vi, name):
IngressClassification.__init__(self, eth, vi, name)
def getOVSRules(self):
rules = []
return rules
class IngressFactory(object):
coex_types=["COEXA", "COEXB", "COEXH"]
ingress_types=["INGRB"]
def getIngr(self, coex_type, coex_data, ingress_type, ingress_data, eth, vi, name, OF_V):
if coex_type not in self.coex_types:
error("ERROR %s not supported" % coex_type)
sys.exit(-2)
if ingress_type not in self.ingress_types:
error("ERROR %s not supported" % ingress_type)
sys.exit(-2)
if coex_type == "COEXA" and ingress_type == "INGRB":
if OF_V == None:
return IngrB_CoexA(eth, vi, coex_data, name)
elif OF_V == "OpenFlow13":
return IngrB_CoexA_13(eth, vi, coex_data, name)
if coex_type == "COEXB" and ingress_type == "INGRB":
return IngrB_CoexB(eth, vi, name)
if coex_type == "COEXH" and ingress_type == "INGRB":
if OF_V == None:
error("ERROR %s is not supported by OpenFlow 1.0" % coex_type)
sys.exit(-2)
elif OF_V == "OpenFlow13":
return IngrB_CoexH(eth, vi, name)