/
firewall.py2
47 lines (41 loc) · 1.33 KB
/
firewall.py2
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
from pox.core import core
from pox.lib.addresses import *
from pox.lib.packet import *
# Get a logger
log = core.getLogger("fw")
class Firewall (object):
"""
Firewall class.
Extend this to implement some firewall functionality.
Don't change the name or anything -- the eecore component
expects it to be firewall.Firewall.
"""
def __init__(self):
"""
Constructor.
Put your initialization code here.
"""
log.debug("Firewall initialized.")
def _handle_ConnectionIn (self, event, flow, packet):
"""
New connection event handler.
You can alter what happens with the connection by altering the
action property of the event.
"""
log.debug("Allowed connection [" + str(flow.src) + ":" + str(flow.srcport) + "," + str(flow.dst) + ":" + str(flow.dstport) + "]" )
event.action.forward = True
def _handle_DeferredConnectionIn (self, event, flow, packet):
"""
Deferred connection event handler.
If the initial connection handler defers its decision, this
handler will be called when the first actual payload data
comes across the connection.
"""
pass
def _handle_MonitorData (self, event, packet, reverse):
"""
Monitoring event handler.
Called when data passes over the connection if monitoring
has been enabled by a prior event handler.
"""
pass