frenetic-lang / pyretic

The Pyretic language and runtime system
http://frenetic-lang.org/pyretic/
159 stars 99 forks source link

Install policies depending on fields of the packet #30

Closed alvgarvilla closed 10 years ago

alvgarvilla commented 10 years ago

First of all say that I am new with Pyretic and OpenFlow, I am starting with my Master Thesis and it is about DDoS defense mechanisms with OpenFlow. One of the cases that I have to develop is TCP SYN defense, in which I control the TCP connection and when it is done then I install flow entries with the client and the server. Anyway, my question is, can I install new policies in the callback function? For example:

def newRule(pkt):
   new flow policie with fields in pkt 

def dpi():
   q = packets()
   q.register_callback(newRule)
   return q

def main():
   return (dpi())
joshreich commented 10 years ago

take a look at https://github.com/frenetic-lang/pyretic/blob/master/pyretic/modules/mac_learner.py which provides an example of updating a policy using a query callback