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