blob: 6cc6f4dec892e8efb7a531057e609c5c60dbf165 [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
22#include <zebra.h>
23
24/* Include other stuffs */
paul718e3742002-12-13 20:15:29 +000025#include "log.h"
paul718e3742002-12-13 20:15:29 +000026#include "linklist.h"
hasso1e058382004-09-01 21:36:14 +000027#include "vector.h"
28#include "vty.h"
paul718e3742002-12-13 20:15:29 +000029#include "command.h"
30#include "memory.h"
paul718e3742002-12-13 20:15:29 +000031#include "thread.h"
paul718e3742002-12-13 20:15:29 +000032
33#include "ospf6_proto.h"
paul718e3742002-12-13 20:15:29 +000034#include "ospf6_lsa.h"
35#include "ospf6_lsdb.h"
36#include "ospf6_message.h"
paul718e3742002-12-13 20:15:29 +000037
38#include "ospf6_top.h"
39#include "ospf6_area.h"
40#include "ospf6_interface.h"
41#include "ospf6_neighbor.h"
paul718e3742002-12-13 20:15:29 +000042
hasso508e53e2004-05-18 18:57:06 +000043#include "ospf6_flood.h"
hasso049207c2004-08-04 20:02:13 +000044#include "ospf6d.h"
paul718e3742002-12-13 20:15:29 +000045
hasso1e058382004-09-01 21:36:14 +000046vector ospf6_lsa_handler_vector;
hasso508e53e2004-05-18 18:57:06 +000047
hasso1e058382004-09-01 21:36:14 +000048int
49ospf6_unknown_lsa_show (struct vty *vty, struct ospf6_lsa *lsa)
50{
51 u_char *start, *end, *current;
52 char byte[4];
hasso508e53e2004-05-18 18:57:06 +000053
hasso1e058382004-09-01 21:36:14 +000054 start = (char *) lsa->header + sizeof (struct ospf6_lsa_header);
55 end = (char *) lsa->header + ntohs (lsa->header->length);
56
57 vty_out (vty, " Unknown contents:%s", VNL);
58 for (current = start; current < end; current ++)
59 {
60 if ((current - start) % 16 == 0)
61 vty_out (vty, "%s ", VNL);
62 else if ((current - start) % 4 == 0)
63 vty_out (vty, " ");
64
65 snprintf (byte, sizeof (byte), "%02x", *current);
66 vty_out (vty, "%s", byte);
67 }
68
69 vty_out (vty, "%s%s", VNL, VNL);
70 return 0;
71}
72
73struct ospf6_lsa_handler unknown_handler =
74{
75 OSPF6_LSTYPE_UNKNOWN,
76 "Unknown",
77 ospf6_unknown_lsa_show,
78 OSPF6_LSA_DEBUG,
79};
80
81void
82ospf6_install_lsa_handler (struct ospf6_lsa_handler *handler)
83{
84 /* type in handler is host byte order */
85 int index = handler->type & OSPF6_LSTYPE_FCODE_MASK;
86 vector_set_index (ospf6_lsa_handler_vector, index, handler);
87}
88
89struct ospf6_lsa_handler *
90ospf6_get_lsa_handler (u_int16_t type)
91{
92 struct ospf6_lsa_handler *handler = NULL;
93 int index = ntohs (type) & OSPF6_LSTYPE_FCODE_MASK;
94
95 if (index >= vector_max (ospf6_lsa_handler_vector))
96 handler = &unknown_handler;
97 else
98 handler = vector_slot (ospf6_lsa_handler_vector, index);
99
100 return handler;
101}
hasso508e53e2004-05-18 18:57:06 +0000102
103char *
104ospf6_lstype_name (u_int16_t type)
paul718e3742002-12-13 20:15:29 +0000105{
hasso508e53e2004-05-18 18:57:06 +0000106 static char buf[8];
hasso1e058382004-09-01 21:36:14 +0000107 struct ospf6_lsa_handler *handler;
paul718e3742002-12-13 20:15:29 +0000108
hasso1e058382004-09-01 21:36:14 +0000109 handler = ospf6_get_lsa_handler (type);
110 if (handler && handler != &unknown_handler)
111 return handler->name;
paul718e3742002-12-13 20:15:29 +0000112
hasso508e53e2004-05-18 18:57:06 +0000113 snprintf (buf, sizeof (buf), "0x%04hx", ntohs (type));
114 return buf;
paul718e3742002-12-13 20:15:29 +0000115}
116
hasso1e058382004-09-01 21:36:14 +0000117u_char
118ospf6_lstype_debug (u_int16_t type)
119{
120 struct ospf6_lsa_handler *handler;
121 handler = ospf6_get_lsa_handler (type);
122 return handler->debug;
123}
124
paul718e3742002-12-13 20:15:29 +0000125/* RFC2328: Section 13.2 */
126int
hasso508e53e2004-05-18 18:57:06 +0000127ospf6_lsa_is_differ (struct ospf6_lsa *lsa1,
128 struct ospf6_lsa *lsa2)
paul718e3742002-12-13 20:15:29 +0000129{
hasso508e53e2004-05-18 18:57:06 +0000130 int len;
paul718e3742002-12-13 20:15:29 +0000131
hasso508e53e2004-05-18 18:57:06 +0000132 assert (OSPF6_LSA_IS_SAME (lsa1, lsa2));
paul718e3742002-12-13 20:15:29 +0000133
hasso508e53e2004-05-18 18:57:06 +0000134 /* XXX, Options ??? */
paul718e3742002-12-13 20:15:29 +0000135
136 ospf6_lsa_age_current (lsa1);
137 ospf6_lsa_age_current (lsa2);
138 if (ntohs (lsa1->header->age) == MAXAGE &&
139 ntohs (lsa2->header->age) != MAXAGE)
140 return 1;
141 if (ntohs (lsa1->header->age) != MAXAGE &&
142 ntohs (lsa2->header->age) == MAXAGE)
143 return 1;
144
145 /* compare body */
146 if (ntohs (lsa1->header->length) != ntohs (lsa2->header->length))
147 return 1;
148
hasso508e53e2004-05-18 18:57:06 +0000149 len = ntohs (lsa1->header->length) - sizeof (struct ospf6_lsa_header);
150 return memcmp (lsa1->header + 1, lsa2->header + 1, len);
paul718e3742002-12-13 20:15:29 +0000151}
152
153int
hasso508e53e2004-05-18 18:57:06 +0000154ospf6_lsa_is_changed (struct ospf6_lsa *lsa1,
155 struct ospf6_lsa *lsa2)
paul718e3742002-12-13 20:15:29 +0000156{
hasso508e53e2004-05-18 18:57:06 +0000157 int length;
paul718e3742002-12-13 20:15:29 +0000158
hasso508e53e2004-05-18 18:57:06 +0000159 if (OSPF6_LSA_IS_MAXAGE (lsa1) ^ OSPF6_LSA_IS_MAXAGE (lsa2))
160 return 1;
161 if (ntohs (lsa1->header->length) != ntohs (lsa2->header->length))
162 return 1;
paul718e3742002-12-13 20:15:29 +0000163
hasso508e53e2004-05-18 18:57:06 +0000164 length = OSPF6_LSA_SIZE (lsa1->header) - sizeof (struct ospf6_lsa_header);
165 assert (length > 0);
paul718e3742002-12-13 20:15:29 +0000166
hasso508e53e2004-05-18 18:57:06 +0000167 return memcmp (OSPF6_LSA_HEADER_END (lsa1->header),
168 OSPF6_LSA_HEADER_END (lsa2->header), length);
paul718e3742002-12-13 20:15:29 +0000169}
170
171/* ospf6 age functions */
hasso3b687352004-08-19 06:56:53 +0000172/* calculate birth */
paul718e3742002-12-13 20:15:29 +0000173static void
174ospf6_lsa_age_set (struct ospf6_lsa *lsa)
175{
176 struct timeval now;
177
178 assert (lsa && lsa->header);
179
180 if (gettimeofday (&now, (struct timezone *)NULL) < 0)
181 zlog_warn ("LSA: gettimeofday failed, may fail LSA AGEs: %s",
182 strerror (errno));
183
184 lsa->birth.tv_sec = now.tv_sec - ntohs (lsa->header->age);
185 lsa->birth.tv_usec = now.tv_usec;
hasso3b687352004-08-19 06:56:53 +0000186
paul718e3742002-12-13 20:15:29 +0000187 return;
188}
189
190/* this function calculates current age from its birth,
191 then update age field of LSA header. return value is current age */
192u_int16_t
193ospf6_lsa_age_current (struct ospf6_lsa *lsa)
194{
195 struct timeval now;
196 u_int32_t ulage;
197 u_int16_t age;
198
199 assert (lsa);
200 assert (lsa->header);
201
202 /* current time */
203 if (gettimeofday (&now, (struct timezone *)NULL) < 0)
hasso508e53e2004-05-18 18:57:06 +0000204 zlog_warn ("LSA: gettimeofday failed, may fail LSA AGEs: %s",
paul718e3742002-12-13 20:15:29 +0000205 strerror (errno));
206
207 /* calculate age */
208 ulage = now.tv_sec - lsa->birth.tv_sec;
209
210 /* if over MAXAGE, set to it */
hasso508e53e2004-05-18 18:57:06 +0000211 age = (ulage > MAXAGE ? MAXAGE : ulage);
paul718e3742002-12-13 20:15:29 +0000212
213 lsa->header->age = htons (age);
214 return age;
215}
216
217/* update age field of LSA header with adding InfTransDelay */
218void
219ospf6_lsa_age_update_to_send (struct ospf6_lsa *lsa, u_int32_t transdelay)
220{
221 unsigned short age;
222
223 age = ospf6_lsa_age_current (lsa) + transdelay;
224 if (age > MAXAGE)
225 age = MAXAGE;
226 lsa->header->age = htons (age);
paul718e3742002-12-13 20:15:29 +0000227}
228
229void
230ospf6_lsa_premature_aging (struct ospf6_lsa *lsa)
231{
232 /* log */
hasso1e058382004-09-01 21:36:14 +0000233 if (IS_OSPF6_DEBUG_LSA_TYPE (lsa->header->type))
hasso508e53e2004-05-18 18:57:06 +0000234 zlog_info ("LSA: Premature aging: %s", lsa->name);
paul718e3742002-12-13 20:15:29 +0000235
hasso508e53e2004-05-18 18:57:06 +0000236 THREAD_OFF (lsa->expire);
237 THREAD_OFF (lsa->refresh);
paul718e3742002-12-13 20:15:29 +0000238
239 memset (&lsa->birth, 0, sizeof (struct timeval));
240 thread_execute (master, ospf6_lsa_expire, lsa, 0);
241}
242
243/* check which is more recent. if a is more recent, return -1;
244 if the same, return 0; otherwise(b is more recent), return 1 */
245int
hasso508e53e2004-05-18 18:57:06 +0000246ospf6_lsa_compare (struct ospf6_lsa *a, struct ospf6_lsa *b)
paul718e3742002-12-13 20:15:29 +0000247{
248 signed long seqnuma, seqnumb;
249 u_int16_t cksuma, cksumb;
250 u_int16_t agea, ageb;
251
252 assert (a && a->header);
253 assert (b && b->header);
hasso508e53e2004-05-18 18:57:06 +0000254 assert (OSPF6_LSA_IS_SAME (a, b));
paul718e3742002-12-13 20:15:29 +0000255
256 seqnuma = ((signed long) ntohl (a->header->seqnum))
257 - (signed long) INITIAL_SEQUENCE_NUMBER;
258 seqnumb = ((signed long) ntohl (b->header->seqnum))
259 - (signed long) INITIAL_SEQUENCE_NUMBER;
260
261 /* compare by sequence number */
hasso508e53e2004-05-18 18:57:06 +0000262 /* XXX, LS sequence number wrapping */
paul718e3742002-12-13 20:15:29 +0000263 if (seqnuma > seqnumb)
264 return -1;
265 else if (seqnuma < seqnumb)
266 return 1;
267
268 /* Checksum */
269 cksuma = ntohs (a->header->checksum);
270 cksumb = ntohs (b->header->checksum);
271 if (cksuma > cksumb)
272 return -1;
273 if (cksuma < cksumb)
274 return 0;
275
hasso508e53e2004-05-18 18:57:06 +0000276 /* Update Age */
paul718e3742002-12-13 20:15:29 +0000277 agea = ospf6_lsa_age_current (a);
278 ageb = ospf6_lsa_age_current (b);
279
hasso508e53e2004-05-18 18:57:06 +0000280 /* MaxAge check */
281 if (agea == MAXAGE && ageb != MAXAGE)
paul718e3742002-12-13 20:15:29 +0000282 return -1;
hasso508e53e2004-05-18 18:57:06 +0000283 else if (agea != MAXAGE && ageb == MAXAGE)
paul718e3742002-12-13 20:15:29 +0000284 return 1;
285
hasso508e53e2004-05-18 18:57:06 +0000286 /* Age check */
287 if (agea > ageb && agea - ageb >= MAX_AGE_DIFF)
paul718e3742002-12-13 20:15:29 +0000288 return 1;
hasso508e53e2004-05-18 18:57:06 +0000289 else if (agea < ageb && ageb - agea >= MAX_AGE_DIFF)
paul718e3742002-12-13 20:15:29 +0000290 return -1;
291
292 /* neither recent */
paul718e3742002-12-13 20:15:29 +0000293 return 0;
294}
295
hasso508e53e2004-05-18 18:57:06 +0000296char *
297ospf6_lsa_printbuf (struct ospf6_lsa *lsa, char *buf, int size)
paul718e3742002-12-13 20:15:29 +0000298{
hasso508e53e2004-05-18 18:57:06 +0000299 char id[16], adv_router[16];
300 inet_ntop (AF_INET, &lsa->header->id, id, sizeof (id));
301 inet_ntop (AF_INET, &lsa->header->adv_router, adv_router,
302 sizeof (adv_router));
303 snprintf (buf, size, "[%s Id:%s Adv:%s]",
hasso1e058382004-09-01 21:36:14 +0000304 ospf6_lstype_name (lsa->header->type), id, adv_router);
hasso508e53e2004-05-18 18:57:06 +0000305 return buf;
paul718e3742002-12-13 20:15:29 +0000306}
307
hasso508e53e2004-05-18 18:57:06 +0000308void
309ospf6_lsa_header_print_raw (struct ospf6_lsa_header *header)
paul718e3742002-12-13 20:15:29 +0000310{
hasso508e53e2004-05-18 18:57:06 +0000311 char id[16], adv_router[16];
312 inet_ntop (AF_INET, &header->id, id, sizeof (id));
313 inet_ntop (AF_INET, &header->adv_router, adv_router,
314 sizeof (adv_router));
315 zlog_info (" [%s Id:%s Adv:%s]",
hasso1e058382004-09-01 21:36:14 +0000316 ospf6_lstype_name (header->type), id, adv_router);
hasso508e53e2004-05-18 18:57:06 +0000317 zlog_info (" Age: %4hu SeqNum: %#08lx Cksum: %04hx Len: %d",
318 ntohs (header->age), (u_long) ntohl (header->seqnum),
319 ntohs (header->checksum), ntohs (header->length));
paul718e3742002-12-13 20:15:29 +0000320}
321
hasso508e53e2004-05-18 18:57:06 +0000322void
323ospf6_lsa_header_print (struct ospf6_lsa *lsa)
paul718e3742002-12-13 20:15:29 +0000324{
hasso508e53e2004-05-18 18:57:06 +0000325 ospf6_lsa_age_current (lsa);
326 ospf6_lsa_header_print_raw (lsa->header);
paul718e3742002-12-13 20:15:29 +0000327}
328
329void
paul718e3742002-12-13 20:15:29 +0000330ospf6_lsa_show_summary_header (struct vty *vty)
331{
332 vty_out (vty, "%-12s %-15s %-15s %4s %8s %4s %4s %-8s%s",
333 "Type", "LSId", "AdvRouter", "Age", "SeqNum",
hasso049207c2004-08-04 20:02:13 +0000334 "Cksm", "Len", "Duration", VNL);
paul718e3742002-12-13 20:15:29 +0000335}
336
337void
338ospf6_lsa_show_summary (struct vty *vty, struct ospf6_lsa *lsa)
339{
hasso508e53e2004-05-18 18:57:06 +0000340 char adv_router[16], id[16];
paul718e3742002-12-13 20:15:29 +0000341 struct timeval now, res;
342 char duration[16];
343
344 assert (lsa);
345 assert (lsa->header);
346
paul718e3742002-12-13 20:15:29 +0000347 inet_ntop (AF_INET, &lsa->header->id, id, sizeof (id));
348 inet_ntop (AF_INET, &lsa->header->adv_router, adv_router,
349 sizeof (adv_router));
350
351 gettimeofday (&now, NULL);
hasso508e53e2004-05-18 18:57:06 +0000352 timersub (&now, &lsa->installed, &res);
353 timerstring (&res, duration, sizeof (duration));
paul718e3742002-12-13 20:15:29 +0000354
355 vty_out (vty, "%-12s %-15s %-15s %4hu %8lx %04hx %4hu %8s%s",
hasso1e058382004-09-01 21:36:14 +0000356 ospf6_lstype_name (lsa->header->type),
hasso508e53e2004-05-18 18:57:06 +0000357 id, adv_router, ospf6_lsa_age_current (lsa),
paul718e3742002-12-13 20:15:29 +0000358 (u_long) ntohl (lsa->header->seqnum),
359 ntohs (lsa->header->checksum), ntohs (lsa->header->length),
hasso049207c2004-08-04 20:02:13 +0000360 duration, VNL);
paul718e3742002-12-13 20:15:29 +0000361}
362
363void
364ospf6_lsa_show_dump (struct vty *vty, struct ospf6_lsa *lsa)
365{
366 u_char *start, *end, *current;
367 char byte[4];
368
369 start = (char *) lsa->header;
370 end = (char *) lsa->header + ntohs (lsa->header->length);
371
hasso049207c2004-08-04 20:02:13 +0000372 vty_out (vty, "%s", VNL);
373 vty_out (vty, "%s:%s", lsa->name, VNL);
paul718e3742002-12-13 20:15:29 +0000374
375 for (current = start; current < end; current ++)
376 {
377 if ((current - start) % 16 == 0)
hasso049207c2004-08-04 20:02:13 +0000378 vty_out (vty, "%s ", VNL);
paul718e3742002-12-13 20:15:29 +0000379 else if ((current - start) % 4 == 0)
380 vty_out (vty, " ");
381
382 snprintf (byte, sizeof (byte), "%02x", *current);
383 vty_out (vty, "%s", byte);
384 }
385
hasso049207c2004-08-04 20:02:13 +0000386 vty_out (vty, "%s%s", VNL, VNL);
hasso6452df02004-08-15 05:52:07 +0000387 return;
paul718e3742002-12-13 20:15:29 +0000388}
389
hasso508e53e2004-05-18 18:57:06 +0000390void
391ospf6_lsa_show_internal (struct vty *vty, struct ospf6_lsa *lsa)
392{
393 char adv_router[64], id[64];
394
395 assert (lsa && lsa->header);
396
397 inet_ntop (AF_INET, &lsa->header->id, id, sizeof (id));
398 inet_ntop (AF_INET, &lsa->header->adv_router,
399 adv_router, sizeof (adv_router));
400
hasso049207c2004-08-04 20:02:13 +0000401 vty_out (vty, "%s", VNL);
hasso508e53e2004-05-18 18:57:06 +0000402 vty_out (vty, "Age: %4hu Type: %s%s", ospf6_lsa_age_current (lsa),
hasso1e058382004-09-01 21:36:14 +0000403 ospf6_lstype_name (lsa->header->type), VNL);
hasso049207c2004-08-04 20:02:13 +0000404 vty_out (vty, "Link State ID: %s%s", id, VNL);
405 vty_out (vty, "Advertising Router: %s%s", adv_router, VNL);
hasso508e53e2004-05-18 18:57:06 +0000406 vty_out (vty, "LS Sequence Number: %#010lx%s",
hasso049207c2004-08-04 20:02:13 +0000407 (u_long) ntohl (lsa->header->seqnum), VNL);
hasso508e53e2004-05-18 18:57:06 +0000408 vty_out (vty, "CheckSum: %#06hx Length: %hu%s",
409 ntohs (lsa->header->checksum),
hasso049207c2004-08-04 20:02:13 +0000410 ntohs (lsa->header->length), VNL);
hasso508e53e2004-05-18 18:57:06 +0000411 vty_out (vty, " Prev: %p This: %p Next: %p%s",
hasso049207c2004-08-04 20:02:13 +0000412 lsa->prev, lsa, lsa->next, VNL);
413 vty_out (vty, "%s", VNL);
hasso6452df02004-08-15 05:52:07 +0000414 return;
415}
416
417void
418ospf6_lsa_show (struct vty *vty, struct ospf6_lsa *lsa)
419{
420 char adv_router[64], id[64];
hasso1e058382004-09-01 21:36:14 +0000421 struct ospf6_lsa_handler *handler;
hasso6452df02004-08-15 05:52:07 +0000422
423 assert (lsa && lsa->header);
424
425 inet_ntop (AF_INET, &lsa->header->id, id, sizeof (id));
426 inet_ntop (AF_INET, &lsa->header->adv_router,
427 adv_router, sizeof (adv_router));
428
429 vty_out (vty, "Age: %4hu Type: %s%s", ospf6_lsa_age_current (lsa),
hasso1e058382004-09-01 21:36:14 +0000430 ospf6_lstype_name (lsa->header->type), VNL);
hasso6452df02004-08-15 05:52:07 +0000431 vty_out (vty, "Link State ID: %s%s", id, VNL);
432 vty_out (vty, "Advertising Router: %s%s", adv_router, VNL);
433 vty_out (vty, "LS Sequence Number: %#010lx%s",
434 (u_long) ntohl (lsa->header->seqnum), VNL);
435 vty_out (vty, "CheckSum: %#06hx Length: %hu%s",
436 ntohs (lsa->header->checksum),
437 ntohs (lsa->header->length), VNL);
438
hasso1e058382004-09-01 21:36:14 +0000439 handler = ospf6_get_lsa_handler (lsa->header->type);
440 if (handler->show == NULL)
441 handler = &unknown_handler;
442 (*handler->show) (vty, lsa);
hasso6452df02004-08-15 05:52:07 +0000443
444 vty_out (vty, "%s", VNL);
hasso508e53e2004-05-18 18:57:06 +0000445}
446
paul718e3742002-12-13 20:15:29 +0000447/* OSPFv3 LSA creation/deletion function */
paul718e3742002-12-13 20:15:29 +0000448struct ospf6_lsa *
hasso508e53e2004-05-18 18:57:06 +0000449ospf6_lsa_create (struct ospf6_lsa_header *header)
paul718e3742002-12-13 20:15:29 +0000450{
451 struct ospf6_lsa *lsa = NULL;
hasso508e53e2004-05-18 18:57:06 +0000452 struct ospf6_lsa_header *new_header = NULL;
paul718e3742002-12-13 20:15:29 +0000453 u_int16_t lsa_size = 0;
paul718e3742002-12-13 20:15:29 +0000454
hasso508e53e2004-05-18 18:57:06 +0000455 /* size of the entire LSA */
456 lsa_size = ntohs (header->length); /* XXX vulnerable */
paul718e3742002-12-13 20:15:29 +0000457
458 /* allocate memory for this LSA */
hasso508e53e2004-05-18 18:57:06 +0000459 new_header = (struct ospf6_lsa_header *)
paul718e3742002-12-13 20:15:29 +0000460 XMALLOC (MTYPE_OSPF6_LSA, lsa_size);
paul718e3742002-12-13 20:15:29 +0000461
hasso508e53e2004-05-18 18:57:06 +0000462 /* copy LSA from original header */
463 memcpy (new_header, header, lsa_size);
paul718e3742002-12-13 20:15:29 +0000464
465 /* LSA information structure */
466 /* allocate memory */
467 lsa = (struct ospf6_lsa *)
hasso508e53e2004-05-18 18:57:06 +0000468 XMALLOC (MTYPE_OSPF6_LSA, sizeof (struct ospf6_lsa));
paul718e3742002-12-13 20:15:29 +0000469 memset (lsa, 0, sizeof (struct ospf6_lsa));
470
hasso508e53e2004-05-18 18:57:06 +0000471 lsa->header = (struct ospf6_lsa_header *) new_header;
paul718e3742002-12-13 20:15:29 +0000472
473 /* dump string */
hasso508e53e2004-05-18 18:57:06 +0000474 ospf6_lsa_printbuf (lsa, lsa->name, sizeof (lsa->name));
paul718e3742002-12-13 20:15:29 +0000475
hasso3b687352004-08-19 06:56:53 +0000476 /* calculate birth of this lsa */
paul718e3742002-12-13 20:15:29 +0000477 ospf6_lsa_age_set (lsa);
478
paul718e3742002-12-13 20:15:29 +0000479 return lsa;
480}
481
482struct ospf6_lsa *
hasso508e53e2004-05-18 18:57:06 +0000483ospf6_lsa_create_headeronly (struct ospf6_lsa_header *header)
paul718e3742002-12-13 20:15:29 +0000484{
485 struct ospf6_lsa *lsa = NULL;
hasso508e53e2004-05-18 18:57:06 +0000486 struct ospf6_lsa_header *new_header = NULL;
paul718e3742002-12-13 20:15:29 +0000487
488 /* allocate memory for this LSA */
hasso508e53e2004-05-18 18:57:06 +0000489 new_header = (struct ospf6_lsa_header *)
490 XMALLOC (MTYPE_OSPF6_LSA, sizeof (struct ospf6_lsa_header));
paul718e3742002-12-13 20:15:29 +0000491
hasso508e53e2004-05-18 18:57:06 +0000492 /* copy LSA from original header */
493 memcpy (new_header, header, sizeof (struct ospf6_lsa_header));
paul718e3742002-12-13 20:15:29 +0000494
495 /* LSA information structure */
496 /* allocate memory */
497 lsa = (struct ospf6_lsa *)
hasso508e53e2004-05-18 18:57:06 +0000498 XMALLOC (MTYPE_OSPF6_LSA, sizeof (struct ospf6_lsa));
paul718e3742002-12-13 20:15:29 +0000499 memset (lsa, 0, sizeof (struct ospf6_lsa));
500
hasso508e53e2004-05-18 18:57:06 +0000501 lsa->header = (struct ospf6_lsa_header *) new_header;
hasso6452df02004-08-15 05:52:07 +0000502 SET_FLAG (lsa->flag, OSPF6_LSA_HEADERONLY);
paul718e3742002-12-13 20:15:29 +0000503
504 /* dump string */
hasso508e53e2004-05-18 18:57:06 +0000505 ospf6_lsa_printbuf (lsa, lsa->name, sizeof (lsa->name));
paul718e3742002-12-13 20:15:29 +0000506
hasso3b687352004-08-19 06:56:53 +0000507 /* calculate birth of this lsa */
paul718e3742002-12-13 20:15:29 +0000508 ospf6_lsa_age_set (lsa);
509
paul718e3742002-12-13 20:15:29 +0000510 return lsa;
511}
512
513void
514ospf6_lsa_delete (struct ospf6_lsa *lsa)
515{
hasso508e53e2004-05-18 18:57:06 +0000516 assert (lsa->lock == 0);
paul718e3742002-12-13 20:15:29 +0000517
518 /* cancel threads */
hasso508e53e2004-05-18 18:57:06 +0000519 THREAD_OFF (lsa->expire);
520 THREAD_OFF (lsa->refresh);
paul718e3742002-12-13 20:15:29 +0000521
paul718e3742002-12-13 20:15:29 +0000522 /* do free */
hasso508e53e2004-05-18 18:57:06 +0000523 XFREE (MTYPE_OSPF6_LSA, lsa->header);
524 XFREE (MTYPE_OSPF6_LSA, lsa);
paul718e3742002-12-13 20:15:29 +0000525}
526
hasso508e53e2004-05-18 18:57:06 +0000527struct ospf6_lsa *
528ospf6_lsa_copy (struct ospf6_lsa *lsa)
529{
530 struct ospf6_lsa *copy = NULL;
531
hasso508e53e2004-05-18 18:57:06 +0000532 ospf6_lsa_age_current (lsa);
hasso6452df02004-08-15 05:52:07 +0000533 if (CHECK_FLAG (lsa->flag, OSPF6_LSA_HEADERONLY))
hasso508e53e2004-05-18 18:57:06 +0000534 copy = ospf6_lsa_create_headeronly (lsa->header);
535 else
536 copy = ospf6_lsa_create (lsa->header);
537 assert (copy->lock == 0);
538
hasso3b687352004-08-19 06:56:53 +0000539 copy->birth = lsa->birth;
hasso508e53e2004-05-18 18:57:06 +0000540 copy->originated = lsa->originated;
hassoccb59b12004-08-25 09:10:37 +0000541 copy->received = lsa->received;
542 copy->installed = lsa->installed;
hasso6452df02004-08-15 05:52:07 +0000543 copy->lsdb = lsa->lsdb;
hasso508e53e2004-05-18 18:57:06 +0000544
hasso508e53e2004-05-18 18:57:06 +0000545 return copy;
546}
547
548/* increment reference counter of struct ospf6_lsa */
paul718e3742002-12-13 20:15:29 +0000549void
550ospf6_lsa_lock (struct ospf6_lsa *lsa)
551{
552 lsa->lock++;
553 return;
554}
555
hasso508e53e2004-05-18 18:57:06 +0000556/* decrement reference counter of struct ospf6_lsa */
paul718e3742002-12-13 20:15:29 +0000557void
558ospf6_lsa_unlock (struct ospf6_lsa *lsa)
559{
560 /* decrement reference counter */
hasso508e53e2004-05-18 18:57:06 +0000561 assert (lsa->lock > 0);
562 lsa->lock--;
paul718e3742002-12-13 20:15:29 +0000563
hasso508e53e2004-05-18 18:57:06 +0000564 if (lsa->lock != 0)
565 return;
566
hasso508e53e2004-05-18 18:57:06 +0000567 ospf6_lsa_delete (lsa);
paul718e3742002-12-13 20:15:29 +0000568}
569
paul718e3742002-12-13 20:15:29 +0000570
hasso508e53e2004-05-18 18:57:06 +0000571/* ospf6 lsa expiry */
paul718e3742002-12-13 20:15:29 +0000572int
573ospf6_lsa_expire (struct thread *thread)
574{
575 struct ospf6_lsa *lsa;
paul718e3742002-12-13 20:15:29 +0000576
577 lsa = (struct ospf6_lsa *) THREAD_ARG (thread);
paul718e3742002-12-13 20:15:29 +0000578
hasso508e53e2004-05-18 18:57:06 +0000579 assert (lsa && lsa->header);
580 assert (OSPF6_LSA_IS_MAXAGE (lsa));
581 assert (! lsa->refresh);
paul718e3742002-12-13 20:15:29 +0000582
583 lsa->expire = (struct thread *) NULL;
584
hasso1e058382004-09-01 21:36:14 +0000585 if (IS_OSPF6_DEBUG_LSA_TYPE (lsa->header->type))
paul718e3742002-12-13 20:15:29 +0000586 {
hasso508e53e2004-05-18 18:57:06 +0000587 zlog_info ("LSA Expire:");
588 ospf6_lsa_header_print (lsa);
paul718e3742002-12-13 20:15:29 +0000589 }
590
hasso6452df02004-08-15 05:52:07 +0000591 if (CHECK_FLAG (lsa->flag, OSPF6_LSA_HEADERONLY))
hasso508e53e2004-05-18 18:57:06 +0000592 return 0; /* dbexchange will do something ... */
593
594 /* reflood lsa */
hasso6452df02004-08-15 05:52:07 +0000595 ospf6_flood (NULL, lsa);
hasso508e53e2004-05-18 18:57:06 +0000596
597 /* reinstall lsa */
hasso3b687352004-08-19 06:56:53 +0000598 ospf6_install_lsa (lsa);
hasso508e53e2004-05-18 18:57:06 +0000599
600 /* schedule maxage remover */
601 ospf6_maxage_remove (ospf6);
602
paul718e3742002-12-13 20:15:29 +0000603 return 0;
604}
605
606int
607ospf6_lsa_refresh (struct thread *thread)
608{
hasso6452df02004-08-15 05:52:07 +0000609 struct ospf6_lsa *old, *self, *new;
610 struct ospf6_lsdb *lsdb_self;
paul718e3742002-12-13 20:15:29 +0000611
612 assert (thread);
hasso6452df02004-08-15 05:52:07 +0000613 old = (struct ospf6_lsa *) THREAD_ARG (thread);
614 assert (old && old->header);
paul718e3742002-12-13 20:15:29 +0000615
hasso6452df02004-08-15 05:52:07 +0000616 old->refresh = (struct thread *) NULL;
paul718e3742002-12-13 20:15:29 +0000617
hasso6452df02004-08-15 05:52:07 +0000618 lsdb_self = ospf6_get_scoped_lsdb_self (old);
619 self = ospf6_lsdb_lookup (old->header->type, old->header->id,
620 old->header->adv_router, lsdb_self);
621 if (self == NULL)
622 {
hasso1e058382004-09-01 21:36:14 +0000623 if (IS_OSPF6_DEBUG_LSA_TYPE (old->header->type))
hasso3b687352004-08-19 06:56:53 +0000624 zlog_info ("Refresh: could not find self LSA, flush %s", old->name);
hasso6452df02004-08-15 05:52:07 +0000625 ospf6_lsa_premature_aging (old);
626 return 0;
627 }
628
629 /* Reset age, increment LS sequence number. */
630 self->header->age = htons (0);
631 self->header->seqnum =
632 ospf6_new_ls_seqnum (self->header->type, self->header->id,
633 self->header->adv_router, old->lsdb);
634 ospf6_lsa_checksum (self->header);
635
636 new = ospf6_lsa_create (self->header);
637 new->lsdb = old->lsdb;
638 new->refresh = thread_add_timer (master, ospf6_lsa_refresh, new,
639 LS_REFRESH_TIME);
640
641 /* store it in the LSDB for self-originated LSAs */
642 ospf6_lsdb_add (ospf6_lsa_copy (new), lsdb_self);
paul718e3742002-12-13 20:15:29 +0000643
hasso1e058382004-09-01 21:36:14 +0000644 if (IS_OSPF6_DEBUG_LSA_TYPE (new->header->type))
paul718e3742002-12-13 20:15:29 +0000645 {
hasso508e53e2004-05-18 18:57:06 +0000646 zlog_info ("LSA Refresh:");
hasso6452df02004-08-15 05:52:07 +0000647 ospf6_lsa_header_print (new);
paul718e3742002-12-13 20:15:29 +0000648 }
649
hasso6452df02004-08-15 05:52:07 +0000650 ospf6_flood_clear (old);
651 ospf6_flood (NULL, new);
652 ospf6_install_lsa (new);
653
hasso508e53e2004-05-18 18:57:06 +0000654 return 0;
paul718e3742002-12-13 20:15:29 +0000655}
656
657
658
659/* enhanced Fletcher checksum algorithm, RFC1008 7.2 */
660#define MODX 4102
661#define LSA_CHECKSUM_OFFSET 15
662
663unsigned short
664ospf6_lsa_checksum (struct ospf6_lsa_header *lsa_header)
665{
666 u_char *sp, *ep, *p, *q;
667 int c0 = 0, c1 = 0;
668 int x, y;
669 u_int16_t length;
670
671 lsa_header->checksum = 0;
672 length = ntohs (lsa_header->length) - 2;
673 sp = (char *) &lsa_header->type;
674
675 for (ep = sp + length; sp < ep; sp = q)
676 {
677 q = sp + MODX;
678 if (q > ep)
679 q = ep;
680 for (p = sp; p < q; p++)
681 {
682 c0 += *p;
683 c1 += c0;
684 }
685 c0 %= 255;
686 c1 %= 255;
687 }
688
689 /* r = (c1 << 8) + c0; */
690 x = ((length - LSA_CHECKSUM_OFFSET) * c0 - c1) % 255;
691 if (x <= 0)
692 x += 255;
693 y = 510 - c0 - x;
694 if (y > 255)
695 y -= 255;
696
697 lsa_header->checksum = htons ((x << 8) + y);
698
699 return (lsa_header->checksum);
700}
701
hasso6452df02004-08-15 05:52:07 +0000702void
paul718e3742002-12-13 20:15:29 +0000703ospf6_lsa_init ()
704{
hasso1e058382004-09-01 21:36:14 +0000705 ospf6_lsa_handler_vector = vector_init (0);
hasso6452df02004-08-15 05:52:07 +0000706 ospf6_install_lsa_handler (&unknown_handler);
paul718e3742002-12-13 20:15:29 +0000707}
708
hasso508e53e2004-05-18 18:57:06 +0000709
hasso1e058382004-09-01 21:36:14 +0000710char *
711ospf6_lsa_handler_name (struct ospf6_lsa_handler *h)
hasso508e53e2004-05-18 18:57:06 +0000712{
hasso1e058382004-09-01 21:36:14 +0000713 static char buf[64];
714 int i, size = strlen (h->name);
hasso508e53e2004-05-18 18:57:06 +0000715
hasso1e058382004-09-01 21:36:14 +0000716 if (h->name == "Unknown" &&
717 h->type != OSPF6_LSTYPE_UNKNOWN)
hasso508e53e2004-05-18 18:57:06 +0000718 {
hasso1e058382004-09-01 21:36:14 +0000719 snprintf (buf, sizeof (buf), "%#04hx", h->type);
720 return buf;
hasso508e53e2004-05-18 18:57:06 +0000721 }
722
hasso1e058382004-09-01 21:36:14 +0000723 for (i = 0; i < MIN (size, sizeof (buf)); i++)
hasso508e53e2004-05-18 18:57:06 +0000724 {
hasso1e058382004-09-01 21:36:14 +0000725 if (! islower (h->name[i]))
726 buf[i] = tolower (h->name[i]);
hasso508e53e2004-05-18 18:57:06 +0000727 else
hasso1e058382004-09-01 21:36:14 +0000728 buf[i] = h->name[i];
729 }
730 buf[size] = '\0';
731 return buf;
732}
hasso508e53e2004-05-18 18:57:06 +0000733
hasso1e058382004-09-01 21:36:14 +0000734DEFUN (debug_ospf6_lsa_type,
735 debug_ospf6_lsa_hex_cmd,
736 "debug ospf6 lsa XXXX/0xXXXX",
737 DEBUG_STR
738 OSPF6_STR
739 "Debug Link State Advertisements (LSAs)\n"
740 "Specify LS type as Hexadecimal\n"
741 )
742{
743 int i;
744 struct ospf6_lsa_handler *handler = NULL;
745 unsigned long val;
746 char *endptr = NULL;
747 u_int16_t type = 0;
748
749 assert (argc);
750
751 if ((strlen (argv[0]) == 6 && ! strncmp (argv[0], "0x", 2)) ||
752 (strlen (argv[0]) == 4))
753 {
754 val = strtoul (argv[0], &endptr, 16);
755 if (*endptr == '\0')
756 type = val;
hasso508e53e2004-05-18 18:57:06 +0000757 }
758
hasso1e058382004-09-01 21:36:14 +0000759 for (i = 0; i < vector_max (ospf6_lsa_handler_vector); i++)
760 {
761 handler = vector_slot (ospf6_lsa_handler_vector, i);
762 if (handler == NULL)
763 continue;
764 if (type && handler->type == type)
765 break;
766 if (! strcasecmp (argv[0], handler->name))
767 break;
768 handler = NULL;
769 }
770
771 if (type && handler == NULL)
772 {
773 handler = (struct ospf6_lsa_handler *)
774 malloc (sizeof (struct ospf6_lsa_handler));
775 memset (handler, 0, sizeof (struct ospf6_lsa_handler));
776 handler->type = type;
777 handler->name = "Unknown";
778 handler->show = ospf6_unknown_lsa_show;
779 vector_set_index (ospf6_lsa_handler_vector,
780 handler->type & OSPF6_LSTYPE_FCODE_MASK, handler);
781 }
782
783 if (handler == NULL)
784 handler = &unknown_handler;
785
786 if (argc >= 2)
787 {
788 if (! strcmp (argv[1], "originate"))
789 SET_FLAG (handler->debug, OSPF6_LSA_DEBUG_ORIGINATE);
790 if (! strcmp (argv[1], "examin"))
791 SET_FLAG (handler->debug, OSPF6_LSA_DEBUG_EXAMIN);
792 if (! strcmp (argv[1], "flooding"))
793 SET_FLAG (handler->debug, OSPF6_LSA_DEBUG_FLOOD);
794 }
795 else
796 SET_FLAG (handler->debug, OSPF6_LSA_DEBUG);
797
798 return CMD_SUCCESS;
hasso508e53e2004-05-18 18:57:06 +0000799}
800
hasso1e058382004-09-01 21:36:14 +0000801DEFUN (no_debug_ospf6_lsa_type,
802 no_debug_ospf6_lsa_hex_cmd,
803 "no debug ospf6 lsa XXXX/0xXXXX",
804 NO_STR
805 DEBUG_STR
806 OSPF6_STR
807 "Debug Link State Advertisements (LSAs)\n"
808 "Specify LS type as Hexadecimal\n"
809 )
810{
811 int i;
812 struct ospf6_lsa_handler *handler = NULL;
813 unsigned long val;
814 char *endptr = NULL;
815 u_int16_t type = 0;
816
817 assert (argc);
818
819 if ((strlen (argv[0]) == 6 && ! strncmp (argv[0], "0x", 2)) ||
820 (strlen (argv[0]) == 4))
821 {
822 val = strtoul (argv[0], &endptr, 16);
823 if (*endptr == '\0')
824 type = val;
825 }
826
827 for (i = 0; i < vector_max (ospf6_lsa_handler_vector); i++)
828 {
829 handler = vector_slot (ospf6_lsa_handler_vector, i);
830 if (handler == NULL)
831 continue;
832 if (type && handler->type == type)
833 break;
834 if (! strcasecmp (argv[0], handler->name))
835 break;
836 }
837
838 if (handler == NULL)
839 return CMD_SUCCESS;
840
841 if (argc >= 2)
842 {
843 if (! strcmp (argv[1], "originate"))
844 UNSET_FLAG (handler->debug, OSPF6_LSA_DEBUG_ORIGINATE);
845 if (! strcmp (argv[1], "examin"))
846 UNSET_FLAG (handler->debug, OSPF6_LSA_DEBUG_EXAMIN);
847 if (! strcmp (argv[1], "flooding"))
848 UNSET_FLAG (handler->debug, OSPF6_LSA_DEBUG_FLOOD);
849 }
850 else
851 UNSET_FLAG (handler->debug, OSPF6_LSA_DEBUG);
852
853 if (handler->debug == 0 &&
854 handler->name == "Unknown" && type != OSPF6_LSTYPE_UNKNOWN)
855 {
856 free (handler);
857 vector_slot (ospf6_lsa_handler_vector, i) = NULL;
858 }
859
860 return CMD_SUCCESS;
861}
862
863struct cmd_element debug_ospf6_lsa_type_cmd;
864struct cmd_element debug_ospf6_lsa_type_detail_cmd;
865struct cmd_element no_debug_ospf6_lsa_type_cmd;
866struct cmd_element no_debug_ospf6_lsa_type_detail_cmd;
867
hasso508e53e2004-05-18 18:57:06 +0000868void
869install_element_ospf6_debug_lsa ()
870{
hasso1e058382004-09-01 21:36:14 +0000871 int i;
872 struct ospf6_lsa_handler *handler;
873#define STRSIZE 256
874#define DOCSIZE 1024
875 static char strbuf[STRSIZE];
876 static char docbuf[DOCSIZE];
877 static char detail_strbuf[STRSIZE];
878 static char detail_docbuf[DOCSIZE];
879 char *str, *no_str;
880 char *doc, *no_doc;
881
882 strbuf[0] = '\0';
883 no_str = &strbuf[strlen (strbuf)];
884 strncat (strbuf, "no ", STRSIZE - strlen (strbuf));
885 str = &strbuf[strlen (strbuf)];
886
887 strncat (strbuf, "debug ospf6 lsa (", STRSIZE - strlen (strbuf));
888 for (i = 0; i < vector_max (ospf6_lsa_handler_vector); i++)
889 {
890 handler = vector_slot (ospf6_lsa_handler_vector, i);
891 if (handler == NULL)
892 continue;
893 strncat (strbuf, ospf6_lsa_handler_name (handler),
894 STRSIZE - strlen (strbuf));
895 strncat (strbuf, "|", STRSIZE - strlen (strbuf));
896 }
897 strbuf[strlen (strbuf) - 1] = ')';
898 strbuf[strlen (strbuf)] = '\0';
899
900 docbuf[0] = '\0';
901 no_doc = &docbuf[strlen (docbuf)];
902 strncat (docbuf, NO_STR, DOCSIZE - strlen (docbuf));
903 doc = &docbuf[strlen (docbuf)];
904
905 strncat (docbuf, DEBUG_STR, DOCSIZE - strlen (docbuf));
906 strncat (docbuf, OSPF6_STR, DOCSIZE - strlen (docbuf));
907 strncat (docbuf, "Debug Link State Advertisements (LSAs)\n",
908 DOCSIZE - strlen (docbuf));
909
910 for (i = 0; i < vector_max (ospf6_lsa_handler_vector); i++)
911 {
912 handler = vector_slot (ospf6_lsa_handler_vector, i);
913 if (handler == NULL)
914 continue;
915 strncat (docbuf, "Debug ", DOCSIZE - strlen (docbuf));
916 strncat (docbuf, handler->name, DOCSIZE - strlen (docbuf));
917 strncat (docbuf, "-LSA\n", DOCSIZE - strlen (docbuf));
918 }
919 docbuf[strlen (docbuf)] = '\0';
920
921 debug_ospf6_lsa_type_cmd.string = str;
922 debug_ospf6_lsa_type_cmd.func = debug_ospf6_lsa_type;
923 debug_ospf6_lsa_type_cmd.doc = doc;
924
925 no_debug_ospf6_lsa_type_cmd.string = no_str;
926 no_debug_ospf6_lsa_type_cmd.func = no_debug_ospf6_lsa_type;
927 no_debug_ospf6_lsa_type_cmd.doc = no_doc;
928
929 strncpy (detail_strbuf, strbuf, STRSIZE);
930 strncat (detail_strbuf, " (originate|examin|flooding)",
931 STRSIZE - strlen (detail_strbuf));
932 detail_strbuf[strlen (detail_strbuf)] = '\0';
933 no_str = &detail_strbuf[0];
934 str = &detail_strbuf[strlen ("no ")];
935
936 strncpy (detail_docbuf, docbuf, DOCSIZE);
937 strncat (detail_docbuf, "Debug Originating LSA\n",
938 DOCSIZE - strlen (detail_docbuf));
939 strncat (detail_docbuf, "Debug Examining LSA\n",
940 DOCSIZE - strlen (detail_docbuf));
941 strncat (detail_docbuf, "Debug Flooding LSA\n",
942 DOCSIZE - strlen (detail_docbuf));
943 detail_docbuf[strlen (detail_docbuf)] = '\0';
944 no_doc = &detail_docbuf[0];
945 doc = &detail_docbuf[strlen (NO_STR)];
946
947 debug_ospf6_lsa_type_detail_cmd.string = str;
948 debug_ospf6_lsa_type_detail_cmd.func = debug_ospf6_lsa_type;
949 debug_ospf6_lsa_type_detail_cmd.doc = doc;
950
951 no_debug_ospf6_lsa_type_detail_cmd.string = no_str;
952 no_debug_ospf6_lsa_type_detail_cmd.func = no_debug_ospf6_lsa_type;
953 no_debug_ospf6_lsa_type_detail_cmd.doc = no_doc;
954
955 install_element (ENABLE_NODE, &debug_ospf6_lsa_hex_cmd);
956 install_element (ENABLE_NODE, &debug_ospf6_lsa_type_cmd);
957 install_element (ENABLE_NODE, &debug_ospf6_lsa_type_detail_cmd);
958 install_element (ENABLE_NODE, &no_debug_ospf6_lsa_hex_cmd);
959 install_element (ENABLE_NODE, &no_debug_ospf6_lsa_type_cmd);
960 install_element (ENABLE_NODE, &no_debug_ospf6_lsa_type_detail_cmd);
961 install_element (CONFIG_NODE, &debug_ospf6_lsa_hex_cmd);
962 install_element (CONFIG_NODE, &debug_ospf6_lsa_type_cmd);
963 install_element (CONFIG_NODE, &debug_ospf6_lsa_type_detail_cmd);
964 install_element (CONFIG_NODE, &no_debug_ospf6_lsa_hex_cmd);
965 install_element (CONFIG_NODE, &no_debug_ospf6_lsa_type_cmd);
966 install_element (CONFIG_NODE, &no_debug_ospf6_lsa_type_detail_cmd);
967}
968
969int
970config_write_ospf6_debug_lsa (struct vty *vty)
971{
972 int i;
973 struct ospf6_lsa_handler *handler;
974
975 for (i = 0; i < vector_max (ospf6_lsa_handler_vector); i++)
976 {
977 handler = vector_slot (ospf6_lsa_handler_vector, i);
978 if (handler == NULL)
979 continue;
980 if (CHECK_FLAG (handler->debug, OSPF6_LSA_DEBUG))
981 vty_out (vty, "debug ospf6 lsa %s%s",
982 ospf6_lsa_handler_name (handler), VNL);
983 if (CHECK_FLAG (handler->debug, OSPF6_LSA_DEBUG_ORIGINATE))
984 vty_out (vty, "debug ospf6 lsa %s originate%s",
985 ospf6_lsa_handler_name (handler), VNL);
986 if (CHECK_FLAG (handler->debug, OSPF6_LSA_DEBUG_EXAMIN))
987 vty_out (vty, "debug ospf6 lsa %s examin%s",
988 ospf6_lsa_handler_name (handler), VNL);
989 if (CHECK_FLAG (handler->debug, OSPF6_LSA_DEBUG_FLOOD))
990 vty_out (vty, "debug ospf6 lsa %s flooding%s",
991 ospf6_lsa_handler_name (handler), VNL);
992 }
993
994 return 0;
hasso508e53e2004-05-18 18:57:06 +0000995}
996
997