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 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 22 | #include <zebra.h> |
| 23 | |
| 24 | #include "log.h" |
| 25 | #include "linklist.h" |
| 26 | #include "thread.h" |
| 27 | #include "memory.h" |
| 28 | #include "if.h" |
| 29 | #include "prefix.h" |
| 30 | #include "table.h" |
| 31 | #include "vty.h" |
| 32 | #include "command.h" |
| 33 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 34 | #include "ospf6_proto.h" |
| 35 | #include "ospf6_message.h" |
| 36 | #include "ospf6_route.h" |
| 37 | #include "ospf6_lsa.h" |
| 38 | #include "ospf6_lsdb.h" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 39 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 40 | #include "ospf6_top.h" |
| 41 | #include "ospf6_area.h" |
| 42 | #include "ospf6_interface.h" |
| 43 | #include "ospf6_neighbor.h" |
| 44 | #include "ospf6_intra.h" |
| 45 | #include "ospf6_asbr.h" |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 46 | #include "ospf6_abr.h" |
| 47 | #include "ospf6_flood.h" |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 48 | #include "ospf6d.h" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 49 | |
Paul Jakma | cb4b884 | 2006-05-15 10:39:30 +0000 | [diff] [blame] | 50 | |
| 51 | unsigned char conf_debug_ospf6_brouter = 0; |
| 52 | u_int32_t conf_debug_ospf6_brouter_specific_router_id; |
| 53 | u_int32_t conf_debug_ospf6_brouter_specific_area_id; |
| 54 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 55 | /******************************/ |
| 56 | /* RFC2740 3.4.3.1 Router-LSA */ |
| 57 | /******************************/ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 58 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 59 | static int |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 60 | ospf6_router_lsa_show (struct vty *vty, struct ospf6_lsa *lsa) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 61 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 62 | char *start, *end, *current; |
| 63 | char buf[32], name[32], bits[16], options[32]; |
| 64 | struct ospf6_router_lsa *router_lsa; |
| 65 | struct ospf6_router_lsdesc *lsdesc; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 66 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 67 | router_lsa = (struct ospf6_router_lsa *) |
| 68 | ((char *) lsa->header + sizeof (struct ospf6_lsa_header)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 69 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 70 | ospf6_capability_printbuf (router_lsa->bits, bits, sizeof (bits)); |
| 71 | ospf6_options_printbuf (router_lsa->options, options, sizeof (options)); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 72 | vty_out (vty, " Bits: %s Options: %s%s", bits, options, VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 73 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 74 | start = (char *) router_lsa + sizeof (struct ospf6_router_lsa); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 75 | end = (char *) lsa->header + ntohs (lsa->header->length); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 76 | for (current = start; current + sizeof (struct ospf6_router_lsdesc) <= end; |
| 77 | current += sizeof (struct ospf6_router_lsdesc)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 78 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 79 | lsdesc = (struct ospf6_router_lsdesc *) current; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 80 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 81 | if (lsdesc->type == OSPF6_ROUTER_LSDESC_POINTTOPOINT) |
| 82 | snprintf (name, sizeof (name), "Point-To-Point"); |
| 83 | else if (lsdesc->type == OSPF6_ROUTER_LSDESC_TRANSIT_NETWORK) |
| 84 | snprintf (name, sizeof (name), "Transit-Network"); |
| 85 | else if (lsdesc->type == OSPF6_ROUTER_LSDESC_STUB_NETWORK) |
| 86 | snprintf (name, sizeof (name), "Stub-Network"); |
| 87 | else if (lsdesc->type == OSPF6_ROUTER_LSDESC_VIRTUAL_LINK) |
| 88 | snprintf (name, sizeof (name), "Virtual-Link"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 89 | else |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 90 | snprintf (name, sizeof (name), "Unknown (%#x)", lsdesc->type); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 91 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 92 | vty_out (vty, " Type: %s Metric: %d%s", |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 93 | name, ntohs (lsdesc->metric), VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 94 | vty_out (vty, " Interface ID: %s%s", |
| 95 | inet_ntop (AF_INET, &lsdesc->interface_id, |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 96 | buf, sizeof (buf)), VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 97 | vty_out (vty, " Neighbor Interface ID: %s%s", |
| 98 | inet_ntop (AF_INET, &lsdesc->neighbor_interface_id, |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 99 | buf, sizeof (buf)), VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 100 | vty_out (vty, " Neighbor Router ID: %s%s", |
| 101 | inet_ntop (AF_INET, &lsdesc->neighbor_router_id, |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 102 | buf, sizeof (buf)), VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 103 | } |
| 104 | return 0; |
| 105 | } |
| 106 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 107 | int |
Dinesh Dutt | f41b4a0 | 2013-08-24 08:00:37 +0000 | [diff] [blame^] | 108 | ospf6_router_is_stub_router (struct ospf6_lsa *lsa) |
| 109 | { |
| 110 | struct ospf6_router_lsa *rtr_lsa; |
| 111 | |
| 112 | if (lsa != NULL && OSPF6_LSA_IS_TYPE (ROUTER, lsa)) |
| 113 | { |
| 114 | rtr_lsa = (struct ospf6_router_lsa *) |
| 115 | ((caddr_t) lsa->header + sizeof (struct ospf6_lsa_header)); |
| 116 | |
| 117 | if (!OSPF6_OPT_ISSET (rtr_lsa->options, OSPF6_OPT_R)) |
| 118 | { |
| 119 | return (OSPF6_IS_STUB_ROUTER); |
| 120 | } |
| 121 | else if (!OSPF6_OPT_ISSET (rtr_lsa->options, OSPF6_OPT_V6)) |
| 122 | { |
| 123 | return (OSPF6_IS_STUB_ROUTER_V6); |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | return (OSPF6_NOT_STUB_ROUTER); |
| 128 | } |
| 129 | |
| 130 | int |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 131 | ospf6_router_lsa_originate (struct thread *thread) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 132 | { |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 133 | struct ospf6_area *oa; |
| 134 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 135 | char buffer [OSPF6_MAX_LSASIZE]; |
| 136 | struct ospf6_lsa_header *lsa_header; |
| 137 | struct ospf6_lsa *lsa; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 138 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 139 | u_int32_t link_state_id = 0; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 140 | struct listnode *node, *nnode; |
| 141 | struct listnode *j; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 142 | struct ospf6_interface *oi; |
| 143 | struct ospf6_neighbor *on, *drouter = NULL; |
| 144 | struct ospf6_router_lsa *router_lsa; |
| 145 | struct ospf6_router_lsdesc *lsdesc; |
| 146 | u_int16_t type; |
| 147 | u_int32_t router; |
| 148 | int count; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 149 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 150 | oa = (struct ospf6_area *) THREAD_ARG (thread); |
| 151 | oa->thread_router_lsa = NULL; |
| 152 | |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 153 | if (IS_OSPF6_DEBUG_ORIGINATE (ROUTER)) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 154 | zlog_debug ("Originate Router-LSA for Area %s", oa->name); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 155 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 156 | memset (buffer, 0, sizeof (buffer)); |
| 157 | lsa_header = (struct ospf6_lsa_header *) buffer; |
| 158 | router_lsa = (struct ospf6_router_lsa *) |
| 159 | ((caddr_t) lsa_header + sizeof (struct ospf6_lsa_header)); |
| 160 | |
| 161 | OSPF6_OPT_SET (router_lsa->options, OSPF6_OPT_V6); |
| 162 | OSPF6_OPT_SET (router_lsa->options, OSPF6_OPT_E); |
| 163 | OSPF6_OPT_CLEAR (router_lsa->options, OSPF6_OPT_MC); |
| 164 | OSPF6_OPT_CLEAR (router_lsa->options, OSPF6_OPT_N); |
| 165 | OSPF6_OPT_SET (router_lsa->options, OSPF6_OPT_R); |
| 166 | OSPF6_OPT_CLEAR (router_lsa->options, OSPF6_OPT_DC); |
| 167 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 168 | if (ospf6_is_router_abr (ospf6)) |
| 169 | SET_FLAG (router_lsa->bits, OSPF6_ROUTER_BIT_B); |
| 170 | else |
| 171 | UNSET_FLAG (router_lsa->bits, OSPF6_ROUTER_BIT_B); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 172 | if (ospf6_asbr_is_asbr (ospf6)) |
| 173 | SET_FLAG (router_lsa->bits, OSPF6_ROUTER_BIT_E); |
| 174 | else |
| 175 | UNSET_FLAG (router_lsa->bits, OSPF6_ROUTER_BIT_E); |
| 176 | UNSET_FLAG (router_lsa->bits, OSPF6_ROUTER_BIT_V); |
| 177 | UNSET_FLAG (router_lsa->bits, OSPF6_ROUTER_BIT_W); |
| 178 | |
| 179 | /* describe links for each interfaces */ |
| 180 | lsdesc = (struct ospf6_router_lsdesc *) |
| 181 | ((caddr_t) router_lsa + sizeof (struct ospf6_router_lsa)); |
| 182 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 183 | for (ALL_LIST_ELEMENTS (oa->if_list, node, nnode, oi)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 184 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 185 | /* Interfaces in state Down or Loopback are not described */ |
| 186 | if (oi->state == OSPF6_INTERFACE_DOWN || |
| 187 | oi->state == OSPF6_INTERFACE_LOOPBACK) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 188 | continue; |
| 189 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 190 | /* Nor are interfaces without any full adjacencies described */ |
| 191 | count = 0; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 192 | for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, j, on)) |
| 193 | if (on->state == OSPF6_NEIGHBOR_FULL) |
| 194 | count++; |
| 195 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 196 | if (count == 0) |
| 197 | continue; |
| 198 | |
| 199 | /* Multiple Router-LSA instance according to size limit setting */ |
paul | 0c083ee | 2004-10-10 12:54:58 +0000 | [diff] [blame] | 200 | if ( (oa->router_lsa_size_limit != 0) |
| 201 | && ((caddr_t) lsdesc + sizeof (struct ospf6_router_lsdesc) - |
gdt | 1686f93 | 2004-12-09 14:47:09 +0000 | [diff] [blame] | 202 | /* XXX warning: comparison between signed and unsigned */ |
paul | 0c083ee | 2004-10-10 12:54:58 +0000 | [diff] [blame] | 203 | (caddr_t) buffer > oa->router_lsa_size_limit)) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 204 | { |
| 205 | if ((caddr_t) lsdesc == (caddr_t) router_lsa + |
| 206 | sizeof (struct ospf6_router_lsa)) |
| 207 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 208 | if (IS_OSPF6_DEBUG_ORIGINATE (ROUTER)) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 209 | zlog_debug ("Size limit setting for Router-LSA too short"); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 210 | return 0; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 211 | } |
| 212 | |
| 213 | /* Fill LSA Header */ |
| 214 | lsa_header->age = 0; |
| 215 | lsa_header->type = htons (OSPF6_LSTYPE_ROUTER); |
| 216 | lsa_header->id = htonl (link_state_id); |
| 217 | lsa_header->adv_router = oa->ospf6->router_id; |
| 218 | lsa_header->seqnum = |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 219 | ospf6_new_ls_seqnum (lsa_header->type, lsa_header->id, |
| 220 | lsa_header->adv_router, oa->lsdb); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 221 | lsa_header->length = htons ((caddr_t) lsdesc - (caddr_t) buffer); |
| 222 | |
| 223 | /* LSA checksum */ |
| 224 | ospf6_lsa_checksum (lsa_header); |
| 225 | |
| 226 | /* create LSA */ |
| 227 | lsa = ospf6_lsa_create (lsa_header); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 228 | |
| 229 | /* Originate */ |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 230 | ospf6_lsa_originate_area (lsa, oa); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 231 | |
| 232 | /* Reset setting for consecutive origination */ |
| 233 | memset ((caddr_t) router_lsa + sizeof (struct ospf6_router_lsa), |
| 234 | 0, (caddr_t) lsdesc - (caddr_t) router_lsa); |
| 235 | lsdesc = (struct ospf6_router_lsdesc *) |
| 236 | ((caddr_t) router_lsa + sizeof (struct ospf6_router_lsa)); |
| 237 | link_state_id ++; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 238 | } |
| 239 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 240 | /* Point-to-Point interfaces */ |
Dinesh Dutt | c5926a9 | 2013-08-24 07:55:00 +0000 | [diff] [blame] | 241 | if (oi->type == OSPF_IFTYPE_POINTOPOINT) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 242 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 243 | for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, j, on)) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 244 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 245 | if (on->state != OSPF6_NEIGHBOR_FULL) |
| 246 | continue; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 247 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 248 | lsdesc->type = OSPF6_ROUTER_LSDESC_POINTTOPOINT; |
| 249 | lsdesc->metric = htons (oi->cost); |
| 250 | lsdesc->interface_id = htonl (oi->interface->ifindex); |
| 251 | lsdesc->neighbor_interface_id = htonl (on->ifindex); |
| 252 | lsdesc->neighbor_router_id = on->router_id; |
| 253 | |
| 254 | lsdesc++; |
| 255 | } |
| 256 | } |
| 257 | |
| 258 | /* Broadcast and NBMA interfaces */ |
Dinesh Dutt | c5926a9 | 2013-08-24 07:55:00 +0000 | [diff] [blame] | 259 | else if (oi->type == OSPF_IFTYPE_BROADCAST) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 260 | { |
| 261 | /* If this router is not DR, |
| 262 | and If this router not fully adjacent with DR, |
| 263 | this interface is not transit yet: ignore. */ |
| 264 | if (oi->state != OSPF6_INTERFACE_DR) |
| 265 | { |
| 266 | drouter = ospf6_neighbor_lookup (oi->drouter, oi); |
| 267 | if (drouter == NULL || drouter->state != OSPF6_NEIGHBOR_FULL) |
| 268 | continue; |
| 269 | } |
| 270 | |
| 271 | lsdesc->type = OSPF6_ROUTER_LSDESC_TRANSIT_NETWORK; |
| 272 | lsdesc->metric = htons (oi->cost); |
| 273 | lsdesc->interface_id = htonl (oi->interface->ifindex); |
| 274 | if (oi->state != OSPF6_INTERFACE_DR) |
| 275 | { |
| 276 | lsdesc->neighbor_interface_id = htonl (drouter->ifindex); |
| 277 | lsdesc->neighbor_router_id = drouter->router_id; |
| 278 | } |
| 279 | else |
| 280 | { |
| 281 | lsdesc->neighbor_interface_id = htonl (oi->interface->ifindex); |
| 282 | lsdesc->neighbor_router_id = oi->area->ospf6->router_id; |
| 283 | } |
| 284 | |
| 285 | lsdesc++; |
| 286 | } |
Dinesh Dutt | c5926a9 | 2013-08-24 07:55:00 +0000 | [diff] [blame] | 287 | else |
| 288 | { |
| 289 | assert (0); /* Unknown interface type */ |
| 290 | } |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 291 | |
| 292 | /* Virtual links */ |
| 293 | /* xxx */ |
| 294 | /* Point-to-Multipoint interfaces */ |
| 295 | /* xxx */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 296 | } |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 297 | |
Dinesh Dutt | 17d003d | 2013-08-24 07:55:43 +0000 | [diff] [blame] | 298 | /* Fill LSA Header */ |
| 299 | lsa_header->age = 0; |
| 300 | lsa_header->type = htons (OSPF6_LSTYPE_ROUTER); |
| 301 | lsa_header->id = htonl (link_state_id); |
| 302 | lsa_header->adv_router = oa->ospf6->router_id; |
| 303 | lsa_header->seqnum = |
| 304 | ospf6_new_ls_seqnum (lsa_header->type, lsa_header->id, |
| 305 | lsa_header->adv_router, oa->lsdb); |
| 306 | lsa_header->length = htons ((caddr_t) lsdesc - (caddr_t) buffer); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 307 | |
Dinesh Dutt | 17d003d | 2013-08-24 07:55:43 +0000 | [diff] [blame] | 308 | /* LSA checksum */ |
| 309 | ospf6_lsa_checksum (lsa_header); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 310 | |
Dinesh Dutt | 17d003d | 2013-08-24 07:55:43 +0000 | [diff] [blame] | 311 | /* create LSA */ |
| 312 | lsa = ospf6_lsa_create (lsa_header); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 313 | |
Dinesh Dutt | 17d003d | 2013-08-24 07:55:43 +0000 | [diff] [blame] | 314 | /* Originate */ |
| 315 | ospf6_lsa_originate_area (lsa, oa); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 316 | |
Dinesh Dutt | 17d003d | 2013-08-24 07:55:43 +0000 | [diff] [blame] | 317 | link_state_id ++; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 318 | |
| 319 | /* Do premature-aging of rest, undesired Router-LSAs */ |
| 320 | type = ntohs (OSPF6_LSTYPE_ROUTER); |
| 321 | router = oa->ospf6->router_id; |
| 322 | for (lsa = ospf6_lsdb_type_router_head (type, router, oa->lsdb); lsa; |
| 323 | lsa = ospf6_lsdb_type_router_next (type, router, lsa)) |
| 324 | { |
| 325 | if (ntohl (lsa->header->id) < link_state_id) |
| 326 | continue; |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 327 | ospf6_lsa_purge (lsa); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 328 | } |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 329 | |
| 330 | return 0; |
| 331 | } |
| 332 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 333 | /*******************************/ |
| 334 | /* RFC2740 3.4.3.2 Network-LSA */ |
| 335 | /*******************************/ |
| 336 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 337 | static int |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 338 | ospf6_network_lsa_show (struct vty *vty, struct ospf6_lsa *lsa) |
| 339 | { |
| 340 | char *start, *end, *current; |
| 341 | struct ospf6_network_lsa *network_lsa; |
| 342 | struct ospf6_network_lsdesc *lsdesc; |
| 343 | char buf[128], options[32]; |
| 344 | |
| 345 | network_lsa = (struct ospf6_network_lsa *) |
| 346 | ((caddr_t) lsa->header + sizeof (struct ospf6_lsa_header)); |
| 347 | |
| 348 | ospf6_options_printbuf (network_lsa->options, options, sizeof (options)); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 349 | vty_out (vty, " Options: %s%s", options, VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 350 | |
| 351 | start = (char *) network_lsa + sizeof (struct ospf6_network_lsa); |
| 352 | end = (char *) lsa->header + ntohs (lsa->header->length); |
| 353 | for (current = start; current + sizeof (struct ospf6_network_lsdesc) <= end; |
| 354 | current += sizeof (struct ospf6_network_lsdesc)) |
| 355 | { |
| 356 | lsdesc = (struct ospf6_network_lsdesc *) current; |
| 357 | inet_ntop (AF_INET, &lsdesc->router_id, buf, sizeof (buf)); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 358 | vty_out (vty, " Attached Router: %s%s", buf, VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 359 | } |
| 360 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 361 | } |
| 362 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 363 | int |
| 364 | ospf6_network_lsa_originate (struct thread *thread) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 365 | { |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 366 | struct ospf6_interface *oi; |
| 367 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 368 | char buffer [OSPF6_MAX_LSASIZE]; |
| 369 | struct ospf6_lsa_header *lsa_header; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 370 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 371 | int count; |
| 372 | struct ospf6_lsa *old, *lsa; |
| 373 | struct ospf6_network_lsa *network_lsa; |
| 374 | struct ospf6_network_lsdesc *lsdesc; |
| 375 | struct ospf6_neighbor *on; |
| 376 | struct ospf6_link_lsa *link_lsa; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 377 | struct listnode *i; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 378 | u_int16_t type; |
| 379 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 380 | oi = (struct ospf6_interface *) THREAD_ARG (thread); |
| 381 | oi->thread_network_lsa = NULL; |
| 382 | |
| 383 | /* The interface must be enabled until here. A Network-LSA of a |
| 384 | disabled interface (but was once enabled) should be flushed |
| 385 | by ospf6_lsa_refresh (), and does not come here. */ |
| 386 | assert (oi->area); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 387 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 388 | old = ospf6_lsdb_lookup (htons (OSPF6_LSTYPE_NETWORK), |
| 389 | htonl (oi->interface->ifindex), |
| 390 | oi->area->ospf6->router_id, oi->area->lsdb); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 391 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 392 | /* Do not originate Network-LSA if not DR */ |
| 393 | if (oi->state != OSPF6_INTERFACE_DR) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 394 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 395 | if (old) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 396 | ospf6_lsa_purge (old); |
| 397 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 398 | } |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 399 | |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 400 | if (IS_OSPF6_DEBUG_ORIGINATE (NETWORK)) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 401 | zlog_debug ("Originate Network-LSA for Interface %s", oi->interface->name); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 402 | |
| 403 | /* If none of neighbor is adjacent to us */ |
| 404 | count = 0; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 405 | |
| 406 | for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, i, on)) |
| 407 | if (on->state == OSPF6_NEIGHBOR_FULL) |
| 408 | count++; |
| 409 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 410 | if (count == 0) |
| 411 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 412 | if (IS_OSPF6_DEBUG_ORIGINATE (NETWORK)) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 413 | zlog_debug ("Interface stub, ignore"); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 414 | if (old) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 415 | ospf6_lsa_purge (old); |
| 416 | return 0; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 417 | } |
| 418 | |
| 419 | /* prepare buffer */ |
| 420 | memset (buffer, 0, sizeof (buffer)); |
| 421 | lsa_header = (struct ospf6_lsa_header *) buffer; |
| 422 | network_lsa = (struct ospf6_network_lsa *) |
| 423 | ((caddr_t) lsa_header + sizeof (struct ospf6_lsa_header)); |
| 424 | |
| 425 | /* Collect the interface's Link-LSAs to describe |
| 426 | network's optional capabilities */ |
| 427 | type = htons (OSPF6_LSTYPE_LINK); |
| 428 | for (lsa = ospf6_lsdb_type_head (type, oi->lsdb); lsa; |
| 429 | lsa = ospf6_lsdb_type_next (type, lsa)) |
| 430 | { |
| 431 | link_lsa = (struct ospf6_link_lsa *) |
| 432 | ((caddr_t) lsa->header + sizeof (struct ospf6_lsa_header)); |
| 433 | network_lsa->options[0] |= link_lsa->options[0]; |
| 434 | network_lsa->options[1] |= link_lsa->options[1]; |
| 435 | network_lsa->options[2] |= link_lsa->options[2]; |
| 436 | } |
| 437 | |
| 438 | lsdesc = (struct ospf6_network_lsdesc *) |
| 439 | ((caddr_t) network_lsa + sizeof (struct ospf6_network_lsa)); |
| 440 | |
| 441 | /* set Link Description to the router itself */ |
| 442 | lsdesc->router_id = oi->area->ospf6->router_id; |
| 443 | lsdesc++; |
| 444 | |
| 445 | /* Walk through the neighbors */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 446 | for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, i, on)) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 447 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 448 | if (on->state != OSPF6_NEIGHBOR_FULL) |
| 449 | continue; |
| 450 | |
| 451 | /* set this neighbor's Router-ID to LSA */ |
| 452 | lsdesc->router_id = on->router_id; |
| 453 | lsdesc++; |
| 454 | } |
| 455 | |
| 456 | /* Fill LSA Header */ |
| 457 | lsa_header->age = 0; |
| 458 | lsa_header->type = htons (OSPF6_LSTYPE_NETWORK); |
| 459 | lsa_header->id = htonl (oi->interface->ifindex); |
| 460 | lsa_header->adv_router = oi->area->ospf6->router_id; |
| 461 | lsa_header->seqnum = |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 462 | ospf6_new_ls_seqnum (lsa_header->type, lsa_header->id, |
| 463 | lsa_header->adv_router, oi->area->lsdb); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 464 | lsa_header->length = htons ((caddr_t) lsdesc - (caddr_t) buffer); |
| 465 | |
| 466 | /* LSA checksum */ |
| 467 | ospf6_lsa_checksum (lsa_header); |
| 468 | |
| 469 | /* create LSA */ |
| 470 | lsa = ospf6_lsa_create (lsa_header); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 471 | |
| 472 | /* Originate */ |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 473 | ospf6_lsa_originate_area (lsa, oi->area); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 474 | |
| 475 | return 0; |
| 476 | } |
| 477 | |
| 478 | |
| 479 | /****************************/ |
| 480 | /* RFC2740 3.4.3.6 Link-LSA */ |
| 481 | /****************************/ |
| 482 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 483 | static int |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 484 | ospf6_link_lsa_show (struct vty *vty, struct ospf6_lsa *lsa) |
| 485 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 486 | char *start, *end, *current; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 487 | struct ospf6_link_lsa *link_lsa; |
| 488 | int prefixnum; |
| 489 | char buf[128], options[32]; |
| 490 | struct ospf6_prefix *prefix; |
paul | 0c083ee | 2004-10-10 12:54:58 +0000 | [diff] [blame] | 491 | const char *p, *mc, *la, *nu; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 492 | struct in6_addr in6; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 493 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 494 | link_lsa = (struct ospf6_link_lsa *) |
| 495 | ((caddr_t) lsa->header + sizeof (struct ospf6_lsa_header)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 496 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 497 | ospf6_options_printbuf (link_lsa->options, options, sizeof (options)); |
| 498 | inet_ntop (AF_INET6, &link_lsa->linklocal_addr, buf, sizeof (buf)); |
| 499 | prefixnum = ntohl (link_lsa->prefix_num); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 500 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 501 | vty_out (vty, " Priority: %d Options: %s%s", |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 502 | link_lsa->priority, options, VNL); |
| 503 | vty_out (vty, " LinkLocal Address: %s%s", buf, VNL); |
| 504 | vty_out (vty, " Number of Prefix: %d%s", prefixnum, VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 505 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 506 | start = (char *) link_lsa + sizeof (struct ospf6_link_lsa); |
| 507 | end = (char *) lsa->header + ntohs (lsa->header->length); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 508 | for (current = start; current < end; current += OSPF6_PREFIX_SIZE (prefix)) |
| 509 | { |
| 510 | prefix = (struct ospf6_prefix *) current; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 511 | if (prefix->prefix_length == 0 || |
| 512 | current + OSPF6_PREFIX_SIZE (prefix) > end) |
| 513 | break; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 514 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 515 | p = (CHECK_FLAG (prefix->prefix_options, OSPF6_PREFIX_OPTION_P) ? |
| 516 | "P" : "--"); |
| 517 | mc = (CHECK_FLAG (prefix->prefix_options, OSPF6_PREFIX_OPTION_MC) ? |
| 518 | "MC" : "--"); |
| 519 | la = (CHECK_FLAG (prefix->prefix_options, OSPF6_PREFIX_OPTION_LA) ? |
| 520 | "LA" : "--"); |
| 521 | nu = (CHECK_FLAG (prefix->prefix_options, OSPF6_PREFIX_OPTION_NU) ? |
| 522 | "NU" : "--"); |
| 523 | vty_out (vty, " Prefix Options: %s|%s|%s|%s%s", |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 524 | p, mc, la, nu, VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 525 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 526 | memset (&in6, 0, sizeof (in6)); |
| 527 | memcpy (&in6, OSPF6_PREFIX_BODY (prefix), |
| 528 | OSPF6_PREFIX_SPACE (prefix->prefix_length)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 529 | inet_ntop (AF_INET6, &in6, buf, sizeof (buf)); |
| 530 | vty_out (vty, " Prefix: %s/%d%s", |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 531 | buf, prefix->prefix_length, VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 532 | } |
| 533 | |
| 534 | return 0; |
| 535 | } |
| 536 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 537 | int |
| 538 | ospf6_link_lsa_originate (struct thread *thread) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 539 | { |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 540 | struct ospf6_interface *oi; |
| 541 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 542 | char buffer[OSPF6_MAX_LSASIZE]; |
| 543 | struct ospf6_lsa_header *lsa_header; |
| 544 | struct ospf6_lsa *old, *lsa; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 545 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 546 | struct ospf6_link_lsa *link_lsa; |
| 547 | struct ospf6_route *route; |
| 548 | struct ospf6_prefix *op; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 549 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 550 | oi = (struct ospf6_interface *) THREAD_ARG (thread); |
| 551 | oi->thread_link_lsa = NULL; |
| 552 | |
| 553 | assert (oi->area); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 554 | |
| 555 | /* find previous LSA */ |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 556 | old = ospf6_lsdb_lookup (htons (OSPF6_LSTYPE_LINK), |
| 557 | htonl (oi->interface->ifindex), |
| 558 | oi->area->ospf6->router_id, oi->lsdb); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 559 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 560 | if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 561 | { |
| 562 | if (old) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 563 | ospf6_lsa_purge (old); |
| 564 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 565 | } |
| 566 | |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 567 | if (IS_OSPF6_DEBUG_ORIGINATE (LINK)) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 568 | zlog_debug ("Originate Link-LSA for Interface %s", oi->interface->name); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 569 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 570 | /* can't make Link-LSA if linklocal address not set */ |
| 571 | if (oi->linklocal_addr == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 572 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 573 | if (IS_OSPF6_DEBUG_ORIGINATE (LINK)) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 574 | zlog_debug ("No Linklocal address on %s, defer originating", |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 575 | oi->interface->name); |
| 576 | if (old) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 577 | ospf6_lsa_purge (old); |
| 578 | return 0; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 579 | } |
| 580 | |
| 581 | /* prepare buffer */ |
| 582 | memset (buffer, 0, sizeof (buffer)); |
| 583 | lsa_header = (struct ospf6_lsa_header *) buffer; |
| 584 | link_lsa = (struct ospf6_link_lsa *) |
| 585 | ((caddr_t) lsa_header + sizeof (struct ospf6_lsa_header)); |
| 586 | |
| 587 | /* Fill Link-LSA */ |
| 588 | link_lsa->priority = oi->priority; |
| 589 | memcpy (link_lsa->options, oi->area->options, 3); |
| 590 | memcpy (&link_lsa->linklocal_addr, oi->linklocal_addr, |
| 591 | sizeof (struct in6_addr)); |
| 592 | link_lsa->prefix_num = htonl (oi->route_connected->count); |
| 593 | |
| 594 | op = (struct ospf6_prefix *) |
| 595 | ((caddr_t) link_lsa + sizeof (struct ospf6_link_lsa)); |
| 596 | |
| 597 | /* connected prefix to advertise */ |
| 598 | for (route = ospf6_route_head (oi->route_connected); route; |
| 599 | route = ospf6_route_next (route)) |
| 600 | { |
| 601 | op->prefix_length = route->prefix.prefixlen; |
| 602 | op->prefix_options = route->path.prefix_options; |
| 603 | op->prefix_metric = htons (0); |
| 604 | memcpy (OSPF6_PREFIX_BODY (op), &route->prefix.u.prefix6, |
| 605 | OSPF6_PREFIX_SPACE (op->prefix_length)); |
| 606 | op = OSPF6_PREFIX_NEXT (op); |
| 607 | } |
| 608 | |
| 609 | /* Fill LSA Header */ |
| 610 | lsa_header->age = 0; |
| 611 | lsa_header->type = htons (OSPF6_LSTYPE_LINK); |
| 612 | lsa_header->id = htonl (oi->interface->ifindex); |
| 613 | lsa_header->adv_router = oi->area->ospf6->router_id; |
| 614 | lsa_header->seqnum = |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 615 | ospf6_new_ls_seqnum (lsa_header->type, lsa_header->id, |
| 616 | lsa_header->adv_router, oi->lsdb); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 617 | lsa_header->length = htons ((caddr_t) op - (caddr_t) buffer); |
| 618 | |
| 619 | /* LSA checksum */ |
| 620 | ospf6_lsa_checksum (lsa_header); |
| 621 | |
| 622 | /* create LSA */ |
| 623 | lsa = ospf6_lsa_create (lsa_header); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 624 | |
| 625 | /* Originate */ |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 626 | ospf6_lsa_originate_interface (lsa, oi); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 627 | |
| 628 | return 0; |
| 629 | } |
| 630 | |
| 631 | |
| 632 | /*****************************************/ |
| 633 | /* RFC2740 3.4.3.7 Intra-Area-Prefix-LSA */ |
| 634 | /*****************************************/ |
| 635 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 636 | static int |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 637 | ospf6_intra_prefix_lsa_show (struct vty *vty, struct ospf6_lsa *lsa) |
| 638 | { |
| 639 | char *start, *end, *current; |
| 640 | struct ospf6_intra_prefix_lsa *intra_prefix_lsa; |
| 641 | int prefixnum; |
| 642 | char buf[128]; |
| 643 | struct ospf6_prefix *prefix; |
| 644 | char id[16], adv_router[16]; |
paul | 0c083ee | 2004-10-10 12:54:58 +0000 | [diff] [blame] | 645 | const char *p, *mc, *la, *nu; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 646 | struct in6_addr in6; |
| 647 | |
| 648 | intra_prefix_lsa = (struct ospf6_intra_prefix_lsa *) |
| 649 | ((caddr_t) lsa->header + sizeof (struct ospf6_lsa_header)); |
| 650 | |
| 651 | prefixnum = ntohs (intra_prefix_lsa->prefix_num); |
| 652 | |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 653 | vty_out (vty, " Number of Prefix: %d%s", prefixnum, VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 654 | |
| 655 | inet_ntop (AF_INET, &intra_prefix_lsa->ref_id, id, sizeof (id)); |
| 656 | inet_ntop (AF_INET, &intra_prefix_lsa->ref_adv_router, |
| 657 | adv_router, sizeof (adv_router)); |
| 658 | vty_out (vty, " Reference: %s Id: %s Adv: %s%s", |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 659 | ospf6_lstype_name (intra_prefix_lsa->ref_type), id, adv_router, |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 660 | VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 661 | |
| 662 | start = (char *) intra_prefix_lsa + sizeof (struct ospf6_intra_prefix_lsa); |
| 663 | end = (char *) lsa->header + ntohs (lsa->header->length); |
| 664 | for (current = start; current < end; current += OSPF6_PREFIX_SIZE (prefix)) |
| 665 | { |
| 666 | prefix = (struct ospf6_prefix *) current; |
| 667 | if (prefix->prefix_length == 0 || |
| 668 | current + OSPF6_PREFIX_SIZE (prefix) > end) |
| 669 | break; |
| 670 | |
| 671 | p = (CHECK_FLAG (prefix->prefix_options, OSPF6_PREFIX_OPTION_P) ? |
| 672 | "P" : "--"); |
| 673 | mc = (CHECK_FLAG (prefix->prefix_options, OSPF6_PREFIX_OPTION_MC) ? |
| 674 | "MC" : "--"); |
| 675 | la = (CHECK_FLAG (prefix->prefix_options, OSPF6_PREFIX_OPTION_LA) ? |
| 676 | "LA" : "--"); |
| 677 | nu = (CHECK_FLAG (prefix->prefix_options, OSPF6_PREFIX_OPTION_NU) ? |
| 678 | "NU" : "--"); |
| 679 | vty_out (vty, " Prefix Options: %s|%s|%s|%s%s", |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 680 | p, mc, la, nu, VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 681 | |
| 682 | memset (&in6, 0, sizeof (in6)); |
| 683 | memcpy (&in6, OSPF6_PREFIX_BODY (prefix), |
| 684 | OSPF6_PREFIX_SPACE (prefix->prefix_length)); |
| 685 | inet_ntop (AF_INET6, &in6, buf, sizeof (buf)); |
| 686 | vty_out (vty, " Prefix: %s/%d%s", |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 687 | buf, prefix->prefix_length, VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 688 | } |
| 689 | |
| 690 | return 0; |
| 691 | } |
| 692 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 693 | int |
| 694 | ospf6_intra_prefix_lsa_originate_stub (struct thread *thread) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 695 | { |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 696 | struct ospf6_area *oa; |
| 697 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 698 | char buffer[OSPF6_MAX_LSASIZE]; |
| 699 | struct ospf6_lsa_header *lsa_header; |
| 700 | struct ospf6_lsa *old, *lsa; |
| 701 | |
| 702 | struct ospf6_intra_prefix_lsa *intra_prefix_lsa; |
| 703 | struct ospf6_interface *oi; |
| 704 | struct ospf6_neighbor *on; |
| 705 | struct ospf6_route *route; |
| 706 | struct ospf6_prefix *op; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 707 | struct listnode *i, *j; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 708 | int full_count = 0; |
| 709 | unsigned short prefix_num = 0; |
| 710 | char buf[BUFSIZ]; |
| 711 | struct ospf6_route_table *route_advertise; |
| 712 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 713 | oa = (struct ospf6_area *) THREAD_ARG (thread); |
| 714 | oa->thread_intra_prefix_lsa = NULL; |
| 715 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 716 | /* find previous LSA */ |
| 717 | old = ospf6_lsdb_lookup (htons (OSPF6_LSTYPE_INTRA_PREFIX), |
| 718 | htonl (0), oa->ospf6->router_id, oa->lsdb); |
| 719 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 720 | if (! IS_AREA_ENABLED (oa)) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 721 | { |
| 722 | if (old) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 723 | ospf6_lsa_purge (old); |
| 724 | return 0; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 725 | } |
| 726 | |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 727 | if (IS_OSPF6_DEBUG_ORIGINATE (INTRA_PREFIX)) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 728 | zlog_debug ("Originate Intra-Area-Prefix-LSA for area %s's stub prefix", |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 729 | oa->name); |
| 730 | |
| 731 | /* prepare buffer */ |
| 732 | memset (buffer, 0, sizeof (buffer)); |
| 733 | lsa_header = (struct ospf6_lsa_header *) buffer; |
| 734 | intra_prefix_lsa = (struct ospf6_intra_prefix_lsa *) |
| 735 | ((caddr_t) lsa_header + sizeof (struct ospf6_lsa_header)); |
| 736 | |
| 737 | /* Fill Intra-Area-Prefix-LSA */ |
| 738 | intra_prefix_lsa->ref_type = htons (OSPF6_LSTYPE_ROUTER); |
| 739 | intra_prefix_lsa->ref_id = htonl (0); |
| 740 | intra_prefix_lsa->ref_adv_router = oa->ospf6->router_id; |
| 741 | |
Paul Jakma | cf1ce25 | 2006-05-15 10:46:07 +0000 | [diff] [blame] | 742 | route_advertise = ospf6_route_table_create (0, 0); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 743 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 744 | for (ALL_LIST_ELEMENTS_RO (oa->if_list, i, oi)) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 745 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 746 | if (oi->state == OSPF6_INTERFACE_DOWN) |
| 747 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 748 | if (IS_OSPF6_DEBUG_ORIGINATE (INTRA_PREFIX)) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 749 | zlog_debug (" Interface %s is down, ignore", oi->interface->name); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 750 | continue; |
| 751 | } |
| 752 | |
| 753 | full_count = 0; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 754 | |
| 755 | for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, j, on)) |
| 756 | if (on->state == OSPF6_NEIGHBOR_FULL) |
| 757 | full_count++; |
| 758 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 759 | if (oi->state != OSPF6_INTERFACE_LOOPBACK && |
| 760 | oi->state != OSPF6_INTERFACE_POINTTOPOINT && |
| 761 | full_count != 0) |
| 762 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 763 | if (IS_OSPF6_DEBUG_ORIGINATE (INTRA_PREFIX)) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 764 | zlog_debug (" Interface %s is not stub, ignore", |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 765 | oi->interface->name); |
| 766 | continue; |
| 767 | } |
| 768 | |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 769 | if (IS_OSPF6_DEBUG_ORIGINATE (INTRA_PREFIX)) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 770 | zlog_debug (" Interface %s:", oi->interface->name); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 771 | |
| 772 | /* connected prefix to advertise */ |
| 773 | for (route = ospf6_route_head (oi->route_connected); route; |
| 774 | route = ospf6_route_best_next (route)) |
| 775 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 776 | if (IS_OSPF6_DEBUG_ORIGINATE (INTRA_PREFIX)) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 777 | { |
| 778 | prefix2str (&route->prefix, buf, sizeof (buf)); |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 779 | zlog_debug (" include %s", buf); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 780 | } |
| 781 | ospf6_route_add (ospf6_route_copy (route), route_advertise); |
| 782 | } |
| 783 | } |
| 784 | |
| 785 | if (route_advertise->count == 0) |
| 786 | { |
| 787 | if (old) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 788 | ospf6_lsa_purge (old); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 789 | ospf6_route_table_delete (route_advertise); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 790 | return 0; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 791 | } |
| 792 | |
| 793 | /* put prefixes to advertise */ |
| 794 | prefix_num = 0; |
| 795 | op = (struct ospf6_prefix *) |
| 796 | ((caddr_t) intra_prefix_lsa + sizeof (struct ospf6_intra_prefix_lsa)); |
| 797 | for (route = ospf6_route_head (route_advertise); route; |
| 798 | route = ospf6_route_best_next (route)) |
| 799 | { |
| 800 | op->prefix_length = route->prefix.prefixlen; |
| 801 | op->prefix_options = route->path.prefix_options; |
| 802 | op->prefix_metric = htons (route->path.cost); |
| 803 | memcpy (OSPF6_PREFIX_BODY (op), &route->prefix.u.prefix6, |
| 804 | OSPF6_PREFIX_SPACE (op->prefix_length)); |
| 805 | op = OSPF6_PREFIX_NEXT (op); |
| 806 | prefix_num++; |
| 807 | } |
| 808 | |
| 809 | ospf6_route_table_delete (route_advertise); |
| 810 | |
| 811 | if (prefix_num == 0) |
| 812 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 813 | if (IS_OSPF6_DEBUG_ORIGINATE (INTRA_PREFIX)) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 814 | zlog_debug ("Quit to Advertise Intra-Prefix: no route to advertise"); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 815 | return 0; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 816 | } |
| 817 | |
| 818 | intra_prefix_lsa->prefix_num = htons (prefix_num); |
| 819 | |
| 820 | /* Fill LSA Header */ |
| 821 | lsa_header->age = 0; |
| 822 | lsa_header->type = htons (OSPF6_LSTYPE_INTRA_PREFIX); |
| 823 | lsa_header->id = htonl (0); |
| 824 | lsa_header->adv_router = oa->ospf6->router_id; |
| 825 | lsa_header->seqnum = |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 826 | ospf6_new_ls_seqnum (lsa_header->type, lsa_header->id, |
| 827 | lsa_header->adv_router, oa->lsdb); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 828 | lsa_header->length = htons ((caddr_t) op - (caddr_t) lsa_header); |
| 829 | |
| 830 | /* LSA checksum */ |
| 831 | ospf6_lsa_checksum (lsa_header); |
| 832 | |
| 833 | /* create LSA */ |
| 834 | lsa = ospf6_lsa_create (lsa_header); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 835 | |
| 836 | /* Originate */ |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 837 | ospf6_lsa_originate_area (lsa, oa); |
| 838 | |
| 839 | return 0; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 840 | } |
| 841 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 842 | |
| 843 | int |
| 844 | ospf6_intra_prefix_lsa_originate_transit (struct thread *thread) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 845 | { |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 846 | struct ospf6_interface *oi; |
| 847 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 848 | char buffer[OSPF6_MAX_LSASIZE]; |
| 849 | struct ospf6_lsa_header *lsa_header; |
| 850 | struct ospf6_lsa *old, *lsa; |
| 851 | |
| 852 | struct ospf6_intra_prefix_lsa *intra_prefix_lsa; |
| 853 | struct ospf6_neighbor *on; |
| 854 | struct ospf6_route *route; |
| 855 | struct ospf6_prefix *op; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 856 | struct listnode *i; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 857 | int full_count = 0; |
| 858 | unsigned short prefix_num = 0; |
| 859 | struct ospf6_route_table *route_advertise; |
| 860 | struct ospf6_link_lsa *link_lsa; |
| 861 | char *start, *end, *current; |
| 862 | u_int16_t type; |
| 863 | char buf[BUFSIZ]; |
| 864 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 865 | oi = (struct ospf6_interface *) THREAD_ARG (thread); |
| 866 | oi->thread_intra_prefix_lsa = NULL; |
| 867 | |
| 868 | assert (oi->area); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 869 | |
| 870 | /* find previous LSA */ |
| 871 | old = ospf6_lsdb_lookup (htons (OSPF6_LSTYPE_INTRA_PREFIX), |
| 872 | htonl (oi->interface->ifindex), |
| 873 | oi->area->ospf6->router_id, oi->area->lsdb); |
| 874 | |
| 875 | if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE)) |
| 876 | { |
| 877 | if (old) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 878 | ospf6_lsa_purge (old); |
| 879 | return 0; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 880 | } |
| 881 | |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 882 | if (IS_OSPF6_DEBUG_ORIGINATE (INTRA_PREFIX)) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 883 | zlog_debug ("Originate Intra-Area-Prefix-LSA for interface %s's prefix", |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 884 | oi->interface->name); |
| 885 | |
| 886 | /* prepare buffer */ |
| 887 | memset (buffer, 0, sizeof (buffer)); |
| 888 | lsa_header = (struct ospf6_lsa_header *) buffer; |
| 889 | intra_prefix_lsa = (struct ospf6_intra_prefix_lsa *) |
| 890 | ((caddr_t) lsa_header + sizeof (struct ospf6_lsa_header)); |
| 891 | |
| 892 | /* Fill Intra-Area-Prefix-LSA */ |
| 893 | intra_prefix_lsa->ref_type = htons (OSPF6_LSTYPE_NETWORK); |
| 894 | intra_prefix_lsa->ref_id = htonl (oi->interface->ifindex); |
| 895 | intra_prefix_lsa->ref_adv_router = oi->area->ospf6->router_id; |
| 896 | |
| 897 | if (oi->state != OSPF6_INTERFACE_DR) |
| 898 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 899 | if (IS_OSPF6_DEBUG_ORIGINATE (INTRA_PREFIX)) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 900 | zlog_debug (" Interface is not DR"); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 901 | if (old) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 902 | ospf6_lsa_purge (old); |
| 903 | return 0; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 904 | } |
| 905 | |
| 906 | full_count = 0; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 907 | for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, i, on)) |
| 908 | if (on->state == OSPF6_NEIGHBOR_FULL) |
| 909 | full_count++; |
| 910 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 911 | if (full_count == 0) |
| 912 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 913 | if (IS_OSPF6_DEBUG_ORIGINATE (INTRA_PREFIX)) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 914 | zlog_debug (" Interface is stub"); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 915 | if (old) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 916 | ospf6_lsa_purge (old); |
| 917 | return 0; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 918 | } |
| 919 | |
| 920 | /* connected prefix to advertise */ |
Paul Jakma | cf1ce25 | 2006-05-15 10:46:07 +0000 | [diff] [blame] | 921 | route_advertise = ospf6_route_table_create (0, 0); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 922 | |
| 923 | type = ntohs (OSPF6_LSTYPE_LINK); |
| 924 | for (lsa = ospf6_lsdb_type_head (type, oi->lsdb); lsa; |
| 925 | lsa = ospf6_lsdb_type_next (type, lsa)) |
| 926 | { |
| 927 | if (OSPF6_LSA_IS_MAXAGE (lsa)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 928 | continue; |
| 929 | |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 930 | if (IS_OSPF6_DEBUG_ORIGINATE (INTRA_PREFIX)) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 931 | zlog_debug (" include prefix from %s", lsa->name); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 932 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 933 | if (lsa->header->adv_router != oi->area->ospf6->router_id) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 934 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 935 | on = ospf6_neighbor_lookup (lsa->header->adv_router, oi); |
| 936 | if (on == NULL || on->state != OSPF6_NEIGHBOR_FULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 937 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 938 | if (IS_OSPF6_DEBUG_ORIGINATE (INTRA_PREFIX)) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 939 | zlog_debug (" Neighbor not found or not Full, ignore"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 940 | continue; |
| 941 | } |
| 942 | } |
| 943 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 944 | link_lsa = (struct ospf6_link_lsa *) |
| 945 | ((caddr_t) lsa->header + sizeof (struct ospf6_lsa_header)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 946 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 947 | prefix_num = (unsigned short) ntohl (link_lsa->prefix_num); |
| 948 | start = (char *) link_lsa + sizeof (struct ospf6_link_lsa); |
| 949 | end = (char *) lsa->header + ntohs (lsa->header->length); |
| 950 | for (current = start; current < end && prefix_num; |
| 951 | current += OSPF6_PREFIX_SIZE (op)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 952 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 953 | op = (struct ospf6_prefix *) current; |
| 954 | if (op->prefix_length == 0 || |
| 955 | current + OSPF6_PREFIX_SIZE (op) > end) |
| 956 | break; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 957 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 958 | route = ospf6_route_create (); |
| 959 | |
| 960 | route->type = OSPF6_DEST_TYPE_NETWORK; |
| 961 | route->prefix.family = AF_INET6; |
| 962 | route->prefix.prefixlen = op->prefix_length; |
| 963 | memset (&route->prefix.u.prefix6, 0, sizeof (struct in6_addr)); |
| 964 | memcpy (&route->prefix.u.prefix6, OSPF6_PREFIX_BODY (op), |
| 965 | OSPF6_PREFIX_SPACE (op->prefix_length)); |
| 966 | |
| 967 | route->path.origin.type = lsa->header->type; |
| 968 | route->path.origin.id = lsa->header->id; |
| 969 | route->path.origin.adv_router = lsa->header->adv_router; |
| 970 | route->path.options[0] = link_lsa->options[0]; |
| 971 | route->path.options[1] = link_lsa->options[1]; |
| 972 | route->path.options[2] = link_lsa->options[2]; |
| 973 | route->path.prefix_options = op->prefix_options; |
| 974 | route->path.area_id = oi->area->area_id; |
| 975 | route->path.type = OSPF6_PATH_TYPE_INTRA; |
| 976 | |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 977 | if (IS_OSPF6_DEBUG_ORIGINATE (INTRA_PREFIX)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 978 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 979 | prefix2str (&route->prefix, buf, sizeof (buf)); |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 980 | zlog_debug (" include %s", buf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 981 | } |
| 982 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 983 | ospf6_route_add (route, route_advertise); |
| 984 | prefix_num--; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 985 | } |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 986 | if (current != end && IS_OSPF6_DEBUG_ORIGINATE (INTRA_PREFIX)) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 987 | zlog_debug ("Trailing garbage in %s", lsa->name); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 988 | } |
| 989 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 990 | op = (struct ospf6_prefix *) |
| 991 | ((caddr_t) intra_prefix_lsa + sizeof (struct ospf6_intra_prefix_lsa)); |
| 992 | |
| 993 | prefix_num = 0; |
| 994 | for (route = ospf6_route_head (route_advertise); route; |
| 995 | route = ospf6_route_best_next (route)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 996 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 997 | op->prefix_length = route->prefix.prefixlen; |
| 998 | op->prefix_options = route->path.prefix_options; |
| 999 | op->prefix_metric = htons (0); |
| 1000 | memcpy (OSPF6_PREFIX_BODY (op), &route->prefix.u.prefix6, |
| 1001 | OSPF6_PREFIX_SPACE (op->prefix_length)); |
| 1002 | op = OSPF6_PREFIX_NEXT (op); |
| 1003 | prefix_num++; |
| 1004 | } |
| 1005 | |
| 1006 | ospf6_route_table_delete (route_advertise); |
| 1007 | |
| 1008 | if (prefix_num == 0) |
| 1009 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 1010 | if (IS_OSPF6_DEBUG_ORIGINATE (INTRA_PREFIX)) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 1011 | zlog_debug ("Quit to Advertise Intra-Prefix: no route to advertise"); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 1012 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1013 | } |
| 1014 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1015 | intra_prefix_lsa->prefix_num = htons (prefix_num); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1016 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1017 | /* Fill LSA Header */ |
| 1018 | lsa_header->age = 0; |
| 1019 | lsa_header->type = htons (OSPF6_LSTYPE_INTRA_PREFIX); |
| 1020 | lsa_header->id = htonl (oi->interface->ifindex); |
| 1021 | lsa_header->adv_router = oi->area->ospf6->router_id; |
| 1022 | lsa_header->seqnum = |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 1023 | ospf6_new_ls_seqnum (lsa_header->type, lsa_header->id, |
| 1024 | lsa_header->adv_router, oi->area->lsdb); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1025 | lsa_header->length = htons ((caddr_t) op - (caddr_t) lsa_header); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1026 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1027 | /* LSA checksum */ |
| 1028 | ospf6_lsa_checksum (lsa_header); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1029 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1030 | /* create LSA */ |
| 1031 | lsa = ospf6_lsa_create (lsa_header); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1032 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1033 | /* Originate */ |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 1034 | ospf6_lsa_originate_area (lsa, oi->area); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1035 | |
| 1036 | return 0; |
| 1037 | } |
| 1038 | |
| 1039 | void |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1040 | ospf6_intra_prefix_lsa_add (struct ospf6_lsa *lsa) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1041 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1042 | struct ospf6_area *oa; |
| 1043 | struct ospf6_intra_prefix_lsa *intra_prefix_lsa; |
| 1044 | struct prefix ls_prefix; |
| 1045 | struct ospf6_route *route, *ls_entry; |
| 1046 | int i, prefix_num; |
| 1047 | struct ospf6_prefix *op; |
| 1048 | char *start, *current, *end; |
| 1049 | char buf[64]; |
Dinesh Dutt | b81e97a | 2013-08-24 07:55:50 +0000 | [diff] [blame] | 1050 | struct interface *ifp; |
| 1051 | int direct_connect = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1052 | |
hasso | ccb59b1 | 2004-08-25 09:10:37 +0000 | [diff] [blame] | 1053 | if (OSPF6_LSA_IS_MAXAGE (lsa)) |
| 1054 | return; |
| 1055 | |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 1056 | if (IS_OSPF6_DEBUG_EXAMIN (INTRA_PREFIX)) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 1057 | zlog_debug ("%s found", lsa->name); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1058 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 1059 | oa = OSPF6_AREA (lsa->lsdb->data); |
| 1060 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1061 | intra_prefix_lsa = (struct ospf6_intra_prefix_lsa *) |
| 1062 | OSPF6_LSA_HEADER_END (lsa->header); |
| 1063 | if (intra_prefix_lsa->ref_type == htons (OSPF6_LSTYPE_ROUTER)) |
| 1064 | ospf6_linkstate_prefix (intra_prefix_lsa->ref_adv_router, |
| 1065 | htonl (0), &ls_prefix); |
| 1066 | else if (intra_prefix_lsa->ref_type == htons (OSPF6_LSTYPE_NETWORK)) |
| 1067 | ospf6_linkstate_prefix (intra_prefix_lsa->ref_adv_router, |
| 1068 | intra_prefix_lsa->ref_id, &ls_prefix); |
| 1069 | else |
| 1070 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 1071 | if (IS_OSPF6_DEBUG_EXAMIN (INTRA_PREFIX)) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 1072 | zlog_debug ("Unknown reference LS-type: %#hx", |
| 1073 | ntohs (intra_prefix_lsa->ref_type)); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1074 | return; |
| 1075 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1076 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1077 | ls_entry = ospf6_route_lookup (&ls_prefix, oa->spf_table); |
| 1078 | if (ls_entry == NULL) |
| 1079 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 1080 | if (IS_OSPF6_DEBUG_EXAMIN (INTRA_PREFIX)) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1081 | { |
| 1082 | ospf6_linkstate_prefix2str (&ls_prefix, buf, sizeof (buf)); |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 1083 | zlog_debug ("LS entry does not exist: %s", buf); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1084 | } |
| 1085 | return; |
| 1086 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1087 | |
Dinesh Dutt | b81e97a | 2013-08-24 07:55:50 +0000 | [diff] [blame] | 1088 | if (intra_prefix_lsa->ref_adv_router == oa->ospf6->router_id) |
| 1089 | { |
| 1090 | /* the intra-prefix are directly connected */ |
| 1091 | direct_connect = 1; |
| 1092 | } |
| 1093 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1094 | prefix_num = ntohs (intra_prefix_lsa->prefix_num); |
| 1095 | start = (caddr_t) intra_prefix_lsa + |
| 1096 | sizeof (struct ospf6_intra_prefix_lsa); |
| 1097 | end = OSPF6_LSA_END (lsa->header); |
| 1098 | for (current = start; current < end; current += OSPF6_PREFIX_SIZE (op)) |
| 1099 | { |
| 1100 | op = (struct ospf6_prefix *) current; |
| 1101 | if (prefix_num == 0) |
| 1102 | break; |
| 1103 | if (end < current + OSPF6_PREFIX_SIZE (op)) |
| 1104 | break; |
| 1105 | |
| 1106 | route = ospf6_route_create (); |
hasso | ccb59b1 | 2004-08-25 09:10:37 +0000 | [diff] [blame] | 1107 | |
| 1108 | memset (&route->prefix, 0, sizeof (struct prefix)); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1109 | route->prefix.family = AF_INET6; |
hasso | ccb59b1 | 2004-08-25 09:10:37 +0000 | [diff] [blame] | 1110 | route->prefix.prefixlen = op->prefix_length; |
| 1111 | ospf6_prefix_in6_addr (&route->prefix.u.prefix6, op); |
| 1112 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1113 | route->type = OSPF6_DEST_TYPE_NETWORK; |
| 1114 | route->path.origin.type = lsa->header->type; |
| 1115 | route->path.origin.id = lsa->header->id; |
| 1116 | route->path.origin.adv_router = lsa->header->adv_router; |
| 1117 | route->path.prefix_options = op->prefix_options; |
| 1118 | route->path.area_id = oa->area_id; |
| 1119 | route->path.type = OSPF6_PATH_TYPE_INTRA; |
| 1120 | route->path.metric_type = 1; |
| 1121 | route->path.cost = ls_entry->path.cost + |
| 1122 | ntohs (op->prefix_metric); |
| 1123 | |
Dinesh Dutt | b81e97a | 2013-08-24 07:55:50 +0000 | [diff] [blame] | 1124 | if (direct_connect) |
| 1125 | { |
| 1126 | ifp = if_lookup_prefix(&route->prefix); |
| 1127 | if (ifp) |
| 1128 | route->nexthop[0].ifindex = ifp->ifindex; |
| 1129 | } |
| 1130 | else |
| 1131 | { |
| 1132 | for (i = 0; ospf6_nexthop_is_set (&ls_entry->nexthop[i]) && |
| 1133 | i < OSPF6_MULTI_PATH_LIMIT; i++) |
| 1134 | ospf6_nexthop_copy (&route->nexthop[i], &ls_entry->nexthop[i]); |
| 1135 | } |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1136 | |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 1137 | if (IS_OSPF6_DEBUG_EXAMIN (INTRA_PREFIX)) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1138 | { |
| 1139 | prefix2str (&route->prefix, buf, sizeof (buf)); |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 1140 | zlog_debug (" add %s", buf); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1141 | } |
| 1142 | |
| 1143 | ospf6_route_add (route, oa->route_table); |
| 1144 | prefix_num--; |
| 1145 | } |
| 1146 | |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 1147 | if (current != end && IS_OSPF6_DEBUG_EXAMIN (INTRA_PREFIX)) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 1148 | zlog_debug ("Trailing garbage ignored"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1149 | } |
| 1150 | |
| 1151 | void |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1152 | ospf6_intra_prefix_lsa_remove (struct ospf6_lsa *lsa) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1153 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1154 | struct ospf6_area *oa; |
| 1155 | struct ospf6_intra_prefix_lsa *intra_prefix_lsa; |
| 1156 | struct prefix prefix; |
| 1157 | struct ospf6_route *route; |
| 1158 | int prefix_num; |
| 1159 | struct ospf6_prefix *op; |
| 1160 | char *start, *current, *end; |
| 1161 | char buf[64]; |
| 1162 | |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 1163 | if (IS_OSPF6_DEBUG_EXAMIN (INTRA_PREFIX)) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 1164 | zlog_debug ("%s disappearing", lsa->name); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1165 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 1166 | oa = OSPF6_AREA (lsa->lsdb->data); |
| 1167 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1168 | intra_prefix_lsa = (struct ospf6_intra_prefix_lsa *) |
| 1169 | OSPF6_LSA_HEADER_END (lsa->header); |
| 1170 | |
| 1171 | prefix_num = ntohs (intra_prefix_lsa->prefix_num); |
| 1172 | start = (caddr_t) intra_prefix_lsa + |
| 1173 | sizeof (struct ospf6_intra_prefix_lsa); |
| 1174 | end = OSPF6_LSA_END (lsa->header); |
| 1175 | for (current = start; current < end; current += OSPF6_PREFIX_SIZE (op)) |
| 1176 | { |
| 1177 | op = (struct ospf6_prefix *) current; |
| 1178 | if (prefix_num == 0) |
| 1179 | break; |
| 1180 | if (end < current + OSPF6_PREFIX_SIZE (op)) |
| 1181 | break; |
| 1182 | prefix_num--; |
| 1183 | |
hasso | ccb59b1 | 2004-08-25 09:10:37 +0000 | [diff] [blame] | 1184 | memset (&prefix, 0, sizeof (struct prefix)); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1185 | prefix.family = AF_INET6; |
| 1186 | prefix.prefixlen = op->prefix_length; |
| 1187 | ospf6_prefix_in6_addr (&prefix.u.prefix6, op); |
| 1188 | |
| 1189 | route = ospf6_route_lookup (&prefix, oa->route_table); |
| 1190 | if (route == NULL) |
| 1191 | continue; |
| 1192 | |
| 1193 | for (ospf6_route_lock (route); |
| 1194 | route && ospf6_route_is_prefix (&prefix, route); |
| 1195 | route = ospf6_route_next (route)) |
| 1196 | { |
| 1197 | if (route->type != OSPF6_DEST_TYPE_NETWORK) |
| 1198 | continue; |
| 1199 | if (route->path.area_id != oa->area_id) |
| 1200 | continue; |
| 1201 | if (route->path.type != OSPF6_PATH_TYPE_INTRA) |
| 1202 | continue; |
| 1203 | if (route->path.origin.type != lsa->header->type || |
| 1204 | route->path.origin.id != lsa->header->id || |
| 1205 | route->path.origin.adv_router != lsa->header->adv_router) |
| 1206 | continue; |
| 1207 | |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 1208 | if (IS_OSPF6_DEBUG_EXAMIN (INTRA_PREFIX)) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1209 | { |
| 1210 | prefix2str (&route->prefix, buf, sizeof (buf)); |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 1211 | zlog_debug ("remove %s", buf); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1212 | } |
| 1213 | ospf6_route_remove (route, oa->route_table); |
| 1214 | } |
Tom Goff | e7a6d80 | 2010-11-10 13:03:02 -0800 | [diff] [blame] | 1215 | if (route) |
| 1216 | ospf6_route_unlock (route); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1217 | } |
| 1218 | |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 1219 | if (current != end && IS_OSPF6_DEBUG_EXAMIN (INTRA_PREFIX)) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 1220 | zlog_debug ("Trailing garbage ignored"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1221 | } |
| 1222 | |
| 1223 | void |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1224 | ospf6_intra_route_calculation (struct ospf6_area *oa) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1225 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1226 | struct ospf6_route *route; |
| 1227 | u_int16_t type; |
| 1228 | struct ospf6_lsa *lsa; |
| 1229 | void (*hook_add) (struct ospf6_route *) = NULL; |
| 1230 | void (*hook_remove) (struct ospf6_route *) = NULL; |
| 1231 | |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 1232 | if (IS_OSPF6_DEBUG_EXAMIN (INTRA_PREFIX)) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 1233 | zlog_debug ("Re-examin intra-routes for area %s", oa->name); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1234 | |
| 1235 | hook_add = oa->route_table->hook_add; |
| 1236 | hook_remove = oa->route_table->hook_remove; |
| 1237 | oa->route_table->hook_add = NULL; |
| 1238 | oa->route_table->hook_remove = NULL; |
| 1239 | |
| 1240 | for (route = ospf6_route_head (oa->route_table); route; |
| 1241 | route = ospf6_route_next (route)) |
| 1242 | route->flag = OSPF6_ROUTE_REMOVE; |
| 1243 | |
| 1244 | type = htons (OSPF6_LSTYPE_INTRA_PREFIX); |
| 1245 | for (lsa = ospf6_lsdb_type_head (type, oa->lsdb); lsa; |
| 1246 | lsa = ospf6_lsdb_type_next (type, lsa)) |
| 1247 | ospf6_intra_prefix_lsa_add (lsa); |
| 1248 | |
| 1249 | oa->route_table->hook_add = hook_add; |
| 1250 | oa->route_table->hook_remove = hook_remove; |
| 1251 | |
| 1252 | for (route = ospf6_route_head (oa->route_table); route; |
| 1253 | route = ospf6_route_next (route)) |
| 1254 | { |
| 1255 | if (CHECK_FLAG (route->flag, OSPF6_ROUTE_REMOVE) && |
| 1256 | CHECK_FLAG (route->flag, OSPF6_ROUTE_ADD)) |
| 1257 | { |
| 1258 | UNSET_FLAG (route->flag, OSPF6_ROUTE_REMOVE); |
| 1259 | UNSET_FLAG (route->flag, OSPF6_ROUTE_ADD); |
| 1260 | } |
| 1261 | |
| 1262 | if (CHECK_FLAG (route->flag, OSPF6_ROUTE_REMOVE)) |
| 1263 | ospf6_route_remove (route, oa->route_table); |
| 1264 | else if (CHECK_FLAG (route->flag, OSPF6_ROUTE_ADD) || |
| 1265 | CHECK_FLAG (route->flag, OSPF6_ROUTE_CHANGE)) |
| 1266 | { |
| 1267 | if (hook_add) |
| 1268 | (*hook_add) (route); |
| 1269 | } |
| 1270 | |
| 1271 | route->flag = 0; |
| 1272 | } |
| 1273 | |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 1274 | if (IS_OSPF6_DEBUG_EXAMIN (INTRA_PREFIX)) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 1275 | zlog_debug ("Re-examin intra-routes for area %s: Done", oa->name); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1276 | } |
| 1277 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 1278 | static void |
Paul Jakma | cf1ce25 | 2006-05-15 10:46:07 +0000 | [diff] [blame] | 1279 | ospf6_brouter_debug_print (struct ospf6_route *brouter) |
| 1280 | { |
| 1281 | u_int32_t brouter_id; |
| 1282 | char brouter_name[16]; |
| 1283 | char area_name[16]; |
| 1284 | char destination[64]; |
| 1285 | char installed[16], changed[16]; |
| 1286 | struct timeval now, res; |
| 1287 | char id[16], adv_router[16]; |
| 1288 | char capa[16], options[16]; |
| 1289 | |
| 1290 | brouter_id = ADV_ROUTER_IN_PREFIX (&brouter->prefix); |
| 1291 | inet_ntop (AF_INET, &brouter_id, brouter_name, sizeof (brouter_name)); |
| 1292 | inet_ntop (AF_INET, &brouter->path.area_id, area_name, sizeof (area_name)); |
| 1293 | ospf6_linkstate_prefix2str (&brouter->prefix, destination, |
| 1294 | sizeof (destination)); |
| 1295 | |
Takashi Sogabe | 86f72dc | 2009-06-22 13:07:02 +0900 | [diff] [blame] | 1296 | quagga_gettime (QUAGGA_CLK_MONOTONIC, &now); |
Paul Jakma | cf1ce25 | 2006-05-15 10:46:07 +0000 | [diff] [blame] | 1297 | timersub (&now, &brouter->installed, &res); |
| 1298 | timerstring (&res, installed, sizeof (installed)); |
| 1299 | |
Takashi Sogabe | 86f72dc | 2009-06-22 13:07:02 +0900 | [diff] [blame] | 1300 | quagga_gettime (QUAGGA_CLK_MONOTONIC, &now); |
Paul Jakma | cf1ce25 | 2006-05-15 10:46:07 +0000 | [diff] [blame] | 1301 | timersub (&now, &brouter->changed, &res); |
| 1302 | timerstring (&res, changed, sizeof (changed)); |
| 1303 | |
| 1304 | inet_ntop (AF_INET, &brouter->path.origin.id, id, sizeof (id)); |
| 1305 | inet_ntop (AF_INET, &brouter->path.origin.adv_router, adv_router, |
| 1306 | sizeof (adv_router)); |
| 1307 | |
| 1308 | ospf6_options_printbuf (brouter->path.options, options, sizeof (options)); |
| 1309 | ospf6_capability_printbuf (brouter->path.router_bits, capa, sizeof (capa)); |
| 1310 | |
| 1311 | zlog_info ("Brouter: %s via area %s", brouter_name, area_name); |
| 1312 | zlog_info (" memory: prev: %p this: %p next: %p parent rnode: %p", |
| 1313 | brouter->prev, brouter, brouter->next, brouter->rnode); |
| 1314 | zlog_info (" type: %d prefix: %s installed: %s changed: %s", |
| 1315 | brouter->type, destination, installed, changed); |
| 1316 | zlog_info (" lock: %d flags: %s%s%s%s", brouter->lock, |
| 1317 | (CHECK_FLAG (brouter->flag, OSPF6_ROUTE_BEST) ? "B" : "-"), |
| 1318 | (CHECK_FLAG (brouter->flag, OSPF6_ROUTE_ADD) ? "A" : "-"), |
| 1319 | (CHECK_FLAG (brouter->flag, OSPF6_ROUTE_REMOVE) ? "R" : "-"), |
| 1320 | (CHECK_FLAG (brouter->flag, OSPF6_ROUTE_CHANGE) ? "C" : "-")); |
| 1321 | zlog_info (" path type: %s ls-origin %s id: %s adv-router %s", |
| 1322 | OSPF6_PATH_TYPE_NAME (brouter->path.type), |
| 1323 | ospf6_lstype_name (brouter->path.origin.type), |
| 1324 | id, adv_router); |
| 1325 | zlog_info (" options: %s router-bits: %s metric-type: %d metric: %d/%d", |
| 1326 | options, capa, brouter->path.metric_type, |
| 1327 | brouter->path.cost, brouter->path.cost_e2); |
| 1328 | } |
| 1329 | |
| 1330 | void |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 1331 | ospf6_intra_brouter_calculation (struct ospf6_area *oa) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1332 | { |
Paul Jakma | cb4b884 | 2006-05-15 10:39:30 +0000 | [diff] [blame] | 1333 | struct ospf6_route *brouter, *copy; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1334 | void (*hook_add) (struct ospf6_route *) = NULL; |
| 1335 | void (*hook_remove) (struct ospf6_route *) = NULL; |
Paul Jakma | cb4b884 | 2006-05-15 10:39:30 +0000 | [diff] [blame] | 1336 | u_int32_t brouter_id; |
| 1337 | char brouter_name[16]; |
| 1338 | |
| 1339 | if (IS_OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_ID (oa->area_id)) |
| 1340 | zlog_info ("border-router calculation for area %s", oa->name); |
| 1341 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 1342 | hook_add = oa->ospf6->brouter_table->hook_add; |
| 1343 | hook_remove = oa->ospf6->brouter_table->hook_remove; |
| 1344 | oa->ospf6->brouter_table->hook_add = NULL; |
| 1345 | oa->ospf6->brouter_table->hook_remove = NULL; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1346 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 1347 | /* withdraw the previous router entries for the area */ |
Paul Jakma | cb4b884 | 2006-05-15 10:39:30 +0000 | [diff] [blame] | 1348 | for (brouter = ospf6_route_head (oa->ospf6->brouter_table); brouter; |
| 1349 | brouter = ospf6_route_next (brouter)) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1350 | { |
Paul Jakma | cf1ce25 | 2006-05-15 10:46:07 +0000 | [diff] [blame] | 1351 | brouter_id = ADV_ROUTER_IN_PREFIX (&brouter->prefix); |
| 1352 | inet_ntop (AF_INET, &brouter_id, brouter_name, sizeof (brouter_name)); |
Paul Jakma | cb4b884 | 2006-05-15 10:39:30 +0000 | [diff] [blame] | 1353 | if (brouter->path.area_id != oa->area_id) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1354 | continue; |
Paul Jakma | cb4b884 | 2006-05-15 10:39:30 +0000 | [diff] [blame] | 1355 | brouter->flag = OSPF6_ROUTE_REMOVE; |
Paul Jakma | cf1ce25 | 2006-05-15 10:46:07 +0000 | [diff] [blame] | 1356 | |
| 1357 | if (IS_OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_ID (brouter_id) || |
| 1358 | IS_OSPF6_DEBUG_ROUTE (MEMORY)) |
| 1359 | { |
| 1360 | zlog_info ("%p: mark as removing: area %s brouter %s", |
| 1361 | brouter, oa->name, brouter_name); |
| 1362 | ospf6_brouter_debug_print (brouter); |
| 1363 | } |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1364 | } |
| 1365 | |
Paul Jakma | cb4b884 | 2006-05-15 10:39:30 +0000 | [diff] [blame] | 1366 | for (brouter = ospf6_route_head (oa->spf_table); brouter; |
| 1367 | brouter = ospf6_route_next (brouter)) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1368 | { |
Paul Jakma | cf1ce25 | 2006-05-15 10:46:07 +0000 | [diff] [blame] | 1369 | brouter_id = ADV_ROUTER_IN_PREFIX (&brouter->prefix); |
| 1370 | inet_ntop (AF_INET, &brouter_id, brouter_name, sizeof (brouter_name)); |
| 1371 | |
Paul Jakma | cb4b884 | 2006-05-15 10:39:30 +0000 | [diff] [blame] | 1372 | if (brouter->type != OSPF6_DEST_TYPE_LINKSTATE) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1373 | continue; |
Paul Jakma | cb4b884 | 2006-05-15 10:39:30 +0000 | [diff] [blame] | 1374 | if (ospf6_linkstate_prefix_id (&brouter->prefix) != htonl (0)) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1375 | continue; |
Paul Jakma | cb4b884 | 2006-05-15 10:39:30 +0000 | [diff] [blame] | 1376 | if (! CHECK_FLAG (brouter->path.router_bits, OSPF6_ROUTER_BIT_E) && |
| 1377 | ! CHECK_FLAG (brouter->path.router_bits, OSPF6_ROUTER_BIT_B)) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1378 | continue; |
| 1379 | |
Paul Jakma | cb4b884 | 2006-05-15 10:39:30 +0000 | [diff] [blame] | 1380 | copy = ospf6_route_copy (brouter); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1381 | copy->type = OSPF6_DEST_TYPE_ROUTER; |
hasso | ccb59b1 | 2004-08-25 09:10:37 +0000 | [diff] [blame] | 1382 | copy->path.area_id = oa->area_id; |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 1383 | ospf6_route_add (copy, oa->ospf6->brouter_table); |
Paul Jakma | cf1ce25 | 2006-05-15 10:46:07 +0000 | [diff] [blame] | 1384 | |
| 1385 | if (IS_OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_ID (brouter_id) || |
| 1386 | IS_OSPF6_DEBUG_ROUTE (MEMORY)) |
| 1387 | { |
| 1388 | zlog_info ("%p: transfer: area %s brouter %s", |
| 1389 | brouter, oa->name, brouter_name); |
| 1390 | ospf6_brouter_debug_print (brouter); |
| 1391 | } |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1392 | } |
| 1393 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 1394 | oa->ospf6->brouter_table->hook_add = hook_add; |
| 1395 | oa->ospf6->brouter_table->hook_remove = hook_remove; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1396 | |
Paul Jakma | cb4b884 | 2006-05-15 10:39:30 +0000 | [diff] [blame] | 1397 | for (brouter = ospf6_route_head (oa->ospf6->brouter_table); brouter; |
| 1398 | brouter = ospf6_route_next (brouter)) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1399 | { |
Paul Jakma | cb4b884 | 2006-05-15 10:39:30 +0000 | [diff] [blame] | 1400 | brouter_id = ADV_ROUTER_IN_PREFIX (&brouter->prefix); |
| 1401 | inet_ntop (AF_INET, &brouter_id, brouter_name, sizeof (brouter_name)); |
| 1402 | |
| 1403 | if (brouter->path.area_id != oa->area_id) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1404 | continue; |
| 1405 | |
Paul Jakma | cb4b884 | 2006-05-15 10:39:30 +0000 | [diff] [blame] | 1406 | if (CHECK_FLAG (brouter->flag, OSPF6_ROUTE_WAS_REMOVED)) |
hasso | 9428f2d | 2004-09-13 14:01:12 +0000 | [diff] [blame] | 1407 | continue; |
| 1408 | |
Paul Jakma | cb4b884 | 2006-05-15 10:39:30 +0000 | [diff] [blame] | 1409 | if (CHECK_FLAG (brouter->flag, OSPF6_ROUTE_REMOVE) && |
| 1410 | CHECK_FLAG (brouter->flag, OSPF6_ROUTE_ADD)) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1411 | { |
Paul Jakma | cb4b884 | 2006-05-15 10:39:30 +0000 | [diff] [blame] | 1412 | UNSET_FLAG (brouter->flag, OSPF6_ROUTE_REMOVE); |
| 1413 | UNSET_FLAG (brouter->flag, OSPF6_ROUTE_ADD); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1414 | } |
| 1415 | |
Paul Jakma | cb4b884 | 2006-05-15 10:39:30 +0000 | [diff] [blame] | 1416 | if (CHECK_FLAG (brouter->flag, OSPF6_ROUTE_REMOVE)) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1417 | { |
Paul Jakma | cb4b884 | 2006-05-15 10:39:30 +0000 | [diff] [blame] | 1418 | if (IS_OSPF6_DEBUG_BROUTER || |
| 1419 | IS_OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_ID (brouter_id) || |
| 1420 | IS_OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_ID (oa->area_id)) |
| 1421 | zlog_info ("brouter %s disappears via area %s", |
| 1422 | brouter_name, oa->name); |
| 1423 | ospf6_route_remove (brouter, oa->ospf6->brouter_table); |
| 1424 | } |
| 1425 | else if (CHECK_FLAG (brouter->flag, OSPF6_ROUTE_ADD) || |
| 1426 | CHECK_FLAG (brouter->flag, OSPF6_ROUTE_CHANGE)) |
| 1427 | { |
| 1428 | if (IS_OSPF6_DEBUG_BROUTER || |
| 1429 | IS_OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_ID (brouter_id) || |
| 1430 | IS_OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_ID (oa->area_id)) |
| 1431 | zlog_info ("brouter %s appears via area %s", |
| 1432 | brouter_name, oa->name); |
Paul Jakma | cf1ce25 | 2006-05-15 10:46:07 +0000 | [diff] [blame] | 1433 | |
Paul Jakma | cb4b884 | 2006-05-15 10:39:30 +0000 | [diff] [blame] | 1434 | /* newly added */ |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1435 | if (hook_add) |
Paul Jakma | cb4b884 | 2006-05-15 10:39:30 +0000 | [diff] [blame] | 1436 | (*hook_add) (brouter); |
| 1437 | } |
| 1438 | else |
| 1439 | { |
| 1440 | if (IS_OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_ID (brouter_id) || |
| 1441 | IS_OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_ID (oa->area_id)) |
| 1442 | zlog_info ("brouter %s still exists via area %s", |
| 1443 | brouter_name, oa->name); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1444 | } |
| 1445 | |
Paul Jakma | cb4b884 | 2006-05-15 10:39:30 +0000 | [diff] [blame] | 1446 | brouter->flag = 0; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1447 | } |
| 1448 | |
Paul Jakma | cb4b884 | 2006-05-15 10:39:30 +0000 | [diff] [blame] | 1449 | if (IS_OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_ID (oa->area_id)) |
| 1450 | zlog_info ("border-router calculation for area %s: done", oa->name); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1451 | } |
| 1452 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 1453 | struct ospf6_lsa_handler router_handler = |
| 1454 | { |
| 1455 | OSPF6_LSTYPE_ROUTER, |
| 1456 | "Router", |
| 1457 | ospf6_router_lsa_show |
| 1458 | }; |
| 1459 | |
| 1460 | struct ospf6_lsa_handler network_handler = |
| 1461 | { |
| 1462 | OSPF6_LSTYPE_NETWORK, |
| 1463 | "Network", |
| 1464 | ospf6_network_lsa_show |
| 1465 | }; |
| 1466 | |
| 1467 | struct ospf6_lsa_handler link_handler = |
| 1468 | { |
| 1469 | OSPF6_LSTYPE_LINK, |
| 1470 | "Link", |
| 1471 | ospf6_link_lsa_show |
| 1472 | }; |
| 1473 | |
| 1474 | struct ospf6_lsa_handler intra_prefix_handler = |
| 1475 | { |
| 1476 | OSPF6_LSTYPE_INTRA_PREFIX, |
| 1477 | "Intra-Prefix", |
| 1478 | ospf6_intra_prefix_lsa_show |
| 1479 | }; |
| 1480 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1481 | void |
Paul Jakma | cb4b884 | 2006-05-15 10:39:30 +0000 | [diff] [blame] | 1482 | ospf6_intra_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1483 | { |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 1484 | ospf6_install_lsa_handler (&router_handler); |
| 1485 | ospf6_install_lsa_handler (&network_handler); |
| 1486 | ospf6_install_lsa_handler (&link_handler); |
| 1487 | ospf6_install_lsa_handler (&intra_prefix_handler); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1488 | } |
| 1489 | |
Paul Jakma | cb4b884 | 2006-05-15 10:39:30 +0000 | [diff] [blame] | 1490 | DEFUN (debug_ospf6_brouter, |
| 1491 | debug_ospf6_brouter_cmd, |
| 1492 | "debug ospf6 border-routers", |
| 1493 | DEBUG_STR |
| 1494 | OSPF6_STR |
| 1495 | "Debug border router\n" |
| 1496 | ) |
| 1497 | { |
| 1498 | OSPF6_DEBUG_BROUTER_ON (); |
| 1499 | return CMD_SUCCESS; |
| 1500 | } |
| 1501 | |
| 1502 | DEFUN (no_debug_ospf6_brouter, |
| 1503 | no_debug_ospf6_brouter_cmd, |
| 1504 | "no debug ospf6 border-routers", |
| 1505 | NO_STR |
| 1506 | DEBUG_STR |
| 1507 | OSPF6_STR |
| 1508 | "Debug border router\n" |
| 1509 | ) |
| 1510 | { |
| 1511 | OSPF6_DEBUG_BROUTER_OFF (); |
| 1512 | return CMD_SUCCESS; |
| 1513 | } |
| 1514 | |
| 1515 | DEFUN (debug_ospf6_brouter_router, |
| 1516 | debug_ospf6_brouter_router_cmd, |
| 1517 | "debug ospf6 border-routers router-id A.B.C.D", |
| 1518 | DEBUG_STR |
| 1519 | OSPF6_STR |
| 1520 | "Debug border router\n" |
| 1521 | "Debug specific border router\n" |
| 1522 | "Specify border-router's router-id\n" |
| 1523 | ) |
| 1524 | { |
| 1525 | u_int32_t router_id; |
| 1526 | inet_pton (AF_INET, argv[0], &router_id); |
| 1527 | OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_ON (router_id); |
| 1528 | return CMD_SUCCESS; |
| 1529 | } |
| 1530 | |
| 1531 | DEFUN (no_debug_ospf6_brouter_router, |
| 1532 | no_debug_ospf6_brouter_router_cmd, |
| 1533 | "no debug ospf6 border-routers router-id", |
| 1534 | NO_STR |
| 1535 | DEBUG_STR |
| 1536 | OSPF6_STR |
| 1537 | "Debug border router\n" |
| 1538 | "Debug specific border router\n" |
| 1539 | ) |
| 1540 | { |
| 1541 | OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_OFF (); |
| 1542 | return CMD_SUCCESS; |
| 1543 | } |
| 1544 | |
| 1545 | DEFUN (debug_ospf6_brouter_area, |
| 1546 | debug_ospf6_brouter_area_cmd, |
| 1547 | "debug ospf6 border-routers area-id A.B.C.D", |
| 1548 | DEBUG_STR |
| 1549 | OSPF6_STR |
| 1550 | "Debug border router\n" |
| 1551 | "Debug border routers in specific Area\n" |
| 1552 | "Specify Area-ID\n" |
| 1553 | ) |
| 1554 | { |
| 1555 | u_int32_t area_id; |
| 1556 | inet_pton (AF_INET, argv[0], &area_id); |
| 1557 | OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_ON (area_id); |
| 1558 | return CMD_SUCCESS; |
| 1559 | } |
| 1560 | |
| 1561 | DEFUN (no_debug_ospf6_brouter_area, |
| 1562 | no_debug_ospf6_brouter_area_cmd, |
| 1563 | "no debug ospf6 border-routers area-id", |
| 1564 | NO_STR |
| 1565 | DEBUG_STR |
| 1566 | OSPF6_STR |
| 1567 | "Debug border router\n" |
| 1568 | "Debug border routers in specific Area\n" |
| 1569 | ) |
| 1570 | { |
| 1571 | OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_OFF (); |
| 1572 | return CMD_SUCCESS; |
| 1573 | } |
| 1574 | |
| 1575 | int |
| 1576 | config_write_ospf6_debug_brouter (struct vty *vty) |
| 1577 | { |
| 1578 | char buf[16]; |
| 1579 | if (IS_OSPF6_DEBUG_BROUTER) |
| 1580 | vty_out (vty, "debug ospf6 border-routers%s", VNL); |
| 1581 | if (IS_OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER) |
| 1582 | { |
| 1583 | inet_ntop (AF_INET, &conf_debug_ospf6_brouter_specific_router_id, |
| 1584 | buf, sizeof (buf)); |
| 1585 | vty_out (vty, "debug ospf6 border-routers router-id %s%s", buf, VNL); |
| 1586 | } |
| 1587 | if (IS_OSPF6_DEBUG_BROUTER_SPECIFIC_AREA) |
| 1588 | { |
| 1589 | inet_ntop (AF_INET, &conf_debug_ospf6_brouter_specific_area_id, |
| 1590 | buf, sizeof (buf)); |
| 1591 | vty_out (vty, "debug ospf6 border-routers area-id %s%s", buf, VNL); |
| 1592 | } |
| 1593 | return 0; |
| 1594 | } |
| 1595 | |
| 1596 | void |
| 1597 | install_element_ospf6_debug_brouter (void) |
| 1598 | { |
| 1599 | install_element (ENABLE_NODE, &debug_ospf6_brouter_cmd); |
| 1600 | install_element (ENABLE_NODE, &debug_ospf6_brouter_router_cmd); |
| 1601 | install_element (ENABLE_NODE, &debug_ospf6_brouter_area_cmd); |
| 1602 | install_element (ENABLE_NODE, &no_debug_ospf6_brouter_cmd); |
| 1603 | install_element (ENABLE_NODE, &no_debug_ospf6_brouter_router_cmd); |
| 1604 | install_element (ENABLE_NODE, &no_debug_ospf6_brouter_area_cmd); |
| 1605 | install_element (CONFIG_NODE, &debug_ospf6_brouter_cmd); |
| 1606 | install_element (CONFIG_NODE, &debug_ospf6_brouter_router_cmd); |
| 1607 | install_element (CONFIG_NODE, &debug_ospf6_brouter_area_cmd); |
| 1608 | install_element (CONFIG_NODE, &no_debug_ospf6_brouter_cmd); |
| 1609 | install_element (CONFIG_NODE, &no_debug_ospf6_brouter_router_cmd); |
| 1610 | install_element (CONFIG_NODE, &no_debug_ospf6_brouter_area_cmd); |
| 1611 | } |
| 1612 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1613 | |