backing up
[vsorcdistro/.git] / ryu / build / lib.linux-armv7l-2.7 / ryu / services / protocols / bgp / info_base / vpnv4fs.py
1 # Copyright (C) 2017 Nippon Telegraph and Telephone Corporation.
2 #
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
6 #
7 #    http://www.apache.org/licenses/LICENSE-2.0
8 #
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
12 # implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 """
17  Defines data types and models required specifically for
18  VPNv4 Flow Specification support.
19 """
20
21 import logging
22
23 from ryu.lib.packet.bgp import FlowSpecVPNv4NLRI
24 from ryu.lib.packet.bgp import RF_VPNv4_FLOWSPEC
25
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
29
30 LOG = logging.getLogger('bgpspeaker.info_base.vpnv4fs')
31
32
33 class VPNv4FlowSpecDest(VpnDest):
34     """VPNv4 Flow Specification Destination
35
36     Store Flow Specification Paths.
37     """
38     ROUTE_FAMILY = RF_VPNv4_FLOWSPEC
39
40
41 class VPNv4FlowSpecTable(VpnTable):
42     """Global table to store VPNv4 Flow Specification routing information.
43
44     Uses `VPNv4FlowSpecDest` to store destination information for each known
45     Flow Specification paths.
46     """
47     ROUTE_FAMILY = RF_VPNv4_FLOWSPEC
48     VPN_DEST_CLASS = VPNv4FlowSpecDest
49
50
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
56
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 (
62             Vrf4FlowSpecPath)
63         self.VRF_PATH_CLASS = Vrf4FlowSpecPath
64         # Because the IPv4 Flow Specification does not require nexthop,
65         # initialize with None.
66         self._nexthop = None