1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) 2003 Yasuhiro Ohara
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)
23 #define OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_ON(router_id) \
25 conf_debug_ospf6_brouter_specific_router_id = (router_id); \
26 conf_debug_ospf6_brouter |= \
27 OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER; \
29 #define OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_OFF() \
31 conf_debug_ospf6_brouter_specific_router_id = 0; \
32 conf_debug_ospf6_brouter &= \
33 ~OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER; \
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))
41 #define OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_ON(area_id) \
43 conf_debug_ospf6_brouter_specific_area_id = (area_id); \
44 conf_debug_ospf6_brouter |= OSPF6_DEBUG_BROUTER_SPECIFIC_AREA; \
46 #define OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_OFF() \
48 conf_debug_ospf6_brouter_specific_area_id = 0; \
49 conf_debug_ospf6_brouter &= \
50 ~OSPF6_DEBUG_BROUTER_SPECIFIC_AREA; \
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))
59 #define OSPF6_ROUTER_LSA_MIN_SIZE 4U
60 struct ospf6_router_lsa
{
63 /* followed by ospf6_router_lsdesc(s) */
66 /* Link State Description in Router-LSA */
67 #define OSPF6_ROUTER_LSDESC_FIX_SIZE 16U
68 struct ospf6_router_lsdesc
{
71 uint16_t metric
; /* output cost */
72 uint32_t interface_id
;
73 uint32_t neighbor_interface_id
;
74 in_addr_t neighbor_router_id
;
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
82 enum stub_router_mode
{
83 OSPF6_NOT_STUB_ROUTER
,
85 OSPF6_IS_STUB_ROUTER_V6
,
88 #define ROUTER_LSDESC_IS_TYPE(t, x) \
89 ((((struct ospf6_router_lsdesc *)(x))->type \
90 == OSPF6_ROUTER_LSDESC_##t) \
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)
103 #define OSPF6_NETWORK_LSA_MIN_SIZE 4U
104 struct ospf6_network_lsa
{
107 /* followed by ospf6_netowrk_lsd(s) */
110 /* Link State Description in Router-LSA */
111 #define OSPF6_NETWORK_LSDESC_FIX_SIZE 4U
112 struct ospf6_network_lsdesc
{
115 #define NETWORK_LSDESC_GET_NBR_ROUTERID(x) \
116 (((struct ospf6_network_lsdesc *)(x))->router_id)
119 #define OSPF6_LINK_LSA_MIN_SIZE 24U /* w/o 1st IPv6 prefix */
120 struct ospf6_link_lsa
{
123 struct in6_addr linklocal_addr
;
125 /* followed by ospf6 prefix(es) */
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
{
134 in_addr_t ref_adv_router
;
135 /* followed by ospf6 prefix(es) */
139 #define OSPF6_ROUTER_LSA_SCHEDULE(oa) \
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); \
145 #define OSPF6_NETWORK_LSA_SCHEDULE(oi) \
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); \
151 #define OSPF6_LINK_LSA_SCHEDULE(oi) \
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); \
157 #define OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB(oa) \
159 if (CHECK_FLAG((oa)->flag, OSPF6_AREA_ENABLE)) \
161 master, ospf6_intra_prefix_lsa_originate_stub, \
162 oa, 0, &(oa)->thread_intra_prefix_lsa); \
164 #define OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT(oi) \
166 if (!CHECK_FLAG((oi)->flag, OSPF6_INTERFACE_DISABLE)) \
169 ospf6_intra_prefix_lsa_originate_transit, oi, \
170 0, &(oi)->thread_intra_prefix_lsa); \
173 #define OSPF6_AS_EXTERN_LSA_SCHEDULE(oi) \
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); \
180 #define OSPF6_ROUTER_LSA_EXECUTE(oa) \
182 if (CHECK_FLAG((oa)->flag, OSPF6_AREA_ENABLE)) \
183 event_execute(master, ospf6_router_lsa_originate, oa, \
187 #define OSPF6_NETWORK_LSA_EXECUTE(oi) \
189 EVENT_OFF((oi)->thread_network_lsa); \
190 event_execute(master, ospf6_network_lsa_originate, oi, 0); \
193 #define OSPF6_LINK_LSA_EXECUTE(oi) \
195 if (!CHECK_FLAG((oi)->flag, OSPF6_INTERFACE_DISABLE)) \
196 event_execute(master, ospf6_link_lsa_originate, oi, \
200 #define OSPF6_INTRA_PREFIX_LSA_EXECUTE_TRANSIT(oi) \
202 EVENT_OFF((oi)->thread_intra_prefix_lsa); \
203 event_execute(master, \
204 ospf6_intra_prefix_lsa_originate_transit, oi, \
208 #define OSPF6_AS_EXTERN_LSA_EXECUTE(oi) \
210 EVENT_OFF((oi)->thread_as_extern_lsa); \
211 event_execute(master, ospf6_orig_as_external_lsa, oi, 0); \
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
);
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
);
237 extern void ospf6_intra_init(void);
239 extern int config_write_ospf6_debug_brouter(struct vty
*vty
);
240 extern void install_element_ospf6_debug_brouter(void);
242 #endif /* OSPF6_LSA_H */