On Mon, 06 Jan 2014 17:54:21 +0900 "watanabe.fumitaka" <[email protected]> wrote:
> In bpdu.py only one version was permitted with one type, before. > This patch improves parser so that it may be based on multiple versions and > types. > > > Signed-off-by: WATANABE Fumitaka <[email protected]> > --- > ryu/lib/packet/bpdu.py | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/ryu/lib/packet/bpdu.py b/ryu/lib/packet/bpdu.py > index 8c39ec5..a98d35d 100644 > --- a/ryu/lib/packet/bpdu.py > +++ b/ryu/lib/packet/bpdu.py > @@ -171,7 +171,8 @@ class bpdu(packet_base.PacketBase): > > @staticmethod > def register_bpdu_type(sub_cls): > - bpdu._BPDU_TYPES[sub_cls.BPDU_TYPE] = sub_cls > + bpdu._BPDU_TYPES.setdefault(sub_cls.VERSION_ID, {}) > + bpdu._BPDU_TYPES[sub_cls.VERSION_ID][sub_cls.BPDU_TYPE] = sub_cls > return sub_cls > > def __init__(self): > @@ -194,14 +195,13 @@ class bpdu(packet_base.PacketBase): > bpdu_type) = struct.unpack_from(cls._PACK_STR, buf) > assert protocol_id == PROTOCOL_IDENTIFIER > > - bpdu_cls = cls._BPDU_TYPES.get(bpdu_type, None) > - > - if bpdu_cls: > - assert version_id == bpdu_cls.VERSION_ID > + if (version_id in cls._BPDU_TYPES > + and bpdu_type in cls._BPDU_TYPES[version_id]): > + bpdu_cls = cls._BPDU_TYPES[version_id][bpdu_type] > assert len(buf[cls._PACK_LEN:]) >= bpdu_cls.PACK_LEN > return bpdu_cls.parser(buf[cls._PACK_LEN:]) > else: > - # Unknown bdpu type. > + # Unknown bpdu version/type. > return buf, None, None Nicholas, looks ok to you? Thanks, ------------------------------------------------------------------------------ Rapidly troubleshoot problems before they affect your business. Most IT organizations don't have a clear picture of how application performance affects their revenue. With AppDynamics, you get 100% visibility into your Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro! http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk _______________________________________________ Ryu-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ryu-devel
