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> |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 23 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 24 | #include "memory.h" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 25 | #include "if.h" |
| 26 | #include "log.h" |
| 27 | #include "command.h" |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 28 | #include "thread.h" |
| 29 | #include "prefix.h" |
| 30 | #include "plist.h" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 31 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 32 | #include "ospf6_lsa.h" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 33 | #include "ospf6_lsdb.h" |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 34 | #include "ospf6_network.h" |
| 35 | #include "ospf6_message.h" |
| 36 | #include "ospf6_route.h" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 37 | #include "ospf6_top.h" |
| 38 | #include "ospf6_area.h" |
| 39 | #include "ospf6_interface.h" |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 40 | #include "ospf6_neighbor.h" |
| 41 | #include "ospf6_intra.h" |
| 42 | #include "ospf6_spf.h" |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame^] | 43 | #include "ospf6d.h" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 44 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 45 | unsigned char conf_debug_ospf6_interface = 0; |
| 46 | |
| 47 | char *ospf6_interface_state_str[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 48 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 49 | "None", |
| 50 | "Down", |
| 51 | "Loopback", |
| 52 | "Waiting", |
| 53 | "PointToPoint", |
| 54 | "DROther", |
| 55 | "BDR", |
| 56 | "DR", |
| 57 | NULL |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 58 | }; |
| 59 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 60 | struct ospf6_interface * |
| 61 | ospf6_interface_lookup_by_ifindex (int ifindex) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 62 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 63 | struct ospf6_interface *oi; |
| 64 | struct interface *ifp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 65 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 66 | ifp = if_lookup_by_index (ifindex); |
| 67 | if (ifp == NULL) |
| 68 | return (struct ospf6_interface *) NULL; |
| 69 | |
| 70 | oi = (struct ospf6_interface *) ifp->info; |
| 71 | return oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 72 | } |
| 73 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 74 | struct ospf6_interface * |
| 75 | ospf6_interface_lookup_by_name (char *ifname) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 76 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 77 | struct ospf6_interface *oi; |
| 78 | struct interface *ifp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 79 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 80 | ifp = if_lookup_by_name (ifname); |
| 81 | if (ifp == NULL) |
| 82 | return (struct ospf6_interface *) NULL; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 83 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 84 | oi = (struct ospf6_interface *) ifp->info; |
| 85 | return oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 86 | } |
| 87 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 88 | /* schedule routing table recalculation */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 89 | void |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 90 | ospf6_interface_lsdb_hook (struct ospf6_lsa *lsa) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 91 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 92 | struct ospf6_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 93 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 94 | oi = (struct ospf6_interface *) lsa->scope; |
| 95 | switch (ntohs (lsa->header->type)) |
| 96 | { |
| 97 | case OSPF6_LSTYPE_LINK: |
| 98 | if (oi->state == OSPF6_INTERFACE_DR) |
| 99 | OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi); |
| 100 | ospf6_spf_schedule (oi->area); |
| 101 | break; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 102 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 103 | default: |
| 104 | if (IS_OSPF6_DEBUG_LSA (RECV)) |
| 105 | zlog_info ("Unknown LSA in Interface %s's lsdb", |
| 106 | oi->interface->name); |
| 107 | break; |
| 108 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 109 | } |
| 110 | |
| 111 | /* Create new ospf6 interface structure */ |
| 112 | struct ospf6_interface * |
| 113 | ospf6_interface_create (struct interface *ifp) |
| 114 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 115 | struct ospf6_interface *oi; |
hasso | 3b4cd3a | 2004-05-18 19:28:32 +0000 | [diff] [blame] | 116 | int iobuflen; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 117 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 118 | oi = (struct ospf6_interface *) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 119 | XMALLOC (MTYPE_OSPF6_IF, sizeof (struct ospf6_interface)); |
| 120 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 121 | if (oi) |
| 122 | memset (oi, 0, sizeof (struct ospf6_interface)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 123 | else |
| 124 | { |
| 125 | zlog_err ("Can't malloc ospf6_interface for ifindex %d", ifp->ifindex); |
| 126 | return (struct ospf6_interface *) NULL; |
| 127 | } |
| 128 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 129 | oi->area = (struct ospf6_area *) NULL; |
| 130 | oi->neighbor_list = list_new (); |
| 131 | oi->neighbor_list->cmp = ospf6_neighbor_cmp; |
| 132 | oi->linklocal_addr = (struct in6_addr *) NULL; |
| 133 | oi->instance_id = 0; |
| 134 | oi->transdelay = 1; |
| 135 | oi->priority = 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 136 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 137 | oi->hello_interval = 10; |
| 138 | oi->dead_interval = 40; |
| 139 | oi->rxmt_interval = 5; |
| 140 | oi->cost = 1; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 141 | oi->state = OSPF6_INTERFACE_DOWN; |
| 142 | oi->flag = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 143 | |
hasso | b596c71 | 2004-07-09 18:33:43 +0000 | [diff] [blame] | 144 | /* Try to adjust I/O buffer size with IfMtu */ |
hasso | 1203e1c | 2004-07-23 21:34:27 +0000 | [diff] [blame] | 145 | oi->ifmtu = ifp->mtu6; |
| 146 | iobuflen = ospf6_iobuf_size (ifp->mtu6); |
hasso | b596c71 | 2004-07-09 18:33:43 +0000 | [diff] [blame] | 147 | if (oi->ifmtu > iobuflen) |
hasso | 3b4cd3a | 2004-05-18 19:28:32 +0000 | [diff] [blame] | 148 | { |
| 149 | zlog_info ("Interface %s: IfMtu is adjusted to I/O buffer size: %d.", |
| 150 | ifp->name, iobuflen); |
| 151 | oi->ifmtu = iobuflen; |
| 152 | } |
hasso | 3b4cd3a | 2004-05-18 19:28:32 +0000 | [diff] [blame] | 153 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 154 | oi->lsupdate_list = ospf6_lsdb_create (); |
| 155 | oi->lsack_list = ospf6_lsdb_create (); |
| 156 | oi->lsdb = ospf6_lsdb_create (); |
| 157 | oi->lsdb->hook_add = ospf6_interface_lsdb_hook; |
| 158 | oi->lsdb->hook_remove = ospf6_interface_lsdb_hook; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 159 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 160 | oi->route_connected = ospf6_route_table_create (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 161 | |
| 162 | /* link both */ |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 163 | oi->interface = ifp; |
| 164 | ifp->info = oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 165 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 166 | return oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 167 | } |
| 168 | |
| 169 | void |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 170 | ospf6_interface_delete (struct ospf6_interface *oi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 171 | { |
| 172 | listnode n; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 173 | struct ospf6_neighbor *on; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 174 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 175 | for (n = listhead (oi->neighbor_list); n; nextnode (n)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 176 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 177 | on = (struct ospf6_neighbor *) getdata (n); |
| 178 | ospf6_neighbor_delete (on); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 179 | } |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 180 | list_delete (oi->neighbor_list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 181 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 182 | THREAD_OFF (oi->thread_send_hello); |
| 183 | THREAD_OFF (oi->thread_send_lsupdate); |
| 184 | THREAD_OFF (oi->thread_send_lsack); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 185 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 186 | ospf6_lsdb_remove_all (oi->lsdb); |
| 187 | ospf6_lsdb_remove_all (oi->lsupdate_list); |
| 188 | ospf6_lsdb_remove_all (oi->lsack_list); |
| 189 | |
| 190 | ospf6_lsdb_delete (oi->lsdb); |
| 191 | ospf6_lsdb_delete (oi->lsupdate_list); |
| 192 | ospf6_lsdb_delete (oi->lsack_list); |
| 193 | |
| 194 | ospf6_route_table_delete (oi->route_connected); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 195 | |
| 196 | /* cut link */ |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 197 | oi->interface->info = NULL; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 198 | |
| 199 | /* plist_name */ |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 200 | if (oi->plist_name) |
| 201 | XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 202 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 203 | XFREE (MTYPE_OSPF6_IF, oi); |
| 204 | } |
| 205 | |
| 206 | void |
| 207 | ospf6_interface_enable (struct ospf6_interface *oi) |
| 208 | { |
| 209 | UNSET_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE); |
| 210 | |
| 211 | oi->thread_send_hello = |
| 212 | thread_add_event (master, ospf6_hello_send, oi, 0); |
| 213 | } |
| 214 | |
| 215 | void |
| 216 | ospf6_interface_disable (struct ospf6_interface *oi) |
| 217 | { |
| 218 | listnode i; |
| 219 | struct ospf6_neighbor *on; |
| 220 | |
| 221 | SET_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE); |
| 222 | |
| 223 | for (i = listhead (oi->neighbor_list); i; nextnode (i)) |
| 224 | { |
| 225 | on = (struct ospf6_neighbor *) getdata (i); |
| 226 | ospf6_neighbor_delete (on); |
| 227 | } |
| 228 | list_delete_all_node (oi->neighbor_list); |
| 229 | |
| 230 | ospf6_lsdb_remove_all (oi->lsdb); |
| 231 | ospf6_lsdb_remove_all (oi->lsupdate_list); |
| 232 | ospf6_lsdb_remove_all (oi->lsack_list); |
| 233 | |
| 234 | THREAD_OFF (oi->thread_send_hello); |
| 235 | THREAD_OFF (oi->thread_send_lsupdate); |
| 236 | THREAD_OFF (oi->thread_send_lsack); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 237 | } |
| 238 | |
| 239 | static struct in6_addr * |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 240 | ospf6_interface_get_linklocal_address (struct interface *ifp) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 241 | { |
| 242 | listnode n; |
| 243 | struct connected *c; |
| 244 | struct in6_addr *l = (struct in6_addr *) NULL; |
| 245 | |
| 246 | /* for each connected address */ |
| 247 | for (n = listhead (ifp->connected); n; nextnode (n)) |
| 248 | { |
| 249 | c = (struct connected *) getdata (n); |
| 250 | |
| 251 | /* if family not AF_INET6, ignore */ |
| 252 | if (c->address->family != AF_INET6) |
| 253 | continue; |
| 254 | |
| 255 | /* linklocal scope check */ |
| 256 | if (IN6_IS_ADDR_LINKLOCAL (&c->address->u.prefix6)) |
| 257 | l = &c->address->u.prefix6; |
| 258 | } |
| 259 | return l; |
| 260 | } |
| 261 | |
| 262 | void |
| 263 | ospf6_interface_if_add (struct interface *ifp) |
| 264 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 265 | struct ospf6_interface *oi; |
hasso | 3b4cd3a | 2004-05-18 19:28:32 +0000 | [diff] [blame] | 266 | int iobuflen; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 267 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 268 | oi = (struct ospf6_interface *) ifp->info; |
| 269 | if (oi == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 270 | return; |
| 271 | |
hasso | b596c71 | 2004-07-09 18:33:43 +0000 | [diff] [blame] | 272 | /* Try to adjust I/O buffer size with IfMtu */ |
| 273 | if (oi->ifmtu == 0) |
hasso | 1203e1c | 2004-07-23 21:34:27 +0000 | [diff] [blame] | 274 | oi->ifmtu = ifp->mtu6; |
| 275 | iobuflen = ospf6_iobuf_size (ifp->mtu6); |
hasso | b596c71 | 2004-07-09 18:33:43 +0000 | [diff] [blame] | 276 | if (oi->ifmtu > iobuflen) |
hasso | 3b4cd3a | 2004-05-18 19:28:32 +0000 | [diff] [blame] | 277 | { |
| 278 | zlog_info ("Interface %s: IfMtu is adjusted to I/O buffer size: %d.", |
| 279 | ifp->name, iobuflen); |
| 280 | oi->ifmtu = iobuflen; |
| 281 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 282 | |
| 283 | /* interface start */ |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 284 | if (oi->area) |
| 285 | thread_add_event (master, interface_up, oi, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 286 | } |
| 287 | |
| 288 | void |
| 289 | ospf6_interface_if_del (struct interface *ifp) |
| 290 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 291 | struct ospf6_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 292 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 293 | oi = (struct ospf6_interface *) ifp->info; |
| 294 | if (oi == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 295 | return; |
| 296 | |
| 297 | /* interface stop */ |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 298 | if (oi->area) |
| 299 | thread_execute (master, interface_down, oi, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 300 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 301 | listnode_delete (oi->area->if_list, oi); |
| 302 | oi->area = (struct ospf6_area *) NULL; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 303 | |
| 304 | /* cut link */ |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 305 | oi->interface = NULL; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 306 | ifp->info = NULL; |
| 307 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 308 | ospf6_interface_delete (oi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 309 | } |
| 310 | |
| 311 | void |
| 312 | ospf6_interface_state_update (struct interface *ifp) |
| 313 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 314 | struct ospf6_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 315 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 316 | oi = (struct ospf6_interface *) ifp->info; |
| 317 | if (oi == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 318 | return; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 319 | if (oi->area == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 320 | return; |
| 321 | |
| 322 | if (if_is_up (ifp)) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 323 | thread_add_event (master, interface_up, oi, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 324 | else |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 325 | thread_add_event (master, interface_down, oi, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 326 | |
| 327 | return; |
| 328 | } |
| 329 | |
| 330 | void |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 331 | ospf6_interface_connected_route_update (struct interface *ifp) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 332 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 333 | struct ospf6_interface *oi; |
| 334 | struct ospf6_route *route; |
| 335 | struct connected *c; |
| 336 | listnode i; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 337 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 338 | oi = (struct ospf6_interface *) ifp->info; |
| 339 | if (oi == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 340 | return; |
| 341 | |
| 342 | /* reset linklocal pointer */ |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 343 | oi->linklocal_addr = ospf6_interface_get_linklocal_address (ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 344 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 345 | /* if area is null, do not make connected-route list */ |
| 346 | if (oi->area == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 347 | return; |
| 348 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 349 | /* update "route to advertise" interface route table */ |
| 350 | ospf6_route_remove_all (oi->route_connected); |
| 351 | for (i = listhead (oi->interface->connected); i; nextnode (i)) |
| 352 | { |
| 353 | c = (struct connected *) getdata (i); |
| 354 | |
| 355 | if (c->address->family != AF_INET6) |
| 356 | continue; |
| 357 | |
| 358 | CONTINUE_IF_ADDRESS_LINKLOCAL (c->address); |
| 359 | CONTINUE_IF_ADDRESS_UNSPECIFIED (c->address); |
| 360 | CONTINUE_IF_ADDRESS_LOOPBACK (c->address); |
| 361 | CONTINUE_IF_ADDRESS_V4COMPAT (c->address); |
| 362 | CONTINUE_IF_ADDRESS_V4MAPPED (c->address); |
| 363 | |
| 364 | /* apply filter */ |
| 365 | if (oi->plist_name) |
| 366 | { |
| 367 | struct prefix_list *plist; |
| 368 | enum prefix_list_type ret; |
| 369 | char buf[128]; |
| 370 | |
| 371 | prefix2str (c->address, buf, sizeof (buf)); |
| 372 | plist = prefix_list_lookup (AFI_IP6, oi->plist_name); |
| 373 | ret = prefix_list_apply (plist, (void *) c->address); |
| 374 | if (ret == PREFIX_DENY) |
| 375 | { |
| 376 | zlog_info ("%s on %s filtered by prefix-list %s ", |
| 377 | buf, oi->interface->name, oi->plist_name); |
| 378 | continue; |
| 379 | } |
| 380 | } |
| 381 | |
| 382 | route = ospf6_route_create (); |
| 383 | memcpy (&route->prefix, c->address, sizeof (struct prefix)); |
| 384 | apply_mask (&route->prefix); |
| 385 | route->type = OSPF6_DEST_TYPE_NETWORK; |
| 386 | route->path.area_id = oi->area->area_id; |
| 387 | route->path.type = OSPF6_PATH_TYPE_INTRA; |
| 388 | route->path.cost = oi->cost; |
| 389 | route->nexthop[0].ifindex = oi->interface->ifindex; |
| 390 | inet_pton (AF_INET6, "::1", &route->nexthop[0].address); |
| 391 | ospf6_route_add (route, oi->route_connected); |
| 392 | } |
| 393 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 394 | /* create new Link-LSA */ |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 395 | OSPF6_LINK_LSA_SCHEDULE (oi); |
| 396 | OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi); |
| 397 | OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 398 | } |
| 399 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 400 | static void |
| 401 | ospf6_interface_state_change (u_char next_state, struct ospf6_interface *oi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 402 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 403 | u_char prev_state; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 404 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 405 | prev_state = oi->state; |
| 406 | oi->state = next_state; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 407 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 408 | if (prev_state == next_state) |
| 409 | return; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 410 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 411 | /* log */ |
| 412 | if (IS_OSPF6_DEBUG_INTERFACE) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 413 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 414 | zlog_info ("Interface state change %s: %s -> %s", oi->interface->name, |
| 415 | ospf6_interface_state_str[prev_state], |
| 416 | ospf6_interface_state_str[next_state]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 417 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 418 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 419 | if ((prev_state == OSPF6_INTERFACE_DR || |
| 420 | prev_state == OSPF6_INTERFACE_BDR) && |
| 421 | (next_state != OSPF6_INTERFACE_DR && |
| 422 | next_state != OSPF6_INTERFACE_BDR)) |
| 423 | ospf6_leave_alldrouters (oi->interface->ifindex); |
| 424 | if ((prev_state != OSPF6_INTERFACE_DR && |
| 425 | prev_state != OSPF6_INTERFACE_BDR) && |
| 426 | (next_state == OSPF6_INTERFACE_DR || |
| 427 | next_state == OSPF6_INTERFACE_BDR)) |
| 428 | ospf6_join_alldrouters (oi->interface->ifindex); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 429 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 430 | OSPF6_ROUTER_LSA_SCHEDULE (oi->area); |
| 431 | if (prev_state == OSPF6_INTERFACE_DR || next_state == OSPF6_INTERFACE_DR) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 432 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 433 | OSPF6_NETWORK_LSA_SCHEDULE (oi); |
| 434 | OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi); |
| 435 | OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 436 | } |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 437 | } |
| 438 | |
| 439 | |
| 440 | /* DR Election, RFC2328 section 9.4 */ |
| 441 | |
| 442 | #define IS_ELIGIBLE(n) \ |
| 443 | ((n)->state >= OSPF6_NEIGHBOR_TWOWAY && (n)->priority != 0) |
| 444 | |
| 445 | static struct ospf6_neighbor * |
| 446 | better_bdrouter (struct ospf6_neighbor *a, struct ospf6_neighbor *b) |
| 447 | { |
| 448 | if ((a == NULL || ! IS_ELIGIBLE (a) || a->drouter == a->router_id) && |
| 449 | (b == NULL || ! IS_ELIGIBLE (b) || b->drouter == b->router_id)) |
| 450 | return NULL; |
| 451 | else if (a == NULL || ! IS_ELIGIBLE (a) || a->drouter == a->router_id) |
| 452 | return b; |
| 453 | else if (b == NULL || ! IS_ELIGIBLE (b) || b->drouter == b->router_id) |
| 454 | return a; |
| 455 | |
| 456 | if (a->bdrouter == a->router_id && b->bdrouter != b->router_id) |
| 457 | return a; |
| 458 | if (a->bdrouter != a->router_id && b->bdrouter == b->router_id) |
| 459 | return b; |
| 460 | |
| 461 | if (a->priority > b->priority) |
| 462 | return a; |
| 463 | if (a->priority < b->priority) |
| 464 | return b; |
| 465 | |
| 466 | if (ntohl (a->router_id) > ntohl (b->router_id)) |
| 467 | return a; |
| 468 | if (ntohl (a->router_id) < ntohl (b->router_id)) |
| 469 | return b; |
| 470 | |
| 471 | zlog_warn ("Router-ID duplicate ?"); |
| 472 | return a; |
| 473 | } |
| 474 | |
| 475 | static struct ospf6_neighbor * |
| 476 | better_drouter (struct ospf6_neighbor *a, struct ospf6_neighbor *b) |
| 477 | { |
| 478 | if ((a == NULL || ! IS_ELIGIBLE (a) || a->drouter != a->router_id) && |
| 479 | (b == NULL || ! IS_ELIGIBLE (b) || b->drouter != b->router_id)) |
| 480 | return NULL; |
| 481 | else if (a == NULL || ! IS_ELIGIBLE (a) || a->drouter != a->router_id) |
| 482 | return b; |
| 483 | else if (b == NULL || ! IS_ELIGIBLE (b) || b->drouter != b->router_id) |
| 484 | return a; |
| 485 | |
| 486 | if (a->drouter == a->router_id && b->drouter != b->router_id) |
| 487 | return a; |
| 488 | if (a->drouter != a->router_id && b->drouter == b->router_id) |
| 489 | return b; |
| 490 | |
| 491 | if (a->priority > b->priority) |
| 492 | return a; |
| 493 | if (a->priority < b->priority) |
| 494 | return b; |
| 495 | |
| 496 | if (ntohl (a->router_id) > ntohl (b->router_id)) |
| 497 | return a; |
| 498 | if (ntohl (a->router_id) < ntohl (b->router_id)) |
| 499 | return b; |
| 500 | |
| 501 | zlog_warn ("Router-ID duplicate ?"); |
| 502 | return a; |
| 503 | } |
| 504 | |
| 505 | static u_char |
| 506 | dr_election (struct ospf6_interface *oi) |
| 507 | { |
| 508 | listnode i; |
| 509 | struct ospf6_neighbor *on, *drouter, *bdrouter, myself; |
| 510 | struct ospf6_neighbor *best_drouter, *best_bdrouter; |
| 511 | u_char next_state = 0; |
| 512 | |
| 513 | drouter = bdrouter = NULL; |
| 514 | best_drouter = best_bdrouter = NULL; |
| 515 | |
| 516 | /* pseudo neighbor myself, including noting current DR/BDR (1) */ |
| 517 | memset (&myself, 0, sizeof (myself)); |
| 518 | inet_ntop (AF_INET, &oi->area->ospf6->router_id, myself.name, |
| 519 | sizeof (myself.name)); |
| 520 | myself.state = OSPF6_NEIGHBOR_TWOWAY; |
| 521 | myself.drouter = oi->drouter; |
| 522 | myself.bdrouter = oi->bdrouter; |
| 523 | myself.priority = oi->priority; |
| 524 | myself.router_id = oi->area->ospf6->router_id; |
| 525 | |
| 526 | /* Electing BDR (2) */ |
| 527 | for (i = listhead (oi->neighbor_list); i; nextnode (i)) |
| 528 | { |
| 529 | on = (struct ospf6_neighbor *) getdata (i); |
| 530 | bdrouter = better_bdrouter (bdrouter, on); |
| 531 | } |
| 532 | best_bdrouter = bdrouter; |
| 533 | bdrouter = better_bdrouter (best_bdrouter, &myself); |
| 534 | |
| 535 | /* Electing DR (3) */ |
| 536 | for (i = listhead (oi->neighbor_list); i; nextnode (i)) |
| 537 | { |
| 538 | on = (struct ospf6_neighbor *) getdata (i); |
| 539 | drouter = better_drouter (drouter, on); |
| 540 | } |
| 541 | best_drouter = drouter; |
| 542 | drouter = better_drouter (best_drouter, &myself); |
| 543 | if (drouter == NULL) |
| 544 | drouter = bdrouter; |
| 545 | |
| 546 | /* the router itself is newly/no longer DR/BDR (4) */ |
| 547 | if ((drouter == &myself && myself.drouter != myself.router_id) || |
| 548 | (drouter != &myself && myself.drouter == myself.router_id) || |
| 549 | (bdrouter == &myself && myself.bdrouter != myself.router_id) || |
| 550 | (bdrouter != &myself && myself.bdrouter == myself.router_id)) |
| 551 | { |
| 552 | myself.drouter = (drouter ? drouter->router_id : htonl (0)); |
| 553 | myself.bdrouter = (bdrouter ? bdrouter->router_id : htonl (0)); |
| 554 | |
| 555 | /* compatible to Electing BDR (2) */ |
| 556 | bdrouter = better_bdrouter (best_bdrouter, &myself); |
| 557 | |
| 558 | /* compatible to Electing DR (3) */ |
| 559 | drouter = better_drouter (best_drouter, &myself); |
| 560 | if (drouter == NULL) |
| 561 | drouter = bdrouter; |
| 562 | } |
| 563 | |
| 564 | /* Set interface state accordingly (5) */ |
| 565 | if (drouter && drouter == &myself) |
| 566 | next_state = OSPF6_INTERFACE_DR; |
| 567 | else if (bdrouter && bdrouter == &myself) |
| 568 | next_state = OSPF6_INTERFACE_BDR; |
| 569 | else |
| 570 | next_state = OSPF6_INTERFACE_DROTHER; |
| 571 | |
| 572 | /* If NBMA, schedule Start for each neighbor having priority of 0 (6) */ |
| 573 | /* XXX */ |
| 574 | |
| 575 | /* If DR or BDR change, invoke AdjOK? for each neighbor (7) */ |
| 576 | /* RFC 2328 section 12.4. Originating LSAs (3) will be handled |
| 577 | accordingly after AdjOK */ |
| 578 | if (oi->drouter != (drouter ? drouter->router_id : htonl (0)) || |
| 579 | oi->bdrouter != (bdrouter ? bdrouter->router_id : htonl (0))) |
| 580 | { |
| 581 | if (IS_OSPF6_DEBUG_INTERFACE) |
| 582 | zlog_info ("DR Election on %s: DR: %s BDR: %s", oi->interface->name, |
| 583 | (drouter ? drouter->name : "0.0.0.0"), |
| 584 | (bdrouter ? bdrouter->name : "0.0.0.0")); |
| 585 | |
| 586 | for (i = listhead (oi->neighbor_list); i; nextnode (i)) |
| 587 | { |
| 588 | on = (struct ospf6_neighbor *) getdata (i); |
| 589 | if (on->state < OSPF6_NEIGHBOR_TWOWAY) |
| 590 | continue; |
| 591 | /* Schedule AdjOK. */ |
| 592 | thread_add_event (master, adj_ok, on, 0); |
| 593 | } |
| 594 | } |
| 595 | |
| 596 | oi->drouter = (drouter ? drouter->router_id : htonl (0)); |
| 597 | oi->bdrouter = (bdrouter ? bdrouter->router_id : htonl (0)); |
| 598 | return next_state; |
| 599 | } |
| 600 | |
| 601 | |
| 602 | /* Interface State Machine */ |
| 603 | int |
| 604 | interface_up (struct thread *thread) |
| 605 | { |
| 606 | struct ospf6_interface *oi; |
| 607 | |
| 608 | oi = (struct ospf6_interface *) THREAD_ARG (thread); |
| 609 | assert (oi && oi->interface); |
| 610 | |
| 611 | if (IS_OSPF6_DEBUG_INTERFACE) |
| 612 | zlog_info ("Interface Event %s: [InterfaceUp]", |
| 613 | oi->interface->name); |
| 614 | |
| 615 | /* check physical interface is up */ |
| 616 | if (! if_is_up (oi->interface)) |
| 617 | { |
| 618 | if (IS_OSPF6_DEBUG_INTERFACE) |
| 619 | zlog_info ("Interface %s is down, can't execute [InterfaceUp]", |
| 620 | oi->interface->name); |
| 621 | return 0; |
| 622 | } |
| 623 | |
| 624 | /* if already enabled, do nothing */ |
| 625 | if (oi->state > OSPF6_INTERFACE_DOWN) |
| 626 | { |
| 627 | if (IS_OSPF6_DEBUG_INTERFACE) |
| 628 | zlog_info ("Interface %s already enabled", |
| 629 | oi->interface->name); |
| 630 | return 0; |
| 631 | } |
| 632 | |
| 633 | /* Join AllSPFRouters */ |
| 634 | ospf6_join_allspfrouters (oi->interface->ifindex); |
| 635 | |
| 636 | /* Update interface route */ |
| 637 | ospf6_interface_connected_route_update (oi->interface); |
| 638 | |
| 639 | /* Schedule Hello */ |
| 640 | if (! CHECK_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE)) |
| 641 | thread_add_event (master, ospf6_hello_send, oi, 0); |
| 642 | |
| 643 | /* decide next interface state */ |
| 644 | if (if_is_pointopoint (oi->interface)) |
| 645 | ospf6_interface_state_change (OSPF6_INTERFACE_POINTTOPOINT, oi); |
| 646 | else if (oi->priority == 0) |
| 647 | ospf6_interface_state_change (OSPF6_INTERFACE_DROTHER, oi); |
| 648 | else |
| 649 | { |
| 650 | ospf6_interface_state_change (OSPF6_INTERFACE_WAITING, oi); |
| 651 | thread_add_timer (master, wait_timer, oi, oi->dead_interval); |
| 652 | } |
| 653 | |
| 654 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 655 | } |
| 656 | |
| 657 | int |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 658 | wait_timer (struct thread *thread) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 659 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 660 | struct ospf6_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 661 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 662 | oi = (struct ospf6_interface *) THREAD_ARG (thread); |
| 663 | assert (oi && oi->interface); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 664 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 665 | if (IS_OSPF6_DEBUG_INTERFACE) |
| 666 | zlog_info ("Interface Event %s: [WaitTimer]", |
| 667 | oi->interface->name); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 668 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 669 | if (oi->state == OSPF6_INTERFACE_WAITING) |
| 670 | ospf6_interface_state_change (dr_election (oi), oi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 671 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 672 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 673 | } |
| 674 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 675 | int |
| 676 | backup_seen (struct thread *thread) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 677 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 678 | struct ospf6_interface *oi; |
| 679 | |
| 680 | oi = (struct ospf6_interface *) THREAD_ARG (thread); |
| 681 | assert (oi && oi->interface); |
| 682 | |
| 683 | if (IS_OSPF6_DEBUG_INTERFACE) |
| 684 | zlog_info ("Interface Event %s: [BackupSeen]", |
| 685 | oi->interface->name); |
| 686 | |
| 687 | if (oi->state == OSPF6_INTERFACE_WAITING) |
| 688 | ospf6_interface_state_change (dr_election (oi), oi); |
| 689 | |
| 690 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 691 | } |
| 692 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 693 | int |
| 694 | neighbor_change (struct thread *thread) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 695 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 696 | struct ospf6_interface *oi; |
| 697 | |
| 698 | oi = (struct ospf6_interface *) THREAD_ARG (thread); |
| 699 | assert (oi && oi->interface); |
| 700 | |
| 701 | if (IS_OSPF6_DEBUG_INTERFACE) |
| 702 | zlog_info ("Interface Event %s: [NeighborChange]", |
| 703 | oi->interface->name); |
| 704 | |
| 705 | if (oi->state == OSPF6_INTERFACE_DROTHER || |
| 706 | oi->state == OSPF6_INTERFACE_BDR || |
| 707 | oi->state == OSPF6_INTERFACE_DR) |
| 708 | ospf6_interface_state_change (dr_election (oi), oi); |
| 709 | |
| 710 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 711 | } |
| 712 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 713 | int |
| 714 | loopind (struct thread *thread) |
| 715 | { |
| 716 | struct ospf6_interface *oi; |
| 717 | |
| 718 | oi = (struct ospf6_interface *) THREAD_ARG (thread); |
| 719 | assert (oi && oi->interface); |
| 720 | |
| 721 | if (IS_OSPF6_DEBUG_INTERFACE) |
| 722 | zlog_info ("Interface Event %s: [LoopInd]", |
| 723 | oi->interface->name); |
| 724 | |
| 725 | /* XXX not yet */ |
| 726 | |
| 727 | return 0; |
| 728 | } |
| 729 | |
| 730 | int |
| 731 | interface_down (struct thread *thread) |
| 732 | { |
| 733 | struct ospf6_interface *oi; |
| 734 | listnode n; |
| 735 | struct ospf6_neighbor *on; |
| 736 | |
| 737 | oi = (struct ospf6_interface *) THREAD_ARG (thread); |
| 738 | assert (oi && oi->interface); |
| 739 | |
| 740 | if (IS_OSPF6_DEBUG_INTERFACE) |
| 741 | zlog_info ("Interface Event %s: [InterfaceDown]", |
| 742 | oi->interface->name); |
| 743 | |
| 744 | /* Leave AllSPFRouters */ |
| 745 | if (oi->state > OSPF6_INTERFACE_DOWN) |
| 746 | ospf6_leave_allspfrouters (oi->interface->ifindex); |
| 747 | |
| 748 | ospf6_interface_state_change (OSPF6_INTERFACE_DOWN, oi); |
| 749 | |
| 750 | for (n = listhead (oi->neighbor_list); n; nextnode (n)) |
| 751 | { |
| 752 | on = (struct ospf6_neighbor *) getdata (n); |
| 753 | ospf6_neighbor_delete (on); |
| 754 | } |
| 755 | list_delete_all_node (oi->neighbor_list); |
| 756 | |
| 757 | return 0; |
| 758 | } |
| 759 | |
| 760 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 761 | /* show specified interface structure */ |
| 762 | int |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 763 | ospf6_interface_show (struct vty *vty, struct interface *ifp) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 764 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 765 | struct ospf6_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 766 | struct connected *c; |
| 767 | struct prefix *p; |
| 768 | listnode i; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 769 | char strbuf[64], drouter[32], bdrouter[32]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 770 | char *updown[3] = {"down", "up", NULL}; |
| 771 | char *type; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 772 | struct timeval res, now; |
| 773 | char duration[32]; |
| 774 | struct ospf6_lsa *lsa; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 775 | |
| 776 | /* check physical interface type */ |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 777 | if (if_is_loopback (ifp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 778 | type = "LOOPBACK"; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 779 | else if (if_is_broadcast (ifp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 780 | type = "BROADCAST"; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 781 | else if (if_is_pointopoint (ifp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 782 | type = "POINTOPOINT"; |
| 783 | else |
| 784 | type = "UNKNOWN"; |
| 785 | |
| 786 | vty_out (vty, "%s is %s, type %s%s", |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 787 | ifp->name, updown[if_is_up (ifp)], type, |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame^] | 788 | VNL); |
| 789 | vty_out (vty, " Interface ID: %d%s", ifp->ifindex, VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 790 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 791 | if (ifp->info == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 792 | { |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame^] | 793 | vty_out (vty, " OSPF not enabled on this interface%s", VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 794 | return 0; |
| 795 | } |
| 796 | else |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 797 | oi = (struct ospf6_interface *) ifp->info; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 798 | |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame^] | 799 | vty_out (vty, " Internet Address:%s", VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 800 | for (i = listhead (ifp->connected); i; nextnode (i)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 801 | { |
| 802 | c = (struct connected *)getdata (i); |
| 803 | p = c->address; |
| 804 | prefix2str (p, strbuf, sizeof (strbuf)); |
| 805 | switch (p->family) |
| 806 | { |
| 807 | case AF_INET: |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 808 | vty_out (vty, " inet : %s%s", strbuf, |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame^] | 809 | VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 810 | break; |
| 811 | case AF_INET6: |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 812 | vty_out (vty, " inet6: %s%s", strbuf, |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame^] | 813 | VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 814 | break; |
| 815 | default: |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 816 | vty_out (vty, " ??? : %s%s", strbuf, |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame^] | 817 | VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 818 | break; |
| 819 | } |
| 820 | } |
| 821 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 822 | if (oi->area) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 823 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 824 | vty_out (vty, " Instance ID %d, Interface MTU %d (autodetect: %d)%s", |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame^] | 825 | oi->instance_id, oi->ifmtu, ifp->mtu6, VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 826 | inet_ntop (AF_INET, &oi->area->area_id, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 827 | strbuf, sizeof (strbuf)); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 828 | vty_out (vty, " Area ID %s, Cost %hu%s", strbuf, oi->cost, |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame^] | 829 | VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 830 | } |
| 831 | else |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame^] | 832 | vty_out (vty, " Not Attached to Area%s", VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 833 | |
| 834 | vty_out (vty, " State %s, Transmit Delay %d sec, Priority %d%s", |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 835 | ospf6_interface_state_str[oi->state], |
| 836 | oi->transdelay, oi->priority, |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame^] | 837 | VNL); |
| 838 | vty_out (vty, " Timer intervals configured:%s", VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 839 | vty_out (vty, " Hello %d, Dead %d, Retransmit %d%s", |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 840 | oi->hello_interval, oi->dead_interval, oi->rxmt_interval, |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame^] | 841 | VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 842 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 843 | inet_ntop (AF_INET, &oi->drouter, drouter, sizeof (drouter)); |
| 844 | inet_ntop (AF_INET, &oi->bdrouter, bdrouter, sizeof (bdrouter)); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame^] | 845 | vty_out (vty, " DR: %s BDR: %s%s", drouter, bdrouter, VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 846 | |
| 847 | vty_out (vty, " Number of I/F scoped LSAs is %u%s", |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame^] | 848 | oi->lsdb->count, VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 849 | |
| 850 | gettimeofday (&now, (struct timezone *) NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 851 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 852 | timerclear (&res); |
| 853 | if (oi->thread_send_lsupdate) |
| 854 | timersub (&oi->thread_send_lsupdate->u.sands, &now, &res); |
| 855 | timerstring (&res, duration, sizeof (duration)); |
| 856 | vty_out (vty, " %d Pending LSAs for LSUpdate in Time %s [thread %s]%s", |
| 857 | oi->lsupdate_list->count, duration, |
| 858 | (oi->thread_send_lsupdate ? "on" : "off"), |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame^] | 859 | VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 860 | for (lsa = ospf6_lsdb_head (oi->lsupdate_list); lsa; |
| 861 | lsa = ospf6_lsdb_next (lsa)) |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame^] | 862 | vty_out (vty, " %s%s", lsa->name, VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 863 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 864 | timerclear (&res); |
| 865 | if (oi->thread_send_lsack) |
| 866 | timersub (&oi->thread_send_lsack->u.sands, &now, &res); |
| 867 | timerstring (&res, duration, sizeof (duration)); |
| 868 | vty_out (vty, " %d Pending LSAs for LSAck in Time %s [thread %s]%s", |
| 869 | oi->lsack_list->count, duration, |
| 870 | (oi->thread_send_lsack ? "on" : "off"), |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame^] | 871 | VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 872 | for (lsa = ospf6_lsdb_head (oi->lsack_list); lsa; |
| 873 | lsa = ospf6_lsdb_next (lsa)) |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame^] | 874 | vty_out (vty, " %s%s", lsa->name, VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 875 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 876 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 877 | } |
| 878 | |
| 879 | /* show interface */ |
| 880 | DEFUN (show_ipv6_ospf6_interface, |
| 881 | show_ipv6_ospf6_interface_ifname_cmd, |
| 882 | "show ipv6 ospf6 interface IFNAME", |
| 883 | SHOW_STR |
| 884 | IP6_STR |
| 885 | OSPF6_STR |
| 886 | INTERFACE_STR |
| 887 | IFNAME_STR |
| 888 | ) |
| 889 | { |
| 890 | struct interface *ifp; |
| 891 | listnode i; |
| 892 | |
| 893 | if (argc) |
| 894 | { |
| 895 | ifp = if_lookup_by_name (argv[0]); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 896 | if (ifp == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 897 | { |
| 898 | vty_out (vty, "No such Interface: %s%s", argv[0], |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame^] | 899 | VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 900 | return CMD_WARNING; |
| 901 | } |
| 902 | ospf6_interface_show (vty, ifp); |
| 903 | } |
| 904 | else |
| 905 | { |
| 906 | for (i = listhead (iflist); i; nextnode (i)) |
| 907 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 908 | ifp = (struct interface *) getdata (i); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 909 | ospf6_interface_show (vty, ifp); |
| 910 | } |
| 911 | } |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 912 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 913 | return CMD_SUCCESS; |
| 914 | } |
| 915 | |
| 916 | ALIAS (show_ipv6_ospf6_interface, |
| 917 | show_ipv6_ospf6_interface_cmd, |
| 918 | "show ipv6 ospf6 interface", |
| 919 | SHOW_STR |
| 920 | IP6_STR |
| 921 | OSPF6_STR |
| 922 | INTERFACE_STR |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 923 | ); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 924 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 925 | DEFUN (show_ipv6_ospf6_interface_ifname_prefix, |
| 926 | show_ipv6_ospf6_interface_ifname_prefix_cmd, |
| 927 | "show ipv6 ospf6 interface IFNAME prefix", |
| 928 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 929 | IP6_STR |
| 930 | OSPF6_STR |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 931 | INTERFACE_STR |
| 932 | IFNAME_STR |
| 933 | "Display connected prefixes to advertise\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 934 | ) |
| 935 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 936 | struct interface *ifp; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 937 | struct ospf6_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 938 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 939 | ifp = if_lookup_by_name (argv[0]); |
| 940 | if (ifp == NULL) |
| 941 | { |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame^] | 942 | vty_out (vty, "No such Interface: %s%s", argv[0], VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 943 | return CMD_WARNING; |
| 944 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 945 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 946 | oi = ifp->info; |
| 947 | if (oi == NULL) |
| 948 | { |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame^] | 949 | vty_out (vty, "OSPFv3 is not enabled on %s%s", argv[0], VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 950 | return CMD_WARNING; |
| 951 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 952 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 953 | argc--; |
| 954 | argv++; |
| 955 | ospf6_route_table_show (vty, argc, argv, oi->route_connected); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 956 | |
| 957 | return CMD_SUCCESS; |
| 958 | } |
| 959 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 960 | ALIAS (show_ipv6_ospf6_interface_ifname_prefix, |
| 961 | show_ipv6_ospf6_interface_ifname_prefix_detail_cmd, |
| 962 | "show ipv6 ospf6 interface IFNAME prefix (X:X::X:X|X:X::X:X/M|detail)", |
| 963 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 964 | IP6_STR |
| 965 | OSPF6_STR |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 966 | INTERFACE_STR |
| 967 | IFNAME_STR |
| 968 | "Display connected prefixes to advertise\n" |
| 969 | OSPF6_ROUTE_ADDRESS_STR |
| 970 | OSPF6_ROUTE_PREFIX_STR |
| 971 | "Dispaly details of the prefixes\n" |
| 972 | ); |
| 973 | |
| 974 | ALIAS (show_ipv6_ospf6_interface_ifname_prefix, |
| 975 | show_ipv6_ospf6_interface_ifname_prefix_match_cmd, |
| 976 | "show ipv6 ospf6 interface IFNAME prefix X:X::X:X/M (match|detail)", |
| 977 | SHOW_STR |
| 978 | IP6_STR |
| 979 | OSPF6_STR |
| 980 | INTERFACE_STR |
| 981 | IFNAME_STR |
| 982 | "Display connected prefixes to advertise\n" |
| 983 | OSPF6_ROUTE_PREFIX_STR |
| 984 | OSPF6_ROUTE_MATCH_STR |
| 985 | "Dispaly details of the prefixes\n" |
| 986 | ); |
| 987 | |
| 988 | DEFUN (show_ipv6_ospf6_interface_prefix, |
| 989 | show_ipv6_ospf6_interface_prefix_cmd, |
| 990 | "show ipv6 ospf6 interface prefix", |
| 991 | SHOW_STR |
| 992 | IP6_STR |
| 993 | OSPF6_STR |
| 994 | INTERFACE_STR |
| 995 | "Display connected prefixes to advertise\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 996 | ) |
| 997 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 998 | listnode i; |
| 999 | struct ospf6_interface *oi; |
| 1000 | struct interface *ifp; |
| 1001 | |
| 1002 | for (i = listhead (iflist); i; nextnode (i)) |
| 1003 | { |
| 1004 | ifp = (struct interface *) getdata (i); |
| 1005 | oi = (struct ospf6_interface *) ifp->info; |
| 1006 | if (oi == NULL) |
| 1007 | continue; |
| 1008 | |
| 1009 | ospf6_route_table_show (vty, argc, argv, oi->route_connected); |
| 1010 | } |
| 1011 | |
| 1012 | return CMD_SUCCESS; |
| 1013 | } |
| 1014 | |
| 1015 | ALIAS (show_ipv6_ospf6_interface_prefix, |
| 1016 | show_ipv6_ospf6_interface_prefix_detail_cmd, |
| 1017 | "show ipv6 ospf6 interface prefix (X:X::X:X|X:X::X:X/M|detail)", |
| 1018 | SHOW_STR |
| 1019 | IP6_STR |
| 1020 | OSPF6_STR |
| 1021 | INTERFACE_STR |
| 1022 | "Display connected prefixes to advertise\n" |
| 1023 | OSPF6_ROUTE_ADDRESS_STR |
| 1024 | OSPF6_ROUTE_PREFIX_STR |
| 1025 | "Dispaly details of the prefixes\n" |
| 1026 | ); |
| 1027 | |
| 1028 | ALIAS (show_ipv6_ospf6_interface_prefix, |
| 1029 | show_ipv6_ospf6_interface_prefix_match_cmd, |
| 1030 | "show ipv6 ospf6 interface prefix X:X::X:X/M (match|detail)", |
| 1031 | SHOW_STR |
| 1032 | IP6_STR |
| 1033 | OSPF6_STR |
| 1034 | INTERFACE_STR |
| 1035 | "Display connected prefixes to advertise\n" |
| 1036 | OSPF6_ROUTE_PREFIX_STR |
| 1037 | OSPF6_ROUTE_MATCH_STR |
| 1038 | "Dispaly details of the prefixes\n" |
| 1039 | ); |
| 1040 | |
| 1041 | |
| 1042 | /* interface variable set command */ |
hasso | b596c71 | 2004-07-09 18:33:43 +0000 | [diff] [blame] | 1043 | DEFUN (ipv6_ospf6_ifmtu, |
| 1044 | ipv6_ospf6_ifmtu_cmd, |
| 1045 | "ipv6 ospf6 ifmtu <1-65535>", |
| 1046 | IP6_STR |
| 1047 | OSPF6_STR |
| 1048 | "Interface MTU\n" |
| 1049 | "OSPFv3 Interface MTU\n" |
| 1050 | ) |
| 1051 | { |
| 1052 | struct ospf6_interface *oi; |
| 1053 | struct interface *ifp; |
| 1054 | int ifmtu, iobuflen; |
| 1055 | listnode node; |
| 1056 | struct ospf6_neighbor *on; |
| 1057 | |
| 1058 | ifp = (struct interface *) vty->index; |
| 1059 | assert (ifp); |
| 1060 | |
| 1061 | oi = (struct ospf6_interface *) ifp->info; |
| 1062 | if (oi == NULL) |
| 1063 | oi = ospf6_interface_create (ifp); |
| 1064 | assert (oi); |
| 1065 | |
| 1066 | ifmtu = strtol (argv[0], NULL, 10); |
| 1067 | |
| 1068 | if (oi->ifmtu == ifmtu) |
| 1069 | return CMD_SUCCESS; |
| 1070 | |
hasso | 1203e1c | 2004-07-23 21:34:27 +0000 | [diff] [blame] | 1071 | if (ifp->mtu6 != 0 && ifp->mtu6 < ifmtu) |
hasso | b596c71 | 2004-07-09 18:33:43 +0000 | [diff] [blame] | 1072 | { |
| 1073 | vty_out (vty, "%s's ospf6 ifmtu cannot go beyond physical mtu (%d)%s", |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame^] | 1074 | ifp->name, ifp->mtu6, VNL); |
hasso | b596c71 | 2004-07-09 18:33:43 +0000 | [diff] [blame] | 1075 | return CMD_WARNING; |
| 1076 | } |
| 1077 | |
| 1078 | if (oi->ifmtu < ifmtu) |
| 1079 | { |
| 1080 | iobuflen = ospf6_iobuf_size (ifmtu); |
| 1081 | if (iobuflen < ifmtu) |
| 1082 | { |
| 1083 | vty_out (vty, "%s's ifmtu is adjusted to I/O buffer size (%d).%s", |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame^] | 1084 | ifp->name, iobuflen, VNL); |
hasso | b596c71 | 2004-07-09 18:33:43 +0000 | [diff] [blame] | 1085 | oi->ifmtu = iobuflen; |
| 1086 | } |
| 1087 | else |
| 1088 | oi->ifmtu = ifmtu; |
| 1089 | } |
| 1090 | else |
| 1091 | oi->ifmtu = ifmtu; |
| 1092 | |
| 1093 | /* re-establish adjacencies */ |
| 1094 | for (node = listhead (oi->neighbor_list); node; nextnode (node)) |
| 1095 | { |
| 1096 | on = (struct ospf6_neighbor *) getdata (node); |
| 1097 | THREAD_OFF (on->inactivity_timer); |
| 1098 | thread_execute (master, inactivity_timer, on, 0); |
| 1099 | } |
| 1100 | |
| 1101 | return CMD_SUCCESS; |
| 1102 | } |
| 1103 | |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame^] | 1104 | DEFUN (no_ipv6_ospf6_ifmtu, |
| 1105 | no_ipv6_ospf6_ifmtu_cmd, |
| 1106 | "no ipv6 ospf6 ifmtu", |
| 1107 | NO_STR |
| 1108 | IP6_STR |
| 1109 | OSPF6_STR |
| 1110 | "Interface MTU\n" |
| 1111 | ) |
| 1112 | { |
| 1113 | struct ospf6_interface *oi; |
| 1114 | struct interface *ifp; |
| 1115 | int iobuflen; |
| 1116 | listnode node; |
| 1117 | struct ospf6_neighbor *on; |
| 1118 | |
| 1119 | ifp = (struct interface *) vty->index; |
| 1120 | assert (ifp); |
| 1121 | |
| 1122 | oi = (struct ospf6_interface *) ifp->info; |
| 1123 | if (oi == NULL) |
| 1124 | oi = ospf6_interface_create (ifp); |
| 1125 | assert (oi); |
| 1126 | |
| 1127 | if (oi->ifmtu < ifp->mtu) |
| 1128 | { |
| 1129 | iobuflen = ospf6_iobuf_size (ifp->mtu); |
| 1130 | if (iobuflen < ifp->mtu) |
| 1131 | { |
| 1132 | vty_out (vty, "%s's ifmtu is adjusted to I/O buffer size (%d).%s", |
| 1133 | ifp->name, iobuflen, VNL); |
| 1134 | oi->ifmtu = iobuflen; |
| 1135 | } |
| 1136 | else |
| 1137 | oi->ifmtu = ifp->mtu; |
| 1138 | } |
| 1139 | else |
| 1140 | oi->ifmtu = ifp->mtu; |
| 1141 | |
| 1142 | /* re-establish adjacencies */ |
| 1143 | for (node = listhead (oi->neighbor_list); node; nextnode (node)) |
| 1144 | { |
| 1145 | on = (struct ospf6_neighbor *) getdata (node); |
| 1146 | THREAD_OFF (on->inactivity_timer); |
| 1147 | thread_execute (master, inactivity_timer, on, 0); |
| 1148 | } |
| 1149 | |
| 1150 | return CMD_SUCCESS; |
| 1151 | } |
| 1152 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1153 | DEFUN (ipv6_ospf6_cost, |
| 1154 | ipv6_ospf6_cost_cmd, |
| 1155 | "ipv6 ospf6 cost <1-65535>", |
| 1156 | IP6_STR |
| 1157 | OSPF6_STR |
| 1158 | "Interface cost\n" |
| 1159 | "Outgoing metric of this interface\n" |
| 1160 | ) |
| 1161 | { |
| 1162 | struct ospf6_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1163 | struct interface *ifp; |
| 1164 | |
| 1165 | ifp = (struct interface *) vty->index; |
| 1166 | assert (ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1167 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1168 | oi = (struct ospf6_interface *) ifp->info; |
| 1169 | if (oi == NULL) |
| 1170 | oi = ospf6_interface_create (ifp); |
| 1171 | assert (oi); |
| 1172 | |
| 1173 | if (oi->cost == strtol (argv[0], NULL, 10)) |
| 1174 | return CMD_SUCCESS; |
| 1175 | |
| 1176 | oi->cost = strtol (argv[0], NULL, 10); |
| 1177 | |
| 1178 | /* update cost held in route_connected list in ospf6_interface */ |
| 1179 | ospf6_interface_connected_route_update (oi->interface); |
| 1180 | |
| 1181 | /* execute LSA hooks */ |
| 1182 | if (oi->area) |
| 1183 | { |
| 1184 | OSPF6_LINK_LSA_SCHEDULE (oi); |
| 1185 | OSPF6_ROUTER_LSA_SCHEDULE (oi->area); |
| 1186 | OSPF6_NETWORK_LSA_SCHEDULE (oi); |
| 1187 | OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi); |
| 1188 | OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area); |
| 1189 | } |
| 1190 | |
| 1191 | return CMD_SUCCESS; |
| 1192 | } |
| 1193 | |
| 1194 | DEFUN (ipv6_ospf6_hellointerval, |
| 1195 | ipv6_ospf6_hellointerval_cmd, |
| 1196 | "ipv6 ospf6 hello-interval <1-65535>", |
| 1197 | IP6_STR |
| 1198 | OSPF6_STR |
| 1199 | "Interval time of Hello packets\n" |
| 1200 | SECONDS_STR |
| 1201 | ) |
| 1202 | { |
| 1203 | struct ospf6_interface *oi; |
| 1204 | struct interface *ifp; |
| 1205 | |
| 1206 | ifp = (struct interface *) vty->index; |
| 1207 | assert (ifp); |
| 1208 | |
| 1209 | oi = (struct ospf6_interface *) ifp->info; |
| 1210 | if (oi == NULL) |
| 1211 | oi = ospf6_interface_create (ifp); |
| 1212 | assert (oi); |
| 1213 | |
| 1214 | oi->hello_interval = strtol (argv[0], NULL, 10); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1215 | return CMD_SUCCESS; |
| 1216 | } |
| 1217 | |
| 1218 | /* interface variable set command */ |
| 1219 | DEFUN (ipv6_ospf6_deadinterval, |
| 1220 | ipv6_ospf6_deadinterval_cmd, |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1221 | "ipv6 ospf6 dead-interval <1-65535>", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1222 | IP6_STR |
| 1223 | OSPF6_STR |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1224 | "Interval time after which a neighbor is declared down\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1225 | SECONDS_STR |
| 1226 | ) |
| 1227 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1228 | struct ospf6_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1229 | struct interface *ifp; |
| 1230 | |
| 1231 | ifp = (struct interface *) vty->index; |
| 1232 | assert (ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1233 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1234 | oi = (struct ospf6_interface *) ifp->info; |
| 1235 | if (oi == NULL) |
| 1236 | oi = ospf6_interface_create (ifp); |
| 1237 | assert (oi); |
| 1238 | |
| 1239 | oi->dead_interval = strtol (argv[0], NULL, 10); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1240 | return CMD_SUCCESS; |
| 1241 | } |
| 1242 | |
| 1243 | /* interface variable set command */ |
| 1244 | DEFUN (ipv6_ospf6_transmitdelay, |
| 1245 | ipv6_ospf6_transmitdelay_cmd, |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1246 | "ipv6 ospf6 transmit-delay <1-3600>", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1247 | IP6_STR |
| 1248 | OSPF6_STR |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1249 | "Transmit delay of this interface\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1250 | SECONDS_STR |
| 1251 | ) |
| 1252 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1253 | struct ospf6_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1254 | struct interface *ifp; |
| 1255 | |
| 1256 | ifp = (struct interface *) vty->index; |
| 1257 | assert (ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1258 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1259 | oi = (struct ospf6_interface *) ifp->info; |
| 1260 | if (oi == NULL) |
| 1261 | oi = ospf6_interface_create (ifp); |
| 1262 | assert (oi); |
| 1263 | |
| 1264 | oi->transdelay = strtol (argv[0], NULL, 10); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1265 | return CMD_SUCCESS; |
| 1266 | } |
| 1267 | |
| 1268 | /* interface variable set command */ |
| 1269 | DEFUN (ipv6_ospf6_retransmitinterval, |
| 1270 | ipv6_ospf6_retransmitinterval_cmd, |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1271 | "ipv6 ospf6 retransmit-interval <1-65535>", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1272 | IP6_STR |
| 1273 | OSPF6_STR |
| 1274 | "Time between retransmitting lost link state advertisements\n" |
| 1275 | SECONDS_STR |
| 1276 | ) |
| 1277 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1278 | struct ospf6_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1279 | struct interface *ifp; |
| 1280 | |
| 1281 | ifp = (struct interface *) vty->index; |
| 1282 | assert (ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1283 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1284 | oi = (struct ospf6_interface *) ifp->info; |
| 1285 | if (oi == NULL) |
| 1286 | oi = ospf6_interface_create (ifp); |
| 1287 | assert (oi); |
| 1288 | |
| 1289 | oi->rxmt_interval = strtol (argv[0], NULL, 10); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1290 | return CMD_SUCCESS; |
| 1291 | } |
| 1292 | |
| 1293 | /* interface variable set command */ |
| 1294 | DEFUN (ipv6_ospf6_priority, |
| 1295 | ipv6_ospf6_priority_cmd, |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1296 | "ipv6 ospf6 priority <0-255>", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1297 | IP6_STR |
| 1298 | OSPF6_STR |
| 1299 | "Router priority\n" |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1300 | "Priority value\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1301 | ) |
| 1302 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1303 | struct ospf6_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1304 | struct interface *ifp; |
| 1305 | |
| 1306 | ifp = (struct interface *) vty->index; |
| 1307 | assert (ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1308 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1309 | oi = (struct ospf6_interface *) ifp->info; |
| 1310 | if (oi == NULL) |
| 1311 | oi = ospf6_interface_create (ifp); |
| 1312 | assert (oi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1313 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1314 | oi->priority = strtol (argv[0], NULL, 10); |
| 1315 | |
| 1316 | if (oi->area) |
| 1317 | ospf6_interface_state_change (dr_election (oi), oi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1318 | |
| 1319 | return CMD_SUCCESS; |
| 1320 | } |
| 1321 | |
| 1322 | DEFUN (ipv6_ospf6_instance, |
| 1323 | ipv6_ospf6_instance_cmd, |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1324 | "ipv6 ospf6 instance-id <0-255>", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1325 | IP6_STR |
| 1326 | OSPF6_STR |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1327 | "Instance ID for this interface\n" |
| 1328 | "Instance ID value\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1329 | ) |
| 1330 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1331 | struct ospf6_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1332 | struct interface *ifp; |
| 1333 | |
| 1334 | ifp = (struct interface *)vty->index; |
| 1335 | assert (ifp); |
| 1336 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1337 | oi = (struct ospf6_interface *)ifp->info; |
| 1338 | if (oi == NULL) |
| 1339 | oi = ospf6_interface_create (ifp); |
| 1340 | assert (oi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1341 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1342 | oi->instance_id = strtol (argv[0], NULL, 10); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1343 | return CMD_SUCCESS; |
| 1344 | } |
| 1345 | |
| 1346 | DEFUN (ipv6_ospf6_passive, |
| 1347 | ipv6_ospf6_passive_cmd, |
| 1348 | "ipv6 ospf6 passive", |
| 1349 | IP6_STR |
| 1350 | OSPF6_STR |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1351 | "passive interface, No adjacency will be formed on this interface\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1352 | ) |
| 1353 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1354 | struct ospf6_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1355 | struct interface *ifp; |
| 1356 | listnode node; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1357 | struct ospf6_neighbor *on; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1358 | |
| 1359 | ifp = (struct interface *) vty->index; |
| 1360 | assert (ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1361 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1362 | oi = (struct ospf6_interface *) ifp->info; |
| 1363 | if (oi == NULL) |
| 1364 | oi = ospf6_interface_create (ifp); |
| 1365 | assert (oi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1366 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1367 | SET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE); |
| 1368 | THREAD_OFF (oi->thread_send_hello); |
| 1369 | |
| 1370 | for (node = listhead (oi->neighbor_list); node; nextnode (node)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1371 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1372 | on = (struct ospf6_neighbor *) getdata (node); |
| 1373 | THREAD_OFF (on->inactivity_timer); |
| 1374 | thread_execute (master, inactivity_timer, on, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1375 | } |
| 1376 | |
| 1377 | return CMD_SUCCESS; |
| 1378 | } |
| 1379 | |
| 1380 | DEFUN (no_ipv6_ospf6_passive, |
| 1381 | no_ipv6_ospf6_passive_cmd, |
| 1382 | "no ipv6 ospf6 passive", |
| 1383 | NO_STR |
| 1384 | IP6_STR |
| 1385 | OSPF6_STR |
| 1386 | "passive interface: No Adjacency will be formed on this I/F\n" |
| 1387 | ) |
| 1388 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1389 | struct ospf6_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1390 | struct interface *ifp; |
| 1391 | |
| 1392 | ifp = (struct interface *) vty->index; |
| 1393 | assert (ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1394 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1395 | oi = (struct ospf6_interface *) ifp->info; |
| 1396 | if (oi == NULL) |
| 1397 | oi = ospf6_interface_create (ifp); |
| 1398 | assert (oi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1399 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1400 | UNSET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE); |
| 1401 | THREAD_OFF (oi->thread_send_hello); |
| 1402 | oi->thread_send_hello = |
| 1403 | thread_add_event (master, ospf6_hello_send, oi, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1404 | |
| 1405 | return CMD_SUCCESS; |
| 1406 | } |
| 1407 | |
| 1408 | DEFUN (ipv6_ospf6_advertise_prefix_list, |
| 1409 | ipv6_ospf6_advertise_prefix_list_cmd, |
| 1410 | "ipv6 ospf6 advertise prefix-list WORD", |
| 1411 | IP6_STR |
| 1412 | OSPF6_STR |
| 1413 | "Advertising options\n" |
| 1414 | "Filter prefix using prefix-list\n" |
| 1415 | "Prefix list name\n" |
| 1416 | ) |
| 1417 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1418 | struct ospf6_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1419 | struct interface *ifp; |
| 1420 | |
| 1421 | ifp = (struct interface *) vty->index; |
| 1422 | assert (ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1423 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1424 | oi = (struct ospf6_interface *) ifp->info; |
| 1425 | if (oi == NULL) |
| 1426 | oi = ospf6_interface_create (ifp); |
| 1427 | assert (oi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1428 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1429 | if (oi->plist_name) |
| 1430 | XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name); |
| 1431 | oi->plist_name = XSTRDUP (MTYPE_PREFIX_LIST_STR, argv[0]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1432 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1433 | ospf6_interface_connected_route_update (oi->interface); |
| 1434 | OSPF6_LINK_LSA_SCHEDULE (oi); |
| 1435 | if (oi->state == OSPF6_INTERFACE_DR) |
| 1436 | { |
| 1437 | OSPF6_NETWORK_LSA_SCHEDULE (oi); |
| 1438 | OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi); |
| 1439 | } |
| 1440 | OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1441 | |
| 1442 | return CMD_SUCCESS; |
| 1443 | } |
| 1444 | |
| 1445 | DEFUN (no_ipv6_ospf6_advertise_prefix_list, |
| 1446 | no_ipv6_ospf6_advertise_prefix_list_cmd, |
| 1447 | "no ipv6 ospf6 advertise prefix-list", |
| 1448 | NO_STR |
| 1449 | IP6_STR |
| 1450 | OSPF6_STR |
| 1451 | "Advertising options\n" |
| 1452 | "Filter prefix using prefix-list\n" |
| 1453 | ) |
| 1454 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1455 | struct ospf6_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1456 | struct interface *ifp; |
| 1457 | |
| 1458 | ifp = (struct interface *) vty->index; |
| 1459 | assert (ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1460 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1461 | oi = (struct ospf6_interface *) ifp->info; |
| 1462 | if (oi == NULL) |
| 1463 | oi = ospf6_interface_create (ifp); |
| 1464 | assert (oi); |
| 1465 | |
| 1466 | if (oi->plist_name) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1467 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1468 | XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name); |
| 1469 | oi->plist_name = NULL; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1470 | } |
| 1471 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1472 | ospf6_interface_connected_route_update (oi->interface); |
| 1473 | OSPF6_LINK_LSA_SCHEDULE (oi); |
| 1474 | if (oi->state == OSPF6_INTERFACE_DR) |
| 1475 | { |
| 1476 | OSPF6_NETWORK_LSA_SCHEDULE (oi); |
| 1477 | OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi); |
| 1478 | } |
| 1479 | OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1480 | |
| 1481 | return CMD_SUCCESS; |
| 1482 | } |
| 1483 | |
| 1484 | int |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1485 | config_write_ospf6_interface (struct vty *vty) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1486 | { |
| 1487 | listnode i; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1488 | struct ospf6_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1489 | struct interface *ifp; |
| 1490 | |
| 1491 | for (i = listhead (iflist); i; nextnode (i)) |
| 1492 | { |
| 1493 | ifp = (struct interface *) getdata (i); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1494 | oi = (struct ospf6_interface *) ifp->info; |
| 1495 | if (oi == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1496 | continue; |
| 1497 | |
| 1498 | vty_out (vty, "interface %s%s", |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame^] | 1499 | oi->interface->name, VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1500 | |
| 1501 | if (ifp->desc) |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame^] | 1502 | vty_out (vty, " description %s%s", ifp->desc, VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1503 | |
hasso | 1203e1c | 2004-07-23 21:34:27 +0000 | [diff] [blame] | 1504 | if (ifp->mtu6 != oi->ifmtu) |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame^] | 1505 | vty_out (vty, " ipv6 ospf6 ifmtu %d%s", oi->ifmtu, VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1506 | vty_out (vty, " ipv6 ospf6 cost %d%s", |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame^] | 1507 | oi->cost, VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1508 | vty_out (vty, " ipv6 ospf6 hello-interval %d%s", |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame^] | 1509 | oi->hello_interval, VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1510 | vty_out (vty, " ipv6 ospf6 dead-interval %d%s", |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame^] | 1511 | oi->dead_interval, VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1512 | vty_out (vty, " ipv6 ospf6 retransmit-interval %d%s", |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame^] | 1513 | oi->rxmt_interval, VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1514 | vty_out (vty, " ipv6 ospf6 priority %d%s", |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame^] | 1515 | oi->priority, VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1516 | vty_out (vty, " ipv6 ospf6 transmit-delay %d%s", |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame^] | 1517 | oi->transdelay, VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1518 | vty_out (vty, " ipv6 ospf6 instance-id %d%s", |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame^] | 1519 | oi->instance_id, VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1520 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1521 | if (oi->plist_name) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1522 | vty_out (vty, " ipv6 ospf6 advertise prefix-list %s%s", |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame^] | 1523 | oi->plist_name, VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1524 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1525 | if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE)) |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame^] | 1526 | vty_out (vty, " ipv6 ospf6 passive%s", VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1527 | |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame^] | 1528 | vty_out (vty, "!%s", VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1529 | } |
| 1530 | return 0; |
| 1531 | } |
| 1532 | |
| 1533 | struct cmd_node interface_node = |
| 1534 | { |
| 1535 | INTERFACE_NODE, |
| 1536 | "%s(config-if)# ", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1537 | }; |
| 1538 | |
| 1539 | void |
| 1540 | ospf6_interface_init () |
| 1541 | { |
| 1542 | /* Install interface node. */ |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1543 | install_node (&interface_node, config_write_ospf6_interface); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1544 | |
| 1545 | install_element (VIEW_NODE, &show_ipv6_ospf6_interface_cmd); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1546 | install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_cmd); |
| 1547 | install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_detail_cmd); |
| 1548 | install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_match_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1549 | install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_cmd); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1550 | install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_cmd); |
| 1551 | install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd); |
| 1552 | install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1553 | install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_cmd); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1554 | install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_cmd); |
| 1555 | install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_detail_cmd); |
| 1556 | install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_match_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1557 | install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_cmd); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1558 | install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_cmd); |
| 1559 | install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd); |
| 1560 | install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1561 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1562 | install_element (CONFIG_NODE, &interface_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1563 | install_default (INTERFACE_NODE); |
| 1564 | install_element (INTERFACE_NODE, &interface_desc_cmd); |
| 1565 | install_element (INTERFACE_NODE, &no_interface_desc_cmd); |
| 1566 | install_element (INTERFACE_NODE, &ipv6_ospf6_cost_cmd); |
hasso | b596c71 | 2004-07-09 18:33:43 +0000 | [diff] [blame] | 1567 | install_element (INTERFACE_NODE, &ipv6_ospf6_ifmtu_cmd); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame^] | 1568 | install_element (INTERFACE_NODE, &no_ipv6_ospf6_ifmtu_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1569 | install_element (INTERFACE_NODE, &ipv6_ospf6_deadinterval_cmd); |
| 1570 | install_element (INTERFACE_NODE, &ipv6_ospf6_hellointerval_cmd); |
| 1571 | install_element (INTERFACE_NODE, &ipv6_ospf6_priority_cmd); |
| 1572 | install_element (INTERFACE_NODE, &ipv6_ospf6_retransmitinterval_cmd); |
| 1573 | install_element (INTERFACE_NODE, &ipv6_ospf6_transmitdelay_cmd); |
| 1574 | install_element (INTERFACE_NODE, &ipv6_ospf6_instance_cmd); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1575 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1576 | install_element (INTERFACE_NODE, &ipv6_ospf6_passive_cmd); |
| 1577 | install_element (INTERFACE_NODE, &no_ipv6_ospf6_passive_cmd); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1578 | |
| 1579 | install_element (INTERFACE_NODE, &ipv6_ospf6_advertise_prefix_list_cmd); |
| 1580 | install_element (INTERFACE_NODE, &no_ipv6_ospf6_advertise_prefix_list_cmd); |
| 1581 | } |
| 1582 | |
| 1583 | DEFUN (debug_ospf6_interface, |
| 1584 | debug_ospf6_interface_cmd, |
| 1585 | "debug ospf6 interface", |
| 1586 | DEBUG_STR |
| 1587 | OSPF6_STR |
| 1588 | "Debug OSPFv3 Interface\n" |
| 1589 | ) |
| 1590 | { |
| 1591 | OSPF6_DEBUG_INTERFACE_ON (); |
| 1592 | return CMD_SUCCESS; |
| 1593 | } |
| 1594 | |
| 1595 | DEFUN (no_debug_ospf6_interface, |
| 1596 | no_debug_ospf6_interface_cmd, |
| 1597 | "no debug ospf6 interface", |
| 1598 | NO_STR |
| 1599 | DEBUG_STR |
| 1600 | OSPF6_STR |
| 1601 | "Debug OSPFv3 Interface\n" |
| 1602 | ) |
| 1603 | { |
| 1604 | OSPF6_DEBUG_INTERFACE_ON (); |
| 1605 | return CMD_SUCCESS; |
| 1606 | } |
| 1607 | |
| 1608 | int |
| 1609 | config_write_ospf6_debug_interface (struct vty *vty) |
| 1610 | { |
| 1611 | if (IS_OSPF6_DEBUG_INTERFACE) |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame^] | 1612 | vty_out (vty, "debug ospf6 interface%s", VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1613 | return 0; |
| 1614 | } |
| 1615 | |
| 1616 | void |
| 1617 | install_element_ospf6_debug_interface () |
| 1618 | { |
| 1619 | install_element (ENABLE_NODE, &debug_ospf6_interface_cmd); |
| 1620 | install_element (ENABLE_NODE, &no_debug_ospf6_interface_cmd); |
| 1621 | install_element (CONFIG_NODE, &debug_ospf6_interface_cmd); |
| 1622 | install_element (CONFIG_NODE, &no_debug_ospf6_interface_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1623 | } |
| 1624 | |
| 1625 | |