summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSimon Horman <horms@verge.net.au>2014-02-04 13:27:56 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2014-02-04 18:41:50 +0900
commit0742b5b19f91d3931b5451743993f61373cd5810 (patch)
treeeaac02c2df970d28f06ef65c3c53711469b3a666
parent4c119f9abe64501b87bc5433fe8858492bcde71c (diff)
of14: Add port status message 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.py7
-rw-r--r--ryu/ofproto/ofproto_v1_4_parser.py54
2 files changed, 61 insertions, 0 deletions
diff --git a/ryu/ofproto/ofproto_v1_4.py b/ryu/ofproto/ofproto_v1_4.py
index b5139c6d..c9316cea 100644
--- a/ryu/ofproto/ofproto_v1_4.py
+++ b/ryu/ofproto/ofproto_v1_4.py
@@ -604,6 +604,13 @@ OFPRR_GROUP_DELETE = 3 # Group was removed.
OFPRR_METER_DELETE = 4 # Meter was removed.
OFPRR_EVICTION = 5 # Switch eviction to free resources.
+# struct ofp_port_status
+OFP_PORT_STATUS_PACK_STR = '!B7x' + _OFP_PORT_PACK_STR
+OFP_PORT_STATUS_DESC_OFFSET = OFP_HEADER_SIZE + 8
+OFP_PORT_STATUS_SIZE = 56
+assert (calcsize(OFP_PORT_STATUS_PACK_STR) + OFP_HEADER_SIZE ==
+ OFP_PORT_STATUS_SIZE)
+
# struct ofp_flow_removed
_OFP_FLOW_REMOVED_PACK_STR0 = 'QHBBIIHHQQ'
OFP_FLOW_REMOVED_PACK_STR = '!' + _OFP_FLOW_REMOVED_PACK_STR0 + \
diff --git a/ryu/ofproto/ofproto_v1_4_parser.py b/ryu/ofproto/ofproto_v1_4_parser.py
index 5c289a89..fbc5f1c9 100644
--- a/ryu/ofproto/ofproto_v1_4_parser.py
+++ b/ryu/ofproto/ofproto_v1_4_parser.py
@@ -3382,6 +3382,60 @@ class OFPBarrierReply(MsgBase):
super(OFPBarrierReply, self).__init__(datapath)
+@_register_parser
+@_set_msg_type(ofproto.OFPT_PORT_STATUS)
+class OFPPortStatus(MsgBase):
+ """
+ Port status message
+
+ The switch notifies controller of change of ports.
+
+ ================ ======================================================
+ Attribute Description
+ ================ ======================================================
+ reason One of the following values.
+ OFPPR_ADD
+ OFPPR_DELETE
+ OFPPR_MODIFY
+ desc instance of ``OFPPort``
+ ================ ======================================================
+
+ Example::
+
+ @set_ev_cls(ofp_event.EventOFPPortStatus, MAIN_DISPATCHER)
+ def port_status_handler(self, ev):
+ msg = ev.msg
+ dp = msg.datapath
+ ofp = dp.ofproto
+
+ if msg.reason == ofp.OFPPR_ADD:
+ reason = 'ADD'
+ elif msg.reason == ofp.OFPPR_DELETE:
+ reason = 'DELETE'
+ elif msg.reason == ofp.OFPPR_MODIFY:
+ reason = 'MODIFY'
+ else:
+ reason = 'unknown'
+
+ self.logger.debug('OFPPortStatus received: reason=%s desc=%s',
+ reason, msg.desc)
+ """
+ def __init__(self, datapath, reason=None, desc=None):
+ super(OFPPortStatus, self).__init__(datapath)
+ self.reason = reason
+ self.desc = desc
+
+ @classmethod
+ def parser(cls, datapath, version, msg_type, msg_len, xid, buf):
+ msg = super(OFPPortStatus, cls).parser(datapath, version, msg_type,
+ msg_len, xid, buf)
+ msg.reason = struct.unpack_from(
+ ofproto.OFP_PORT_STATUS_PACK_STR, msg.buf,
+ ofproto.OFP_HEADER_SIZE)[0]
+ msg.desc = OFPPort.parser(msg.buf, ofproto.OFP_PORT_STATUS_DESC_OFFSET)
+ return msg
+
+
@_set_msg_type(ofproto.OFPT_PACKET_OUT)
class OFPPacketOut(MsgBase):
"""