]> git.proxmox.com Git - mirror_frr.git/blob - zebra/zebra_rnh.h
Merge pull request #4240 from FRRouting/revert-4236-zebra_diet
[mirror_frr.git] / zebra / zebra_rnh.h
1 /*
2 * Zebra next hop tracking header
3 * Copyright (C) 2013 Cumulus Networks, Inc.
4 *
5 * This file is part of GNU Zebra.
6 *
7 * GNU Zebra is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2, or (at your option) any
10 * later version.
11 *
12 * GNU Zebra is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; see the file COPYING; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 #ifndef _ZEBRA_RNH_H
23 #define _ZEBRA_RNH_H
24
25 #include "prefix.h"
26 #include "vty.h"
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31
32 typedef enum { RNH_NEXTHOP_TYPE, RNH_IMPORT_CHECK_TYPE } rnh_type_t;
33
34 /* Nexthop structure. */
35 struct rnh {
36 uint8_t flags;
37
38 #define ZEBRA_NHT_CONNECTED 0x1
39 #define ZEBRA_NHT_DELETED 0x2
40 #define ZEBRA_NHT_EXACT_MATCH 0x4
41
42 /* VRF identifier. */
43 vrf_id_t vrf_id;
44
45 afi_t afi;
46
47 rnh_type_t type;
48
49 uint32_t seqno;
50
51 struct route_entry *state;
52 struct prefix resolved_route;
53 struct list *client_list;
54
55 /* pseudowires dependent on this nh */
56 struct list *zebra_pseudowire_list;
57
58 struct route_node *node;
59
60 /*
61 * if this has been filtered for the client
62 */
63 int filtered[ZEBRA_ROUTE_MAX];
64 };
65
66 extern int zebra_rnh_ip_default_route;
67 extern int zebra_rnh_ipv6_default_route;
68
69 extern void zebra_rnh_init(void);
70
71 static inline int rnh_resolve_via_default(int family)
72 {
73 if (((family == AF_INET) && zebra_rnh_ip_default_route)
74 || ((family == AF_INET6) && zebra_rnh_ipv6_default_route))
75 return 1;
76 else
77 return 0;
78 }
79
80 extern struct rnh *zebra_add_rnh(struct prefix *p, vrf_id_t vrfid,
81 rnh_type_t type, bool *exists);
82 extern struct rnh *zebra_lookup_rnh(struct prefix *p, vrf_id_t vrfid,
83 rnh_type_t type);
84 extern void zebra_free_rnh(struct rnh *rnh);
85 extern void zebra_add_rnh_client(struct rnh *rnh, struct zserv *client,
86 rnh_type_t type, vrf_id_t vrfid);
87 extern void zebra_register_rnh_pseudowire(vrf_id_t, struct zebra_pw *);
88 extern void zebra_deregister_rnh_pseudowire(vrf_id_t, struct zebra_pw *);
89 extern void zebra_remove_rnh_client(struct rnh *rnh, struct zserv *client,
90 rnh_type_t type);
91 extern void zebra_evaluate_rnh(struct zebra_vrf *zvrf, afi_t afi, int force,
92 rnh_type_t type, struct prefix *p);
93 extern void zebra_print_rnh_table(vrf_id_t vrfid, afi_t afi, struct vty *vty,
94 rnh_type_t type, struct prefix *p);
95 extern char *rnh_str(struct rnh *rnh, char *buf, int size);
96
97 #ifdef __cplusplus
98 }
99 #endif
100
101 #endif /*_ZEBRA_RNH_H */