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