mirror of
https://github.com/faucetsdn/ryu.git
synced 2026-05-05 04:16:11 +02:00
Add OF1.4 get async request and reply support
Signed-off-by: Simon Horman <horms@verge.net.au> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
parent
c6bea4f028
commit
5752b25739
@ -1359,6 +1359,11 @@ OFP_ROLE_STATUS_SIZE = 24
|
||||
assert (calcsize(OFP_ROLE_STATUS_PACK_STR) + OFP_HEADER_SIZE ==
|
||||
OFP_ROLE_STATUS_SIZE)
|
||||
|
||||
# struct ofp_async_config
|
||||
OFP_ASYNC_CONFIG_PACK_STR = '!2I2I2I'
|
||||
OFP_ASYNC_CONFIG_SIZE = 32
|
||||
assert (calcsize(OFP_ASYNC_CONFIG_PACK_STR) + OFP_HEADER_SIZE ==
|
||||
OFP_ASYNC_CONFIG_SIZE)
|
||||
|
||||
# enum ofp_async_config_prop_type
|
||||
OFPACPT_PACKET_IN_SLAVE = 0 # Packet-in mask for slave.
|
||||
|
||||
@ -4014,3 +4014,94 @@ class OFPRoleReply(MsgBase):
|
||||
ofproto.OFP_ROLE_REQUEST_PACK_STR, msg.buf,
|
||||
ofproto.OFP_HEADER_SIZE)
|
||||
return msg
|
||||
|
||||
|
||||
@_set_msg_type(ofproto.OFPT_GET_ASYNC_REQUEST)
|
||||
class OFPGetAsyncRequest(MsgBase):
|
||||
"""
|
||||
Get asynchronous configuration request message
|
||||
|
||||
The controller uses this message to query the asynchronous message.
|
||||
|
||||
Example::
|
||||
|
||||
def send_get_async_request(self, datapath):
|
||||
ofp_parser = datapath.ofproto_parser
|
||||
|
||||
req = ofp_parser.OFPGetAsyncRequest(datapath)
|
||||
datapath.send_msg(req)
|
||||
"""
|
||||
def __init__(self, datapath):
|
||||
super(OFPGetAsyncRequest, self).__init__(datapath)
|
||||
|
||||
|
||||
@_register_parser
|
||||
@_set_msg_type(ofproto.OFPT_GET_ASYNC_REPLY)
|
||||
class OFPGetAsyncReply(MsgBase):
|
||||
"""
|
||||
Get asynchronous configuration reply message
|
||||
|
||||
The switch responds with this message to a get asynchronous configuration
|
||||
request.
|
||||
|
||||
================== ====================================================
|
||||
Attribute Description
|
||||
================== ====================================================
|
||||
packet_in_mask 2-element array: element 0, when the controller has a
|
||||
OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER role. element 1,
|
||||
OFPCR_ROLE_SLAVE role controller.
|
||||
Bitmasks of following values.
|
||||
OFPR_NO_MATCH
|
||||
OFPR_ACTION
|
||||
OFPR_INVALID_TTL
|
||||
port_status_mask 2-element array.
|
||||
Bitmasks of following values.
|
||||
OFPPR_ADD
|
||||
OFPPR_DELETE
|
||||
OFPPR_MODIFY
|
||||
flow_removed_mask 2-element array.
|
||||
Bitmasks of following values.
|
||||
OFPRR_IDLE_TIMEOUT
|
||||
OFPRR_HARD_TIMEOUT
|
||||
OFPRR_DELETE
|
||||
OFPRR_GROUP_DELETE
|
||||
================== ====================================================
|
||||
|
||||
Example::
|
||||
|
||||
@set_ev_cls(ofp_event.EventOFPGetAsyncReply, MAIN_DISPATCHER)
|
||||
def get_async_reply_handler(self, ev):
|
||||
msg = ev.msg
|
||||
|
||||
self.logger.debug('OFPGetAsyncReply received: '
|
||||
'packet_in_mask=0x%08x:0x%08x '
|
||||
'port_status_mask=0x%08x:0x%08x '
|
||||
'flow_removed_mask=0x%08x:0x%08x',
|
||||
msg.packet_in_mask[0],
|
||||
msg.packet_in_mask[1],
|
||||
msg.port_status_mask[0],
|
||||
msg.port_status_mask[1],
|
||||
msg.flow_removed_mask[0],
|
||||
msg.flow_removed_mask[1])
|
||||
"""
|
||||
def __init__(self, datapath, packet_in_mask=None, port_status_mask=None,
|
||||
flow_removed_mask=None):
|
||||
super(OFPGetAsyncReply, self).__init__(datapath)
|
||||
self.packet_in_mask = packet_in_mask
|
||||
self.port_status_mask = port_status_mask
|
||||
self.flow_removed_mask = flow_removed_mask
|
||||
|
||||
@classmethod
|
||||
def parser(cls, datapath, version, msg_type, msg_len, xid, buf):
|
||||
msg = super(OFPGetAsyncReply, cls).parser(datapath, version,
|
||||
msg_type, msg_len,
|
||||
xid, buf)
|
||||
(packet_in_mask_m, packet_in_mask_s,
|
||||
port_status_mask_m, port_status_mask_s,
|
||||
flow_removed_mask_m, flow_removed_mask_s) = struct.unpack_from(
|
||||
ofproto.OFP_ASYNC_CONFIG_PACK_STR, msg.buf,
|
||||
ofproto.OFP_HEADER_SIZE)
|
||||
msg.packet_in_mask = [packet_in_mask_m, packet_in_mask_s]
|
||||
msg.port_status_mask = [port_status_mask_m, port_status_mask_s]
|
||||
msg.flow_removed_mask = [flow_removed_mask_m, flow_removed_mask_s]
|
||||
return msg
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user