Created on Jan 27, 2011
@author: peyman kazemian
Specifically, checks whether it’s possible for any packets to fall into the blackhole in the first place.
Created on Jan 24, 2011
@author: peyman kazemian
perform ‘and’ operation when b1 and b2 can have wildcard bits
perform ‘or’ operation when b1 and b2 can have wildcard bits
perform ‘or’ operation when b1 and b2 can have wildcard bits
checks if a is subset of b. doesn’t work if a is empty
Bases: object
A headerspace object keeps a set of header space regions. it can be union of [0,1,x,z] expressions. It can also keep a list of headerspaces to be subtracted from this object. The subtraction can be done lazily. It also enables normal set operations on header space.
adds value to the list of headerspaces, hs_list @value: bytearray of lenght self.length or another headerspace objects @return: True if successful, False otherwise
adds values to the list of headerspaces, hs_list @values: list of bytearray of lenght self.length or other headerspace objects @return: True
find the complement of header space pieces saved in hs_list and saves it back to itself
lazily subtract value from this headerspace @value: bytearray of lenght self.length @return: True if successful, False otherwise
lazily subtract values from this headerspace @values: list of bytearray of lenght self.length @return: True
intersect itself with other_hs if the header lengths are equal. The result will be saved in the caller instance itself. @other_fs: @type headerspace or bytearray: the other headerspace to intersect with @return: @type Boolean: True if successful, False if an error happens
Created on Jan 26, 2011
@author: peymankazemian
Created on Jan 24, 2011
@author: peyman kazemian
Bases: object
models a box transfer function, a network transfer function or a topology transfer function
returns a list of (hs, list of output ports) as a result of applying transfer function. hs will have A-B format, where A is the intersection of hs and the rule’s match struct and B will be union of match bytes of all the rules that influence on the matching rule.
returns a list of (hs, list of in_ports) as possible inputs that can cause this (hs,port). The format of hs and returned headerspace object, is like T() method above.
Apply rule with id = rule_id to (hs,port) Output is a list of [hs,list_of_out_ports].
Apply rule with id = rule_id to (hs,port) Output is a list of [hs,list_of_out_ports].
Add a custom rule. You need to provide a function for finding math and a function for creating output header. rule should have the following entries: * ‘match’: a pointer to the function for finding if a packet match this rule. the function should accept (headerspace,in_port) as input and returns a list of headerspace objects that match this rule * ‘transform’: a pointer to a function which outputs a list of (headerspace, list of out_ports) pairs as the output of the rule. * ‘inv_match’: a pointer to the function for finding if an output packet can be generated by this rule. The function format is like “match’. * ‘inv_transform’: a pointer to a function which outputs a list of (headerspace, list of in_ports) pairs as the output of the inverse rule. WARNING: use custom rules in a transfer function with only custom rules. Interaction between custom rules and rewrite/fw rules is not defined.
match this rule. * ‘in_ports’: the list of input port numbers to match on * ‘out_ports’: the list of output port numbers.
This is useful for topology transfer fucntions * ‘in_ports’: the list of input port numbers to match on * ‘out_port’: the list of output port numbers. WARNING: Use link rule only in Topology Transfer Function. Don’t mix it with other type of rules.
rule is a dictionary with following keys: * ‘match’: a bytearray of length self.length describing the header formats that match this rule. * ‘in_ports’: the list of input port numbers to match on * ‘mask’: a bytearray of length self.length that masks all the bits that won’t be rewritten * ‘rewrite’: a bytearray of length self.length that rewrites the desired bits. * ‘out_ports’: the list of output port numbers.
creates a rule that if matches on in_ports, match, does all the actions in rules. the in_ports,matches in rules will be the same as in_ports, match in the multi-rewrite rule.
Create a rule using input arguments. Use None if an input is not applicable.
After inserting the new_rule, into self.rules, call this method to update the rule dependencies. @priority: priority or position of the new rule in the table
This is a simple version of checking for lazy evaluation. TODO: implement a more complex version that understand packet header rather than just looking at some bit positions