2 * Copyright (C) 2003 Yasuhiro Ohara
4 * This file is part of GNU Zebra.
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 extern unsigned char conf_debug_ospf6_brouter
;
26 extern uint32_t conf_debug_ospf6_brouter_specific_router_id
;
27 extern uint32_t conf_debug_ospf6_brouter_specific_area_id
;
28 #define OSPF6_DEBUG_BROUTER_SUMMARY 0x01
29 #define OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER 0x02
30 #define OSPF6_DEBUG_BROUTER_SPECIFIC_AREA 0x04
31 #define OSPF6_DEBUG_BROUTER_ON() \
32 (conf_debug_ospf6_brouter |= OSPF6_DEBUG_BROUTER_SUMMARY)
33 #define OSPF6_DEBUG_BROUTER_OFF() \
34 (conf_debug_ospf6_brouter &= ~OSPF6_DEBUG_BROUTER_SUMMARY)
35 #define IS_OSPF6_DEBUG_BROUTER \
36 (conf_debug_ospf6_brouter & OSPF6_DEBUG_BROUTER_SUMMARY)
38 #define OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_ON(router_id) \
40 conf_debug_ospf6_brouter_specific_router_id = (router_id); \
41 conf_debug_ospf6_brouter |= \
42 OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER; \
44 #define OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_OFF() \
46 conf_debug_ospf6_brouter_specific_router_id = 0; \
47 conf_debug_ospf6_brouter &= \
48 ~OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER; \
50 #define IS_OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER \
51 (conf_debug_ospf6_brouter & OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER)
52 #define IS_OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_ID(router_id) \
53 (IS_OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER \
54 && conf_debug_ospf6_brouter_specific_router_id == (router_id))
56 #define OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_ON(area_id) \
58 conf_debug_ospf6_brouter_specific_area_id = (area_id); \
59 conf_debug_ospf6_brouter |= OSPF6_DEBUG_BROUTER_SPECIFIC_AREA; \
61 #define OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_OFF() \
63 conf_debug_ospf6_brouter_specific_area_id = 0; \
64 conf_debug_ospf6_brouter &= \
65 ~OSPF6_DEBUG_BROUTER_SPECIFIC_AREA; \
67 #define IS_OSPF6_DEBUG_BROUTER_SPECIFIC_AREA \
68 (conf_debug_ospf6_brouter & OSPF6_DEBUG_BROUTER_SPECIFIC_AREA)
69 #define IS_OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_ID(area_id) \
70 (IS_OSPF6_DEBUG_BROUTER_SPECIFIC_AREA \
71 && conf_debug_ospf6_brouter_specific_area_id == (area_id))
74 #define OSPF6_ROUTER_LSA_MIN_SIZE 4U
75 struct ospf6_router_lsa
{
78 /* followed by ospf6_router_lsdesc(s) */
81 /* Link State Description in Router-LSA */
82 #define OSPF6_ROUTER_LSDESC_FIX_SIZE 16U
83 struct ospf6_router_lsdesc
{
86 uint16_t metric
; /* output cost */
87 uint32_t interface_id
;
88 uint32_t neighbor_interface_id
;
89 uint32_t neighbor_router_id
;
92 #define OSPF6_ROUTER_LSDESC_POINTTOPOINT 1
93 #define OSPF6_ROUTER_LSDESC_TRANSIT_NETWORK 2
94 #define OSPF6_ROUTER_LSDESC_STUB_NETWORK 3
95 #define OSPF6_ROUTER_LSDESC_VIRTUAL_LINK 4
97 enum stub_router_mode
{
98 OSPF6_NOT_STUB_ROUTER
,
100 OSPF6_IS_STUB_ROUTER_V6
,
103 #define ROUTER_LSDESC_IS_TYPE(t, x) \
104 ((((struct ospf6_router_lsdesc *)(x))->type \
105 == OSPF6_ROUTER_LSDESC_##t) \
108 #define ROUTER_LSDESC_GET_METRIC(x) \
109 (ntohs(((struct ospf6_router_lsdesc *)(x))->metric))
110 #define ROUTER_LSDESC_GET_IFID(x) \
111 (ntohl(((struct ospf6_router_lsdesc *)(x))->interface_id))
112 #define ROUTER_LSDESC_GET_NBR_IFID(x) \
113 (ntohl(((struct ospf6_router_lsdesc *)(x))->neighbor_interface_id))
114 #define ROUTER_LSDESC_GET_NBR_ROUTERID(x) \
115 (((struct ospf6_router_lsdesc *)(x))->neighbor_router_id)
118 #define OSPF6_NETWORK_LSA_MIN_SIZE 4U
119 struct ospf6_network_lsa
{
122 /* followed by ospf6_netowrk_lsd(s) */
125 /* Link State Description in Router-LSA */
126 #define OSPF6_NETWORK_LSDESC_FIX_SIZE 4U
127 struct ospf6_network_lsdesc
{
130 #define NETWORK_LSDESC_GET_NBR_ROUTERID(x) \
131 (((struct ospf6_network_lsdesc *)(x))->router_id)
134 #define OSPF6_LINK_LSA_MIN_SIZE 24U /* w/o 1st IPv6 prefix */
135 struct ospf6_link_lsa
{
138 struct in6_addr linklocal_addr
;
140 /* followed by ospf6 prefix(es) */
143 /* Intra-Area-Prefix-LSA */
144 #define OSPF6_INTRA_PREFIX_LSA_MIN_SIZE 12U /* w/o 1st IPv6 prefix */
145 struct ospf6_intra_prefix_lsa
{
149 uint32_t ref_adv_router
;
150 /* followed by ospf6 prefix(es) */
154 #define OSPF6_ROUTER_LSA_SCHEDULE(oa) \
156 if (CHECK_FLAG((oa)->flag, OSPF6_AREA_ENABLE)) \
157 thread_add_event(master, ospf6_router_lsa_originate, \
158 oa, 0, &(oa)->thread_router_lsa); \
160 #define OSPF6_NETWORK_LSA_SCHEDULE(oi) \
162 if (!CHECK_FLAG((oi)->flag, OSPF6_INTERFACE_DISABLE)) \
163 thread_add_event(master, ospf6_network_lsa_originate, \
164 oi, 0, &(oi)->thread_network_lsa); \
166 #define OSPF6_LINK_LSA_SCHEDULE(oi) \
168 if (!CHECK_FLAG((oi)->flag, OSPF6_INTERFACE_DISABLE)) \
169 thread_add_event(master, ospf6_link_lsa_originate, oi, \
170 0, &(oi)->thread_link_lsa); \
172 #define OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB(oa) \
174 if (CHECK_FLAG((oa)->flag, OSPF6_AREA_ENABLE)) \
176 master, ospf6_intra_prefix_lsa_originate_stub, \
177 oa, 0, &(oa)->thread_intra_prefix_lsa); \
179 #define OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT(oi) \
181 if (!CHECK_FLAG((oi)->flag, OSPF6_INTERFACE_DISABLE)) \
184 ospf6_intra_prefix_lsa_originate_transit, oi, \
185 0, &(oi)->thread_intra_prefix_lsa); \
188 #define OSPF6_AS_EXTERN_LSA_SCHEDULE(oi) \
190 if (!CHECK_FLAG((oi)->flag, OSPF6_INTERFACE_DISABLE)) \
191 thread_add_event(master, ospf6_orig_as_external_lsa, \
192 oi, 0, &(oi)->thread_as_extern_lsa); \
195 #define OSPF6_NETWORK_LSA_EXECUTE(oi) \
197 THREAD_OFF((oi)->thread_network_lsa); \
198 thread_execute(master, ospf6_network_lsa_originate, oi, 0); \
201 #define OSPF6_INTRA_PREFIX_LSA_EXECUTE_TRANSIT(oi) \
203 THREAD_OFF((oi)->thread_intra_prefix_lsa); \
204 thread_execute(master, \
205 ospf6_intra_prefix_lsa_originate_transit, oi, \
209 #define OSPF6_AS_EXTERN_LSA_EXECUTE(oi) \
211 THREAD_OFF((oi)->thread_as_extern_lsa); \
212 thread_execute(master, ospf6_orig_as_external_lsa, oi, 0); \
215 /* Function Prototypes */
216 extern char *ospf6_router_lsdesc_lookup(uint8_t type
, uint32_t interface_id
,
217 uint32_t neighbor_interface_id
,
218 uint32_t neighbor_router_id
,
219 struct ospf6_lsa
*lsa
);
220 extern char *ospf6_network_lsdesc_lookup(uint32_t router_id
,
221 struct ospf6_lsa
*lsa
);
223 extern int ospf6_router_is_stub_router(struct ospf6_lsa
*lsa
);
224 extern int ospf6_router_lsa_originate(struct thread
*);
225 extern int ospf6_network_lsa_originate(struct thread
*);
226 extern int ospf6_link_lsa_originate(struct thread
*);
227 extern int ospf6_intra_prefix_lsa_originate_transit(struct thread
*);
228 extern int ospf6_intra_prefix_lsa_originate_stub(struct thread
*);
229 extern void ospf6_intra_prefix_lsa_add(struct ospf6_lsa
*lsa
);
230 extern void ospf6_intra_prefix_lsa_remove(struct ospf6_lsa
*lsa
);
231 extern int ospf6_orig_as_external_lsa(struct thread
*thread
);
232 extern void ospf6_intra_route_calculation(struct ospf6_area
*oa
);
233 extern void ospf6_intra_brouter_calculation(struct ospf6_area
*oa
);
234 extern void ospf6_intra_prefix_route_ecmp_path(struct ospf6_area
*oa
,
235 struct ospf6_route
*old
,
236 struct ospf6_route
*route
);
238 extern void ospf6_intra_init(void);
240 extern int config_write_ospf6_debug_brouter(struct vty
*vty
);
241 extern void install_element_ospf6_debug_brouter(void);
243 #endif /* OSPF6_LSA_H */