summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSimon Horman <horms@verge.net.au>2014-01-29 12:06:25 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2014-01-29 12:43:55 +0900
commit5752b25739af66696b0d987b1571d234df489fca (patch)
tree3db2295be841c33481d5ebda39fbf00b82de0203
parentc6bea4f0289fe12f4610a221c1bc2fdf975a9290 (diff)
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>
-rw-r--r--ryu/ofproto/ofproto_v1_4.py5
-rw-r--r--ryu/ofproto/ofproto_v1_4_parser.py91
2 files changed, 96 insertions, 0 deletions
diff --git a/ryu/ofproto/ofproto_v1_4.py b/ryu/ofproto/ofproto_v1_4.py
index 517f71a1..b5139c6d 100644
--- a/ryu/ofproto/ofproto_v1_4.py
+++ b/ryu/ofproto/ofproto_v1_4.py
@@ -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.
diff --git a/ryu/ofproto/ofproto_v1_4_parser.py b/ryu/ofproto/ofproto_v1_4_parser.py
index 3f73f8a3..6a95e380 100644
--- a/ryu/ofproto/ofproto_v1_4_parser.py
+++ b/ryu/ofproto/ofproto_v1_4_parser.py
@@ -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