]> git.proxmox.com Git - mirror_frr.git/blob - ospfd/ospf_route.h
release: FRR 3.0-rc1
[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
18 * along with GNU Zebra; see the file COPYING. If not, write to the Free
19 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20 * 02111-1307, USA.
21 */
22
23 #ifndef _ZEBRA_OSPF_ROUTE_H
24 #define _ZEBRA_OSPF_ROUTE_H
25
26 #define OSPF_DESTINATION_ROUTER 1
27 #define OSPF_DESTINATION_NETWORK 2
28 #define OSPF_DESTINATION_DISCARD 3
29
30 #define OSPF_PATH_MIN 0
31 #define OSPF_PATH_INTRA_AREA 1
32 #define OSPF_PATH_INTER_AREA 2
33 #define OSPF_PATH_TYPE1_EXTERNAL 3
34 #define OSPF_PATH_TYPE2_EXTERNAL 4
35 #define OSPF_PATH_MAX 5
36
37 /* OSPF Path. */
38 struct ospf_path {
39 struct in_addr nexthop;
40 struct in_addr adv_router;
41 ifindex_t ifindex;
42 unsigned char unnumbered;
43 };
44
45 /* Below is the structure linked to every
46 route node. Note that for Network routing
47 entries a single ospf_route is kept, while
48 for ABRs and ASBRs (Router routing entries),
49 we link an instance of ospf_router_route
50 where a list of paths is maintained, so
51
52 nr->info is a (struct ospf_route *) for OSPF_DESTINATION_NETWORK
53 but
54 nr->info is a (struct ospf_router_route *) for OSPF_DESTINATION_ROUTER
55 */
56
57 struct route_standard {
58 /* Link Sate Origin. */
59 struct lsa_header *origin;
60
61 /* Associated Area. */
62 struct in_addr area_id; /* The area the route belongs to */
63
64 /* Area Type */
65 int external_routing;
66
67 /* Optional Capability. */
68 u_char options; /* Get from LSA header. */
69
70 /* */
71 u_char flags; /* From router-LSA */
72 };
73
74 struct route_external {
75 /* Link State Origin. */
76 struct ospf_lsa *origin;
77
78 /* Link State Cost Type2. */
79 u_int32_t type2_cost;
80
81 /* Tag value. */
82 u_int32_t tag;
83
84 /* ASBR route. */
85 struct ospf_route *asbr;
86 };
87
88 struct ospf_route {
89 /* Destination Type. */
90 u_char type;
91
92 /* Destination ID. */ /* i.e. Link State ID. */
93 struct in_addr id;
94
95 /* Address Mask. */
96 struct in_addr mask; /* Only valid for networks. */
97
98 /* Path Type. */
99 u_char path_type;
100
101 /* List of Paths. */
102 struct list *paths;
103
104 /* Link State Cost. */
105 u_int32_t cost; /* i.e. metric. */
106
107 /* Route specific info. */
108 union {
109 struct route_standard std;
110 struct route_external ext;
111 } u;
112 };
113
114 extern struct ospf_path *ospf_path_new(void);
115 extern void ospf_path_free(struct ospf_path *);
116 extern struct ospf_path *ospf_path_lookup(struct list *, struct ospf_path *);
117 extern struct ospf_route *ospf_route_new(void);
118 extern void ospf_route_free(struct ospf_route *);
119 extern void ospf_route_delete(struct route_table *);
120 extern void ospf_route_table_free(struct route_table *);
121
122 extern void ospf_route_install(struct ospf *, struct route_table *);
123 extern void ospf_route_table_dump(struct route_table *);
124
125 extern void ospf_intra_add_router(struct route_table *, struct vertex *,
126 struct ospf_area *);
127
128 extern void ospf_intra_add_transit(struct route_table *, struct vertex *,
129 struct ospf_area *);
130
131 extern void ospf_intra_add_stub(struct route_table *, struct router_lsa_link *,
132 struct vertex *, struct ospf_area *,
133 int parent_is_root, int);
134
135 extern int ospf_route_cmp(struct ospf *, struct ospf_route *,
136 struct ospf_route *);
137 extern void ospf_route_copy_nexthops(struct ospf_route *, struct list *);
138 extern void ospf_route_copy_nexthops_from_vertex(struct ospf_route *,
139 struct vertex *);
140
141 extern void ospf_route_subst(struct route_node *, struct ospf_route *,
142 struct ospf_route *);
143 extern void ospf_route_add(struct route_table *, struct prefix_ipv4 *,
144 struct ospf_route *, struct ospf_route *);
145
146 extern void ospf_route_subst_nexthops(struct ospf_route *, struct list *);
147 extern void ospf_prune_unreachable_networks(struct route_table *);
148 extern void ospf_prune_unreachable_routers(struct route_table *);
149 extern int ospf_add_discard_route(struct route_table *, struct ospf_area *,
150 struct prefix_ipv4 *);
151 extern void ospf_delete_discard_route(struct route_table *,
152 struct prefix_ipv4 *);
153 extern int ospf_route_match_same(struct route_table *, struct prefix_ipv4 *,
154 struct ospf_route *);
155
156 #endif /* _ZEBRA_OSPF_ROUTE_H */