]> git.proxmox.com Git - mirror_frr.git/blob - ospf6d/ospf6_intra.h
ospfd, ospf6d: introduce the "graceful-restart hello-delay" command
[mirror_frr.git] / ospf6d / ospf6_intra.h
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * Copyright (C) 2003 Yasuhiro Ohara
4 */
5
6 #ifndef OSPF6_INTRA_H
7 #define OSPF6_INTRA_H
8
9 /* Debug option */
10 extern unsigned char conf_debug_ospf6_brouter;
11 extern in_addr_t conf_debug_ospf6_brouter_specific_router_id;
12 extern in_addr_t conf_debug_ospf6_brouter_specific_area_id;
13 #define OSPF6_DEBUG_BROUTER_SUMMARY 0x01
14 #define OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER 0x02
15 #define OSPF6_DEBUG_BROUTER_SPECIFIC_AREA 0x04
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))
57
58 /* Router-LSA */
59 #define OSPF6_ROUTER_LSA_MIN_SIZE 4U
60 struct ospf6_router_lsa {
61 uint8_t bits;
62 uint8_t options[3];
63 /* followed by ospf6_router_lsdesc(s) */
64 };
65
66 /* Link State Description in Router-LSA */
67 #define OSPF6_ROUTER_LSDESC_FIX_SIZE 16U
68 struct ospf6_router_lsdesc {
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;
74 in_addr_t neighbor_router_id;
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
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)
101
102 /* Network-LSA */
103 #define OSPF6_NETWORK_LSA_MIN_SIZE 4U
104 struct ospf6_network_lsa {
105 uint8_t reserved;
106 uint8_t options[3];
107 /* followed by ospf6_netowrk_lsd(s) */
108 };
109
110 /* Link State Description in Router-LSA */
111 #define OSPF6_NETWORK_LSDESC_FIX_SIZE 4U
112 struct ospf6_network_lsdesc {
113 in_addr_t router_id;
114 };
115 #define NETWORK_LSDESC_GET_NBR_ROUTERID(x) \
116 (((struct ospf6_network_lsdesc *)(x))->router_id)
117
118 /* Link-LSA */
119 #define OSPF6_LINK_LSA_MIN_SIZE 24U /* w/o 1st IPv6 prefix */
120 struct ospf6_link_lsa {
121 uint8_t priority;
122 uint8_t options[3];
123 struct in6_addr linklocal_addr;
124 uint32_t prefix_num;
125 /* followed by ospf6 prefix(es) */
126 };
127
128 /* Intra-Area-Prefix-LSA */
129 #define OSPF6_INTRA_PREFIX_LSA_MIN_SIZE 12U /* w/o 1st IPv6 prefix */
130 struct ospf6_intra_prefix_lsa {
131 uint16_t prefix_num;
132 uint16_t ref_type;
133 uint32_t ref_id;
134 in_addr_t ref_adv_router;
135 /* followed by ospf6 prefix(es) */
136 };
137
138
139 #define OSPF6_ROUTER_LSA_SCHEDULE(oa) \
140 do { \
141 if (CHECK_FLAG((oa)->flag, OSPF6_AREA_ENABLE)) \
142 event_add_event(master, ospf6_router_lsa_originate, \
143 oa, 0, &(oa)->thread_router_lsa); \
144 } while (0)
145 #define OSPF6_NETWORK_LSA_SCHEDULE(oi) \
146 do { \
147 if (!CHECK_FLAG((oi)->flag, OSPF6_INTERFACE_DISABLE)) \
148 event_add_event(master, ospf6_network_lsa_originate, \
149 oi, 0, &(oi)->thread_network_lsa); \
150 } while (0)
151 #define OSPF6_LINK_LSA_SCHEDULE(oi) \
152 do { \
153 if (!CHECK_FLAG((oi)->flag, OSPF6_INTERFACE_DISABLE)) \
154 event_add_event(master, ospf6_link_lsa_originate, oi, \
155 0, &(oi)->thread_link_lsa); \
156 } while (0)
157 #define OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB(oa) \
158 do { \
159 if (CHECK_FLAG((oa)->flag, OSPF6_AREA_ENABLE)) \
160 event_add_event( \
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)) \
167 event_add_event( \
168 master, \
169 ospf6_intra_prefix_lsa_originate_transit, oi, \
170 0, &(oi)->thread_intra_prefix_lsa); \
171 } while (0)
172
173 #define OSPF6_AS_EXTERN_LSA_SCHEDULE(oi) \
174 do { \
175 if (!CHECK_FLAG((oi)->flag, OSPF6_INTERFACE_DISABLE)) \
176 event_add_event(master, ospf6_orig_as_external_lsa, \
177 oi, 0, &(oi)->thread_as_extern_lsa); \
178 } while (0)
179
180 #define OSPF6_ROUTER_LSA_EXECUTE(oa) \
181 do { \
182 if (CHECK_FLAG((oa)->flag, OSPF6_AREA_ENABLE)) \
183 event_execute(master, ospf6_router_lsa_originate, oa, \
184 0); \
185 } while (0)
186
187 #define OSPF6_NETWORK_LSA_EXECUTE(oi) \
188 do { \
189 EVENT_OFF((oi)->thread_network_lsa); \
190 event_execute(master, ospf6_network_lsa_originate, oi, 0); \
191 } while (0)
192
193 #define OSPF6_LINK_LSA_EXECUTE(oi) \
194 do { \
195 if (!CHECK_FLAG((oi)->flag, OSPF6_INTERFACE_DISABLE)) \
196 event_execute(master, ospf6_link_lsa_originate, oi, \
197 0); \
198 } while (0)
199
200 #define OSPF6_INTRA_PREFIX_LSA_EXECUTE_TRANSIT(oi) \
201 do { \
202 EVENT_OFF((oi)->thread_intra_prefix_lsa); \
203 event_execute(master, \
204 ospf6_intra_prefix_lsa_originate_transit, oi, \
205 0); \
206 } while (0)
207
208 #define OSPF6_AS_EXTERN_LSA_EXECUTE(oi) \
209 do { \
210 EVENT_OFF((oi)->thread_as_extern_lsa); \
211 event_execute(master, ospf6_orig_as_external_lsa, oi, 0); \
212 } while (0)
213
214 /* Function Prototypes */
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,
218 struct ospf6_lsa *lsa);
219 extern char *ospf6_network_lsdesc_lookup(uint32_t router_id,
220 struct ospf6_lsa *lsa);
221
222 extern int ospf6_router_is_stub_router(struct ospf6_lsa *lsa);
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);
228 extern void ospf6_intra_prefix_lsa_add(struct ospf6_lsa *lsa);
229 extern void ospf6_intra_prefix_lsa_remove(struct ospf6_lsa *lsa);
230 extern void ospf6_orig_as_external_lsa(struct event *thread);
231 extern void ospf6_intra_route_calculation(struct ospf6_area *oa);
232 extern void ospf6_intra_brouter_calculation(struct ospf6_area *oa);
233 extern void ospf6_intra_prefix_route_ecmp_path(struct ospf6_area *oa,
234 struct ospf6_route *old,
235 struct ospf6_route *route);
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);
241
242 #endif /* OSPF6_LSA_H */