]>
Commit | Line | Data |
---|---|---|
718e3744 | 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 | * | |
896014f4 DL |
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 | |
718e3744 | 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 | /* OSPF Path. */ | |
d62a17ae | 37 | struct ospf_path { |
38 | struct in_addr nexthop; | |
39 | struct in_addr adv_router; | |
40 | ifindex_t ifindex; | |
41 | unsigned char unnumbered; | |
718e3744 | 42 | }; |
43 | ||
44 | /* Below is the structure linked to every | |
45 | route node. Note that for Network routing | |
46 | entries a single ospf_route is kept, while | |
47 | for ABRs and ASBRs (Router routing entries), | |
48 | we link an instance of ospf_router_route | |
49 | where a list of paths is maintained, so | |
50 | ||
51 | nr->info is a (struct ospf_route *) for OSPF_DESTINATION_NETWORK | |
52 | but | |
53 | nr->info is a (struct ospf_router_route *) for OSPF_DESTINATION_ROUTER | |
54 | */ | |
55 | ||
d62a17ae | 56 | struct route_standard { |
57 | /* Link Sate Origin. */ | |
58 | struct lsa_header *origin; | |
718e3744 | 59 | |
d62a17ae | 60 | /* Associated Area. */ |
61 | struct in_addr area_id; /* The area the route belongs to */ | |
718e3744 | 62 | |
d62a17ae | 63 | /* Area Type */ |
64 | int external_routing; | |
718e3744 | 65 | |
d62a17ae | 66 | /* Optional Capability. */ |
67 | u_char options; /* Get from LSA header. */ | |
718e3744 | 68 | |
d62a17ae | 69 | /* */ |
70 | u_char flags; /* From router-LSA */ | |
718e3744 | 71 | }; |
72 | ||
d62a17ae | 73 | struct route_external { |
74 | /* Link State Origin. */ | |
75 | struct ospf_lsa *origin; | |
718e3744 | 76 | |
d62a17ae | 77 | /* Link State Cost Type2. */ |
78 | u_int32_t type2_cost; | |
718e3744 | 79 | |
d62a17ae | 80 | /* Tag value. */ |
81 | u_int32_t tag; | |
718e3744 | 82 | |
d62a17ae | 83 | /* ASBR route. */ |
84 | struct ospf_route *asbr; | |
718e3744 | 85 | }; |
86 | ||
d62a17ae | 87 | struct ospf_route { |
88 | /* Destination Type. */ | |
89 | u_char type; | |
718e3744 | 90 | |
d62a17ae | 91 | /* Destination ID. */ /* i.e. Link State ID. */ |
92 | struct in_addr id; | |
718e3744 | 93 | |
d62a17ae | 94 | /* Address Mask. */ |
95 | struct in_addr mask; /* Only valid for networks. */ | |
718e3744 | 96 | |
d62a17ae | 97 | /* Path Type. */ |
98 | u_char path_type; | |
718e3744 | 99 | |
d62a17ae | 100 | /* List of Paths. */ |
101 | struct list *paths; | |
718e3744 | 102 | |
d62a17ae | 103 | /* Link State Cost. */ |
104 | u_int32_t cost; /* i.e. metric. */ | |
718e3744 | 105 | |
d62a17ae | 106 | /* Route specific info. */ |
107 | union { | |
108 | struct route_standard std; | |
109 | struct route_external ext; | |
110 | } u; | |
718e3744 | 111 | }; |
112 | ||
d62a17ae | 113 | extern struct ospf_path *ospf_path_new(void); |
114 | extern void ospf_path_free(struct ospf_path *); | |
115 | extern struct ospf_path *ospf_path_lookup(struct list *, struct ospf_path *); | |
116 | extern struct ospf_route *ospf_route_new(void); | |
117 | extern void ospf_route_free(struct ospf_route *); | |
b5a8894d | 118 | extern void ospf_route_delete(struct ospf *, struct route_table *); |
d62a17ae | 119 | extern void ospf_route_table_free(struct route_table *); |
4dadc291 | 120 | |
d62a17ae | 121 | extern void ospf_route_install(struct ospf *, struct route_table *); |
122 | extern void ospf_route_table_dump(struct route_table *); | |
4dadc291 | 123 | |
d62a17ae | 124 | extern void ospf_intra_add_router(struct route_table *, struct vertex *, |
125 | struct ospf_area *); | |
126 | ||
127 | extern void ospf_intra_add_transit(struct route_table *, struct vertex *, | |
4dadc291 | 128 | struct ospf_area *); |
129 | ||
d62a17ae | 130 | extern void ospf_intra_add_stub(struct route_table *, struct router_lsa_link *, |
131 | struct vertex *, struct ospf_area *, | |
132 | int parent_is_root, int); | |
133 | ||
134 | extern int ospf_route_cmp(struct ospf *, struct ospf_route *, | |
135 | struct ospf_route *); | |
136 | extern void ospf_route_copy_nexthops(struct ospf_route *, struct list *); | |
137 | extern void ospf_route_copy_nexthops_from_vertex(struct ospf_route *, | |
138 | struct vertex *); | |
139 | ||
140 | extern void ospf_route_subst(struct route_node *, struct ospf_route *, | |
141 | struct ospf_route *); | |
142 | extern void ospf_route_add(struct route_table *, struct prefix_ipv4 *, | |
143 | struct ospf_route *, struct ospf_route *); | |
144 | ||
145 | extern void ospf_route_subst_nexthops(struct ospf_route *, struct list *); | |
146 | extern void ospf_prune_unreachable_networks(struct route_table *); | |
147 | extern void ospf_prune_unreachable_routers(struct route_table *); | |
b5a8894d CS |
148 | extern int ospf_add_discard_route(struct ospf *, struct route_table *, |
149 | struct ospf_area *, struct prefix_ipv4 *); | |
150 | extern void ospf_delete_discard_route(struct ospf *, struct route_table *, | |
d62a17ae | 151 | struct prefix_ipv4 *); |
152 | extern int ospf_route_match_same(struct route_table *, struct prefix_ipv4 *, | |
153 | struct ospf_route *); | |
718e3744 | 154 | |
155 | #endif /* _ZEBRA_OSPF_ROUTE_H */ |