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