Signed-off-by: Simon Horman <[email protected]>
---
 ryu/ofproto/ofproto_v1_4.py        |  5 +++
 ryu/ofproto/ofproto_v1_4_parser.py | 91 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 96 insertions(+)

diff --git a/ryu/ofproto/ofproto_v1_4.py b/ryu/ofproto/ofproto_v1_4.py
index 517f71a..b5139c6 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 3f73f8a..6a95e38 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
-- 
1.8.5.2


------------------------------------------------------------------------------
WatchGuard Dimension instantly turns raw network data into actionable 
security intelligence. It gives you real-time visual feedback on key
security issues and trends.  Skip the complicated setup - simply import
a virtual appliance and go from zero to informed in seconds.
http://pubads.g.doubleclick.net/gampad/clk?id=123612991&iu=/4140/ostg.clktrk
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to