diff --git a/ryu/lib/packet/bgp.py b/ryu/lib/packet/bgp.py index 8d8f2410..1f8d539b 100644 --- a/ryu/lib/packet/bgp.py +++ b/ryu/lib/packet/bgp.py @@ -1,5 +1,5 @@ -# Copyright (C) 2013 Nippon Telegraph and Telephone Corporation. -# Copyright (C) 2013 YAMAMOTO Takashi +# Copyright (C) 2013,2014 Nippon Telegraph and Telephone Corporation. +# Copyright (C) 2013,2014 YAMAMOTO Takashi # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -56,6 +56,7 @@ BGP_OPT_CAPABILITY = 2 # RFC 5492 BGP_CAP_MULTIPROTOCOL = 1 # RFC 4760 BGP_CAP_ROUTE_REFRESH = 2 # RFC 2918 +BGP_CAP_CARRYING_LABEL_INFO = 4 # RFC 3107 BGP_CAP_FOUR_OCTET_AS_NUMBER = 65 # RFC 4893 BGP_CAP_ENHANCED_ROUTE_REFRESH = 70 # https://tools.ietf.org/html/\ # draft-ietf-idr-bgp-enhanced-route-refresh-05 @@ -317,6 +318,15 @@ class _OptParamCapability(_OptParam, _TypeDisp): return buf + cap_value +class _OptParamEmptyCapability(_OptParamCapability): + @classmethod + def parse_cap_value(cls, buf): + return {} + + def serialize_cap_value(self): + return bytearray() + + @_OptParamCapability.register_unknown_type() class BGPOptParamCapabilityUnknown(_OptParamCapability): @classmethod @@ -328,13 +338,8 @@ class BGPOptParamCapabilityUnknown(_OptParamCapability): @_OptParamCapability.register_type(BGP_CAP_ROUTE_REFRESH) -class BGPOptParamCapabilityRouteRefresh(_OptParamCapability): - @classmethod - def parse_cap_value(cls, buf): - return {} - - def serialize_cap_value(self): - return bytearray() +class BGPOptParamCapabilityRouteRefresh(_OptParamEmptyCapability): + pass @_OptParamCapability.register_type(BGP_CAP_FOUR_OCTET_AS_NUMBER) @@ -386,6 +391,11 @@ class BGPOptParamCapabilityMultiprotocol(_OptParamCapability): return buf +@_OptParamCapability.register_type(BGP_CAP_CARRYING_LABEL_INFO) +class BGPOptParamCapabilityCarryingLabelInfo(_OptParamEmptyCapability): + pass + + class BGPWithdrawnRoute(_IPAddrPrefix): pass diff --git a/ryu/tests/unit/packet/test_bgp.py b/ryu/tests/unit/packet/test_bgp.py index 1652ad30..0f2975d1 100644 --- a/ryu/tests/unit/packet/test_bgp.py +++ b/ryu/tests/unit/packet/test_bgp.py @@ -1,5 +1,5 @@ -# Copyright (C) 2013 Nippon Telegraph and Telephone Corporation. -# Copyright (C) 2013 YAMAMOTO Takashi +# Copyright (C) 2013,2014 Nippon Telegraph and Telephone Corporation. +# Copyright (C) 2013,2014 YAMAMOTO Takashi # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -47,6 +47,7 @@ class Test_bgp(unittest.TestCase): bgp.BGPOptParamCapabilityRouteRefresh(), bgp.BGPOptParamCapabilityMultiprotocol( afi=afi.IP, safi=safi.MPLS_VPN), + bgp.BGPOptParamCapabilityCarryingLabelInfo(), bgp.BGPOptParamCapabilityFourOctetAsNumber( as_number=1234567), bgp.BGPOptParamUnknown(type_=99, value='fuga')]