blob: 4d3287d6d562c319bdcc52128e545c56f51416df [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
hasso2680aa22004-11-25 20:54:46 +0000100 if (handler == NULL)
101 handler = &unknown_handler;
102
hasso1e058382004-09-01 21:36:14 +0000103 return handler;
104}
hasso508e53e2004-05-18 18:57:06 +0000105
paul0c083ee2004-10-10 12:54:58 +0000106const char *
hasso508e53e2004-05-18 18:57:06 +0000107ospf6_lstype_name (u_int16_t type)
paul718e3742002-12-13 20:15:29 +0000108{
hasso508e53e2004-05-18 18:57:06 +0000109 static char buf[8];
hasso1e058382004-09-01 21:36:14 +0000110 struct ospf6_lsa_handler *handler;
paul718e3742002-12-13 20:15:29 +0000111
hasso1e058382004-09-01 21:36:14 +0000112 handler = ospf6_get_lsa_handler (type);
113 if (handler && handler != &unknown_handler)
114 return handler->name;
paul718e3742002-12-13 20:15:29 +0000115
hasso508e53e2004-05-18 18:57:06 +0000116 snprintf (buf, sizeof (buf), "0x%04hx", ntohs (type));
117 return buf;
paul718e3742002-12-13 20:15:29 +0000118}
119
hasso1e058382004-09-01 21:36:14 +0000120u_char
121ospf6_lstype_debug (u_int16_t type)
122{
123 struct ospf6_lsa_handler *handler;
124 handler = ospf6_get_lsa_handler (type);
125 return handler->debug;
126}
127
paul718e3742002-12-13 20:15:29 +0000128/* RFC2328: Section 13.2 */
129int
hasso508e53e2004-05-18 18:57:06 +0000130ospf6_lsa_is_differ (struct ospf6_lsa *lsa1,
131 struct ospf6_lsa *lsa2)
paul718e3742002-12-13 20:15:29 +0000132{
hasso508e53e2004-05-18 18:57:06 +0000133 int len;
paul718e3742002-12-13 20:15:29 +0000134
hasso508e53e2004-05-18 18:57:06 +0000135 assert (OSPF6_LSA_IS_SAME (lsa1, lsa2));
paul718e3742002-12-13 20:15:29 +0000136
hasso508e53e2004-05-18 18:57:06 +0000137 /* XXX, Options ??? */
paul718e3742002-12-13 20:15:29 +0000138
139 ospf6_lsa_age_current (lsa1);
140 ospf6_lsa_age_current (lsa2);
141 if (ntohs (lsa1->header->age) == MAXAGE &&
142 ntohs (lsa2->header->age) != MAXAGE)
143 return 1;
144 if (ntohs (lsa1->header->age) != MAXAGE &&
145 ntohs (lsa2->header->age) == MAXAGE)
146 return 1;
147
148 /* compare body */
149 if (ntohs (lsa1->header->length) != ntohs (lsa2->header->length))
150 return 1;
151
hasso508e53e2004-05-18 18:57:06 +0000152 len = ntohs (lsa1->header->length) - sizeof (struct ospf6_lsa_header);
153 return memcmp (lsa1->header + 1, lsa2->header + 1, len);
paul718e3742002-12-13 20:15:29 +0000154}
155
156int
hasso508e53e2004-05-18 18:57:06 +0000157ospf6_lsa_is_changed (struct ospf6_lsa *lsa1,
158 struct ospf6_lsa *lsa2)
paul718e3742002-12-13 20:15:29 +0000159{
hasso508e53e2004-05-18 18:57:06 +0000160 int length;
paul718e3742002-12-13 20:15:29 +0000161
hasso508e53e2004-05-18 18:57:06 +0000162 if (OSPF6_LSA_IS_MAXAGE (lsa1) ^ OSPF6_LSA_IS_MAXAGE (lsa2))
163 return 1;
164 if (ntohs (lsa1->header->length) != ntohs (lsa2->header->length))
165 return 1;
paul718e3742002-12-13 20:15:29 +0000166
hasso508e53e2004-05-18 18:57:06 +0000167 length = OSPF6_LSA_SIZE (lsa1->header) - sizeof (struct ospf6_lsa_header);
168 assert (length > 0);
paul718e3742002-12-13 20:15:29 +0000169
hasso508e53e2004-05-18 18:57:06 +0000170 return memcmp (OSPF6_LSA_HEADER_END (lsa1->header),
171 OSPF6_LSA_HEADER_END (lsa2->header), length);
paul718e3742002-12-13 20:15:29 +0000172}
173
174/* ospf6 age functions */
hasso3b687352004-08-19 06:56:53 +0000175/* calculate birth */
paul718e3742002-12-13 20:15:29 +0000176static void
177ospf6_lsa_age_set (struct ospf6_lsa *lsa)
178{
179 struct timeval now;
180
181 assert (lsa && lsa->header);
182
183 if (gettimeofday (&now, (struct timezone *)NULL) < 0)
184 zlog_warn ("LSA: gettimeofday failed, may fail LSA AGEs: %s",
ajs6099b3b2004-11-20 02:06:59 +0000185 safe_strerror (errno));
paul718e3742002-12-13 20:15:29 +0000186
187 lsa->birth.tv_sec = now.tv_sec - ntohs (lsa->header->age);
188 lsa->birth.tv_usec = now.tv_usec;
hasso3b687352004-08-19 06:56:53 +0000189
paul718e3742002-12-13 20:15:29 +0000190 return;
191}
192
193/* this function calculates current age from its birth,
194 then update age field of LSA header. return value is current age */
195u_int16_t
196ospf6_lsa_age_current (struct ospf6_lsa *lsa)
197{
198 struct timeval now;
199 u_int32_t ulage;
200 u_int16_t age;
201
202 assert (lsa);
203 assert (lsa->header);
204
205 /* current time */
206 if (gettimeofday (&now, (struct timezone *)NULL) < 0)
hasso508e53e2004-05-18 18:57:06 +0000207 zlog_warn ("LSA: gettimeofday failed, may fail LSA AGEs: %s",
ajs6099b3b2004-11-20 02:06:59 +0000208 safe_strerror (errno));
paul718e3742002-12-13 20:15:29 +0000209
210 /* calculate age */
211 ulage = now.tv_sec - lsa->birth.tv_sec;
212
213 /* if over MAXAGE, set to it */
hasso508e53e2004-05-18 18:57:06 +0000214 age = (ulage > MAXAGE ? MAXAGE : ulage);
paul718e3742002-12-13 20:15:29 +0000215
216 lsa->header->age = htons (age);
217 return age;
218}
219
220/* update age field of LSA header with adding InfTransDelay */
221void
222ospf6_lsa_age_update_to_send (struct ospf6_lsa *lsa, u_int32_t transdelay)
223{
224 unsigned short age;
225
226 age = ospf6_lsa_age_current (lsa) + transdelay;
227 if (age > MAXAGE)
228 age = MAXAGE;
229 lsa->header->age = htons (age);
paul718e3742002-12-13 20:15:29 +0000230}
231
232void
233ospf6_lsa_premature_aging (struct ospf6_lsa *lsa)
234{
235 /* log */
hasso1e058382004-09-01 21:36:14 +0000236 if (IS_OSPF6_DEBUG_LSA_TYPE (lsa->header->type))
hasso508e53e2004-05-18 18:57:06 +0000237 zlog_info ("LSA: Premature aging: %s", lsa->name);
paul718e3742002-12-13 20:15:29 +0000238
hasso508e53e2004-05-18 18:57:06 +0000239 THREAD_OFF (lsa->expire);
240 THREAD_OFF (lsa->refresh);
paul718e3742002-12-13 20:15:29 +0000241
242 memset (&lsa->birth, 0, sizeof (struct timeval));
243 thread_execute (master, ospf6_lsa_expire, lsa, 0);
244}
245
246/* check which is more recent. if a is more recent, return -1;
247 if the same, return 0; otherwise(b is more recent), return 1 */
248int
hasso508e53e2004-05-18 18:57:06 +0000249ospf6_lsa_compare (struct ospf6_lsa *a, struct ospf6_lsa *b)
paul718e3742002-12-13 20:15:29 +0000250{
251 signed long seqnuma, seqnumb;
252 u_int16_t cksuma, cksumb;
253 u_int16_t agea, ageb;
254
255 assert (a && a->header);
256 assert (b && b->header);
hasso508e53e2004-05-18 18:57:06 +0000257 assert (OSPF6_LSA_IS_SAME (a, b));
paul718e3742002-12-13 20:15:29 +0000258
259 seqnuma = ((signed long) ntohl (a->header->seqnum))
260 - (signed long) INITIAL_SEQUENCE_NUMBER;
261 seqnumb = ((signed long) ntohl (b->header->seqnum))
262 - (signed long) INITIAL_SEQUENCE_NUMBER;
263
264 /* compare by sequence number */
hasso508e53e2004-05-18 18:57:06 +0000265 /* XXX, LS sequence number wrapping */
paul718e3742002-12-13 20:15:29 +0000266 if (seqnuma > seqnumb)
267 return -1;
268 else if (seqnuma < seqnumb)
269 return 1;
270
271 /* Checksum */
272 cksuma = ntohs (a->header->checksum);
273 cksumb = ntohs (b->header->checksum);
274 if (cksuma > cksumb)
275 return -1;
276 if (cksuma < cksumb)
277 return 0;
278
hasso508e53e2004-05-18 18:57:06 +0000279 /* Update Age */
paul718e3742002-12-13 20:15:29 +0000280 agea = ospf6_lsa_age_current (a);
281 ageb = ospf6_lsa_age_current (b);
282
hasso508e53e2004-05-18 18:57:06 +0000283 /* MaxAge check */
284 if (agea == MAXAGE && ageb != MAXAGE)
paul718e3742002-12-13 20:15:29 +0000285 return -1;
hasso508e53e2004-05-18 18:57:06 +0000286 else if (agea != MAXAGE && ageb == MAXAGE)
paul718e3742002-12-13 20:15:29 +0000287 return 1;
288
hasso508e53e2004-05-18 18:57:06 +0000289 /* Age check */
290 if (agea > ageb && agea - ageb >= MAX_AGE_DIFF)
paul718e3742002-12-13 20:15:29 +0000291 return 1;
hasso508e53e2004-05-18 18:57:06 +0000292 else if (agea < ageb && ageb - agea >= MAX_AGE_DIFF)
paul718e3742002-12-13 20:15:29 +0000293 return -1;
294
295 /* neither recent */
paul718e3742002-12-13 20:15:29 +0000296 return 0;
297}
298
hasso508e53e2004-05-18 18:57:06 +0000299char *
300ospf6_lsa_printbuf (struct ospf6_lsa *lsa, char *buf, int size)
paul718e3742002-12-13 20:15:29 +0000301{
hasso508e53e2004-05-18 18:57:06 +0000302 char id[16], adv_router[16];
303 inet_ntop (AF_INET, &lsa->header->id, id, sizeof (id));
304 inet_ntop (AF_INET, &lsa->header->adv_router, adv_router,
305 sizeof (adv_router));
306 snprintf (buf, size, "[%s Id:%s Adv:%s]",
hasso1e058382004-09-01 21:36:14 +0000307 ospf6_lstype_name (lsa->header->type), id, adv_router);
hasso508e53e2004-05-18 18:57:06 +0000308 return buf;
paul718e3742002-12-13 20:15:29 +0000309}
310
hasso508e53e2004-05-18 18:57:06 +0000311void
312ospf6_lsa_header_print_raw (struct ospf6_lsa_header *header)
paul718e3742002-12-13 20:15:29 +0000313{
hasso508e53e2004-05-18 18:57:06 +0000314 char id[16], adv_router[16];
315 inet_ntop (AF_INET, &header->id, id, sizeof (id));
316 inet_ntop (AF_INET, &header->adv_router, adv_router,
317 sizeof (adv_router));
318 zlog_info (" [%s Id:%s Adv:%s]",
hasso1e058382004-09-01 21:36:14 +0000319 ospf6_lstype_name (header->type), id, adv_router);
hasso508e53e2004-05-18 18:57:06 +0000320 zlog_info (" Age: %4hu SeqNum: %#08lx Cksum: %04hx Len: %d",
321 ntohs (header->age), (u_long) ntohl (header->seqnum),
322 ntohs (header->checksum), ntohs (header->length));
paul718e3742002-12-13 20:15:29 +0000323}
324
hasso508e53e2004-05-18 18:57:06 +0000325void
326ospf6_lsa_header_print (struct ospf6_lsa *lsa)
paul718e3742002-12-13 20:15:29 +0000327{
hasso508e53e2004-05-18 18:57:06 +0000328 ospf6_lsa_age_current (lsa);
329 ospf6_lsa_header_print_raw (lsa->header);
paul718e3742002-12-13 20:15:29 +0000330}
331
332void
paul718e3742002-12-13 20:15:29 +0000333ospf6_lsa_show_summary_header (struct vty *vty)
334{
335 vty_out (vty, "%-12s %-15s %-15s %4s %8s %4s %4s %-8s%s",
336 "Type", "LSId", "AdvRouter", "Age", "SeqNum",
hasso049207c2004-08-04 20:02:13 +0000337 "Cksm", "Len", "Duration", VNL);
paul718e3742002-12-13 20:15:29 +0000338}
339
340void
341ospf6_lsa_show_summary (struct vty *vty, struct ospf6_lsa *lsa)
342{
hasso508e53e2004-05-18 18:57:06 +0000343 char adv_router[16], id[16];
paul718e3742002-12-13 20:15:29 +0000344 struct timeval now, res;
345 char duration[16];
346
347 assert (lsa);
348 assert (lsa->header);
349
paul718e3742002-12-13 20:15:29 +0000350 inet_ntop (AF_INET, &lsa->header->id, id, sizeof (id));
351 inet_ntop (AF_INET, &lsa->header->adv_router, adv_router,
352 sizeof (adv_router));
353
354 gettimeofday (&now, NULL);
hasso508e53e2004-05-18 18:57:06 +0000355 timersub (&now, &lsa->installed, &res);
356 timerstring (&res, duration, sizeof (duration));
paul718e3742002-12-13 20:15:29 +0000357
358 vty_out (vty, "%-12s %-15s %-15s %4hu %8lx %04hx %4hu %8s%s",
hasso1e058382004-09-01 21:36:14 +0000359 ospf6_lstype_name (lsa->header->type),
hasso508e53e2004-05-18 18:57:06 +0000360 id, adv_router, ospf6_lsa_age_current (lsa),
paul718e3742002-12-13 20:15:29 +0000361 (u_long) ntohl (lsa->header->seqnum),
362 ntohs (lsa->header->checksum), ntohs (lsa->header->length),
hasso049207c2004-08-04 20:02:13 +0000363 duration, VNL);
paul718e3742002-12-13 20:15:29 +0000364}
365
366void
367ospf6_lsa_show_dump (struct vty *vty, struct ospf6_lsa *lsa)
368{
369 u_char *start, *end, *current;
370 char byte[4];
371
hasso03d52f82004-09-29 00:26:19 +0000372 start = (u_char *) lsa->header;
373 end = (u_char *) lsa->header + ntohs (lsa->header->length);
paul718e3742002-12-13 20:15:29 +0000374
hasso049207c2004-08-04 20:02:13 +0000375 vty_out (vty, "%s", VNL);
376 vty_out (vty, "%s:%s", lsa->name, VNL);
paul718e3742002-12-13 20:15:29 +0000377
378 for (current = start; current < end; current ++)
379 {
380 if ((current - start) % 16 == 0)
hasso049207c2004-08-04 20:02:13 +0000381 vty_out (vty, "%s ", VNL);
paul718e3742002-12-13 20:15:29 +0000382 else if ((current - start) % 4 == 0)
383 vty_out (vty, " ");
384
385 snprintf (byte, sizeof (byte), "%02x", *current);
386 vty_out (vty, "%s", byte);
387 }
388
hasso049207c2004-08-04 20:02:13 +0000389 vty_out (vty, "%s%s", VNL, VNL);
hasso6452df02004-08-15 05:52:07 +0000390 return;
paul718e3742002-12-13 20:15:29 +0000391}
392
hasso508e53e2004-05-18 18:57:06 +0000393void
394ospf6_lsa_show_internal (struct vty *vty, struct ospf6_lsa *lsa)
395{
396 char adv_router[64], id[64];
397
398 assert (lsa && lsa->header);
399
400 inet_ntop (AF_INET, &lsa->header->id, id, sizeof (id));
401 inet_ntop (AF_INET, &lsa->header->adv_router,
402 adv_router, sizeof (adv_router));
403
hasso049207c2004-08-04 20:02:13 +0000404 vty_out (vty, "%s", VNL);
hasso508e53e2004-05-18 18:57:06 +0000405 vty_out (vty, "Age: %4hu Type: %s%s", ospf6_lsa_age_current (lsa),
hasso1e058382004-09-01 21:36:14 +0000406 ospf6_lstype_name (lsa->header->type), VNL);
hasso049207c2004-08-04 20:02:13 +0000407 vty_out (vty, "Link State ID: %s%s", id, VNL);
408 vty_out (vty, "Advertising Router: %s%s", adv_router, VNL);
hasso508e53e2004-05-18 18:57:06 +0000409 vty_out (vty, "LS Sequence Number: %#010lx%s",
hasso049207c2004-08-04 20:02:13 +0000410 (u_long) ntohl (lsa->header->seqnum), VNL);
hasso508e53e2004-05-18 18:57:06 +0000411 vty_out (vty, "CheckSum: %#06hx Length: %hu%s",
412 ntohs (lsa->header->checksum),
hasso049207c2004-08-04 20:02:13 +0000413 ntohs (lsa->header->length), VNL);
hasso508e53e2004-05-18 18:57:06 +0000414 vty_out (vty, " Prev: %p This: %p Next: %p%s",
hasso049207c2004-08-04 20:02:13 +0000415 lsa->prev, lsa, lsa->next, VNL);
416 vty_out (vty, "%s", VNL);
hasso6452df02004-08-15 05:52:07 +0000417 return;
418}
419
420void
421ospf6_lsa_show (struct vty *vty, struct ospf6_lsa *lsa)
422{
423 char adv_router[64], id[64];
hasso1e058382004-09-01 21:36:14 +0000424 struct ospf6_lsa_handler *handler;
hasso6452df02004-08-15 05:52:07 +0000425
426 assert (lsa && lsa->header);
427
428 inet_ntop (AF_INET, &lsa->header->id, id, sizeof (id));
429 inet_ntop (AF_INET, &lsa->header->adv_router,
430 adv_router, sizeof (adv_router));
431
432 vty_out (vty, "Age: %4hu Type: %s%s", ospf6_lsa_age_current (lsa),
hasso1e058382004-09-01 21:36:14 +0000433 ospf6_lstype_name (lsa->header->type), VNL);
hasso6452df02004-08-15 05:52:07 +0000434 vty_out (vty, "Link State ID: %s%s", id, VNL);
435 vty_out (vty, "Advertising Router: %s%s", adv_router, VNL);
436 vty_out (vty, "LS Sequence Number: %#010lx%s",
437 (u_long) ntohl (lsa->header->seqnum), VNL);
438 vty_out (vty, "CheckSum: %#06hx Length: %hu%s",
439 ntohs (lsa->header->checksum),
440 ntohs (lsa->header->length), VNL);
441
hasso1e058382004-09-01 21:36:14 +0000442 handler = ospf6_get_lsa_handler (lsa->header->type);
443 if (handler->show == NULL)
444 handler = &unknown_handler;
445 (*handler->show) (vty, lsa);
hasso6452df02004-08-15 05:52:07 +0000446
447 vty_out (vty, "%s", VNL);
hasso508e53e2004-05-18 18:57:06 +0000448}
449
paul718e3742002-12-13 20:15:29 +0000450/* OSPFv3 LSA creation/deletion function */
paul718e3742002-12-13 20:15:29 +0000451struct ospf6_lsa *
hasso508e53e2004-05-18 18:57:06 +0000452ospf6_lsa_create (struct ospf6_lsa_header *header)
paul718e3742002-12-13 20:15:29 +0000453{
454 struct ospf6_lsa *lsa = NULL;
hasso508e53e2004-05-18 18:57:06 +0000455 struct ospf6_lsa_header *new_header = NULL;
paul718e3742002-12-13 20:15:29 +0000456 u_int16_t lsa_size = 0;
paul718e3742002-12-13 20:15:29 +0000457
hasso508e53e2004-05-18 18:57:06 +0000458 /* size of the entire LSA */
459 lsa_size = ntohs (header->length); /* XXX vulnerable */
paul718e3742002-12-13 20:15:29 +0000460
461 /* allocate memory for this LSA */
hasso508e53e2004-05-18 18:57:06 +0000462 new_header = (struct ospf6_lsa_header *)
paul718e3742002-12-13 20:15:29 +0000463 XMALLOC (MTYPE_OSPF6_LSA, lsa_size);
paul718e3742002-12-13 20:15:29 +0000464
hasso508e53e2004-05-18 18:57:06 +0000465 /* copy LSA from original header */
466 memcpy (new_header, header, lsa_size);
paul718e3742002-12-13 20:15:29 +0000467
468 /* LSA information structure */
469 /* allocate memory */
470 lsa = (struct ospf6_lsa *)
hasso508e53e2004-05-18 18:57:06 +0000471 XMALLOC (MTYPE_OSPF6_LSA, sizeof (struct ospf6_lsa));
paul718e3742002-12-13 20:15:29 +0000472 memset (lsa, 0, sizeof (struct ospf6_lsa));
473
hasso508e53e2004-05-18 18:57:06 +0000474 lsa->header = (struct ospf6_lsa_header *) new_header;
paul718e3742002-12-13 20:15:29 +0000475
476 /* dump string */
hasso508e53e2004-05-18 18:57:06 +0000477 ospf6_lsa_printbuf (lsa, lsa->name, sizeof (lsa->name));
paul718e3742002-12-13 20:15:29 +0000478
hasso3b687352004-08-19 06:56:53 +0000479 /* calculate birth of this lsa */
paul718e3742002-12-13 20:15:29 +0000480 ospf6_lsa_age_set (lsa);
481
paul718e3742002-12-13 20:15:29 +0000482 return lsa;
483}
484
485struct ospf6_lsa *
hasso508e53e2004-05-18 18:57:06 +0000486ospf6_lsa_create_headeronly (struct ospf6_lsa_header *header)
paul718e3742002-12-13 20:15:29 +0000487{
488 struct ospf6_lsa *lsa = NULL;
hasso508e53e2004-05-18 18:57:06 +0000489 struct ospf6_lsa_header *new_header = NULL;
paul718e3742002-12-13 20:15:29 +0000490
491 /* allocate memory for this LSA */
hasso508e53e2004-05-18 18:57:06 +0000492 new_header = (struct ospf6_lsa_header *)
493 XMALLOC (MTYPE_OSPF6_LSA, sizeof (struct ospf6_lsa_header));
paul718e3742002-12-13 20:15:29 +0000494
hasso508e53e2004-05-18 18:57:06 +0000495 /* copy LSA from original header */
496 memcpy (new_header, header, sizeof (struct ospf6_lsa_header));
paul718e3742002-12-13 20:15:29 +0000497
498 /* LSA information structure */
499 /* allocate memory */
500 lsa = (struct ospf6_lsa *)
hasso508e53e2004-05-18 18:57:06 +0000501 XMALLOC (MTYPE_OSPF6_LSA, sizeof (struct ospf6_lsa));
paul718e3742002-12-13 20:15:29 +0000502 memset (lsa, 0, sizeof (struct ospf6_lsa));
503
hasso508e53e2004-05-18 18:57:06 +0000504 lsa->header = (struct ospf6_lsa_header *) new_header;
hasso6452df02004-08-15 05:52:07 +0000505 SET_FLAG (lsa->flag, OSPF6_LSA_HEADERONLY);
paul718e3742002-12-13 20:15:29 +0000506
507 /* dump string */
hasso508e53e2004-05-18 18:57:06 +0000508 ospf6_lsa_printbuf (lsa, lsa->name, sizeof (lsa->name));
paul718e3742002-12-13 20:15:29 +0000509
hasso3b687352004-08-19 06:56:53 +0000510 /* calculate birth of this lsa */
paul718e3742002-12-13 20:15:29 +0000511 ospf6_lsa_age_set (lsa);
512
paul718e3742002-12-13 20:15:29 +0000513 return lsa;
514}
515
516void
517ospf6_lsa_delete (struct ospf6_lsa *lsa)
518{
hasso508e53e2004-05-18 18:57:06 +0000519 assert (lsa->lock == 0);
paul718e3742002-12-13 20:15:29 +0000520
521 /* cancel threads */
hasso508e53e2004-05-18 18:57:06 +0000522 THREAD_OFF (lsa->expire);
523 THREAD_OFF (lsa->refresh);
paul718e3742002-12-13 20:15:29 +0000524
paul718e3742002-12-13 20:15:29 +0000525 /* do free */
hasso508e53e2004-05-18 18:57:06 +0000526 XFREE (MTYPE_OSPF6_LSA, lsa->header);
527 XFREE (MTYPE_OSPF6_LSA, lsa);
paul718e3742002-12-13 20:15:29 +0000528}
529
hasso508e53e2004-05-18 18:57:06 +0000530struct ospf6_lsa *
531ospf6_lsa_copy (struct ospf6_lsa *lsa)
532{
533 struct ospf6_lsa *copy = NULL;
534
hasso508e53e2004-05-18 18:57:06 +0000535 ospf6_lsa_age_current (lsa);
hasso6452df02004-08-15 05:52:07 +0000536 if (CHECK_FLAG (lsa->flag, OSPF6_LSA_HEADERONLY))
hasso508e53e2004-05-18 18:57:06 +0000537 copy = ospf6_lsa_create_headeronly (lsa->header);
538 else
539 copy = ospf6_lsa_create (lsa->header);
540 assert (copy->lock == 0);
541
hasso3b687352004-08-19 06:56:53 +0000542 copy->birth = lsa->birth;
hasso508e53e2004-05-18 18:57:06 +0000543 copy->originated = lsa->originated;
hassoccb59b12004-08-25 09:10:37 +0000544 copy->received = lsa->received;
545 copy->installed = lsa->installed;
hasso6452df02004-08-15 05:52:07 +0000546 copy->lsdb = lsa->lsdb;
hasso508e53e2004-05-18 18:57:06 +0000547
hasso508e53e2004-05-18 18:57:06 +0000548 return copy;
549}
550
551/* increment reference counter of struct ospf6_lsa */
paul718e3742002-12-13 20:15:29 +0000552void
553ospf6_lsa_lock (struct ospf6_lsa *lsa)
554{
555 lsa->lock++;
556 return;
557}
558
hasso508e53e2004-05-18 18:57:06 +0000559/* decrement reference counter of struct ospf6_lsa */
paul718e3742002-12-13 20:15:29 +0000560void
561ospf6_lsa_unlock (struct ospf6_lsa *lsa)
562{
563 /* decrement reference counter */
hasso508e53e2004-05-18 18:57:06 +0000564 assert (lsa->lock > 0);
565 lsa->lock--;
paul718e3742002-12-13 20:15:29 +0000566
hasso508e53e2004-05-18 18:57:06 +0000567 if (lsa->lock != 0)
568 return;
569
hasso508e53e2004-05-18 18:57:06 +0000570 ospf6_lsa_delete (lsa);
paul718e3742002-12-13 20:15:29 +0000571}
572
paul718e3742002-12-13 20:15:29 +0000573
hasso508e53e2004-05-18 18:57:06 +0000574/* ospf6 lsa expiry */
paul718e3742002-12-13 20:15:29 +0000575int
576ospf6_lsa_expire (struct thread *thread)
577{
578 struct ospf6_lsa *lsa;
paul718e3742002-12-13 20:15:29 +0000579
580 lsa = (struct ospf6_lsa *) THREAD_ARG (thread);
paul718e3742002-12-13 20:15:29 +0000581
hasso508e53e2004-05-18 18:57:06 +0000582 assert (lsa && lsa->header);
583 assert (OSPF6_LSA_IS_MAXAGE (lsa));
584 assert (! lsa->refresh);
paul718e3742002-12-13 20:15:29 +0000585
586 lsa->expire = (struct thread *) NULL;
587
hasso1e058382004-09-01 21:36:14 +0000588 if (IS_OSPF6_DEBUG_LSA_TYPE (lsa->header->type))
paul718e3742002-12-13 20:15:29 +0000589 {
hasso508e53e2004-05-18 18:57:06 +0000590 zlog_info ("LSA Expire:");
591 ospf6_lsa_header_print (lsa);
paul718e3742002-12-13 20:15:29 +0000592 }
593
hasso6452df02004-08-15 05:52:07 +0000594 if (CHECK_FLAG (lsa->flag, OSPF6_LSA_HEADERONLY))
hasso508e53e2004-05-18 18:57:06 +0000595 return 0; /* dbexchange will do something ... */
596
597 /* reflood lsa */
hasso6452df02004-08-15 05:52:07 +0000598 ospf6_flood (NULL, lsa);
hasso508e53e2004-05-18 18:57:06 +0000599
600 /* reinstall lsa */
hasso3b687352004-08-19 06:56:53 +0000601 ospf6_install_lsa (lsa);
hasso508e53e2004-05-18 18:57:06 +0000602
603 /* schedule maxage remover */
604 ospf6_maxage_remove (ospf6);
605
paul718e3742002-12-13 20:15:29 +0000606 return 0;
607}
608
609int
610ospf6_lsa_refresh (struct thread *thread)
611{
hasso6452df02004-08-15 05:52:07 +0000612 struct ospf6_lsa *old, *self, *new;
613 struct ospf6_lsdb *lsdb_self;
paul718e3742002-12-13 20:15:29 +0000614
615 assert (thread);
hasso6452df02004-08-15 05:52:07 +0000616 old = (struct ospf6_lsa *) THREAD_ARG (thread);
617 assert (old && old->header);
paul718e3742002-12-13 20:15:29 +0000618
hasso6452df02004-08-15 05:52:07 +0000619 old->refresh = (struct thread *) NULL;
paul718e3742002-12-13 20:15:29 +0000620
hasso6452df02004-08-15 05:52:07 +0000621 lsdb_self = ospf6_get_scoped_lsdb_self (old);
622 self = ospf6_lsdb_lookup (old->header->type, old->header->id,
623 old->header->adv_router, lsdb_self);
624 if (self == NULL)
625 {
hasso1e058382004-09-01 21:36:14 +0000626 if (IS_OSPF6_DEBUG_LSA_TYPE (old->header->type))
hasso3b687352004-08-19 06:56:53 +0000627 zlog_info ("Refresh: could not find self LSA, flush %s", old->name);
hasso6452df02004-08-15 05:52:07 +0000628 ospf6_lsa_premature_aging (old);
629 return 0;
630 }
631
632 /* Reset age, increment LS sequence number. */
633 self->header->age = htons (0);
634 self->header->seqnum =
635 ospf6_new_ls_seqnum (self->header->type, self->header->id,
636 self->header->adv_router, old->lsdb);
637 ospf6_lsa_checksum (self->header);
638
639 new = ospf6_lsa_create (self->header);
640 new->lsdb = old->lsdb;
641 new->refresh = thread_add_timer (master, ospf6_lsa_refresh, new,
642 LS_REFRESH_TIME);
643
644 /* store it in the LSDB for self-originated LSAs */
645 ospf6_lsdb_add (ospf6_lsa_copy (new), lsdb_self);
paul718e3742002-12-13 20:15:29 +0000646
hasso1e058382004-09-01 21:36:14 +0000647 if (IS_OSPF6_DEBUG_LSA_TYPE (new->header->type))
paul718e3742002-12-13 20:15:29 +0000648 {
hasso508e53e2004-05-18 18:57:06 +0000649 zlog_info ("LSA Refresh:");
hasso6452df02004-08-15 05:52:07 +0000650 ospf6_lsa_header_print (new);
paul718e3742002-12-13 20:15:29 +0000651 }
652
hasso6452df02004-08-15 05:52:07 +0000653 ospf6_flood_clear (old);
654 ospf6_flood (NULL, new);
655 ospf6_install_lsa (new);
656
hasso508e53e2004-05-18 18:57:06 +0000657 return 0;
paul718e3742002-12-13 20:15:29 +0000658}
659
660
661
662/* enhanced Fletcher checksum algorithm, RFC1008 7.2 */
663#define MODX 4102
664#define LSA_CHECKSUM_OFFSET 15
665
666unsigned short
667ospf6_lsa_checksum (struct ospf6_lsa_header *lsa_header)
668{
669 u_char *sp, *ep, *p, *q;
670 int c0 = 0, c1 = 0;
671 int x, y;
672 u_int16_t length;
673
674 lsa_header->checksum = 0;
675 length = ntohs (lsa_header->length) - 2;
hasso03d52f82004-09-29 00:26:19 +0000676 sp = (u_char *) &lsa_header->type;
paul718e3742002-12-13 20:15:29 +0000677
678 for (ep = sp + length; sp < ep; sp = q)
679 {
680 q = sp + MODX;
681 if (q > ep)
682 q = ep;
683 for (p = sp; p < q; p++)
684 {
685 c0 += *p;
686 c1 += c0;
687 }
688 c0 %= 255;
689 c1 %= 255;
690 }
691
692 /* r = (c1 << 8) + c0; */
693 x = ((length - LSA_CHECKSUM_OFFSET) * c0 - c1) % 255;
694 if (x <= 0)
695 x += 255;
696 y = 510 - c0 - x;
697 if (y > 255)
698 y -= 255;
699
700 lsa_header->checksum = htons ((x << 8) + y);
701
702 return (lsa_header->checksum);
703}
704
hasso6452df02004-08-15 05:52:07 +0000705void
paul718e3742002-12-13 20:15:29 +0000706ospf6_lsa_init ()
707{
hasso1e058382004-09-01 21:36:14 +0000708 ospf6_lsa_handler_vector = vector_init (0);
hasso6452df02004-08-15 05:52:07 +0000709 ospf6_install_lsa_handler (&unknown_handler);
paul718e3742002-12-13 20:15:29 +0000710}
711
hasso508e53e2004-05-18 18:57:06 +0000712
hasso1e058382004-09-01 21:36:14 +0000713char *
714ospf6_lsa_handler_name (struct ospf6_lsa_handler *h)
hasso508e53e2004-05-18 18:57:06 +0000715{
hasso1e058382004-09-01 21:36:14 +0000716 static char buf[64];
paul0c083ee2004-10-10 12:54:58 +0000717 unsigned int i;
718 unsigned int size = strlen (h->name);
hasso508e53e2004-05-18 18:57:06 +0000719
hasso1e058382004-09-01 21:36:14 +0000720 if (h->name == "Unknown" &&
721 h->type != OSPF6_LSTYPE_UNKNOWN)
hasso508e53e2004-05-18 18:57:06 +0000722 {
hasso1e058382004-09-01 21:36:14 +0000723 snprintf (buf, sizeof (buf), "%#04hx", h->type);
724 return buf;
hasso508e53e2004-05-18 18:57:06 +0000725 }
726
hasso1e058382004-09-01 21:36:14 +0000727 for (i = 0; i < MIN (size, sizeof (buf)); i++)
hasso508e53e2004-05-18 18:57:06 +0000728 {
hasso1e058382004-09-01 21:36:14 +0000729 if (! islower (h->name[i]))
730 buf[i] = tolower (h->name[i]);
hasso508e53e2004-05-18 18:57:06 +0000731 else
hasso1e058382004-09-01 21:36:14 +0000732 buf[i] = h->name[i];
733 }
734 buf[size] = '\0';
735 return buf;
736}
hasso508e53e2004-05-18 18:57:06 +0000737
hasso1e058382004-09-01 21:36:14 +0000738DEFUN (debug_ospf6_lsa_type,
739 debug_ospf6_lsa_hex_cmd,
740 "debug ospf6 lsa XXXX/0xXXXX",
741 DEBUG_STR
742 OSPF6_STR
743 "Debug Link State Advertisements (LSAs)\n"
744 "Specify LS type as Hexadecimal\n"
745 )
746{
paul0c083ee2004-10-10 12:54:58 +0000747 unsigned int i;
hasso1e058382004-09-01 21:36:14 +0000748 struct ospf6_lsa_handler *handler = NULL;
749 unsigned long val;
750 char *endptr = NULL;
751 u_int16_t type = 0;
752
753 assert (argc);
754
755 if ((strlen (argv[0]) == 6 && ! strncmp (argv[0], "0x", 2)) ||
756 (strlen (argv[0]) == 4))
757 {
758 val = strtoul (argv[0], &endptr, 16);
759 if (*endptr == '\0')
760 type = val;
hasso508e53e2004-05-18 18:57:06 +0000761 }
762
hasso1e058382004-09-01 21:36:14 +0000763 for (i = 0; i < vector_max (ospf6_lsa_handler_vector); i++)
764 {
765 handler = vector_slot (ospf6_lsa_handler_vector, i);
766 if (handler == NULL)
767 continue;
768 if (type && handler->type == type)
769 break;
770 if (! strcasecmp (argv[0], handler->name))
771 break;
772 handler = NULL;
773 }
774
775 if (type && handler == NULL)
776 {
777 handler = (struct ospf6_lsa_handler *)
778 malloc (sizeof (struct ospf6_lsa_handler));
779 memset (handler, 0, sizeof (struct ospf6_lsa_handler));
780 handler->type = type;
781 handler->name = "Unknown";
782 handler->show = ospf6_unknown_lsa_show;
783 vector_set_index (ospf6_lsa_handler_vector,
784 handler->type & OSPF6_LSTYPE_FCODE_MASK, handler);
785 }
786
787 if (handler == NULL)
788 handler = &unknown_handler;
789
790 if (argc >= 2)
791 {
792 if (! strcmp (argv[1], "originate"))
793 SET_FLAG (handler->debug, OSPF6_LSA_DEBUG_ORIGINATE);
794 if (! strcmp (argv[1], "examin"))
795 SET_FLAG (handler->debug, OSPF6_LSA_DEBUG_EXAMIN);
796 if (! strcmp (argv[1], "flooding"))
797 SET_FLAG (handler->debug, OSPF6_LSA_DEBUG_FLOOD);
798 }
799 else
800 SET_FLAG (handler->debug, OSPF6_LSA_DEBUG);
801
802 return CMD_SUCCESS;
hasso508e53e2004-05-18 18:57:06 +0000803}
804
hasso1e058382004-09-01 21:36:14 +0000805DEFUN (no_debug_ospf6_lsa_type,
806 no_debug_ospf6_lsa_hex_cmd,
807 "no debug ospf6 lsa XXXX/0xXXXX",
808 NO_STR
809 DEBUG_STR
810 OSPF6_STR
811 "Debug Link State Advertisements (LSAs)\n"
812 "Specify LS type as Hexadecimal\n"
813 )
814{
paul0c083ee2004-10-10 12:54:58 +0000815 u_int i;
hasso1e058382004-09-01 21:36:14 +0000816 struct ospf6_lsa_handler *handler = NULL;
817 unsigned long val;
818 char *endptr = NULL;
819 u_int16_t type = 0;
820
821 assert (argc);
822
823 if ((strlen (argv[0]) == 6 && ! strncmp (argv[0], "0x", 2)) ||
824 (strlen (argv[0]) == 4))
825 {
826 val = strtoul (argv[0], &endptr, 16);
827 if (*endptr == '\0')
828 type = val;
829 }
830
831 for (i = 0; i < vector_max (ospf6_lsa_handler_vector); i++)
832 {
833 handler = vector_slot (ospf6_lsa_handler_vector, i);
834 if (handler == NULL)
835 continue;
836 if (type && handler->type == type)
837 break;
838 if (! strcasecmp (argv[0], handler->name))
839 break;
840 }
841
842 if (handler == NULL)
843 return CMD_SUCCESS;
844
845 if (argc >= 2)
846 {
847 if (! strcmp (argv[1], "originate"))
848 UNSET_FLAG (handler->debug, OSPF6_LSA_DEBUG_ORIGINATE);
849 if (! strcmp (argv[1], "examin"))
850 UNSET_FLAG (handler->debug, OSPF6_LSA_DEBUG_EXAMIN);
851 if (! strcmp (argv[1], "flooding"))
852 UNSET_FLAG (handler->debug, OSPF6_LSA_DEBUG_FLOOD);
853 }
854 else
855 UNSET_FLAG (handler->debug, OSPF6_LSA_DEBUG);
856
857 if (handler->debug == 0 &&
858 handler->name == "Unknown" && type != OSPF6_LSTYPE_UNKNOWN)
859 {
860 free (handler);
861 vector_slot (ospf6_lsa_handler_vector, i) = NULL;
862 }
863
864 return CMD_SUCCESS;
865}
866
867struct cmd_element debug_ospf6_lsa_type_cmd;
868struct cmd_element debug_ospf6_lsa_type_detail_cmd;
869struct cmd_element no_debug_ospf6_lsa_type_cmd;
870struct cmd_element no_debug_ospf6_lsa_type_detail_cmd;
871
hasso508e53e2004-05-18 18:57:06 +0000872void
873install_element_ospf6_debug_lsa ()
874{
paul0c083ee2004-10-10 12:54:58 +0000875 u_int i;
hasso1e058382004-09-01 21:36:14 +0000876 struct ospf6_lsa_handler *handler;
877#define STRSIZE 256
878#define DOCSIZE 1024
879 static char strbuf[STRSIZE];
880 static char docbuf[DOCSIZE];
881 static char detail_strbuf[STRSIZE];
882 static char detail_docbuf[DOCSIZE];
883 char *str, *no_str;
884 char *doc, *no_doc;
885
886 strbuf[0] = '\0';
887 no_str = &strbuf[strlen (strbuf)];
888 strncat (strbuf, "no ", STRSIZE - strlen (strbuf));
889 str = &strbuf[strlen (strbuf)];
890
891 strncat (strbuf, "debug ospf6 lsa (", STRSIZE - strlen (strbuf));
892 for (i = 0; i < vector_max (ospf6_lsa_handler_vector); i++)
893 {
894 handler = vector_slot (ospf6_lsa_handler_vector, i);
895 if (handler == NULL)
896 continue;
897 strncat (strbuf, ospf6_lsa_handler_name (handler),
898 STRSIZE - strlen (strbuf));
899 strncat (strbuf, "|", STRSIZE - strlen (strbuf));
900 }
901 strbuf[strlen (strbuf) - 1] = ')';
902 strbuf[strlen (strbuf)] = '\0';
903
904 docbuf[0] = '\0';
905 no_doc = &docbuf[strlen (docbuf)];
906 strncat (docbuf, NO_STR, DOCSIZE - strlen (docbuf));
907 doc = &docbuf[strlen (docbuf)];
908
909 strncat (docbuf, DEBUG_STR, DOCSIZE - strlen (docbuf));
910 strncat (docbuf, OSPF6_STR, DOCSIZE - strlen (docbuf));
911 strncat (docbuf, "Debug Link State Advertisements (LSAs)\n",
912 DOCSIZE - strlen (docbuf));
913
914 for (i = 0; i < vector_max (ospf6_lsa_handler_vector); i++)
915 {
916 handler = vector_slot (ospf6_lsa_handler_vector, i);
917 if (handler == NULL)
918 continue;
919 strncat (docbuf, "Debug ", DOCSIZE - strlen (docbuf));
920 strncat (docbuf, handler->name, DOCSIZE - strlen (docbuf));
921 strncat (docbuf, "-LSA\n", DOCSIZE - strlen (docbuf));
922 }
923 docbuf[strlen (docbuf)] = '\0';
924
925 debug_ospf6_lsa_type_cmd.string = str;
926 debug_ospf6_lsa_type_cmd.func = debug_ospf6_lsa_type;
927 debug_ospf6_lsa_type_cmd.doc = doc;
928
929 no_debug_ospf6_lsa_type_cmd.string = no_str;
930 no_debug_ospf6_lsa_type_cmd.func = no_debug_ospf6_lsa_type;
931 no_debug_ospf6_lsa_type_cmd.doc = no_doc;
932
933 strncpy (detail_strbuf, strbuf, STRSIZE);
934 strncat (detail_strbuf, " (originate|examin|flooding)",
935 STRSIZE - strlen (detail_strbuf));
936 detail_strbuf[strlen (detail_strbuf)] = '\0';
937 no_str = &detail_strbuf[0];
938 str = &detail_strbuf[strlen ("no ")];
939
940 strncpy (detail_docbuf, docbuf, DOCSIZE);
941 strncat (detail_docbuf, "Debug Originating LSA\n",
942 DOCSIZE - strlen (detail_docbuf));
943 strncat (detail_docbuf, "Debug Examining LSA\n",
944 DOCSIZE - strlen (detail_docbuf));
945 strncat (detail_docbuf, "Debug Flooding LSA\n",
946 DOCSIZE - strlen (detail_docbuf));
947 detail_docbuf[strlen (detail_docbuf)] = '\0';
948 no_doc = &detail_docbuf[0];
949 doc = &detail_docbuf[strlen (NO_STR)];
950
951 debug_ospf6_lsa_type_detail_cmd.string = str;
952 debug_ospf6_lsa_type_detail_cmd.func = debug_ospf6_lsa_type;
953 debug_ospf6_lsa_type_detail_cmd.doc = doc;
954
955 no_debug_ospf6_lsa_type_detail_cmd.string = no_str;
956 no_debug_ospf6_lsa_type_detail_cmd.func = no_debug_ospf6_lsa_type;
957 no_debug_ospf6_lsa_type_detail_cmd.doc = no_doc;
958
959 install_element (ENABLE_NODE, &debug_ospf6_lsa_hex_cmd);
960 install_element (ENABLE_NODE, &debug_ospf6_lsa_type_cmd);
961 install_element (ENABLE_NODE, &debug_ospf6_lsa_type_detail_cmd);
962 install_element (ENABLE_NODE, &no_debug_ospf6_lsa_hex_cmd);
963 install_element (ENABLE_NODE, &no_debug_ospf6_lsa_type_cmd);
964 install_element (ENABLE_NODE, &no_debug_ospf6_lsa_type_detail_cmd);
965 install_element (CONFIG_NODE, &debug_ospf6_lsa_hex_cmd);
966 install_element (CONFIG_NODE, &debug_ospf6_lsa_type_cmd);
967 install_element (CONFIG_NODE, &debug_ospf6_lsa_type_detail_cmd);
968 install_element (CONFIG_NODE, &no_debug_ospf6_lsa_hex_cmd);
969 install_element (CONFIG_NODE, &no_debug_ospf6_lsa_type_cmd);
970 install_element (CONFIG_NODE, &no_debug_ospf6_lsa_type_detail_cmd);
971}
972
973int
974config_write_ospf6_debug_lsa (struct vty *vty)
975{
paul0c083ee2004-10-10 12:54:58 +0000976 u_int i;
hasso1e058382004-09-01 21:36:14 +0000977 struct ospf6_lsa_handler *handler;
978
979 for (i = 0; i < vector_max (ospf6_lsa_handler_vector); i++)
980 {
981 handler = vector_slot (ospf6_lsa_handler_vector, i);
982 if (handler == NULL)
983 continue;
984 if (CHECK_FLAG (handler->debug, OSPF6_LSA_DEBUG))
985 vty_out (vty, "debug ospf6 lsa %s%s",
986 ospf6_lsa_handler_name (handler), VNL);
987 if (CHECK_FLAG (handler->debug, OSPF6_LSA_DEBUG_ORIGINATE))
988 vty_out (vty, "debug ospf6 lsa %s originate%s",
989 ospf6_lsa_handler_name (handler), VNL);
990 if (CHECK_FLAG (handler->debug, OSPF6_LSA_DEBUG_EXAMIN))
991 vty_out (vty, "debug ospf6 lsa %s examin%s",
992 ospf6_lsa_handler_name (handler), VNL);
993 if (CHECK_FLAG (handler->debug, OSPF6_LSA_DEBUG_FLOOD))
994 vty_out (vty, "debug ospf6 lsa %s flooding%s",
995 ospf6_lsa_handler_name (handler), VNL);
996 }
997
998 return 0;
hasso508e53e2004-05-18 18:57:06 +0000999}
1000
1001