summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYAMAMOTO Takashi <yamamoto@valinux.co.jp>2014-01-15 12:01:16 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2014-01-15 19:54:58 +0900
commit4209fc01709a829927ba9a863870aa1276a9d2ee (patch)
tree7f82a73e45339c44c47598c7caf850bc693da490
parent93215e4b222350c994d008a2584ddec8118786aa (diff)
bgp: implement BGPOptParamCapabilityCarryingLabelInfo
Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--ryu/lib/packet/bgp.py28
-rw-r--r--ryu/tests/unit/packet/test_bgp.py5
2 files changed, 22 insertions, 11 deletions
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 <yamamoto at valinux co jp>
+# Copyright (C) 2013,2014 Nippon Telegraph and Telephone Corporation.
+# Copyright (C) 2013,2014 YAMAMOTO Takashi <yamamoto at valinux co jp>
#
# 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 <yamamoto at valinux co jp>
+# Copyright (C) 2013,2014 Nippon Telegraph and Telephone Corporation.
+# Copyright (C) 2013,2014 YAMAMOTO Takashi <yamamoto at valinux co jp>
#
# 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')]