]>
Commit | Line | Data |
---|---|---|
718e3744 | 1 | /* |
508e53e2 | 2 | * Copyright (C) 2003 Yasuhiro Ohara |
718e3744 | 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 | * | |
896014f4 DL |
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 | |
718e3744 | 19 | */ |
20 | ||
21 | #ifndef OSPF6_INTRA_H | |
22 | #define OSPF6_INTRA_H | |
23 | ||
cb4b8845 PJ |
24 | /* Debug option */ |
25 | extern unsigned char conf_debug_ospf6_brouter; | |
858f9c08 DL |
26 | extern in_addr_t conf_debug_ospf6_brouter_specific_router_id; |
27 | extern in_addr_t conf_debug_ospf6_brouter_specific_area_id; | |
cb4b8845 PJ |
28 | #define OSPF6_DEBUG_BROUTER_SUMMARY 0x01 |
29 | #define OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER 0x02 | |
30 | #define OSPF6_DEBUG_BROUTER_SPECIFIC_AREA 0x04 | |
d62a17ae | 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)) | |
cb4b8845 | 72 | |
508e53e2 | 73 | /* Router-LSA */ |
abc7ef44 | 74 | #define OSPF6_ROUTER_LSA_MIN_SIZE 4U |
d62a17ae | 75 | struct ospf6_router_lsa { |
d7c0a89a QY |
76 | uint8_t bits; |
77 | uint8_t options[3]; | |
d62a17ae | 78 | /* followed by ospf6_router_lsdesc(s) */ |
508e53e2 | 79 | }; |
80 | ||
81 | /* Link State Description in Router-LSA */ | |
abc7ef44 | 82 | #define OSPF6_ROUTER_LSDESC_FIX_SIZE 16U |
d62a17ae | 83 | struct ospf6_router_lsdesc { |
d7c0a89a QY |
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; | |
858f9c08 | 89 | in_addr_t neighbor_router_id; |
508e53e2 | 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 | ||
d62a17ae | 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) | |
508e53e2 | 116 | |
117 | /* Network-LSA */ | |
abc7ef44 | 118 | #define OSPF6_NETWORK_LSA_MIN_SIZE 4U |
d62a17ae | 119 | struct ospf6_network_lsa { |
d7c0a89a QY |
120 | uint8_t reserved; |
121 | uint8_t options[3]; | |
d62a17ae | 122 | /* followed by ospf6_netowrk_lsd(s) */ |
508e53e2 | 123 | }; |
124 | ||
125 | /* Link State Description in Router-LSA */ | |
abc7ef44 | 126 | #define OSPF6_NETWORK_LSDESC_FIX_SIZE 4U |
d62a17ae | 127 | struct ospf6_network_lsdesc { |
858f9c08 | 128 | in_addr_t router_id; |
508e53e2 | 129 | }; |
d62a17ae | 130 | #define NETWORK_LSDESC_GET_NBR_ROUTERID(x) \ |
131 | (((struct ospf6_network_lsdesc *)(x))->router_id) | |
508e53e2 | 132 | |
133 | /* Link-LSA */ | |
abc7ef44 | 134 | #define OSPF6_LINK_LSA_MIN_SIZE 24U /* w/o 1st IPv6 prefix */ |
d62a17ae | 135 | struct ospf6_link_lsa { |
d7c0a89a QY |
136 | uint8_t priority; |
137 | uint8_t options[3]; | |
d62a17ae | 138 | struct in6_addr linklocal_addr; |
d7c0a89a | 139 | uint32_t prefix_num; |
d62a17ae | 140 | /* followed by ospf6 prefix(es) */ |
508e53e2 | 141 | }; |
142 | ||
143 | /* Intra-Area-Prefix-LSA */ | |
abc7ef44 | 144 | #define OSPF6_INTRA_PREFIX_LSA_MIN_SIZE 12U /* w/o 1st IPv6 prefix */ |
d62a17ae | 145 | struct ospf6_intra_prefix_lsa { |
d7c0a89a QY |
146 | uint16_t prefix_num; |
147 | uint16_t ref_type; | |
148 | uint32_t ref_id; | |
858f9c08 | 149 | in_addr_t ref_adv_router; |
d62a17ae | 150 | /* followed by ospf6 prefix(es) */ |
508e53e2 | 151 | }; |
152 | ||
6b0655a2 | 153 | |
d62a17ae | 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 | ||
996c9314 | 188 | #define OSPF6_AS_EXTERN_LSA_SCHEDULE(oi) \ |
76249532 CS |
189 | do { \ |
190 | if (!CHECK_FLAG((oi)->flag, OSPF6_INTERFACE_DISABLE)) \ | |
996c9314 LB |
191 | thread_add_event(master, ospf6_orig_as_external_lsa, \ |
192 | oi, 0, &(oi)->thread_as_extern_lsa); \ | |
76249532 CS |
193 | } while (0) |
194 | ||
d62a17ae | 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) | |
76249532 | 200 | |
d62a17ae | 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) | |
6452df09 | 208 | |
76249532 CS |
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) | |
6452df09 | 214 | |
508e53e2 | 215 | /* Function Prototypes */ |
d7c0a89a QY |
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, | |
d62a17ae | 219 | struct ospf6_lsa *lsa); |
d7c0a89a | 220 | extern char *ospf6_network_lsdesc_lookup(uint32_t router_id, |
d62a17ae | 221 | struct ospf6_lsa *lsa); |
222 | ||
223 | extern int ospf6_router_is_stub_router(struct ospf6_lsa *lsa); | |
7932dd93 DS |
224 | extern int ospf6_router_lsa_originate(struct thread *thread); |
225 | extern int ospf6_network_lsa_originate(struct thread *thread); | |
226 | extern int ospf6_link_lsa_originate(struct thread *thread); | |
227 | extern int ospf6_intra_prefix_lsa_originate_transit(struct thread *thread); | |
228 | extern int ospf6_intra_prefix_lsa_originate_stub(struct thread *thread); | |
d62a17ae | 229 | extern void ospf6_intra_prefix_lsa_add(struct ospf6_lsa *lsa); |
230 | extern void ospf6_intra_prefix_lsa_remove(struct ospf6_lsa *lsa); | |
76249532 | 231 | extern int ospf6_orig_as_external_lsa(struct thread *thread); |
d62a17ae | 232 | extern void ospf6_intra_route_calculation(struct ospf6_area *oa); |
233 | extern void ospf6_intra_brouter_calculation(struct ospf6_area *oa); | |
03f3c1c1 CS |
234 | extern void ospf6_intra_prefix_route_ecmp_path(struct ospf6_area *oa, |
235 | struct ospf6_route *old, | |
236 | struct ospf6_route *route); | |
d62a17ae | 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); | |
cb4b8845 | 242 | |
508e53e2 | 243 | #endif /* OSPF6_LSA_H */ |