blob: d6356c7279afd618a831b2a448dbf9860fb538a8 [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
hasso03d52f82004-09-29 00:26:19 +000054 start = (u_char *) lsa->header + sizeof (struct ospf6_lsa_header);
55 end = (u_char *) lsa->header + ntohs (lsa->header->length);
hasso1e058382004-09-01 21:36:14 +000056
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;
paul0c083ee2004-10-10 12:54:58 +000093 unsigned int index = ntohs (type) & OSPF6_LSTYPE_FCODE_MASK;
hasso1e058382004-09-01 21:36:14 +000094
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
paul0c083ee2004-10-10 12:54:58 +0000103const char *
hasso508e53e2004-05-18 18:57:06 +0000104ospf6_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
hasso03d52f82004-09-29 00:26:19 +0000369 start = (u_char *) lsa->header;
370 end = (u_char *) lsa->header + ntohs (lsa->header->length);
paul718e3742002-12-13 20:15:29 +0000371
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;
hasso03d52f82004-09-29 00:26:19 +0000673 sp = (u_char *) &lsa_header->type;
paul718e3742002-12-13 20:15:29 +0000674
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];
paul0c083ee2004-10-10 12:54:58 +0000714 unsigned int i;
715 unsigned int size = strlen (h->name);
hasso508e53e2004-05-18 18:57:06 +0000716
hasso1e058382004-09-01 21:36:14 +0000717 if (h->name == "Unknown" &&
718 h->type != OSPF6_LSTYPE_UNKNOWN)
hasso508e53e2004-05-18 18:57:06 +0000719 {
hasso1e058382004-09-01 21:36:14 +0000720 snprintf (buf, sizeof (buf), "%#04hx", h->type);
721 return buf;
hasso508e53e2004-05-18 18:57:06 +0000722 }
723
hasso1e058382004-09-01 21:36:14 +0000724 for (i = 0; i < MIN (size, sizeof (buf)); i++)
hasso508e53e2004-05-18 18:57:06 +0000725 {
hasso1e058382004-09-01 21:36:14 +0000726 if (! islower (h->name[i]))
727 buf[i] = tolower (h->name[i]);
hasso508e53e2004-05-18 18:57:06 +0000728 else
hasso1e058382004-09-01 21:36:14 +0000729 buf[i] = h->name[i];
730 }
731 buf[size] = '\0';
732 return buf;
733}
hasso508e53e2004-05-18 18:57:06 +0000734
hasso1e058382004-09-01 21:36:14 +0000735DEFUN (debug_ospf6_lsa_type,
736 debug_ospf6_lsa_hex_cmd,
737 "debug ospf6 lsa XXXX/0xXXXX",
738 DEBUG_STR
739 OSPF6_STR
740 "Debug Link State Advertisements (LSAs)\n"
741 "Specify LS type as Hexadecimal\n"
742 )
743{
paul0c083ee2004-10-10 12:54:58 +0000744 unsigned int i;
hasso1e058382004-09-01 21:36:14 +0000745 struct ospf6_lsa_handler *handler = NULL;
746 unsigned long val;
747 char *endptr = NULL;
748 u_int16_t type = 0;
749
750 assert (argc);
751
752 if ((strlen (argv[0]) == 6 && ! strncmp (argv[0], "0x", 2)) ||
753 (strlen (argv[0]) == 4))
754 {
755 val = strtoul (argv[0], &endptr, 16);
756 if (*endptr == '\0')
757 type = val;
hasso508e53e2004-05-18 18:57:06 +0000758 }
759
hasso1e058382004-09-01 21:36:14 +0000760 for (i = 0; i < vector_max (ospf6_lsa_handler_vector); i++)
761 {
762 handler = vector_slot (ospf6_lsa_handler_vector, i);
763 if (handler == NULL)
764 continue;
765 if (type && handler->type == type)
766 break;
767 if (! strcasecmp (argv[0], handler->name))
768 break;
769 handler = NULL;
770 }
771
772 if (type && handler == NULL)
773 {
774 handler = (struct ospf6_lsa_handler *)
775 malloc (sizeof (struct ospf6_lsa_handler));
776 memset (handler, 0, sizeof (struct ospf6_lsa_handler));
777 handler->type = type;
778 handler->name = "Unknown";
779 handler->show = ospf6_unknown_lsa_show;
780 vector_set_index (ospf6_lsa_handler_vector,
781 handler->type & OSPF6_LSTYPE_FCODE_MASK, handler);
782 }
783
784 if (handler == NULL)
785 handler = &unknown_handler;
786
787 if (argc >= 2)
788 {
789 if (! strcmp (argv[1], "originate"))
790 SET_FLAG (handler->debug, OSPF6_LSA_DEBUG_ORIGINATE);
791 if (! strcmp (argv[1], "examin"))
792 SET_FLAG (handler->debug, OSPF6_LSA_DEBUG_EXAMIN);
793 if (! strcmp (argv[1], "flooding"))
794 SET_FLAG (handler->debug, OSPF6_LSA_DEBUG_FLOOD);
795 }
796 else
797 SET_FLAG (handler->debug, OSPF6_LSA_DEBUG);
798
799 return CMD_SUCCESS;
hasso508e53e2004-05-18 18:57:06 +0000800}
801
hasso1e058382004-09-01 21:36:14 +0000802DEFUN (no_debug_ospf6_lsa_type,
803 no_debug_ospf6_lsa_hex_cmd,
804 "no debug ospf6 lsa XXXX/0xXXXX",
805 NO_STR
806 DEBUG_STR
807 OSPF6_STR
808 "Debug Link State Advertisements (LSAs)\n"
809 "Specify LS type as Hexadecimal\n"
810 )
811{
paul0c083ee2004-10-10 12:54:58 +0000812 u_int i;
hasso1e058382004-09-01 21:36:14 +0000813 struct ospf6_lsa_handler *handler = NULL;
814 unsigned long val;
815 char *endptr = NULL;
816 u_int16_t type = 0;
817
818 assert (argc);
819
820 if ((strlen (argv[0]) == 6 && ! strncmp (argv[0], "0x", 2)) ||
821 (strlen (argv[0]) == 4))
822 {
823 val = strtoul (argv[0], &endptr, 16);
824 if (*endptr == '\0')
825 type = val;
826 }
827
828 for (i = 0; i < vector_max (ospf6_lsa_handler_vector); i++)
829 {
830 handler = vector_slot (ospf6_lsa_handler_vector, i);
831 if (handler == NULL)
832 continue;
833 if (type && handler->type == type)
834 break;
835 if (! strcasecmp (argv[0], handler->name))
836 break;
837 }
838
839 if (handler == NULL)
840 return CMD_SUCCESS;
841
842 if (argc >= 2)
843 {
844 if (! strcmp (argv[1], "originate"))
845 UNSET_FLAG (handler->debug, OSPF6_LSA_DEBUG_ORIGINATE);
846 if (! strcmp (argv[1], "examin"))
847 UNSET_FLAG (handler->debug, OSPF6_LSA_DEBUG_EXAMIN);
848 if (! strcmp (argv[1], "flooding"))
849 UNSET_FLAG (handler->debug, OSPF6_LSA_DEBUG_FLOOD);
850 }
851 else
852 UNSET_FLAG (handler->debug, OSPF6_LSA_DEBUG);
853
854 if (handler->debug == 0 &&
855 handler->name == "Unknown" && type != OSPF6_LSTYPE_UNKNOWN)
856 {
857 free (handler);
858 vector_slot (ospf6_lsa_handler_vector, i) = NULL;
859 }
860
861 return CMD_SUCCESS;
862}
863
864struct cmd_element debug_ospf6_lsa_type_cmd;
865struct cmd_element debug_ospf6_lsa_type_detail_cmd;
866struct cmd_element no_debug_ospf6_lsa_type_cmd;
867struct cmd_element no_debug_ospf6_lsa_type_detail_cmd;
868
hasso508e53e2004-05-18 18:57:06 +0000869void
870install_element_ospf6_debug_lsa ()
871{
paul0c083ee2004-10-10 12:54:58 +0000872 u_int i;
hasso1e058382004-09-01 21:36:14 +0000873 struct ospf6_lsa_handler *handler;
874#define STRSIZE 256
875#define DOCSIZE 1024
876 static char strbuf[STRSIZE];
877 static char docbuf[DOCSIZE];
878 static char detail_strbuf[STRSIZE];
879 static char detail_docbuf[DOCSIZE];
880 char *str, *no_str;
881 char *doc, *no_doc;
882
883 strbuf[0] = '\0';
884 no_str = &strbuf[strlen (strbuf)];
885 strncat (strbuf, "no ", STRSIZE - strlen (strbuf));
886 str = &strbuf[strlen (strbuf)];
887
888 strncat (strbuf, "debug ospf6 lsa (", STRSIZE - strlen (strbuf));
889 for (i = 0; i < vector_max (ospf6_lsa_handler_vector); i++)
890 {
891 handler = vector_slot (ospf6_lsa_handler_vector, i);
892 if (handler == NULL)
893 continue;
894 strncat (strbuf, ospf6_lsa_handler_name (handler),
895 STRSIZE - strlen (strbuf));
896 strncat (strbuf, "|", STRSIZE - strlen (strbuf));
897 }
898 strbuf[strlen (strbuf) - 1] = ')';
899 strbuf[strlen (strbuf)] = '\0';
900
901 docbuf[0] = '\0';
902 no_doc = &docbuf[strlen (docbuf)];
903 strncat (docbuf, NO_STR, DOCSIZE - strlen (docbuf));
904 doc = &docbuf[strlen (docbuf)];
905
906 strncat (docbuf, DEBUG_STR, DOCSIZE - strlen (docbuf));
907 strncat (docbuf, OSPF6_STR, DOCSIZE - strlen (docbuf));
908 strncat (docbuf, "Debug Link State Advertisements (LSAs)\n",
909 DOCSIZE - strlen (docbuf));
910
911 for (i = 0; i < vector_max (ospf6_lsa_handler_vector); i++)
912 {
913 handler = vector_slot (ospf6_lsa_handler_vector, i);
914 if (handler == NULL)
915 continue;
916 strncat (docbuf, "Debug ", DOCSIZE - strlen (docbuf));
917 strncat (docbuf, handler->name, DOCSIZE - strlen (docbuf));
918 strncat (docbuf, "-LSA\n", DOCSIZE - strlen (docbuf));
919 }
920 docbuf[strlen (docbuf)] = '\0';
921
922 debug_ospf6_lsa_type_cmd.string = str;
923 debug_ospf6_lsa_type_cmd.func = debug_ospf6_lsa_type;
924 debug_ospf6_lsa_type_cmd.doc = doc;
925
926 no_debug_ospf6_lsa_type_cmd.string = no_str;
927 no_debug_ospf6_lsa_type_cmd.func = no_debug_ospf6_lsa_type;
928 no_debug_ospf6_lsa_type_cmd.doc = no_doc;
929
930 strncpy (detail_strbuf, strbuf, STRSIZE);
931 strncat (detail_strbuf, " (originate|examin|flooding)",
932 STRSIZE - strlen (detail_strbuf));
933 detail_strbuf[strlen (detail_strbuf)] = '\0';
934 no_str = &detail_strbuf[0];
935 str = &detail_strbuf[strlen ("no ")];
936
937 strncpy (detail_docbuf, docbuf, DOCSIZE);
938 strncat (detail_docbuf, "Debug Originating LSA\n",
939 DOCSIZE - strlen (detail_docbuf));
940 strncat (detail_docbuf, "Debug Examining LSA\n",
941 DOCSIZE - strlen (detail_docbuf));
942 strncat (detail_docbuf, "Debug Flooding LSA\n",
943 DOCSIZE - strlen (detail_docbuf));
944 detail_docbuf[strlen (detail_docbuf)] = '\0';
945 no_doc = &detail_docbuf[0];
946 doc = &detail_docbuf[strlen (NO_STR)];
947
948 debug_ospf6_lsa_type_detail_cmd.string = str;
949 debug_ospf6_lsa_type_detail_cmd.func = debug_ospf6_lsa_type;
950 debug_ospf6_lsa_type_detail_cmd.doc = doc;
951
952 no_debug_ospf6_lsa_type_detail_cmd.string = no_str;
953 no_debug_ospf6_lsa_type_detail_cmd.func = no_debug_ospf6_lsa_type;
954 no_debug_ospf6_lsa_type_detail_cmd.doc = no_doc;
955
956 install_element (ENABLE_NODE, &debug_ospf6_lsa_hex_cmd);
957 install_element (ENABLE_NODE, &debug_ospf6_lsa_type_cmd);
958 install_element (ENABLE_NODE, &debug_ospf6_lsa_type_detail_cmd);
959 install_element (ENABLE_NODE, &no_debug_ospf6_lsa_hex_cmd);
960 install_element (ENABLE_NODE, &no_debug_ospf6_lsa_type_cmd);
961 install_element (ENABLE_NODE, &no_debug_ospf6_lsa_type_detail_cmd);
962 install_element (CONFIG_NODE, &debug_ospf6_lsa_hex_cmd);
963 install_element (CONFIG_NODE, &debug_ospf6_lsa_type_cmd);
964 install_element (CONFIG_NODE, &debug_ospf6_lsa_type_detail_cmd);
965 install_element (CONFIG_NODE, &no_debug_ospf6_lsa_hex_cmd);
966 install_element (CONFIG_NODE, &no_debug_ospf6_lsa_type_cmd);
967 install_element (CONFIG_NODE, &no_debug_ospf6_lsa_type_detail_cmd);
968}
969
970int
971config_write_ospf6_debug_lsa (struct vty *vty)
972{
paul0c083ee2004-10-10 12:54:58 +0000973 u_int i;
hasso1e058382004-09-01 21:36:14 +0000974 struct ospf6_lsa_handler *handler;
975
976 for (i = 0; i < vector_max (ospf6_lsa_handler_vector); i++)
977 {
978 handler = vector_slot (ospf6_lsa_handler_vector, i);
979 if (handler == NULL)
980 continue;
981 if (CHECK_FLAG (handler->debug, OSPF6_LSA_DEBUG))
982 vty_out (vty, "debug ospf6 lsa %s%s",
983 ospf6_lsa_handler_name (handler), VNL);
984 if (CHECK_FLAG (handler->debug, OSPF6_LSA_DEBUG_ORIGINATE))
985 vty_out (vty, "debug ospf6 lsa %s originate%s",
986 ospf6_lsa_handler_name (handler), VNL);
987 if (CHECK_FLAG (handler->debug, OSPF6_LSA_DEBUG_EXAMIN))
988 vty_out (vty, "debug ospf6 lsa %s examin%s",
989 ospf6_lsa_handler_name (handler), VNL);
990 if (CHECK_FLAG (handler->debug, OSPF6_LSA_DEBUG_FLOOD))
991 vty_out (vty, "debug ospf6 lsa %s flooding%s",
992 ospf6_lsa_handler_name (handler), VNL);
993 }
994
995 return 0;
hasso508e53e2004-05-18 18:57:06 +0000996}
997
998