def add_nw_rewrite(self, rewrite_src, addr): """Add rewrite for IP address @param rewrite_src boolean for indicated rewrite src or dst @param addr address to rewrite to """ oanw = pyof.ofp_action_nw_addr() if rewrite_src: oanw.type = pyof.OFPAT_SET_NW_SRC else: oanw.type = pyof.OFPAT_SET_NW_DST oanw.nw_addr = addr self.add(oanw)
def unpack_action(self, string): """Unpack action @param string binary string of actions @return (action, remaining) """ remaining = string action = None ah = pyof.ofp_action_header() ah.unpack(string) if (ah.type == pyof.OFPAT_OUTPUT): action = pyof.ofp_action_output() remaining = action.unpack(string) elif (ah.type == pyof.OFPAT_SET_NW_SRC) or (ah.type == pyof.OFPAT_SET_NW_DST): action = pyof.ofp_action_nw_addr() remaining = action.unpack(string) else: output.warn("Unhandled action type "+str(ah.type)+"!", self.__class__.__name__) return (None, remaining[ah.len:]) return (action, remaining)