diff options
author | Yusuke Iwase <iwase.yusuke0@gmail.com> | 2015-08-19 10:20:09 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-08-20 18:22:11 +0900 |
commit | 7ec9537b06cba62277dfdf25b107c8f0bda5e1bd (patch) | |
tree | d7d42d0adee72c58b728aeee51159999f8b806ae | |
parent | 6cdc2720f144ccc34b37548d1b38fa63b9c5a59b (diff) |
ofproto_v1_5_parser: Enable OFPRoleRequest to set short_id
OpenFlow Spec 1.5 introduces short_id to identify controller
themselves and enables ofp_role_request to set short_id.
This patch adds short_id field into OFPRoleRequest message.
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r-- | ryu/ofproto/ofproto_v1_5_parser.py | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/ryu/ofproto/ofproto_v1_5_parser.py b/ryu/ofproto/ofproto_v1_5_parser.py index c62bf754..ba593b8e 100644 --- a/ryu/ofproto/ofproto_v1_5_parser.py +++ b/ryu/ofproto/ofproto_v1_5_parser.py @@ -6539,6 +6539,8 @@ class OFPRoleRequest(MsgBase): | OFPCR_ROLE_EQUAL | OFPCR_ROLE_MASTER | OFPCR_ROLE_SLAVE + short_id ID number for the controller. + The default is OFPCID_UNDEFINED. generation_id Master Election Generation ID ================ ====================================================== @@ -6548,20 +6550,25 @@ class OFPRoleRequest(MsgBase): ofp = datapath.ofproto ofp_parser = datapath.ofproto_parser - req = ofp_parser.OFPRoleRequest(datapath, ofp.OFPCR_ROLE_EQUAL, 0) + req = ofp_parser.OFPRoleRequest(datapath, ofp.OFPCR_ROLE_EQUAL, + ofp.OFPCID_UNDEFINED, 0) datapath.send_msg(req) """ - def __init__(self, datapath, role=None, generation_id=None): + def __init__(self, datapath, role=None, short_id=None, + generation_id=None): super(OFPRoleRequest, self).__init__(datapath) self.role = role + self.short_id = short_id self.generation_id = generation_id def _serialize_body(self): assert self.role is not None assert self.generation_id is not None + if self.short_id is None: + self.short_id = ofproto.OFPCID_UNDEFINED msg_pack_into(ofproto.OFP_ROLE_REQUEST_PACK_STR, self.buf, ofproto.OFP_HEADER_SIZE, - self.role, self.generation_id) + self.role, self.short_id, self.generation_id) @_register_parser @@ -6581,6 +6588,8 @@ class OFPRoleReply(MsgBase): | OFPCR_ROLE_EQUAL | OFPCR_ROLE_MASTER | OFPCR_ROLE_SLAVE + short_id ID number for the controller. + The default is OFPCID_UNDEFINED. generation_id Master Election Generation ID ================ ====================================================== @@ -6603,12 +6612,14 @@ class OFPRoleReply(MsgBase): role = 'unknown' self.logger.debug('OFPRoleReply received: ' - 'role=%s generation_id=%d', - role, msg.generation_id) + 'role=%s short_id=%d, generation_id=%d', + role, msg.short_id, msg.generation_id) """ - def __init__(self, datapath, role=None, generation_id=None): + def __init__(self, datapath, role=None, short_id=None, + generation_id=None): super(OFPRoleReply, self).__init__(datapath) self.role = role + self.short_id = short_id self.generation_id = generation_id @classmethod @@ -6616,7 +6627,7 @@ class OFPRoleReply(MsgBase): msg = super(OFPRoleReply, cls).parser(datapath, version, msg_type, msg_len, xid, buf) - (msg.role, msg.generation_id) = struct.unpack_from( + (msg.role, msg.short_id, msg.generation_id) = struct.unpack_from( ofproto.OFP_ROLE_REQUEST_PACK_STR, msg.buf, ofproto.OFP_HEADER_SIZE) return msg |