Advertisement
Guest User

Untitled

a guest
Jan 26th, 2015
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.99 KB | None | 0 0
  1. [%
  2. import "header.egl";
  3. import "utils.egl";
  4. import "condition.egl";
  5. import "firewall.egl";
  6. import "monitor.egl";
  7. %]
  8.  
  9. [% var header = getCodeHeader(); %]
  10. [%=header%]
  11. [% var counterActionDrop : Integer = 0; %]
  12. def mdn_handler (event):
  13.      
  14.   # Handles packet events and kills the ones with blocked property
  15.   packet = event.parsed
  16.                
  17. [%
  18. for (policy in Policy.all) {
  19.   if (policy.policyAction.isDefined()) {
  20.     if (policy.policyAction.type.value = Actions#DROP.value) {
  21.       if (counterActionDrop == 0) {
  22.         counterActionDrop = counterActionDrop + 1;
  23.       }    
  24.       actionDrop(policy);
  25.     }
  26.     //IF ACTION EQUALS TO MONITOR
  27.     if (policy.policyAction.type.value = Actions#MONITOR.value) {
  28.       if (counterActionMonitor == 0) {
  29.         counterActionMonitor = counterActionMonitor + 1;
  30.       }
  31.       monitorAction(policy);   
  32.     }
  33.   }
  34. }
  35. %]
  36. [...]
  37. def launch ():
  38. [% if (counterActionDrop > 0) { %]
  39.   core.openflow.addListenerByName("PacketIn", mdn_handler)
  40. [% } %]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement