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