]> git.proxmox.com Git - mirror_frr.git/blob - ospfd/ospf_route.h
Merge pull request #6471 from volta-networks/fix_zebra_register_rnh_pseudowire
[mirror_frr.git] / ospfd / ospf_route.h
1 /*
2 * OSPF routing table.
3 * Copyright (C) 1999, 2000 Toshiaki Takada
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_OSPF_ROUTE_H
23 #define _ZEBRA_OSPF_ROUTE_H
24
25 #define OSPF_DESTINATION_ROUTER 1
26 #define OSPF_DESTINATION_NETWORK 2
27 #define OSPF_DESTINATION_DISCARD 3
28
29 #define OSPF_PATH_MIN 0
30 #define OSPF_PATH_INTRA_AREA 1
31 #define OSPF_PATH_INTER_AREA 2
32 #define OSPF_PATH_TYPE1_EXTERNAL 3
33 #define OSPF_PATH_TYPE2_EXTERNAL 4
34 #define OSPF_PATH_MAX 5
35
36 /* Segment Routing information to complement ospf_path structure */
37 struct sr_nexthop_info {
38 /* Output label associated to this route */
39 mpls_label_t label_out;
40 /*
41 * Pointer to SR Node which is the next hop for this route
42 * or NULL if next hop is the destination of the prefix
43 */
44 struct sr_node *nexthop;
45 };
46
47 /* OSPF Path. */
48 struct ospf_path {
49 struct in_addr nexthop;
50 struct in_addr adv_router;
51 ifindex_t ifindex;
52 unsigned char unnumbered;
53 struct sr_nexthop_info srni;
54 };
55
56 /* Below is the structure linked to every
57 route node. Note that for Network routing
58 entries a single ospf_route is kept, while
59 for ABRs and ASBRs (Router routing entries),
60 we link an instance of ospf_router_route
61 where a list of paths is maintained, so
62
63 nr->info is a (struct ospf_route *) for OSPF_DESTINATION_NETWORK
64 but
65 nr->info is a (struct ospf_router_route *) for OSPF_DESTINATION_ROUTER
66 */
67
68 struct route_standard {
69 /* Link Sate Origin. */
70 struct lsa_header *origin;
71
72 /* Associated Area. */
73 struct in_addr area_id; /* The area the route belongs to */
74
75 /* Area Type */
76 int external_routing;
77
78 /* Optional Capability. */
79 uint8_t options; /* Get from LSA header. */
80
81 /* */
82 uint8_t flags; /* From router-LSA */
83 };
84
85 struct route_external {
86 /* Link State Origin. */
87 struct ospf_lsa *origin;
88
89 /* Link State Cost Type2. */
90 uint32_t type2_cost;
91
92 /* Tag value. */
93 uint32_t tag;
94
95 /* ASBR route. */
96 struct ospf_route *asbr;
97 };
98
99 struct ospf_route {
100 /* Destination Type. */
101 uint8_t type;
102
103 /* Destination ID. */ /* i.e. Link State ID. */
104 struct in_addr id;
105
106 /* Address Mask. */
107 struct in_addr mask; /* Only valid for networks. */
108
109 /* Path Type. */
110 uint8_t path_type;
111
112 /* List of Paths. */
113 struct list *paths;
114
115 /* Link State Cost. */
116 uint32_t cost; /* i.e. metric. */
117
118 /* Route specific info. */
119 union {
120 struct route_standard std;
121 struct route_external ext;
122 } u;
123 };
124
125 extern struct ospf_path *ospf_path_new(void);
126 extern void ospf_path_free(struct ospf_path *);
127 extern struct ospf_path *ospf_path_lookup(struct list *, struct ospf_path *);
128 extern struct ospf_route *ospf_route_new(void);
129 extern void ospf_route_free(struct ospf_route *);
130 extern void ospf_route_delete(struct ospf *, struct route_table *);
131 extern void ospf_route_table_free(struct route_table *);
132
133 extern void ospf_route_install(struct ospf *, struct route_table *);
134 extern void ospf_route_table_dump(struct route_table *);
135
136 extern void ospf_intra_add_router(struct route_table *, struct vertex *,
137 struct ospf_area *);
138
139 extern void ospf_intra_add_transit(struct route_table *, struct vertex *,
140 struct ospf_area *);
141
142 extern void ospf_intra_add_stub(struct route_table *, struct router_lsa_link *,
143 struct vertex *, struct ospf_area *,
144 int parent_is_root, int);
145
146 extern int ospf_route_cmp(struct ospf *, struct ospf_route *,
147 struct ospf_route *);
148 extern void ospf_route_copy_nexthops(struct ospf_route *, struct list *);
149 extern void ospf_route_copy_nexthops_from_vertex(struct ospf_route *,
150 struct vertex *);
151
152 extern void ospf_route_subst(struct route_node *, struct ospf_route *,
153 struct ospf_route *);
154 extern void ospf_route_add(struct route_table *, struct prefix_ipv4 *,
155 struct ospf_route *, struct ospf_route *);
156
157 extern void ospf_route_subst_nexthops(struct ospf_route *, struct list *);
158 extern void ospf_prune_unreachable_networks(struct route_table *);
159 extern void ospf_prune_unreachable_routers(struct route_table *);
160 extern int ospf_add_discard_route(struct ospf *, struct route_table *,
161 struct ospf_area *, struct prefix_ipv4 *);
162 extern void ospf_delete_discard_route(struct ospf *, struct route_table *,
163 struct prefix_ipv4 *);
164 extern int ospf_route_match_same(struct route_table *, struct prefix_ipv4 *,
165 struct ospf_route *);
166
167 #endif /* _ZEBRA_OSPF_ROUTE_H */