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