1 # Copyright (C) 2014 Nippon Telegraph and Telephone Corporation.
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
17 Defines data types and models required specifically for RTC support.
22 from ryu.lib.packet.bgp import RF_RTC_UC
24 from ryu.services.protocols.bgp.info_base.base import Destination
25 from ryu.services.protocols.bgp.info_base.base import NonVrfPathProcessingMixin
26 from ryu.services.protocols.bgp.info_base.base import Path
27 from ryu.services.protocols.bgp.info_base.base import Table
29 LOG = logging.getLogger('bgpspeaker.info_base.rtc')
32 class RtcTable(Table):
33 """Global table to store RT membership information.
35 Uses `RtDest` to store destination information for each known RT NLRI path.
37 ROUTE_FAMILY = RF_RTC_UC
39 def __init__(self, core_service, signal_bus):
40 Table.__init__(self, None, core_service, signal_bus)
42 def _table_key(self, rtc_nlri):
43 """Return a key that will uniquely identify this RT NLRI inside
46 return str(rtc_nlri.origin_as) + ':' + rtc_nlri.route_target
48 def _create_dest(self, nlri):
49 return RtcDest(self, nlri)
52 return 'RtcTable(scope_id: %s, rf: %s)' % (self.scope_id,
56 class RtcDest(Destination, NonVrfPathProcessingMixin):
57 ROUTE_FAMILY = RF_RTC_UC
59 def _new_best_path(self, new_best_path):
60 NonVrfPathProcessingMixin._new_best_path(self, new_best_path)
62 def _best_path_lost(self):
63 NonVrfPathProcessingMixin._best_path_lost(self)
67 ROUTE_FAMILY = RF_RTC_UC
69 def __init__(self, source, nlri, src_ver_num, pattrs=None,
70 nexthop='0.0.0.0', is_withdraw=False,
71 med_set_by_target_neighbor=False):
72 Path.__init__(self, source, nlri, src_ver_num, pattrs, nexthop,
73 is_withdraw, med_set_by_target_neighbor)