-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfirewall.py
23 lines (18 loc) · 795 Bytes
/
firewall.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from pox.core import core
import pox.openflow.libopenflow_01 as of
from pox.lib.revent import *
from pox.lib.addresses import EthAddr
rules = [['00:00:00:00:00:01','00:00:00:00:00:02'],['00:00:00:00:00:02', '00:00:00:00:00:04'],['00:00:00:00:00:08','00:00:00:00:00:03'],['00:00:00:00:00:07','00:00:00:00:00:02']]
class SDNFirewall (EventMixin):
def __init__ (self):
self.listenTo(core.openflow)
def _handle_ConnectionUp (self, event):
for rule in rules:
block = of.ofp_match()
block.dl_src = EthAddr(rule[0])
block.dl_dst = EthAddr(rule[1])
flow_mod = of.ofp_flow_mod()
flow_mod.match = block
event.connection.send(flow_mod)
def launch ():
core.registerNew(SDNFirewall)