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 Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 75 | static 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 | { |
Dinesh Dutt | 3810e06 | 2013-08-24 07:54:09 +0000 | [diff] [blame] | 78 | struct ospf6_interface *oi; |
| 79 | |
| 80 | if (lsa == NULL) |
| 81 | return; |
| 82 | |
| 83 | oi = lsa->lsdb->data; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 84 | switch (ntohs (lsa->header->type)) |
| 85 | { |
| 86 | case OSPF6_LSTYPE_LINK: |
Dinesh Dutt | 3810e06 | 2013-08-24 07:54:09 +0000 | [diff] [blame] | 87 | if (oi->state == OSPF6_INTERFACE_DR) |
| 88 | OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi); |
| 89 | ospf6_spf_schedule (oi->area->ospf6); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 90 | break; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 91 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 92 | default: |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 93 | break; |
| 94 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 95 | } |
| 96 | |
Dinesh Dutt | c5926a9 | 2013-08-24 07:55:00 +0000 | [diff] [blame] | 97 | static u_char |
| 98 | ospf6_default_iftype(struct interface *ifp) |
| 99 | { |
| 100 | if (if_is_pointopoint (ifp)) |
| 101 | return OSPF_IFTYPE_POINTOPOINT; |
| 102 | else if (if_is_loopback (ifp)) |
| 103 | return OSPF_IFTYPE_LOOPBACK; |
| 104 | else |
| 105 | return OSPF_IFTYPE_BROADCAST; |
| 106 | } |
| 107 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 108 | /* Create new ospf6 interface structure */ |
| 109 | struct ospf6_interface * |
| 110 | ospf6_interface_create (struct interface *ifp) |
| 111 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 112 | struct ospf6_interface *oi; |
paul | 0c083ee | 2004-10-10 12:54:58 +0000 | [diff] [blame] | 113 | unsigned int iobuflen; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 114 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 115 | oi = (struct ospf6_interface *) |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 116 | XCALLOC (MTYPE_OSPF6_IF, sizeof (struct ospf6_interface)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 117 | |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 118 | if (!oi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 119 | { |
| 120 | zlog_err ("Can't malloc ospf6_interface for ifindex %d", ifp->ifindex); |
| 121 | return (struct ospf6_interface *) NULL; |
| 122 | } |
| 123 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 124 | oi->area = (struct ospf6_area *) NULL; |
| 125 | oi->neighbor_list = list_new (); |
| 126 | oi->neighbor_list->cmp = ospf6_neighbor_cmp; |
| 127 | oi->linklocal_addr = (struct in6_addr *) NULL; |
Vyacheslav Trushkin | b51a3a3 | 2012-02-10 10:42:45 +0400 | [diff] [blame] | 128 | oi->instance_id = OSPF6_INTERFACE_INSTANCE_ID; |
| 129 | oi->transdelay = OSPF6_INTERFACE_TRANSDELAY; |
| 130 | oi->priority = OSPF6_INTERFACE_PRIORITY; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 131 | |
Dinesh Dutt | 8551e6d | 2013-10-22 17:42:18 -0700 | [diff] [blame] | 132 | oi->hello_interval = OSPF_HELLO_INTERVAL_DEFAULT; |
| 133 | oi->dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT; |
| 134 | oi->rxmt_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT; |
Vyacheslav Trushkin | b51a3a3 | 2012-02-10 10:42:45 +0400 | [diff] [blame] | 135 | oi->cost = OSPF6_INTERFACE_COST; |
Dinesh Dutt | c5926a9 | 2013-08-24 07:55:00 +0000 | [diff] [blame] | 136 | oi->type = ospf6_default_iftype (ifp); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 137 | oi->state = OSPF6_INTERFACE_DOWN; |
| 138 | oi->flag = 0; |
Dmitrij Tejblum | d42306d | 2011-04-22 19:27:54 +0400 | [diff] [blame] | 139 | oi->mtu_ignore = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 140 | |
hasso | b596c71 | 2004-07-09 18:33:43 +0000 | [diff] [blame] | 141 | /* Try to adjust I/O buffer size with IfMtu */ |
hasso | 1203e1c | 2004-07-23 21:34:27 +0000 | [diff] [blame] | 142 | oi->ifmtu = ifp->mtu6; |
| 143 | iobuflen = ospf6_iobuf_size (ifp->mtu6); |
hasso | b596c71 | 2004-07-09 18:33:43 +0000 | [diff] [blame] | 144 | if (oi->ifmtu > iobuflen) |
hasso | 3b4cd3a | 2004-05-18 19:28:32 +0000 | [diff] [blame] | 145 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 146 | if (IS_OSPF6_DEBUG_INTERFACE) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 147 | zlog_debug ("Interface %s: IfMtu is adjusted to I/O buffer size: %d.", |
| 148 | ifp->name, iobuflen); |
hasso | 3b4cd3a | 2004-05-18 19:28:32 +0000 | [diff] [blame] | 149 | oi->ifmtu = iobuflen; |
| 150 | } |
hasso | 3b4cd3a | 2004-05-18 19:28:32 +0000 | [diff] [blame] | 151 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 152 | oi->lsupdate_list = ospf6_lsdb_create (oi); |
| 153 | oi->lsack_list = ospf6_lsdb_create (oi); |
| 154 | oi->lsdb = ospf6_lsdb_create (oi); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 155 | oi->lsdb->hook_add = ospf6_interface_lsdb_hook; |
| 156 | oi->lsdb->hook_remove = ospf6_interface_lsdb_hook; |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 157 | oi->lsdb_self = ospf6_lsdb_create (oi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 158 | |
Paul Jakma | cf1ce25 | 2006-05-15 10:46:07 +0000 | [diff] [blame] | 159 | oi->route_connected = OSPF6_ROUTE_TABLE_CREATE (INTERFACE, CONNECTED_ROUTES); |
| 160 | oi->route_connected->scope = oi; |
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 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 172 | struct listnode *node, *nnode; |
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 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 175 | for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on)) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 176 | ospf6_neighbor_delete (on); |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 177 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 178 | list_delete (oi->neighbor_list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 179 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 180 | THREAD_OFF (oi->thread_send_hello); |
| 181 | THREAD_OFF (oi->thread_send_lsupdate); |
| 182 | THREAD_OFF (oi->thread_send_lsack); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 183 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 184 | ospf6_lsdb_remove_all (oi->lsdb); |
| 185 | ospf6_lsdb_remove_all (oi->lsupdate_list); |
| 186 | ospf6_lsdb_remove_all (oi->lsack_list); |
| 187 | |
| 188 | ospf6_lsdb_delete (oi->lsdb); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 189 | ospf6_lsdb_delete (oi->lsdb_self); |
| 190 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 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 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 218 | struct listnode *node, *nnode; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 219 | struct ospf6_neighbor *on; |
| 220 | |
| 221 | SET_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE); |
| 222 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 223 | for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on)) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 224 | ospf6_neighbor_delete (on); |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 225 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 226 | list_delete_all_node (oi->neighbor_list); |
| 227 | |
| 228 | ospf6_lsdb_remove_all (oi->lsdb); |
| 229 | ospf6_lsdb_remove_all (oi->lsupdate_list); |
| 230 | ospf6_lsdb_remove_all (oi->lsack_list); |
| 231 | |
| 232 | THREAD_OFF (oi->thread_send_hello); |
| 233 | THREAD_OFF (oi->thread_send_lsupdate); |
| 234 | THREAD_OFF (oi->thread_send_lsack); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 235 | } |
| 236 | |
| 237 | static struct in6_addr * |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 238 | ospf6_interface_get_linklocal_address (struct interface *ifp) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 239 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 240 | struct listnode *n; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 241 | struct connected *c; |
| 242 | struct in6_addr *l = (struct in6_addr *) NULL; |
| 243 | |
| 244 | /* for each connected address */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 245 | for (ALL_LIST_ELEMENTS_RO (ifp->connected, n, c)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 246 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 247 | /* if family not AF_INET6, ignore */ |
| 248 | if (c->address->family != AF_INET6) |
| 249 | continue; |
| 250 | |
| 251 | /* linklocal scope check */ |
| 252 | if (IN6_IS_ADDR_LINKLOCAL (&c->address->u.prefix6)) |
| 253 | l = &c->address->u.prefix6; |
| 254 | } |
| 255 | return l; |
| 256 | } |
| 257 | |
| 258 | void |
| 259 | ospf6_interface_if_add (struct interface *ifp) |
| 260 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 261 | struct ospf6_interface *oi; |
paul | 0c083ee | 2004-10-10 12:54:58 +0000 | [diff] [blame] | 262 | unsigned int iobuflen; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 263 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 264 | oi = (struct ospf6_interface *) ifp->info; |
| 265 | if (oi == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 266 | return; |
| 267 | |
hasso | b596c71 | 2004-07-09 18:33:43 +0000 | [diff] [blame] | 268 | /* Try to adjust I/O buffer size with IfMtu */ |
| 269 | if (oi->ifmtu == 0) |
hasso | 1203e1c | 2004-07-23 21:34:27 +0000 | [diff] [blame] | 270 | oi->ifmtu = ifp->mtu6; |
| 271 | iobuflen = ospf6_iobuf_size (ifp->mtu6); |
hasso | b596c71 | 2004-07-09 18:33:43 +0000 | [diff] [blame] | 272 | if (oi->ifmtu > iobuflen) |
hasso | 3b4cd3a | 2004-05-18 19:28:32 +0000 | [diff] [blame] | 273 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 274 | if (IS_OSPF6_DEBUG_INTERFACE) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 275 | zlog_debug ("Interface %s: IfMtu is adjusted to I/O buffer size: %d.", |
| 276 | ifp->name, iobuflen); |
hasso | 3b4cd3a | 2004-05-18 19:28:32 +0000 | [diff] [blame] | 277 | oi->ifmtu = iobuflen; |
| 278 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 279 | |
| 280 | /* interface start */ |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 281 | if (oi->area) |
| 282 | thread_add_event (master, interface_up, oi, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 283 | } |
| 284 | |
| 285 | void |
| 286 | ospf6_interface_if_del (struct interface *ifp) |
| 287 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 288 | struct ospf6_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 289 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 290 | oi = (struct ospf6_interface *) ifp->info; |
| 291 | if (oi == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 292 | return; |
| 293 | |
| 294 | /* interface stop */ |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 295 | if (oi->area) |
| 296 | thread_execute (master, interface_down, oi, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 297 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 298 | listnode_delete (oi->area->if_list, oi); |
| 299 | oi->area = (struct ospf6_area *) NULL; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 300 | |
| 301 | /* cut link */ |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 302 | oi->interface = NULL; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 303 | ifp->info = NULL; |
| 304 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 305 | ospf6_interface_delete (oi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 306 | } |
| 307 | |
| 308 | void |
| 309 | ospf6_interface_state_update (struct interface *ifp) |
| 310 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 311 | struct ospf6_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 312 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 313 | oi = (struct ospf6_interface *) ifp->info; |
| 314 | if (oi == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 315 | return; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 316 | if (oi->area == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 317 | return; |
| 318 | |
Dinesh Dutt | e7ad6b2 | 2013-08-24 07:55:57 +0000 | [diff] [blame] | 319 | if (if_is_operative (ifp)) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 320 | thread_add_event (master, interface_up, oi, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 321 | else |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 322 | thread_add_event (master, interface_down, oi, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 323 | |
| 324 | return; |
| 325 | } |
| 326 | |
| 327 | void |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 328 | ospf6_interface_connected_route_update (struct interface *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 | struct ospf6_interface *oi; |
| 331 | struct ospf6_route *route; |
| 332 | struct connected *c; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 333 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 334 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 335 | oi = (struct ospf6_interface *) ifp->info; |
| 336 | if (oi == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 337 | return; |
| 338 | |
| 339 | /* reset linklocal pointer */ |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 340 | oi->linklocal_addr = ospf6_interface_get_linklocal_address (ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 341 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 342 | /* if area is null, do not make connected-route list */ |
| 343 | if (oi->area == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 344 | return; |
| 345 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 346 | /* update "route to advertise" interface route table */ |
| 347 | ospf6_route_remove_all (oi->route_connected); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 348 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 349 | for (ALL_LIST_ELEMENTS (oi->interface->connected, node, nnode, c)) |
| 350 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 351 | if (c->address->family != AF_INET6) |
| 352 | continue; |
| 353 | |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 354 | CONTINUE_IF_ADDRESS_LINKLOCAL (IS_OSPF6_DEBUG_INTERFACE, c->address); |
| 355 | CONTINUE_IF_ADDRESS_UNSPECIFIED (IS_OSPF6_DEBUG_INTERFACE, c->address); |
| 356 | CONTINUE_IF_ADDRESS_LOOPBACK (IS_OSPF6_DEBUG_INTERFACE, c->address); |
| 357 | CONTINUE_IF_ADDRESS_V4COMPAT (IS_OSPF6_DEBUG_INTERFACE, c->address); |
| 358 | CONTINUE_IF_ADDRESS_V4MAPPED (IS_OSPF6_DEBUG_INTERFACE, c->address); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 359 | |
| 360 | /* apply filter */ |
| 361 | if (oi->plist_name) |
| 362 | { |
| 363 | struct prefix_list *plist; |
| 364 | enum prefix_list_type ret; |
| 365 | char buf[128]; |
| 366 | |
| 367 | prefix2str (c->address, buf, sizeof (buf)); |
| 368 | plist = prefix_list_lookup (AFI_IP6, oi->plist_name); |
| 369 | ret = prefix_list_apply (plist, (void *) c->address); |
| 370 | if (ret == PREFIX_DENY) |
| 371 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 372 | if (IS_OSPF6_DEBUG_INTERFACE) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 373 | zlog_debug ("%s on %s filtered by prefix-list %s ", |
| 374 | buf, oi->interface->name, oi->plist_name); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 375 | continue; |
| 376 | } |
| 377 | } |
| 378 | |
| 379 | route = ospf6_route_create (); |
| 380 | memcpy (&route->prefix, c->address, sizeof (struct prefix)); |
| 381 | apply_mask (&route->prefix); |
| 382 | route->type = OSPF6_DEST_TYPE_NETWORK; |
| 383 | route->path.area_id = oi->area->area_id; |
| 384 | route->path.type = OSPF6_PATH_TYPE_INTRA; |
| 385 | route->path.cost = oi->cost; |
| 386 | route->nexthop[0].ifindex = oi->interface->ifindex; |
| 387 | inet_pton (AF_INET6, "::1", &route->nexthop[0].address); |
| 388 | ospf6_route_add (route, oi->route_connected); |
| 389 | } |
| 390 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 391 | /* create new Link-LSA */ |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 392 | OSPF6_LINK_LSA_SCHEDULE (oi); |
| 393 | OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi); |
| 394 | OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 395 | } |
| 396 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 397 | static void |
| 398 | ospf6_interface_state_change (u_char next_state, struct ospf6_interface *oi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 399 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 400 | u_char prev_state; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 401 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 402 | prev_state = oi->state; |
| 403 | oi->state = next_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 | if (prev_state == next_state) |
| 406 | return; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 407 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 408 | /* log */ |
| 409 | if (IS_OSPF6_DEBUG_INTERFACE) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 410 | { |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 411 | zlog_debug ("Interface state change %s: %s -> %s", oi->interface->name, |
| 412 | ospf6_interface_state_str[prev_state], |
| 413 | ospf6_interface_state_str[next_state]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 414 | } |
Vincent Bernat | 3bc4f84 | 2012-06-04 11:40:04 +0200 | [diff] [blame] | 415 | oi->state_change++; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 416 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 417 | if ((prev_state == OSPF6_INTERFACE_DR || |
| 418 | prev_state == OSPF6_INTERFACE_BDR) && |
| 419 | (next_state != OSPF6_INTERFACE_DR && |
| 420 | next_state != OSPF6_INTERFACE_BDR)) |
Vyacheslav Trushkin | 9a9446e | 2011-11-21 20:26:39 +0400 | [diff] [blame] | 421 | ospf6_sso (oi->interface->ifindex, &alldrouters6, IPV6_LEAVE_GROUP); |
Dinesh Dutt | c5926a9 | 2013-08-24 07:55:00 +0000 | [diff] [blame] | 422 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 423 | if ((prev_state != OSPF6_INTERFACE_DR && |
| 424 | prev_state != OSPF6_INTERFACE_BDR) && |
| 425 | (next_state == OSPF6_INTERFACE_DR || |
| 426 | next_state == OSPF6_INTERFACE_BDR)) |
Vyacheslav Trushkin | 9a9446e | 2011-11-21 20:26:39 +0400 | [diff] [blame] | 427 | ospf6_sso (oi->interface->ifindex, &alldrouters6, IPV6_JOIN_GROUP); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 428 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 429 | OSPF6_ROUTER_LSA_SCHEDULE (oi->area); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 430 | if (next_state == OSPF6_INTERFACE_DOWN) |
| 431 | { |
| 432 | OSPF6_NETWORK_LSA_EXECUTE (oi); |
| 433 | OSPF6_INTRA_PREFIX_LSA_EXECUTE_TRANSIT (oi); |
| 434 | OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area); |
| 435 | } |
| 436 | else if (prev_state == OSPF6_INTERFACE_DR || |
| 437 | next_state == OSPF6_INTERFACE_DR) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 438 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 439 | OSPF6_NETWORK_LSA_SCHEDULE (oi); |
| 440 | OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi); |
| 441 | OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 442 | } |
Vincent Bernat | bf83666 | 2012-06-04 14:36:12 +0200 | [diff] [blame] | 443 | |
| 444 | #ifdef HAVE_SNMP |
| 445 | /* Terminal state or regression */ |
| 446 | if ((next_state == OSPF6_INTERFACE_POINTTOPOINT) || |
| 447 | (next_state == OSPF6_INTERFACE_DROTHER) || |
| 448 | (next_state == OSPF6_INTERFACE_BDR) || |
| 449 | (next_state == OSPF6_INTERFACE_DR) || |
| 450 | (next_state < prev_state)) |
| 451 | ospf6TrapIfStateChange (oi); |
| 452 | #endif |
| 453 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 454 | } |
| 455 | |
| 456 | |
| 457 | /* DR Election, RFC2328 section 9.4 */ |
| 458 | |
| 459 | #define IS_ELIGIBLE(n) \ |
| 460 | ((n)->state >= OSPF6_NEIGHBOR_TWOWAY && (n)->priority != 0) |
| 461 | |
| 462 | static struct ospf6_neighbor * |
| 463 | better_bdrouter (struct ospf6_neighbor *a, struct ospf6_neighbor *b) |
| 464 | { |
| 465 | if ((a == NULL || ! IS_ELIGIBLE (a) || a->drouter == a->router_id) && |
| 466 | (b == NULL || ! IS_ELIGIBLE (b) || b->drouter == b->router_id)) |
| 467 | return NULL; |
| 468 | else if (a == NULL || ! IS_ELIGIBLE (a) || a->drouter == a->router_id) |
| 469 | return b; |
| 470 | else if (b == NULL || ! IS_ELIGIBLE (b) || b->drouter == b->router_id) |
| 471 | return a; |
| 472 | |
| 473 | if (a->bdrouter == a->router_id && b->bdrouter != b->router_id) |
| 474 | return a; |
| 475 | if (a->bdrouter != a->router_id && b->bdrouter == b->router_id) |
| 476 | return b; |
| 477 | |
| 478 | if (a->priority > b->priority) |
| 479 | return a; |
| 480 | if (a->priority < b->priority) |
| 481 | return b; |
| 482 | |
| 483 | if (ntohl (a->router_id) > ntohl (b->router_id)) |
| 484 | return a; |
| 485 | if (ntohl (a->router_id) < ntohl (b->router_id)) |
| 486 | return b; |
| 487 | |
| 488 | zlog_warn ("Router-ID duplicate ?"); |
| 489 | return a; |
| 490 | } |
| 491 | |
| 492 | static struct ospf6_neighbor * |
| 493 | better_drouter (struct ospf6_neighbor *a, struct ospf6_neighbor *b) |
| 494 | { |
| 495 | if ((a == NULL || ! IS_ELIGIBLE (a) || a->drouter != a->router_id) && |
| 496 | (b == NULL || ! IS_ELIGIBLE (b) || b->drouter != b->router_id)) |
| 497 | return NULL; |
| 498 | else if (a == NULL || ! IS_ELIGIBLE (a) || a->drouter != a->router_id) |
| 499 | return b; |
| 500 | else if (b == NULL || ! IS_ELIGIBLE (b) || b->drouter != b->router_id) |
| 501 | return a; |
| 502 | |
| 503 | if (a->drouter == a->router_id && b->drouter != b->router_id) |
| 504 | return a; |
| 505 | if (a->drouter != a->router_id && b->drouter == b->router_id) |
| 506 | return b; |
| 507 | |
| 508 | if (a->priority > b->priority) |
| 509 | return a; |
| 510 | if (a->priority < b->priority) |
| 511 | return b; |
| 512 | |
| 513 | if (ntohl (a->router_id) > ntohl (b->router_id)) |
| 514 | return a; |
| 515 | if (ntohl (a->router_id) < ntohl (b->router_id)) |
| 516 | return b; |
| 517 | |
| 518 | zlog_warn ("Router-ID duplicate ?"); |
| 519 | return a; |
| 520 | } |
| 521 | |
| 522 | static u_char |
| 523 | dr_election (struct ospf6_interface *oi) |
| 524 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 525 | struct listnode *node, *nnode; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 526 | struct ospf6_neighbor *on, *drouter, *bdrouter, myself; |
| 527 | struct ospf6_neighbor *best_drouter, *best_bdrouter; |
| 528 | u_char next_state = 0; |
| 529 | |
| 530 | drouter = bdrouter = NULL; |
| 531 | best_drouter = best_bdrouter = NULL; |
| 532 | |
| 533 | /* pseudo neighbor myself, including noting current DR/BDR (1) */ |
| 534 | memset (&myself, 0, sizeof (myself)); |
| 535 | inet_ntop (AF_INET, &oi->area->ospf6->router_id, myself.name, |
| 536 | sizeof (myself.name)); |
| 537 | myself.state = OSPF6_NEIGHBOR_TWOWAY; |
| 538 | myself.drouter = oi->drouter; |
| 539 | myself.bdrouter = oi->bdrouter; |
| 540 | myself.priority = oi->priority; |
| 541 | myself.router_id = oi->area->ospf6->router_id; |
| 542 | |
| 543 | /* Electing BDR (2) */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 544 | for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on)) |
| 545 | bdrouter = better_bdrouter (bdrouter, on); |
| 546 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 547 | best_bdrouter = bdrouter; |
| 548 | bdrouter = better_bdrouter (best_bdrouter, &myself); |
| 549 | |
| 550 | /* Electing DR (3) */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 551 | for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on)) |
| 552 | drouter = better_drouter (drouter, on); |
| 553 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 554 | best_drouter = drouter; |
| 555 | drouter = better_drouter (best_drouter, &myself); |
| 556 | if (drouter == NULL) |
| 557 | drouter = bdrouter; |
| 558 | |
| 559 | /* the router itself is newly/no longer DR/BDR (4) */ |
| 560 | if ((drouter == &myself && myself.drouter != myself.router_id) || |
| 561 | (drouter != &myself && myself.drouter == myself.router_id) || |
| 562 | (bdrouter == &myself && myself.bdrouter != myself.router_id) || |
| 563 | (bdrouter != &myself && myself.bdrouter == myself.router_id)) |
| 564 | { |
| 565 | myself.drouter = (drouter ? drouter->router_id : htonl (0)); |
| 566 | myself.bdrouter = (bdrouter ? bdrouter->router_id : htonl (0)); |
| 567 | |
| 568 | /* compatible to Electing BDR (2) */ |
| 569 | bdrouter = better_bdrouter (best_bdrouter, &myself); |
| 570 | |
| 571 | /* compatible to Electing DR (3) */ |
| 572 | drouter = better_drouter (best_drouter, &myself); |
| 573 | if (drouter == NULL) |
| 574 | drouter = bdrouter; |
| 575 | } |
| 576 | |
| 577 | /* Set interface state accordingly (5) */ |
| 578 | if (drouter && drouter == &myself) |
| 579 | next_state = OSPF6_INTERFACE_DR; |
| 580 | else if (bdrouter && bdrouter == &myself) |
| 581 | next_state = OSPF6_INTERFACE_BDR; |
| 582 | else |
| 583 | next_state = OSPF6_INTERFACE_DROTHER; |
| 584 | |
| 585 | /* If NBMA, schedule Start for each neighbor having priority of 0 (6) */ |
| 586 | /* XXX */ |
| 587 | |
| 588 | /* If DR or BDR change, invoke AdjOK? for each neighbor (7) */ |
| 589 | /* RFC 2328 section 12.4. Originating LSAs (3) will be handled |
| 590 | accordingly after AdjOK */ |
| 591 | if (oi->drouter != (drouter ? drouter->router_id : htonl (0)) || |
| 592 | oi->bdrouter != (bdrouter ? bdrouter->router_id : htonl (0))) |
| 593 | { |
| 594 | if (IS_OSPF6_DEBUG_INTERFACE) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 595 | zlog_debug ("DR Election on %s: DR: %s BDR: %s", oi->interface->name, |
| 596 | (drouter ? drouter->name : "0.0.0.0"), |
| 597 | (bdrouter ? bdrouter->name : "0.0.0.0")); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 598 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 599 | for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, node, on)) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 600 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 601 | if (on->state < OSPF6_NEIGHBOR_TWOWAY) |
| 602 | continue; |
| 603 | /* Schedule AdjOK. */ |
| 604 | thread_add_event (master, adj_ok, on, 0); |
| 605 | } |
| 606 | } |
| 607 | |
| 608 | oi->drouter = (drouter ? drouter->router_id : htonl (0)); |
| 609 | oi->bdrouter = (bdrouter ? bdrouter->router_id : htonl (0)); |
| 610 | return next_state; |
| 611 | } |
| 612 | |
| 613 | |
| 614 | /* Interface State Machine */ |
| 615 | int |
| 616 | interface_up (struct thread *thread) |
| 617 | { |
| 618 | struct ospf6_interface *oi; |
| 619 | |
| 620 | oi = (struct ospf6_interface *) THREAD_ARG (thread); |
| 621 | assert (oi && oi->interface); |
| 622 | |
| 623 | if (IS_OSPF6_DEBUG_INTERFACE) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 624 | zlog_debug ("Interface Event %s: [InterfaceUp]", |
| 625 | oi->interface->name); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 626 | |
| 627 | /* check physical interface is up */ |
Dinesh Dutt | e7ad6b2 | 2013-08-24 07:55:57 +0000 | [diff] [blame] | 628 | if (! if_is_operative (oi->interface)) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 629 | { |
| 630 | if (IS_OSPF6_DEBUG_INTERFACE) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 631 | zlog_debug ("Interface %s is down, can't execute [InterfaceUp]", |
| 632 | oi->interface->name); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 633 | return 0; |
| 634 | } |
| 635 | |
| 636 | /* if already enabled, do nothing */ |
| 637 | if (oi->state > OSPF6_INTERFACE_DOWN) |
| 638 | { |
| 639 | if (IS_OSPF6_DEBUG_INTERFACE) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 640 | zlog_debug ("Interface %s already enabled", |
| 641 | oi->interface->name); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 642 | return 0; |
| 643 | } |
| 644 | |
| 645 | /* Join AllSPFRouters */ |
Vyacheslav Trushkin | 9a9446e | 2011-11-21 20:26:39 +0400 | [diff] [blame] | 646 | ospf6_sso (oi->interface->ifindex, &allspfrouters6, IPV6_JOIN_GROUP); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 647 | |
| 648 | /* Update interface route */ |
| 649 | ospf6_interface_connected_route_update (oi->interface); |
| 650 | |
| 651 | /* Schedule Hello */ |
| 652 | if (! CHECK_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE)) |
| 653 | thread_add_event (master, ospf6_hello_send, oi, 0); |
| 654 | |
| 655 | /* decide next interface state */ |
Dinesh Dutt | c5926a9 | 2013-08-24 07:55:00 +0000 | [diff] [blame] | 656 | if ((if_is_pointopoint (oi->interface)) || |
| 657 | (oi->type == OSPF_IFTYPE_POINTOPOINT)) { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 658 | ospf6_interface_state_change (OSPF6_INTERFACE_POINTTOPOINT, oi); |
Dinesh Dutt | c5926a9 | 2013-08-24 07:55:00 +0000 | [diff] [blame] | 659 | } |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 660 | else if (oi->priority == 0) |
| 661 | ospf6_interface_state_change (OSPF6_INTERFACE_DROTHER, oi); |
| 662 | else |
| 663 | { |
| 664 | ospf6_interface_state_change (OSPF6_INTERFACE_WAITING, oi); |
| 665 | thread_add_timer (master, wait_timer, oi, oi->dead_interval); |
| 666 | } |
| 667 | |
| 668 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 669 | } |
| 670 | |
| 671 | int |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 672 | wait_timer (struct thread *thread) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 673 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 674 | struct ospf6_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 675 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 676 | oi = (struct ospf6_interface *) THREAD_ARG (thread); |
| 677 | assert (oi && oi->interface); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 678 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 679 | if (IS_OSPF6_DEBUG_INTERFACE) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 680 | zlog_debug ("Interface Event %s: [WaitTimer]", |
| 681 | oi->interface->name); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 682 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 683 | if (oi->state == OSPF6_INTERFACE_WAITING) |
| 684 | ospf6_interface_state_change (dr_election (oi), oi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 685 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 686 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 687 | } |
| 688 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 689 | int |
| 690 | backup_seen (struct thread *thread) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 691 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 692 | struct ospf6_interface *oi; |
| 693 | |
| 694 | oi = (struct ospf6_interface *) THREAD_ARG (thread); |
| 695 | assert (oi && oi->interface); |
| 696 | |
| 697 | if (IS_OSPF6_DEBUG_INTERFACE) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 698 | zlog_debug ("Interface Event %s: [BackupSeen]", |
| 699 | oi->interface->name); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 700 | |
| 701 | if (oi->state == OSPF6_INTERFACE_WAITING) |
| 702 | ospf6_interface_state_change (dr_election (oi), oi); |
| 703 | |
| 704 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 705 | } |
| 706 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 707 | int |
| 708 | neighbor_change (struct thread *thread) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 709 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 710 | struct ospf6_interface *oi; |
| 711 | |
| 712 | oi = (struct ospf6_interface *) THREAD_ARG (thread); |
| 713 | assert (oi && oi->interface); |
| 714 | |
| 715 | if (IS_OSPF6_DEBUG_INTERFACE) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 716 | zlog_debug ("Interface Event %s: [NeighborChange]", |
| 717 | oi->interface->name); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 718 | |
| 719 | if (oi->state == OSPF6_INTERFACE_DROTHER || |
| 720 | oi->state == OSPF6_INTERFACE_BDR || |
| 721 | oi->state == OSPF6_INTERFACE_DR) |
| 722 | ospf6_interface_state_change (dr_election (oi), oi); |
| 723 | |
| 724 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 725 | } |
| 726 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 727 | int |
| 728 | interface_down (struct thread *thread) |
| 729 | { |
| 730 | struct ospf6_interface *oi; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 731 | struct listnode *node, *nnode; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 732 | struct ospf6_neighbor *on; |
| 733 | |
| 734 | oi = (struct ospf6_interface *) THREAD_ARG (thread); |
| 735 | assert (oi && oi->interface); |
| 736 | |
| 737 | if (IS_OSPF6_DEBUG_INTERFACE) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 738 | zlog_debug ("Interface Event %s: [InterfaceDown]", |
| 739 | oi->interface->name); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 740 | |
| 741 | /* Leave AllSPFRouters */ |
| 742 | if (oi->state > OSPF6_INTERFACE_DOWN) |
Vyacheslav Trushkin | 9a9446e | 2011-11-21 20:26:39 +0400 | [diff] [blame] | 743 | ospf6_sso (oi->interface->ifindex, &allspfrouters6, IPV6_LEAVE_GROUP); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 744 | |
| 745 | ospf6_interface_state_change (OSPF6_INTERFACE_DOWN, oi); |
| 746 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 747 | for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on)) |
| 748 | ospf6_neighbor_delete (on); |
| 749 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 750 | list_delete_all_node (oi->neighbor_list); |
| 751 | |
| 752 | return 0; |
| 753 | } |
| 754 | |
| 755 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 756 | /* show specified interface structure */ |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 757 | static int |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 758 | ospf6_interface_show (struct vty *vty, struct interface *ifp) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 759 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 760 | struct ospf6_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 761 | struct connected *c; |
| 762 | struct prefix *p; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 763 | struct listnode *i; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 764 | char strbuf[64], drouter[32], bdrouter[32]; |
paul | 0c083ee | 2004-10-10 12:54:58 +0000 | [diff] [blame] | 765 | const char *updown[3] = {"down", "up", NULL}; |
| 766 | const char *type; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 767 | struct timeval res, now; |
| 768 | char duration[32]; |
| 769 | struct ospf6_lsa *lsa; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 770 | |
| 771 | /* check physical interface type */ |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 772 | if (if_is_loopback (ifp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 773 | type = "LOOPBACK"; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 774 | else if (if_is_broadcast (ifp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 775 | type = "BROADCAST"; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 776 | else if (if_is_pointopoint (ifp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 777 | type = "POINTOPOINT"; |
| 778 | else |
| 779 | type = "UNKNOWN"; |
| 780 | |
| 781 | vty_out (vty, "%s is %s, type %s%s", |
Dinesh Dutt | e7ad6b2 | 2013-08-24 07:55:57 +0000 | [diff] [blame] | 782 | ifp->name, updown[if_is_operative (ifp)], type, |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 783 | VNL); |
| 784 | vty_out (vty, " Interface ID: %d%s", ifp->ifindex, VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 785 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 786 | if (ifp->info == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 787 | { |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 788 | vty_out (vty, " OSPF not enabled on this interface%s", VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 789 | return 0; |
| 790 | } |
| 791 | else |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 792 | oi = (struct ospf6_interface *) ifp->info; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 793 | |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 794 | vty_out (vty, " Internet Address:%s", VNL); |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 795 | |
| 796 | for (ALL_LIST_ELEMENTS_RO (ifp->connected, i, c)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 797 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 798 | p = c->address; |
| 799 | prefix2str (p, strbuf, sizeof (strbuf)); |
| 800 | switch (p->family) |
| 801 | { |
| 802 | case AF_INET: |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 803 | vty_out (vty, " inet : %s%s", strbuf, |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 804 | VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 805 | break; |
| 806 | case AF_INET6: |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 807 | vty_out (vty, " inet6: %s%s", strbuf, |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 808 | VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 809 | break; |
| 810 | default: |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 811 | vty_out (vty, " ??? : %s%s", strbuf, |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 812 | VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 813 | break; |
| 814 | } |
| 815 | } |
| 816 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 817 | if (oi->area) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 818 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 819 | vty_out (vty, " Instance ID %d, Interface MTU %d (autodetect: %d)%s", |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 820 | oi->instance_id, oi->ifmtu, ifp->mtu6, VNL); |
Dmitrij Tejblum | d42306d | 2011-04-22 19:27:54 +0400 | [diff] [blame] | 821 | vty_out (vty, " MTU mismatch detection: %s%s", oi->mtu_ignore ? |
| 822 | "disabled" : "enabled", VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 823 | inet_ntop (AF_INET, &oi->area->area_id, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 824 | strbuf, sizeof (strbuf)); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 825 | vty_out (vty, " Area ID %s, Cost %hu%s", strbuf, oi->cost, |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 826 | VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 827 | } |
| 828 | else |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 829 | vty_out (vty, " Not Attached to Area%s", VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 830 | |
| 831 | vty_out (vty, " State %s, Transmit Delay %d sec, Priority %d%s", |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 832 | ospf6_interface_state_str[oi->state], |
| 833 | oi->transdelay, oi->priority, |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 834 | VNL); |
| 835 | vty_out (vty, " Timer intervals configured:%s", VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 836 | vty_out (vty, " Hello %d, Dead %d, Retransmit %d%s", |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 837 | oi->hello_interval, oi->dead_interval, oi->rxmt_interval, |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 838 | VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 839 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 840 | inet_ntop (AF_INET, &oi->drouter, drouter, sizeof (drouter)); |
| 841 | inet_ntop (AF_INET, &oi->bdrouter, bdrouter, sizeof (bdrouter)); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 842 | vty_out (vty, " DR: %s BDR: %s%s", drouter, bdrouter, VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 843 | |
| 844 | vty_out (vty, " Number of I/F scoped LSAs is %u%s", |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 845 | oi->lsdb->count, VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 846 | |
Takashi Sogabe | 86f72dc | 2009-06-22 13:07:02 +0900 | [diff] [blame] | 847 | quagga_gettime (QUAGGA_CLK_MONOTONIC, &now); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 848 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 849 | timerclear (&res); |
| 850 | if (oi->thread_send_lsupdate) |
| 851 | timersub (&oi->thread_send_lsupdate->u.sands, &now, &res); |
| 852 | timerstring (&res, duration, sizeof (duration)); |
| 853 | vty_out (vty, " %d Pending LSAs for LSUpdate in Time %s [thread %s]%s", |
| 854 | oi->lsupdate_list->count, duration, |
| 855 | (oi->thread_send_lsupdate ? "on" : "off"), |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 856 | VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 857 | for (lsa = ospf6_lsdb_head (oi->lsupdate_list); lsa; |
| 858 | lsa = ospf6_lsdb_next (lsa)) |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 859 | vty_out (vty, " %s%s", lsa->name, VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 860 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 861 | timerclear (&res); |
| 862 | if (oi->thread_send_lsack) |
| 863 | timersub (&oi->thread_send_lsack->u.sands, &now, &res); |
| 864 | timerstring (&res, duration, sizeof (duration)); |
| 865 | vty_out (vty, " %d Pending LSAs for LSAck in Time %s [thread %s]%s", |
| 866 | oi->lsack_list->count, duration, |
| 867 | (oi->thread_send_lsack ? "on" : "off"), |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 868 | VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 869 | for (lsa = ospf6_lsdb_head (oi->lsack_list); lsa; |
| 870 | lsa = ospf6_lsdb_next (lsa)) |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 871 | vty_out (vty, " %s%s", lsa->name, VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 872 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 873 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 874 | } |
| 875 | |
| 876 | /* show interface */ |
| 877 | DEFUN (show_ipv6_ospf6_interface, |
| 878 | show_ipv6_ospf6_interface_ifname_cmd, |
| 879 | "show ipv6 ospf6 interface IFNAME", |
| 880 | SHOW_STR |
| 881 | IP6_STR |
| 882 | OSPF6_STR |
| 883 | INTERFACE_STR |
| 884 | IFNAME_STR |
| 885 | ) |
| 886 | { |
| 887 | struct interface *ifp; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 888 | struct listnode *i; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 889 | |
| 890 | if (argc) |
| 891 | { |
| 892 | ifp = if_lookup_by_name (argv[0]); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 893 | if (ifp == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 894 | { |
| 895 | vty_out (vty, "No such Interface: %s%s", argv[0], |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 896 | VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 897 | return CMD_WARNING; |
| 898 | } |
| 899 | ospf6_interface_show (vty, ifp); |
| 900 | } |
| 901 | else |
| 902 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 903 | for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp)) |
| 904 | ospf6_interface_show (vty, ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 905 | } |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 906 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 907 | return CMD_SUCCESS; |
| 908 | } |
| 909 | |
| 910 | ALIAS (show_ipv6_ospf6_interface, |
| 911 | show_ipv6_ospf6_interface_cmd, |
| 912 | "show ipv6 ospf6 interface", |
| 913 | SHOW_STR |
| 914 | IP6_STR |
| 915 | OSPF6_STR |
| 916 | INTERFACE_STR |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 917 | ) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 918 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 919 | DEFUN (show_ipv6_ospf6_interface_ifname_prefix, |
| 920 | show_ipv6_ospf6_interface_ifname_prefix_cmd, |
| 921 | "show ipv6 ospf6 interface IFNAME prefix", |
| 922 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 923 | IP6_STR |
| 924 | OSPF6_STR |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 925 | INTERFACE_STR |
| 926 | IFNAME_STR |
| 927 | "Display connected prefixes to advertise\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 928 | ) |
| 929 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 930 | struct interface *ifp; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 931 | struct ospf6_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 932 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 933 | ifp = if_lookup_by_name (argv[0]); |
| 934 | if (ifp == NULL) |
| 935 | { |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 936 | vty_out (vty, "No such Interface: %s%s", argv[0], VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 937 | return CMD_WARNING; |
| 938 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 939 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 940 | oi = ifp->info; |
| 941 | if (oi == NULL) |
| 942 | { |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 943 | vty_out (vty, "OSPFv3 is not enabled on %s%s", argv[0], VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 944 | return CMD_WARNING; |
| 945 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 946 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 947 | argc--; |
| 948 | argv++; |
| 949 | ospf6_route_table_show (vty, argc, argv, oi->route_connected); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 950 | |
| 951 | return CMD_SUCCESS; |
| 952 | } |
| 953 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 954 | ALIAS (show_ipv6_ospf6_interface_ifname_prefix, |
| 955 | show_ipv6_ospf6_interface_ifname_prefix_detail_cmd, |
| 956 | "show ipv6 ospf6 interface IFNAME prefix (X:X::X:X|X:X::X:X/M|detail)", |
| 957 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 958 | IP6_STR |
| 959 | OSPF6_STR |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 960 | INTERFACE_STR |
| 961 | IFNAME_STR |
| 962 | "Display connected prefixes to advertise\n" |
| 963 | OSPF6_ROUTE_ADDRESS_STR |
| 964 | OSPF6_ROUTE_PREFIX_STR |
Denis Ovsienko | ea40219 | 2011-08-19 16:27:16 +0400 | [diff] [blame] | 965 | "Display details of the prefixes\n" |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 966 | ) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 967 | |
| 968 | ALIAS (show_ipv6_ospf6_interface_ifname_prefix, |
| 969 | show_ipv6_ospf6_interface_ifname_prefix_match_cmd, |
| 970 | "show ipv6 ospf6 interface IFNAME prefix X:X::X:X/M (match|detail)", |
| 971 | SHOW_STR |
| 972 | IP6_STR |
| 973 | OSPF6_STR |
| 974 | INTERFACE_STR |
| 975 | IFNAME_STR |
| 976 | "Display connected prefixes to advertise\n" |
| 977 | OSPF6_ROUTE_PREFIX_STR |
| 978 | OSPF6_ROUTE_MATCH_STR |
Denis Ovsienko | ea40219 | 2011-08-19 16:27:16 +0400 | [diff] [blame] | 979 | "Display details of the prefixes\n" |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 980 | ) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 981 | |
| 982 | DEFUN (show_ipv6_ospf6_interface_prefix, |
| 983 | show_ipv6_ospf6_interface_prefix_cmd, |
| 984 | "show ipv6 ospf6 interface prefix", |
| 985 | SHOW_STR |
| 986 | IP6_STR |
| 987 | OSPF6_STR |
| 988 | INTERFACE_STR |
| 989 | "Display connected prefixes to advertise\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 990 | ) |
| 991 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 992 | struct listnode *i; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 993 | struct ospf6_interface *oi; |
| 994 | struct interface *ifp; |
| 995 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 996 | for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp)) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 997 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 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 |
Denis Ovsienko | ea40219 | 2011-08-19 16:27:16 +0400 | [diff] [blame] | 1018 | "Display details of the prefixes\n" |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 1019 | ) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 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 |
Denis Ovsienko | ea40219 | 2011-08-19 16:27:16 +0400 | [diff] [blame] | 1031 | "Display details of the prefixes\n" |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 1032 | ) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 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; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1048 | struct listnode *node, *nnode; |
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 */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1087 | for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on)) |
hasso | b596c71 | 2004-07-09 18:33:43 +0000 | [diff] [blame] | 1088 | { |
hasso | b596c71 | 2004-07-09 18:33:43 +0000 | [diff] [blame] | 1089 | THREAD_OFF (on->inactivity_timer); |
hasso | 3e834b1 | 2005-06-24 07:50:12 +0000 | [diff] [blame] | 1090 | thread_add_event (master, inactivity_timer, on, 0); |
hasso | b596c71 | 2004-07-09 18:33:43 +0000 | [diff] [blame] | 1091 | } |
| 1092 | |
| 1093 | return CMD_SUCCESS; |
| 1094 | } |
| 1095 | |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 1096 | DEFUN (no_ipv6_ospf6_ifmtu, |
| 1097 | no_ipv6_ospf6_ifmtu_cmd, |
| 1098 | "no ipv6 ospf6 ifmtu", |
| 1099 | NO_STR |
| 1100 | IP6_STR |
| 1101 | OSPF6_STR |
| 1102 | "Interface MTU\n" |
| 1103 | ) |
| 1104 | { |
| 1105 | struct ospf6_interface *oi; |
| 1106 | struct interface *ifp; |
paul | 0c083ee | 2004-10-10 12:54:58 +0000 | [diff] [blame] | 1107 | unsigned int iobuflen; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1108 | struct listnode *node, *nnode; |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 1109 | struct ospf6_neighbor *on; |
| 1110 | |
| 1111 | ifp = (struct interface *) vty->index; |
| 1112 | assert (ifp); |
| 1113 | |
| 1114 | oi = (struct ospf6_interface *) ifp->info; |
| 1115 | if (oi == NULL) |
| 1116 | oi = ospf6_interface_create (ifp); |
| 1117 | assert (oi); |
| 1118 | |
| 1119 | if (oi->ifmtu < ifp->mtu) |
| 1120 | { |
| 1121 | iobuflen = ospf6_iobuf_size (ifp->mtu); |
| 1122 | if (iobuflen < ifp->mtu) |
| 1123 | { |
| 1124 | vty_out (vty, "%s's ifmtu is adjusted to I/O buffer size (%d).%s", |
| 1125 | ifp->name, iobuflen, VNL); |
| 1126 | oi->ifmtu = iobuflen; |
| 1127 | } |
| 1128 | else |
| 1129 | oi->ifmtu = ifp->mtu; |
| 1130 | } |
| 1131 | else |
| 1132 | oi->ifmtu = ifp->mtu; |
| 1133 | |
| 1134 | /* re-establish adjacencies */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1135 | for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on)) |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 1136 | { |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 1137 | THREAD_OFF (on->inactivity_timer); |
hasso | 3e834b1 | 2005-06-24 07:50:12 +0000 | [diff] [blame] | 1138 | thread_add_event (master, inactivity_timer, on, 0); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 1139 | } |
| 1140 | |
| 1141 | return CMD_SUCCESS; |
| 1142 | } |
| 1143 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1144 | DEFUN (ipv6_ospf6_cost, |
| 1145 | ipv6_ospf6_cost_cmd, |
| 1146 | "ipv6 ospf6 cost <1-65535>", |
| 1147 | IP6_STR |
| 1148 | OSPF6_STR |
| 1149 | "Interface cost\n" |
| 1150 | "Outgoing metric of this interface\n" |
| 1151 | ) |
| 1152 | { |
| 1153 | struct ospf6_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1154 | struct interface *ifp; |
paul | 0c083ee | 2004-10-10 12:54:58 +0000 | [diff] [blame] | 1155 | unsigned long int lcost; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1156 | |
| 1157 | ifp = (struct interface *) vty->index; |
| 1158 | assert (ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1159 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1160 | oi = (struct ospf6_interface *) ifp->info; |
| 1161 | if (oi == NULL) |
| 1162 | oi = ospf6_interface_create (ifp); |
| 1163 | assert (oi); |
| 1164 | |
paul | 0c083ee | 2004-10-10 12:54:58 +0000 | [diff] [blame] | 1165 | lcost = strtol (argv[0], NULL, 10); |
| 1166 | |
| 1167 | if (lcost > UINT32_MAX) |
| 1168 | { |
| 1169 | vty_out (vty, "Cost %ld is out of range%s", lcost, VNL); |
| 1170 | return CMD_WARNING; |
| 1171 | } |
| 1172 | |
| 1173 | if (oi->cost == lcost) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1174 | return CMD_SUCCESS; |
paul | 0c083ee | 2004-10-10 12:54:58 +0000 | [diff] [blame] | 1175 | |
| 1176 | oi->cost = lcost; |
| 1177 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 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; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1356 | struct listnode *node, *nnode; |
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 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1370 | for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1371 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1372 | THREAD_OFF (on->inactivity_timer); |
hasso | 3e834b1 | 2005-06-24 07:50:12 +0000 | [diff] [blame] | 1373 | thread_add_event (master, inactivity_timer, on, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1374 | } |
| 1375 | |
| 1376 | return CMD_SUCCESS; |
| 1377 | } |
| 1378 | |
| 1379 | DEFUN (no_ipv6_ospf6_passive, |
| 1380 | no_ipv6_ospf6_passive_cmd, |
| 1381 | "no ipv6 ospf6 passive", |
| 1382 | NO_STR |
| 1383 | IP6_STR |
| 1384 | OSPF6_STR |
| 1385 | "passive interface: No Adjacency will be formed on this I/F\n" |
| 1386 | ) |
| 1387 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1388 | struct ospf6_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1389 | struct interface *ifp; |
| 1390 | |
| 1391 | ifp = (struct interface *) vty->index; |
| 1392 | assert (ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1393 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1394 | oi = (struct ospf6_interface *) ifp->info; |
| 1395 | if (oi == NULL) |
| 1396 | oi = ospf6_interface_create (ifp); |
| 1397 | assert (oi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1398 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1399 | UNSET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE); |
| 1400 | THREAD_OFF (oi->thread_send_hello); |
| 1401 | oi->thread_send_hello = |
| 1402 | thread_add_event (master, ospf6_hello_send, oi, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1403 | |
| 1404 | return CMD_SUCCESS; |
| 1405 | } |
| 1406 | |
Dmitrij Tejblum | d42306d | 2011-04-22 19:27:54 +0400 | [diff] [blame] | 1407 | DEFUN (ipv6_ospf6_mtu_ignore, |
| 1408 | ipv6_ospf6_mtu_ignore_cmd, |
| 1409 | "ipv6 ospf6 mtu-ignore", |
| 1410 | IP6_STR |
| 1411 | OSPF6_STR |
| 1412 | "Ignore MTU mismatch on this interface\n" |
| 1413 | ) |
| 1414 | { |
| 1415 | struct ospf6_interface *oi; |
| 1416 | struct interface *ifp; |
| 1417 | |
| 1418 | ifp = (struct interface *) vty->index; |
| 1419 | assert (ifp); |
| 1420 | |
| 1421 | oi = (struct ospf6_interface *) ifp->info; |
| 1422 | if (oi == NULL) |
| 1423 | oi = ospf6_interface_create (ifp); |
| 1424 | assert (oi); |
| 1425 | |
| 1426 | oi->mtu_ignore = 1; |
| 1427 | |
| 1428 | return CMD_SUCCESS; |
| 1429 | } |
| 1430 | |
| 1431 | DEFUN (no_ipv6_ospf6_mtu_ignore, |
| 1432 | no_ipv6_ospf6_mtu_ignore_cmd, |
| 1433 | "no ipv6 ospf6 mtu-ignore", |
| 1434 | NO_STR |
| 1435 | IP6_STR |
| 1436 | OSPF6_STR |
| 1437 | "Ignore MTU mismatch on this interface\n" |
| 1438 | ) |
| 1439 | { |
| 1440 | struct ospf6_interface *oi; |
| 1441 | struct interface *ifp; |
| 1442 | |
| 1443 | ifp = (struct interface *) vty->index; |
| 1444 | assert (ifp); |
| 1445 | |
| 1446 | oi = (struct ospf6_interface *) ifp->info; |
| 1447 | if (oi == NULL) |
| 1448 | oi = ospf6_interface_create (ifp); |
| 1449 | assert (oi); |
| 1450 | |
| 1451 | oi->mtu_ignore = 0; |
| 1452 | |
| 1453 | return CMD_SUCCESS; |
| 1454 | } |
| 1455 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1456 | DEFUN (ipv6_ospf6_advertise_prefix_list, |
| 1457 | ipv6_ospf6_advertise_prefix_list_cmd, |
| 1458 | "ipv6 ospf6 advertise prefix-list WORD", |
| 1459 | IP6_STR |
| 1460 | OSPF6_STR |
| 1461 | "Advertising options\n" |
| 1462 | "Filter prefix using prefix-list\n" |
| 1463 | "Prefix list name\n" |
| 1464 | ) |
| 1465 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1466 | struct ospf6_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1467 | struct interface *ifp; |
| 1468 | |
| 1469 | ifp = (struct interface *) vty->index; |
| 1470 | assert (ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1471 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1472 | oi = (struct ospf6_interface *) ifp->info; |
| 1473 | if (oi == NULL) |
| 1474 | oi = ospf6_interface_create (ifp); |
| 1475 | assert (oi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1476 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1477 | if (oi->plist_name) |
| 1478 | XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name); |
| 1479 | oi->plist_name = XSTRDUP (MTYPE_PREFIX_LIST_STR, argv[0]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1480 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1481 | ospf6_interface_connected_route_update (oi->interface); |
David Ward | 2470e99 | 2010-01-05 02:45:39 +0000 | [diff] [blame] | 1482 | |
| 1483 | if (oi->area) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1484 | { |
David Ward | 2470e99 | 2010-01-05 02:45:39 +0000 | [diff] [blame] | 1485 | OSPF6_LINK_LSA_SCHEDULE (oi); |
| 1486 | if (oi->state == OSPF6_INTERFACE_DR) |
| 1487 | { |
| 1488 | OSPF6_NETWORK_LSA_SCHEDULE (oi); |
| 1489 | OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi); |
| 1490 | } |
| 1491 | OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1492 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1493 | |
| 1494 | return CMD_SUCCESS; |
| 1495 | } |
| 1496 | |
| 1497 | DEFUN (no_ipv6_ospf6_advertise_prefix_list, |
| 1498 | no_ipv6_ospf6_advertise_prefix_list_cmd, |
| 1499 | "no ipv6 ospf6 advertise prefix-list", |
| 1500 | NO_STR |
| 1501 | IP6_STR |
| 1502 | OSPF6_STR |
| 1503 | "Advertising options\n" |
| 1504 | "Filter prefix using prefix-list\n" |
| 1505 | ) |
| 1506 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1507 | struct ospf6_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1508 | struct interface *ifp; |
| 1509 | |
| 1510 | ifp = (struct interface *) vty->index; |
| 1511 | assert (ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1512 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1513 | oi = (struct ospf6_interface *) ifp->info; |
| 1514 | if (oi == NULL) |
| 1515 | oi = ospf6_interface_create (ifp); |
| 1516 | assert (oi); |
| 1517 | |
| 1518 | if (oi->plist_name) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1519 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1520 | XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name); |
| 1521 | oi->plist_name = NULL; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1522 | } |
| 1523 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1524 | ospf6_interface_connected_route_update (oi->interface); |
David Ward | 2470e99 | 2010-01-05 02:45:39 +0000 | [diff] [blame] | 1525 | |
| 1526 | if (oi->area) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1527 | { |
David Ward | 2470e99 | 2010-01-05 02:45:39 +0000 | [diff] [blame] | 1528 | OSPF6_LINK_LSA_SCHEDULE (oi); |
| 1529 | if (oi->state == OSPF6_INTERFACE_DR) |
| 1530 | { |
| 1531 | OSPF6_NETWORK_LSA_SCHEDULE (oi); |
| 1532 | OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi); |
| 1533 | } |
| 1534 | OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1535 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1536 | |
| 1537 | return CMD_SUCCESS; |
| 1538 | } |
| 1539 | |
Dinesh Dutt | c5926a9 | 2013-08-24 07:55:00 +0000 | [diff] [blame] | 1540 | DEFUN (ipv6_ospf6_network, |
| 1541 | ipv6_ospf6_network_cmd, |
| 1542 | "ipv6 ospf6 network (broadcast|point-to-point)", |
| 1543 | IP6_STR |
| 1544 | OSPF6_STR |
| 1545 | "Network Type\n" |
| 1546 | "Specify OSPFv6 broadcast network\n" |
| 1547 | "Specify OSPF6 point-to-point network\n" |
| 1548 | ) |
| 1549 | { |
| 1550 | struct ospf6_interface *oi; |
| 1551 | struct interface *ifp; |
| 1552 | |
| 1553 | ifp = (struct interface *) vty->index; |
| 1554 | assert (ifp); |
| 1555 | |
| 1556 | oi = (struct ospf6_interface *) ifp->info; |
| 1557 | if (oi == NULL) { |
| 1558 | oi = ospf6_interface_create (ifp); |
| 1559 | } |
| 1560 | assert (oi); |
| 1561 | |
| 1562 | if (strncmp (argv[0], "b", 1) == 0) |
| 1563 | { |
| 1564 | if (oi->type == OSPF_IFTYPE_BROADCAST) |
| 1565 | return CMD_SUCCESS; |
| 1566 | |
| 1567 | oi->type = OSPF_IFTYPE_BROADCAST; |
| 1568 | } |
| 1569 | else if (strncmp (argv[0], "point-to-p", 10) == 0) |
| 1570 | { |
| 1571 | if (oi->type == OSPF_IFTYPE_POINTOPOINT) { |
| 1572 | return CMD_SUCCESS; |
| 1573 | } |
| 1574 | oi->type = OSPF_IFTYPE_POINTOPOINT; |
| 1575 | } |
| 1576 | |
| 1577 | /* Reset the interface */ |
| 1578 | thread_add_event (master, interface_down, oi, 0); |
| 1579 | thread_add_event (master, interface_up, oi, 0); |
| 1580 | |
| 1581 | return CMD_SUCCESS; |
| 1582 | } |
| 1583 | |
| 1584 | DEFUN (no_ipv6_ospf6_network, |
| 1585 | no_ipv6_ospf6_network_cmd, |
| 1586 | "no ipv6 ospf6 network", |
| 1587 | NO_STR |
| 1588 | IP6_STR |
| 1589 | OSPF6_STR |
| 1590 | "Network Type\n" |
| 1591 | "Default to whatever interface type system specifies" |
| 1592 | ) |
| 1593 | { |
| 1594 | struct ospf6_interface *oi; |
| 1595 | struct interface *ifp; |
| 1596 | int type; |
| 1597 | |
| 1598 | ifp = (struct interface *) vty->index; |
| 1599 | assert (ifp); |
| 1600 | |
| 1601 | oi = (struct ospf6_interface *) ifp->info; |
| 1602 | if (oi == NULL) { |
| 1603 | return CMD_SUCCESS; |
| 1604 | } |
| 1605 | |
| 1606 | type = ospf6_default_iftype (ifp); |
| 1607 | if (oi->type == type) |
| 1608 | { |
| 1609 | return CMD_SUCCESS; |
| 1610 | } |
| 1611 | oi->type = type; |
| 1612 | |
| 1613 | /* Reset the interface */ |
| 1614 | thread_add_event (master, interface_down, oi, 0); |
| 1615 | thread_add_event (master, interface_up, oi, 0); |
| 1616 | |
| 1617 | return CMD_SUCCESS; |
| 1618 | } |
| 1619 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 1620 | static int |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1621 | config_write_ospf6_interface (struct vty *vty) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1622 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 1623 | struct listnode *i; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1624 | struct ospf6_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1625 | struct interface *ifp; |
| 1626 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1627 | for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1628 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1629 | oi = (struct ospf6_interface *) ifp->info; |
| 1630 | if (oi == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1631 | continue; |
| 1632 | |
| 1633 | vty_out (vty, "interface %s%s", |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 1634 | oi->interface->name, VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1635 | |
| 1636 | if (ifp->desc) |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 1637 | vty_out (vty, " description %s%s", ifp->desc, VNL); |
hasso | 1203e1c | 2004-07-23 21:34:27 +0000 | [diff] [blame] | 1638 | if (ifp->mtu6 != oi->ifmtu) |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 1639 | vty_out (vty, " ipv6 ospf6 ifmtu %d%s", oi->ifmtu, VNL); |
Vyacheslav Trushkin | b51a3a3 | 2012-02-10 10:42:45 +0400 | [diff] [blame] | 1640 | |
| 1641 | if (oi->cost != OSPF6_INTERFACE_COST) |
| 1642 | vty_out (vty, " ipv6 ospf6 cost %d%s", |
| 1643 | oi->cost, VNL); |
| 1644 | |
| 1645 | if (oi->hello_interval != OSPF6_INTERFACE_HELLO_INTERVAL) |
| 1646 | vty_out (vty, " ipv6 ospf6 hello-interval %d%s", |
| 1647 | oi->hello_interval, VNL); |
| 1648 | |
| 1649 | if (oi->dead_interval != OSPF6_INTERFACE_DEAD_INTERVAL) |
| 1650 | vty_out (vty, " ipv6 ospf6 dead-interval %d%s", |
| 1651 | oi->dead_interval, VNL); |
| 1652 | |
| 1653 | if (oi->rxmt_interval != OSPF6_INTERFACE_RXMT_INTERVAL) |
| 1654 | vty_out (vty, " ipv6 ospf6 retransmit-interval %d%s", |
| 1655 | oi->rxmt_interval, VNL); |
| 1656 | |
| 1657 | if (oi->priority != OSPF6_INTERFACE_PRIORITY) |
| 1658 | vty_out (vty, " ipv6 ospf6 priority %d%s", |
| 1659 | oi->priority, VNL); |
| 1660 | |
| 1661 | if (oi->transdelay != OSPF6_INTERFACE_TRANSDELAY) |
| 1662 | vty_out (vty, " ipv6 ospf6 transmit-delay %d%s", |
| 1663 | oi->transdelay, VNL); |
| 1664 | |
| 1665 | if (oi->instance_id != OSPF6_INTERFACE_INSTANCE_ID) |
| 1666 | vty_out (vty, " ipv6 ospf6 instance-id %d%s", |
| 1667 | oi->instance_id, VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1668 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1669 | if (oi->plist_name) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1670 | vty_out (vty, " ipv6 ospf6 advertise prefix-list %s%s", |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 1671 | oi->plist_name, VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1672 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1673 | if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE)) |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 1674 | vty_out (vty, " ipv6 ospf6 passive%s", VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1675 | |
Dmitrij Tejblum | d42306d | 2011-04-22 19:27:54 +0400 | [diff] [blame] | 1676 | if (oi->mtu_ignore) |
| 1677 | vty_out (vty, " ipv6 ospf6 mtu-ignore%s", VNL); |
| 1678 | |
Dinesh Dutt | c5926a9 | 2013-08-24 07:55:00 +0000 | [diff] [blame] | 1679 | if (oi->type == OSPF_IFTYPE_POINTOPOINT) |
| 1680 | vty_out (vty, " ipv6 ospf6 network point-to-point%s", VNL); |
| 1681 | else if (oi->type == OSPF_IFTYPE_BROADCAST) |
| 1682 | vty_out (vty, " ipv6 ospf6 network broadcast%s", VNL); |
| 1683 | |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 1684 | vty_out (vty, "!%s", VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1685 | } |
| 1686 | return 0; |
| 1687 | } |
| 1688 | |
Stephen Hemminger | 7fc626d | 2008-12-01 11:10:34 -0800 | [diff] [blame] | 1689 | static struct cmd_node interface_node = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1690 | { |
| 1691 | INTERFACE_NODE, |
| 1692 | "%s(config-if)# ", |
hasso | 69b4a81 | 2004-08-26 18:10:36 +0000 | [diff] [blame] | 1693 | 1 /* VTYSH */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1694 | }; |
| 1695 | |
| 1696 | void |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 1697 | ospf6_interface_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1698 | { |
| 1699 | /* Install interface node. */ |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1700 | install_node (&interface_node, config_write_ospf6_interface); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1701 | |
| 1702 | install_element (VIEW_NODE, &show_ipv6_ospf6_interface_cmd); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1703 | install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_cmd); |
| 1704 | install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_detail_cmd); |
| 1705 | install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_match_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1706 | install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_cmd); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1707 | install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_cmd); |
| 1708 | install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd); |
| 1709 | install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1710 | install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_cmd); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1711 | install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_cmd); |
| 1712 | install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_detail_cmd); |
| 1713 | install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_match_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1714 | install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_cmd); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1715 | install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_cmd); |
| 1716 | install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd); |
| 1717 | install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1718 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1719 | install_element (CONFIG_NODE, &interface_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1720 | install_default (INTERFACE_NODE); |
| 1721 | install_element (INTERFACE_NODE, &interface_desc_cmd); |
| 1722 | install_element (INTERFACE_NODE, &no_interface_desc_cmd); |
| 1723 | install_element (INTERFACE_NODE, &ipv6_ospf6_cost_cmd); |
hasso | b596c71 | 2004-07-09 18:33:43 +0000 | [diff] [blame] | 1724 | install_element (INTERFACE_NODE, &ipv6_ospf6_ifmtu_cmd); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 1725 | install_element (INTERFACE_NODE, &no_ipv6_ospf6_ifmtu_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1726 | install_element (INTERFACE_NODE, &ipv6_ospf6_deadinterval_cmd); |
| 1727 | install_element (INTERFACE_NODE, &ipv6_ospf6_hellointerval_cmd); |
| 1728 | install_element (INTERFACE_NODE, &ipv6_ospf6_priority_cmd); |
| 1729 | install_element (INTERFACE_NODE, &ipv6_ospf6_retransmitinterval_cmd); |
| 1730 | install_element (INTERFACE_NODE, &ipv6_ospf6_transmitdelay_cmd); |
| 1731 | install_element (INTERFACE_NODE, &ipv6_ospf6_instance_cmd); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1732 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1733 | install_element (INTERFACE_NODE, &ipv6_ospf6_passive_cmd); |
| 1734 | install_element (INTERFACE_NODE, &no_ipv6_ospf6_passive_cmd); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1735 | |
Dmitrij Tejblum | d42306d | 2011-04-22 19:27:54 +0400 | [diff] [blame] | 1736 | install_element (INTERFACE_NODE, &ipv6_ospf6_mtu_ignore_cmd); |
| 1737 | install_element (INTERFACE_NODE, &no_ipv6_ospf6_mtu_ignore_cmd); |
| 1738 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1739 | install_element (INTERFACE_NODE, &ipv6_ospf6_advertise_prefix_list_cmd); |
| 1740 | install_element (INTERFACE_NODE, &no_ipv6_ospf6_advertise_prefix_list_cmd); |
Dinesh Dutt | c5926a9 | 2013-08-24 07:55:00 +0000 | [diff] [blame] | 1741 | |
| 1742 | install_element (INTERFACE_NODE, &ipv6_ospf6_network_cmd); |
| 1743 | install_element (INTERFACE_NODE, &no_ipv6_ospf6_network_cmd); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1744 | } |
| 1745 | |
| 1746 | DEFUN (debug_ospf6_interface, |
| 1747 | debug_ospf6_interface_cmd, |
| 1748 | "debug ospf6 interface", |
| 1749 | DEBUG_STR |
| 1750 | OSPF6_STR |
| 1751 | "Debug OSPFv3 Interface\n" |
| 1752 | ) |
| 1753 | { |
| 1754 | OSPF6_DEBUG_INTERFACE_ON (); |
| 1755 | return CMD_SUCCESS; |
| 1756 | } |
| 1757 | |
| 1758 | DEFUN (no_debug_ospf6_interface, |
| 1759 | no_debug_ospf6_interface_cmd, |
| 1760 | "no debug ospf6 interface", |
| 1761 | NO_STR |
| 1762 | DEBUG_STR |
| 1763 | OSPF6_STR |
| 1764 | "Debug OSPFv3 Interface\n" |
| 1765 | ) |
| 1766 | { |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 1767 | OSPF6_DEBUG_INTERFACE_OFF (); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1768 | return CMD_SUCCESS; |
| 1769 | } |
| 1770 | |
| 1771 | int |
| 1772 | config_write_ospf6_debug_interface (struct vty *vty) |
| 1773 | { |
| 1774 | if (IS_OSPF6_DEBUG_INTERFACE) |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 1775 | vty_out (vty, "debug ospf6 interface%s", VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1776 | return 0; |
| 1777 | } |
| 1778 | |
| 1779 | void |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 1780 | install_element_ospf6_debug_interface (void) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1781 | { |
| 1782 | install_element (ENABLE_NODE, &debug_ospf6_interface_cmd); |
| 1783 | install_element (ENABLE_NODE, &no_debug_ospf6_interface_cmd); |
| 1784 | install_element (CONFIG_NODE, &debug_ospf6_interface_cmd); |
| 1785 | install_element (CONFIG_NODE, &no_debug_ospf6_interface_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1786 | } |
| 1787 | |
| 1788 | |