Debian Codegraph @

networking_bagpipe/bagpipe_bgp/engine/flowspec.py

raw
1 # Copyright 2014 Orange
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 implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 from networking_bagpipe.bagpipe_bgp.engine import exa
16
17
18 @exa.NLRI.register(exa.AFI.ipv4, exa.SAFI.flow_vpn, force=True)
19 @exa.NLRI.register(exa.AFI.ipv6, exa.SAFI.flow_vpn, force=True)
20 class Flow(exa.Flow):
21 '''ExaBGP Flow wrapper
22
23 This wraps an ExaBGP Flow so that __eq__ and __hash__
24 meet the criteria for RouteTableManager (in particular,
25 not look at actions and nexthop)
26 '''
27
28 def __eq__(self, other):
29 return self.pack() == other.pack()
30
31 def __hash__(self):
32 return hash(self.pack())
33
34 def __repr__(self):
35 return str(self)
36
37
38 def FlowRouteFactory(afi, rd):
39 flow_route = Flow(afi, safi=exa.SAFI.flow_vpn)
40 flow_route.rd = rd
41 return flow_route