1 # Copyright (C) 2017 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
18 L2VPN Flow Specification support.
23 from ryu.lib.packet.bgp import FlowSpecL2VPNNLRI
24 from ryu.lib.packet.bgp import RF_L2VPN_FLOWSPEC
26 from ryu.services.protocols.bgp.info_base.vpn import VpnDest
27 from ryu.services.protocols.bgp.info_base.vpn import VpnPath
28 from ryu.services.protocols.bgp.info_base.vpn import VpnTable
30 LOG = logging.getLogger('bgpspeaker.info_base.l2vpnfs')
33 class L2VPNFlowSpecDest(VpnDest):
34 """L2VPN Flow Specification Destination
36 Store Flow Specification Paths.
38 ROUTE_FAMILY = RF_L2VPN_FLOWSPEC
41 class L2VPNFlowSpecTable(VpnTable):
42 """Global table to store L2VPN Flow Specification routing information.
44 Uses `L2VPNFlowSpecDest` to store destination information for each known
45 Flow Specification paths.
47 ROUTE_FAMILY = RF_L2VPN_FLOWSPEC
48 VPN_DEST_CLASS = L2VPNFlowSpecDest
51 class L2VPNFlowSpecPath(VpnPath):
52 """Represents a way of reaching an L2VPN Flow Specification destination."""
53 ROUTE_FAMILY = RF_L2VPN_FLOWSPEC
54 VRF_PATH_CLASS = None # defined in init - anti cyclic import hack
55 NLRI_CLASS = FlowSpecL2VPNNLRI
57 def __init__(self, *args, **kwargs):
58 # Set dummy IP address.
59 kwargs['nexthop'] = '0.0.0.0'
60 super(L2VPNFlowSpecPath, self).__init__(*args, **kwargs)
61 from ryu.services.protocols.bgp.info_base.vrfl2vpnfs import (
63 self.VRF_PATH_CLASS = L2vpnFlowSpecPath
64 # Because the L2VPN Flow Specification does not require nexthop,
65 # initialize with None.