]> git.proxmox.com Git - mirror_frr.git/blob - ospf6d/ospf6_intra.h
zebra: Move sin6_masklen to earlier in the file
[mirror_frr.git] / ospf6d / ospf6_intra.h
1 /*
2 * Copyright (C) 2003 Yasuhiro Ohara
3 *
4 * This file is part of GNU Zebra.
5 *
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
9 * later version.
10 *
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.
15 *
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
19 */
20
21 #ifndef OSPF6_INTRA_H
22 #define OSPF6_INTRA_H
23
24 /* Debug option */
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)
37
38 #define OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_ON(router_id) \
39 do { \
40 conf_debug_ospf6_brouter_specific_router_id = (router_id); \
41 conf_debug_ospf6_brouter |= \
42 OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER; \
43 } while (0)
44 #define OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_OFF() \
45 do { \
46 conf_debug_ospf6_brouter_specific_router_id = 0; \
47 conf_debug_ospf6_brouter &= \
48 ~OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER; \
49 } while (0)
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))
55
56 #define OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_ON(area_id) \
57 do { \
58 conf_debug_ospf6_brouter_specific_area_id = (area_id); \
59 conf_debug_ospf6_brouter |= OSPF6_DEBUG_BROUTER_SPECIFIC_AREA; \
60 } while (0)
61 #define OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_OFF() \
62 do { \
63 conf_debug_ospf6_brouter_specific_area_id = 0; \
64 conf_debug_ospf6_brouter &= \
65 ~OSPF6_DEBUG_BROUTER_SPECIFIC_AREA; \
66 } while (0)
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))
72
73 /* Router-LSA */
74 #define OSPF6_ROUTER_LSA_MIN_SIZE 4U
75 struct ospf6_router_lsa {
76 uint8_t bits;
77 uint8_t options[3];
78 /* followed by ospf6_router_lsdesc(s) */
79 };
80
81 /* Link State Description in Router-LSA */
82 #define OSPF6_ROUTER_LSDESC_FIX_SIZE 16U
83 struct ospf6_router_lsdesc {
84 uint8_t type;
85 uint8_t reserved;
86 uint16_t metric; /* output cost */
87 uint32_t interface_id;
88 uint32_t neighbor_interface_id;
89 uint32_t neighbor_router_id;
90 };
91
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
96
97 enum stub_router_mode {
98 OSPF6_NOT_STUB_ROUTER,
99 OSPF6_IS_STUB_ROUTER,
100 OSPF6_IS_STUB_ROUTER_V6,
101 };
102
103 #define ROUTER_LSDESC_IS_TYPE(t, x) \
104 ((((struct ospf6_router_lsdesc *)(x))->type \
105 == OSPF6_ROUTER_LSDESC_##t) \
106 ? 1 \
107 : 0)
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)
116
117 /* Network-LSA */
118 #define OSPF6_NETWORK_LSA_MIN_SIZE 4U
119 struct ospf6_network_lsa {
120 uint8_t reserved;
121 uint8_t options[3];
122 /* followed by ospf6_netowrk_lsd(s) */
123 };
124
125 /* Link State Description in Router-LSA */
126 #define OSPF6_NETWORK_LSDESC_FIX_SIZE 4U
127 struct ospf6_network_lsdesc {
128 uint32_t router_id;
129 };
130 #define NETWORK_LSDESC_GET_NBR_ROUTERID(x) \
131 (((struct ospf6_network_lsdesc *)(x))->router_id)
132
133 /* Link-LSA */
134 #define OSPF6_LINK_LSA_MIN_SIZE 24U /* w/o 1st IPv6 prefix */
135 struct ospf6_link_lsa {
136 uint8_t priority;
137 uint8_t options[3];
138 struct in6_addr linklocal_addr;
139 uint32_t prefix_num;
140 /* followed by ospf6 prefix(es) */
141 };
142
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 {
146 uint16_t prefix_num;
147 uint16_t ref_type;
148 uint32_t ref_id;
149 uint32_t ref_adv_router;
150 /* followed by ospf6 prefix(es) */
151 };
152
153
154 #define OSPF6_ROUTER_LSA_SCHEDULE(oa) \
155 do { \
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); \
159 } while (0)
160 #define OSPF6_NETWORK_LSA_SCHEDULE(oi) \
161 do { \
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); \
165 } while (0)
166 #define OSPF6_LINK_LSA_SCHEDULE(oi) \
167 do { \
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); \
171 } while (0)
172 #define OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB(oa) \
173 do { \
174 if (CHECK_FLAG((oa)->flag, OSPF6_AREA_ENABLE)) \
175 thread_add_event( \
176 master, ospf6_intra_prefix_lsa_originate_stub, \
177 oa, 0, &(oa)->thread_intra_prefix_lsa); \
178 } while (0)
179 #define OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT(oi) \
180 do { \
181 if (!CHECK_FLAG((oi)->flag, OSPF6_INTERFACE_DISABLE)) \
182 thread_add_event( \
183 master, \
184 ospf6_intra_prefix_lsa_originate_transit, oi, \
185 0, &(oi)->thread_intra_prefix_lsa); \
186 } while (0)
187
188 #define OSPF6_AS_EXTERN_LSA_SCHEDULE(oi) \
189 do { \
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); \
193 } while (0)
194
195 #define OSPF6_NETWORK_LSA_EXECUTE(oi) \
196 do { \
197 THREAD_OFF((oi)->thread_network_lsa); \
198 thread_execute(master, ospf6_network_lsa_originate, oi, 0); \
199 } while (0)
200
201 #define OSPF6_INTRA_PREFIX_LSA_EXECUTE_TRANSIT(oi) \
202 do { \
203 THREAD_OFF((oi)->thread_intra_prefix_lsa); \
204 thread_execute(master, \
205 ospf6_intra_prefix_lsa_originate_transit, oi, \
206 0); \
207 } while (0)
208
209 #define OSPF6_AS_EXTERN_LSA_EXECUTE(oi) \
210 do { \
211 THREAD_OFF((oi)->thread_as_extern_lsa); \
212 thread_execute(master, ospf6_orig_as_external_lsa, oi, 0); \
213 } while (0)
214
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);
222
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);
237
238 extern void ospf6_intra_init(void);
239
240 extern int config_write_ospf6_debug_brouter(struct vty *vty);
241 extern void install_element_ospf6_debug_brouter(void);
242
243 #endif /* OSPF6_LSA_H */