]>
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; | |
26 | extern u_int32_t conf_debug_ospf6_brouter_specific_router_id; | |
27 | extern u_int32_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 |= OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER; \ | |
42 | } while (0) | |
43 | #define OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_OFF() \ | |
44 | do { \ | |
45 | conf_debug_ospf6_brouter_specific_router_id = 0; \ | |
46 | conf_debug_ospf6_brouter &= ~OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER; \ | |
47 | } while (0) | |
48 | #define IS_OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER \ | |
49 | (conf_debug_ospf6_brouter & OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER) | |
50 | #define IS_OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_ID(router_id) \ | |
51 | (IS_OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER && \ | |
52 | conf_debug_ospf6_brouter_specific_router_id == (router_id)) | |
53 | ||
54 | #define OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_ON(area_id) \ | |
55 | do { \ | |
56 | conf_debug_ospf6_brouter_specific_area_id = (area_id); \ | |
57 | conf_debug_ospf6_brouter |= OSPF6_DEBUG_BROUTER_SPECIFIC_AREA; \ | |
58 | } while (0) | |
59 | #define OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_OFF() \ | |
60 | do { \ | |
61 | conf_debug_ospf6_brouter_specific_area_id = 0; \ | |
62 | conf_debug_ospf6_brouter &= ~OSPF6_DEBUG_BROUTER_SPECIFIC_AREA; \ | |
63 | } while (0) | |
64 | #define IS_OSPF6_DEBUG_BROUTER_SPECIFIC_AREA \ | |
65 | (conf_debug_ospf6_brouter & OSPF6_DEBUG_BROUTER_SPECIFIC_AREA) | |
66 | #define IS_OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_ID(area_id) \ | |
67 | (IS_OSPF6_DEBUG_BROUTER_SPECIFIC_AREA && \ | |
68 | conf_debug_ospf6_brouter_specific_area_id == (area_id)) | |
69 | ||
508e53e2 | 70 | /* Router-LSA */ |
abc7ef44 | 71 | #define OSPF6_ROUTER_LSA_MIN_SIZE 4U |
508e53e2 | 72 | struct ospf6_router_lsa |
73 | { | |
74 | u_char bits; | |
75 | u_char options[3]; | |
76 | /* followed by ospf6_router_lsdesc(s) */ | |
77 | }; | |
78 | ||
79 | /* Link State Description in Router-LSA */ | |
abc7ef44 | 80 | #define OSPF6_ROUTER_LSDESC_FIX_SIZE 16U |
508e53e2 | 81 | struct ospf6_router_lsdesc |
82 | { | |
83 | u_char type; | |
84 | u_char reserved; | |
85 | u_int16_t metric; /* output cost */ | |
86 | u_int32_t interface_id; | |
87 | u_int32_t neighbor_interface_id; | |
88 | u_int32_t neighbor_router_id; | |
89 | }; | |
90 | ||
91 | #define OSPF6_ROUTER_LSDESC_POINTTOPOINT 1 | |
92 | #define OSPF6_ROUTER_LSDESC_TRANSIT_NETWORK 2 | |
93 | #define OSPF6_ROUTER_LSDESC_STUB_NETWORK 3 | |
94 | #define OSPF6_ROUTER_LSDESC_VIRTUAL_LINK 4 | |
95 | ||
f41b4a02 DD |
96 | enum stub_router_mode |
97 | { | |
98 | OSPF6_NOT_STUB_ROUTER, | |
99 | OSPF6_IS_STUB_ROUTER, | |
100 | OSPF6_IS_STUB_ROUTER_V6, | |
101 | }; | |
102 | ||
508e53e2 | 103 | #define ROUTER_LSDESC_IS_TYPE(t,x) \ |
104 | ((((struct ospf6_router_lsdesc *)(x))->type == \ | |
105 | OSPF6_ROUTER_LSDESC_ ## t) ? 1 : 0) | |
106 | #define ROUTER_LSDESC_GET_METRIC(x) \ | |
107 | (ntohs (((struct ospf6_router_lsdesc *)(x))->metric)) | |
108 | #define ROUTER_LSDESC_GET_IFID(x) \ | |
109 | (ntohl (((struct ospf6_router_lsdesc *)(x))->interface_id)) | |
110 | #define ROUTER_LSDESC_GET_NBR_IFID(x) \ | |
111 | (ntohl (((struct ospf6_router_lsdesc *)(x))->neighbor_interface_id)) | |
112 | #define ROUTER_LSDESC_GET_NBR_ROUTERID(x) \ | |
113 | (((struct ospf6_router_lsdesc *)(x))->neighbor_router_id) | |
114 | ||
115 | /* Network-LSA */ | |
abc7ef44 | 116 | #define OSPF6_NETWORK_LSA_MIN_SIZE 4U |
508e53e2 | 117 | struct ospf6_network_lsa |
118 | { | |
119 | u_char reserved; | |
120 | u_char options[3]; | |
121 | /* followed by ospf6_netowrk_lsd(s) */ | |
122 | }; | |
123 | ||
124 | /* Link State Description in Router-LSA */ | |
abc7ef44 | 125 | #define OSPF6_NETWORK_LSDESC_FIX_SIZE 4U |
508e53e2 | 126 | struct ospf6_network_lsdesc |
127 | { | |
128 | u_int32_t router_id; | |
129 | }; | |
130 | #define NETWORK_LSDESC_GET_NBR_ROUTERID(x) \ | |
131 | (((struct ospf6_network_lsdesc *)(x))->router_id) | |
132 | ||
133 | /* Link-LSA */ | |
abc7ef44 | 134 | #define OSPF6_LINK_LSA_MIN_SIZE 24U /* w/o 1st IPv6 prefix */ |
508e53e2 | 135 | struct ospf6_link_lsa |
136 | { | |
137 | u_char priority; | |
138 | u_char options[3]; | |
139 | struct in6_addr linklocal_addr; | |
140 | u_int32_t prefix_num; | |
141 | /* followed by ospf6 prefix(es) */ | |
142 | }; | |
143 | ||
144 | /* Intra-Area-Prefix-LSA */ | |
abc7ef44 | 145 | #define OSPF6_INTRA_PREFIX_LSA_MIN_SIZE 12U /* w/o 1st IPv6 prefix */ |
508e53e2 | 146 | struct ospf6_intra_prefix_lsa |
147 | { | |
148 | u_int16_t prefix_num; | |
149 | u_int16_t ref_type; | |
150 | u_int32_t ref_id; | |
151 | u_int32_t ref_adv_router; | |
152 | /* followed by ospf6 prefix(es) */ | |
153 | }; | |
154 | ||
6b0655a2 | 155 | |
508e53e2 | 156 | #define OSPF6_ROUTER_LSA_SCHEDULE(oa) \ |
157 | do { \ | |
ffa2c898 QY |
158 | if (CHECK_FLAG((oa)->flag, OSPF6_AREA_ENABLE)) \ |
159 | thread_add_event (master, ospf6_router_lsa_originate, oa, 0, &(oa)->thread_router_lsa); \ | |
508e53e2 | 160 | } while (0) |
161 | #define OSPF6_NETWORK_LSA_SCHEDULE(oi) \ | |
162 | do { \ | |
ffa2c898 QY |
163 | if (!CHECK_FLAG((oi)->flag, OSPF6_INTERFACE_DISABLE)) \ |
164 | thread_add_event (master, ospf6_network_lsa_originate, oi, 0, &(oi)->thread_network_lsa); \ | |
508e53e2 | 165 | } while (0) |
166 | #define OSPF6_LINK_LSA_SCHEDULE(oi) \ | |
167 | do { \ | |
ffa2c898 QY |
168 | if (!CHECK_FLAG((oi)->flag, OSPF6_INTERFACE_DISABLE)) \ |
169 | thread_add_event (master, ospf6_link_lsa_originate, oi, 0, &(oi)->thread_link_lsa); \ | |
508e53e2 | 170 | } while (0) |
171 | #define OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB(oa) \ | |
172 | do { \ | |
ffa2c898 QY |
173 | if (CHECK_FLAG((oa)->flag, OSPF6_AREA_ENABLE)) \ |
174 | thread_add_event (master, ospf6_intra_prefix_lsa_originate_stub, \ | |
175 | oa, 0, &(oa)->thread_intra_prefix_lsa); \ | |
508e53e2 | 176 | } while (0) |
177 | #define OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT(oi) \ | |
178 | do { \ | |
ffa2c898 QY |
179 | if (!CHECK_FLAG((oi)->flag, OSPF6_INTERFACE_DISABLE)) \ |
180 | thread_add_event (master, ospf6_intra_prefix_lsa_originate_transit, \ | |
181 | oi, 0, &(oi)->thread_intra_prefix_lsa); \ | |
508e53e2 | 182 | } while (0) |
183 | ||
6452df09 | 184 | #define OSPF6_NETWORK_LSA_EXECUTE(oi) \ |
185 | do { \ | |
186 | THREAD_OFF ((oi)->thread_network_lsa); \ | |
187 | thread_execute (master, ospf6_network_lsa_originate, oi, 0); \ | |
188 | } while (0) | |
189 | #define OSPF6_INTRA_PREFIX_LSA_EXECUTE_TRANSIT(oi) \ | |
190 | do { \ | |
191 | THREAD_OFF ((oi)->thread_intra_prefix_lsa); \ | |
192 | thread_execute (master, ospf6_intra_prefix_lsa_originate_transit, oi, 0); \ | |
193 | } while (0) | |
194 | ||
195 | ||
508e53e2 | 196 | /* Function Prototypes */ |
6ac29a51 PJ |
197 | extern char *ospf6_router_lsdesc_lookup (u_char type, u_int32_t interface_id, |
198 | u_int32_t neighbor_interface_id, | |
199 | u_int32_t neighbor_router_id, | |
200 | struct ospf6_lsa *lsa); | |
201 | extern char *ospf6_network_lsdesc_lookup (u_int32_t router_id, | |
202 | struct ospf6_lsa *lsa); | |
203 | ||
f41b4a02 | 204 | extern int ospf6_router_is_stub_router (struct ospf6_lsa *lsa); |
6ac29a51 PJ |
205 | extern int ospf6_router_lsa_originate (struct thread *); |
206 | extern int ospf6_network_lsa_originate (struct thread *); | |
207 | extern int ospf6_link_lsa_originate (struct thread *); | |
208 | extern int ospf6_intra_prefix_lsa_originate_transit (struct thread *); | |
209 | extern int ospf6_intra_prefix_lsa_originate_stub (struct thread *); | |
210 | extern void ospf6_intra_prefix_lsa_add (struct ospf6_lsa *lsa); | |
211 | extern void ospf6_intra_prefix_lsa_remove (struct ospf6_lsa *lsa); | |
212 | ||
213 | extern void ospf6_intra_route_calculation (struct ospf6_area *oa); | |
214 | extern void ospf6_intra_brouter_calculation (struct ospf6_area *oa); | |
215 | ||
216 | extern void ospf6_intra_init (void); | |
217 | ||
218 | extern int config_write_ospf6_debug_brouter (struct vty *vty); | |
219 | extern void install_element_ospf6_debug_brouter (void); | |
cb4b8845 | 220 | |
508e53e2 | 221 | #endif /* OSPF6_LSA_H */ |
718e3744 | 222 |