summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSimon Horman <horms@verge.net.au>2014-03-11 10:42:04 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2014-03-16 21:42:21 +0900
commit5ae836b7131bee49b56280c81642126b861e42de (patch)
treedddf1d321a21d722fa1c10d771e44eef8f15fd68
parent2316f5e03b9178d2902c892e26e6ae5dea7e49e8 (diff)
of14: Add table status 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.py6
-rw-r--r--ryu/ofproto/ofproto_v1_4_parser.py55
2 files changed, 60 insertions, 1 deletions
diff --git a/ryu/ofproto/ofproto_v1_4.py b/ryu/ofproto/ofproto_v1_4.py
index 5f83e074..200e9b09 100644
--- a/ryu/ofproto/ofproto_v1_4.py
+++ b/ryu/ofproto/ofproto_v1_4.py
@@ -1414,7 +1414,11 @@ OFPTR_VACANCY_DOWN = 3 # Vacancy down threshold event.
OFPTR_VACANCY_UP = 4 # Vacancy up threshold event.
# struct ofp_table_status
-OFP_TABLE_STATUS_PACK_STR = '!B7x' + _OFP_TABLE_DESC_PACK_STR
+_OFP_TABLE_STATUS_0_PACK_STR = 'B7x'
+OFP_TABLE_STATUS_0_PACK_STR = '!' + _OFP_TABLE_STATUS_0_PACK_STR
+OFP_TABLE_STATUS_0_SIZE = 16
+OFP_TABLE_STATUS_PACK_STR = (OFP_TABLE_STATUS_0_PACK_STR +
+ _OFP_TABLE_DESC_PACK_STR)
OFP_TABLE_STATUS_SIZE = 24
assert (calcsize(OFP_TABLE_STATUS_PACK_STR) + OFP_HEADER_SIZE ==
OFP_TABLE_STATUS_SIZE)
diff --git a/ryu/ofproto/ofproto_v1_4_parser.py b/ryu/ofproto/ofproto_v1_4_parser.py
index f3b0aee8..74a6e33a 100644
--- a/ryu/ofproto/ofproto_v1_4_parser.py
+++ b/ryu/ofproto/ofproto_v1_4_parser.py
@@ -4416,6 +4416,61 @@ class OFPRoleStatus(MsgBase):
return msg
+@_register_parser
+@_set_msg_type(ofproto.OFPT_TABLE_STATUS)
+class OFPTableStatus(MsgBase):
+ """
+ Table status message
+
+ The switch notifies controller of change of table status.
+
+ ================ ======================================================
+ Attribute Description
+ ================ ======================================================
+ reason One of the following values.
+ OFPTR_VACANCY_DOWN
+ OFPTR_VACANCY_UP
+ table ``OFPTableDesc`` instance
+ ================ ======================================================
+
+ Example::
+
+ @set_ev_cls(ofp_event.EventOFPTableStatus, MAIN_DISPATCHER)
+ def table(self, ev):
+ msg = ev.msg
+ dp = msg.datapath
+ ofp = dp.ofproto
+
+ if msg.reason == ofp.OFPTR_VACANCY_DOWN:
+ reason = 'VACANCY_DOWN'
+ elif msg.reason == ofp.OFPTR_VACANCY_UP:
+ reason = 'VACANCY_UP'
+ else:
+ reason = 'unknown'
+
+ self.logger.debug('OFPTableStatus received: reason=%s '
+ 'table_id=%d config=0x%08x properties=%s',
+ reason, msg.table.table_id, msg.table.config,
+ repr(msg.table.properties))
+ """
+ def __init__(self, datapath, reason=None, table=None):
+ super(OFPTableStatus, self).__init__(datapath)
+ self.reason = reason
+ self.table = table
+
+ @classmethod
+ def parser(cls, datapath, version, msg_type, msg_len, xid, buf):
+ msg = super(OFPTableStatus, cls).parser(datapath, version, msg_type,
+ msg_len, xid, buf)
+ (msg.reason,) = struct.unpack_from(ofproto.OFP_TABLE_STATUS_0_PACK_STR,
+ msg.buf, ofproto.OFP_HEADER_SIZE)
+
+ msg.table = OFPTableDesc.parser(msg.buf,
+ ofproto.OFP_TABLE_STATUS_0_SIZE)
+
+ return msg
+
+
@_set_msg_type(ofproto.OFPT_PACKET_OUT)
class OFPPacketOut(MsgBase):
"""