blob: ce323c24fc30704e5dec880a28e2c109b94e8741 [file] [log] [blame]
# Python OpenFlow instruction wrapper classes
from cstruct import *
from action_list import action_list
class instruction_goto_table(ofp_instruction_goto_table):
"""
Wrapper class for goto_table instruction object
Data members inherited from ofp_instruction_goto_table:
@arg type
@arg len
@arg table_id
"""
def __init__(self):
ofp_instruction_goto_table.__init__(self)
self.type = OFPIT_GOTO_TABLE
self.len = self.__len__()
def show(self, prefix=''):
outstr = prefix + "instruction_goto_table\n"
outstr += ofp_instruction_goto_table.show(self, prefix)
return outstr
class instruction_write_actions(ofp_instruction_actions):
"""
Wrapper class for write_actions instruction object
Data members inherited from ofp_instruction_actions:
@arg type
@arg len
"""
def __init__(self):
ofp_instruction_actions.__init__(self)
self.type = OFPIT_WRITE_ACTIONS
self.actions = action_list()
self.len = self.__len__()
def show(self, prefix=''):
outstr = prefix + "instruction_write_actions\n"
outstr += ofp_instruction_actions.show(self, prefix)
outstr += self.actions.show(prefix)
return outstr
def unpack(self, binary_string):
binary_string = ofp_instruction_actions.unpack(self, binary_string)
bytes = self.len - OFP_INSTRUCTION_ACTIONS_BYTES
self.actions = action_list()
binary_string = self.actions.unpack(binary_string, bytes=bytes)
return binary_string
def pack(self):
self.len = self.__len__()
packed = ""
packed += ofp_instruction_actions.pack(self)
packed += self.actions.pack()
return packed
def __len__(self):
return ofp_instruction_actions.__len__(self) + self.actions.__len__()
class instruction_apply_actions(ofp_instruction_actions):
"""
Wrapper class for apply_actions instruction object
Data members inherited from ofp_instruction_actions:
@arg type
@arg len
"""
def __init__(self):
ofp_instruction_actions.__init__(self)
self.type = OFPIT_APPLY_ACTIONS
self.actions = action_list()
self.len = self.__len__()
def show(self, prefix=''):
outstr = prefix + "instruction_apply_actions\n"
outstr += ofp_instruction_actions.show(self, prefix)
outstr += self.actions.show(prefix)
return outstr
def unpack(self, binary_string):
binary_string = ofp_instruction_actions.unpack(self, binary_string)
bytes = self.len - OFP_INSTRUCTION_ACTIONS_BYTES
self.actions = action_list()
binary_string = self.actions.unpack(binary_string, bytes=bytes)
return binary_string
def pack(self):
self.len = self.__len__()
packed = ""
packed += ofp_instruction_actions.pack(self)
packed += self.actions.pack()
return packed
def __len__(self):
return ofp_instruction_actions.__len__(self) + self.actions.__len__()
class instruction_experimenter(ofp_instruction_experimenter):
"""
Wrapper class for experimenter instruction object
Data members inherited from ofp_instruction_experimenter:
@arg type
@arg len
@arg experimenter
"""
def __init__(self):
ofp_instruction_experimenter.__init__(self)
self.type = OFPIT_EXPERIMENTER
self.len = self.__len__()
def show(self, prefix=''):
outstr = prefix + "instruction_experimenter\n"
outstr += ofp_instruction_experimenter.show(self, prefix)
return outstr
class instruction_write_metadata(ofp_instruction_write_metadata):
"""
Wrapper class for write_metadata instruction object
Data members inherited from ofp_instruction_write_metadata:
@arg type
@arg len
@arg metadata
@arg metadata_mask
"""
def __init__(self):
ofp_instruction_write_metadata.__init__(self)
self.type = OFPIT_WRITE_METADATA
self.len = self.__len__()
def show(self, prefix=''):
outstr = prefix + "instruction_write_metadata\n"
outstr += ofp_instruction_write_metadata.show(self, prefix)
return outstr
class instruction_clear_actions(ofp_instruction):
"""
Wrapper class for clear_actions instruction object
Data members inherited from ofp_instruction:
@arg type
@arg len
"""
def __init__(self):
ofp_instruction.__init__(self)
self.type = OFPIT_CLEAR_ACTIONS
self.len = self.__len__()
def show(self, prefix=''):
outstr = prefix + "instruction_clear_actions\n"
outstr += ofp_instruction.show(self, prefix)
return outstr
instruction_class_list = (
instruction_apply_actions,
instruction_clear_actions,
instruction_experimenter,
instruction_goto_table,
instruction_write_actions,
instruction_write_metadata)