]>
Commit | Line | Data |
---|---|---|
acddc0ed | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
718e3744 | 2 | /* |
3 | * OSPF routing table. | |
4 | * Copyright (C) 1999, 2000 Toshiaki Takada | |
718e3744 | 5 | */ |
6 | ||
7 | #ifndef _ZEBRA_OSPF_ROUTE_H | |
8 | #define _ZEBRA_OSPF_ROUTE_H | |
9 | ||
10 | #define OSPF_DESTINATION_ROUTER 1 | |
11 | #define OSPF_DESTINATION_NETWORK 2 | |
12 | #define OSPF_DESTINATION_DISCARD 3 | |
13 | ||
14 | #define OSPF_PATH_MIN 0 | |
15 | #define OSPF_PATH_INTRA_AREA 1 | |
16 | #define OSPF_PATH_INTER_AREA 2 | |
17 | #define OSPF_PATH_TYPE1_EXTERNAL 3 | |
18 | #define OSPF_PATH_TYPE2_EXTERNAL 4 | |
19 | #define OSPF_PATH_MAX 5 | |
20 | ||
b37eb79c OD |
21 | /* Segment Routing information to complement ospf_path structure */ |
22 | struct sr_nexthop_info { | |
23 | /* Output label associated to this route */ | |
24 | mpls_label_t label_out; | |
25 | /* | |
26 | * Pointer to SR Node which is the next hop for this route | |
27 | * or NULL if next hop is the destination of the prefix | |
28 | */ | |
29 | struct sr_node *nexthop; | |
7fd0729f G |
30 | |
31 | /* TI-LFA */ | |
32 | struct mpls_label_stack *backup_label_stack; | |
33 | struct in_addr backup_nexthop; | |
b37eb79c OD |
34 | }; |
35 | ||
718e3744 | 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; | |
b37eb79c | 42 | struct sr_nexthop_info srni; |
718e3744 | 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 | ||
d62a17ae | 57 | struct route_standard { |
58 | /* Link Sate Origin. */ | |
59 | struct lsa_header *origin; | |
718e3744 | 60 | |
d62a17ae | 61 | /* Associated Area. */ |
62 | struct in_addr area_id; /* The area the route belongs to */ | |
718e3744 | 63 | |
d62a17ae | 64 | /* Area Type */ |
65 | int external_routing; | |
718e3744 | 66 | |
d62a17ae | 67 | /* Optional Capability. */ |
d7c0a89a | 68 | uint8_t options; /* Get from LSA header. */ |
718e3744 | 69 | |
d62a17ae | 70 | /* */ |
d7c0a89a | 71 | uint8_t flags; /* From router-LSA */ |
718e3744 | 72 | }; |
73 | ||
d62a17ae | 74 | struct route_external { |
75 | /* Link State Origin. */ | |
76 | struct ospf_lsa *origin; | |
718e3744 | 77 | |
d62a17ae | 78 | /* Link State Cost Type2. */ |
d7c0a89a | 79 | uint32_t type2_cost; |
718e3744 | 80 | |
d62a17ae | 81 | /* Tag value. */ |
d7c0a89a | 82 | uint32_t tag; |
718e3744 | 83 | |
d62a17ae | 84 | /* ASBR route. */ |
85 | struct ospf_route *asbr; | |
718e3744 | 86 | }; |
87 | ||
d62a17ae | 88 | struct ospf_route { |
89 | /* Destination Type. */ | |
d7c0a89a | 90 | uint8_t type; |
718e3744 | 91 | |
d62a17ae | 92 | /* Destination ID. */ /* i.e. Link State ID. */ |
93 | struct in_addr id; | |
718e3744 | 94 | |
d62a17ae | 95 | /* Address Mask. */ |
96 | struct in_addr mask; /* Only valid for networks. */ | |
718e3744 | 97 | |
d62a17ae | 98 | /* Path Type. */ |
d7c0a89a | 99 | uint8_t path_type; |
718e3744 | 100 | |
d62a17ae | 101 | /* List of Paths. */ |
102 | struct list *paths; | |
718e3744 | 103 | |
d62a17ae | 104 | /* Link State Cost. */ |
d7c0a89a | 105 | uint32_t cost; /* i.e. metric. */ |
718e3744 | 106 | |
d62a17ae | 107 | /* Route specific info. */ |
108 | union { | |
109 | struct route_standard std; | |
110 | struct route_external ext; | |
111 | } u; | |
effee187 DS |
112 | |
113 | bool changed; | |
718e3744 | 114 | }; |
115 | ||
5b5d66c4 | 116 | extern const char *ospf_path_type_name(int path_type); |
d62a17ae | 117 | extern struct ospf_path *ospf_path_new(void); |
118 | extern void ospf_path_free(struct ospf_path *); | |
119 | extern struct ospf_path *ospf_path_lookup(struct list *, struct ospf_path *); | |
120 | extern struct ospf_route *ospf_route_new(void); | |
121 | extern void ospf_route_free(struct ospf_route *); | |
b5a8894d | 122 | extern void ospf_route_delete(struct ospf *, struct route_table *); |
d62a17ae | 123 | extern void ospf_route_table_free(struct route_table *); |
4dadc291 | 124 | |
d62a17ae | 125 | extern void ospf_route_install(struct ospf *, struct route_table *); |
126 | extern void ospf_route_table_dump(struct route_table *); | |
b538baf3 | 127 | extern void ospf_router_route_table_dump(struct route_table *rt); |
4dadc291 | 128 | |
b538baf3 CH |
129 | extern void ospf_intra_add_router(struct route_table *rt, struct vertex *v, |
130 | struct ospf_area *area, bool add_all); | |
d62a17ae | 131 | |
132 | extern void ospf_intra_add_transit(struct route_table *, struct vertex *, | |
4dadc291 | 133 | struct ospf_area *); |
134 | ||
d62a17ae | 135 | extern void ospf_intra_add_stub(struct route_table *, struct router_lsa_link *, |
136 | struct vertex *, struct ospf_area *, | |
137 | int parent_is_root, int); | |
138 | ||
139 | extern int ospf_route_cmp(struct ospf *, struct ospf_route *, | |
140 | struct ospf_route *); | |
141 | extern void ospf_route_copy_nexthops(struct ospf_route *, struct list *); | |
1d376ff5 G |
142 | extern void ospf_route_copy_nexthops_from_vertex(struct ospf_area *area, |
143 | struct ospf_route *, | |
d62a17ae | 144 | struct vertex *); |
145 | ||
146 | extern void ospf_route_subst(struct route_node *, struct ospf_route *, | |
147 | struct ospf_route *); | |
148 | extern void ospf_route_add(struct route_table *, struct prefix_ipv4 *, | |
149 | struct ospf_route *, struct ospf_route *); | |
150 | ||
151 | extern void ospf_route_subst_nexthops(struct ospf_route *, struct list *); | |
152 | extern void ospf_prune_unreachable_networks(struct route_table *); | |
153 | extern void ospf_prune_unreachable_routers(struct route_table *); | |
b5a8894d | 154 | extern int ospf_add_discard_route(struct ospf *, struct route_table *, |
f07ff222 RW |
155 | struct ospf_area *, struct prefix_ipv4 *, |
156 | bool); | |
b5a8894d | 157 | extern void ospf_delete_discard_route(struct ospf *, struct route_table *, |
f07ff222 | 158 | struct prefix_ipv4 *, bool); |
d62a17ae | 159 | extern int ospf_route_match_same(struct route_table *, struct prefix_ipv4 *, |
160 | struct ospf_route *); | |
731d0769 | 161 | |
718e3744 | 162 | #endif /* _ZEBRA_OSPF_ROUTE_H */ |