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>
This commit is contained in:
parent
4c119f9abe
commit
0742b5b19f
@ -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 + \
|
||||
|
@ -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):
|
||||
"""
|
||||
|
Loading…
x
Reference in New Issue
Block a user