blob: 365b98d155860b6bcce65e28310c89aae32845ec [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/*
hasso508e53e2004-05-18 18:57:06 +00002 * Copyright (C) 2003 Yasuhiro Ohara
paul718e3742002-12-13 20:15:29 +00003 *
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
17 * along with GNU Zebra; see the file COPYING. If not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
hasso508e53e2004-05-18 18:57:06 +000022#include <zebra.h>
23
24#include "log.h"
25#include "linklist.h"
26#include "thread.h"
27#include "memory.h"
28#include "if.h"
29#include "prefix.h"
30#include "table.h"
31#include "vty.h"
32#include "command.h"
33
hasso508e53e2004-05-18 18:57:06 +000034#include "ospf6_proto.h"
35#include "ospf6_message.h"
36#include "ospf6_route.h"
37#include "ospf6_lsa.h"
38#include "ospf6_lsdb.h"
paul718e3742002-12-13 20:15:29 +000039
hasso508e53e2004-05-18 18:57:06 +000040#include "ospf6_top.h"
41#include "ospf6_area.h"
42#include "ospf6_interface.h"
43#include "ospf6_neighbor.h"
44#include "ospf6_intra.h"
45#include "ospf6_asbr.h"
hasso6452df02004-08-15 05:52:07 +000046#include "ospf6_abr.h"
47#include "ospf6_flood.h"
hasso049207c2004-08-04 20:02:13 +000048#include "ospf6d.h"
paul718e3742002-12-13 20:15:29 +000049
hasso508e53e2004-05-18 18:57:06 +000050/******************************/
51/* RFC2740 3.4.3.1 Router-LSA */
52/******************************/
paul718e3742002-12-13 20:15:29 +000053
hasso508e53e2004-05-18 18:57:06 +000054int
55ospf6_router_lsa_show (struct vty *vty, struct ospf6_lsa *lsa)
paul718e3742002-12-13 20:15:29 +000056{
hasso508e53e2004-05-18 18:57:06 +000057 char *start, *end, *current;
58 char buf[32], name[32], bits[16], options[32];
59 struct ospf6_router_lsa *router_lsa;
60 struct ospf6_router_lsdesc *lsdesc;
paul718e3742002-12-13 20:15:29 +000061
hasso508e53e2004-05-18 18:57:06 +000062 router_lsa = (struct ospf6_router_lsa *)
63 ((char *) lsa->header + sizeof (struct ospf6_lsa_header));
paul718e3742002-12-13 20:15:29 +000064
hasso508e53e2004-05-18 18:57:06 +000065 ospf6_capability_printbuf (router_lsa->bits, bits, sizeof (bits));
66 ospf6_options_printbuf (router_lsa->options, options, sizeof (options));
hasso049207c2004-08-04 20:02:13 +000067 vty_out (vty, " Bits: %s Options: %s%s", bits, options, VNL);
paul718e3742002-12-13 20:15:29 +000068
hasso508e53e2004-05-18 18:57:06 +000069 start = (char *) router_lsa + sizeof (struct ospf6_router_lsa);
paul718e3742002-12-13 20:15:29 +000070 end = (char *) lsa->header + ntohs (lsa->header->length);
hasso508e53e2004-05-18 18:57:06 +000071 for (current = start; current + sizeof (struct ospf6_router_lsdesc) <= end;
72 current += sizeof (struct ospf6_router_lsdesc))
paul718e3742002-12-13 20:15:29 +000073 {
hasso508e53e2004-05-18 18:57:06 +000074 lsdesc = (struct ospf6_router_lsdesc *) current;
paul718e3742002-12-13 20:15:29 +000075
hasso508e53e2004-05-18 18:57:06 +000076 if (lsdesc->type == OSPF6_ROUTER_LSDESC_POINTTOPOINT)
77 snprintf (name, sizeof (name), "Point-To-Point");
78 else if (lsdesc->type == OSPF6_ROUTER_LSDESC_TRANSIT_NETWORK)
79 snprintf (name, sizeof (name), "Transit-Network");
80 else if (lsdesc->type == OSPF6_ROUTER_LSDESC_STUB_NETWORK)
81 snprintf (name, sizeof (name), "Stub-Network");
82 else if (lsdesc->type == OSPF6_ROUTER_LSDESC_VIRTUAL_LINK)
83 snprintf (name, sizeof (name), "Virtual-Link");
paul718e3742002-12-13 20:15:29 +000084 else
hasso508e53e2004-05-18 18:57:06 +000085 snprintf (name, sizeof (name), "Unknown (%#x)", lsdesc->type);
paul718e3742002-12-13 20:15:29 +000086
hasso508e53e2004-05-18 18:57:06 +000087 vty_out (vty, " Type: %s Metric: %d%s",
hasso049207c2004-08-04 20:02:13 +000088 name, ntohs (lsdesc->metric), VNL);
hasso508e53e2004-05-18 18:57:06 +000089 vty_out (vty, " Interface ID: %s%s",
90 inet_ntop (AF_INET, &lsdesc->interface_id,
hasso049207c2004-08-04 20:02:13 +000091 buf, sizeof (buf)), VNL);
hasso508e53e2004-05-18 18:57:06 +000092 vty_out (vty, " Neighbor Interface ID: %s%s",
93 inet_ntop (AF_INET, &lsdesc->neighbor_interface_id,
hasso049207c2004-08-04 20:02:13 +000094 buf, sizeof (buf)), VNL);
hasso508e53e2004-05-18 18:57:06 +000095 vty_out (vty, " Neighbor Router ID: %s%s",
96 inet_ntop (AF_INET, &lsdesc->neighbor_router_id,
hasso049207c2004-08-04 20:02:13 +000097 buf, sizeof (buf)), VNL);
paul718e3742002-12-13 20:15:29 +000098 }
99 return 0;
100}
101
hasso6452df02004-08-15 05:52:07 +0000102int
103ospf6_router_lsa_originate (struct thread *thread)
paul718e3742002-12-13 20:15:29 +0000104{
hasso6452df02004-08-15 05:52:07 +0000105 struct ospf6_area *oa;
106
hasso508e53e2004-05-18 18:57:06 +0000107 char buffer [OSPF6_MAX_LSASIZE];
108 struct ospf6_lsa_header *lsa_header;
109 struct ospf6_lsa *lsa;
paul718e3742002-12-13 20:15:29 +0000110
hasso508e53e2004-05-18 18:57:06 +0000111 u_int32_t link_state_id = 0;
hasso52dc7ee2004-09-23 19:18:23 +0000112 struct listnode *i, *j;
hasso508e53e2004-05-18 18:57:06 +0000113 struct ospf6_interface *oi;
114 struct ospf6_neighbor *on, *drouter = NULL;
115 struct ospf6_router_lsa *router_lsa;
116 struct ospf6_router_lsdesc *lsdesc;
117 u_int16_t type;
118 u_int32_t router;
119 int count;
paul718e3742002-12-13 20:15:29 +0000120
hasso6452df02004-08-15 05:52:07 +0000121 oa = (struct ospf6_area *) THREAD_ARG (thread);
122 oa->thread_router_lsa = NULL;
123
hasso1e058382004-09-01 21:36:14 +0000124 if (IS_OSPF6_DEBUG_ORIGINATE (ROUTER))
hasso508e53e2004-05-18 18:57:06 +0000125 zlog_info ("Originate Router-LSA for Area %s", oa->name);
paul718e3742002-12-13 20:15:29 +0000126
hasso508e53e2004-05-18 18:57:06 +0000127 memset (buffer, 0, sizeof (buffer));
128 lsa_header = (struct ospf6_lsa_header *) buffer;
129 router_lsa = (struct ospf6_router_lsa *)
130 ((caddr_t) lsa_header + sizeof (struct ospf6_lsa_header));
131
132 OSPF6_OPT_SET (router_lsa->options, OSPF6_OPT_V6);
133 OSPF6_OPT_SET (router_lsa->options, OSPF6_OPT_E);
134 OSPF6_OPT_CLEAR (router_lsa->options, OSPF6_OPT_MC);
135 OSPF6_OPT_CLEAR (router_lsa->options, OSPF6_OPT_N);
136 OSPF6_OPT_SET (router_lsa->options, OSPF6_OPT_R);
137 OSPF6_OPT_CLEAR (router_lsa->options, OSPF6_OPT_DC);
138
hasso6452df02004-08-15 05:52:07 +0000139 if (ospf6_is_router_abr (ospf6))
140 SET_FLAG (router_lsa->bits, OSPF6_ROUTER_BIT_B);
141 else
142 UNSET_FLAG (router_lsa->bits, OSPF6_ROUTER_BIT_B);
hasso508e53e2004-05-18 18:57:06 +0000143 if (ospf6_asbr_is_asbr (ospf6))
144 SET_FLAG (router_lsa->bits, OSPF6_ROUTER_BIT_E);
145 else
146 UNSET_FLAG (router_lsa->bits, OSPF6_ROUTER_BIT_E);
147 UNSET_FLAG (router_lsa->bits, OSPF6_ROUTER_BIT_V);
148 UNSET_FLAG (router_lsa->bits, OSPF6_ROUTER_BIT_W);
149
150 /* describe links for each interfaces */
151 lsdesc = (struct ospf6_router_lsdesc *)
152 ((caddr_t) router_lsa + sizeof (struct ospf6_router_lsa));
153
154 for (i = listhead (oa->if_list); i; nextnode (i))
paul718e3742002-12-13 20:15:29 +0000155 {
hasso508e53e2004-05-18 18:57:06 +0000156 oi = (struct ospf6_interface *) getdata (i);
157
158 /* Interfaces in state Down or Loopback are not described */
159 if (oi->state == OSPF6_INTERFACE_DOWN ||
160 oi->state == OSPF6_INTERFACE_LOOPBACK)
paul718e3742002-12-13 20:15:29 +0000161 continue;
162
hasso508e53e2004-05-18 18:57:06 +0000163 /* Nor are interfaces without any full adjacencies described */
164 count = 0;
165 for (j = listhead (oi->neighbor_list); j; nextnode (j))
paul718e3742002-12-13 20:15:29 +0000166 {
hasso508e53e2004-05-18 18:57:06 +0000167 on = (struct ospf6_neighbor *) getdata (j);
168 if (on->state == OSPF6_NEIGHBOR_FULL)
169 count++;
170 }
171 if (count == 0)
172 continue;
173
174 /* Multiple Router-LSA instance according to size limit setting */
paul0c083ee2004-10-10 12:54:58 +0000175 if ( (oa->router_lsa_size_limit != 0)
176 && ((caddr_t) lsdesc + sizeof (struct ospf6_router_lsdesc) -
177 (caddr_t) buffer > oa->router_lsa_size_limit))
hasso508e53e2004-05-18 18:57:06 +0000178 {
179 if ((caddr_t) lsdesc == (caddr_t) router_lsa +
180 sizeof (struct ospf6_router_lsa))
181 {
hasso1e058382004-09-01 21:36:14 +0000182 if (IS_OSPF6_DEBUG_ORIGINATE (ROUTER))
hasso508e53e2004-05-18 18:57:06 +0000183 zlog_info ("Size limit setting for Router-LSA too short");
hasso6452df02004-08-15 05:52:07 +0000184 return 0;
hasso508e53e2004-05-18 18:57:06 +0000185 }
186
187 /* Fill LSA Header */
188 lsa_header->age = 0;
189 lsa_header->type = htons (OSPF6_LSTYPE_ROUTER);
190 lsa_header->id = htonl (link_state_id);
191 lsa_header->adv_router = oa->ospf6->router_id;
192 lsa_header->seqnum =
hasso049207c2004-08-04 20:02:13 +0000193 ospf6_new_ls_seqnum (lsa_header->type, lsa_header->id,
194 lsa_header->adv_router, oa->lsdb);
hasso508e53e2004-05-18 18:57:06 +0000195 lsa_header->length = htons ((caddr_t) lsdesc - (caddr_t) buffer);
196
197 /* LSA checksum */
198 ospf6_lsa_checksum (lsa_header);
199
200 /* create LSA */
201 lsa = ospf6_lsa_create (lsa_header);
hasso508e53e2004-05-18 18:57:06 +0000202
203 /* Originate */
hasso6452df02004-08-15 05:52:07 +0000204 ospf6_lsa_originate_area (lsa, oa);
hasso508e53e2004-05-18 18:57:06 +0000205
206 /* Reset setting for consecutive origination */
207 memset ((caddr_t) router_lsa + sizeof (struct ospf6_router_lsa),
208 0, (caddr_t) lsdesc - (caddr_t) router_lsa);
209 lsdesc = (struct ospf6_router_lsdesc *)
210 ((caddr_t) router_lsa + sizeof (struct ospf6_router_lsa));
211 link_state_id ++;
paul718e3742002-12-13 20:15:29 +0000212 }
213
hasso508e53e2004-05-18 18:57:06 +0000214 /* Point-to-Point interfaces */
215 if (if_is_pointopoint (oi->interface))
216 {
217 for (j = listhead (oi->neighbor_list); j; nextnode (j))
218 {
219 on = (struct ospf6_neighbor *) getdata (j);
220 if (on->state != OSPF6_NEIGHBOR_FULL)
221 continue;
paul718e3742002-12-13 20:15:29 +0000222
hasso508e53e2004-05-18 18:57:06 +0000223 lsdesc->type = OSPF6_ROUTER_LSDESC_POINTTOPOINT;
224 lsdesc->metric = htons (oi->cost);
225 lsdesc->interface_id = htonl (oi->interface->ifindex);
226 lsdesc->neighbor_interface_id = htonl (on->ifindex);
227 lsdesc->neighbor_router_id = on->router_id;
228
229 lsdesc++;
230 }
231 }
232
233 /* Broadcast and NBMA interfaces */
234 if (if_is_broadcast (oi->interface))
235 {
236 /* If this router is not DR,
237 and If this router not fully adjacent with DR,
238 this interface is not transit yet: ignore. */
239 if (oi->state != OSPF6_INTERFACE_DR)
240 {
241 drouter = ospf6_neighbor_lookup (oi->drouter, oi);
242 if (drouter == NULL || drouter->state != OSPF6_NEIGHBOR_FULL)
243 continue;
244 }
245
246 lsdesc->type = OSPF6_ROUTER_LSDESC_TRANSIT_NETWORK;
247 lsdesc->metric = htons (oi->cost);
248 lsdesc->interface_id = htonl (oi->interface->ifindex);
249 if (oi->state != OSPF6_INTERFACE_DR)
250 {
251 lsdesc->neighbor_interface_id = htonl (drouter->ifindex);
252 lsdesc->neighbor_router_id = drouter->router_id;
253 }
254 else
255 {
256 lsdesc->neighbor_interface_id = htonl (oi->interface->ifindex);
257 lsdesc->neighbor_router_id = oi->area->ospf6->router_id;
258 }
259
260 lsdesc++;
261 }
262
263 /* Virtual links */
264 /* xxx */
265 /* Point-to-Multipoint interfaces */
266 /* xxx */
paul718e3742002-12-13 20:15:29 +0000267 }
hasso508e53e2004-05-18 18:57:06 +0000268
269 if ((caddr_t) lsdesc != (caddr_t) router_lsa +
270 sizeof (struct ospf6_router_lsa))
271 {
272 /* Fill LSA Header */
273 lsa_header->age = 0;
274 lsa_header->type = htons (OSPF6_LSTYPE_ROUTER);
275 lsa_header->id = htonl (link_state_id);
276 lsa_header->adv_router = oa->ospf6->router_id;
277 lsa_header->seqnum =
hasso049207c2004-08-04 20:02:13 +0000278 ospf6_new_ls_seqnum (lsa_header->type, lsa_header->id,
279 lsa_header->adv_router, oa->lsdb);
hasso508e53e2004-05-18 18:57:06 +0000280 lsa_header->length = htons ((caddr_t) lsdesc - (caddr_t) buffer);
281
282 /* LSA checksum */
283 ospf6_lsa_checksum (lsa_header);
284
285 /* create LSA */
286 lsa = ospf6_lsa_create (lsa_header);
hasso508e53e2004-05-18 18:57:06 +0000287
288 /* Originate */
hasso6452df02004-08-15 05:52:07 +0000289 ospf6_lsa_originate_area (lsa, oa);
hasso508e53e2004-05-18 18:57:06 +0000290
291 link_state_id ++;
292 }
hasso6452df02004-08-15 05:52:07 +0000293 else
294 {
hasso1e058382004-09-01 21:36:14 +0000295 if (IS_OSPF6_DEBUG_ORIGINATE (ROUTER))
hasso6452df02004-08-15 05:52:07 +0000296 zlog_info ("Nothing to describe in Router-LSA, suppress");
297 }
hasso508e53e2004-05-18 18:57:06 +0000298
299 /* Do premature-aging of rest, undesired Router-LSAs */
300 type = ntohs (OSPF6_LSTYPE_ROUTER);
301 router = oa->ospf6->router_id;
302 for (lsa = ospf6_lsdb_type_router_head (type, router, oa->lsdb); lsa;
303 lsa = ospf6_lsdb_type_router_next (type, router, lsa))
304 {
305 if (ntohl (lsa->header->id) < link_state_id)
306 continue;
hasso6452df02004-08-15 05:52:07 +0000307 ospf6_lsa_purge (lsa);
hasso508e53e2004-05-18 18:57:06 +0000308 }
hasso508e53e2004-05-18 18:57:06 +0000309
310 return 0;
311}
312
hasso508e53e2004-05-18 18:57:06 +0000313/*******************************/
314/* RFC2740 3.4.3.2 Network-LSA */
315/*******************************/
316
317int
318ospf6_network_lsa_show (struct vty *vty, struct ospf6_lsa *lsa)
319{
320 char *start, *end, *current;
321 struct ospf6_network_lsa *network_lsa;
322 struct ospf6_network_lsdesc *lsdesc;
323 char buf[128], options[32];
324
325 network_lsa = (struct ospf6_network_lsa *)
326 ((caddr_t) lsa->header + sizeof (struct ospf6_lsa_header));
327
328 ospf6_options_printbuf (network_lsa->options, options, sizeof (options));
hasso049207c2004-08-04 20:02:13 +0000329 vty_out (vty, " Options: %s%s", options, VNL);
hasso508e53e2004-05-18 18:57:06 +0000330
331 start = (char *) network_lsa + sizeof (struct ospf6_network_lsa);
332 end = (char *) lsa->header + ntohs (lsa->header->length);
333 for (current = start; current + sizeof (struct ospf6_network_lsdesc) <= end;
334 current += sizeof (struct ospf6_network_lsdesc))
335 {
336 lsdesc = (struct ospf6_network_lsdesc *) current;
337 inet_ntop (AF_INET, &lsdesc->router_id, buf, sizeof (buf));
hasso049207c2004-08-04 20:02:13 +0000338 vty_out (vty, " Attached Router: %s%s", buf, VNL);
hasso508e53e2004-05-18 18:57:06 +0000339 }
340 return 0;
paul718e3742002-12-13 20:15:29 +0000341}
342
hasso6452df02004-08-15 05:52:07 +0000343int
344ospf6_network_lsa_originate (struct thread *thread)
paul718e3742002-12-13 20:15:29 +0000345{
hasso6452df02004-08-15 05:52:07 +0000346 struct ospf6_interface *oi;
347
hasso508e53e2004-05-18 18:57:06 +0000348 char buffer [OSPF6_MAX_LSASIZE];
349 struct ospf6_lsa_header *lsa_header;
paul718e3742002-12-13 20:15:29 +0000350
hasso508e53e2004-05-18 18:57:06 +0000351 int count;
352 struct ospf6_lsa *old, *lsa;
353 struct ospf6_network_lsa *network_lsa;
354 struct ospf6_network_lsdesc *lsdesc;
355 struct ospf6_neighbor *on;
356 struct ospf6_link_lsa *link_lsa;
hasso52dc7ee2004-09-23 19:18:23 +0000357 struct listnode *i;
hasso508e53e2004-05-18 18:57:06 +0000358 u_int16_t type;
359
hasso6452df02004-08-15 05:52:07 +0000360 oi = (struct ospf6_interface *) THREAD_ARG (thread);
361 oi->thread_network_lsa = NULL;
362
363 /* The interface must be enabled until here. A Network-LSA of a
364 disabled interface (but was once enabled) should be flushed
365 by ospf6_lsa_refresh (), and does not come here. */
366 assert (oi->area);
paul718e3742002-12-13 20:15:29 +0000367
hasso508e53e2004-05-18 18:57:06 +0000368 old = ospf6_lsdb_lookup (htons (OSPF6_LSTYPE_NETWORK),
369 htonl (oi->interface->ifindex),
370 oi->area->ospf6->router_id, oi->area->lsdb);
paul718e3742002-12-13 20:15:29 +0000371
hasso508e53e2004-05-18 18:57:06 +0000372 /* Do not originate Network-LSA if not DR */
373 if (oi->state != OSPF6_INTERFACE_DR)
paul718e3742002-12-13 20:15:29 +0000374 {
hasso508e53e2004-05-18 18:57:06 +0000375 if (old)
hasso6452df02004-08-15 05:52:07 +0000376 ospf6_lsa_purge (old);
377 return 0;
paul718e3742002-12-13 20:15:29 +0000378 }
hasso508e53e2004-05-18 18:57:06 +0000379
hasso1e058382004-09-01 21:36:14 +0000380 if (IS_OSPF6_DEBUG_ORIGINATE (NETWORK))
hasso508e53e2004-05-18 18:57:06 +0000381 zlog_info ("Originate Network-LSA for Interface %s", oi->interface->name);
382
383 /* If none of neighbor is adjacent to us */
384 count = 0;
385 for (i = listhead (oi->neighbor_list); i; nextnode (i))
386 {
387 on = (struct ospf6_neighbor *) getdata (i);
388 if (on->state == OSPF6_NEIGHBOR_FULL)
389 count++;
390 }
391 if (count == 0)
392 {
hasso1e058382004-09-01 21:36:14 +0000393 if (IS_OSPF6_DEBUG_ORIGINATE (NETWORK))
hasso508e53e2004-05-18 18:57:06 +0000394 zlog_info ("Interface stub, ignore");
395 if (old)
hasso6452df02004-08-15 05:52:07 +0000396 ospf6_lsa_purge (old);
397 return 0;
hasso508e53e2004-05-18 18:57:06 +0000398 }
399
400 /* prepare buffer */
401 memset (buffer, 0, sizeof (buffer));
402 lsa_header = (struct ospf6_lsa_header *) buffer;
403 network_lsa = (struct ospf6_network_lsa *)
404 ((caddr_t) lsa_header + sizeof (struct ospf6_lsa_header));
405
406 /* Collect the interface's Link-LSAs to describe
407 network's optional capabilities */
408 type = htons (OSPF6_LSTYPE_LINK);
409 for (lsa = ospf6_lsdb_type_head (type, oi->lsdb); lsa;
410 lsa = ospf6_lsdb_type_next (type, lsa))
411 {
412 link_lsa = (struct ospf6_link_lsa *)
413 ((caddr_t) lsa->header + sizeof (struct ospf6_lsa_header));
414 network_lsa->options[0] |= link_lsa->options[0];
415 network_lsa->options[1] |= link_lsa->options[1];
416 network_lsa->options[2] |= link_lsa->options[2];
417 }
418
419 lsdesc = (struct ospf6_network_lsdesc *)
420 ((caddr_t) network_lsa + sizeof (struct ospf6_network_lsa));
421
422 /* set Link Description to the router itself */
423 lsdesc->router_id = oi->area->ospf6->router_id;
424 lsdesc++;
425
426 /* Walk through the neighbors */
427 for (i = listhead (oi->neighbor_list); i; nextnode (i))
428 {
429 on = (struct ospf6_neighbor *) getdata (i);
430
431 if (on->state != OSPF6_NEIGHBOR_FULL)
432 continue;
433
434 /* set this neighbor's Router-ID to LSA */
435 lsdesc->router_id = on->router_id;
436 lsdesc++;
437 }
438
439 /* Fill LSA Header */
440 lsa_header->age = 0;
441 lsa_header->type = htons (OSPF6_LSTYPE_NETWORK);
442 lsa_header->id = htonl (oi->interface->ifindex);
443 lsa_header->adv_router = oi->area->ospf6->router_id;
444 lsa_header->seqnum =
hasso049207c2004-08-04 20:02:13 +0000445 ospf6_new_ls_seqnum (lsa_header->type, lsa_header->id,
446 lsa_header->adv_router, oi->area->lsdb);
hasso508e53e2004-05-18 18:57:06 +0000447 lsa_header->length = htons ((caddr_t) lsdesc - (caddr_t) buffer);
448
449 /* LSA checksum */
450 ospf6_lsa_checksum (lsa_header);
451
452 /* create LSA */
453 lsa = ospf6_lsa_create (lsa_header);
hasso508e53e2004-05-18 18:57:06 +0000454
455 /* Originate */
hasso6452df02004-08-15 05:52:07 +0000456 ospf6_lsa_originate_area (lsa, oi->area);
hasso508e53e2004-05-18 18:57:06 +0000457
458 return 0;
459}
460
461
462/****************************/
463/* RFC2740 3.4.3.6 Link-LSA */
464/****************************/
465
466int
467ospf6_link_lsa_show (struct vty *vty, struct ospf6_lsa *lsa)
468{
paul718e3742002-12-13 20:15:29 +0000469 char *start, *end, *current;
hasso508e53e2004-05-18 18:57:06 +0000470 struct ospf6_link_lsa *link_lsa;
471 int prefixnum;
472 char buf[128], options[32];
473 struct ospf6_prefix *prefix;
paul0c083ee2004-10-10 12:54:58 +0000474 const char *p, *mc, *la, *nu;
hasso508e53e2004-05-18 18:57:06 +0000475 struct in6_addr in6;
paul718e3742002-12-13 20:15:29 +0000476
hasso508e53e2004-05-18 18:57:06 +0000477 link_lsa = (struct ospf6_link_lsa *)
478 ((caddr_t) lsa->header + sizeof (struct ospf6_lsa_header));
paul718e3742002-12-13 20:15:29 +0000479
hasso508e53e2004-05-18 18:57:06 +0000480 ospf6_options_printbuf (link_lsa->options, options, sizeof (options));
481 inet_ntop (AF_INET6, &link_lsa->linklocal_addr, buf, sizeof (buf));
482 prefixnum = ntohl (link_lsa->prefix_num);
paul718e3742002-12-13 20:15:29 +0000483
hasso508e53e2004-05-18 18:57:06 +0000484 vty_out (vty, " Priority: %d Options: %s%s",
hasso049207c2004-08-04 20:02:13 +0000485 link_lsa->priority, options, VNL);
486 vty_out (vty, " LinkLocal Address: %s%s", buf, VNL);
487 vty_out (vty, " Number of Prefix: %d%s", prefixnum, VNL);
paul718e3742002-12-13 20:15:29 +0000488
hasso508e53e2004-05-18 18:57:06 +0000489 start = (char *) link_lsa + sizeof (struct ospf6_link_lsa);
490 end = (char *) lsa->header + ntohs (lsa->header->length);
paul718e3742002-12-13 20:15:29 +0000491 for (current = start; current < end; current += OSPF6_PREFIX_SIZE (prefix))
492 {
493 prefix = (struct ospf6_prefix *) current;
hasso508e53e2004-05-18 18:57:06 +0000494 if (prefix->prefix_length == 0 ||
495 current + OSPF6_PREFIX_SIZE (prefix) > end)
496 break;
paul718e3742002-12-13 20:15:29 +0000497
hasso508e53e2004-05-18 18:57:06 +0000498 p = (CHECK_FLAG (prefix->prefix_options, OSPF6_PREFIX_OPTION_P) ?
499 "P" : "--");
500 mc = (CHECK_FLAG (prefix->prefix_options, OSPF6_PREFIX_OPTION_MC) ?
501 "MC" : "--");
502 la = (CHECK_FLAG (prefix->prefix_options, OSPF6_PREFIX_OPTION_LA) ?
503 "LA" : "--");
504 nu = (CHECK_FLAG (prefix->prefix_options, OSPF6_PREFIX_OPTION_NU) ?
505 "NU" : "--");
506 vty_out (vty, " Prefix Options: %s|%s|%s|%s%s",
hasso049207c2004-08-04 20:02:13 +0000507 p, mc, la, nu, VNL);
paul718e3742002-12-13 20:15:29 +0000508
hasso508e53e2004-05-18 18:57:06 +0000509 memset (&in6, 0, sizeof (in6));
510 memcpy (&in6, OSPF6_PREFIX_BODY (prefix),
511 OSPF6_PREFIX_SPACE (prefix->prefix_length));
paul718e3742002-12-13 20:15:29 +0000512 inet_ntop (AF_INET6, &in6, buf, sizeof (buf));
513 vty_out (vty, " Prefix: %s/%d%s",
hasso049207c2004-08-04 20:02:13 +0000514 buf, prefix->prefix_length, VNL);
paul718e3742002-12-13 20:15:29 +0000515 }
516
517 return 0;
518}
519
hasso6452df02004-08-15 05:52:07 +0000520int
521ospf6_link_lsa_originate (struct thread *thread)
paul718e3742002-12-13 20:15:29 +0000522{
hasso6452df02004-08-15 05:52:07 +0000523 struct ospf6_interface *oi;
524
hasso508e53e2004-05-18 18:57:06 +0000525 char buffer[OSPF6_MAX_LSASIZE];
526 struct ospf6_lsa_header *lsa_header;
527 struct ospf6_lsa *old, *lsa;
paul718e3742002-12-13 20:15:29 +0000528
hasso508e53e2004-05-18 18:57:06 +0000529 struct ospf6_link_lsa *link_lsa;
530 struct ospf6_route *route;
531 struct ospf6_prefix *op;
paul718e3742002-12-13 20:15:29 +0000532
hasso6452df02004-08-15 05:52:07 +0000533 oi = (struct ospf6_interface *) THREAD_ARG (thread);
534 oi->thread_link_lsa = NULL;
535
536 assert (oi->area);
paul718e3742002-12-13 20:15:29 +0000537
538 /* find previous LSA */
hasso508e53e2004-05-18 18:57:06 +0000539 old = ospf6_lsdb_lookup (htons (OSPF6_LSTYPE_LINK),
540 htonl (oi->interface->ifindex),
541 oi->area->ospf6->router_id, oi->lsdb);
paul718e3742002-12-13 20:15:29 +0000542
hasso508e53e2004-05-18 18:57:06 +0000543 if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE))
paul718e3742002-12-13 20:15:29 +0000544 {
545 if (old)
hasso6452df02004-08-15 05:52:07 +0000546 ospf6_lsa_purge (old);
547 return 0;
paul718e3742002-12-13 20:15:29 +0000548 }
549
hasso1e058382004-09-01 21:36:14 +0000550 if (IS_OSPF6_DEBUG_ORIGINATE (LINK))
hasso508e53e2004-05-18 18:57:06 +0000551 zlog_info ("Originate Link-LSA for Interface %s", oi->interface->name);
paul718e3742002-12-13 20:15:29 +0000552
hasso508e53e2004-05-18 18:57:06 +0000553 /* can't make Link-LSA if linklocal address not set */
554 if (oi->linklocal_addr == NULL)
paul718e3742002-12-13 20:15:29 +0000555 {
hasso1e058382004-09-01 21:36:14 +0000556 if (IS_OSPF6_DEBUG_ORIGINATE (LINK))
hasso508e53e2004-05-18 18:57:06 +0000557 zlog_info ("No Linklocal address on %s, defer originating",
558 oi->interface->name);
559 if (old)
hasso6452df02004-08-15 05:52:07 +0000560 ospf6_lsa_purge (old);
561 return 0;
hasso508e53e2004-05-18 18:57:06 +0000562 }
563
564 /* prepare buffer */
565 memset (buffer, 0, sizeof (buffer));
566 lsa_header = (struct ospf6_lsa_header *) buffer;
567 link_lsa = (struct ospf6_link_lsa *)
568 ((caddr_t) lsa_header + sizeof (struct ospf6_lsa_header));
569
570 /* Fill Link-LSA */
571 link_lsa->priority = oi->priority;
572 memcpy (link_lsa->options, oi->area->options, 3);
573 memcpy (&link_lsa->linklocal_addr, oi->linklocal_addr,
574 sizeof (struct in6_addr));
575 link_lsa->prefix_num = htonl (oi->route_connected->count);
576
577 op = (struct ospf6_prefix *)
578 ((caddr_t) link_lsa + sizeof (struct ospf6_link_lsa));
579
580 /* connected prefix to advertise */
581 for (route = ospf6_route_head (oi->route_connected); route;
582 route = ospf6_route_next (route))
583 {
584 op->prefix_length = route->prefix.prefixlen;
585 op->prefix_options = route->path.prefix_options;
586 op->prefix_metric = htons (0);
587 memcpy (OSPF6_PREFIX_BODY (op), &route->prefix.u.prefix6,
588 OSPF6_PREFIX_SPACE (op->prefix_length));
589 op = OSPF6_PREFIX_NEXT (op);
590 }
591
592 /* Fill LSA Header */
593 lsa_header->age = 0;
594 lsa_header->type = htons (OSPF6_LSTYPE_LINK);
595 lsa_header->id = htonl (oi->interface->ifindex);
596 lsa_header->adv_router = oi->area->ospf6->router_id;
597 lsa_header->seqnum =
hasso049207c2004-08-04 20:02:13 +0000598 ospf6_new_ls_seqnum (lsa_header->type, lsa_header->id,
599 lsa_header->adv_router, oi->lsdb);
hasso508e53e2004-05-18 18:57:06 +0000600 lsa_header->length = htons ((caddr_t) op - (caddr_t) buffer);
601
602 /* LSA checksum */
603 ospf6_lsa_checksum (lsa_header);
604
605 /* create LSA */
606 lsa = ospf6_lsa_create (lsa_header);
hasso508e53e2004-05-18 18:57:06 +0000607
608 /* Originate */
hasso6452df02004-08-15 05:52:07 +0000609 ospf6_lsa_originate_interface (lsa, oi);
hasso508e53e2004-05-18 18:57:06 +0000610
611 return 0;
612}
613
614
615/*****************************************/
616/* RFC2740 3.4.3.7 Intra-Area-Prefix-LSA */
617/*****************************************/
618
619int
620ospf6_intra_prefix_lsa_show (struct vty *vty, struct ospf6_lsa *lsa)
621{
622 char *start, *end, *current;
623 struct ospf6_intra_prefix_lsa *intra_prefix_lsa;
624 int prefixnum;
625 char buf[128];
626 struct ospf6_prefix *prefix;
627 char id[16], adv_router[16];
paul0c083ee2004-10-10 12:54:58 +0000628 const char *p, *mc, *la, *nu;
hasso508e53e2004-05-18 18:57:06 +0000629 struct in6_addr in6;
630
631 intra_prefix_lsa = (struct ospf6_intra_prefix_lsa *)
632 ((caddr_t) lsa->header + sizeof (struct ospf6_lsa_header));
633
634 prefixnum = ntohs (intra_prefix_lsa->prefix_num);
635
hasso049207c2004-08-04 20:02:13 +0000636 vty_out (vty, " Number of Prefix: %d%s", prefixnum, VNL);
hasso508e53e2004-05-18 18:57:06 +0000637
638 inet_ntop (AF_INET, &intra_prefix_lsa->ref_id, id, sizeof (id));
639 inet_ntop (AF_INET, &intra_prefix_lsa->ref_adv_router,
640 adv_router, sizeof (adv_router));
641 vty_out (vty, " Reference: %s Id: %s Adv: %s%s",
hasso1e058382004-09-01 21:36:14 +0000642 ospf6_lstype_name (intra_prefix_lsa->ref_type), id, adv_router,
hasso049207c2004-08-04 20:02:13 +0000643 VNL);
hasso508e53e2004-05-18 18:57:06 +0000644
645 start = (char *) intra_prefix_lsa + sizeof (struct ospf6_intra_prefix_lsa);
646 end = (char *) lsa->header + ntohs (lsa->header->length);
647 for (current = start; current < end; current += OSPF6_PREFIX_SIZE (prefix))
648 {
649 prefix = (struct ospf6_prefix *) current;
650 if (prefix->prefix_length == 0 ||
651 current + OSPF6_PREFIX_SIZE (prefix) > end)
652 break;
653
654 p = (CHECK_FLAG (prefix->prefix_options, OSPF6_PREFIX_OPTION_P) ?
655 "P" : "--");
656 mc = (CHECK_FLAG (prefix->prefix_options, OSPF6_PREFIX_OPTION_MC) ?
657 "MC" : "--");
658 la = (CHECK_FLAG (prefix->prefix_options, OSPF6_PREFIX_OPTION_LA) ?
659 "LA" : "--");
660 nu = (CHECK_FLAG (prefix->prefix_options, OSPF6_PREFIX_OPTION_NU) ?
661 "NU" : "--");
662 vty_out (vty, " Prefix Options: %s|%s|%s|%s%s",
hasso049207c2004-08-04 20:02:13 +0000663 p, mc, la, nu, VNL);
hasso508e53e2004-05-18 18:57:06 +0000664
665 memset (&in6, 0, sizeof (in6));
666 memcpy (&in6, OSPF6_PREFIX_BODY (prefix),
667 OSPF6_PREFIX_SPACE (prefix->prefix_length));
668 inet_ntop (AF_INET6, &in6, buf, sizeof (buf));
669 vty_out (vty, " Prefix: %s/%d%s",
hasso049207c2004-08-04 20:02:13 +0000670 buf, prefix->prefix_length, VNL);
hasso508e53e2004-05-18 18:57:06 +0000671 }
672
673 return 0;
674}
675
hasso6452df02004-08-15 05:52:07 +0000676int
677ospf6_intra_prefix_lsa_originate_stub (struct thread *thread)
hasso508e53e2004-05-18 18:57:06 +0000678{
hasso6452df02004-08-15 05:52:07 +0000679 struct ospf6_area *oa;
680
hasso508e53e2004-05-18 18:57:06 +0000681 char buffer[OSPF6_MAX_LSASIZE];
682 struct ospf6_lsa_header *lsa_header;
683 struct ospf6_lsa *old, *lsa;
684
685 struct ospf6_intra_prefix_lsa *intra_prefix_lsa;
686 struct ospf6_interface *oi;
687 struct ospf6_neighbor *on;
688 struct ospf6_route *route;
689 struct ospf6_prefix *op;
hasso52dc7ee2004-09-23 19:18:23 +0000690 struct listnode *i, *j;
hasso508e53e2004-05-18 18:57:06 +0000691 int full_count = 0;
692 unsigned short prefix_num = 0;
693 char buf[BUFSIZ];
694 struct ospf6_route_table *route_advertise;
695
hasso6452df02004-08-15 05:52:07 +0000696 oa = (struct ospf6_area *) THREAD_ARG (thread);
697 oa->thread_intra_prefix_lsa = NULL;
698
hasso508e53e2004-05-18 18:57:06 +0000699 /* find previous LSA */
700 old = ospf6_lsdb_lookup (htons (OSPF6_LSTYPE_INTRA_PREFIX),
701 htonl (0), oa->ospf6->router_id, oa->lsdb);
702
hasso6452df02004-08-15 05:52:07 +0000703 if (! IS_AREA_ENABLED (oa))
hasso508e53e2004-05-18 18:57:06 +0000704 {
705 if (old)
hasso6452df02004-08-15 05:52:07 +0000706 ospf6_lsa_purge (old);
707 return 0;
hasso508e53e2004-05-18 18:57:06 +0000708 }
709
hasso1e058382004-09-01 21:36:14 +0000710 if (IS_OSPF6_DEBUG_ORIGINATE (INTRA_PREFIX))
hasso508e53e2004-05-18 18:57:06 +0000711 zlog_info ("Originate Intra-Area-Prefix-LSA for area %s's stub prefix",
712 oa->name);
713
714 /* prepare buffer */
715 memset (buffer, 0, sizeof (buffer));
716 lsa_header = (struct ospf6_lsa_header *) buffer;
717 intra_prefix_lsa = (struct ospf6_intra_prefix_lsa *)
718 ((caddr_t) lsa_header + sizeof (struct ospf6_lsa_header));
719
720 /* Fill Intra-Area-Prefix-LSA */
721 intra_prefix_lsa->ref_type = htons (OSPF6_LSTYPE_ROUTER);
722 intra_prefix_lsa->ref_id = htonl (0);
723 intra_prefix_lsa->ref_adv_router = oa->ospf6->router_id;
724
725 route_advertise = ospf6_route_table_create ();
726
727 for (i = listhead (oa->if_list); i; nextnode (i))
728 {
729 oi = (struct ospf6_interface *) getdata (i);
730
731 if (oi->state == OSPF6_INTERFACE_DOWN)
732 {
hasso1e058382004-09-01 21:36:14 +0000733 if (IS_OSPF6_DEBUG_ORIGINATE (INTRA_PREFIX))
hasso508e53e2004-05-18 18:57:06 +0000734 zlog_info (" Interface %s is down, ignore", oi->interface->name);
735 continue;
736 }
737
738 full_count = 0;
739 for (j = listhead (oi->neighbor_list); j; nextnode (j))
740 {
741 on = (struct ospf6_neighbor *) getdata (j);
742 if (on->state == OSPF6_NEIGHBOR_FULL)
743 full_count++;
744 }
745 if (oi->state != OSPF6_INTERFACE_LOOPBACK &&
746 oi->state != OSPF6_INTERFACE_POINTTOPOINT &&
747 full_count != 0)
748 {
hasso1e058382004-09-01 21:36:14 +0000749 if (IS_OSPF6_DEBUG_ORIGINATE (INTRA_PREFIX))
hasso508e53e2004-05-18 18:57:06 +0000750 zlog_info (" Interface %s is not stub, ignore",
751 oi->interface->name);
752 continue;
753 }
754
hasso1e058382004-09-01 21:36:14 +0000755 if (IS_OSPF6_DEBUG_ORIGINATE (INTRA_PREFIX))
hasso508e53e2004-05-18 18:57:06 +0000756 zlog_info (" Interface %s:", oi->interface->name);
757
758 /* connected prefix to advertise */
759 for (route = ospf6_route_head (oi->route_connected); route;
760 route = ospf6_route_best_next (route))
761 {
hasso1e058382004-09-01 21:36:14 +0000762 if (IS_OSPF6_DEBUG_ORIGINATE (INTRA_PREFIX))
hasso508e53e2004-05-18 18:57:06 +0000763 {
764 prefix2str (&route->prefix, buf, sizeof (buf));
765 zlog_info (" include %s", buf);
766 }
767 ospf6_route_add (ospf6_route_copy (route), route_advertise);
768 }
769 }
770
771 if (route_advertise->count == 0)
772 {
773 if (old)
hasso6452df02004-08-15 05:52:07 +0000774 ospf6_lsa_purge (old);
hasso508e53e2004-05-18 18:57:06 +0000775 ospf6_route_table_delete (route_advertise);
hasso6452df02004-08-15 05:52:07 +0000776 return 0;
hasso508e53e2004-05-18 18:57:06 +0000777 }
778
779 /* put prefixes to advertise */
780 prefix_num = 0;
781 op = (struct ospf6_prefix *)
782 ((caddr_t) intra_prefix_lsa + sizeof (struct ospf6_intra_prefix_lsa));
783 for (route = ospf6_route_head (route_advertise); route;
784 route = ospf6_route_best_next (route))
785 {
786 op->prefix_length = route->prefix.prefixlen;
787 op->prefix_options = route->path.prefix_options;
788 op->prefix_metric = htons (route->path.cost);
789 memcpy (OSPF6_PREFIX_BODY (op), &route->prefix.u.prefix6,
790 OSPF6_PREFIX_SPACE (op->prefix_length));
791 op = OSPF6_PREFIX_NEXT (op);
792 prefix_num++;
793 }
794
795 ospf6_route_table_delete (route_advertise);
796
797 if (prefix_num == 0)
798 {
hasso1e058382004-09-01 21:36:14 +0000799 if (IS_OSPF6_DEBUG_ORIGINATE (INTRA_PREFIX))
hasso508e53e2004-05-18 18:57:06 +0000800 zlog_info ("Quit to Advertise Intra-Prefix: no route to advertise");
hasso6452df02004-08-15 05:52:07 +0000801 return 0;
hasso508e53e2004-05-18 18:57:06 +0000802 }
803
804 intra_prefix_lsa->prefix_num = htons (prefix_num);
805
806 /* Fill LSA Header */
807 lsa_header->age = 0;
808 lsa_header->type = htons (OSPF6_LSTYPE_INTRA_PREFIX);
809 lsa_header->id = htonl (0);
810 lsa_header->adv_router = oa->ospf6->router_id;
811 lsa_header->seqnum =
hasso049207c2004-08-04 20:02:13 +0000812 ospf6_new_ls_seqnum (lsa_header->type, lsa_header->id,
813 lsa_header->adv_router, oa->lsdb);
hasso508e53e2004-05-18 18:57:06 +0000814 lsa_header->length = htons ((caddr_t) op - (caddr_t) lsa_header);
815
816 /* LSA checksum */
817 ospf6_lsa_checksum (lsa_header);
818
819 /* create LSA */
820 lsa = ospf6_lsa_create (lsa_header);
hasso508e53e2004-05-18 18:57:06 +0000821
822 /* Originate */
hasso6452df02004-08-15 05:52:07 +0000823 ospf6_lsa_originate_area (lsa, oa);
824
825 return 0;
hasso508e53e2004-05-18 18:57:06 +0000826}
827
hasso6452df02004-08-15 05:52:07 +0000828
829int
830ospf6_intra_prefix_lsa_originate_transit (struct thread *thread)
hasso508e53e2004-05-18 18:57:06 +0000831{
hasso6452df02004-08-15 05:52:07 +0000832 struct ospf6_interface *oi;
833
hasso508e53e2004-05-18 18:57:06 +0000834 char buffer[OSPF6_MAX_LSASIZE];
835 struct ospf6_lsa_header *lsa_header;
836 struct ospf6_lsa *old, *lsa;
837
838 struct ospf6_intra_prefix_lsa *intra_prefix_lsa;
839 struct ospf6_neighbor *on;
840 struct ospf6_route *route;
841 struct ospf6_prefix *op;
hasso52dc7ee2004-09-23 19:18:23 +0000842 struct listnode *i;
hasso508e53e2004-05-18 18:57:06 +0000843 int full_count = 0;
844 unsigned short prefix_num = 0;
845 struct ospf6_route_table *route_advertise;
846 struct ospf6_link_lsa *link_lsa;
847 char *start, *end, *current;
848 u_int16_t type;
849 char buf[BUFSIZ];
850
hasso6452df02004-08-15 05:52:07 +0000851 oi = (struct ospf6_interface *) THREAD_ARG (thread);
852 oi->thread_intra_prefix_lsa = NULL;
853
854 assert (oi->area);
hasso508e53e2004-05-18 18:57:06 +0000855
856 /* find previous LSA */
857 old = ospf6_lsdb_lookup (htons (OSPF6_LSTYPE_INTRA_PREFIX),
858 htonl (oi->interface->ifindex),
859 oi->area->ospf6->router_id, oi->area->lsdb);
860
861 if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE))
862 {
863 if (old)
hasso6452df02004-08-15 05:52:07 +0000864 ospf6_lsa_purge (old);
865 return 0;
hasso508e53e2004-05-18 18:57:06 +0000866 }
867
hasso1e058382004-09-01 21:36:14 +0000868 if (IS_OSPF6_DEBUG_ORIGINATE (INTRA_PREFIX))
hasso508e53e2004-05-18 18:57:06 +0000869 zlog_info ("Originate Intra-Area-Prefix-LSA for interface %s's prefix",
870 oi->interface->name);
871
872 /* prepare buffer */
873 memset (buffer, 0, sizeof (buffer));
874 lsa_header = (struct ospf6_lsa_header *) buffer;
875 intra_prefix_lsa = (struct ospf6_intra_prefix_lsa *)
876 ((caddr_t) lsa_header + sizeof (struct ospf6_lsa_header));
877
878 /* Fill Intra-Area-Prefix-LSA */
879 intra_prefix_lsa->ref_type = htons (OSPF6_LSTYPE_NETWORK);
880 intra_prefix_lsa->ref_id = htonl (oi->interface->ifindex);
881 intra_prefix_lsa->ref_adv_router = oi->area->ospf6->router_id;
882
883 if (oi->state != OSPF6_INTERFACE_DR)
884 {
hasso1e058382004-09-01 21:36:14 +0000885 if (IS_OSPF6_DEBUG_ORIGINATE (INTRA_PREFIX))
hasso508e53e2004-05-18 18:57:06 +0000886 zlog_info (" Interface is not DR");
887 if (old)
hasso6452df02004-08-15 05:52:07 +0000888 ospf6_lsa_purge (old);
889 return 0;
hasso508e53e2004-05-18 18:57:06 +0000890 }
891
892 full_count = 0;
893 for (i = listhead (oi->neighbor_list); i; nextnode (i))
894 {
895 on = (struct ospf6_neighbor *) getdata (i);
896 if (on->state == OSPF6_NEIGHBOR_FULL)
897 full_count++;
898 }
899 if (full_count == 0)
900 {
hasso1e058382004-09-01 21:36:14 +0000901 if (IS_OSPF6_DEBUG_ORIGINATE (INTRA_PREFIX))
hasso508e53e2004-05-18 18:57:06 +0000902 zlog_info (" Interface is stub");
903 if (old)
hasso6452df02004-08-15 05:52:07 +0000904 ospf6_lsa_purge (old);
905 return 0;
hasso508e53e2004-05-18 18:57:06 +0000906 }
907
908 /* connected prefix to advertise */
909 route_advertise = ospf6_route_table_create ();
910
911 type = ntohs (OSPF6_LSTYPE_LINK);
912 for (lsa = ospf6_lsdb_type_head (type, oi->lsdb); lsa;
913 lsa = ospf6_lsdb_type_next (type, lsa))
914 {
915 if (OSPF6_LSA_IS_MAXAGE (lsa))
paul718e3742002-12-13 20:15:29 +0000916 continue;
917
hasso1e058382004-09-01 21:36:14 +0000918 if (IS_OSPF6_DEBUG_ORIGINATE (INTRA_PREFIX))
hasso508e53e2004-05-18 18:57:06 +0000919 zlog_info (" include prefix from %s", lsa->name);
paul718e3742002-12-13 20:15:29 +0000920
hasso508e53e2004-05-18 18:57:06 +0000921 if (lsa->header->adv_router != oi->area->ospf6->router_id)
paul718e3742002-12-13 20:15:29 +0000922 {
hasso508e53e2004-05-18 18:57:06 +0000923 on = ospf6_neighbor_lookup (lsa->header->adv_router, oi);
924 if (on == NULL || on->state != OSPF6_NEIGHBOR_FULL)
paul718e3742002-12-13 20:15:29 +0000925 {
hasso1e058382004-09-01 21:36:14 +0000926 if (IS_OSPF6_DEBUG_ORIGINATE (INTRA_PREFIX))
hasso508e53e2004-05-18 18:57:06 +0000927 zlog_info (" Neighbor not found or not Full, ignore");
paul718e3742002-12-13 20:15:29 +0000928 continue;
929 }
930 }
931
hasso508e53e2004-05-18 18:57:06 +0000932 link_lsa = (struct ospf6_link_lsa *)
933 ((caddr_t) lsa->header + sizeof (struct ospf6_lsa_header));
paul718e3742002-12-13 20:15:29 +0000934
hasso508e53e2004-05-18 18:57:06 +0000935 prefix_num = (unsigned short) ntohl (link_lsa->prefix_num);
936 start = (char *) link_lsa + sizeof (struct ospf6_link_lsa);
937 end = (char *) lsa->header + ntohs (lsa->header->length);
938 for (current = start; current < end && prefix_num;
939 current += OSPF6_PREFIX_SIZE (op))
paul718e3742002-12-13 20:15:29 +0000940 {
hasso508e53e2004-05-18 18:57:06 +0000941 op = (struct ospf6_prefix *) current;
942 if (op->prefix_length == 0 ||
943 current + OSPF6_PREFIX_SIZE (op) > end)
944 break;
paul718e3742002-12-13 20:15:29 +0000945
hasso508e53e2004-05-18 18:57:06 +0000946 route = ospf6_route_create ();
947
948 route->type = OSPF6_DEST_TYPE_NETWORK;
949 route->prefix.family = AF_INET6;
950 route->prefix.prefixlen = op->prefix_length;
951 memset (&route->prefix.u.prefix6, 0, sizeof (struct in6_addr));
952 memcpy (&route->prefix.u.prefix6, OSPF6_PREFIX_BODY (op),
953 OSPF6_PREFIX_SPACE (op->prefix_length));
954
955 route->path.origin.type = lsa->header->type;
956 route->path.origin.id = lsa->header->id;
957 route->path.origin.adv_router = lsa->header->adv_router;
958 route->path.options[0] = link_lsa->options[0];
959 route->path.options[1] = link_lsa->options[1];
960 route->path.options[2] = link_lsa->options[2];
961 route->path.prefix_options = op->prefix_options;
962 route->path.area_id = oi->area->area_id;
963 route->path.type = OSPF6_PATH_TYPE_INTRA;
964
hasso1e058382004-09-01 21:36:14 +0000965 if (IS_OSPF6_DEBUG_ORIGINATE (INTRA_PREFIX))
paul718e3742002-12-13 20:15:29 +0000966 {
hasso508e53e2004-05-18 18:57:06 +0000967 prefix2str (&route->prefix, buf, sizeof (buf));
968 zlog_info (" include %s", buf);
paul718e3742002-12-13 20:15:29 +0000969 }
970
hasso508e53e2004-05-18 18:57:06 +0000971 ospf6_route_add (route, route_advertise);
972 prefix_num--;
paul718e3742002-12-13 20:15:29 +0000973 }
hasso1e058382004-09-01 21:36:14 +0000974 if (current != end && IS_OSPF6_DEBUG_ORIGINATE (INTRA_PREFIX))
hasso508e53e2004-05-18 18:57:06 +0000975 zlog_info ("Trailing garbage in %s", lsa->name);
paul718e3742002-12-13 20:15:29 +0000976 }
977
hasso508e53e2004-05-18 18:57:06 +0000978 op = (struct ospf6_prefix *)
979 ((caddr_t) intra_prefix_lsa + sizeof (struct ospf6_intra_prefix_lsa));
980
981 prefix_num = 0;
982 for (route = ospf6_route_head (route_advertise); route;
983 route = ospf6_route_best_next (route))
paul718e3742002-12-13 20:15:29 +0000984 {
hasso508e53e2004-05-18 18:57:06 +0000985 op->prefix_length = route->prefix.prefixlen;
986 op->prefix_options = route->path.prefix_options;
987 op->prefix_metric = htons (0);
988 memcpy (OSPF6_PREFIX_BODY (op), &route->prefix.u.prefix6,
989 OSPF6_PREFIX_SPACE (op->prefix_length));
990 op = OSPF6_PREFIX_NEXT (op);
991 prefix_num++;
992 }
993
994 ospf6_route_table_delete (route_advertise);
995
996 if (prefix_num == 0)
997 {
hasso1e058382004-09-01 21:36:14 +0000998 if (IS_OSPF6_DEBUG_ORIGINATE (INTRA_PREFIX))
hasso508e53e2004-05-18 18:57:06 +0000999 zlog_info ("Quit to Advertise Intra-Prefix: no route to advertise");
hasso6452df02004-08-15 05:52:07 +00001000 return 0;
paul718e3742002-12-13 20:15:29 +00001001 }
1002
hasso508e53e2004-05-18 18:57:06 +00001003 intra_prefix_lsa->prefix_num = htons (prefix_num);
paul718e3742002-12-13 20:15:29 +00001004
hasso508e53e2004-05-18 18:57:06 +00001005 /* Fill LSA Header */
1006 lsa_header->age = 0;
1007 lsa_header->type = htons (OSPF6_LSTYPE_INTRA_PREFIX);
1008 lsa_header->id = htonl (oi->interface->ifindex);
1009 lsa_header->adv_router = oi->area->ospf6->router_id;
1010 lsa_header->seqnum =
hasso049207c2004-08-04 20:02:13 +00001011 ospf6_new_ls_seqnum (lsa_header->type, lsa_header->id,
1012 lsa_header->adv_router, oi->area->lsdb);
hasso508e53e2004-05-18 18:57:06 +00001013 lsa_header->length = htons ((caddr_t) op - (caddr_t) lsa_header);
paul718e3742002-12-13 20:15:29 +00001014
hasso508e53e2004-05-18 18:57:06 +00001015 /* LSA checksum */
1016 ospf6_lsa_checksum (lsa_header);
paul718e3742002-12-13 20:15:29 +00001017
hasso508e53e2004-05-18 18:57:06 +00001018 /* create LSA */
1019 lsa = ospf6_lsa_create (lsa_header);
paul718e3742002-12-13 20:15:29 +00001020
hasso508e53e2004-05-18 18:57:06 +00001021 /* Originate */
hasso6452df02004-08-15 05:52:07 +00001022 ospf6_lsa_originate_area (lsa, oi->area);
paul718e3742002-12-13 20:15:29 +00001023
1024 return 0;
1025}
1026
1027void
hasso508e53e2004-05-18 18:57:06 +00001028ospf6_intra_prefix_lsa_add (struct ospf6_lsa *lsa)
paul718e3742002-12-13 20:15:29 +00001029{
hasso508e53e2004-05-18 18:57:06 +00001030 struct ospf6_area *oa;
1031 struct ospf6_intra_prefix_lsa *intra_prefix_lsa;
1032 struct prefix ls_prefix;
1033 struct ospf6_route *route, *ls_entry;
1034 int i, prefix_num;
1035 struct ospf6_prefix *op;
1036 char *start, *current, *end;
1037 char buf[64];
paul718e3742002-12-13 20:15:29 +00001038
hassoccb59b12004-08-25 09:10:37 +00001039 if (OSPF6_LSA_IS_MAXAGE (lsa))
1040 return;
1041
hasso1e058382004-09-01 21:36:14 +00001042 if (IS_OSPF6_DEBUG_EXAMIN (INTRA_PREFIX))
hasso508e53e2004-05-18 18:57:06 +00001043 zlog_info ("%s found", lsa->name);
paul718e3742002-12-13 20:15:29 +00001044
hasso6452df02004-08-15 05:52:07 +00001045 oa = OSPF6_AREA (lsa->lsdb->data);
1046
hasso508e53e2004-05-18 18:57:06 +00001047 intra_prefix_lsa = (struct ospf6_intra_prefix_lsa *)
1048 OSPF6_LSA_HEADER_END (lsa->header);
1049 if (intra_prefix_lsa->ref_type == htons (OSPF6_LSTYPE_ROUTER))
1050 ospf6_linkstate_prefix (intra_prefix_lsa->ref_adv_router,
1051 htonl (0), &ls_prefix);
1052 else if (intra_prefix_lsa->ref_type == htons (OSPF6_LSTYPE_NETWORK))
1053 ospf6_linkstate_prefix (intra_prefix_lsa->ref_adv_router,
1054 intra_prefix_lsa->ref_id, &ls_prefix);
1055 else
1056 {
hasso1e058382004-09-01 21:36:14 +00001057 if (IS_OSPF6_DEBUG_EXAMIN (INTRA_PREFIX))
hasso508e53e2004-05-18 18:57:06 +00001058 zlog_info ("Unknown reference LS-type: %#hx",
1059 ntohs (intra_prefix_lsa->ref_type));
1060 return;
1061 }
paul718e3742002-12-13 20:15:29 +00001062
hasso508e53e2004-05-18 18:57:06 +00001063 ls_entry = ospf6_route_lookup (&ls_prefix, oa->spf_table);
1064 if (ls_entry == NULL)
1065 {
hasso1e058382004-09-01 21:36:14 +00001066 if (IS_OSPF6_DEBUG_EXAMIN (INTRA_PREFIX))
hasso508e53e2004-05-18 18:57:06 +00001067 {
1068 ospf6_linkstate_prefix2str (&ls_prefix, buf, sizeof (buf));
1069 zlog_info ("LS entry does not exist: %s", buf);
1070 }
1071 return;
1072 }
paul718e3742002-12-13 20:15:29 +00001073
hasso508e53e2004-05-18 18:57:06 +00001074 prefix_num = ntohs (intra_prefix_lsa->prefix_num);
1075 start = (caddr_t) intra_prefix_lsa +
1076 sizeof (struct ospf6_intra_prefix_lsa);
1077 end = OSPF6_LSA_END (lsa->header);
1078 for (current = start; current < end; current += OSPF6_PREFIX_SIZE (op))
1079 {
1080 op = (struct ospf6_prefix *) current;
1081 if (prefix_num == 0)
1082 break;
1083 if (end < current + OSPF6_PREFIX_SIZE (op))
1084 break;
1085
1086 route = ospf6_route_create ();
hassoccb59b12004-08-25 09:10:37 +00001087
1088 memset (&route->prefix, 0, sizeof (struct prefix));
hasso508e53e2004-05-18 18:57:06 +00001089 route->prefix.family = AF_INET6;
hassoccb59b12004-08-25 09:10:37 +00001090 route->prefix.prefixlen = op->prefix_length;
1091 ospf6_prefix_in6_addr (&route->prefix.u.prefix6, op);
1092
hasso508e53e2004-05-18 18:57:06 +00001093 route->type = OSPF6_DEST_TYPE_NETWORK;
1094 route->path.origin.type = lsa->header->type;
1095 route->path.origin.id = lsa->header->id;
1096 route->path.origin.adv_router = lsa->header->adv_router;
1097 route->path.prefix_options = op->prefix_options;
1098 route->path.area_id = oa->area_id;
1099 route->path.type = OSPF6_PATH_TYPE_INTRA;
1100 route->path.metric_type = 1;
1101 route->path.cost = ls_entry->path.cost +
1102 ntohs (op->prefix_metric);
1103
1104 for (i = 0; ospf6_nexthop_is_set (&ls_entry->nexthop[i]) &&
1105 i < OSPF6_MULTI_PATH_LIMIT; i++)
1106 ospf6_nexthop_copy (&route->nexthop[i], &ls_entry->nexthop[i]);
1107
hasso1e058382004-09-01 21:36:14 +00001108 if (IS_OSPF6_DEBUG_EXAMIN (INTRA_PREFIX))
hasso508e53e2004-05-18 18:57:06 +00001109 {
1110 prefix2str (&route->prefix, buf, sizeof (buf));
1111 zlog_info (" add %s", buf);
1112 }
1113
1114 ospf6_route_add (route, oa->route_table);
1115 prefix_num--;
1116 }
1117
hasso1e058382004-09-01 21:36:14 +00001118 if (current != end && IS_OSPF6_DEBUG_EXAMIN (INTRA_PREFIX))
hasso508e53e2004-05-18 18:57:06 +00001119 zlog_info ("Trailing garbage ignored");
paul718e3742002-12-13 20:15:29 +00001120}
1121
1122void
hasso508e53e2004-05-18 18:57:06 +00001123ospf6_intra_prefix_lsa_remove (struct ospf6_lsa *lsa)
paul718e3742002-12-13 20:15:29 +00001124{
hasso508e53e2004-05-18 18:57:06 +00001125 struct ospf6_area *oa;
1126 struct ospf6_intra_prefix_lsa *intra_prefix_lsa;
1127 struct prefix prefix;
1128 struct ospf6_route *route;
1129 int prefix_num;
1130 struct ospf6_prefix *op;
1131 char *start, *current, *end;
1132 char buf[64];
1133
hasso1e058382004-09-01 21:36:14 +00001134 if (IS_OSPF6_DEBUG_EXAMIN (INTRA_PREFIX))
hasso508e53e2004-05-18 18:57:06 +00001135 zlog_info ("%s disappearing", lsa->name);
1136
hasso6452df02004-08-15 05:52:07 +00001137 oa = OSPF6_AREA (lsa->lsdb->data);
1138
hasso508e53e2004-05-18 18:57:06 +00001139 intra_prefix_lsa = (struct ospf6_intra_prefix_lsa *)
1140 OSPF6_LSA_HEADER_END (lsa->header);
1141
1142 prefix_num = ntohs (intra_prefix_lsa->prefix_num);
1143 start = (caddr_t) intra_prefix_lsa +
1144 sizeof (struct ospf6_intra_prefix_lsa);
1145 end = OSPF6_LSA_END (lsa->header);
1146 for (current = start; current < end; current += OSPF6_PREFIX_SIZE (op))
1147 {
1148 op = (struct ospf6_prefix *) current;
1149 if (prefix_num == 0)
1150 break;
1151 if (end < current + OSPF6_PREFIX_SIZE (op))
1152 break;
1153 prefix_num--;
1154
hassoccb59b12004-08-25 09:10:37 +00001155 memset (&prefix, 0, sizeof (struct prefix));
hasso508e53e2004-05-18 18:57:06 +00001156 prefix.family = AF_INET6;
1157 prefix.prefixlen = op->prefix_length;
1158 ospf6_prefix_in6_addr (&prefix.u.prefix6, op);
1159
1160 route = ospf6_route_lookup (&prefix, oa->route_table);
1161 if (route == NULL)
1162 continue;
1163
1164 for (ospf6_route_lock (route);
1165 route && ospf6_route_is_prefix (&prefix, route);
1166 route = ospf6_route_next (route))
1167 {
1168 if (route->type != OSPF6_DEST_TYPE_NETWORK)
1169 continue;
1170 if (route->path.area_id != oa->area_id)
1171 continue;
1172 if (route->path.type != OSPF6_PATH_TYPE_INTRA)
1173 continue;
1174 if (route->path.origin.type != lsa->header->type ||
1175 route->path.origin.id != lsa->header->id ||
1176 route->path.origin.adv_router != lsa->header->adv_router)
1177 continue;
1178
hasso1e058382004-09-01 21:36:14 +00001179 if (IS_OSPF6_DEBUG_EXAMIN (INTRA_PREFIX))
hasso508e53e2004-05-18 18:57:06 +00001180 {
1181 prefix2str (&route->prefix, buf, sizeof (buf));
1182 zlog_info ("remove %s", buf);
1183 }
1184 ospf6_route_remove (route, oa->route_table);
1185 }
1186 }
1187
hasso1e058382004-09-01 21:36:14 +00001188 if (current != end && IS_OSPF6_DEBUG_EXAMIN (INTRA_PREFIX))
hasso508e53e2004-05-18 18:57:06 +00001189 zlog_info ("Trailing garbage ignored");
paul718e3742002-12-13 20:15:29 +00001190}
1191
1192void
hasso508e53e2004-05-18 18:57:06 +00001193ospf6_intra_route_calculation (struct ospf6_area *oa)
paul718e3742002-12-13 20:15:29 +00001194{
hasso508e53e2004-05-18 18:57:06 +00001195 struct ospf6_route *route;
1196 u_int16_t type;
1197 struct ospf6_lsa *lsa;
1198 void (*hook_add) (struct ospf6_route *) = NULL;
1199 void (*hook_remove) (struct ospf6_route *) = NULL;
1200
hasso1e058382004-09-01 21:36:14 +00001201 if (IS_OSPF6_DEBUG_EXAMIN (INTRA_PREFIX))
1202 zlog_info ("Re-examin intra-routes for area %s", oa->name);
hasso508e53e2004-05-18 18:57:06 +00001203
1204 hook_add = oa->route_table->hook_add;
1205 hook_remove = oa->route_table->hook_remove;
1206 oa->route_table->hook_add = NULL;
1207 oa->route_table->hook_remove = NULL;
1208
1209 for (route = ospf6_route_head (oa->route_table); route;
1210 route = ospf6_route_next (route))
1211 route->flag = OSPF6_ROUTE_REMOVE;
1212
1213 type = htons (OSPF6_LSTYPE_INTRA_PREFIX);
1214 for (lsa = ospf6_lsdb_type_head (type, oa->lsdb); lsa;
1215 lsa = ospf6_lsdb_type_next (type, lsa))
1216 ospf6_intra_prefix_lsa_add (lsa);
1217
1218 oa->route_table->hook_add = hook_add;
1219 oa->route_table->hook_remove = hook_remove;
1220
1221 for (route = ospf6_route_head (oa->route_table); route;
1222 route = ospf6_route_next (route))
1223 {
1224 if (CHECK_FLAG (route->flag, OSPF6_ROUTE_REMOVE) &&
1225 CHECK_FLAG (route->flag, OSPF6_ROUTE_ADD))
1226 {
1227 UNSET_FLAG (route->flag, OSPF6_ROUTE_REMOVE);
1228 UNSET_FLAG (route->flag, OSPF6_ROUTE_ADD);
1229 }
1230
1231 if (CHECK_FLAG (route->flag, OSPF6_ROUTE_REMOVE))
1232 ospf6_route_remove (route, oa->route_table);
1233 else if (CHECK_FLAG (route->flag, OSPF6_ROUTE_ADD) ||
1234 CHECK_FLAG (route->flag, OSPF6_ROUTE_CHANGE))
1235 {
1236 if (hook_add)
1237 (*hook_add) (route);
1238 }
1239
1240 route->flag = 0;
1241 }
1242
hasso1e058382004-09-01 21:36:14 +00001243 if (IS_OSPF6_DEBUG_EXAMIN (INTRA_PREFIX))
1244 zlog_info ("Re-examin intra-routes for area %s: Done", oa->name);
hasso508e53e2004-05-18 18:57:06 +00001245}
1246
1247void
hasso6452df02004-08-15 05:52:07 +00001248ospf6_intra_brouter_calculation (struct ospf6_area *oa)
hasso508e53e2004-05-18 18:57:06 +00001249{
1250 struct ospf6_route *lsentry, *copy;
1251 void (*hook_add) (struct ospf6_route *) = NULL;
1252 void (*hook_remove) (struct ospf6_route *) = NULL;
hassoccb59b12004-08-25 09:10:37 +00001253 char buf[16];
hasso508e53e2004-05-18 18:57:06 +00001254
hasso6452df02004-08-15 05:52:07 +00001255 if (IS_OSPF6_DEBUG_ROUTE (INTRA))
1256 zlog_info ("Border-router calculation for area %s", oa->name);
hasso508e53e2004-05-18 18:57:06 +00001257
hasso6452df02004-08-15 05:52:07 +00001258 hook_add = oa->ospf6->brouter_table->hook_add;
1259 hook_remove = oa->ospf6->brouter_table->hook_remove;
1260 oa->ospf6->brouter_table->hook_add = NULL;
1261 oa->ospf6->brouter_table->hook_remove = NULL;
hasso508e53e2004-05-18 18:57:06 +00001262
hasso6452df02004-08-15 05:52:07 +00001263 /* withdraw the previous router entries for the area */
1264 for (lsentry = ospf6_route_head (oa->ospf6->brouter_table); lsentry;
hasso508e53e2004-05-18 18:57:06 +00001265 lsentry = ospf6_route_next (lsentry))
1266 {
1267 if (lsentry->path.area_id != oa->area_id)
1268 continue;
1269 lsentry->flag = OSPF6_ROUTE_REMOVE;
1270 }
1271
1272 for (lsentry = ospf6_route_head (oa->spf_table); lsentry;
1273 lsentry = ospf6_route_next (lsentry))
1274 {
1275 if (lsentry->type != OSPF6_DEST_TYPE_LINKSTATE)
1276 continue;
1277 if (ospf6_linkstate_prefix_id (&lsentry->prefix) != htonl (0))
1278 continue;
hasso6452df02004-08-15 05:52:07 +00001279 if (! CHECK_FLAG (lsentry->path.router_bits, OSPF6_ROUTER_BIT_E) &&
1280 ! CHECK_FLAG (lsentry->path.router_bits, OSPF6_ROUTER_BIT_B))
hasso508e53e2004-05-18 18:57:06 +00001281 continue;
1282
1283 copy = ospf6_route_copy (lsentry);
1284 copy->type = OSPF6_DEST_TYPE_ROUTER;
hassoccb59b12004-08-25 09:10:37 +00001285 copy->path.area_id = oa->area_id;
hasso6452df02004-08-15 05:52:07 +00001286 ospf6_route_add (copy, oa->ospf6->brouter_table);
hassoccb59b12004-08-25 09:10:37 +00001287
1288 if (IS_OSPF6_DEBUG_ROUTE (INTRA))
1289 {
1290 inet_ntop (AF_INET, &ADV_ROUTER_IN_PREFIX (&copy->prefix),
1291 buf, sizeof (buf));
1292 zlog_info ("Re-install router entry %s", buf);
1293 }
hasso508e53e2004-05-18 18:57:06 +00001294 }
1295
hasso6452df02004-08-15 05:52:07 +00001296 oa->ospf6->brouter_table->hook_add = hook_add;
1297 oa->ospf6->brouter_table->hook_remove = hook_remove;
hasso508e53e2004-05-18 18:57:06 +00001298
hasso6452df02004-08-15 05:52:07 +00001299 for (lsentry = ospf6_route_head (oa->ospf6->brouter_table); lsentry;
hasso508e53e2004-05-18 18:57:06 +00001300 lsentry = ospf6_route_next (lsentry))
1301 {
1302 if (lsentry->path.area_id != oa->area_id)
1303 continue;
1304
hasso9428f2d2004-09-13 14:01:12 +00001305 if (CHECK_FLAG (lsentry->flag, OSPF6_ROUTE_WAS_REMOVED))
1306 continue;
1307
hasso508e53e2004-05-18 18:57:06 +00001308 if (CHECK_FLAG (lsentry->flag, OSPF6_ROUTE_REMOVE) &&
1309 CHECK_FLAG (lsentry->flag, OSPF6_ROUTE_ADD))
1310 {
1311 UNSET_FLAG (lsentry->flag, OSPF6_ROUTE_REMOVE);
1312 UNSET_FLAG (lsentry->flag, OSPF6_ROUTE_ADD);
1313 }
1314
1315 if (CHECK_FLAG (lsentry->flag, OSPF6_ROUTE_REMOVE))
hasso6452df02004-08-15 05:52:07 +00001316 ospf6_route_remove (lsentry, oa->ospf6->brouter_table);
hasso508e53e2004-05-18 18:57:06 +00001317 else if (CHECK_FLAG (lsentry->flag, OSPF6_ROUTE_ADD) ||
1318 CHECK_FLAG (lsentry->flag, OSPF6_ROUTE_CHANGE))
1319 {
hassoccb59b12004-08-25 09:10:37 +00001320 if (IS_OSPF6_DEBUG_ROUTE (INTRA))
1321 {
1322 inet_ntop (AF_INET, &ADV_ROUTER_IN_PREFIX (&lsentry->prefix),
1323 buf, sizeof (buf));
1324 zlog_info ("Call hook for router entry %s", buf);
1325 }
hasso508e53e2004-05-18 18:57:06 +00001326 if (hook_add)
1327 (*hook_add) (lsentry);
1328 }
1329
1330 lsentry->flag = 0;
1331 }
1332
hasso6452df02004-08-15 05:52:07 +00001333 if (IS_OSPF6_DEBUG_ROUTE (INTRA))
1334 zlog_info ("Border-router calculation for area %s: Done", oa->name);
paul718e3742002-12-13 20:15:29 +00001335}
1336
hasso6452df02004-08-15 05:52:07 +00001337struct ospf6_lsa_handler router_handler =
1338{
1339 OSPF6_LSTYPE_ROUTER,
1340 "Router",
1341 ospf6_router_lsa_show
1342};
1343
1344struct ospf6_lsa_handler network_handler =
1345{
1346 OSPF6_LSTYPE_NETWORK,
1347 "Network",
1348 ospf6_network_lsa_show
1349};
1350
1351struct ospf6_lsa_handler link_handler =
1352{
1353 OSPF6_LSTYPE_LINK,
1354 "Link",
1355 ospf6_link_lsa_show
1356};
1357
1358struct ospf6_lsa_handler intra_prefix_handler =
1359{
1360 OSPF6_LSTYPE_INTRA_PREFIX,
1361 "Intra-Prefix",
1362 ospf6_intra_prefix_lsa_show
1363};
1364
paul718e3742002-12-13 20:15:29 +00001365void
1366ospf6_intra_init ()
1367{
hasso6452df02004-08-15 05:52:07 +00001368 ospf6_install_lsa_handler (&router_handler);
1369 ospf6_install_lsa_handler (&network_handler);
1370 ospf6_install_lsa_handler (&link_handler);
1371 ospf6_install_lsa_handler (&intra_prefix_handler);
paul718e3742002-12-13 20:15:29 +00001372}
1373
1374