paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1 | /* |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 2 | * Copyright (C) 2003 Yasuhiro Ohara |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3 | * |
| 4 | * This file is part of GNU Zebra. |
| 5 | * |
| 6 | * GNU Zebra is free software; you can redistribute it and/or modify it |
| 7 | * under the terms of the GNU General Public License as published by the |
| 8 | * Free Software Foundation; either version 2, or (at your option) any |
| 9 | * later version. |
| 10 | * |
| 11 | * GNU Zebra is distributed in the hope that it will be useful, but |
| 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | * General Public License for more details. |
| 15 | * |
| 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 */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 25 | #include "log.h" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 26 | #include "linklist.h" |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 27 | #include "vector.h" |
| 28 | #include "vty.h" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 29 | #include "command.h" |
| 30 | #include "memory.h" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 31 | #include "thread.h" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 32 | |
| 33 | #include "ospf6_proto.h" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 34 | #include "ospf6_lsa.h" |
| 35 | #include "ospf6_lsdb.h" |
| 36 | #include "ospf6_message.h" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 37 | |
| 38 | #include "ospf6_top.h" |
| 39 | #include "ospf6_area.h" |
| 40 | #include "ospf6_interface.h" |
| 41 | #include "ospf6_neighbor.h" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 42 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 43 | #include "ospf6_flood.h" |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 44 | #include "ospf6d.h" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 45 | |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 46 | vector ospf6_lsa_handler_vector; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 47 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 48 | static int |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 49 | ospf6_unknown_lsa_show (struct vty *vty, struct ospf6_lsa *lsa) |
| 50 | { |
| 51 | u_char *start, *end, *current; |
| 52 | char byte[4]; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 53 | |
hasso | 03d52f8 | 2004-09-29 00:26:19 +0000 | [diff] [blame] | 54 | start = (u_char *) lsa->header + sizeof (struct ospf6_lsa_header); |
| 55 | end = (u_char *) lsa->header + ntohs (lsa->header->length); |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 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 | |
| 73 | struct ospf6_lsa_handler unknown_handler = |
| 74 | { |
| 75 | OSPF6_LSTYPE_UNKNOWN, |
| 76 | "Unknown", |
| 77 | ospf6_unknown_lsa_show, |
| 78 | OSPF6_LSA_DEBUG, |
| 79 | }; |
| 80 | |
| 81 | void |
| 82 | ospf6_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 | |
| 89 | struct ospf6_lsa_handler * |
| 90 | ospf6_get_lsa_handler (u_int16_t type) |
| 91 | { |
| 92 | struct ospf6_lsa_handler *handler = NULL; |
paul | 0c083ee | 2004-10-10 12:54:58 +0000 | [diff] [blame] | 93 | unsigned int index = ntohs (type) & OSPF6_LSTYPE_FCODE_MASK; |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 94 | |
paul | 55468c8 | 2005-03-14 20:19:01 +0000 | [diff] [blame] | 95 | if (index >= vector_active (ospf6_lsa_handler_vector)) |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 96 | handler = &unknown_handler; |
| 97 | else |
| 98 | handler = vector_slot (ospf6_lsa_handler_vector, index); |
| 99 | |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 100 | if (handler == NULL) |
| 101 | handler = &unknown_handler; |
| 102 | |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 103 | return handler; |
| 104 | } |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 105 | |
paul | 0c083ee | 2004-10-10 12:54:58 +0000 | [diff] [blame] | 106 | const char * |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 107 | ospf6_lstype_name (u_int16_t type) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 108 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 109 | static char buf[8]; |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 110 | struct ospf6_lsa_handler *handler; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 111 | |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 112 | handler = ospf6_get_lsa_handler (type); |
| 113 | if (handler && handler != &unknown_handler) |
| 114 | return handler->name; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 115 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 116 | snprintf (buf, sizeof (buf), "0x%04hx", ntohs (type)); |
| 117 | return buf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 118 | } |
| 119 | |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 120 | u_char |
| 121 | ospf6_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 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 128 | /* RFC2328: Section 13.2 */ |
| 129 | int |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 130 | ospf6_lsa_is_differ (struct ospf6_lsa *lsa1, |
| 131 | struct ospf6_lsa *lsa2) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 132 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 133 | int len; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 134 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 135 | assert (OSPF6_LSA_IS_SAME (lsa1, lsa2)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 136 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 137 | /* XXX, Options ??? */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 138 | |
| 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 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 152 | len = ntohs (lsa1->header->length) - sizeof (struct ospf6_lsa_header); |
| 153 | return memcmp (lsa1->header + 1, lsa2->header + 1, len); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 154 | } |
| 155 | |
| 156 | int |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 157 | ospf6_lsa_is_changed (struct ospf6_lsa *lsa1, |
| 158 | struct ospf6_lsa *lsa2) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 159 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 160 | int length; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 161 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 162 | 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; |
Denis Ovsienko | 308687b | 2011-09-26 13:18:36 +0400 | [diff] [blame] | 166 | /* Going beyond LSA headers to compare the payload only makes sense, when both LSAs aren't header-only. */ |
| 167 | if (CHECK_FLAG (lsa1->flag, OSPF6_LSA_HEADERONLY) != CHECK_FLAG (lsa2->flag, OSPF6_LSA_HEADERONLY)) |
| 168 | { |
| 169 | zlog_warn ("%s: only one of two (%s, %s) LSAs compared is header-only", __func__, lsa1->name, lsa2->name); |
| 170 | return 1; |
| 171 | } |
| 172 | if (CHECK_FLAG (lsa1->flag, OSPF6_LSA_HEADERONLY)) |
| 173 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 174 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 175 | length = OSPF6_LSA_SIZE (lsa1->header) - sizeof (struct ospf6_lsa_header); |
Denis Ovsienko | 308687b | 2011-09-26 13:18:36 +0400 | [diff] [blame] | 176 | /* Once upper layer verifies LSAs received, length underrun should become a warning. */ |
| 177 | if (length <= 0) |
| 178 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 179 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 180 | return memcmp (OSPF6_LSA_HEADER_END (lsa1->header), |
| 181 | OSPF6_LSA_HEADER_END (lsa2->header), length); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 182 | } |
| 183 | |
| 184 | /* ospf6 age functions */ |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 185 | /* calculate birth */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 186 | static void |
| 187 | ospf6_lsa_age_set (struct ospf6_lsa *lsa) |
| 188 | { |
| 189 | struct timeval now; |
| 190 | |
| 191 | assert (lsa && lsa->header); |
| 192 | |
Takashi Sogabe | 86f72dc | 2009-06-22 13:07:02 +0900 | [diff] [blame] | 193 | if (quagga_gettime (QUAGGA_CLK_MONOTONIC, &now) < 0) |
| 194 | zlog_warn ("LSA: quagga_gettime failed, may fail LSA AGEs: %s", |
ajs | 6099b3b | 2004-11-20 02:06:59 +0000 | [diff] [blame] | 195 | safe_strerror (errno)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 196 | |
| 197 | lsa->birth.tv_sec = now.tv_sec - ntohs (lsa->header->age); |
| 198 | lsa->birth.tv_usec = now.tv_usec; |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 199 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 200 | return; |
| 201 | } |
| 202 | |
| 203 | /* this function calculates current age from its birth, |
| 204 | then update age field of LSA header. return value is current age */ |
| 205 | u_int16_t |
| 206 | ospf6_lsa_age_current (struct ospf6_lsa *lsa) |
| 207 | { |
| 208 | struct timeval now; |
| 209 | u_int32_t ulage; |
| 210 | u_int16_t age; |
| 211 | |
| 212 | assert (lsa); |
| 213 | assert (lsa->header); |
| 214 | |
| 215 | /* current time */ |
Takashi Sogabe | 86f72dc | 2009-06-22 13:07:02 +0900 | [diff] [blame] | 216 | if (quagga_gettime (QUAGGA_CLK_MONOTONIC, &now) < 0) |
| 217 | zlog_warn ("LSA: quagga_gettime failed, may fail LSA AGEs: %s", |
ajs | 6099b3b | 2004-11-20 02:06:59 +0000 | [diff] [blame] | 218 | safe_strerror (errno)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 219 | |
Tom Henderson | aabbb1a | 2009-08-28 15:10:00 +0100 | [diff] [blame] | 220 | if (ntohs (lsa->header->age) >= MAXAGE) |
Tom Henderson | 9b4ef25 | 2009-07-16 17:20:37 +0100 | [diff] [blame] | 221 | { |
Tom Henderson | aabbb1a | 2009-08-28 15:10:00 +0100 | [diff] [blame] | 222 | /* ospf6_lsa_premature_aging () sets age to MAXAGE; when using |
| 223 | relative time, we cannot compare against lsa birth time, so |
| 224 | we catch this special case here. */ |
Tom Henderson | 9b4ef25 | 2009-07-16 17:20:37 +0100 | [diff] [blame] | 225 | lsa->header->age = htons (MAXAGE); |
| 226 | return MAXAGE; |
| 227 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 228 | /* calculate age */ |
| 229 | ulage = now.tv_sec - lsa->birth.tv_sec; |
| 230 | |
| 231 | /* if over MAXAGE, set to it */ |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 232 | age = (ulage > MAXAGE ? MAXAGE : ulage); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 233 | |
| 234 | lsa->header->age = htons (age); |
| 235 | return age; |
| 236 | } |
| 237 | |
| 238 | /* update age field of LSA header with adding InfTransDelay */ |
| 239 | void |
| 240 | ospf6_lsa_age_update_to_send (struct ospf6_lsa *lsa, u_int32_t transdelay) |
| 241 | { |
| 242 | unsigned short age; |
| 243 | |
| 244 | age = ospf6_lsa_age_current (lsa) + transdelay; |
| 245 | if (age > MAXAGE) |
| 246 | age = MAXAGE; |
| 247 | lsa->header->age = htons (age); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 248 | } |
| 249 | |
| 250 | void |
| 251 | ospf6_lsa_premature_aging (struct ospf6_lsa *lsa) |
| 252 | { |
| 253 | /* log */ |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 254 | if (IS_OSPF6_DEBUG_LSA_TYPE (lsa->header->type)) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 255 | zlog_debug ("LSA: Premature aging: %s", lsa->name); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 256 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 257 | THREAD_OFF (lsa->expire); |
| 258 | THREAD_OFF (lsa->refresh); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 259 | |
Tom Henderson | 9b4ef25 | 2009-07-16 17:20:37 +0100 | [diff] [blame] | 260 | lsa->header->age = htons (MAXAGE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 261 | thread_execute (master, ospf6_lsa_expire, lsa, 0); |
| 262 | } |
| 263 | |
| 264 | /* check which is more recent. if a is more recent, return -1; |
| 265 | if the same, return 0; otherwise(b is more recent), return 1 */ |
| 266 | int |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 267 | ospf6_lsa_compare (struct ospf6_lsa *a, struct ospf6_lsa *b) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 268 | { |
Ondrej Zajicek | 64bf3ab | 2009-12-07 12:33:20 +0300 | [diff] [blame] | 269 | int seqnuma, seqnumb; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 270 | u_int16_t cksuma, cksumb; |
| 271 | u_int16_t agea, ageb; |
| 272 | |
| 273 | assert (a && a->header); |
| 274 | assert (b && b->header); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 275 | assert (OSPF6_LSA_IS_SAME (a, b)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 276 | |
Ondrej Zajicek | 64bf3ab | 2009-12-07 12:33:20 +0300 | [diff] [blame] | 277 | seqnuma = (int) ntohl (a->header->seqnum); |
| 278 | seqnumb = (int) ntohl (b->header->seqnum); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 279 | |
| 280 | /* compare by sequence number */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 281 | if (seqnuma > seqnumb) |
| 282 | return -1; |
Ondrej Zajicek | 64bf3ab | 2009-12-07 12:33:20 +0300 | [diff] [blame] | 283 | if (seqnuma < seqnumb) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 284 | return 1; |
| 285 | |
| 286 | /* Checksum */ |
| 287 | cksuma = ntohs (a->header->checksum); |
| 288 | cksumb = ntohs (b->header->checksum); |
| 289 | if (cksuma > cksumb) |
| 290 | return -1; |
| 291 | if (cksuma < cksumb) |
| 292 | return 0; |
| 293 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 294 | /* Update Age */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 295 | agea = ospf6_lsa_age_current (a); |
| 296 | ageb = ospf6_lsa_age_current (b); |
| 297 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 298 | /* MaxAge check */ |
| 299 | if (agea == MAXAGE && ageb != MAXAGE) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 300 | return -1; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 301 | else if (agea != MAXAGE && ageb == MAXAGE) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 302 | return 1; |
| 303 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 304 | /* Age check */ |
| 305 | if (agea > ageb && agea - ageb >= MAX_AGE_DIFF) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 306 | return 1; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 307 | else if (agea < ageb && ageb - agea >= MAX_AGE_DIFF) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 308 | return -1; |
| 309 | |
| 310 | /* neither recent */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 311 | return 0; |
| 312 | } |
| 313 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 314 | char * |
| 315 | ospf6_lsa_printbuf (struct ospf6_lsa *lsa, char *buf, int size) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 316 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 317 | char id[16], adv_router[16]; |
| 318 | inet_ntop (AF_INET, &lsa->header->id, id, sizeof (id)); |
| 319 | inet_ntop (AF_INET, &lsa->header->adv_router, adv_router, |
| 320 | sizeof (adv_router)); |
| 321 | snprintf (buf, size, "[%s Id:%s Adv:%s]", |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 322 | ospf6_lstype_name (lsa->header->type), id, adv_router); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 323 | return buf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 324 | } |
| 325 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 326 | void |
| 327 | ospf6_lsa_header_print_raw (struct ospf6_lsa_header *header) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 328 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 329 | char id[16], adv_router[16]; |
| 330 | inet_ntop (AF_INET, &header->id, id, sizeof (id)); |
| 331 | inet_ntop (AF_INET, &header->adv_router, adv_router, |
| 332 | sizeof (adv_router)); |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 333 | zlog_debug (" [%s Id:%s Adv:%s]", |
| 334 | ospf6_lstype_name (header->type), id, adv_router); |
| 335 | zlog_debug (" Age: %4hu SeqNum: %#08lx Cksum: %04hx Len: %d", |
| 336 | ntohs (header->age), (u_long) ntohl (header->seqnum), |
| 337 | ntohs (header->checksum), ntohs (header->length)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 338 | } |
| 339 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 340 | void |
| 341 | ospf6_lsa_header_print (struct ospf6_lsa *lsa) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 342 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 343 | ospf6_lsa_age_current (lsa); |
| 344 | ospf6_lsa_header_print_raw (lsa->header); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 345 | } |
| 346 | |
| 347 | void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 348 | ospf6_lsa_show_summary_header (struct vty *vty) |
| 349 | { |
| 350 | vty_out (vty, "%-12s %-15s %-15s %4s %8s %4s %4s %-8s%s", |
| 351 | "Type", "LSId", "AdvRouter", "Age", "SeqNum", |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 352 | "Cksm", "Len", "Duration", VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 353 | } |
| 354 | |
| 355 | void |
| 356 | ospf6_lsa_show_summary (struct vty *vty, struct ospf6_lsa *lsa) |
| 357 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 358 | char adv_router[16], id[16]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 359 | struct timeval now, res; |
| 360 | char duration[16]; |
| 361 | |
| 362 | assert (lsa); |
| 363 | assert (lsa->header); |
| 364 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 365 | inet_ntop (AF_INET, &lsa->header->id, id, sizeof (id)); |
| 366 | inet_ntop (AF_INET, &lsa->header->adv_router, adv_router, |
| 367 | sizeof (adv_router)); |
| 368 | |
Takashi Sogabe | 86f72dc | 2009-06-22 13:07:02 +0900 | [diff] [blame] | 369 | quagga_gettime (QUAGGA_CLK_MONOTONIC, &now); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 370 | timersub (&now, &lsa->installed, &res); |
| 371 | timerstring (&res, duration, sizeof (duration)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 372 | |
| 373 | vty_out (vty, "%-12s %-15s %-15s %4hu %8lx %04hx %4hu %8s%s", |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 374 | ospf6_lstype_name (lsa->header->type), |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 375 | id, adv_router, ospf6_lsa_age_current (lsa), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 376 | (u_long) ntohl (lsa->header->seqnum), |
| 377 | ntohs (lsa->header->checksum), ntohs (lsa->header->length), |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 378 | duration, VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 379 | } |
| 380 | |
| 381 | void |
| 382 | ospf6_lsa_show_dump (struct vty *vty, struct ospf6_lsa *lsa) |
| 383 | { |
| 384 | u_char *start, *end, *current; |
| 385 | char byte[4]; |
| 386 | |
hasso | 03d52f8 | 2004-09-29 00:26:19 +0000 | [diff] [blame] | 387 | start = (u_char *) lsa->header; |
| 388 | end = (u_char *) lsa->header + ntohs (lsa->header->length); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 389 | |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 390 | vty_out (vty, "%s", VNL); |
| 391 | vty_out (vty, "%s:%s", lsa->name, VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 392 | |
| 393 | for (current = start; current < end; current ++) |
| 394 | { |
| 395 | if ((current - start) % 16 == 0) |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 396 | vty_out (vty, "%s ", VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 397 | else if ((current - start) % 4 == 0) |
| 398 | vty_out (vty, " "); |
| 399 | |
| 400 | snprintf (byte, sizeof (byte), "%02x", *current); |
| 401 | vty_out (vty, "%s", byte); |
| 402 | } |
| 403 | |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 404 | vty_out (vty, "%s%s", VNL, VNL); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 405 | return; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 406 | } |
| 407 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 408 | void |
| 409 | ospf6_lsa_show_internal (struct vty *vty, struct ospf6_lsa *lsa) |
| 410 | { |
| 411 | char adv_router[64], id[64]; |
| 412 | |
| 413 | assert (lsa && lsa->header); |
| 414 | |
| 415 | inet_ntop (AF_INET, &lsa->header->id, id, sizeof (id)); |
| 416 | inet_ntop (AF_INET, &lsa->header->adv_router, |
| 417 | adv_router, sizeof (adv_router)); |
| 418 | |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 419 | vty_out (vty, "%s", VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 420 | vty_out (vty, "Age: %4hu Type: %s%s", ospf6_lsa_age_current (lsa), |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 421 | ospf6_lstype_name (lsa->header->type), VNL); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 422 | vty_out (vty, "Link State ID: %s%s", id, VNL); |
| 423 | vty_out (vty, "Advertising Router: %s%s", adv_router, VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 424 | vty_out (vty, "LS Sequence Number: %#010lx%s", |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 425 | (u_long) ntohl (lsa->header->seqnum), VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 426 | vty_out (vty, "CheckSum: %#06hx Length: %hu%s", |
| 427 | ntohs (lsa->header->checksum), |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 428 | ntohs (lsa->header->length), VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 429 | vty_out (vty, " Prev: %p This: %p Next: %p%s", |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 430 | lsa->prev, lsa, lsa->next, VNL); |
| 431 | vty_out (vty, "%s", VNL); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 432 | return; |
| 433 | } |
| 434 | |
| 435 | void |
| 436 | ospf6_lsa_show (struct vty *vty, struct ospf6_lsa *lsa) |
| 437 | { |
| 438 | char adv_router[64], id[64]; |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 439 | struct ospf6_lsa_handler *handler; |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 440 | |
| 441 | assert (lsa && lsa->header); |
| 442 | |
| 443 | inet_ntop (AF_INET, &lsa->header->id, id, sizeof (id)); |
| 444 | inet_ntop (AF_INET, &lsa->header->adv_router, |
| 445 | adv_router, sizeof (adv_router)); |
| 446 | |
| 447 | vty_out (vty, "Age: %4hu Type: %s%s", ospf6_lsa_age_current (lsa), |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 448 | ospf6_lstype_name (lsa->header->type), VNL); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 449 | vty_out (vty, "Link State ID: %s%s", id, VNL); |
| 450 | vty_out (vty, "Advertising Router: %s%s", adv_router, VNL); |
| 451 | vty_out (vty, "LS Sequence Number: %#010lx%s", |
| 452 | (u_long) ntohl (lsa->header->seqnum), VNL); |
| 453 | vty_out (vty, "CheckSum: %#06hx Length: %hu%s", |
| 454 | ntohs (lsa->header->checksum), |
| 455 | ntohs (lsa->header->length), VNL); |
| 456 | |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 457 | handler = ospf6_get_lsa_handler (lsa->header->type); |
| 458 | if (handler->show == NULL) |
| 459 | handler = &unknown_handler; |
| 460 | (*handler->show) (vty, lsa); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 461 | |
| 462 | vty_out (vty, "%s", VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 463 | } |
| 464 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 465 | /* OSPFv3 LSA creation/deletion function */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 466 | struct ospf6_lsa * |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 467 | ospf6_lsa_create (struct ospf6_lsa_header *header) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 468 | { |
| 469 | struct ospf6_lsa *lsa = NULL; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 470 | struct ospf6_lsa_header *new_header = NULL; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 471 | u_int16_t lsa_size = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 472 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 473 | /* size of the entire LSA */ |
| 474 | lsa_size = ntohs (header->length); /* XXX vulnerable */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 475 | |
| 476 | /* allocate memory for this LSA */ |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 477 | new_header = (struct ospf6_lsa_header *) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 478 | XMALLOC (MTYPE_OSPF6_LSA, lsa_size); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 479 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 480 | /* copy LSA from original header */ |
| 481 | memcpy (new_header, header, lsa_size); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 482 | |
| 483 | /* LSA information structure */ |
| 484 | /* allocate memory */ |
| 485 | lsa = (struct ospf6_lsa *) |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 486 | XCALLOC (MTYPE_OSPF6_LSA, sizeof (struct ospf6_lsa)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 487 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 488 | lsa->header = (struct ospf6_lsa_header *) new_header; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 489 | |
| 490 | /* dump string */ |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 491 | ospf6_lsa_printbuf (lsa, lsa->name, sizeof (lsa->name)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 492 | |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 493 | /* calculate birth of this lsa */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 494 | ospf6_lsa_age_set (lsa); |
| 495 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 496 | return lsa; |
| 497 | } |
| 498 | |
| 499 | struct ospf6_lsa * |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 500 | ospf6_lsa_create_headeronly (struct ospf6_lsa_header *header) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 501 | { |
| 502 | struct ospf6_lsa *lsa = NULL; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 503 | struct ospf6_lsa_header *new_header = NULL; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 504 | |
| 505 | /* allocate memory for this LSA */ |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 506 | new_header = (struct ospf6_lsa_header *) |
| 507 | XMALLOC (MTYPE_OSPF6_LSA, sizeof (struct ospf6_lsa_header)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 508 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 509 | /* copy LSA from original header */ |
| 510 | memcpy (new_header, header, sizeof (struct ospf6_lsa_header)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 511 | |
| 512 | /* LSA information structure */ |
| 513 | /* allocate memory */ |
| 514 | lsa = (struct ospf6_lsa *) |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 515 | XCALLOC (MTYPE_OSPF6_LSA, sizeof (struct ospf6_lsa)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 516 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 517 | lsa->header = (struct ospf6_lsa_header *) new_header; |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 518 | SET_FLAG (lsa->flag, OSPF6_LSA_HEADERONLY); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 519 | |
| 520 | /* dump string */ |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 521 | ospf6_lsa_printbuf (lsa, lsa->name, sizeof (lsa->name)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 522 | |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 523 | /* calculate birth of this lsa */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 524 | ospf6_lsa_age_set (lsa); |
| 525 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 526 | return lsa; |
| 527 | } |
| 528 | |
| 529 | void |
| 530 | ospf6_lsa_delete (struct ospf6_lsa *lsa) |
| 531 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 532 | assert (lsa->lock == 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 533 | |
| 534 | /* cancel threads */ |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 535 | THREAD_OFF (lsa->expire); |
| 536 | THREAD_OFF (lsa->refresh); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 537 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 538 | /* do free */ |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 539 | XFREE (MTYPE_OSPF6_LSA, lsa->header); |
| 540 | XFREE (MTYPE_OSPF6_LSA, lsa); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 541 | } |
| 542 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 543 | struct ospf6_lsa * |
| 544 | ospf6_lsa_copy (struct ospf6_lsa *lsa) |
| 545 | { |
| 546 | struct ospf6_lsa *copy = NULL; |
| 547 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 548 | ospf6_lsa_age_current (lsa); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 549 | if (CHECK_FLAG (lsa->flag, OSPF6_LSA_HEADERONLY)) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 550 | copy = ospf6_lsa_create_headeronly (lsa->header); |
| 551 | else |
| 552 | copy = ospf6_lsa_create (lsa->header); |
| 553 | assert (copy->lock == 0); |
| 554 | |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 555 | copy->birth = lsa->birth; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 556 | copy->originated = lsa->originated; |
hasso | ccb59b1 | 2004-08-25 09:10:37 +0000 | [diff] [blame] | 557 | copy->received = lsa->received; |
| 558 | copy->installed = lsa->installed; |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 559 | copy->lsdb = lsa->lsdb; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 560 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 561 | return copy; |
| 562 | } |
| 563 | |
| 564 | /* increment reference counter of struct ospf6_lsa */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 565 | void |
| 566 | ospf6_lsa_lock (struct ospf6_lsa *lsa) |
| 567 | { |
| 568 | lsa->lock++; |
| 569 | return; |
| 570 | } |
| 571 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 572 | /* decrement reference counter of struct ospf6_lsa */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 573 | void |
| 574 | ospf6_lsa_unlock (struct ospf6_lsa *lsa) |
| 575 | { |
| 576 | /* decrement reference counter */ |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 577 | assert (lsa->lock > 0); |
| 578 | lsa->lock--; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 579 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 580 | if (lsa->lock != 0) |
| 581 | return; |
| 582 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 583 | ospf6_lsa_delete (lsa); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 584 | } |
| 585 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 586 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 587 | /* ospf6 lsa expiry */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 588 | int |
| 589 | ospf6_lsa_expire (struct thread *thread) |
| 590 | { |
| 591 | struct ospf6_lsa *lsa; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 592 | |
| 593 | lsa = (struct ospf6_lsa *) THREAD_ARG (thread); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 594 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 595 | assert (lsa && lsa->header); |
| 596 | assert (OSPF6_LSA_IS_MAXAGE (lsa)); |
| 597 | assert (! lsa->refresh); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 598 | |
| 599 | lsa->expire = (struct thread *) NULL; |
| 600 | |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 601 | if (IS_OSPF6_DEBUG_LSA_TYPE (lsa->header->type)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 602 | { |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 603 | zlog_debug ("LSA Expire:"); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 604 | ospf6_lsa_header_print (lsa); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 605 | } |
| 606 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 607 | if (CHECK_FLAG (lsa->flag, OSPF6_LSA_HEADERONLY)) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 608 | return 0; /* dbexchange will do something ... */ |
| 609 | |
| 610 | /* reflood lsa */ |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 611 | ospf6_flood (NULL, lsa); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 612 | |
| 613 | /* reinstall lsa */ |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 614 | ospf6_install_lsa (lsa); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 615 | |
| 616 | /* schedule maxage remover */ |
| 617 | ospf6_maxage_remove (ospf6); |
| 618 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 619 | return 0; |
| 620 | } |
| 621 | |
| 622 | int |
| 623 | ospf6_lsa_refresh (struct thread *thread) |
| 624 | { |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 625 | struct ospf6_lsa *old, *self, *new; |
| 626 | struct ospf6_lsdb *lsdb_self; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 627 | |
| 628 | assert (thread); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 629 | old = (struct ospf6_lsa *) THREAD_ARG (thread); |
| 630 | assert (old && old->header); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 631 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 632 | old->refresh = (struct thread *) NULL; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 633 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 634 | lsdb_self = ospf6_get_scoped_lsdb_self (old); |
| 635 | self = ospf6_lsdb_lookup (old->header->type, old->header->id, |
| 636 | old->header->adv_router, lsdb_self); |
| 637 | if (self == NULL) |
| 638 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 639 | if (IS_OSPF6_DEBUG_LSA_TYPE (old->header->type)) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 640 | zlog_debug ("Refresh: could not find self LSA, flush %s", old->name); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 641 | ospf6_lsa_premature_aging (old); |
| 642 | return 0; |
| 643 | } |
| 644 | |
| 645 | /* Reset age, increment LS sequence number. */ |
| 646 | self->header->age = htons (0); |
| 647 | self->header->seqnum = |
| 648 | ospf6_new_ls_seqnum (self->header->type, self->header->id, |
| 649 | self->header->adv_router, old->lsdb); |
| 650 | ospf6_lsa_checksum (self->header); |
| 651 | |
| 652 | new = ospf6_lsa_create (self->header); |
| 653 | new->lsdb = old->lsdb; |
| 654 | new->refresh = thread_add_timer (master, ospf6_lsa_refresh, new, |
| 655 | LS_REFRESH_TIME); |
| 656 | |
| 657 | /* store it in the LSDB for self-originated LSAs */ |
| 658 | ospf6_lsdb_add (ospf6_lsa_copy (new), lsdb_self); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 659 | |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 660 | if (IS_OSPF6_DEBUG_LSA_TYPE (new->header->type)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 661 | { |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 662 | zlog_debug ("LSA Refresh:"); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 663 | ospf6_lsa_header_print (new); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 664 | } |
| 665 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 666 | ospf6_flood_clear (old); |
| 667 | ospf6_flood (NULL, new); |
| 668 | ospf6_install_lsa (new); |
| 669 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 670 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 671 | } |
| 672 | |
| 673 | |
| 674 | |
| 675 | /* enhanced Fletcher checksum algorithm, RFC1008 7.2 */ |
| 676 | #define MODX 4102 |
| 677 | #define LSA_CHECKSUM_OFFSET 15 |
| 678 | |
| 679 | unsigned short |
| 680 | ospf6_lsa_checksum (struct ospf6_lsa_header *lsa_header) |
| 681 | { |
| 682 | u_char *sp, *ep, *p, *q; |
| 683 | int c0 = 0, c1 = 0; |
| 684 | int x, y; |
| 685 | u_int16_t length; |
| 686 | |
| 687 | lsa_header->checksum = 0; |
| 688 | length = ntohs (lsa_header->length) - 2; |
hasso | 03d52f8 | 2004-09-29 00:26:19 +0000 | [diff] [blame] | 689 | sp = (u_char *) &lsa_header->type; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 690 | |
| 691 | for (ep = sp + length; sp < ep; sp = q) |
| 692 | { |
| 693 | q = sp + MODX; |
| 694 | if (q > ep) |
| 695 | q = ep; |
| 696 | for (p = sp; p < q; p++) |
| 697 | { |
| 698 | c0 += *p; |
| 699 | c1 += c0; |
| 700 | } |
| 701 | c0 %= 255; |
| 702 | c1 %= 255; |
| 703 | } |
| 704 | |
| 705 | /* r = (c1 << 8) + c0; */ |
| 706 | x = ((length - LSA_CHECKSUM_OFFSET) * c0 - c1) % 255; |
| 707 | if (x <= 0) |
| 708 | x += 255; |
| 709 | y = 510 - c0 - x; |
| 710 | if (y > 255) |
| 711 | y -= 255; |
| 712 | |
| 713 | lsa_header->checksum = htons ((x << 8) + y); |
| 714 | |
| 715 | return (lsa_header->checksum); |
| 716 | } |
| 717 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 718 | void |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 719 | ospf6_lsa_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 720 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 721 | ospf6_lsa_handler_vector = vector_init (0); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 722 | ospf6_install_lsa_handler (&unknown_handler); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 723 | } |
| 724 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 725 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 726 | static char * |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 727 | ospf6_lsa_handler_name (struct ospf6_lsa_handler *h) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 728 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 729 | static char buf[64]; |
paul | 0c083ee | 2004-10-10 12:54:58 +0000 | [diff] [blame] | 730 | unsigned int i; |
| 731 | unsigned int size = strlen (h->name); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 732 | |
Andrew J. Schorr | c32d28b | 2007-02-27 15:24:36 +0000 | [diff] [blame] | 733 | if (!strcmp(h->name, "Unknown") && |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 734 | h->type != OSPF6_LSTYPE_UNKNOWN) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 735 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 736 | snprintf (buf, sizeof (buf), "%#04hx", h->type); |
| 737 | return buf; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 738 | } |
| 739 | |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 740 | for (i = 0; i < MIN (size, sizeof (buf)); i++) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 741 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 742 | if (! islower (h->name[i])) |
| 743 | buf[i] = tolower (h->name[i]); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 744 | else |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 745 | buf[i] = h->name[i]; |
| 746 | } |
| 747 | buf[size] = '\0'; |
| 748 | return buf; |
| 749 | } |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 750 | |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 751 | DEFUN (debug_ospf6_lsa_type, |
| 752 | debug_ospf6_lsa_hex_cmd, |
| 753 | "debug ospf6 lsa XXXX/0xXXXX", |
| 754 | DEBUG_STR |
| 755 | OSPF6_STR |
| 756 | "Debug Link State Advertisements (LSAs)\n" |
| 757 | "Specify LS type as Hexadecimal\n" |
| 758 | ) |
| 759 | { |
paul | 0c083ee | 2004-10-10 12:54:58 +0000 | [diff] [blame] | 760 | unsigned int i; |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 761 | struct ospf6_lsa_handler *handler = NULL; |
| 762 | unsigned long val; |
| 763 | char *endptr = NULL; |
| 764 | u_int16_t type = 0; |
| 765 | |
| 766 | assert (argc); |
| 767 | |
| 768 | if ((strlen (argv[0]) == 6 && ! strncmp (argv[0], "0x", 2)) || |
| 769 | (strlen (argv[0]) == 4)) |
| 770 | { |
| 771 | val = strtoul (argv[0], &endptr, 16); |
| 772 | if (*endptr == '\0') |
| 773 | type = val; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 774 | } |
| 775 | |
paul | 55468c8 | 2005-03-14 20:19:01 +0000 | [diff] [blame] | 776 | for (i = 0; i < vector_active (ospf6_lsa_handler_vector); i++) |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 777 | { |
| 778 | handler = vector_slot (ospf6_lsa_handler_vector, i); |
| 779 | if (handler == NULL) |
| 780 | continue; |
| 781 | if (type && handler->type == type) |
| 782 | break; |
| 783 | if (! strcasecmp (argv[0], handler->name)) |
| 784 | break; |
| 785 | handler = NULL; |
| 786 | } |
| 787 | |
| 788 | if (type && handler == NULL) |
| 789 | { |
| 790 | handler = (struct ospf6_lsa_handler *) |
| 791 | malloc (sizeof (struct ospf6_lsa_handler)); |
| 792 | memset (handler, 0, sizeof (struct ospf6_lsa_handler)); |
| 793 | handler->type = type; |
| 794 | handler->name = "Unknown"; |
| 795 | handler->show = ospf6_unknown_lsa_show; |
| 796 | vector_set_index (ospf6_lsa_handler_vector, |
| 797 | handler->type & OSPF6_LSTYPE_FCODE_MASK, handler); |
| 798 | } |
| 799 | |
| 800 | if (handler == NULL) |
| 801 | handler = &unknown_handler; |
| 802 | |
| 803 | if (argc >= 2) |
| 804 | { |
| 805 | if (! strcmp (argv[1], "originate")) |
| 806 | SET_FLAG (handler->debug, OSPF6_LSA_DEBUG_ORIGINATE); |
| 807 | if (! strcmp (argv[1], "examin")) |
| 808 | SET_FLAG (handler->debug, OSPF6_LSA_DEBUG_EXAMIN); |
| 809 | if (! strcmp (argv[1], "flooding")) |
| 810 | SET_FLAG (handler->debug, OSPF6_LSA_DEBUG_FLOOD); |
| 811 | } |
| 812 | else |
| 813 | SET_FLAG (handler->debug, OSPF6_LSA_DEBUG); |
| 814 | |
| 815 | return CMD_SUCCESS; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 816 | } |
| 817 | |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 818 | DEFUN (no_debug_ospf6_lsa_type, |
| 819 | no_debug_ospf6_lsa_hex_cmd, |
| 820 | "no debug ospf6 lsa XXXX/0xXXXX", |
| 821 | NO_STR |
| 822 | DEBUG_STR |
| 823 | OSPF6_STR |
| 824 | "Debug Link State Advertisements (LSAs)\n" |
| 825 | "Specify LS type as Hexadecimal\n" |
| 826 | ) |
| 827 | { |
paul | 0c083ee | 2004-10-10 12:54:58 +0000 | [diff] [blame] | 828 | u_int i; |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 829 | struct ospf6_lsa_handler *handler = NULL; |
| 830 | unsigned long val; |
| 831 | char *endptr = NULL; |
| 832 | u_int16_t type = 0; |
| 833 | |
| 834 | assert (argc); |
| 835 | |
| 836 | if ((strlen (argv[0]) == 6 && ! strncmp (argv[0], "0x", 2)) || |
| 837 | (strlen (argv[0]) == 4)) |
| 838 | { |
| 839 | val = strtoul (argv[0], &endptr, 16); |
| 840 | if (*endptr == '\0') |
| 841 | type = val; |
| 842 | } |
| 843 | |
paul | 55468c8 | 2005-03-14 20:19:01 +0000 | [diff] [blame] | 844 | for (i = 0; i < vector_active (ospf6_lsa_handler_vector); i++) |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 845 | { |
| 846 | handler = vector_slot (ospf6_lsa_handler_vector, i); |
| 847 | if (handler == NULL) |
| 848 | continue; |
| 849 | if (type && handler->type == type) |
| 850 | break; |
| 851 | if (! strcasecmp (argv[0], handler->name)) |
| 852 | break; |
| 853 | } |
| 854 | |
| 855 | if (handler == NULL) |
| 856 | return CMD_SUCCESS; |
| 857 | |
| 858 | if (argc >= 2) |
| 859 | { |
| 860 | if (! strcmp (argv[1], "originate")) |
| 861 | UNSET_FLAG (handler->debug, OSPF6_LSA_DEBUG_ORIGINATE); |
| 862 | if (! strcmp (argv[1], "examin")) |
| 863 | UNSET_FLAG (handler->debug, OSPF6_LSA_DEBUG_EXAMIN); |
| 864 | if (! strcmp (argv[1], "flooding")) |
| 865 | UNSET_FLAG (handler->debug, OSPF6_LSA_DEBUG_FLOOD); |
| 866 | } |
| 867 | else |
| 868 | UNSET_FLAG (handler->debug, OSPF6_LSA_DEBUG); |
| 869 | |
| 870 | if (handler->debug == 0 && |
Andrew J. Schorr | e733f94 | 2007-06-07 13:11:58 +0000 | [diff] [blame] | 871 | !strcmp(handler->name, "Unknown") && type != OSPF6_LSTYPE_UNKNOWN) |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 872 | { |
| 873 | free (handler); |
| 874 | vector_slot (ospf6_lsa_handler_vector, i) = NULL; |
| 875 | } |
| 876 | |
| 877 | return CMD_SUCCESS; |
| 878 | } |
| 879 | |
| 880 | struct cmd_element debug_ospf6_lsa_type_cmd; |
| 881 | struct cmd_element debug_ospf6_lsa_type_detail_cmd; |
| 882 | struct cmd_element no_debug_ospf6_lsa_type_cmd; |
| 883 | struct cmd_element no_debug_ospf6_lsa_type_detail_cmd; |
| 884 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 885 | void |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 886 | install_element_ospf6_debug_lsa (void) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 887 | { |
paul | 0c083ee | 2004-10-10 12:54:58 +0000 | [diff] [blame] | 888 | u_int i; |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 889 | struct ospf6_lsa_handler *handler; |
| 890 | #define STRSIZE 256 |
| 891 | #define DOCSIZE 1024 |
| 892 | static char strbuf[STRSIZE]; |
| 893 | static char docbuf[DOCSIZE]; |
| 894 | static char detail_strbuf[STRSIZE]; |
| 895 | static char detail_docbuf[DOCSIZE]; |
| 896 | char *str, *no_str; |
| 897 | char *doc, *no_doc; |
| 898 | |
| 899 | strbuf[0] = '\0'; |
| 900 | no_str = &strbuf[strlen (strbuf)]; |
| 901 | strncat (strbuf, "no ", STRSIZE - strlen (strbuf)); |
| 902 | str = &strbuf[strlen (strbuf)]; |
| 903 | |
| 904 | strncat (strbuf, "debug ospf6 lsa (", STRSIZE - strlen (strbuf)); |
paul | 55468c8 | 2005-03-14 20:19:01 +0000 | [diff] [blame] | 905 | for (i = 0; i < vector_active (ospf6_lsa_handler_vector); i++) |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 906 | { |
| 907 | handler = vector_slot (ospf6_lsa_handler_vector, i); |
| 908 | if (handler == NULL) |
| 909 | continue; |
| 910 | strncat (strbuf, ospf6_lsa_handler_name (handler), |
| 911 | STRSIZE - strlen (strbuf)); |
| 912 | strncat (strbuf, "|", STRSIZE - strlen (strbuf)); |
| 913 | } |
| 914 | strbuf[strlen (strbuf) - 1] = ')'; |
| 915 | strbuf[strlen (strbuf)] = '\0'; |
| 916 | |
| 917 | docbuf[0] = '\0'; |
| 918 | no_doc = &docbuf[strlen (docbuf)]; |
| 919 | strncat (docbuf, NO_STR, DOCSIZE - strlen (docbuf)); |
| 920 | doc = &docbuf[strlen (docbuf)]; |
| 921 | |
| 922 | strncat (docbuf, DEBUG_STR, DOCSIZE - strlen (docbuf)); |
| 923 | strncat (docbuf, OSPF6_STR, DOCSIZE - strlen (docbuf)); |
| 924 | strncat (docbuf, "Debug Link State Advertisements (LSAs)\n", |
| 925 | DOCSIZE - strlen (docbuf)); |
| 926 | |
paul | 55468c8 | 2005-03-14 20:19:01 +0000 | [diff] [blame] | 927 | for (i = 0; i < vector_active (ospf6_lsa_handler_vector); i++) |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 928 | { |
| 929 | handler = vector_slot (ospf6_lsa_handler_vector, i); |
| 930 | if (handler == NULL) |
| 931 | continue; |
| 932 | strncat (docbuf, "Debug ", DOCSIZE - strlen (docbuf)); |
| 933 | strncat (docbuf, handler->name, DOCSIZE - strlen (docbuf)); |
| 934 | strncat (docbuf, "-LSA\n", DOCSIZE - strlen (docbuf)); |
| 935 | } |
| 936 | docbuf[strlen (docbuf)] = '\0'; |
| 937 | |
| 938 | debug_ospf6_lsa_type_cmd.string = str; |
| 939 | debug_ospf6_lsa_type_cmd.func = debug_ospf6_lsa_type; |
| 940 | debug_ospf6_lsa_type_cmd.doc = doc; |
| 941 | |
| 942 | no_debug_ospf6_lsa_type_cmd.string = no_str; |
| 943 | no_debug_ospf6_lsa_type_cmd.func = no_debug_ospf6_lsa_type; |
| 944 | no_debug_ospf6_lsa_type_cmd.doc = no_doc; |
| 945 | |
| 946 | strncpy (detail_strbuf, strbuf, STRSIZE); |
| 947 | strncat (detail_strbuf, " (originate|examin|flooding)", |
| 948 | STRSIZE - strlen (detail_strbuf)); |
| 949 | detail_strbuf[strlen (detail_strbuf)] = '\0'; |
| 950 | no_str = &detail_strbuf[0]; |
| 951 | str = &detail_strbuf[strlen ("no ")]; |
| 952 | |
| 953 | strncpy (detail_docbuf, docbuf, DOCSIZE); |
| 954 | strncat (detail_docbuf, "Debug Originating LSA\n", |
| 955 | DOCSIZE - strlen (detail_docbuf)); |
| 956 | strncat (detail_docbuf, "Debug Examining LSA\n", |
| 957 | DOCSIZE - strlen (detail_docbuf)); |
| 958 | strncat (detail_docbuf, "Debug Flooding LSA\n", |
| 959 | DOCSIZE - strlen (detail_docbuf)); |
| 960 | detail_docbuf[strlen (detail_docbuf)] = '\0'; |
| 961 | no_doc = &detail_docbuf[0]; |
| 962 | doc = &detail_docbuf[strlen (NO_STR)]; |
| 963 | |
| 964 | debug_ospf6_lsa_type_detail_cmd.string = str; |
| 965 | debug_ospf6_lsa_type_detail_cmd.func = debug_ospf6_lsa_type; |
| 966 | debug_ospf6_lsa_type_detail_cmd.doc = doc; |
| 967 | |
| 968 | no_debug_ospf6_lsa_type_detail_cmd.string = no_str; |
| 969 | no_debug_ospf6_lsa_type_detail_cmd.func = no_debug_ospf6_lsa_type; |
| 970 | no_debug_ospf6_lsa_type_detail_cmd.doc = no_doc; |
| 971 | |
| 972 | install_element (ENABLE_NODE, &debug_ospf6_lsa_hex_cmd); |
| 973 | install_element (ENABLE_NODE, &debug_ospf6_lsa_type_cmd); |
| 974 | install_element (ENABLE_NODE, &debug_ospf6_lsa_type_detail_cmd); |
| 975 | install_element (ENABLE_NODE, &no_debug_ospf6_lsa_hex_cmd); |
| 976 | install_element (ENABLE_NODE, &no_debug_ospf6_lsa_type_cmd); |
| 977 | install_element (ENABLE_NODE, &no_debug_ospf6_lsa_type_detail_cmd); |
| 978 | install_element (CONFIG_NODE, &debug_ospf6_lsa_hex_cmd); |
| 979 | install_element (CONFIG_NODE, &debug_ospf6_lsa_type_cmd); |
| 980 | install_element (CONFIG_NODE, &debug_ospf6_lsa_type_detail_cmd); |
| 981 | install_element (CONFIG_NODE, &no_debug_ospf6_lsa_hex_cmd); |
| 982 | install_element (CONFIG_NODE, &no_debug_ospf6_lsa_type_cmd); |
| 983 | install_element (CONFIG_NODE, &no_debug_ospf6_lsa_type_detail_cmd); |
| 984 | } |
| 985 | |
| 986 | int |
| 987 | config_write_ospf6_debug_lsa (struct vty *vty) |
| 988 | { |
paul | 0c083ee | 2004-10-10 12:54:58 +0000 | [diff] [blame] | 989 | u_int i; |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 990 | struct ospf6_lsa_handler *handler; |
| 991 | |
paul | 55468c8 | 2005-03-14 20:19:01 +0000 | [diff] [blame] | 992 | for (i = 0; i < vector_active (ospf6_lsa_handler_vector); i++) |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 993 | { |
| 994 | handler = vector_slot (ospf6_lsa_handler_vector, i); |
| 995 | if (handler == NULL) |
| 996 | continue; |
| 997 | if (CHECK_FLAG (handler->debug, OSPF6_LSA_DEBUG)) |
| 998 | vty_out (vty, "debug ospf6 lsa %s%s", |
| 999 | ospf6_lsa_handler_name (handler), VNL); |
| 1000 | if (CHECK_FLAG (handler->debug, OSPF6_LSA_DEBUG_ORIGINATE)) |
| 1001 | vty_out (vty, "debug ospf6 lsa %s originate%s", |
| 1002 | ospf6_lsa_handler_name (handler), VNL); |
| 1003 | if (CHECK_FLAG (handler->debug, OSPF6_LSA_DEBUG_EXAMIN)) |
| 1004 | vty_out (vty, "debug ospf6 lsa %s examin%s", |
| 1005 | ospf6_lsa_handler_name (handler), VNL); |
| 1006 | if (CHECK_FLAG (handler->debug, OSPF6_LSA_DEBUG_FLOOD)) |
| 1007 | vty_out (vty, "debug ospf6 lsa %s flooding%s", |
| 1008 | ospf6_lsa_handler_name (handler), VNL); |
| 1009 | } |
| 1010 | |
| 1011 | return 0; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1012 | } |
| 1013 | |
| 1014 | |