]> git.proxmox.com Git - mirror_frr.git/blame - babeld/route.h
Merge pull request #5793 from ton31337/fix/formatting_show_bgp_summary_failed
[mirror_frr.git] / babeld / route.h
CommitLineData
ca10883e
DS
1/*
2Copyright (c) 2007, 2008 by Juliusz Chroboczek
3Copyright 2011 by Matthieu Boutier and Juliusz Chroboczek
4
5Permission is hereby granted, free of charge, to any person obtaining a copy
6of this software and associated documentation files (the "Software"), to deal
7in the Software without restriction, including without limitation the rights
8to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9copies of the Software, and to permit persons to whom the Software is
10furnished to do so, subject to the following conditions:
11
12The above copyright notice and this permission notice shall be included in
13all copies or substantial portions of the Software.
14
15THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21THE SOFTWARE.
22*/
23
24#ifndef BABEL_ROUTE_H
25#define BABEL_ROUTE_H
26
27#include "babel_interface.h"
28#include "source.h"
29
e33b116c
DS
30enum babel_diversity {
31 DIVERSITY_NONE,
32 DIVERSITY_INTERFACE_1,
33 DIVERSITY_CHANNEL_1,
34 DIVERSITY_CHANNEL,
35};
ca10883e
DS
36
37#define DIVERSITY_HOPS 8
38
39struct babel_route {
40 struct source *src;
41 unsigned short refmetric;
42 unsigned short cost;
43 unsigned short add_metric;
44 unsigned short seqno;
45 struct neighbour *neigh;
46 unsigned char nexthop[16];
47 time_t time;
48 unsigned short hold_time; /* in seconds */
49 unsigned short smoothed_metric; /* for route selection */
50 time_t smoothed_metric_time;
51 short installed;
52 unsigned char channels[DIVERSITY_HOPS];
53 struct babel_route *next;
54};
55
56struct route_stream;
57
58extern struct babel_route **routes;
59extern int kernel_metric;
e33b116c
DS
60extern enum babel_diversity diversity_kind;
61extern int diversity_factor;
ca10883e
DS
62extern int keep_unfeasible;
63extern int smoothing_half_life;
64
65static inline int
66route_metric(const struct babel_route *route)
67{
68 int m = (int)route->refmetric + route->cost + route->add_metric;
69 return MIN(m, INFINITY);
70}
71
72static inline int
73route_metric_noninterfering(const struct babel_route *route)
74{
75 int m =
76 (int)route->refmetric +
77 (diversity_factor * route->cost + 128) / 256 +
78 route->add_metric;
79 m = MAX(m, route->refmetric + 1);
80 return MIN(m, INFINITY);
81}
82
83struct babel_route *find_route(const unsigned char *prefix, unsigned char plen,
84 struct neighbour *neigh, const unsigned char *nexthop);
85struct babel_route *find_installed_route(const unsigned char *prefix,
86 unsigned char plen);
87int installed_routes_estimate(void);
88void flush_route(struct babel_route *route);
89void flush_all_routes(void);
90void flush_neighbour_routes(struct neighbour *neigh);
91void flush_interface_routes(struct interface *ifp, int v4only);
92struct route_stream *route_stream(int installed);
93struct babel_route *route_stream_next(struct route_stream *stream);
94void route_stream_done(struct route_stream *stream);
95void install_route(struct babel_route *route);
96void uninstall_route(struct babel_route *route);
97int route_feasible(struct babel_route *route);
98int route_old(struct babel_route *route);
99int route_expired(struct babel_route *route);
100int route_interferes(struct babel_route *route, struct interface *ifp);
101int update_feasible(struct source *src,
102 unsigned short seqno, unsigned short refmetric);
103void change_smoothing_half_life(int half_life);
104int route_smoothed_metric(struct babel_route *route);
105struct babel_route *find_best_route(const unsigned char *prefix, unsigned char plen,
106 int feasible, struct neighbour *exclude);
107struct babel_route *install_best_route(const unsigned char prefix[16],
108 unsigned char plen);
109void update_neighbour_metric(struct neighbour *neigh, int change);
110void update_interface_metric(struct interface *ifp);
111void update_route_metric(struct babel_route *route);
112struct babel_route *update_route(const unsigned char *id,
113 const unsigned char *prefix, unsigned char plen,
114 unsigned short seqno, unsigned short refmetric,
115 unsigned short interval, struct neighbour *neigh,
116 const unsigned char *nexthop,
117 const unsigned char *channels, int channels_len);
118void retract_neighbour_routes(struct neighbour *neigh);
119void send_unfeasible_request(struct neighbour *neigh, int force,
120 unsigned short seqno, unsigned short metric,
121 struct source *src);
122void send_triggered_update(struct babel_route *route,
123 struct source *oldsrc, unsigned oldmetric);
124void route_changed(struct babel_route *route,
125 struct source *oldsrc, unsigned short oldmetric);
126void route_lost(struct source *src, unsigned oldmetric);
127void expire_routes(void);
128
129#endif