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 VPNv4 Flow Specification support.
23 from ryu.lib.packet.bgp import FlowSpecVPNv4NLRI
24 from ryu.lib.packet.bgp import RF_VPNv4_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.vpnv4fs')
33 class VPNv4FlowSpecDest(VpnDest):
34 """VPNv4 Flow Specification Destination
36 Store Flow Specification Paths.
38 ROUTE_FAMILY = RF_VPNv4_FLOWSPEC
41 class VPNv4FlowSpecTable(VpnTable):
42 """Global table to store VPNv4 Flow Specification routing information.
44 Uses `VPNv4FlowSpecDest` to store destination information for each known
45 Flow Specification paths.
47 ROUTE_FAMILY = RF_VPNv4_FLOWSPEC
48 VPN_DEST_CLASS = VPNv4FlowSpecDest
51 class VPNv4FlowSpecPath(VpnPath):
52 """Represents a way of reaching an VPNv4 Flow Specification destination."""
53 ROUTE_FAMILY = RF_VPNv4_FLOWSPEC
54 VRF_PATH_CLASS = None # defined in init - anti cyclic import hack
55 NLRI_CLASS = FlowSpecVPNv4NLRI
57 def __init__(self, *args, **kwargs):
58 # Set dummy IP address.
59 kwargs['nexthop'] = '0.0.0.0'
60 super(VPNv4FlowSpecPath, self).__init__(*args, **kwargs)
61 from ryu.services.protocols.bgp.info_base.vrf4fs import (
63 self.VRF_PATH_CLASS = Vrf4FlowSpecPath
64 # Because the IPv4 Flow Specification does not require nexthop,
65 # initialize with None.