diff options
author | Yusuke Iwase <iwase.yusuke0@gmail.com> | 2015-07-22 14:15:03 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-07-22 19:01:01 +0900 |
commit | 8a638c088f53bb506c863fa56034b61e48bf8d2a (patch) | |
tree | 188cf61c994e3b857be59508544ce2c771a8a483 | |
parent | 142e180b941b0804a0366e8e6331a44f18c3f291 (diff) |
ofproto_v1_5_parser: Add OFPPortDescPropRecirculate class
This class is parser class for OFPPDPT_RECIRCULATE type
in Port Description Properties.
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 | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/ryu/ofproto/ofproto_v1_5_parser.py b/ryu/ofproto/ofproto_v1_5_parser.py index 966c5766..07b1ae09 100644 --- a/ryu/ofproto/ofproto_v1_5_parser.py +++ b/ryu/ofproto/ofproto_v1_5_parser.py @@ -1134,6 +1134,33 @@ class OFPPortDescPropOxm(OFPPortDescProp): return bin_ids +@OFPPortDescProp.register_type(ofproto.OFPPDPT_RECIRCULATE) +class OFPPortDescPropRecirculate(OFPPortDescProp): + _PORT_NO_PACK_STR = '!I' + + def __init__(self, type_=None, length=None, port_nos=[]): + super(OFPPortDescPropRecirculate, self).__init__(type_, length) + self.port_nos = port_nos + + @classmethod + def parser(cls, buf): + rest = cls.get_rest(buf) + nos = [] + while rest: + (n,) = struct.unpack_from(cls._PORT_NO_PACK_STR, buffer(rest), 0) + rest = rest[struct.calcsize(cls._PORT_NO_PACK_STR):] + nos.append(n) + return cls(port_nos=nos) + + def serialize_body(self): + bin_nos = bytearray() + for n in self.port_nos: + bin_no = bytearray() + msg_pack_into(self._PORT_NO_PACK_STR, bin_no, 0, n) + bin_nos += bin_no + return bin_nos + + @OFPPortDescProp.register_type(ofproto.OFPPDPT_EXPERIMENTER) class OFPPortDescPropExperimenter(OFPPropCommonExperimenter4ByteData): pass |