]>
Commit | Line | Data |
---|---|---|
acddc0ed | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
718e3744 | 2 | /* |
508e53e2 | 3 | * Copyright (C) 2003 Yasuhiro Ohara |
718e3744 | 4 | */ |
5 | ||
6 | #ifndef OSPF6_INTRA_H | |
7 | #define OSPF6_INTRA_H | |
8 | ||
cb4b8845 PJ |
9 | /* Debug option */ |
10 | extern unsigned char conf_debug_ospf6_brouter; | |
858f9c08 DL |
11 | extern in_addr_t conf_debug_ospf6_brouter_specific_router_id; |
12 | extern in_addr_t conf_debug_ospf6_brouter_specific_area_id; | |
cb4b8845 PJ |
13 | #define OSPF6_DEBUG_BROUTER_SUMMARY 0x01 |
14 | #define OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER 0x02 | |
15 | #define OSPF6_DEBUG_BROUTER_SPECIFIC_AREA 0x04 | |
d62a17ae | 16 | #define OSPF6_DEBUG_BROUTER_ON() \ |
17 | (conf_debug_ospf6_brouter |= OSPF6_DEBUG_BROUTER_SUMMARY) | |
18 | #define OSPF6_DEBUG_BROUTER_OFF() \ | |
19 | (conf_debug_ospf6_brouter &= ~OSPF6_DEBUG_BROUTER_SUMMARY) | |
20 | #define IS_OSPF6_DEBUG_BROUTER \ | |
21 | (conf_debug_ospf6_brouter & OSPF6_DEBUG_BROUTER_SUMMARY) | |
22 | ||
23 | #define OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_ON(router_id) \ | |
24 | do { \ | |
25 | conf_debug_ospf6_brouter_specific_router_id = (router_id); \ | |
26 | conf_debug_ospf6_brouter |= \ | |
27 | OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER; \ | |
28 | } while (0) | |
29 | #define OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_OFF() \ | |
30 | do { \ | |
31 | conf_debug_ospf6_brouter_specific_router_id = 0; \ | |
32 | conf_debug_ospf6_brouter &= \ | |
33 | ~OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER; \ | |
34 | } while (0) | |
35 | #define IS_OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER \ | |
36 | (conf_debug_ospf6_brouter & OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER) | |
37 | #define IS_OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_ID(router_id) \ | |
38 | (IS_OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER \ | |
39 | && conf_debug_ospf6_brouter_specific_router_id == (router_id)) | |
40 | ||
41 | #define OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_ON(area_id) \ | |
42 | do { \ | |
43 | conf_debug_ospf6_brouter_specific_area_id = (area_id); \ | |
44 | conf_debug_ospf6_brouter |= OSPF6_DEBUG_BROUTER_SPECIFIC_AREA; \ | |
45 | } while (0) | |
46 | #define OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_OFF() \ | |
47 | do { \ | |
48 | conf_debug_ospf6_brouter_specific_area_id = 0; \ | |
49 | conf_debug_ospf6_brouter &= \ | |
50 | ~OSPF6_DEBUG_BROUTER_SPECIFIC_AREA; \ | |
51 | } while (0) | |
52 | #define IS_OSPF6_DEBUG_BROUTER_SPECIFIC_AREA \ | |
53 | (conf_debug_ospf6_brouter & OSPF6_DEBUG_BROUTER_SPECIFIC_AREA) | |
54 | #define IS_OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_ID(area_id) \ | |
55 | (IS_OSPF6_DEBUG_BROUTER_SPECIFIC_AREA \ | |
56 | && conf_debug_ospf6_brouter_specific_area_id == (area_id)) | |
cb4b8845 | 57 | |
508e53e2 | 58 | /* Router-LSA */ |
abc7ef44 | 59 | #define OSPF6_ROUTER_LSA_MIN_SIZE 4U |
d62a17ae | 60 | struct ospf6_router_lsa { |
d7c0a89a QY |
61 | uint8_t bits; |
62 | uint8_t options[3]; | |
d62a17ae | 63 | /* followed by ospf6_router_lsdesc(s) */ |
508e53e2 | 64 | }; |
65 | ||
66 | /* Link State Description in Router-LSA */ | |
abc7ef44 | 67 | #define OSPF6_ROUTER_LSDESC_FIX_SIZE 16U |
d62a17ae | 68 | struct ospf6_router_lsdesc { |
d7c0a89a QY |
69 | uint8_t type; |
70 | uint8_t reserved; | |
71 | uint16_t metric; /* output cost */ | |
72 | uint32_t interface_id; | |
73 | uint32_t neighbor_interface_id; | |
858f9c08 | 74 | in_addr_t neighbor_router_id; |
508e53e2 | 75 | }; |
76 | ||
77 | #define OSPF6_ROUTER_LSDESC_POINTTOPOINT 1 | |
78 | #define OSPF6_ROUTER_LSDESC_TRANSIT_NETWORK 2 | |
79 | #define OSPF6_ROUTER_LSDESC_STUB_NETWORK 3 | |
80 | #define OSPF6_ROUTER_LSDESC_VIRTUAL_LINK 4 | |
81 | ||
d62a17ae | 82 | enum stub_router_mode { |
83 | OSPF6_NOT_STUB_ROUTER, | |
84 | OSPF6_IS_STUB_ROUTER, | |
85 | OSPF6_IS_STUB_ROUTER_V6, | |
86 | }; | |
87 | ||
88 | #define ROUTER_LSDESC_IS_TYPE(t, x) \ | |
89 | ((((struct ospf6_router_lsdesc *)(x))->type \ | |
90 | == OSPF6_ROUTER_LSDESC_##t) \ | |
91 | ? 1 \ | |
92 | : 0) | |
93 | #define ROUTER_LSDESC_GET_METRIC(x) \ | |
94 | (ntohs(((struct ospf6_router_lsdesc *)(x))->metric)) | |
95 | #define ROUTER_LSDESC_GET_IFID(x) \ | |
96 | (ntohl(((struct ospf6_router_lsdesc *)(x))->interface_id)) | |
97 | #define ROUTER_LSDESC_GET_NBR_IFID(x) \ | |
98 | (ntohl(((struct ospf6_router_lsdesc *)(x))->neighbor_interface_id)) | |
99 | #define ROUTER_LSDESC_GET_NBR_ROUTERID(x) \ | |
100 | (((struct ospf6_router_lsdesc *)(x))->neighbor_router_id) | |
508e53e2 | 101 | |
102 | /* Network-LSA */ | |
abc7ef44 | 103 | #define OSPF6_NETWORK_LSA_MIN_SIZE 4U |
d62a17ae | 104 | struct ospf6_network_lsa { |
d7c0a89a QY |
105 | uint8_t reserved; |
106 | uint8_t options[3]; | |
d62a17ae | 107 | /* followed by ospf6_netowrk_lsd(s) */ |
508e53e2 | 108 | }; |
109 | ||
110 | /* Link State Description in Router-LSA */ | |
abc7ef44 | 111 | #define OSPF6_NETWORK_LSDESC_FIX_SIZE 4U |
d62a17ae | 112 | struct ospf6_network_lsdesc { |
858f9c08 | 113 | in_addr_t router_id; |
508e53e2 | 114 | }; |
d62a17ae | 115 | #define NETWORK_LSDESC_GET_NBR_ROUTERID(x) \ |
116 | (((struct ospf6_network_lsdesc *)(x))->router_id) | |
508e53e2 | 117 | |
118 | /* Link-LSA */ | |
abc7ef44 | 119 | #define OSPF6_LINK_LSA_MIN_SIZE 24U /* w/o 1st IPv6 prefix */ |
d62a17ae | 120 | struct ospf6_link_lsa { |
d7c0a89a QY |
121 | uint8_t priority; |
122 | uint8_t options[3]; | |
d62a17ae | 123 | struct in6_addr linklocal_addr; |
d7c0a89a | 124 | uint32_t prefix_num; |
d62a17ae | 125 | /* followed by ospf6 prefix(es) */ |
508e53e2 | 126 | }; |
127 | ||
128 | /* Intra-Area-Prefix-LSA */ | |
abc7ef44 | 129 | #define OSPF6_INTRA_PREFIX_LSA_MIN_SIZE 12U /* w/o 1st IPv6 prefix */ |
d62a17ae | 130 | struct ospf6_intra_prefix_lsa { |
d7c0a89a QY |
131 | uint16_t prefix_num; |
132 | uint16_t ref_type; | |
133 | uint32_t ref_id; | |
858f9c08 | 134 | in_addr_t ref_adv_router; |
d62a17ae | 135 | /* followed by ospf6 prefix(es) */ |
508e53e2 | 136 | }; |
137 | ||
6b0655a2 | 138 | |
d62a17ae | 139 | #define OSPF6_ROUTER_LSA_SCHEDULE(oa) \ |
140 | do { \ | |
141 | if (CHECK_FLAG((oa)->flag, OSPF6_AREA_ENABLE)) \ | |
907a2395 DS |
142 | event_add_event(master, ospf6_router_lsa_originate, \ |
143 | oa, 0, &(oa)->thread_router_lsa); \ | |
d62a17ae | 144 | } while (0) |
145 | #define OSPF6_NETWORK_LSA_SCHEDULE(oi) \ | |
146 | do { \ | |
147 | if (!CHECK_FLAG((oi)->flag, OSPF6_INTERFACE_DISABLE)) \ | |
907a2395 DS |
148 | event_add_event(master, ospf6_network_lsa_originate, \ |
149 | oi, 0, &(oi)->thread_network_lsa); \ | |
d62a17ae | 150 | } while (0) |
151 | #define OSPF6_LINK_LSA_SCHEDULE(oi) \ | |
152 | do { \ | |
153 | if (!CHECK_FLAG((oi)->flag, OSPF6_INTERFACE_DISABLE)) \ | |
907a2395 DS |
154 | event_add_event(master, ospf6_link_lsa_originate, oi, \ |
155 | 0, &(oi)->thread_link_lsa); \ | |
d62a17ae | 156 | } while (0) |
157 | #define OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB(oa) \ | |
158 | do { \ | |
159 | if (CHECK_FLAG((oa)->flag, OSPF6_AREA_ENABLE)) \ | |
907a2395 | 160 | event_add_event( \ |
d62a17ae | 161 | master, ospf6_intra_prefix_lsa_originate_stub, \ |
162 | oa, 0, &(oa)->thread_intra_prefix_lsa); \ | |
163 | } while (0) | |
164 | #define OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT(oi) \ | |
165 | do { \ | |
166 | if (!CHECK_FLAG((oi)->flag, OSPF6_INTERFACE_DISABLE)) \ | |
907a2395 | 167 | event_add_event( \ |
d62a17ae | 168 | master, \ |
169 | ospf6_intra_prefix_lsa_originate_transit, oi, \ | |
170 | 0, &(oi)->thread_intra_prefix_lsa); \ | |
171 | } while (0) | |
172 | ||
996c9314 | 173 | #define OSPF6_AS_EXTERN_LSA_SCHEDULE(oi) \ |
76249532 CS |
174 | do { \ |
175 | if (!CHECK_FLAG((oi)->flag, OSPF6_INTERFACE_DISABLE)) \ | |
907a2395 DS |
176 | event_add_event(master, ospf6_orig_as_external_lsa, \ |
177 | oi, 0, &(oi)->thread_as_extern_lsa); \ | |
76249532 CS |
178 | } while (0) |
179 | ||
71165098 RW |
180 | #define OSPF6_ROUTER_LSA_EXECUTE(oa) \ |
181 | do { \ | |
182 | if (CHECK_FLAG((oa)->flag, OSPF6_AREA_ENABLE)) \ | |
8c1186d3 DS |
183 | event_execute(master, ospf6_router_lsa_originate, oa, \ |
184 | 0); \ | |
71165098 RW |
185 | } while (0) |
186 | ||
d62a17ae | 187 | #define OSPF6_NETWORK_LSA_EXECUTE(oi) \ |
188 | do { \ | |
e16d030c | 189 | EVENT_OFF((oi)->thread_network_lsa); \ |
8c1186d3 | 190 | event_execute(master, ospf6_network_lsa_originate, oi, 0); \ |
d62a17ae | 191 | } while (0) |
76249532 | 192 | |
71165098 RW |
193 | #define OSPF6_LINK_LSA_EXECUTE(oi) \ |
194 | do { \ | |
195 | if (!CHECK_FLAG((oi)->flag, OSPF6_INTERFACE_DISABLE)) \ | |
8c1186d3 DS |
196 | event_execute(master, ospf6_link_lsa_originate, oi, \ |
197 | 0); \ | |
71165098 RW |
198 | } while (0) |
199 | ||
d62a17ae | 200 | #define OSPF6_INTRA_PREFIX_LSA_EXECUTE_TRANSIT(oi) \ |
201 | do { \ | |
e16d030c | 202 | EVENT_OFF((oi)->thread_intra_prefix_lsa); \ |
8c1186d3 DS |
203 | event_execute(master, \ |
204 | ospf6_intra_prefix_lsa_originate_transit, oi, \ | |
205 | 0); \ | |
d62a17ae | 206 | } while (0) |
6452df09 | 207 | |
76249532 CS |
208 | #define OSPF6_AS_EXTERN_LSA_EXECUTE(oi) \ |
209 | do { \ | |
e16d030c | 210 | EVENT_OFF((oi)->thread_as_extern_lsa); \ |
8c1186d3 | 211 | event_execute(master, ospf6_orig_as_external_lsa, oi, 0); \ |
76249532 | 212 | } while (0) |
6452df09 | 213 | |
508e53e2 | 214 | /* Function Prototypes */ |
d7c0a89a QY |
215 | extern char *ospf6_router_lsdesc_lookup(uint8_t type, uint32_t interface_id, |
216 | uint32_t neighbor_interface_id, | |
217 | uint32_t neighbor_router_id, | |
d62a17ae | 218 | struct ospf6_lsa *lsa); |
d7c0a89a | 219 | extern char *ospf6_network_lsdesc_lookup(uint32_t router_id, |
d62a17ae | 220 | struct ospf6_lsa *lsa); |
221 | ||
222 | extern int ospf6_router_is_stub_router(struct ospf6_lsa *lsa); | |
e6685141 DS |
223 | extern void ospf6_router_lsa_originate(struct event *thread); |
224 | extern void ospf6_network_lsa_originate(struct event *thread); | |
225 | extern void ospf6_link_lsa_originate(struct event *thread); | |
226 | extern void ospf6_intra_prefix_lsa_originate_transit(struct event *thread); | |
227 | extern void ospf6_intra_prefix_lsa_originate_stub(struct event *thread); | |
d62a17ae | 228 | extern void ospf6_intra_prefix_lsa_add(struct ospf6_lsa *lsa); |
229 | extern void ospf6_intra_prefix_lsa_remove(struct ospf6_lsa *lsa); | |
e6685141 | 230 | extern void ospf6_orig_as_external_lsa(struct event *thread); |
d62a17ae | 231 | extern void ospf6_intra_route_calculation(struct ospf6_area *oa); |
232 | extern void ospf6_intra_brouter_calculation(struct ospf6_area *oa); | |
03f3c1c1 CS |
233 | extern void ospf6_intra_prefix_route_ecmp_path(struct ospf6_area *oa, |
234 | struct ospf6_route *old, | |
235 | struct ospf6_route *route); | |
d62a17ae | 236 | |
237 | extern void ospf6_intra_init(void); | |
238 | ||
239 | extern int config_write_ospf6_debug_brouter(struct vty *vty); | |
240 | extern void install_element_ospf6_debug_brouter(void); | |
cb4b8845 | 241 | |
508e53e2 | 242 | #endif /* OSPF6_LSA_H */ |