-
Notifications
You must be signed in to change notification settings - Fork 1
/
rules.py
63 lines (57 loc) · 1.67 KB
/
rules.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
def to_wifi(params, user):
to_wifi_data = {
"dpid": int(params["br-int_dpid"]),
"table_id": 0,
"priority": 80,
"idle_timeout": 120,
"match": {
"eth_type": 2048,
"ipv4_dst": user["vlc_ip"],
"dl_vlan": "0x0000",
"in_port": params["external_of_port"]
},
"actions": [
{
"type": "PUSH_VLAN",
"ethertype": 33024
},
{
"type": "SET_FIELD",
"field": "vlan_vid",
"value": 4098
},
{
"type": "SET_FIELD",
"field": "ipv4_dst",
"value": user["wifi_ip"]
},
{
"type": "GOTO_TABLE",
"table_id": 60
}
]
}
return to_wifi_data
def from_wifi(params, user):
from_wifi_data = {
"dpid": int(params["br-int_dpid"]),
"table_id": 0,
"priority": 2,
"idle_timeout": 120,
"match": {
"eth_type": 2048,
"ipv4_src": user["wifi_ip"]
},
"actions": [
{
"type": "SET_FIELD",
"field": "ipv4_src",
"value": user["vlc_ip"]
},
{
"type": "GOTO_TABLE",
"table_id": 60
}
]
}
return from_wifi_data