<s> """<STR_LIT>""" <EOL> import six <EOL> import struct <EOL> from ryu . lib import addrconv <EOL> from ryu . lib . pack_utils import msg_pack_into <EOL> from ryu import utils <EOL> from ryu . ofproto . ofproto_parser import StringifyMixin , MsgBase , MsgInMsgBase <EOL> from ryu . ofproto import ether <EOL> from ryu . ofproto import nx_actions <EOL> from ryu . ofproto import ofproto_parser <EOL> from ryu . ofproto import ofproto_common <EOL> from ryu . ofproto import ofproto_v1_4 as ofproto <EOL> _MSG_PARSERS = { } <EOL> def _set_msg_type ( msg_type ) : <EOL> def _set_cls_msg_type ( cls ) : <EOL> cls . cls_msg_type = msg_type <EOL> return cls <EOL> return _set_cls_msg_type <EOL> def _register_parser ( cls ) : <EOL> '''<STR_LIT>''' <EOL> assert cls . cls_msg_type is not None <EOL> assert cls . cls_msg_type not in _MSG_PARSERS <EOL> _MSG_PARSERS [ cls . cls_msg_type ] = cls . parser <EOL> return cls <EOL> @ ofproto_parser . register_msg_parser ( ofproto . OFP_VERSION ) <EOL> def msg_parser ( datapath , version , msg_type , msg_len , xid , buf ) : <EOL> parser = _MSG_PARSERS . get ( msg_type ) <EOL> return parser ( datapath , version , msg_type , msg_len , xid , buf ) <EOL> @ _register_parser <EOL> @ _set_msg_type ( ofproto . OFPT_HELLO ) <EOL> class OFPHello ( MsgBase ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , elements = None ) : <EOL> elements = elements if elements else [ ] <EOL> super ( OFPHello , self ) . __init__ ( datapath ) <EOL> self . elements = elements <EOL> @ classmethod <EOL> def parser ( cls , datapath , version , msg_type , msg_len , xid , buf ) : <EOL> msg = super ( OFPHello , cls ) . parser ( datapath , version , msg_type , <EOL> msg_len , xid , buf ) <EOL> offset = ofproto . OFP_HELLO_HEADER_SIZE <EOL> elems = [ ] <EOL> while offset < msg . msg_len : <EOL> type_ , length = struct . unpack_from ( <EOL> ofproto . OFP_HELLO_ELEM_HEADER_PACK_STR , msg . buf , offset ) <EOL> if type_ == ofproto . OFPHET_VERSIONBITMAP : <EOL> elem = OFPHelloElemVersionBitmap . parser ( msg . buf , offset ) <EOL> elems . append ( elem ) <EOL> offset += length <EOL> msg . elements = elems <EOL> return msg <EOL> class OFPHelloElemVersionBitmap ( StringifyMixin ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , versions , type_ = None , length = None ) : <EOL> super ( OFPHelloElemVersionBitmap , self ) . __init__ ( ) <EOL> self . type = ofproto . OFPHET_VERSIONBITMAP <EOL> self . length = None <EOL> self . _bitmaps = None <EOL> self . versions = versions <EOL> @ classmethod <EOL> def parser ( cls , buf , offset ) : <EOL> type_ , length = struct . unpack_from ( <EOL> ofproto . OFP_HELLO_ELEM_VERSIONBITMAP_HEADER_PACK_STR , <EOL> buf , offset ) <EOL> assert type_ == ofproto . OFPHET_VERSIONBITMAP <EOL> bitmaps_len = ( length - <EOL> ofproto . OFP_HELLO_ELEM_VERSIONBITMAP_HEADER_SIZE ) <EOL> offset += ofproto . OFP_HELLO_ELEM_VERSIONBITMAP_HEADER_SIZE <EOL> bitmaps = [ ] <EOL> while bitmaps_len >= <NUM_LIT:4> : <EOL> bitmap = struct . unpack_from ( '<STR_LIT>' , buf , offset ) <EOL> bitmaps . append ( bitmap [ <NUM_LIT:0> ] ) <EOL> offset += <NUM_LIT:4> <EOL> bitmaps_len -= <NUM_LIT:4> <EOL> versions = [ i * <NUM_LIT:32> + shift <EOL> for i , bitmap in enumerate ( bitmaps ) <EOL> for shift in range ( <NUM_LIT> ) if bitmap & ( <NUM_LIT:1> << shift ) ] <EOL> elem = cls ( versions ) <EOL> elem . length = length <EOL> elem . _bitmaps = bitmaps <EOL> return elem <EOL> @ _register_parser <EOL> @ _set_msg_type ( ofproto . OFPT_ECHO_REQUEST ) <EOL> class OFPEchoRequest ( MsgBase ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , data = None ) : <EOL> super ( OFPEchoRequest , self ) . __init__ ( datapath ) <EOL> self . data = data <EOL> @ classmethod <EOL> def parser ( cls , datapath , version , msg_type , msg_len , xid , buf ) : <EOL> msg = super ( OFPEchoRequest , cls ) . parser ( datapath , version , msg_type , <EOL> msg_len , xid , buf ) <EOL> msg . data = msg . buf [ ofproto . OFP_HEADER_SIZE : ] <EOL> return msg <EOL> def _serialize_body ( self ) : <EOL> if self . data is not None : <EOL> self . buf += self . data <EOL> @ _register_parser <EOL> @ _set_msg_type ( ofproto . OFPT_ERROR ) <EOL> class OFPErrorMsg ( MsgBase ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , type_ = None , code = None , data = None ) : <EOL> super ( OFPErrorMsg , self ) . __init__ ( datapath ) <EOL> self . type = type_ <EOL> self . code = code <EOL> self . data = data <EOL> @ classmethod <EOL> def parser ( cls , datapath , version , msg_type , msg_len , xid , buf ) : <EOL> type_ , = struct . unpack_from ( '<STR_LIT>' , six . binary_type ( buf ) , <EOL> ofproto . OFP_HEADER_SIZE ) <EOL> if type_ == ofproto . OFPET_EXPERIMENTER : <EOL> return OFPErrorExperimenterMsg . parser ( datapath , version , msg_type , <EOL> msg_len , xid , buf ) <EOL> msg = super ( OFPErrorMsg , cls ) . parser ( datapath , version , msg_type , <EOL> msg_len , xid , buf ) <EOL> msg . type , msg . code = struct . unpack_from ( <EOL> ofproto . OFP_ERROR_MSG_PACK_STR , msg . buf , <EOL> ofproto . OFP_HEADER_SIZE ) <EOL> msg . data = msg . buf [ ofproto . OFP_ERROR_MSG_SIZE : ] <EOL> return msg <EOL> def _serialize_body ( self ) : <EOL> assert self . data is not None <EOL> msg_pack_into ( ofproto . OFP_ERROR_MSG_PACK_STR , self . buf , <EOL> ofproto . OFP_HEADER_SIZE , self . type , self . code ) <EOL> self . buf += self . data <EOL> class OFPErrorExperimenterMsg ( MsgBase ) : <EOL> def __init__ ( self , datapath , type_ = None , exp_type = None , experimenter = None , <EOL> data = None ) : <EOL> super ( OFPErrorExperimenterMsg , self ) . __init__ ( datapath ) <EOL> self . type = ofproto . OFPET_EXPERIMENTER <EOL> self . exp_type = exp_type <EOL> self . experimenter = experimenter <EOL> self . data = data <EOL> @ classmethod <EOL> def parser ( cls , datapath , version , msg_type , msg_len , xid , buf ) : <EOL> cls . cls_msg_type = msg_type <EOL> msg = super ( OFPErrorExperimenterMsg , cls ) . parser ( <EOL> datapath , version , msg_type , msg_len , xid , buf ) <EOL> msg . type , msg . exp_type , msg . experimenter = struct . unpack_from ( <EOL> ofproto . OFP_ERROR_EXPERIMENTER_MSG_PACK_STR , msg . buf , <EOL> ofproto . OFP_HEADER_SIZE ) <EOL> msg . data = msg . buf [ ofproto . OFP_ERROR_EXPERIMENTER_MSG_SIZE : ] <EOL> return msg <EOL> def _serialize_body ( self ) : <EOL> assert self . data is not None <EOL> msg_pack_into ( ofproto . OFP_ERROR_EXPERIMENTER_MSG_PACK_STR , <EOL> self . buf , ofproto . OFP_HEADER_SIZE , <EOL> self . type , self . exp_type , self . experimenter ) <EOL> self . buf += self . data <EOL> @ _register_parser <EOL> @ _set_msg_type ( ofproto . OFPT_ECHO_REPLY ) <EOL> class OFPEchoReply ( MsgBase ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , data = None ) : <EOL> super ( OFPEchoReply , self ) . __init__ ( datapath ) <EOL> self . data = data <EOL> @ classmethod <EOL> def parser ( cls , datapath , version , msg_type , msg_len , xid , buf ) : <EOL> msg = super ( OFPEchoReply , cls ) . parser ( datapath , version , msg_type , <EOL> msg_len , xid , buf ) <EOL> msg . data = msg . buf [ ofproto . OFP_HEADER_SIZE : ] <EOL> return msg <EOL> def _serialize_body ( self ) : <EOL> assert self . data is not None <EOL> self . buf += self . data <EOL> @ _set_msg_type ( ofproto . OFPT_FEATURES_REQUEST ) <EOL> class OFPFeaturesRequest ( MsgBase ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath ) : <EOL> super ( OFPFeaturesRequest , self ) . __init__ ( datapath ) <EOL> @ _register_parser <EOL> @ _set_msg_type ( ofproto . OFPT_EXPERIMENTER ) <EOL> class OFPExperimenter ( MsgBase ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , experimenter = None , exp_type = None , data = None ) : <EOL> super ( OFPExperimenter , self ) . __init__ ( datapath ) <EOL> self . experimenter = experimenter <EOL> self . exp_type = exp_type <EOL> self . data = data <EOL> @ classmethod <EOL> def parser ( cls , datapath , version , msg_type , msg_len , xid , buf ) : <EOL> msg = super ( OFPExperimenter , cls ) . parser ( datapath , version , <EOL> msg_type , msg_len , <EOL> xid , buf ) <EOL> ( msg . experimenter , msg . exp_type ) = struct . unpack_from ( <EOL> ofproto . OFP_EXPERIMENTER_HEADER_PACK_STR , msg . buf , <EOL> ofproto . OFP_HEADER_SIZE ) <EOL> msg . data = msg . buf [ ofproto . OFP_EXPERIMENTER_HEADER_SIZE : ] <EOL> return msg <EOL> def _serialize_body ( self ) : <EOL> assert self . data is not None <EOL> msg_pack_into ( ofproto . OFP_EXPERIMENTER_HEADER_PACK_STR , <EOL> self . buf , ofproto . OFP_HEADER_SIZE , <EOL> self . experimenter , self . exp_type ) <EOL> self . buf += self . data <EOL> @ _register_parser <EOL> @ _set_msg_type ( ofproto . OFPT_FEATURES_REPLY ) <EOL> class OFPSwitchFeatures ( MsgBase ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , datapath_id = None , n_buffers = None , <EOL> n_tables = None , auxiliary_id = None , capabilities = None ) : <EOL> super ( OFPSwitchFeatures , self ) . __init__ ( datapath ) <EOL> self . datapath_id = datapath_id <EOL> self . n_buffers = n_buffers <EOL> self . n_tables = n_tables <EOL> self . auxiliary_id = auxiliary_id <EOL> self . capabilities = capabilities <EOL> @ classmethod <EOL> def parser ( cls , datapath , version , msg_type , msg_len , xid , buf ) : <EOL> msg = super ( OFPSwitchFeatures , cls ) . parser ( datapath , version , msg_type , <EOL> msg_len , xid , buf ) <EOL> ( msg . datapath_id , <EOL> msg . n_buffers , <EOL> msg . n_tables , <EOL> msg . auxiliary_id , <EOL> msg . capabilities , <EOL> msg . _reserved ) = struct . unpack_from ( <EOL> ofproto . OFP_SWITCH_FEATURES_PACK_STR , msg . buf , <EOL> ofproto . OFP_HEADER_SIZE ) <EOL> return msg <EOL> @ _set_msg_type ( ofproto . OFPT_GET_CONFIG_REQUEST ) <EOL> class OFPGetConfigRequest ( MsgBase ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath ) : <EOL> super ( OFPGetConfigRequest , self ) . __init__ ( datapath ) <EOL> @ _register_parser <EOL> @ _set_msg_type ( ofproto . OFPT_GET_CONFIG_REPLY ) <EOL> class OFPGetConfigReply ( MsgBase ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , flags = None , miss_send_len = None ) : <EOL> super ( OFPGetConfigReply , self ) . __init__ ( datapath ) <EOL> self . flags = flags <EOL> self . miss_send_len = miss_send_len <EOL> @ classmethod <EOL> def parser ( cls , datapath , version , msg_type , msg_len , xid , buf ) : <EOL> msg = super ( OFPGetConfigReply , cls ) . parser ( datapath , version , msg_type , <EOL> msg_len , xid , buf ) <EOL> msg . flags , msg . miss_send_len = struct . unpack_from ( <EOL> ofproto . OFP_SWITCH_CONFIG_PACK_STR , msg . buf , <EOL> ofproto . OFP_HEADER_SIZE ) <EOL> return msg <EOL> @ _set_msg_type ( ofproto . OFPT_SET_CONFIG ) <EOL> class OFPSetConfig ( MsgBase ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , flags = <NUM_LIT:0> , miss_send_len = <NUM_LIT:0> ) : <EOL> super ( OFPSetConfig , self ) . __init__ ( datapath ) <EOL> self . flags = flags <EOL> self . miss_send_len = miss_send_len <EOL> def _serialize_body ( self ) : <EOL> assert self . flags is not None <EOL> assert self . miss_send_len is not None <EOL> msg_pack_into ( ofproto . OFP_SWITCH_CONFIG_PACK_STR , <EOL> self . buf , ofproto . OFP_HEADER_SIZE , <EOL> self . flags , self . miss_send_len ) <EOL> class OFPMatch ( StringifyMixin ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , type_ = None , length = None , _ordered_fields = None , <EOL> ** kwargs ) : <EOL> super ( OFPMatch , self ) . __init__ ( ) <EOL> self . type = ofproto . OFPMT_OXM <EOL> self . length = length <EOL> if _ordered_fields is not None : <EOL> assert not kwargs <EOL> self . _fields2 = _ordered_fields <EOL> else : <EOL> kwargs = dict ( ofproto . oxm_normalize_user ( k , v ) for <EOL> ( k , v ) in kwargs . items ( ) ) <EOL> fields = [ ofproto . oxm_from_user ( k , v ) for ( k , v ) <EOL> in kwargs . items ( ) ] <EOL> fields . sort ( <EOL> key = lambda x : x [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] if isinstance ( x [ <NUM_LIT:0> ] , tuple ) else x [ <NUM_LIT:0> ] ) <EOL> self . _fields2 = [ ofproto . oxm_to_user ( n , v , m ) for ( n , v , m ) <EOL> in fields ] <EOL> @ classmethod <EOL> def parser ( cls , buf , offset ) : <EOL> """<STR_LIT>""" <EOL> match = OFPMatch ( ) <EOL> type_ , length = struct . unpack_from ( '<STR_LIT>' , buf , offset ) <EOL> match . type = type_ <EOL> match . length = length <EOL> offset += <NUM_LIT:4> <EOL> length -= <NUM_LIT:4> <EOL> fields = [ ] <EOL> while length > <NUM_LIT:0> : <EOL> n , value , mask , field_len = ofproto . oxm_parse ( buf , offset ) <EOL> k , uv = ofproto . oxm_to_user ( n , value , mask ) <EOL> fields . append ( ( k , uv ) ) <EOL> offset += field_len <EOL> length -= field_len <EOL> match . _fields2 = fields <EOL> return match <EOL> def serialize ( self , buf , offset ) : <EOL> """<STR_LIT>""" <EOL> fields = [ ofproto . oxm_from_user ( k , uv ) for ( k , uv ) <EOL> in self . _fields2 ] <EOL> hdr_pack_str = '<STR_LIT>' <EOL> field_offset = offset + struct . calcsize ( hdr_pack_str ) <EOL> for ( n , value , mask ) in fields : <EOL> field_offset += ofproto . oxm_serialize ( n , value , mask , buf , <EOL> field_offset ) <EOL> length = field_offset - offset <EOL> msg_pack_into ( hdr_pack_str , buf , offset , ofproto . OFPMT_OXM , length ) <EOL> self . length = length <EOL> pad_len = utils . round_up ( length , <NUM_LIT:8> ) - length <EOL> msg_pack_into ( "<STR_LIT>" % pad_len , buf , field_offset ) <EOL> return length + pad_len <EOL> def __getitem__ ( self , key ) : <EOL> return dict ( self . _fields2 ) [ key ] <EOL> def __contains__ ( self , key ) : <EOL> return key in dict ( self . _fields2 ) <EOL> def iteritems ( self ) : <EOL> return iter ( dict ( self . _fields2 ) . items ( ) ) <EOL> def items ( self ) : <EOL> return self . _fields2 <EOL> def get ( self , key , default = None ) : <EOL> return dict ( self . _fields2 ) . get ( key , default ) <EOL> def stringify_attrs ( self ) : <EOL> yield "<STR_LIT>" , dict ( self . _fields2 ) <EOL> def to_jsondict ( self ) : <EOL> """<STR_LIT>""" <EOL> body = { "<STR_LIT>" : [ ofproto . oxm_to_jsondict ( k , uv ) for k , uv <EOL> in self . _fields2 ] , <EOL> "<STR_LIT>" : self . length , <EOL> "<STR_LIT:type>" : self . type } <EOL> return { self . __class__ . __name__ : body } <EOL> @ classmethod <EOL> def from_jsondict ( cls , dict_ ) : <EOL> """<STR_LIT>""" <EOL> fields = [ ofproto . oxm_from_jsondict ( f ) for f <EOL> in dict_ [ '<STR_LIT>' ] ] <EOL> return OFPMatch ( _ordered_fields = fields ) <EOL> class OFPPropUnknown ( StringifyMixin ) : <EOL> def __init__ ( self , type_ = None , length = None , buf = None ) : <EOL> self . buf = buf <EOL> @ classmethod <EOL> def parser ( cls , buf ) : <EOL> return cls ( buf = buf ) <EOL> class OFPPropBase ( StringifyMixin ) : <EOL> _PACK_STR = '<STR_LIT>' <EOL> def __init__ ( self , type_ , length = None ) : <EOL> self . type = type_ <EOL> self . length = length <EOL> @ classmethod <EOL> def register_type ( cls , type_ ) : <EOL> def _register_type ( subcls ) : <EOL> cls . _TYPES [ type_ ] = subcls <EOL> return subcls <EOL> return _register_type <EOL> @ classmethod <EOL> def parse ( cls , buf ) : <EOL> ( type_ , length ) = struct . unpack_from ( cls . _PACK_STR , buf , <NUM_LIT:0> ) <EOL> rest = buf [ utils . round_up ( length , <NUM_LIT:8> ) : ] <EOL> try : <EOL> subcls = cls . _TYPES [ type_ ] <EOL> except KeyError : <EOL> subcls = OFPPropUnknown <EOL> prop = subcls . parser ( buf ) <EOL> prop . type = type_ <EOL> prop . length = length <EOL> return prop , rest <EOL> @ classmethod <EOL> def get_rest ( cls , buf ) : <EOL> ( type_ , length ) = struct . unpack_from ( cls . _PACK_STR , buf , <NUM_LIT:0> ) <EOL> offset = struct . calcsize ( cls . _PACK_STR ) <EOL> return buf [ offset : length ] <EOL> def serialize ( self ) : <EOL> body = bytearray ( ) <EOL> body += self . serialize_body ( ) <EOL> self . length = len ( body ) + struct . calcsize ( self . _PACK_STR ) <EOL> buf = bytearray ( ) <EOL> msg_pack_into ( self . _PACK_STR , buf , <NUM_LIT:0> , self . type , self . length ) <EOL> buf += body <EOL> pad_len = utils . round_up ( self . length , <NUM_LIT:8> ) - self . length <EOL> msg_pack_into ( "<STR_LIT>" % pad_len , buf , len ( buf ) ) <EOL> return buf <EOL> class OFPPropCommonExperimenter4ByteData ( StringifyMixin ) : <EOL> _PACK_STR = '<STR_LIT>' <EOL> _EXPERIMENTER_DATA_PACK_STR = '<STR_LIT>' <EOL> _EXPERIMENTER_DATA_SIZE = <NUM_LIT:4> <EOL> def __init__ ( self , type_ = None , length = None , experimenter = None , <EOL> exp_type = None , data = bytearray ( ) ) : <EOL> self . type = type_ <EOL> self . length = length <EOL> self . experimenter = experimenter <EOL> self . exp_type = exp_type <EOL> self . data = data <EOL> @ classmethod <EOL> def parser ( cls , buf ) : <EOL> ( type_ , length , experimenter , exp_type ) = struct . unpack_from ( <EOL> ofproto . OFP_PROP_EXPERIMENTER_PACK_STR , buf , <NUM_LIT:0> ) <EOL> rest = buf [ ofproto . OFP_PROP_EXPERIMENTER_SIZE : length ] <EOL> data = [ ] <EOL> while rest : <EOL> ( d , ) = struct . unpack_from ( <EOL> cls . _EXPERIMENTER_DATA_PACK_STR , rest , <NUM_LIT:0> ) <EOL> data . append ( d ) <EOL> rest = rest [ cls . _EXPERIMENTER_DATA_SIZE : ] <EOL> return cls ( type_ , length , experimenter , exp_type , data ) <EOL> def serialize ( self ) : <EOL> offset = <NUM_LIT:0> <EOL> bin_data = bytearray ( ) <EOL> for d in self . data : <EOL> msg_pack_into ( self . _EXPERIMENTER_DATA_PACK_STR , <EOL> bin_data , offset , d ) <EOL> offset += self . _EXPERIMENTER_DATA_SIZE <EOL> self . length = struct . calcsize ( self . _PACK_STR ) <EOL> self . length += len ( bin_data ) <EOL> buf = bytearray ( ) <EOL> msg_pack_into ( self . _PACK_STR , buf , <EOL> <NUM_LIT:0> , self . type , self . length , self . experimenter , <EOL> self . exp_type ) <EOL> buf += bin_data <EOL> pad_len = utils . round_up ( self . length , <NUM_LIT:8> ) - self . length <EOL> msg_pack_into ( "<STR_LIT>" % pad_len , buf , len ( buf ) ) <EOL> return buf <EOL> class OFPPortDescProp ( OFPPropBase ) : <EOL> _TYPES = { } <EOL> @ OFPPortDescProp . register_type ( ofproto . OFPPDPT_ETHERNET ) <EOL> class OFPPortDescPropEthernet ( OFPPortDescProp ) : <EOL> def __init__ ( self , type_ = None , length = None , curr = None , advertised = None , <EOL> supported = None , peer = None , curr_speed = None , max_speed = None ) : <EOL> self . type = type_ <EOL> self . length = length <EOL> self . curr = curr <EOL> self . advertised = advertised <EOL> self . supported = supported <EOL> self . peer = peer <EOL> self . curr_speed = curr_speed <EOL> self . max_speed = max_speed <EOL> @ classmethod <EOL> def parser ( cls , buf ) : <EOL> ether = cls ( ) <EOL> ( ether . type , ether . length , ether . curr , <EOL> ether . advertised , ether . supported , <EOL> ether . peer , ether . curr_speed , ether . max_speed ) = struct . unpack_from ( <EOL> ofproto . OFP_PORT_DESC_PROP_ETHERNET_PACK_STR , buf , <NUM_LIT:0> ) <EOL> return ether <EOL> @ OFPPortDescProp . register_type ( ofproto . OFPPDPT_OPTICAL ) <EOL> class OFPPortDescPropOptical ( OFPPortDescProp ) : <EOL> def __init__ ( self , type_ = None , length = None , supported = None , <EOL> tx_min_freq_lmda = None , tx_max_freq_lmda = None , <EOL> tx_grid_freq_lmda = None , rx_min_freq_lmda = None , <EOL> rx_max_freq_lmda = None , rx_grid_freq_lmda = None , <EOL> tx_pwr_min = None , tx_pwr_max = None ) : <EOL> self . type = type_ <EOL> self . length = length <EOL> self . supported = supported <EOL> self . tx_min_freq_lmda = tx_min_freq_lmda <EOL> self . tx_max_freq_lmda = tx_max_freq_lmda <EOL> self . tx_grid_freq_lmda = tx_grid_freq_lmda <EOL> self . rx_min_freq_lmda = rx_min_freq_lmda <EOL> self . rx_max_freq_lmda = rx_max_freq_lmda <EOL> self . rx_grid_freq_lmda = rx_grid_freq_lmda <EOL> self . tx_pwr_min = tx_pwr_min <EOL> self . tx_pwr_max = tx_pwr_max <EOL> @ classmethod <EOL> def parser ( cls , buf ) : <EOL> optical = cls ( ) <EOL> ( optical . type , optical . length , optical . supported , <EOL> optical . tx_min_freq_lmda , optical . tx_max_freq_lmda , <EOL> optical . tx_grid_freq_lmda , optical . rx_min_freq_lmda , <EOL> optical . rx_max_freq_lmda , optical . rx_grid_freq_lmda , <EOL> optical . tx_pwr_min , optical . tx_pwr_max ) = struct . unpack_from ( <EOL> ofproto . OFP_PORT_DESC_PROP_OPTICAL_PACK_STR , buf , <NUM_LIT:0> ) <EOL> return optical <EOL> @ OFPPortDescProp . register_type ( ofproto . OFPPDPT_EXPERIMENTER ) <EOL> class OFPPortDescPropExperimenter ( OFPPropCommonExperimenter4ByteData ) : <EOL> pass <EOL> class OFPTableModProp ( OFPPropBase ) : <EOL> _TYPES = { } <EOL> @ OFPTableModProp . register_type ( ofproto . OFPTMPT_EVICTION ) <EOL> class OFPTableModPropEviction ( OFPTableModProp ) : <EOL> def __init__ ( self , type_ = None , length = None , flags = None ) : <EOL> self . type = type_ <EOL> self . length = length <EOL> self . flags = flags <EOL> @ classmethod <EOL> def parser ( cls , buf ) : <EOL> eviction = cls ( ) <EOL> ( eviction . type , eviction . length , eviction . flags ) = struct . unpack_from ( <EOL> ofproto . OFP_TABLE_MOD_PROP_EVICTION_PACK_STR , buf , <NUM_LIT:0> ) <EOL> return eviction <EOL> def serialize ( self ) : <EOL> self . length = ofproto . OFP_TABLE_MOD_PROP_EVICTION_SIZE <EOL> buf = bytearray ( ) <EOL> msg_pack_into ( ofproto . OFP_TABLE_MOD_PROP_EVICTION_PACK_STR , buf , <NUM_LIT:0> , <EOL> self . type , self . length , self . flags ) <EOL> return buf <EOL> @ OFPTableModProp . register_type ( ofproto . OFPTMPT_VACANCY ) <EOL> class OFPTableModPropVacancy ( OFPTableModProp ) : <EOL> def __init__ ( self , type_ = None , length = None , vacancy_down = None , <EOL> vacancy_up = None , vacancy = None ) : <EOL> self . type = type_ <EOL> self . length = length <EOL> self . vacancy_down = vacancy_down <EOL> self . vacancy_up = vacancy_up <EOL> self . vacancy = vacancy <EOL> @ classmethod <EOL> def parser ( cls , buf ) : <EOL> vacancy = cls ( ) <EOL> ( vacancy . type , vacancy . length , vacancy . vacancy_down , <EOL> vacancy . vacancy_up , vacancy . vacancy ) = struct . unpack_from ( <EOL> ofproto . OFP_TABLE_MOD_PROP_VACANCY_PACK_STR , buf , <NUM_LIT:0> ) <EOL> return vacancy <EOL> def serialize ( self ) : <EOL> self . length = ofproto . OFP_TABLE_MOD_PROP_VACANCY_SIZE <EOL> buf = bytearray ( ) <EOL> msg_pack_into ( ofproto . OFP_TABLE_MOD_PROP_VACANCY_PACK_STR , buf , <NUM_LIT:0> , <EOL> self . type , self . length , self . vacancy_down , <EOL> self . vacancy_up , self . vacancy ) <EOL> return buf <EOL> @ OFPTableModProp . register_type ( ofproto . OFPTMPT_EXPERIMENTER ) <EOL> class OFPTableModPropExperimenter ( OFPPropCommonExperimenter4ByteData ) : <EOL> pass <EOL> class OFPQueueDescProp ( OFPPropBase ) : <EOL> _TYPES = { } <EOL> @ OFPQueueDescProp . register_type ( ofproto . OFPQDPT_MIN_RATE ) <EOL> class OFPQueueDescPropMinRate ( OFPQueueDescProp ) : <EOL> def __init__ ( self , type_ = None , length = None , rate = None ) : <EOL> self . type = type_ <EOL> self . length = length <EOL> self . rate = rate <EOL> @ classmethod <EOL> def parser ( cls , buf ) : <EOL> minrate = cls ( ) <EOL> ( minrate . type , minrate . length , minrate . rate ) = struct . unpack_from ( <EOL> ofproto . OFP_QUEUE_DESC_PROP_MIN_RATE_PACK_STR , buf , <NUM_LIT:0> ) <EOL> return minrate <EOL> @ OFPQueueDescProp . register_type ( ofproto . OFPQDPT_MAX_RATE ) <EOL> class OFPQueueDescPropMaxRate ( OFPQueueDescProp ) : <EOL> def __init__ ( self , type_ = None , length = None , rate = None ) : <EOL> self . type = type_ <EOL> self . length = length <EOL> self . rate = rate <EOL> @ classmethod <EOL> def parser ( cls , buf ) : <EOL> maxrate = cls ( ) <EOL> ( maxrate . type , maxrate . length , maxrate . rate ) = struct . unpack_from ( <EOL> ofproto . OFP_QUEUE_DESC_PROP_MAX_RATE_PACK_STR , buf , <NUM_LIT:0> ) <EOL> return maxrate <EOL> @ OFPQueueDescProp . register_type ( ofproto . OFPQDPT_EXPERIMENTER ) <EOL> class OFPQueueDescPropExperimenter ( OFPPropCommonExperimenter4ByteData ) : <EOL> pass <EOL> class OFPRoleProp ( OFPPropBase ) : <EOL> _TYPES = { } <EOL> @ OFPRoleProp . register_type ( ofproto . OFPRPT_EXPERIMENTER ) <EOL> class OFPRolePropExperimenter ( OFPPropCommonExperimenter4ByteData ) : <EOL> pass <EOL> class OFPBundleProp ( OFPPropBase ) : <EOL> _TYPES = { } <EOL> @ OFPBundleProp . register_type ( ofproto . OFPRPT_EXPERIMENTER ) <EOL> class OFPBundlePropExperimenter ( OFPPropCommonExperimenter4ByteData ) : <EOL> pass <EOL> @ _register_parser <EOL> @ _set_msg_type ( ofproto . OFPT_PACKET_IN ) <EOL> class OFPPacketIn ( MsgBase ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , buffer_id = None , total_len = None , reason = None , <EOL> table_id = None , cookie = None , match = None , data = None ) : <EOL> super ( OFPPacketIn , self ) . __init__ ( datapath ) <EOL> self . buffer_id = buffer_id <EOL> self . total_len = total_len <EOL> self . reason = reason <EOL> self . table_id = table_id <EOL> self . cookie = cookie <EOL> self . match = match <EOL> self . data = data <EOL> @ classmethod <EOL> def parser ( cls , datapath , version , msg_type , msg_len , xid , buf ) : <EOL> msg = super ( OFPPacketIn , cls ) . parser ( datapath , version , msg_type , <EOL> msg_len , xid , buf ) <EOL> ( msg . buffer_id , msg . total_len , msg . reason , <EOL> msg . table_id , msg . cookie ) = struct . unpack_from ( <EOL> ofproto . OFP_PACKET_IN_PACK_STR , <EOL> msg . buf , ofproto . OFP_HEADER_SIZE ) <EOL> msg . match = OFPMatch . parser ( msg . buf , ofproto . OFP_PACKET_IN_SIZE - <EOL> ofproto . OFP_MATCH_SIZE ) <EOL> match_len = utils . round_up ( msg . match . length , <NUM_LIT:8> ) <EOL> msg . data = msg . buf [ ( ofproto . OFP_PACKET_IN_SIZE - <EOL> ofproto . OFP_MATCH_SIZE + match_len + <NUM_LIT:2> ) : ] <EOL> if msg . total_len < len ( msg . data ) : <EOL> msg . data = msg . data [ : msg . total_len ] <EOL> return msg <EOL> @ _register_parser <EOL> @ _set_msg_type ( ofproto . OFPT_FLOW_REMOVED ) <EOL> class OFPFlowRemoved ( MsgBase ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , cookie = None , priority = None , reason = None , <EOL> table_id = None , duration_sec = None , duration_nsec = None , <EOL> idle_timeout = None , hard_timeout = None , packet_count = None , <EOL> byte_count = None , match = None ) : <EOL> super ( OFPFlowRemoved , self ) . __init__ ( datapath ) <EOL> self . cookie = cookie <EOL> self . priority = priority <EOL> self . reason = reason <EOL> self . table_id = table_id <EOL> self . duration_sec = duration_sec <EOL> self . duration_nsec = duration_nsec <EOL> self . idle_timeout = idle_timeout <EOL> self . hard_timeout = hard_timeout <EOL> self . packet_count = packet_count <EOL> self . byte_count = byte_count <EOL> self . match = match <EOL> @ classmethod <EOL> def parser ( cls , datapath , version , msg_type , msg_len , xid , buf ) : <EOL> msg = super ( OFPFlowRemoved , cls ) . parser ( datapath , version , msg_type , <EOL> msg_len , xid , buf ) <EOL> ( msg . cookie , msg . priority , msg . reason , <EOL> msg . table_id , msg . duration_sec , msg . duration_nsec , <EOL> msg . idle_timeout , msg . hard_timeout , msg . packet_count , <EOL> msg . byte_count ) = struct . unpack_from ( <EOL> ofproto . OFP_FLOW_REMOVED_PACK_STR0 , <EOL> msg . buf , ofproto . OFP_HEADER_SIZE ) <EOL> offset = ( ofproto . OFP_FLOW_REMOVED_SIZE - ofproto . OFP_MATCH_SIZE ) <EOL> msg . match = OFPMatch . parser ( msg . buf , offset ) <EOL> return msg <EOL> class OFPPort ( StringifyMixin ) : <EOL> """<STR_LIT>""" <EOL> _TYPE = { <EOL> '<STR_LIT:ascii>' : [ <EOL> '<STR_LIT>' , <EOL> ] , <EOL> '<STR_LIT:utf-8>' : [ <EOL> '<STR_LIT:name>' , <EOL> ] <EOL> } <EOL> def __init__ ( self , port_no = None , length = None , hw_addr = None , name = None , <EOL> config = None , state = None , properties = None ) : <EOL> super ( OFPPort , self ) . __init__ ( ) <EOL> self . port_no = port_no <EOL> self . length = length <EOL> self . hw_addr = hw_addr <EOL> self . name = name <EOL> self . config = config <EOL> self . state = state <EOL> self . properties = properties <EOL> @ classmethod <EOL> def parser ( cls , buf , offset ) : <EOL> ( port_no , length , hw_addr , name , config , state ) = struct . unpack_from ( <EOL> ofproto . OFP_PORT_PACK_STR , buf , offset ) <EOL> hw_addr = addrconv . mac . bin_to_text ( hw_addr ) <EOL> name = name . rstrip ( b'<STR_LIT>' ) <EOL> props = [ ] <EOL> rest = buf [ offset + ofproto . OFP_PORT_SIZE : offset + length ] <EOL> while rest : <EOL> p , rest = OFPPortDescProp . parse ( rest ) <EOL> props . append ( p ) <EOL> ofpport = cls ( port_no , length , hw_addr , name , config , state , props ) <EOL> return ofpport <EOL> class OFPTableDesc ( StringifyMixin ) : <EOL> def __init__ ( self , length = None , table_id = None , config = None , <EOL> properties = None ) : <EOL> super ( OFPTableDesc , self ) . __init__ ( ) <EOL> self . table_id = table_id <EOL> self . length = length <EOL> self . config = config <EOL> self . properties = properties <EOL> @ classmethod <EOL> def parser ( cls , buf , offset ) : <EOL> ( length , table_id , config ) = struct . unpack_from ( <EOL> ofproto . OFP_TABLE_DESC_PACK_STR , buf , offset ) <EOL> props = [ ] <EOL> rest = buf [ offset + ofproto . OFP_TABLE_DESC_SIZE : offset + length ] <EOL> while rest : <EOL> p , rest = OFPTableModProp . parse ( rest ) <EOL> props . append ( p ) <EOL> ofptabledesc = cls ( length , table_id , config , props ) <EOL> return ofptabledesc <EOL> class OFPQueueDesc ( StringifyMixin ) : <EOL> def __init__ ( self , port_no = None , queue_id = None , len_ = None , <EOL> properties = None ) : <EOL> super ( OFPQueueDesc , self ) . __init__ ( ) <EOL> self . port_no = port_no <EOL> self . queue_id = queue_id <EOL> self . len = len_ <EOL> self . properties = properties <EOL> @ classmethod <EOL> def parser ( cls , buf , offset ) : <EOL> ( port_no , queue_id , len_ ) = struct . unpack_from ( <EOL> ofproto . OFP_QUEUE_DESC_PACK_STR , buf , offset ) <EOL> props = [ ] <EOL> rest = buf [ offset + ofproto . OFP_QUEUE_DESC_SIZE : offset + len_ ] <EOL> while rest : <EOL> p , rest = OFPQueueDescProp . parse ( rest ) <EOL> props . append ( p ) <EOL> ofpqueuedesc = cls ( port_no , queue_id , len_ , props ) <EOL> return ofpqueuedesc <EOL> def _set_stats_type ( stats_type , stats_body_cls ) : <EOL> def _set_cls_stats_type ( cls ) : <EOL> cls . cls_stats_type = stats_type <EOL> cls . cls_stats_body_cls = stats_body_cls <EOL> return cls <EOL> return _set_cls_stats_type <EOL> @ _set_msg_type ( ofproto . OFPT_MULTIPART_REQUEST ) <EOL> class OFPMultipartRequest ( MsgBase ) : <EOL> def __init__ ( self , datapath , flags ) : <EOL> super ( OFPMultipartRequest , self ) . __init__ ( datapath ) <EOL> self . type = self . __class__ . cls_stats_type <EOL> self . flags = flags <EOL> def _serialize_stats_body ( self ) : <EOL> pass <EOL> def _serialize_body ( self ) : <EOL> msg_pack_into ( ofproto . OFP_MULTIPART_REQUEST_PACK_STR , <EOL> self . buf , ofproto . OFP_HEADER_SIZE , <EOL> self . type , self . flags ) <EOL> self . _serialize_stats_body ( ) <EOL> @ _register_parser <EOL> @ _set_msg_type ( ofproto . OFPT_METER_MOD ) <EOL> class OFPMeterMod ( MsgBase ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , command = ofproto . OFPMC_ADD , <EOL> flags = ofproto . OFPMF_KBPS , meter_id = <NUM_LIT:1> , bands = None ) : <EOL> bands = bands if bands else [ ] <EOL> super ( OFPMeterMod , self ) . __init__ ( datapath ) <EOL> self . command = command <EOL> self . flags = flags <EOL> self . meter_id = meter_id <EOL> self . bands = bands <EOL> @ classmethod <EOL> def parser ( cls , datapath , version , msg_type , msg_len , xid , buf ) : <EOL> msg = super ( OFPMeterMod , cls ) . parser ( <EOL> datapath , version , msg_type , msg_len , xid , buf ) <EOL> ( msg . command , msg . flags , msg . meter_id ) = struct . unpack_from ( <EOL> ofproto . OFP_METER_MOD_PACK_STR , buf , ofproto . OFP_HEADER_SIZE ) <EOL> offset = ofproto . OFP_METER_MOD_SIZE <EOL> msg . bands = [ ] <EOL> while offset < msg . msg_len : <EOL> band = OFPMeterBandHeader . parser ( buf , offset ) <EOL> msg . bands . append ( band ) <EOL> offset += band . len <EOL> return msg <EOL> def _serialize_body ( self ) : <EOL> msg_pack_into ( ofproto . OFP_METER_MOD_PACK_STR , self . buf , <EOL> ofproto . OFP_HEADER_SIZE , <EOL> self . command , self . flags , self . meter_id ) <EOL> offset = ofproto . OFP_METER_MOD_SIZE <EOL> for b in self . bands : <EOL> b . serialize ( self . buf , offset ) <EOL> offset += b . len <EOL> @ _set_msg_type ( ofproto . OFPT_TABLE_MOD ) <EOL> class OFPTableMod ( MsgBase ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , table_id , config , properties ) : <EOL> super ( OFPTableMod , self ) . __init__ ( datapath ) <EOL> self . table_id = table_id <EOL> self . config = config <EOL> self . properties = properties <EOL> def _serialize_body ( self ) : <EOL> props_buf = bytearray ( ) <EOL> for p in self . properties : <EOL> props_buf += p . serialize ( ) <EOL> msg_pack_into ( ofproto . OFP_TABLE_MOD_PACK_STR , self . buf , <EOL> ofproto . OFP_HEADER_SIZE , <EOL> self . table_id , self . config ) <EOL> self . buf += props_buf <EOL> @ _register_parser <EOL> @ _set_msg_type ( ofproto . OFPT_MULTIPART_REPLY ) <EOL> class OFPMultipartReply ( MsgBase ) : <EOL> _STATS_MSG_TYPES = { } <EOL> @ staticmethod <EOL> def register_stats_type ( body_single_struct = False ) : <EOL> def _register_stats_type ( cls ) : <EOL> assert cls . cls_stats_type is not None <EOL> assert cls . cls_stats_type not in OFPMultipartReply . _STATS_MSG_TYPES <EOL> assert cls . cls_stats_body_cls is not None <EOL> cls . cls_body_single_struct = body_single_struct <EOL> OFPMultipartReply . _STATS_MSG_TYPES [ cls . cls_stats_type ] = cls <EOL> return cls <EOL> return _register_stats_type <EOL> def __init__ ( self , datapath , body = None , flags = None ) : <EOL> super ( OFPMultipartReply , self ) . __init__ ( datapath ) <EOL> self . body = body <EOL> self . flags = flags <EOL> @ classmethod <EOL> def parser_stats_body ( cls , buf , msg_len , offset ) : <EOL> body_cls = cls . cls_stats_body_cls <EOL> body = [ ] <EOL> while offset < msg_len : <EOL> entry = body_cls . parser ( buf , offset ) <EOL> body . append ( entry ) <EOL> offset += entry . length <EOL> if cls . cls_body_single_struct : <EOL> return body [ <NUM_LIT:0> ] <EOL> return body <EOL> @ classmethod <EOL> def parser_stats ( cls , datapath , version , msg_type , msg_len , xid , buf ) : <EOL> msg = MsgBase . parser . __func__ ( <EOL> cls , datapath , version , msg_type , msg_len , xid , buf ) <EOL> msg . body = msg . parser_stats_body ( msg . buf , msg . msg_len , <EOL> ofproto . OFP_MULTIPART_REPLY_SIZE ) <EOL> return msg <EOL> @ classmethod <EOL> def parser ( cls , datapath , version , msg_type , msg_len , xid , buf ) : <EOL> type_ , flags = struct . unpack_from ( <EOL> ofproto . OFP_MULTIPART_REPLY_PACK_STR , six . binary_type ( buf ) , <EOL> ofproto . OFP_HEADER_SIZE ) <EOL> stats_type_cls = cls . _STATS_MSG_TYPES . get ( type_ ) <EOL> msg = super ( OFPMultipartReply , stats_type_cls ) . parser ( <EOL> datapath , version , msg_type , msg_len , xid , buf ) <EOL> msg . type = type_ <EOL> msg . flags = flags <EOL> offset = ofproto . OFP_MULTIPART_REPLY_SIZE <EOL> body = [ ] <EOL> while offset < msg_len : <EOL> b = stats_type_cls . cls_stats_body_cls . parser ( msg . buf , offset ) <EOL> body . append ( b ) <EOL> offset += b . length if hasattr ( b , '<STR_LIT>' ) else b . len <EOL> if stats_type_cls . cls_body_single_struct : <EOL> msg . body = body [ <NUM_LIT:0> ] <EOL> else : <EOL> msg . body = body <EOL> return msg <EOL> class OFPDescStats ( ofproto_parser . namedtuple ( '<STR_LIT>' , ( <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) ) ) : <EOL> _TYPE = { <EOL> '<STR_LIT:ascii>' : [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] <EOL> } <EOL> @ classmethod <EOL> def parser ( cls , buf , offset ) : <EOL> desc = struct . unpack_from ( ofproto . OFP_DESC_PACK_STR , <EOL> buf , offset ) <EOL> desc = list ( desc ) <EOL> desc = [ x . rstrip ( b'<STR_LIT>' ) for x in desc ] <EOL> stats = cls ( * desc ) <EOL> stats . length = ofproto . OFP_DESC_SIZE <EOL> return stats <EOL> @ _set_stats_type ( ofproto . OFPMP_DESC , OFPDescStats ) <EOL> @ _set_msg_type ( ofproto . OFPT_MULTIPART_REQUEST ) <EOL> class OFPDescStatsRequest ( OFPMultipartRequest ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , flags = <NUM_LIT:0> , type_ = None ) : <EOL> super ( OFPDescStatsRequest , self ) . __init__ ( datapath , flags ) <EOL> @ OFPMultipartReply . register_stats_type ( body_single_struct = True ) <EOL> @ _set_stats_type ( ofproto . OFPMP_DESC , OFPDescStats ) <EOL> @ _set_msg_type ( ofproto . OFPT_MULTIPART_REPLY ) <EOL> class OFPDescStatsReply ( OFPMultipartReply ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , type_ = None , ** kwargs ) : <EOL> super ( OFPDescStatsReply , self ) . __init__ ( datapath , ** kwargs ) <EOL> class OFPTableFeaturesStats ( StringifyMixin ) : <EOL> _TYPE = { <EOL> '<STR_LIT:utf-8>' : [ <EOL> '<STR_LIT:name>' , <EOL> ] <EOL> } <EOL> def __init__ ( self , table_id = None , name = None , metadata_match = None , <EOL> metadata_write = None , config = None , max_entries = None , <EOL> properties = None , length = None ) : <EOL> super ( OFPTableFeaturesStats , self ) . __init__ ( ) <EOL> self . length = None <EOL> self . table_id = table_id <EOL> self . name = name <EOL> self . metadata_match = metadata_match <EOL> self . metadata_write = metadata_write <EOL> self . config = config <EOL> self . max_entries = max_entries <EOL> self . properties = properties <EOL> @ classmethod <EOL> def parser ( cls , buf , offset ) : <EOL> table_features = cls ( ) <EOL> ( table_features . length , table_features . table_id , <EOL> name , table_features . metadata_match , <EOL> table_features . metadata_write , table_features . config , <EOL> table_features . max_entries <EOL> ) = struct . unpack_from ( ofproto . OFP_TABLE_FEATURES_PACK_STR , <EOL> buf , offset ) <EOL> table_features . name = name . rstrip ( b'<STR_LIT>' ) <EOL> props = [ ] <EOL> rest = buf [ offset + ofproto . OFP_TABLE_FEATURES_SIZE : <EOL> offset + table_features . length ] <EOL> while rest : <EOL> p , rest = OFPTableFeatureProp . parse ( rest ) <EOL> props . append ( p ) <EOL> table_features . properties = props <EOL> return table_features <EOL> def serialize ( self ) : <EOL> bin_props = bytearray ( ) <EOL> for p in self . properties : <EOL> bin_props += p . serialize ( ) <EOL> self . length = ofproto . OFP_TABLE_FEATURES_SIZE + len ( bin_props ) <EOL> buf = bytearray ( ) <EOL> msg_pack_into ( ofproto . OFP_TABLE_FEATURES_PACK_STR , buf , <NUM_LIT:0> , <EOL> self . length , self . table_id , self . name , <EOL> self . metadata_match , self . metadata_write , <EOL> self . config , self . max_entries ) <EOL> return buf + bin_props <EOL> class OFPTableFeatureProp ( OFPPropBase ) : <EOL> _TYPES = { } <EOL> class OFPInstructionId ( StringifyMixin ) : <EOL> _PACK_STR = '<STR_LIT>' <EOL> def __init__ ( self , type_ , len_ = None ) : <EOL> self . type = type_ <EOL> self . len = len_ <EOL> @ classmethod <EOL> def parse ( cls , buf ) : <EOL> ( type_ , len_ , ) = struct . unpack_from ( cls . _PACK_STR , <EOL> six . binary_type ( buf ) , <NUM_LIT:0> ) <EOL> rest = buf [ len_ : ] <EOL> return cls ( type_ = type_ , len_ = len_ ) , rest <EOL> def serialize ( self ) : <EOL> self . len = struct . calcsize ( self . _PACK_STR ) <EOL> buf = bytearray ( ) <EOL> msg_pack_into ( self . _PACK_STR , buf , <NUM_LIT:0> , self . type , self . len ) <EOL> return buf <EOL> @ OFPTableFeatureProp . register_type ( ofproto . OFPTFPT_INSTRUCTIONS ) <EOL> @ OFPTableFeatureProp . register_type ( ofproto . OFPTFPT_INSTRUCTIONS_MISS ) <EOL> class OFPTableFeaturePropInstructions ( OFPTableFeatureProp ) : <EOL> def __init__ ( self , type_ = None , length = None , instruction_ids = None ) : <EOL> instruction_ids = instruction_ids if instruction_ids else [ ] <EOL> super ( OFPTableFeaturePropInstructions , self ) . __init__ ( type_ , length ) <EOL> self . instruction_ids = instruction_ids <EOL> @ classmethod <EOL> def parser ( cls , buf ) : <EOL> rest = cls . get_rest ( buf ) <EOL> ids = [ ] <EOL> while rest : <EOL> i , rest = OFPInstructionId . parse ( rest ) <EOL> ids . append ( i ) <EOL> return cls ( instruction_ids = ids ) <EOL> def serialize_body ( self ) : <EOL> bin_ids = bytearray ( ) <EOL> for i in self . instruction_ids : <EOL> bin_ids += i . serialize ( ) <EOL> return bin_ids <EOL> class OFPActionId ( StringifyMixin ) : <EOL> _PACK_STR = '<STR_LIT>' <EOL> def __init__ ( self , type_ , len_ = None ) : <EOL> self . type = type_ <EOL> self . len = len_ <EOL> @ classmethod <EOL> def parse ( cls , buf ) : <EOL> ( type_ , len_ , ) = struct . unpack_from ( cls . _PACK_STR , <EOL> six . binary_type ( buf ) , <NUM_LIT:0> ) <EOL> rest = buf [ len_ : ] <EOL> return cls ( type_ = type_ , len_ = len_ ) , rest <EOL> def serialize ( self ) : <EOL> self . len = struct . calcsize ( self . _PACK_STR ) <EOL> buf = bytearray ( ) <EOL> msg_pack_into ( self . _PACK_STR , buf , <NUM_LIT:0> , self . type , self . len ) <EOL> return buf <EOL> @ OFPTableFeatureProp . register_type ( ofproto . OFPTFPT_WRITE_ACTIONS ) <EOL> @ OFPTableFeatureProp . register_type ( ofproto . OFPTFPT_WRITE_ACTIONS_MISS ) <EOL> @ OFPTableFeatureProp . register_type ( ofproto . OFPTFPT_APPLY_ACTIONS ) <EOL> @ OFPTableFeatureProp . register_type ( ofproto . OFPTFPT_APPLY_ACTIONS_MISS ) <EOL> class OFPTableFeaturePropActions ( OFPTableFeatureProp ) : <EOL> def __init__ ( self , type_ = None , length = None , action_ids = None ) : <EOL> action_ids = action_ids if action_ids else [ ] <EOL> super ( OFPTableFeaturePropActions , self ) . __init__ ( type_ , length ) <EOL> self . action_ids = action_ids <EOL> @ classmethod <EOL> def parser ( cls , buf ) : <EOL> rest = cls . get_rest ( buf ) <EOL> ids = [ ] <EOL> while rest : <EOL> i , rest = OFPActionId . parse ( rest ) <EOL> ids . append ( i ) <EOL> return cls ( action_ids = ids ) <EOL> def serialize_body ( self ) : <EOL> bin_ids = bytearray ( ) <EOL> for i in self . action_ids : <EOL> bin_ids += i . serialize ( ) <EOL> return bin_ids <EOL> @ OFPTableFeatureProp . register_type ( ofproto . OFPTFPT_NEXT_TABLES ) <EOL> @ OFPTableFeatureProp . register_type ( ofproto . OFPTFPT_NEXT_TABLES_MISS ) <EOL> @ OFPTableFeatureProp . register_type ( ofproto . OFPTFPT_TABLE_SYNC_FROM ) <EOL> class OFPTableFeaturePropNextTables ( OFPTableFeatureProp ) : <EOL> _TABLE_ID_PACK_STR = '<STR_LIT>' <EOL> def __init__ ( self , type_ = None , length = None , table_ids = None ) : <EOL> table_ids = table_ids if table_ids else [ ] <EOL> super ( OFPTableFeaturePropNextTables , self ) . __init__ ( type_ , length ) <EOL> self . table_ids = table_ids <EOL> @ classmethod <EOL> def parser ( cls , buf ) : <EOL> rest = cls . get_rest ( buf ) <EOL> ids = [ ] <EOL> while rest : <EOL> ( i , ) = struct . unpack_from ( cls . _TABLE_ID_PACK_STR , <EOL> six . binary_type ( rest ) , <NUM_LIT:0> ) <EOL> rest = rest [ struct . calcsize ( cls . _TABLE_ID_PACK_STR ) : ] <EOL> ids . append ( i ) <EOL> return cls ( table_ids = ids ) <EOL> def serialize_body ( self ) : <EOL> bin_ids = bytearray ( ) <EOL> for i in self . table_ids : <EOL> bin_id = bytearray ( ) <EOL> msg_pack_into ( self . _TABLE_ID_PACK_STR , bin_id , <NUM_LIT:0> , i ) <EOL> bin_ids += bin_id <EOL> return bin_ids <EOL> class OFPOxmId ( StringifyMixin ) : <EOL> _PACK_STR = '<STR_LIT>' <EOL> _EXPERIMENTER_ID_PACK_STR = '<STR_LIT>' <EOL> _TYPE = { <EOL> '<STR_LIT:ascii>' : [ <EOL> '<STR_LIT:type>' , <EOL> ] , <EOL> } <EOL> def __init__ ( self , type_ , hasmask = False , length = None ) : <EOL> self . type = type_ <EOL> self . hasmask = hasmask <EOL> self . length = length <EOL> @ classmethod <EOL> def parse ( cls , buf ) : <EOL> ( oxm , ) = struct . unpack_from ( cls . _PACK_STR , six . binary_type ( buf ) , <NUM_LIT:0> ) <EOL> ( type_ , _v ) = ofproto . oxm_to_user ( oxm >> ( <NUM_LIT:1> + <NUM_LIT:8> ) , None , None ) <EOL> rest = buf [ struct . calcsize ( cls . _PACK_STR ) : ] <EOL> hasmask = ofproto . oxm_tlv_header_extract_hasmask ( oxm ) <EOL> length = oxm & <NUM_LIT> <EOL> class_ = oxm >> ( <NUM_LIT:7> + <NUM_LIT:1> + <NUM_LIT:8> ) <EOL> if class_ == ofproto . OFPXMC_EXPERIMENTER : <EOL> ( exp_id , ) = struct . unpack_from ( cls . _EXPERIMENTER_ID_PACK_STR , <EOL> six . binary_type ( rest ) , <NUM_LIT:0> ) <EOL> rest = rest [ struct . calcsize ( cls . _EXPERIMENTER_ID_PACK_STR ) : ] <EOL> subcls = OFPExperimenterOxmId <EOL> return subcls ( type_ = type_ , exp_id = exp_id , hasmask = hasmask , <EOL> length = length ) , rest <EOL> else : <EOL> return cls ( type_ = type_ , hasmask = hasmask , length = length ) , rest <EOL> def serialize ( self ) : <EOL> self . length = <NUM_LIT:0> <EOL> ( n , _v , _m ) = ofproto . oxm_from_user ( self . type , None ) <EOL> oxm = ( n << ( <NUM_LIT:1> + <NUM_LIT:8> ) ) | ( self . hasmask << <NUM_LIT:8> ) | self . length <EOL> buf = bytearray ( ) <EOL> msg_pack_into ( self . _PACK_STR , buf , <NUM_LIT:0> , oxm ) <EOL> assert n >> <NUM_LIT:7> != ofproto . OFPXMC_EXPERIMENTER <EOL> return buf <EOL> class OFPExperimenterOxmId ( OFPOxmId ) : <EOL> def __init__ ( self , type_ , exp_id , hasmask = False , length = None ) : <EOL> super ( OFPExperimenterOxmId , self ) . __init__ ( type_ = type_ , <EOL> hasmask = hasmask , <EOL> length = length ) <EOL> self . exp_id = exp_id <EOL> def serialize ( self ) : <EOL> buf = super ( OFPExperimenterOxmId , self ) . serialize ( ) <EOL> msg_pack_into ( self . _EXPERIMENTER_ID_PACK_STR , buf , <EOL> struct . calcsize ( self . _PACK_STR ) , self . exp_id ) <EOL> @ OFPTableFeatureProp . register_type ( ofproto . OFPTFPT_MATCH ) <EOL> @ OFPTableFeatureProp . register_type ( ofproto . OFPTFPT_WILDCARDS ) <EOL> @ OFPTableFeatureProp . register_type ( ofproto . OFPTFPT_WRITE_SETFIELD ) <EOL> @ OFPTableFeatureProp . register_type ( ofproto . OFPTFPT_WRITE_SETFIELD_MISS ) <EOL> @ OFPTableFeatureProp . register_type ( ofproto . OFPTFPT_APPLY_SETFIELD ) <EOL> @ OFPTableFeatureProp . register_type ( ofproto . OFPTFPT_APPLY_SETFIELD_MISS ) <EOL> class OFPTableFeaturePropOxm ( OFPTableFeatureProp ) : <EOL> def __init__ ( self , type_ = None , length = None , oxm_ids = None ) : <EOL> oxm_ids = oxm_ids if oxm_ids else [ ] <EOL> super ( OFPTableFeaturePropOxm , self ) . __init__ ( type_ , length ) <EOL> self . oxm_ids = oxm_ids <EOL> @ classmethod <EOL> def parser ( cls , buf ) : <EOL> rest = cls . get_rest ( buf ) <EOL> ids = [ ] <EOL> while rest : <EOL> i , rest = OFPOxmId . parse ( rest ) <EOL> ids . append ( i ) <EOL> return cls ( oxm_ids = ids ) <EOL> def serialize_body ( self ) : <EOL> bin_ids = bytearray ( ) <EOL> for i in self . oxm_ids : <EOL> bin_ids += i . serialize ( ) <EOL> return bin_ids <EOL> @ OFPTableFeatureProp . register_type ( ofproto . OFPTFPT_EXPERIMENTER ) <EOL> @ OFPTableFeatureProp . register_type ( ofproto . OFPTFPT_EXPERIMENTER_MISS ) <EOL> class OFPTableFeaturePropExperimenter ( OFPPropCommonExperimenter4ByteData ) : <EOL> pass <EOL> @ _set_stats_type ( ofproto . OFPMP_TABLE_FEATURES , OFPTableFeaturesStats ) <EOL> @ _set_msg_type ( ofproto . OFPT_MULTIPART_REQUEST ) <EOL> class OFPTableFeaturesStatsRequest ( OFPMultipartRequest ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , flags = <NUM_LIT:0> , body = None , type_ = None ) : <EOL> body = body if body else [ ] <EOL> super ( OFPTableFeaturesStatsRequest , self ) . __init__ ( datapath , flags ) <EOL> self . body = body <EOL> def _serialize_stats_body ( self ) : <EOL> bin_body = bytearray ( ) <EOL> for p in self . body : <EOL> bin_body += p . serialize ( ) <EOL> self . buf += bin_body <EOL> @ OFPMultipartReply . register_stats_type ( ) <EOL> @ _set_stats_type ( ofproto . OFPMP_TABLE_FEATURES , OFPTableFeaturesStats ) <EOL> @ _set_msg_type ( ofproto . OFPT_MULTIPART_REPLY ) <EOL> class OFPTableFeaturesStatsReply ( OFPMultipartReply ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , type_ = None , ** kwargs ) : <EOL> super ( OFPTableFeaturesStatsReply , self ) . __init__ ( datapath , ** kwargs ) <EOL> @ _set_stats_type ( ofproto . OFPMP_PORT_DESC , OFPPort ) <EOL> @ _set_msg_type ( ofproto . OFPT_MULTIPART_REQUEST ) <EOL> class OFPPortDescStatsRequest ( OFPMultipartRequest ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , flags = <NUM_LIT:0> , type_ = None ) : <EOL> super ( OFPPortDescStatsRequest , self ) . __init__ ( datapath , flags ) <EOL> @ OFPMultipartReply . register_stats_type ( ) <EOL> @ _set_stats_type ( ofproto . OFPMP_PORT_DESC , OFPPort ) <EOL> @ _set_msg_type ( ofproto . OFPT_MULTIPART_REPLY ) <EOL> class OFPPortDescStatsReply ( OFPMultipartReply ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , type_ = None , ** kwargs ) : <EOL> super ( OFPPortDescStatsReply , self ) . __init__ ( datapath , ** kwargs ) <EOL> @ _set_stats_type ( ofproto . OFPMP_TABLE_DESC , OFPTableDesc ) <EOL> @ _set_msg_type ( ofproto . OFPT_MULTIPART_REQUEST ) <EOL> class OFPTableDescStatsRequest ( OFPMultipartRequest ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , flags = <NUM_LIT:0> , type_ = None ) : <EOL> super ( OFPTableDescStatsRequest , self ) . __init__ ( datapath , flags ) <EOL> @ OFPMultipartReply . register_stats_type ( ) <EOL> @ _set_stats_type ( ofproto . OFPMP_TABLE_DESC , OFPTableDesc ) <EOL> @ _set_msg_type ( ofproto . OFPT_MULTIPART_REPLY ) <EOL> class OFPTableDescStatsReply ( OFPMultipartReply ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , type_ = None , ** kwargs ) : <EOL> super ( OFPTableDescStatsReply , self ) . __init__ ( datapath , ** kwargs ) <EOL> @ _set_stats_type ( ofproto . OFPMP_QUEUE_DESC , OFPQueueDesc ) <EOL> @ _set_msg_type ( ofproto . OFPT_MULTIPART_REQUEST ) <EOL> class OFPQueueDescStatsRequest ( OFPMultipartRequest ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , flags = <NUM_LIT:0> , port_no = ofproto . OFPP_ANY , <EOL> queue_id = ofproto . OFPQ_ALL , type_ = None ) : <EOL> super ( OFPQueueDescStatsRequest , self ) . __init__ ( datapath , flags ) <EOL> self . port_no = port_no <EOL> self . queue_id = queue_id <EOL> def _serialize_stats_body ( self ) : <EOL> msg_pack_into ( ofproto . OFP_QUEUE_DESC_REQUEST_PACK_STR , <EOL> self . buf , <EOL> ofproto . OFP_MULTIPART_REQUEST_SIZE , <EOL> self . port_no , self . queue_id ) <EOL> @ OFPMultipartReply . register_stats_type ( ) <EOL> @ _set_stats_type ( ofproto . OFPMP_QUEUE_DESC , OFPQueueDesc ) <EOL> @ _set_msg_type ( ofproto . OFPT_MULTIPART_REPLY ) <EOL> class OFPQueueDescStatsReply ( OFPMultipartReply ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , type_ = None , ** kwargs ) : <EOL> super ( OFPQueueDescStatsReply , self ) . __init__ ( datapath , ** kwargs ) <EOL> class OFPQueueStatsProp ( OFPPropBase ) : <EOL> _TYPES = { } <EOL> @ OFPQueueStatsProp . register_type ( ofproto . OFPQSPT_EXPERIMENTER ) <EOL> class OFPQueueStatsPropExperimenter ( OFPPropCommonExperimenter4ByteData ) : <EOL> pass <EOL> class OFPQueueStats ( StringifyMixin ) : <EOL> def __init__ ( self , length = None , port_no = None , queue_id = None , <EOL> tx_bytes = None , tx_packets = None , tx_errors = None , <EOL> duration_sec = None , duration_nsec = None , properties = None ) : <EOL> super ( OFPQueueStats , self ) . __init__ ( ) <EOL> self . length = length <EOL> self . port_no = port_no <EOL> self . queue_id = queue_id <EOL> self . tx_bytes = tx_bytes <EOL> self . tx_packets = tx_packets <EOL> self . tx_errors = tx_errors <EOL> self . duration_sec = duration_sec <EOL> self . duration_nsec = duration_nsec <EOL> self . properties = properties <EOL> @ classmethod <EOL> def parser ( cls , buf , offset ) : <EOL> ( length , port_no , queue_id , tx_bytes , tx_packets , tx_errors , <EOL> duration_sec , duration_nsec ) = struct . unpack_from ( <EOL> ofproto . OFP_QUEUE_STATS_PACK_STR , buf , offset ) <EOL> props = [ ] <EOL> rest = buf [ offset + ofproto . OFP_QUEUE_STATS_SIZE : offset + length ] <EOL> while rest : <EOL> p , rest = OFPQueueStatsProp . parse ( rest ) <EOL> props . append ( p ) <EOL> stats = cls ( length , port_no , queue_id , tx_bytes , tx_packets , tx_errors , <EOL> duration_sec , duration_nsec , props ) <EOL> return stats <EOL> @ _set_stats_type ( ofproto . OFPMP_QUEUE_STATS , OFPQueueStats ) <EOL> @ _set_msg_type ( ofproto . OFPT_MULTIPART_REQUEST ) <EOL> class OFPQueueStatsRequest ( OFPMultipartRequest ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , flags = <NUM_LIT:0> , port_no = ofproto . OFPP_ANY , <EOL> queue_id = ofproto . OFPQ_ALL , type_ = None ) : <EOL> super ( OFPQueueStatsRequest , self ) . __init__ ( datapath , flags ) <EOL> self . port_no = port_no <EOL> self . queue_id = queue_id <EOL> def _serialize_stats_body ( self ) : <EOL> msg_pack_into ( ofproto . OFP_QUEUE_STATS_REQUEST_PACK_STR , <EOL> self . buf , <EOL> ofproto . OFP_MULTIPART_REQUEST_SIZE , <EOL> self . port_no , self . queue_id ) <EOL> @ OFPMultipartReply . register_stats_type ( ) <EOL> @ _set_stats_type ( ofproto . OFPMP_QUEUE_STATS , OFPQueueStats ) <EOL> @ _set_msg_type ( ofproto . OFPT_MULTIPART_REPLY ) <EOL> class OFPQueueStatsReply ( OFPMultipartReply ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , type_ = None , ** kwargs ) : <EOL> super ( OFPQueueStatsReply , self ) . __init__ ( datapath , ** kwargs ) <EOL> class OFPBucketCounter ( StringifyMixin ) : <EOL> def __init__ ( self , packet_count , byte_count ) : <EOL> super ( OFPBucketCounter , self ) . __init__ ( ) <EOL> self . packet_count = packet_count <EOL> self . byte_count = byte_count <EOL> @ classmethod <EOL> def parser ( cls , buf , offset ) : <EOL> packet_count , byte_count = struct . unpack_from ( <EOL> ofproto . OFP_BUCKET_COUNTER_PACK_STR , buf , offset ) <EOL> return cls ( packet_count , byte_count ) <EOL> class OFPGroupStats ( StringifyMixin ) : <EOL> def __init__ ( self , length = None , group_id = None , ref_count = None , <EOL> packet_count = None , byte_count = None , duration_sec = None , <EOL> duration_nsec = None , bucket_stats = None ) : <EOL> super ( OFPGroupStats , self ) . __init__ ( ) <EOL> self . length = length <EOL> self . group_id = group_id <EOL> self . ref_count = ref_count <EOL> self . packet_count = packet_count <EOL> self . byte_count = byte_count <EOL> self . duration_sec = duration_sec <EOL> self . duration_nsec = duration_nsec <EOL> self . bucket_stats = bucket_stats <EOL> @ classmethod <EOL> def parser ( cls , buf , offset ) : <EOL> group = struct . unpack_from ( ofproto . OFP_GROUP_STATS_PACK_STR , <EOL> buf , offset ) <EOL> group_stats = cls ( * group ) <EOL> group_stats . bucket_stats = [ ] <EOL> total_len = group_stats . length + offset <EOL> offset += ofproto . OFP_GROUP_STATS_SIZE <EOL> while total_len > offset : <EOL> b = OFPBucketCounter . parser ( buf , offset ) <EOL> group_stats . bucket_stats . append ( b ) <EOL> offset += ofproto . OFP_BUCKET_COUNTER_SIZE <EOL> return group_stats <EOL> @ _set_stats_type ( ofproto . OFPMP_GROUP , OFPGroupStats ) <EOL> @ _set_msg_type ( ofproto . OFPT_MULTIPART_REQUEST ) <EOL> class OFPGroupStatsRequest ( OFPMultipartRequest ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , flags = <NUM_LIT:0> , group_id = ofproto . OFPG_ALL , <EOL> type_ = None ) : <EOL> super ( OFPGroupStatsRequest , self ) . __init__ ( datapath , flags ) <EOL> self . group_id = group_id <EOL> def _serialize_stats_body ( self ) : <EOL> msg_pack_into ( ofproto . OFP_GROUP_STATS_REQUEST_PACK_STR , <EOL> self . buf , <EOL> ofproto . OFP_MULTIPART_REQUEST_SIZE , <EOL> self . group_id ) <EOL> @ OFPMultipartReply . register_stats_type ( ) <EOL> @ _set_stats_type ( ofproto . OFPMP_GROUP , OFPGroupStats ) <EOL> @ _set_msg_type ( ofproto . OFPT_MULTIPART_REPLY ) <EOL> class OFPGroupStatsReply ( OFPMultipartReply ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , type_ = None , ** kwargs ) : <EOL> super ( OFPGroupStatsReply , self ) . __init__ ( datapath , ** kwargs ) <EOL> class OFPGroupDescStats ( StringifyMixin ) : <EOL> def __init__ ( self , type_ = None , group_id = None , buckets = None , length = None ) : <EOL> super ( OFPGroupDescStats , self ) . __init__ ( ) <EOL> self . type = type_ <EOL> self . group_id = group_id <EOL> self . buckets = buckets <EOL> @ classmethod <EOL> def parser ( cls , buf , offset ) : <EOL> stats = cls ( ) <EOL> ( stats . length , stats . type , stats . group_id ) = struct . unpack_from ( <EOL> ofproto . OFP_GROUP_DESC_STATS_PACK_STR , buf , offset ) <EOL> offset += ofproto . OFP_GROUP_DESC_STATS_SIZE <EOL> stats . buckets = [ ] <EOL> length = ofproto . OFP_GROUP_DESC_STATS_SIZE <EOL> while length < stats . length : <EOL> bucket = OFPBucket . parser ( buf , offset ) <EOL> stats . buckets . append ( bucket ) <EOL> offset += bucket . len <EOL> length += bucket . len <EOL> return stats <EOL> @ _set_stats_type ( ofproto . OFPMP_GROUP_DESC , OFPGroupDescStats ) <EOL> @ _set_msg_type ( ofproto . OFPT_MULTIPART_REQUEST ) <EOL> class OFPGroupDescStatsRequest ( OFPMultipartRequest ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , flags = <NUM_LIT:0> , type_ = None ) : <EOL> super ( OFPGroupDescStatsRequest , self ) . __init__ ( datapath , flags ) <EOL> @ OFPMultipartReply . register_stats_type ( ) <EOL> @ _set_stats_type ( ofproto . OFPMP_GROUP_DESC , OFPGroupDescStats ) <EOL> @ _set_msg_type ( ofproto . OFPT_MULTIPART_REPLY ) <EOL> class OFPGroupDescStatsReply ( OFPMultipartReply ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , type_ = None , ** kwargs ) : <EOL> super ( OFPGroupDescStatsReply , self ) . __init__ ( datapath , ** kwargs ) <EOL> class OFPGroupFeaturesStats ( ofproto_parser . namedtuple ( '<STR_LIT>' , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' ) ) ) : <EOL> @ classmethod <EOL> def parser ( cls , buf , offset ) : <EOL> group_features = struct . unpack_from ( <EOL> ofproto . OFP_GROUP_FEATURES_PACK_STR , buf , offset ) <EOL> types = group_features [ <NUM_LIT:0> ] <EOL> capabilities = group_features [ <NUM_LIT:1> ] <EOL> max_groups = list ( group_features [ <NUM_LIT:2> : <NUM_LIT:6> ] ) <EOL> actions = list ( group_features [ <NUM_LIT:6> : <NUM_LIT:10> ] ) <EOL> stats = cls ( types , capabilities , max_groups , actions ) <EOL> stats . length = ofproto . OFP_GROUP_FEATURES_SIZE <EOL> return stats <EOL> @ _set_stats_type ( ofproto . OFPMP_GROUP_FEATURES , OFPGroupFeaturesStats ) <EOL> @ _set_msg_type ( ofproto . OFPT_MULTIPART_REQUEST ) <EOL> class OFPGroupFeaturesStatsRequest ( OFPMultipartRequest ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , flags = <NUM_LIT:0> , type_ = None ) : <EOL> super ( OFPGroupFeaturesStatsRequest , self ) . __init__ ( datapath , flags ) <EOL> @ OFPMultipartReply . register_stats_type ( body_single_struct = True ) <EOL> @ _set_stats_type ( ofproto . OFPMP_GROUP_FEATURES , OFPGroupFeaturesStats ) <EOL> @ _set_msg_type ( ofproto . OFPT_MULTIPART_REPLY ) <EOL> class OFPGroupFeaturesStatsReply ( OFPMultipartReply ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , type_ = None , ** kwargs ) : <EOL> super ( OFPGroupFeaturesStatsReply , self ) . __init__ ( datapath , ** kwargs ) <EOL> class OFPMeterBandStats ( StringifyMixin ) : <EOL> def __init__ ( self , packet_band_count , byte_band_count ) : <EOL> super ( OFPMeterBandStats , self ) . __init__ ( ) <EOL> self . packet_band_count = packet_band_count <EOL> self . byte_band_count = byte_band_count <EOL> @ classmethod <EOL> def parser ( cls , buf , offset ) : <EOL> band_stats = struct . unpack_from ( <EOL> ofproto . OFP_METER_BAND_STATS_PACK_STR , buf , offset ) <EOL> return cls ( * band_stats ) <EOL> class OFPMeterStats ( StringifyMixin ) : <EOL> def __init__ ( self , meter_id = None , flow_count = None , packet_in_count = None , <EOL> byte_in_count = None , duration_sec = None , duration_nsec = None , <EOL> band_stats = None , len_ = None ) : <EOL> super ( OFPMeterStats , self ) . __init__ ( ) <EOL> self . meter_id = meter_id <EOL> self . len = <NUM_LIT:0> <EOL> self . flow_count = flow_count <EOL> self . packet_in_count = packet_in_count <EOL> self . byte_in_count = byte_in_count <EOL> self . duration_sec = duration_sec <EOL> self . duration_nsec = duration_nsec <EOL> self . band_stats = band_stats <EOL> @ classmethod <EOL> def parser ( cls , buf , offset ) : <EOL> meter_stats = cls ( ) <EOL> ( meter_stats . meter_id , meter_stats . len , <EOL> meter_stats . flow_count , meter_stats . packet_in_count , <EOL> meter_stats . byte_in_count , meter_stats . duration_sec , <EOL> meter_stats . duration_nsec ) = struct . unpack_from ( <EOL> ofproto . OFP_METER_STATS_PACK_STR , buf , offset ) <EOL> offset += ofproto . OFP_METER_STATS_SIZE <EOL> meter_stats . band_stats = [ ] <EOL> length = ofproto . OFP_METER_STATS_SIZE <EOL> while length < meter_stats . len : <EOL> band_stats = OFPMeterBandStats . parser ( buf , offset ) <EOL> meter_stats . band_stats . append ( band_stats ) <EOL> offset += ofproto . OFP_METER_BAND_STATS_SIZE <EOL> length += ofproto . OFP_METER_BAND_STATS_SIZE <EOL> return meter_stats <EOL> @ _set_stats_type ( ofproto . OFPMP_METER , OFPMeterStats ) <EOL> @ _set_msg_type ( ofproto . OFPT_MULTIPART_REQUEST ) <EOL> class OFPMeterStatsRequest ( OFPMultipartRequest ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , flags = <NUM_LIT:0> , meter_id = ofproto . OFPM_ALL , <EOL> type_ = None ) : <EOL> super ( OFPMeterStatsRequest , self ) . __init__ ( datapath , flags ) <EOL> self . meter_id = meter_id <EOL> def _serialize_stats_body ( self ) : <EOL> msg_pack_into ( ofproto . OFP_METER_MULTIPART_REQUEST_PACK_STR , <EOL> self . buf , <EOL> ofproto . OFP_MULTIPART_REQUEST_SIZE , <EOL> self . meter_id ) <EOL> @ OFPMultipartReply . register_stats_type ( ) <EOL> @ _set_stats_type ( ofproto . OFPMP_METER , OFPMeterStats ) <EOL> @ _set_msg_type ( ofproto . OFPT_MULTIPART_REPLY ) <EOL> class OFPMeterStatsReply ( OFPMultipartReply ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , type_ = None , ** kwargs ) : <EOL> super ( OFPMeterStatsReply , self ) . __init__ ( datapath , ** kwargs ) <EOL> class OFPMeterBand ( StringifyMixin ) : <EOL> def __init__ ( self , type_ , len_ ) : <EOL> super ( OFPMeterBand , self ) . __init__ ( ) <EOL> self . type = type_ <EOL> self . len = len_ <EOL> class OFPMeterBandHeader ( OFPMeterBand ) : <EOL> _METER_BAND = { } <EOL> @ staticmethod <EOL> def register_meter_band_type ( type_ , len_ ) : <EOL> def _register_meter_band_type ( cls ) : <EOL> OFPMeterBandHeader . _METER_BAND [ type_ ] = cls <EOL> cls . cls_meter_band_type = type_ <EOL> cls . cls_meter_band_len = len_ <EOL> return cls <EOL> return _register_meter_band_type <EOL> def __init__ ( self ) : <EOL> cls = self . __class__ <EOL> super ( OFPMeterBandHeader , self ) . __init__ ( cls . cls_meter_band_type , <EOL> cls . cls_meter_band_len ) <EOL> @ classmethod <EOL> def parser ( cls , buf , offset ) : <EOL> type_ , len_ , _rate , _burst_size = struct . unpack_from ( <EOL> ofproto . OFP_METER_BAND_HEADER_PACK_STR , buf , offset ) <EOL> cls_ = cls . _METER_BAND [ type_ ] <EOL> assert cls_ . cls_meter_band_len == len_ <EOL> return cls_ . parser ( buf , offset ) <EOL> @ OFPMeterBandHeader . register_meter_band_type ( <EOL> ofproto . OFPMBT_DROP , ofproto . OFP_METER_BAND_DROP_SIZE ) <EOL> class OFPMeterBandDrop ( OFPMeterBandHeader ) : <EOL> def __init__ ( self , rate = <NUM_LIT:0> , burst_size = <NUM_LIT:0> , type_ = None , len_ = None ) : <EOL> super ( OFPMeterBandDrop , self ) . __init__ ( ) <EOL> self . rate = rate <EOL> self . burst_size = burst_size <EOL> def serialize ( self , buf , offset ) : <EOL> msg_pack_into ( ofproto . OFP_METER_BAND_DROP_PACK_STR , buf , offset , <EOL> self . type , self . len , self . rate , self . burst_size ) <EOL> @ classmethod <EOL> def parser ( cls , buf , offset ) : <EOL> type_ , len_ , rate , burst_size = struct . unpack_from ( <EOL> ofproto . OFP_METER_BAND_DROP_PACK_STR , buf , offset ) <EOL> assert cls . cls_meter_band_type == type_ <EOL> assert cls . cls_meter_band_len == len_ <EOL> return cls ( rate , burst_size ) <EOL> @ OFPMeterBandHeader . register_meter_band_type ( <EOL> ofproto . OFPMBT_DSCP_REMARK , <EOL> ofproto . OFP_METER_BAND_DSCP_REMARK_SIZE ) <EOL> class OFPMeterBandDscpRemark ( OFPMeterBandHeader ) : <EOL> def __init__ ( self , rate = <NUM_LIT:0> , burst_size = <NUM_LIT:0> , prec_level = <NUM_LIT:0> , <EOL> type_ = None , len_ = None ) : <EOL> super ( OFPMeterBandDscpRemark , self ) . __init__ ( ) <EOL> self . rate = rate <EOL> self . burst_size = burst_size <EOL> self . prec_level = prec_level <EOL> def serialize ( self , buf , offset ) : <EOL> msg_pack_into ( ofproto . OFP_METER_BAND_DSCP_REMARK_PACK_STR , buf , <EOL> offset , self . type , self . len , self . rate , <EOL> self . burst_size , self . prec_level ) <EOL> @ classmethod <EOL> def parser ( cls , buf , offset ) : <EOL> type_ , len_ , rate , burst_size , prec_level = struct . unpack_from ( <EOL> ofproto . OFP_METER_BAND_DSCP_REMARK_PACK_STR , buf , offset ) <EOL> assert cls . cls_meter_band_type == type_ <EOL> assert cls . cls_meter_band_len == len_ <EOL> return cls ( rate , burst_size , prec_level ) <EOL> @ OFPMeterBandHeader . register_meter_band_type ( <EOL> ofproto . OFPMBT_EXPERIMENTER , <EOL> ofproto . OFP_METER_BAND_EXPERIMENTER_SIZE ) <EOL> class OFPMeterBandExperimenter ( OFPMeterBandHeader ) : <EOL> def __init__ ( self , rate = <NUM_LIT:0> , burst_size = <NUM_LIT:0> , experimenter = None , <EOL> type_ = None , len_ = None ) : <EOL> super ( OFPMeterBandExperimenter , self ) . __init__ ( ) <EOL> self . rate = rate <EOL> self . burst_size = burst_size <EOL> self . experimenter = experimenter <EOL> def serialize ( self , buf , offset ) : <EOL> msg_pack_into ( ofproto . OFP_METER_BAND_EXPERIMENTER_PACK_STR , buf , <EOL> offset , self . type , self . len , self . rate , <EOL> self . burst_size , self . experimenter ) <EOL> @ classmethod <EOL> def parser ( cls , buf , offset ) : <EOL> type_ , len_ , rate , burst_size , experimenter = struct . unpack_from ( <EOL> ofproto . OFP_METER_BAND_EXPERIMENTER_PACK_STR , buf , offset ) <EOL> assert cls . cls_meter_band_type == type_ <EOL> assert cls . cls_meter_band_len == len_ <EOL> return cls ( rate , burst_size , experimenter ) <EOL> class OFPMeterConfigStats ( StringifyMixin ) : <EOL> def __init__ ( self , flags = None , meter_id = None , bands = None , length = None ) : <EOL> super ( OFPMeterConfigStats , self ) . __init__ ( ) <EOL> self . length = None <EOL> self . flags = flags <EOL> self . meter_id = meter_id <EOL> self . bands = bands <EOL> @ classmethod <EOL> def parser ( cls , buf , offset ) : <EOL> meter_config = cls ( ) <EOL> ( meter_config . length , meter_config . flags , <EOL> meter_config . meter_id ) = struct . unpack_from ( <EOL> ofproto . OFP_METER_CONFIG_PACK_STR , buf , offset ) <EOL> offset += ofproto . OFP_METER_CONFIG_SIZE <EOL> meter_config . bands = [ ] <EOL> length = ofproto . OFP_METER_CONFIG_SIZE <EOL> while length < meter_config . length : <EOL> band = OFPMeterBandHeader . parser ( buf , offset ) <EOL> meter_config . bands . append ( band ) <EOL> offset += band . len <EOL> length += band . len <EOL> return meter_config <EOL> @ _set_stats_type ( ofproto . OFPMP_METER_CONFIG , OFPMeterConfigStats ) <EOL> @ _set_msg_type ( ofproto . OFPT_MULTIPART_REQUEST ) <EOL> class OFPMeterConfigStatsRequest ( OFPMultipartRequest ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , flags = <NUM_LIT:0> , meter_id = ofproto . OFPM_ALL , <EOL> type_ = None ) : <EOL> super ( OFPMeterConfigStatsRequest , self ) . __init__ ( datapath , flags ) <EOL> self . meter_id = meter_id <EOL> def _serialize_stats_body ( self ) : <EOL> msg_pack_into ( ofproto . OFP_METER_MULTIPART_REQUEST_PACK_STR , <EOL> self . buf , <EOL> ofproto . OFP_MULTIPART_REQUEST_SIZE , <EOL> self . meter_id ) <EOL> @ OFPMultipartReply . register_stats_type ( ) <EOL> @ _set_stats_type ( ofproto . OFPMP_METER_CONFIG , OFPMeterConfigStats ) <EOL> @ _set_msg_type ( ofproto . OFPT_MULTIPART_REPLY ) <EOL> class OFPMeterConfigStatsReply ( OFPMultipartReply ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , type_ = None , ** kwargs ) : <EOL> super ( OFPMeterConfigStatsReply , self ) . __init__ ( datapath , ** kwargs ) <EOL> class OFPMeterFeaturesStats ( ofproto_parser . namedtuple ( '<STR_LIT>' , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' ) ) ) : <EOL> @ classmethod <EOL> def parser ( cls , buf , offset ) : <EOL> meter_features = struct . unpack_from ( <EOL> ofproto . OFP_METER_FEATURES_PACK_STR , buf , offset ) <EOL> stats = cls ( * meter_features ) <EOL> stats . length = ofproto . OFP_METER_FEATURES_SIZE <EOL> return stats <EOL> @ _set_stats_type ( ofproto . OFPMP_METER_FEATURES , OFPMeterFeaturesStats ) <EOL> @ _set_msg_type ( ofproto . OFPT_MULTIPART_REQUEST ) <EOL> class OFPMeterFeaturesStatsRequest ( OFPMultipartRequest ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , flags = <NUM_LIT:0> , type_ = None ) : <EOL> super ( OFPMeterFeaturesStatsRequest , self ) . __init__ ( datapath , flags ) <EOL> @ OFPMultipartReply . register_stats_type ( ) <EOL> @ _set_stats_type ( ofproto . OFPMP_METER_FEATURES , OFPMeterFeaturesStats ) <EOL> @ _set_msg_type ( ofproto . OFPT_MULTIPART_REPLY ) <EOL> class OFPMeterFeaturesStatsReply ( OFPMultipartReply ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , type_ = None , ** kwargs ) : <EOL> super ( OFPMeterFeaturesStatsReply , self ) . __init__ ( datapath , ** kwargs ) <EOL> class OFPFlowUpdate ( StringifyMixin ) : <EOL> def __init__ ( self , length , event ) : <EOL> super ( OFPFlowUpdate , self ) . __init__ ( ) <EOL> self . length = length <EOL> self . event = event <EOL> class OFPFlowUpdateHeader ( OFPFlowUpdate ) : <EOL> _EVENT = { } <EOL> @ staticmethod <EOL> def register_flow_update_event ( event , length ) : <EOL> def _register_flow_update_event ( cls ) : <EOL> OFPFlowUpdateHeader . _EVENT [ event ] = cls <EOL> cls . cls_flow_update_event = event <EOL> cls . cls_flow_update_length = length <EOL> return cls <EOL> return _register_flow_update_event <EOL> def __init__ ( self , length = None , event = None ) : <EOL> cls = self . __class__ <EOL> super ( OFPFlowUpdateHeader , self ) . __init__ ( length , <EOL> cls . cls_flow_update_event ) <EOL> self . length = length <EOL> @ classmethod <EOL> def parser ( cls , buf , offset ) : <EOL> length , event = struct . unpack_from ( <EOL> ofproto . OFP_FLOW_UPDATE_HEADER_PACK_STR , buf , offset ) <EOL> cls_ = cls . _EVENT [ event ] <EOL> return cls_ . parser ( buf , offset ) <EOL> @ OFPFlowUpdateHeader . register_flow_update_event ( <EOL> ofproto . OFPFME_INITIAL , ofproto . OFP_FLOW_UPDATE_FULL_SIZE ) <EOL> @ OFPFlowUpdateHeader . register_flow_update_event ( <EOL> ofproto . OFPFME_ADDED , ofproto . OFP_FLOW_UPDATE_FULL_SIZE ) <EOL> @ OFPFlowUpdateHeader . register_flow_update_event ( <EOL> ofproto . OFPFME_REMOVED , ofproto . OFP_FLOW_UPDATE_FULL_SIZE ) <EOL> @ OFPFlowUpdateHeader . register_flow_update_event ( <EOL> ofproto . OFPFME_MODIFIED , ofproto . OFP_FLOW_UPDATE_FULL_SIZE ) <EOL> class OFPFlowUpdateFull ( OFPFlowUpdateHeader ) : <EOL> def __init__ ( self , length = None , event = None , table_id = None , reason = None , <EOL> idle_timeout = None , hard_timeout = None , priority = None , <EOL> cookie = None , match = None , instructions = None ) : <EOL> instructions = instructions if instructions else [ ] <EOL> super ( OFPFlowUpdateFull , self ) . __init__ ( length , event ) <EOL> self . table_id = table_id <EOL> self . reason = reason <EOL> self . idle_timeout = idle_timeout <EOL> self . hard_timeout = hard_timeout <EOL> self . priority = priority <EOL> self . cookie = cookie <EOL> self . match = match <EOL> assert ( event != ofproto . OFPFME_REMOVED or len ( instructions ) == <NUM_LIT:0> ) <EOL> for i in instructions : <EOL> assert isinstance ( i , OFPInstruction ) <EOL> self . instructions = instructions <EOL> @ classmethod <EOL> def parser ( cls , buf , offset ) : <EOL> ( length , event , table_id , reason , idle_timeout , hard_timeout , priority , <EOL> cookie ) = struct . unpack_from ( ofproto . OFP_FLOW_UPDATE_FULL_0_PACK_STR , <EOL> buf , offset ) <EOL> offset += ofproto . OFP_FLOW_UPDATE_FULL_0_SIZE <EOL> assert cls . cls_flow_update_length <= length <EOL> assert cls . cls_flow_update_event == event <EOL> match = OFPMatch . parser ( buf , offset ) <EOL> match_length = utils . round_up ( match . length , <NUM_LIT:8> ) <EOL> offset += match_length <EOL> inst_length = ( length - ofproto . OFP_FLOW_UPDATE_FULL_0_SIZE - <EOL> match_length ) <EOL> instructions = [ ] <EOL> while inst_length > <NUM_LIT:0> : <EOL> inst = OFPInstruction . parser ( buf , offset ) <EOL> instructions . append ( inst ) <EOL> offset += inst . len <EOL> inst_length -= inst . len <EOL> return cls ( length , event , table_id , reason , idle_timeout , <EOL> hard_timeout , priority , cookie , match , instructions ) <EOL> @ OFPFlowUpdateHeader . register_flow_update_event ( <EOL> ofproto . OFPFME_ABBREV , ofproto . OFP_FLOW_UPDATE_ABBREV_SIZE ) <EOL> class OFPFlowUpdateAbbrev ( OFPFlowUpdateHeader ) : <EOL> def __init__ ( self , length = None , event = None , xid = None ) : <EOL> super ( OFPFlowUpdateAbbrev , self ) . __init__ ( length , event ) <EOL> self . xid = xid <EOL> @ classmethod <EOL> def parser ( cls , buf , offset ) : <EOL> length , event , xid = struct . unpack_from ( <EOL> ofproto . OFP_FLOW_UPDATE_ABBREV_PACK_STR , buf , offset ) <EOL> assert cls . cls_flow_update_length == length <EOL> assert cls . cls_flow_update_event == event <EOL> return cls ( length , event , xid ) <EOL> @ OFPFlowUpdateHeader . register_flow_update_event ( <EOL> ofproto . OFPFME_PAUSED , ofproto . OFP_FLOW_UPDATE_PAUSED_SIZE ) <EOL> @ OFPFlowUpdateHeader . register_flow_update_event ( <EOL> ofproto . OFPFME_RESUMED , ofproto . OFP_FLOW_UPDATE_PAUSED_SIZE ) <EOL> class OFPFlowUpdatePaused ( OFPFlowUpdateHeader ) : <EOL> @ classmethod <EOL> def parser ( cls , buf , offset ) : <EOL> length , event = struct . unpack_from ( <EOL> ofproto . OFP_FLOW_UPDATE_PAUSED_PACK_STR , buf , offset ) <EOL> assert cls . cls_flow_update_length == length <EOL> assert cls . cls_flow_update_event == event <EOL> return cls ( length , event ) <EOL> class OFPFlowMonitorRequestBase ( OFPMultipartRequest ) : <EOL> def __init__ ( self , datapath , flags , monitor_id , out_port , out_group , <EOL> monitor_flags , table_id , command , match ) : <EOL> super ( OFPFlowMonitorRequestBase , self ) . __init__ ( datapath , flags ) <EOL> self . monitor_id = monitor_id <EOL> self . out_port = out_port <EOL> self . out_group = out_group <EOL> self . monitor_flags = monitor_flags <EOL> self . table_id = table_id <EOL> self . command = command <EOL> self . match = match <EOL> def _serialize_stats_body ( self ) : <EOL> offset = ofproto . OFP_MULTIPART_REQUEST_SIZE <EOL> msg_pack_into ( ofproto . OFP_FLOW_MONITOR_REQUEST_0_PACK_STR , self . buf , <EOL> offset , self . monitor_id , self . out_port , self . out_group , <EOL> self . monitor_flags , self . table_id , self . command ) <EOL> offset += ofproto . OFP_FLOW_MONITOR_REQUEST_0_SIZE <EOL> self . match . serialize ( self . buf , offset ) <EOL> @ _set_stats_type ( ofproto . OFPMP_FLOW_MONITOR , OFPFlowUpdateHeader ) <EOL> @ _set_msg_type ( ofproto . OFPT_MULTIPART_REQUEST ) <EOL> class OFPFlowMonitorRequest ( OFPFlowMonitorRequestBase ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , flags = <NUM_LIT:0> , monitor_id = <NUM_LIT:0> , <EOL> out_port = ofproto . OFPP_ANY , out_group = ofproto . OFPG_ANY , <EOL> monitor_flags = <NUM_LIT:0> , table_id = ofproto . OFPTT_ALL , <EOL> command = ofproto . OFPFMC_ADD , match = None , type_ = None ) : <EOL> if match is None : <EOL> match = OFPMatch ( ) <EOL> super ( OFPFlowMonitorRequest , self ) . __init__ ( datapath , flags , <EOL> monitor_id , out_port , <EOL> out_group , monitor_flags , <EOL> table_id , command , match ) <EOL> @ OFPMultipartReply . register_stats_type ( ) <EOL> @ _set_stats_type ( ofproto . OFPMP_FLOW_MONITOR , OFPFlowUpdateHeader ) <EOL> @ _set_msg_type ( ofproto . OFPT_MULTIPART_REPLY ) <EOL> class OFPFlowMonitorReply ( OFPMultipartReply ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , type_ = None , ** kwargs ) : <EOL> super ( OFPFlowMonitorReply , self ) . __init__ ( datapath , ** kwargs ) <EOL> class OFPExperimenterMultipart ( ofproto_parser . namedtuple ( <EOL> '<STR_LIT>' , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:data>' ) ) ) : <EOL> """<STR_LIT>""" <EOL> @ classmethod <EOL> def parser ( cls , buf , offset ) : <EOL> args = struct . unpack_from ( <EOL> ofproto . OFP_EXPERIMENTER_MULTIPART_HEADER_PACK_STR , buf , <EOL> offset ) <EOL> args = list ( args ) <EOL> args . append ( buf [ offset + <EOL> ofproto . OFP_EXPERIMENTER_MULTIPART_HEADER_SIZE : ] ) <EOL> stats = cls ( * args ) <EOL> stats . length = ofproto . OFP_METER_FEATURES_SIZE <EOL> return stats <EOL> def serialize ( self ) : <EOL> buf = bytearray ( ) <EOL> msg_pack_into ( ofproto . OFP_EXPERIMENTER_MULTIPART_HEADER_PACK_STR , <EOL> buf , <NUM_LIT:0> , <EOL> self . experimenter , self . exp_type ) <EOL> return buf + self . data <EOL> class OFPExperimenterStatsRequestBase ( OFPMultipartRequest ) : <EOL> def __init__ ( self , datapath , flags , <EOL> experimenter , exp_type , <EOL> type_ = None ) : <EOL> super ( OFPExperimenterStatsRequestBase , self ) . __init__ ( datapath , flags ) <EOL> self . experimenter = experimenter <EOL> self . exp_type = exp_type <EOL> @ _set_stats_type ( ofproto . OFPMP_EXPERIMENTER , OFPExperimenterMultipart ) <EOL> @ _set_msg_type ( ofproto . OFPT_MULTIPART_REQUEST ) <EOL> class OFPExperimenterStatsRequest ( OFPExperimenterStatsRequestBase ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , flags , <EOL> experimenter , exp_type , data , <EOL> type_ = None ) : <EOL> super ( OFPExperimenterStatsRequest , self ) . __init__ ( datapath , flags , <EOL> experimenter , <EOL> exp_type , type_ ) <EOL> self . data = data <EOL> def _serialize_stats_body ( self ) : <EOL> body = OFPExperimenterMultipart ( experimenter = self . experimenter , <EOL> exp_type = self . exp_type , <EOL> data = self . data ) <EOL> self . buf += body . serialize ( ) <EOL> @ OFPMultipartReply . register_stats_type ( body_single_struct = True ) <EOL> @ _set_stats_type ( ofproto . OFPMP_EXPERIMENTER , OFPExperimenterMultipart ) <EOL> @ _set_msg_type ( ofproto . OFPT_MULTIPART_REPLY ) <EOL> class OFPExperimenterStatsReply ( OFPMultipartReply ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , type_ = None , ** kwargs ) : <EOL> super ( OFPExperimenterStatsReply , self ) . __init__ ( datapath , ** kwargs ) <EOL> class OFPFlowStats ( StringifyMixin ) : <EOL> def __init__ ( self , table_id = None , duration_sec = None , duration_nsec = None , <EOL> priority = None , idle_timeout = None , hard_timeout = None , <EOL> flags = None , importance = None , cookie = None , packet_count = None , <EOL> byte_count = None , match = None , instructions = None , <EOL> length = None ) : <EOL> super ( OFPFlowStats , self ) . __init__ ( ) <EOL> self . table_id = table_id <EOL> self . duration_sec = duration_sec <EOL> self . duration_nsec = duration_nsec <EOL> self . priority = priority <EOL> self . idle_timeout = idle_timeout <EOL> self . hard_timeout = hard_timeout <EOL> self . flags = flags <EOL> self . importance = importance <EOL> self . cookie = cookie <EOL> self . packet_count = packet_count <EOL> self . byte_count = byte_count <EOL> self . match = match <EOL> self . instructions = instructions <EOL> self . length = length <EOL> @ classmethod <EOL> def parser ( cls , buf , offset ) : <EOL> flow_stats = cls ( ) <EOL> ( flow_stats . length , flow_stats . table_id , <EOL> flow_stats . duration_sec , flow_stats . duration_nsec , <EOL> flow_stats . priority , flow_stats . idle_timeout , <EOL> flow_stats . hard_timeout , flow_stats . flags , <EOL> flow_stats . importance , flow_stats . cookie , <EOL> flow_stats . packet_count , <EOL> flow_stats . byte_count ) = struct . unpack_from ( <EOL> ofproto . OFP_FLOW_STATS_0_PACK_STR , buf , offset ) <EOL> offset += ofproto . OFP_FLOW_STATS_0_SIZE <EOL> flow_stats . match = OFPMatch . parser ( buf , offset ) <EOL> match_length = utils . round_up ( flow_stats . match . length , <NUM_LIT:8> ) <EOL> inst_length = ( flow_stats . length - ( ofproto . OFP_FLOW_STATS_SIZE - <EOL> ofproto . OFP_MATCH_SIZE + <EOL> match_length ) ) <EOL> offset += match_length <EOL> instructions = [ ] <EOL> while inst_length > <NUM_LIT:0> : <EOL> inst = OFPInstruction . parser ( buf , offset ) <EOL> instructions . append ( inst ) <EOL> offset += inst . len <EOL> inst_length -= inst . len <EOL> flow_stats . instructions = instructions <EOL> return flow_stats <EOL> class OFPFlowStatsRequestBase ( OFPMultipartRequest ) : <EOL> def __init__ ( self , datapath , flags , table_id , out_port , out_group , <EOL> cookie , cookie_mask , match ) : <EOL> super ( OFPFlowStatsRequestBase , self ) . __init__ ( datapath , flags ) <EOL> self . table_id = table_id <EOL> self . out_port = out_port <EOL> self . out_group = out_group <EOL> self . cookie = cookie <EOL> self . cookie_mask = cookie_mask <EOL> self . match = match <EOL> def _serialize_stats_body ( self ) : <EOL> offset = ofproto . OFP_MULTIPART_REQUEST_SIZE <EOL> msg_pack_into ( ofproto . OFP_FLOW_STATS_REQUEST_0_PACK_STR , <EOL> self . buf , offset , self . table_id , self . out_port , <EOL> self . out_group , self . cookie , self . cookie_mask ) <EOL> offset += ofproto . OFP_FLOW_STATS_REQUEST_0_SIZE <EOL> self . match . serialize ( self . buf , offset ) <EOL> @ _set_stats_type ( ofproto . OFPMP_FLOW , OFPFlowStats ) <EOL> @ _set_msg_type ( ofproto . OFPT_MULTIPART_REQUEST ) <EOL> class OFPFlowStatsRequest ( OFPFlowStatsRequestBase ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , flags = <NUM_LIT:0> , table_id = ofproto . OFPTT_ALL , <EOL> out_port = ofproto . OFPP_ANY , <EOL> out_group = ofproto . OFPG_ANY , <EOL> cookie = <NUM_LIT:0> , cookie_mask = <NUM_LIT:0> , match = None , type_ = None ) : <EOL> if match is None : <EOL> match = OFPMatch ( ) <EOL> super ( OFPFlowStatsRequest , self ) . __init__ ( datapath , flags , table_id , <EOL> out_port , out_group , <EOL> cookie , cookie_mask , match ) <EOL> @ OFPMultipartReply . register_stats_type ( ) <EOL> @ _set_stats_type ( ofproto . OFPMP_FLOW , OFPFlowStats ) <EOL> @ _set_msg_type ( ofproto . OFPT_MULTIPART_REPLY ) <EOL> class OFPFlowStatsReply ( OFPMultipartReply ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , type_ = None , ** kwargs ) : <EOL> super ( OFPFlowStatsReply , self ) . __init__ ( datapath , ** kwargs ) <EOL> class OFPAggregateStats ( ofproto_parser . namedtuple ( '<STR_LIT>' , ( <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) ) ) : <EOL> @ classmethod <EOL> def parser ( cls , buf , offset ) : <EOL> agg = struct . unpack_from ( <EOL> ofproto . OFP_AGGREGATE_STATS_REPLY_PACK_STR , buf , offset ) <EOL> stats = cls ( * agg ) <EOL> stats . length = ofproto . OFP_AGGREGATE_STATS_REPLY_SIZE <EOL> return stats <EOL> @ _set_stats_type ( ofproto . OFPMP_AGGREGATE , OFPAggregateStats ) <EOL> @ _set_msg_type ( ofproto . OFPT_MULTIPART_REQUEST ) <EOL> class OFPAggregateStatsRequest ( OFPFlowStatsRequestBase ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , flags , table_id , out_port , out_group , <EOL> cookie , cookie_mask , match , type_ = None ) : <EOL> super ( OFPAggregateStatsRequest , self ) . __init__ ( datapath , <EOL> flags , <EOL> table_id , <EOL> out_port , <EOL> out_group , <EOL> cookie , <EOL> cookie_mask , <EOL> match ) <EOL> @ OFPMultipartReply . register_stats_type ( body_single_struct = True ) <EOL> @ _set_stats_type ( ofproto . OFPMP_AGGREGATE , OFPAggregateStats ) <EOL> @ _set_msg_type ( ofproto . OFPT_MULTIPART_REPLY ) <EOL> class OFPAggregateStatsReply ( OFPMultipartReply ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , type_ = None , ** kwargs ) : <EOL> super ( OFPAggregateStatsReply , self ) . __init__ ( datapath , ** kwargs ) <EOL> class OFPTableStats ( ofproto_parser . namedtuple ( '<STR_LIT>' , ( <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' ) ) ) : <EOL> @ classmethod <EOL> def parser ( cls , buf , offset ) : <EOL> tbl = struct . unpack_from ( ofproto . OFP_TABLE_STATS_PACK_STR , <EOL> buf , offset ) <EOL> stats = cls ( * tbl ) <EOL> stats . length = ofproto . OFP_TABLE_STATS_SIZE <EOL> return stats <EOL> @ _set_stats_type ( ofproto . OFPMP_TABLE , OFPTableStats ) <EOL> @ _set_msg_type ( ofproto . OFPT_MULTIPART_REQUEST ) <EOL> class OFPTableStatsRequest ( OFPMultipartRequest ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , flags , type_ = None ) : <EOL> super ( OFPTableStatsRequest , self ) . __init__ ( datapath , flags ) <EOL> @ OFPMultipartReply . register_stats_type ( ) <EOL> @ _set_stats_type ( ofproto . OFPMP_TABLE , OFPTableStats ) <EOL> @ _set_msg_type ( ofproto . OFPT_MULTIPART_REPLY ) <EOL> class OFPTableStatsReply ( OFPMultipartReply ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , type_ = None , ** kwargs ) : <EOL> super ( OFPTableStatsReply , self ) . __init__ ( datapath , ** kwargs ) <EOL> class OFPPortStatsProp ( OFPPropBase ) : <EOL> _TYPES = { } <EOL> @ OFPPortStatsProp . register_type ( ofproto . OFPPSPT_ETHERNET ) <EOL> class OFPPortStatsPropEthernet ( OFPPortStatsProp ) : <EOL> def __init__ ( self , type_ = None , length = None , rx_frame_err = None , <EOL> rx_over_err = None , rx_crc_err = None , collisions = None ) : <EOL> self . type = type_ <EOL> self . length = length <EOL> self . rx_frame_err = rx_frame_err <EOL> self . rx_over_err = rx_over_err <EOL> self . rx_crc_err = rx_crc_err <EOL> self . collisions = collisions <EOL> @ classmethod <EOL> def parser ( cls , buf ) : <EOL> ether = cls ( ) <EOL> ( ether . type , ether . length , ether . rx_frame_err , ether . rx_over_err , <EOL> ether . rx_crc_err , ether . collisions ) = struct . unpack_from ( <EOL> ofproto . OFP_PORT_STATS_PROP_ETHERNET_PACK_STR , buf , <NUM_LIT:0> ) <EOL> return ether <EOL> @ OFPPortStatsProp . register_type ( ofproto . OFPPSPT_OPTICAL ) <EOL> class OFPPortStatsPropOptical ( OFPPortStatsProp ) : <EOL> def __init__ ( self , type_ = None , length = None , flags = None , <EOL> tx_freq_lmda = None , tx_offset = None , tx_grid_span = None , <EOL> rx_freq_lmda = None , rx_offset = None , rx_grid_span = None , <EOL> tx_pwr = None , rx_pwr = None , bias_current = None , <EOL> temperature = None ) : <EOL> self . type = type_ <EOL> self . length = length <EOL> self . flags = flags <EOL> self . tx_freq_lmda = tx_freq_lmda <EOL> self . tx_offset = tx_offset <EOL> self . tx_grid_span = tx_grid_span <EOL> self . rx_freq_lmda = rx_freq_lmda <EOL> self . rx_offset = rx_offset <EOL> self . rx_grid_span = rx_grid_span <EOL> self . tx_pwr = tx_pwr <EOL> self . rx_pwr = rx_pwr <EOL> self . bias_current = bias_current <EOL> self . temperature = temperature <EOL> @ classmethod <EOL> def parser ( cls , buf ) : <EOL> optical = cls ( ) <EOL> ( optical . type , optical . length , optical . flags , <EOL> optical . tx_freq_lmda , optical . tx_offset , optical . tx_grid_span , <EOL> optical . rx_freq_lmda , optical . rx_offset , optical . rx_grid_span , <EOL> optical . tx_pwr , optical . rx_pwr , optical . bias_current , <EOL> optical . temperature ) = struct . unpack_from ( <EOL> ofproto . OFP_PORT_STATS_PROP_OPTICAL_PACK_STR , buf , <NUM_LIT:0> ) <EOL> return optical <EOL> @ OFPPortStatsProp . register_type ( ofproto . OFPPSPT_EXPERIMENTER ) <EOL> class OFPPortStatsPropExperimenter ( OFPPropCommonExperimenter4ByteData ) : <EOL> pass <EOL> class OFPPortStats ( StringifyMixin ) : <EOL> def __init__ ( self , length = None , port_no = None , duration_sec = None , <EOL> duration_nsec = None , rx_packets = None , tx_packets = None , <EOL> rx_bytes = None , tx_bytes = None , rx_dropped = None , <EOL> tx_dropped = None , rx_errors = None , tx_errors = None , <EOL> properties = None ) : <EOL> super ( OFPPortStats , self ) . __init__ ( ) <EOL> self . length = length <EOL> self . port_no = port_no <EOL> self . duration_sec = duration_sec <EOL> self . duration_nsec = duration_nsec <EOL> self . rx_packets = rx_packets <EOL> self . tx_packets = tx_packets <EOL> self . rx_bytes = rx_bytes <EOL> self . tx_bytes = tx_bytes <EOL> self . rx_dropped = rx_dropped <EOL> self . tx_dropped = tx_dropped <EOL> self . rx_errors = rx_errors <EOL> self . tx_errors = tx_errors <EOL> self . properties = properties <EOL> @ classmethod <EOL> def parser ( cls , buf , offset ) : <EOL> ( length , port_no , duration_sec , duration_nsec , rx_packets , <EOL> tx_packets , rx_bytes , tx_bytes , rx_dropped , tx_dropped , <EOL> rx_errors , tx_errors ) = struct . unpack_from ( <EOL> ofproto . OFP_PORT_STATS_PACK_STR , buf , offset ) <EOL> props = [ ] <EOL> rest = buf [ offset + ofproto . OFP_PORT_STATS_SIZE : offset + length ] <EOL> while rest : <EOL> p , rest = OFPPortStatsProp . parse ( rest ) <EOL> props . append ( p ) <EOL> stats = cls ( length , port_no , duration_sec , duration_nsec , rx_packets , <EOL> tx_packets , rx_bytes , tx_bytes , rx_dropped , tx_dropped , <EOL> rx_errors , tx_errors , props ) <EOL> return stats <EOL> @ _set_stats_type ( ofproto . OFPMP_PORT_STATS , OFPPortStats ) <EOL> @ _set_msg_type ( ofproto . OFPT_MULTIPART_REQUEST ) <EOL> class OFPPortStatsRequest ( OFPMultipartRequest ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , flags , port_no , type_ = None ) : <EOL> super ( OFPPortStatsRequest , self ) . __init__ ( datapath , flags ) <EOL> self . port_no = port_no <EOL> def _serialize_stats_body ( self ) : <EOL> msg_pack_into ( ofproto . OFP_PORT_STATS_REQUEST_PACK_STR , <EOL> self . buf , <EOL> ofproto . OFP_MULTIPART_REQUEST_SIZE , <EOL> self . port_no ) <EOL> @ OFPMultipartReply . register_stats_type ( ) <EOL> @ _set_stats_type ( ofproto . OFPMP_PORT_STATS , OFPPortStats ) <EOL> @ _set_msg_type ( ofproto . OFPT_MULTIPART_REPLY ) <EOL> class OFPPortStatsReply ( OFPMultipartReply ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , type_ = None , ** kwargs ) : <EOL> super ( OFPPortStatsReply , self ) . __init__ ( datapath , ** kwargs ) <EOL> @ _set_msg_type ( ofproto . OFPT_BARRIER_REQUEST ) <EOL> class OFPBarrierRequest ( MsgBase ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath ) : <EOL> super ( OFPBarrierRequest , self ) . __init__ ( datapath ) <EOL> @ _register_parser <EOL> @ _set_msg_type ( ofproto . OFPT_BARRIER_REPLY ) <EOL> class OFPBarrierReply ( MsgBase ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath ) : <EOL> super ( OFPBarrierReply , self ) . __init__ ( datapath ) <EOL> @ _register_parser <EOL> @ _set_msg_type ( ofproto . OFPT_PORT_STATUS ) <EOL> class OFPPortStatus ( MsgBase ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , reason = None , desc = None ) : <EOL> super ( OFPPortStatus , self ) . __init__ ( datapath ) <EOL> self . reason = reason <EOL> self . desc = desc <EOL> @ classmethod <EOL> def parser ( cls , datapath , version , msg_type , msg_len , xid , buf ) : <EOL> msg = super ( OFPPortStatus , cls ) . parser ( datapath , version , msg_type , <EOL> msg_len , xid , buf ) <EOL> msg . reason = struct . unpack_from ( <EOL> ofproto . OFP_PORT_STATUS_PACK_STR , msg . buf , <EOL> ofproto . OFP_HEADER_SIZE ) [ <NUM_LIT:0> ] <EOL> msg . desc = OFPPort . parser ( msg . buf , ofproto . OFP_PORT_STATUS_DESC_OFFSET ) <EOL> return msg <EOL> @ _register_parser <EOL> @ _set_msg_type ( ofproto . OFPT_ROLE_STATUS ) <EOL> class OFPRoleStatus ( MsgBase ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , role = None , reason = None , <EOL> generation_id = None , properties = None ) : <EOL> super ( OFPRoleStatus , self ) . __init__ ( datapath ) <EOL> self . role = role <EOL> self . reason = reason <EOL> self . generation_id = generation_id <EOL> self . properties = properties <EOL> @ classmethod <EOL> def parser ( cls , datapath , version , msg_type , msg_len , xid , buf ) : <EOL> msg = super ( OFPRoleStatus , cls ) . parser ( datapath , version , msg_type , <EOL> msg_len , xid , buf ) <EOL> ( msg . role , msg . reason , msg . generation_id ) = struct . unpack_from ( <EOL> ofproto . OFP_ROLE_STATUS_PACK_STR , msg . buf , <EOL> ofproto . OFP_HEADER_SIZE ) <EOL> msg . properties = [ ] <EOL> rest = msg . buf [ ofproto . OFP_ROLE_STATUS_SIZE : ] <EOL> while rest : <EOL> p , rest = OFPRoleProp . parse ( rest ) <EOL> msg . properties . append ( p ) <EOL> return msg <EOL> @ _register_parser <EOL> @ _set_msg_type ( ofproto . OFPT_TABLE_STATUS ) <EOL> class OFPTableStatus ( MsgBase ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , reason = None , table = None ) : <EOL> super ( OFPTableStatus , self ) . __init__ ( datapath ) <EOL> self . reason = reason <EOL> self . table = table <EOL> @ classmethod <EOL> def parser ( cls , datapath , version , msg_type , msg_len , xid , buf ) : <EOL> msg = super ( OFPTableStatus , cls ) . parser ( datapath , version , msg_type , <EOL> msg_len , xid , buf ) <EOL> ( msg . reason , ) = struct . unpack_from ( ofproto . OFP_TABLE_STATUS_0_PACK_STR , <EOL> msg . buf , ofproto . OFP_HEADER_SIZE ) <EOL> msg . table = OFPTableDesc . parser ( msg . buf , <EOL> ofproto . OFP_TABLE_STATUS_0_SIZE ) <EOL> return msg <EOL> @ _register_parser <EOL> @ _set_msg_type ( ofproto . OFPT_REQUESTFORWARD ) <EOL> class OFPRequestForward ( MsgInMsgBase ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , request = None ) : <EOL> super ( OFPRequestForward , self ) . __init__ ( datapath ) <EOL> self . request = request <EOL> @ classmethod <EOL> def parser ( cls , datapath , version , msg_type , msg_len , xid , buf ) : <EOL> msg = super ( OFPRequestForward , cls ) . parser ( <EOL> datapath , version , msg_type , msg_len , xid , buf ) <EOL> req_buf = buf [ ofproto . OFP_HEADER_SIZE : ] <EOL> ( _ver , _type , _len , _xid ) = ofproto_parser . header ( req_buf ) <EOL> msg . request = ofproto_parser . msg ( <EOL> datapath , _ver , _type , _len , _xid , req_buf ) <EOL> return msg <EOL> def _serialize_body ( self ) : <EOL> assert isinstance ( self . request , ( OFPGroupMod , OFPMeterMod ) ) <EOL> self . request . serialize ( ) <EOL> self . buf += self . request . buf <EOL> @ _set_msg_type ( ofproto . OFPT_PACKET_OUT ) <EOL> class OFPPacketOut ( MsgBase ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , buffer_id = None , in_port = None , actions = None , <EOL> data = None , actions_len = None ) : <EOL> assert in_port is not None <EOL> super ( OFPPacketOut , self ) . __init__ ( datapath ) <EOL> self . buffer_id = buffer_id <EOL> self . in_port = in_port <EOL> self . actions_len = <NUM_LIT:0> <EOL> self . actions = actions <EOL> self . data = data <EOL> def _serialize_body ( self ) : <EOL> self . actions_len = <NUM_LIT:0> <EOL> offset = ofproto . OFP_PACKET_OUT_SIZE <EOL> for a in self . actions : <EOL> a . serialize ( self . buf , offset ) <EOL> offset += a . len <EOL> self . actions_len += a . len <EOL> if self . data is not None : <EOL> assert self . buffer_id == <NUM_LIT> <EOL> self . buf += self . data <EOL> msg_pack_into ( ofproto . OFP_PACKET_OUT_PACK_STR , <EOL> self . buf , ofproto . OFP_HEADER_SIZE , <EOL> self . buffer_id , self . in_port , self . actions_len ) <EOL> @ _set_msg_type ( ofproto . OFPT_FLOW_MOD ) <EOL> class OFPFlowMod ( MsgBase ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , cookie = <NUM_LIT:0> , cookie_mask = <NUM_LIT:0> , table_id = <NUM_LIT:0> , <EOL> command = ofproto . OFPFC_ADD , <EOL> idle_timeout = <NUM_LIT:0> , hard_timeout = <NUM_LIT:0> , <EOL> priority = ofproto . OFP_DEFAULT_PRIORITY , <EOL> buffer_id = ofproto . OFP_NO_BUFFER , <EOL> out_port = <NUM_LIT:0> , out_group = <NUM_LIT:0> , flags = <NUM_LIT:0> , importance = <NUM_LIT:0> , <EOL> match = None , <EOL> instructions = None ) : <EOL> instructions = instructions if instructions else [ ] <EOL> super ( OFPFlowMod , self ) . __init__ ( datapath ) <EOL> self . cookie = cookie <EOL> self . cookie_mask = cookie_mask <EOL> self . table_id = table_id <EOL> self . command = command <EOL> self . idle_timeout = idle_timeout <EOL> self . hard_timeout = hard_timeout <EOL> self . priority = priority <EOL> self . buffer_id = buffer_id <EOL> self . out_port = out_port <EOL> self . out_group = out_group <EOL> self . flags = flags <EOL> self . importance = importance <EOL> if match is None : <EOL> match = OFPMatch ( ) <EOL> assert isinstance ( match , OFPMatch ) <EOL> self . match = match <EOL> for i in instructions : <EOL> assert isinstance ( i , OFPInstruction ) <EOL> self . instructions = instructions <EOL> def _serialize_body ( self ) : <EOL> msg_pack_into ( ofproto . OFP_FLOW_MOD_PACK_STR0 , self . buf , <EOL> ofproto . OFP_HEADER_SIZE , <EOL> self . cookie , self . cookie_mask , self . table_id , <EOL> self . command , self . idle_timeout , self . hard_timeout , <EOL> self . priority , self . buffer_id , self . out_port , <EOL> self . out_group , self . flags , self . importance ) <EOL> offset = ( ofproto . OFP_FLOW_MOD_SIZE - <EOL> ofproto . OFP_MATCH_SIZE ) <EOL> match_len = self . match . serialize ( self . buf , offset ) <EOL> offset += match_len <EOL> for inst in self . instructions : <EOL> inst . serialize ( self . buf , offset ) <EOL> offset += inst . len <EOL> class OFPInstruction ( StringifyMixin ) : <EOL> _INSTRUCTION_TYPES = { } <EOL> @ staticmethod <EOL> def register_instruction_type ( types ) : <EOL> def _register_instruction_type ( cls ) : <EOL> for type_ in types : <EOL> OFPInstruction . _INSTRUCTION_TYPES [ type_ ] = cls <EOL> return cls <EOL> return _register_instruction_type <EOL> @ classmethod <EOL> def parser ( cls , buf , offset ) : <EOL> ( type_ , len_ ) = struct . unpack_from ( '<STR_LIT>' , buf , offset ) <EOL> cls_ = cls . _INSTRUCTION_TYPES . get ( type_ ) <EOL> return cls_ . parser ( buf , offset ) <EOL> @ OFPInstruction . register_instruction_type ( [ ofproto . OFPIT_GOTO_TABLE ] ) <EOL> class OFPInstructionGotoTable ( OFPInstruction ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , table_id , type_ = None , len_ = None ) : <EOL> super ( OFPInstructionGotoTable , self ) . __init__ ( ) <EOL> self . type = ofproto . OFPIT_GOTO_TABLE <EOL> self . len = ofproto . OFP_INSTRUCTION_GOTO_TABLE_SIZE <EOL> self . table_id = table_id <EOL> @ classmethod <EOL> def parser ( cls , buf , offset ) : <EOL> ( type_ , len_ , table_id ) = struct . unpack_from ( <EOL> ofproto . OFP_INSTRUCTION_GOTO_TABLE_PACK_STR , <EOL> buf , offset ) <EOL> return cls ( table_id ) <EOL> def serialize ( self , buf , offset ) : <EOL> msg_pack_into ( ofproto . OFP_INSTRUCTION_GOTO_TABLE_PACK_STR , <EOL> buf , offset , self . type , self . len , self . table_id ) <EOL> @ OFPInstruction . register_instruction_type ( [ ofproto . OFPIT_WRITE_METADATA ] ) <EOL> class OFPInstructionWriteMetadata ( OFPInstruction ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , metadata , metadata_mask , type_ = None , len_ = None ) : <EOL> super ( OFPInstructionWriteMetadata , self ) . __init__ ( ) <EOL> self . type = ofproto . OFPIT_WRITE_METADATA <EOL> self . len = ofproto . OFP_INSTRUCTION_WRITE_METADATA_SIZE <EOL> self . metadata = metadata <EOL> self . metadata_mask = metadata_mask <EOL> @ classmethod <EOL> def parser ( cls , buf , offset ) : <EOL> ( type_ , len_ , metadata , metadata_mask ) = struct . unpack_from ( <EOL> ofproto . OFP_INSTRUCTION_WRITE_METADATA_PACK_STR , <EOL> buf , offset ) <EOL> return cls ( metadata , metadata_mask ) <EOL> def serialize ( self , buf , offset ) : <EOL> msg_pack_into ( ofproto . OFP_INSTRUCTION_WRITE_METADATA_PACK_STR , <EOL> buf , offset , self . type , self . len , self . metadata , <EOL> self . metadata_mask ) <EOL> @ OFPInstruction . register_instruction_type ( [ ofproto . OFPIT_WRITE_ACTIONS , <EOL> ofproto . OFPIT_APPLY_ACTIONS , <EOL> ofproto . OFPIT_CLEAR_ACTIONS ] ) <EOL> class OFPInstructionActions ( OFPInstruction ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , type_ , actions = None , len_ = None ) : <EOL> super ( OFPInstructionActions , self ) . __init__ ( ) <EOL> self . type = type_ <EOL> for a in actions : <EOL> assert isinstance ( a , OFPAction ) <EOL> self . actions = actions <EOL> @ classmethod <EOL> def parser ( cls , buf , offset ) : <EOL> ( type_ , len_ ) = struct . unpack_from ( <EOL> ofproto . OFP_INSTRUCTION_ACTIONS_PACK_STR , <EOL> buf , offset ) <EOL> offset += ofproto . OFP_INSTRUCTION_ACTIONS_SIZE <EOL> actions = [ ] <EOL> actions_len = len_ - ofproto . OFP_INSTRUCTION_ACTIONS_SIZE <EOL> while actions_len > <NUM_LIT:0> : <EOL> a = OFPAction . parser ( buf , offset ) <EOL> actions . append ( a ) <EOL> actions_len -= a . len <EOL> offset += a . len <EOL> inst = cls ( type_ , actions ) <EOL> inst . len = len_ <EOL> return inst <EOL> def serialize ( self , buf , offset ) : <EOL> action_offset = offset + ofproto . OFP_INSTRUCTION_ACTIONS_SIZE <EOL> if self . actions : <EOL> for a in self . actions : <EOL> a . serialize ( buf , action_offset ) <EOL> action_offset += a . len <EOL> self . len = action_offset - offset <EOL> pad_len = utils . round_up ( self . len , <NUM_LIT:8> ) - self . len <EOL> msg_pack_into ( "<STR_LIT>" % pad_len , buf , action_offset ) <EOL> self . len += pad_len <EOL> msg_pack_into ( ofproto . OFP_INSTRUCTION_ACTIONS_PACK_STR , <EOL> buf , offset , self . type , self . len ) <EOL> @ OFPInstruction . register_instruction_type ( [ ofproto . OFPIT_METER ] ) <EOL> class OFPInstructionMeter ( OFPInstruction ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , meter_id = <NUM_LIT:1> , type_ = None , len_ = None ) : <EOL> super ( OFPInstructionMeter , self ) . __init__ ( ) <EOL> self . type = ofproto . OFPIT_METER <EOL> self . len = ofproto . OFP_INSTRUCTION_METER_SIZE <EOL> self . meter_id = meter_id <EOL> @ classmethod <EOL> def parser ( cls , buf , offset ) : <EOL> ( type_ , len_ , meter_id ) = struct . unpack_from ( <EOL> ofproto . OFP_INSTRUCTION_METER_PACK_STR , <EOL> buf , offset ) <EOL> return cls ( meter_id ) <EOL> def serialize ( self , buf , offset ) : <EOL> msg_pack_into ( ofproto . OFP_INSTRUCTION_METER_PACK_STR , <EOL> buf , offset , self . type , self . len , self . meter_id ) <EOL> class OFPActionHeader ( StringifyMixin ) : <EOL> def __init__ ( self , type_ , len_ ) : <EOL> self . type = type_ <EOL> self . len = len_ <EOL> def serialize ( self , buf , offset ) : <EOL> msg_pack_into ( ofproto . OFP_ACTION_HEADER_PACK_STR , <EOL> buf , offset , self . type , self . len ) <EOL> class OFPAction ( OFPActionHeader ) : <EOL> _ACTION_TYPES = { } <EOL> @ staticmethod <EOL> def register_action_type ( type_ , len_ ) : <EOL> def _register_action_type ( cls ) : <EOL> cls . cls_action_type = type_ <EOL> cls . cls_action_len = len_ <EOL> OFPAction . _ACTION_TYPES [ cls . cls_action_type ] = cls <EOL> return cls <EOL> return _register_action_type <EOL> def __init__ ( self ) : <EOL> cls = self . __class__ <EOL> super ( OFPAction , self ) . __init__ ( cls . cls_action_type , <EOL> cls . cls_action_len ) <EOL> @ classmethod <EOL> def parser ( cls , buf , offset ) : <EOL> type_ , len_ = struct . unpack_from ( <EOL> ofproto . OFP_ACTION_HEADER_PACK_STR , buf , offset ) <EOL> cls_ = cls . _ACTION_TYPES . get ( type_ ) <EOL> assert cls_ is not None <EOL> return cls_ . parser ( buf , offset ) <EOL> @ OFPAction . register_action_type ( ofproto . OFPAT_OUTPUT , <EOL> ofproto . OFP_ACTION_OUTPUT_SIZE ) <EOL> class OFPActionOutput ( OFPAction ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , port , max_len = ofproto . OFPCML_MAX , <EOL> type_ = None , len_ = None ) : <EOL> super ( OFPActionOutput , self ) . __init__ ( ) <EOL> self . port = port <EOL> self . max_len = max_len <EOL> @ classmethod <EOL> def parser ( cls , buf , offset ) : <EOL> type_ , len_ , port , max_len = struct . unpack_from ( <EOL> ofproto . OFP_ACTION_OUTPUT_PACK_STR , buf , offset ) <EOL> return cls ( port , max_len ) <EOL> def serialize ( self , buf , offset ) : <EOL> msg_pack_into ( ofproto . OFP_ACTION_OUTPUT_PACK_STR , buf , <EOL> offset , self . type , self . len , self . port , self . max_len ) <EOL> @ OFPAction . register_action_type ( ofproto . OFPAT_GROUP , <EOL> ofproto . OFP_ACTION_GROUP_SIZE ) <EOL> class OFPActionGroup ( OFPAction ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , group_id = <NUM_LIT:0> , type_ = None , len_ = None ) : <EOL> super ( OFPActionGroup , self ) . __init__ ( ) <EOL> self . group_id = group_id <EOL> @ classmethod <EOL> def parser ( cls , buf , offset ) : <EOL> ( type_ , len_ , group_id ) = struct . unpack_from ( <EOL> ofproto . OFP_ACTION_GROUP_PACK_STR , buf , offset ) <EOL> return cls ( group_id ) <EOL> def serialize ( self , buf , offset ) : <EOL> msg_pack_into ( ofproto . OFP_ACTION_GROUP_PACK_STR , buf , <EOL> offset , self . type , self . len , self . group_id ) <EOL> @ OFPAction . register_action_type ( ofproto . OFPAT_SET_QUEUE , <EOL> ofproto . OFP_ACTION_SET_QUEUE_SIZE ) <EOL> class OFPActionSetQueue ( OFPAction ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , queue_id , type_ = None , len_ = None ) : <EOL> super ( OFPActionSetQueue , self ) . __init__ ( ) <EOL> self . queue_id = queue_id <EOL> @ classmethod <EOL> def parser ( cls , buf , offset ) : <EOL> ( type_ , len_ , queue_id ) = struct . unpack_from ( <EOL> ofproto . OFP_ACTION_SET_QUEUE_PACK_STR , buf , offset ) <EOL> return cls ( queue_id ) <EOL> def serialize ( self , buf , offset ) : <EOL> msg_pack_into ( ofproto . OFP_ACTION_SET_QUEUE_PACK_STR , buf , <EOL> offset , self . type , self . len , self . queue_id ) <EOL> @ OFPAction . register_action_type ( ofproto . OFPAT_SET_MPLS_TTL , <EOL> ofproto . OFP_ACTION_MPLS_TTL_SIZE ) <EOL> class OFPActionSetMplsTtl ( OFPAction ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , mpls_ttl , type_ = None , len_ = None ) : <EOL> super ( OFPActionSetMplsTtl , self ) . __init__ ( ) <EOL> self . mpls_ttl = mpls_ttl <EOL> @ classmethod <EOL> def parser ( cls , buf , offset ) : <EOL> ( type_ , len_ , mpls_ttl ) = struct . unpack_from ( <EOL> ofproto . OFP_ACTION_MPLS_TTL_PACK_STR , buf , offset ) <EOL> return cls ( mpls_ttl ) <EOL> def serialize ( self , buf , offset ) : <EOL> msg_pack_into ( ofproto . OFP_ACTION_MPLS_TTL_PACK_STR , buf , <EOL> offset , self . type , self . len , self . mpls_ttl ) <EOL> @ OFPAction . register_action_type ( ofproto . OFPAT_DEC_MPLS_TTL , <EOL> ofproto . OFP_ACTION_HEADER_SIZE ) <EOL> class OFPActionDecMplsTtl ( OFPAction ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , type_ = None , len_ = None ) : <EOL> super ( OFPActionDecMplsTtl , self ) . __init__ ( ) <EOL> @ classmethod <EOL> def parser ( cls , buf , offset ) : <EOL> ( type_ , len_ ) = struct . unpack_from ( <EOL> ofproto . OFP_ACTION_HEADER_PACK_STR , buf , offset ) <EOL> return cls ( ) <EOL> @ OFPAction . register_action_type ( ofproto . OFPAT_SET_NW_TTL , <EOL> ofproto . OFP_ACTION_NW_TTL_SIZE ) <EOL> class OFPActionSetNwTtl ( OFPAction ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , nw_ttl , type_ = None , len_ = None ) : <EOL> super ( OFPActionSetNwTtl , self ) . __init__ ( ) <EOL> self . nw_ttl = nw_ttl <EOL> @ classmethod <EOL> def parser ( cls , buf , offset ) : <EOL> ( type_ , len_ , nw_ttl ) = struct . unpack_from ( <EOL> ofproto . OFP_ACTION_NW_TTL_PACK_STR , buf , offset ) <EOL> return cls ( nw_ttl ) <EOL> def serialize ( self , buf , offset ) : <EOL> msg_pack_into ( ofproto . OFP_ACTION_NW_TTL_PACK_STR , buf , offset , <EOL> self . type , self . len , self . nw_ttl ) <EOL> @ OFPAction . register_action_type ( ofproto . OFPAT_DEC_NW_TTL , <EOL> ofproto . OFP_ACTION_HEADER_SIZE ) <EOL> class OFPActionDecNwTtl ( OFPAction ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , type_ = None , len_ = None ) : <EOL> super ( OFPActionDecNwTtl , self ) . __init__ ( ) <EOL> @ classmethod <EOL> def parser ( cls , buf , offset ) : <EOL> ( type_ , len_ ) = struct . unpack_from ( <EOL> ofproto . OFP_ACTION_HEADER_PACK_STR , buf , offset ) <EOL> return cls ( ) <EOL> @ OFPAction . register_action_type ( ofproto . OFPAT_COPY_TTL_OUT , <EOL> ofproto . OFP_ACTION_HEADER_SIZE ) <EOL> class OFPActionCopyTtlOut ( OFPAction ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , type_ = None , len_ = None ) : <EOL> super ( OFPActionCopyTtlOut , self ) . __init__ ( ) <EOL> @ classmethod <EOL> def parser ( cls , buf , offset ) : <EOL> ( type_ , len_ ) = struct . unpack_from ( <EOL> ofproto . OFP_ACTION_HEADER_PACK_STR , buf , offset ) <EOL> return cls ( ) <EOL> @ OFPAction . register_action_type ( ofproto . OFPAT_COPY_TTL_IN , <EOL> ofproto . OFP_ACTION_HEADER_SIZE ) <EOL> class OFPActionCopyTtlIn ( OFPAction ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , type_ = None , len_ = None ) : <EOL> super ( OFPActionCopyTtlIn , self ) . __init__ ( ) <EOL> @ classmethod <EOL> def parser ( cls , buf , offset ) : <EOL> ( type_ , len_ ) = struct . unpack_from ( <EOL> ofproto . OFP_ACTION_HEADER_PACK_STR , buf , offset ) <EOL> return cls ( ) <EOL> @ OFPAction . register_action_type ( ofproto . OFPAT_PUSH_VLAN , <EOL> ofproto . OFP_ACTION_PUSH_SIZE ) <EOL> class OFPActionPushVlan ( OFPAction ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , ethertype = ether . ETH_TYPE_8021Q , type_ = None , len_ = None ) : <EOL> super ( OFPActionPushVlan , self ) . __init__ ( ) <EOL> self . ethertype = ethertype <EOL> @ classmethod <EOL> def parser ( cls , buf , offset ) : <EOL> ( type_ , len_ , ethertype ) = struct . unpack_from ( <EOL> ofproto . OFP_ACTION_PUSH_PACK_STR , buf , offset ) <EOL> return cls ( ethertype ) <EOL> def serialize ( self , buf , offset ) : <EOL> msg_pack_into ( ofproto . OFP_ACTION_PUSH_PACK_STR , buf , offset , <EOL> self . type , self . len , self . ethertype ) <EOL> @ OFPAction . register_action_type ( ofproto . OFPAT_PUSH_MPLS , <EOL> ofproto . OFP_ACTION_PUSH_SIZE ) <EOL> class OFPActionPushMpls ( OFPAction ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , ethertype = ether . ETH_TYPE_MPLS , type_ = None , len_ = None ) : <EOL> super ( OFPActionPushMpls , self ) . __init__ ( ) <EOL> self . ethertype = ethertype <EOL> @ classmethod <EOL> def parser ( cls , buf , offset ) : <EOL> ( type_ , len_ , ethertype ) = struct . unpack_from ( <EOL> ofproto . OFP_ACTION_PUSH_PACK_STR , buf , offset ) <EOL> return cls ( ethertype ) <EOL> def serialize ( self , buf , offset ) : <EOL> msg_pack_into ( ofproto . OFP_ACTION_PUSH_PACK_STR , buf , offset , <EOL> self . type , self . len , self . ethertype ) <EOL> @ OFPAction . register_action_type ( ofproto . OFPAT_POP_VLAN , <EOL> ofproto . OFP_ACTION_HEADER_SIZE ) <EOL> class OFPActionPopVlan ( OFPAction ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , type_ = None , len_ = None ) : <EOL> super ( OFPActionPopVlan , self ) . __init__ ( ) <EOL> @ classmethod <EOL> def parser ( cls , buf , offset ) : <EOL> ( type_ , len_ ) = struct . unpack_from ( <EOL> ofproto . OFP_ACTION_HEADER_PACK_STR , buf , offset ) <EOL> return cls ( ) <EOL> @ OFPAction . register_action_type ( ofproto . OFPAT_POP_MPLS , <EOL> ofproto . OFP_ACTION_POP_MPLS_SIZE ) <EOL> class OFPActionPopMpls ( OFPAction ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , ethertype = ether . ETH_TYPE_IP , type_ = None , len_ = None ) : <EOL> super ( OFPActionPopMpls , self ) . __init__ ( ) <EOL> self . ethertype = ethertype <EOL> @ classmethod <EOL> def parser ( cls , buf , offset ) : <EOL> ( type_ , len_ , ethertype ) = struct . unpack_from ( <EOL> ofproto . OFP_ACTION_POP_MPLS_PACK_STR , buf , offset ) <EOL> return cls ( ethertype ) <EOL> def serialize ( self , buf , offset ) : <EOL> msg_pack_into ( ofproto . OFP_ACTION_POP_MPLS_PACK_STR , buf , offset , <EOL> self . type , self . len , self . ethertype ) <EOL> @ OFPAction . register_action_type ( ofproto . OFPAT_SET_FIELD , <EOL> ofproto . OFP_ACTION_SET_FIELD_SIZE ) <EOL> class OFPActionSetField ( OFPAction ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , field = None , ** kwargs ) : <EOL> super ( OFPActionSetField , self ) . __init__ ( ) <EOL> assert len ( kwargs ) == <NUM_LIT:1> <EOL> key = list ( kwargs . keys ( ) ) [ <NUM_LIT:0> ] <EOL> value = kwargs [ key ] <EOL> assert isinstance ( key , ( str , six . text_type ) ) <EOL> assert not isinstance ( value , tuple ) <EOL> self . key = key <EOL> self . value = value <EOL> @ classmethod <EOL> def parser ( cls , buf , offset ) : <EOL> ( type_ , len_ ) = struct . unpack_from ( <EOL> ofproto . OFP_ACTION_SET_FIELD_PACK_STR , buf , offset ) <EOL> ( n , value , mask , _len ) = ofproto . oxm_parse ( buf , offset + <NUM_LIT:4> ) <EOL> k , uv = ofproto . oxm_to_user ( n , value , mask ) <EOL> action = cls ( ** { k : uv } ) <EOL> action . len = len_ <EOL> return action <EOL> def serialize ( self , buf , offset ) : <EOL> n , value , mask = ofproto . oxm_from_user ( self . key , self . value ) <EOL> len_ = ofproto . oxm_serialize ( n , value , mask , buf , offset + <NUM_LIT:4> ) <EOL> self . len = utils . round_up ( <NUM_LIT:4> + len_ , <NUM_LIT:8> ) <EOL> msg_pack_into ( '<STR_LIT>' , buf , offset , self . type , self . len ) <EOL> pad_len = self . len - ( <NUM_LIT:4> + len_ ) <EOL> msg_pack_into ( "<STR_LIT>" % pad_len , buf , offset + <NUM_LIT:4> + len_ ) <EOL> def to_jsondict ( self ) : <EOL> return { <EOL> self . __class__ . __name__ : { <EOL> '<STR_LIT>' : ofproto . oxm_to_jsondict ( self . key , self . value ) , <EOL> "<STR_LIT>" : self . len , <EOL> "<STR_LIT:type>" : self . type <EOL> } <EOL> } <EOL> @ classmethod <EOL> def from_jsondict ( cls , dict_ ) : <EOL> k , v = ofproto . oxm_from_jsondict ( dict_ [ '<STR_LIT>' ] ) <EOL> return OFPActionSetField ( ** { k : v } ) <EOL> def stringify_attrs ( self ) : <EOL> yield ( self . key , self . value ) <EOL> @ OFPAction . register_action_type ( ofproto . OFPAT_PUSH_PBB , <EOL> ofproto . OFP_ACTION_PUSH_SIZE ) <EOL> class OFPActionPushPbb ( OFPAction ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , ethertype , type_ = None , len_ = None ) : <EOL> super ( OFPActionPushPbb , self ) . __init__ ( ) <EOL> self . ethertype = ethertype <EOL> @ classmethod <EOL> def parser ( cls , buf , offset ) : <EOL> ( type_ , len_ , ethertype ) = struct . unpack_from ( <EOL> ofproto . OFP_ACTION_PUSH_PACK_STR , buf , offset ) <EOL> return cls ( ethertype ) <EOL> def serialize ( self , buf , offset ) : <EOL> msg_pack_into ( ofproto . OFP_ACTION_PUSH_PACK_STR , buf , offset , <EOL> self . type , self . len , self . ethertype ) <EOL> @ OFPAction . register_action_type ( ofproto . OFPAT_POP_PBB , <EOL> ofproto . OFP_ACTION_HEADER_SIZE ) <EOL> class OFPActionPopPbb ( OFPAction ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , type_ = None , len_ = None ) : <EOL> super ( OFPActionPopPbb , self ) . __init__ ( ) <EOL> @ classmethod <EOL> def parser ( cls , buf , offset ) : <EOL> ( type_ , len_ ) = struct . unpack_from ( <EOL> ofproto . OFP_ACTION_HEADER_PACK_STR , buf , offset ) <EOL> return cls ( ) <EOL> @ OFPAction . register_action_type ( <EOL> ofproto . OFPAT_EXPERIMENTER , <EOL> ofproto . OFP_ACTION_EXPERIMENTER_HEADER_SIZE ) <EOL> class OFPActionExperimenter ( OFPAction ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , experimenter ) : <EOL> super ( OFPActionExperimenter , self ) . __init__ ( ) <EOL> self . type = ofproto . OFPAT_EXPERIMENTER <EOL> self . experimenter = experimenter <EOL> self . len = None <EOL> @ classmethod <EOL> def parser ( cls , buf , offset ) : <EOL> ( type_ , len_ , experimenter ) = struct . unpack_from ( <EOL> ofproto . OFP_ACTION_EXPERIMENTER_HEADER_PACK_STR , buf , offset ) <EOL> data = buf [ ( offset + ofproto . OFP_ACTION_EXPERIMENTER_HEADER_SIZE <EOL> ) : offset + len_ ] <EOL> if experimenter == ofproto_common . NX_EXPERIMENTER_ID : <EOL> obj = NXAction . parse ( data ) <EOL> else : <EOL> obj = OFPActionExperimenterUnknown ( experimenter , data ) <EOL> obj . len = len_ <EOL> return obj <EOL> def serialize ( self , buf , offset ) : <EOL> msg_pack_into ( ofproto . OFP_ACTION_EXPERIMENTER_HEADER_PACK_STR , <EOL> buf , offset , self . type , self . len , self . experimenter ) <EOL> class OFPActionExperimenterUnknown ( OFPActionExperimenter ) : <EOL> def __init__ ( self , experimenter , data = None , type_ = None , len_ = None ) : <EOL> super ( OFPActionExperimenterUnknown , <EOL> self ) . __init__ ( experimenter = experimenter ) <EOL> self . data = data <EOL> def serialize ( self , buf , offset ) : <EOL> data = self . data <EOL> if data is None : <EOL> data = bytearray ( ) <EOL> self . len = ( utils . round_up ( len ( data ) , <NUM_LIT:8> ) + <EOL> ofproto . OFP_ACTION_EXPERIMENTER_HEADER_SIZE ) <EOL> super ( OFPActionExperimenterUnknown , self ) . serialize ( buf , offset ) <EOL> msg_pack_into ( '<STR_LIT>' % len ( self . data ) , <EOL> buf , <EOL> offset + ofproto . OFP_ACTION_EXPERIMENTER_HEADER_SIZE , <EOL> self . data ) <EOL> @ _register_parser <EOL> @ _set_msg_type ( ofproto . OFPT_GROUP_MOD ) <EOL> class OFPGroupMod ( MsgBase ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , command = ofproto . OFPGC_ADD , <EOL> type_ = ofproto . OFPGT_ALL , group_id = <NUM_LIT:0> , buckets = None ) : <EOL> buckets = buckets if buckets else [ ] <EOL> super ( OFPGroupMod , self ) . __init__ ( datapath ) <EOL> self . command = command <EOL> self . type = type_ <EOL> self . group_id = group_id <EOL> self . buckets = buckets <EOL> @ classmethod <EOL> def parser ( cls , datapath , version , msg_type , msg_len , xid , buf ) : <EOL> msg = super ( OFPGroupMod , cls ) . parser ( <EOL> datapath , version , msg_type , msg_len , xid , buf ) <EOL> ( msg . command , msg . type , msg . group_id ) = struct . unpack_from ( <EOL> ofproto . OFP_GROUP_MOD_PACK_STR , buf , ofproto . OFP_HEADER_SIZE ) <EOL> offset = ofproto . OFP_GROUP_MOD_SIZE <EOL> msg . buckets = [ ] <EOL> while offset < msg . msg_len : <EOL> bucket = OFPBucket . parser ( buf , offset ) <EOL> msg . buckets . append ( bucket ) <EOL> offset += bucket . len <EOL> return msg <EOL> def _serialize_body ( self ) : <EOL> msg_pack_into ( ofproto . OFP_GROUP_MOD_PACK_STR , self . buf , <EOL> ofproto . OFP_HEADER_SIZE , <EOL> self . command , self . type , self . group_id ) <EOL> offset = ofproto . OFP_GROUP_MOD_SIZE <EOL> for b in self . buckets : <EOL> b . serialize ( self . buf , offset ) <EOL> offset += b . len <EOL> class OFPPortModProp ( OFPPropBase ) : <EOL> _TYPES = { } <EOL> class OFPPortModPropEthernet ( OFPPortModProp ) : <EOL> def __init__ ( self , type_ = None , length = None , advertise = None ) : <EOL> self . type = type_ <EOL> self . advertise = advertise <EOL> def serialize ( self ) : <EOL> self . length = struct . calcsize ( <EOL> ofproto . OFP_PORT_MOD_PROP_ETHERNET_PACK_STR ) <EOL> buf = bytearray ( ) <EOL> msg_pack_into ( ofproto . OFP_PORT_MOD_PROP_ETHERNET_PACK_STR , <EOL> buf , <NUM_LIT:0> , self . type , self . length , self . advertise ) <EOL> return buf <EOL> class OFPPortModPropOptical ( OFPPortModProp ) : <EOL> def __init__ ( self , type_ = None , length = None , configure = None , <EOL> freq_lmda = None , fl_offset = None , grid_span = None , <EOL> tx_pwr = None ) : <EOL> self . type = type_ <EOL> self . length = length <EOL> self . configure = configure <EOL> self . freq_lmda = freq_lmda <EOL> self . fl_offset = fl_offset <EOL> self . grid_span = grid_span <EOL> self . tx_pwr = tx_pwr <EOL> def serialize ( self ) : <EOL> self . length = struct . calcsize ( <EOL> ofproto . OFP_PORT_MOD_PROP_OPTICAL_PACK_STR ) <EOL> buf = bytearray ( ) <EOL> msg_pack_into ( ofproto . OFP_PORT_MOD_PROP_OPTICAL_PACK_STR , buf , <NUM_LIT:0> , <EOL> self . type , self . length , self . configure , self . freq_lmda , <EOL> self . fl_offset , self . grid_span , self . tx_pwr ) <EOL> return buf <EOL> class OFPPortModPropExperimenter ( OFPPropCommonExperimenter4ByteData ) : <EOL> pass <EOL> @ _set_msg_type ( ofproto . OFPT_PORT_MOD ) <EOL> class OFPPortMod ( MsgBase ) : <EOL> """<STR_LIT>""" <EOL> _TYPE = { <EOL> '<STR_LIT:ascii>' : [ <EOL> '<STR_LIT>' , <EOL> ] <EOL> } <EOL> def __init__ ( self , datapath , port_no = <NUM_LIT:0> , hw_addr = '<STR_LIT>' , <EOL> config = <NUM_LIT:0> , mask = <NUM_LIT:0> , properties = None ) : <EOL> super ( OFPPortMod , self ) . __init__ ( datapath ) <EOL> self . port_no = port_no <EOL> self . hw_addr = hw_addr <EOL> self . config = config <EOL> self . mask = mask <EOL> self . properties = properties or [ ] <EOL> def _serialize_body ( self ) : <EOL> bin_props = bytearray ( ) <EOL> for p in self . properties : <EOL> bin_props += p . serialize ( ) <EOL> msg_pack_into ( ofproto . OFP_PORT_MOD_PACK_STR , self . buf , <EOL> ofproto . OFP_HEADER_SIZE , <EOL> self . port_no , addrconv . mac . text_to_bin ( self . hw_addr ) , <EOL> self . config , <EOL> self . mask ) <EOL> self . buf += bin_props <EOL> class OFPBucket ( StringifyMixin ) : <EOL> def __init__ ( self , weight = <NUM_LIT:0> , watch_port = ofproto . OFPP_ANY , <EOL> watch_group = ofproto . OFPG_ANY , actions = None , len_ = None ) : <EOL> super ( OFPBucket , self ) . __init__ ( ) <EOL> self . weight = weight <EOL> self . watch_port = watch_port <EOL> self . watch_group = watch_group <EOL> self . actions = actions <EOL> @ classmethod <EOL> def parser ( cls , buf , offset ) : <EOL> ( len_ , weight , watch_port , watch_group ) = struct . unpack_from ( <EOL> ofproto . OFP_BUCKET_PACK_STR , buf , offset ) <EOL> msg = cls ( weight , watch_port , watch_group , [ ] ) <EOL> msg . len = len_ <EOL> length = ofproto . OFP_BUCKET_SIZE <EOL> offset += ofproto . OFP_BUCKET_SIZE <EOL> while length < msg . len : <EOL> action = OFPAction . parser ( buf , offset ) <EOL> msg . actions . append ( action ) <EOL> offset += action . len <EOL> length += action . len <EOL> return msg <EOL> def serialize ( self , buf , offset ) : <EOL> action_offset = offset + ofproto . OFP_BUCKET_SIZE <EOL> action_len = <NUM_LIT:0> <EOL> for a in self . actions : <EOL> a . serialize ( buf , action_offset ) <EOL> action_offset += a . len <EOL> action_len += a . len <EOL> self . len = utils . round_up ( ofproto . OFP_BUCKET_SIZE + action_len , <NUM_LIT:8> ) <EOL> msg_pack_into ( ofproto . OFP_BUCKET_PACK_STR , buf , offset , <EOL> self . len , self . weight , self . watch_port , <EOL> self . watch_group ) <EOL> @ _set_msg_type ( ofproto . OFPT_ROLE_REQUEST ) <EOL> class OFPRoleRequest ( MsgBase ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , role = None , generation_id = None ) : <EOL> super ( OFPRoleRequest , self ) . __init__ ( datapath ) <EOL> self . role = role <EOL> self . generation_id = generation_id <EOL> def _serialize_body ( self ) : <EOL> assert self . role is not None <EOL> assert self . generation_id is not None <EOL> msg_pack_into ( ofproto . OFP_ROLE_REQUEST_PACK_STR , <EOL> self . buf , ofproto . OFP_HEADER_SIZE , <EOL> self . role , self . generation_id ) <EOL> @ _register_parser <EOL> @ _set_msg_type ( ofproto . OFPT_ROLE_REPLY ) <EOL> class OFPRoleReply ( MsgBase ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , role = None , generation_id = None ) : <EOL> super ( OFPRoleReply , self ) . __init__ ( datapath ) <EOL> self . role = role <EOL> self . generation_id = generation_id <EOL> @ classmethod <EOL> def parser ( cls , datapath , version , msg_type , msg_len , xid , buf ) : <EOL> msg = super ( OFPRoleReply , cls ) . parser ( datapath , version , <EOL> msg_type , msg_len , xid , <EOL> buf ) <EOL> ( msg . role , msg . generation_id ) = struct . unpack_from ( <EOL> ofproto . OFP_ROLE_REQUEST_PACK_STR , msg . buf , <EOL> ofproto . OFP_HEADER_SIZE ) <EOL> return msg <EOL> class OFPAsyncConfigProp ( OFPPropBase ) : <EOL> _TYPES = { } <EOL> @ OFPAsyncConfigProp . register_type ( ofproto . OFPACPT_PACKET_IN_SLAVE ) <EOL> @ OFPAsyncConfigProp . register_type ( ofproto . OFPACPT_PACKET_IN_MASTER ) <EOL> @ OFPAsyncConfigProp . register_type ( ofproto . OFPACPT_PORT_STATUS_SLAVE ) <EOL> @ OFPAsyncConfigProp . register_type ( ofproto . OFPACPT_PORT_STATUS_MASTER ) <EOL> @ OFPAsyncConfigProp . register_type ( ofproto . OFPACPT_FLOW_REMOVED_SLAVE ) <EOL> @ OFPAsyncConfigProp . register_type ( ofproto . OFPACPT_FLOW_REMOVED_MASTER ) <EOL> @ OFPAsyncConfigProp . register_type ( ofproto . OFPACPT_ROLE_STATUS_SLAVE ) <EOL> @ OFPAsyncConfigProp . register_type ( ofproto . OFPACPT_ROLE_STATUS_MASTER ) <EOL> @ OFPAsyncConfigProp . register_type ( ofproto . OFPACPT_TABLE_STATUS_SLAVE ) <EOL> @ OFPAsyncConfigProp . register_type ( ofproto . OFPACPT_TABLE_STATUS_MASTER ) <EOL> @ OFPAsyncConfigProp . register_type ( ofproto . OFPACPT_REQUESTFORWARD_SLAVE ) <EOL> @ OFPAsyncConfigProp . register_type ( ofproto . OFPACPT_REQUESTFORWARD_MASTER ) <EOL> class OFPAsyncConfigPropReasons ( OFPAsyncConfigProp ) : <EOL> def __init__ ( self , type_ = None , length = None , mask = None ) : <EOL> self . type = type_ <EOL> self . length = length <EOL> self . mask = mask <EOL> @ classmethod <EOL> def parser ( cls , buf ) : <EOL> reasons = cls ( ) <EOL> ( reasons . type , reasons . length , reasons . mask ) = struct . unpack_from ( <EOL> ofproto . OFP_ASYNC_CONFIG_PROP_REASONS_PACK_STR , buf , <NUM_LIT:0> ) <EOL> return reasons <EOL> def serialize ( self ) : <EOL> self . length = ofproto . OFP_ASYNC_CONFIG_PROP_REASONS_SIZE <EOL> buf = bytearray ( ) <EOL> msg_pack_into ( ofproto . OFP_ASYNC_CONFIG_PROP_REASONS_PACK_STR , buf , <NUM_LIT:0> , <EOL> self . type , self . length , self . mask ) <EOL> return buf <EOL> @ OFPAsyncConfigProp . register_type ( ofproto . OFPACPT_EXPERIMENTER_SLAVE ) <EOL> @ OFPAsyncConfigProp . register_type ( ofproto . OFPACPT_EXPERIMENTER_MASTER ) <EOL> class OFPAsyncConfigPropExperimenter ( OFPPropCommonExperimenter4ByteData ) : <EOL> pass <EOL> @ _set_msg_type ( ofproto . OFPT_GET_ASYNC_REQUEST ) <EOL> class OFPGetAsyncRequest ( MsgBase ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath ) : <EOL> super ( OFPGetAsyncRequest , self ) . __init__ ( datapath ) <EOL> @ _register_parser <EOL> @ _set_msg_type ( ofproto . OFPT_GET_ASYNC_REPLY ) <EOL> class OFPGetAsyncReply ( MsgBase ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , properties = None ) : <EOL> super ( OFPGetAsyncReply , self ) . __init__ ( datapath ) <EOL> self . properties = properties <EOL> @ classmethod <EOL> def parser ( cls , datapath , version , msg_type , msg_len , xid , buf ) : <EOL> msg = super ( OFPGetAsyncReply , cls ) . parser ( datapath , version , <EOL> msg_type , msg_len , <EOL> xid , buf ) <EOL> msg . properties = [ ] <EOL> rest = msg . buf [ ofproto . OFP_HEADER_SIZE : ] <EOL> while rest : <EOL> p , rest = OFPAsyncConfigProp . parse ( rest ) <EOL> msg . properties . append ( p ) <EOL> return msg <EOL> @ _set_msg_type ( ofproto . OFPT_SET_ASYNC ) <EOL> class OFPSetAsync ( MsgBase ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , properties = None ) : <EOL> super ( OFPSetAsync , self ) . __init__ ( datapath ) <EOL> self . properties = properties <EOL> def _serialize_body ( self ) : <EOL> bin_props = bytearray ( ) <EOL> for p in self . properties : <EOL> bin_props += p . serialize ( ) <EOL> self . buf += bin_props <EOL> @ _set_msg_type ( ofproto . OFPT_BUNDLE_CONTROL ) <EOL> class OFPBundleCtrlMsg ( MsgBase ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , bundle_id , type_ , flags , properties ) : <EOL> super ( OFPBundleCtrlMsg , self ) . __init__ ( datapath ) <EOL> self . bundle_id = bundle_id <EOL> self . type = type_ <EOL> self . flags = flags <EOL> self . properties = properties <EOL> def _serialize_body ( self ) : <EOL> bin_props = bytearray ( ) <EOL> for p in self . properties : <EOL> bin_props += p . serialize ( ) <EOL> msg_pack_into ( ofproto . OFP_BUNDLE_CTRL_MSG_PACK_STR , <EOL> self . buf , ofproto . OFP_HEADER_SIZE , self . bundle_id , <EOL> self . type , self . flags ) <EOL> self . buf += bin_props <EOL> @ _set_msg_type ( ofproto . OFPT_BUNDLE_ADD_MESSAGE ) <EOL> class OFPBundleAddMsg ( MsgInMsgBase ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , datapath , bundle_id , flags , message , properties ) : <EOL> super ( OFPBundleAddMsg , self ) . __init__ ( datapath ) <EOL> self . bundle_id = bundle_id <EOL> self . flags = flags <EOL> self . message = message <EOL> self . properties = properties <EOL> def _serialize_body ( self ) : <EOL> if self . message . xid != self . xid : <EOL> self . message . set_xid ( self . xid ) <EOL> self . message . serialize ( ) <EOL> tail_buf = self . message . buf <EOL> if len ( self . properties ) > <NUM_LIT:0> : <EOL> message_len = len ( tail_buf ) <EOL> pad_len = utils . round_up ( message_len , <NUM_LIT:8> ) - message_len <EOL> msg_pack_into ( "<STR_LIT>" % pad_len , tail_buf , message_len ) <EOL> for p in self . properties : <EOL> tail_buf += p . serialize ( ) <EOL> msg_pack_into ( ofproto . OFP_BUNDLE_ADD_MSG_0_PACK_STR , <EOL> self . buf , ofproto . OFP_HEADER_SIZE , self . bundle_id , <EOL> self . flags ) <EOL> self . buf += tail_buf <EOL> nx_actions . generate ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' <EOL> ) </s>
