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 | |
| 657 | /* Join AllSPFRouters */ |
Vyacheslav Trushkin | 9a9446e | 2011-11-21 20:26:39 +0400 | [diff] [blame] | 658 | ospf6_sso (oi->interface->ifindex, &allspfrouters6, IPV6_JOIN_GROUP); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 659 | |
| 660 | /* Update interface route */ |
| 661 | ospf6_interface_connected_route_update (oi->interface); |
| 662 | |
| 663 | /* Schedule Hello */ |
| 664 | if (! CHECK_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE)) |
| 665 | thread_add_event (master, ospf6_hello_send, oi, 0); |
| 666 | |
| 667 | /* decide next interface state */ |
Dinesh Dutt | c5926a9 | 2013-08-24 07:55:00 +0000 | [diff] [blame] | 668 | if ((if_is_pointopoint (oi->interface)) || |
| 669 | (oi->type == OSPF_IFTYPE_POINTOPOINT)) { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 670 | ospf6_interface_state_change (OSPF6_INTERFACE_POINTTOPOINT, oi); |
Dinesh Dutt | c5926a9 | 2013-08-24 07:55:00 +0000 | [diff] [blame] | 671 | } |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 672 | else if (oi->priority == 0) |
| 673 | ospf6_interface_state_change (OSPF6_INTERFACE_DROTHER, oi); |
| 674 | else |
| 675 | { |
| 676 | ospf6_interface_state_change (OSPF6_INTERFACE_WAITING, oi); |
| 677 | thread_add_timer (master, wait_timer, oi, oi->dead_interval); |
| 678 | } |
| 679 | |
| 680 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 681 | } |
| 682 | |
| 683 | int |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 684 | wait_timer (struct thread *thread) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 685 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 686 | struct ospf6_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 687 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 688 | oi = (struct ospf6_interface *) THREAD_ARG (thread); |
| 689 | assert (oi && oi->interface); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 690 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 691 | if (IS_OSPF6_DEBUG_INTERFACE) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 692 | zlog_debug ("Interface Event %s: [WaitTimer]", |
| 693 | oi->interface->name); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 694 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 695 | if (oi->state == OSPF6_INTERFACE_WAITING) |
| 696 | ospf6_interface_state_change (dr_election (oi), oi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 697 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 698 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 699 | } |
| 700 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 701 | int |
| 702 | backup_seen (struct thread *thread) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 703 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 704 | struct ospf6_interface *oi; |
| 705 | |
| 706 | oi = (struct ospf6_interface *) THREAD_ARG (thread); |
| 707 | assert (oi && oi->interface); |
| 708 | |
| 709 | if (IS_OSPF6_DEBUG_INTERFACE) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 710 | zlog_debug ("Interface Event %s: [BackupSeen]", |
| 711 | oi->interface->name); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 712 | |
| 713 | if (oi->state == OSPF6_INTERFACE_WAITING) |
| 714 | ospf6_interface_state_change (dr_election (oi), oi); |
| 715 | |
| 716 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 717 | } |
| 718 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 719 | int |
| 720 | neighbor_change (struct thread *thread) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 721 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 722 | struct ospf6_interface *oi; |
| 723 | |
| 724 | oi = (struct ospf6_interface *) THREAD_ARG (thread); |
| 725 | assert (oi && oi->interface); |
| 726 | |
| 727 | if (IS_OSPF6_DEBUG_INTERFACE) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 728 | zlog_debug ("Interface Event %s: [NeighborChange]", |
| 729 | oi->interface->name); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 730 | |
| 731 | if (oi->state == OSPF6_INTERFACE_DROTHER || |
| 732 | oi->state == OSPF6_INTERFACE_BDR || |
| 733 | oi->state == OSPF6_INTERFACE_DR) |
| 734 | ospf6_interface_state_change (dr_election (oi), oi); |
| 735 | |
| 736 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 737 | } |
| 738 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 739 | int |
| 740 | interface_down (struct thread *thread) |
| 741 | { |
| 742 | struct ospf6_interface *oi; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 743 | struct listnode *node, *nnode; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 744 | struct ospf6_neighbor *on; |
| 745 | |
| 746 | oi = (struct ospf6_interface *) THREAD_ARG (thread); |
| 747 | assert (oi && oi->interface); |
| 748 | |
| 749 | if (IS_OSPF6_DEBUG_INTERFACE) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 750 | zlog_debug ("Interface Event %s: [InterfaceDown]", |
| 751 | oi->interface->name); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 752 | |
| 753 | /* Leave AllSPFRouters */ |
| 754 | if (oi->state > OSPF6_INTERFACE_DOWN) |
Vyacheslav Trushkin | 9a9446e | 2011-11-21 20:26:39 +0400 | [diff] [blame] | 755 | ospf6_sso (oi->interface->ifindex, &allspfrouters6, IPV6_LEAVE_GROUP); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 756 | |
| 757 | ospf6_interface_state_change (OSPF6_INTERFACE_DOWN, oi); |
| 758 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 759 | for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on)) |
| 760 | ospf6_neighbor_delete (on); |
| 761 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 762 | list_delete_all_node (oi->neighbor_list); |
| 763 | |
| 764 | return 0; |
| 765 | } |
| 766 | |
| 767 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 768 | /* show specified interface structure */ |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 769 | static int |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 770 | ospf6_interface_show (struct vty *vty, struct interface *ifp) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 771 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 772 | struct ospf6_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 773 | struct connected *c; |
| 774 | struct prefix *p; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 775 | struct listnode *i; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 776 | char strbuf[64], drouter[32], bdrouter[32]; |
paul | 0c083ee | 2004-10-10 12:54:58 +0000 | [diff] [blame] | 777 | const char *updown[3] = {"down", "up", NULL}; |
| 778 | const char *type; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 779 | struct timeval res, now; |
| 780 | char duration[32]; |
| 781 | struct ospf6_lsa *lsa; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 782 | |
| 783 | /* check physical interface type */ |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 784 | if (if_is_loopback (ifp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 785 | type = "LOOPBACK"; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 786 | else if (if_is_broadcast (ifp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 787 | type = "BROADCAST"; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 788 | else if (if_is_pointopoint (ifp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 789 | type = "POINTOPOINT"; |
| 790 | else |
| 791 | type = "UNKNOWN"; |
| 792 | |
| 793 | vty_out (vty, "%s is %s, type %s%s", |
Dinesh Dutt | e7ad6b2 | 2013-08-24 07:55:57 +0000 | [diff] [blame] | 794 | ifp->name, updown[if_is_operative (ifp)], type, |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 795 | VNL); |
| 796 | vty_out (vty, " Interface ID: %d%s", ifp->ifindex, VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 797 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 798 | if (ifp->info == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 799 | { |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 800 | vty_out (vty, " OSPF not enabled on this interface%s", VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 801 | return 0; |
| 802 | } |
| 803 | else |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 804 | oi = (struct ospf6_interface *) ifp->info; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 805 | |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 806 | vty_out (vty, " Internet Address:%s", VNL); |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 807 | |
| 808 | for (ALL_LIST_ELEMENTS_RO (ifp->connected, i, c)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 809 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 810 | p = c->address; |
| 811 | prefix2str (p, strbuf, sizeof (strbuf)); |
| 812 | switch (p->family) |
| 813 | { |
| 814 | case AF_INET: |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 815 | vty_out (vty, " inet : %s%s", strbuf, |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 816 | VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 817 | break; |
| 818 | case AF_INET6: |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 819 | vty_out (vty, " inet6: %s%s", strbuf, |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 820 | VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 821 | break; |
| 822 | default: |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 823 | vty_out (vty, " ??? : %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 | } |
| 827 | } |
| 828 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 829 | if (oi->area) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 830 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 831 | vty_out (vty, " Instance ID %d, Interface MTU %d (autodetect: %d)%s", |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 832 | oi->instance_id, oi->ifmtu, ifp->mtu6, VNL); |
Dmitrij Tejblum | d42306d | 2011-04-22 19:27:54 +0400 | [diff] [blame] | 833 | vty_out (vty, " MTU mismatch detection: %s%s", oi->mtu_ignore ? |
| 834 | "disabled" : "enabled", VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 835 | inet_ntop (AF_INET, &oi->area->area_id, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 836 | strbuf, sizeof (strbuf)); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 837 | vty_out (vty, " Area ID %s, Cost %hu%s", strbuf, oi->cost, |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 838 | VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 839 | } |
| 840 | else |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 841 | vty_out (vty, " Not Attached to Area%s", VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 842 | |
| 843 | vty_out (vty, " State %s, Transmit Delay %d sec, Priority %d%s", |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 844 | ospf6_interface_state_str[oi->state], |
| 845 | oi->transdelay, oi->priority, |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 846 | VNL); |
| 847 | vty_out (vty, " Timer intervals configured:%s", VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 848 | vty_out (vty, " Hello %d, Dead %d, Retransmit %d%s", |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 849 | oi->hello_interval, oi->dead_interval, oi->rxmt_interval, |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 850 | VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 851 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 852 | inet_ntop (AF_INET, &oi->drouter, drouter, sizeof (drouter)); |
| 853 | inet_ntop (AF_INET, &oi->bdrouter, bdrouter, sizeof (bdrouter)); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 854 | vty_out (vty, " DR: %s BDR: %s%s", drouter, bdrouter, VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 855 | |
| 856 | vty_out (vty, " Number of I/F scoped LSAs is %u%s", |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 857 | oi->lsdb->count, VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 858 | |
Takashi Sogabe | 86f72dc | 2009-06-22 13:07:02 +0900 | [diff] [blame] | 859 | quagga_gettime (QUAGGA_CLK_MONOTONIC, &now); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 860 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 861 | timerclear (&res); |
| 862 | if (oi->thread_send_lsupdate) |
| 863 | timersub (&oi->thread_send_lsupdate->u.sands, &now, &res); |
| 864 | timerstring (&res, duration, sizeof (duration)); |
| 865 | vty_out (vty, " %d Pending LSAs for LSUpdate in Time %s [thread %s]%s", |
| 866 | oi->lsupdate_list->count, duration, |
| 867 | (oi->thread_send_lsupdate ? "on" : "off"), |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 868 | VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 869 | for (lsa = ospf6_lsdb_head (oi->lsupdate_list); lsa; |
| 870 | lsa = ospf6_lsdb_next (lsa)) |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 871 | vty_out (vty, " %s%s", lsa->name, VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 872 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 873 | timerclear (&res); |
| 874 | if (oi->thread_send_lsack) |
| 875 | timersub (&oi->thread_send_lsack->u.sands, &now, &res); |
| 876 | timerstring (&res, duration, sizeof (duration)); |
| 877 | vty_out (vty, " %d Pending LSAs for LSAck in Time %s [thread %s]%s", |
| 878 | oi->lsack_list->count, duration, |
| 879 | (oi->thread_send_lsack ? "on" : "off"), |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 880 | VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 881 | for (lsa = ospf6_lsdb_head (oi->lsack_list); lsa; |
| 882 | lsa = ospf6_lsdb_next (lsa)) |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 883 | vty_out (vty, " %s%s", lsa->name, VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 884 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 885 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 886 | } |
| 887 | |
| 888 | /* show interface */ |
| 889 | DEFUN (show_ipv6_ospf6_interface, |
| 890 | show_ipv6_ospf6_interface_ifname_cmd, |
| 891 | "show ipv6 ospf6 interface IFNAME", |
| 892 | SHOW_STR |
| 893 | IP6_STR |
| 894 | OSPF6_STR |
| 895 | INTERFACE_STR |
| 896 | IFNAME_STR |
| 897 | ) |
| 898 | { |
| 899 | struct interface *ifp; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 900 | struct listnode *i; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 901 | |
| 902 | if (argc) |
| 903 | { |
| 904 | ifp = if_lookup_by_name (argv[0]); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 905 | if (ifp == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 906 | { |
| 907 | vty_out (vty, "No such Interface: %s%s", argv[0], |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 908 | VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 909 | return CMD_WARNING; |
| 910 | } |
| 911 | ospf6_interface_show (vty, ifp); |
| 912 | } |
| 913 | else |
| 914 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 915 | for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp)) |
| 916 | ospf6_interface_show (vty, ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 917 | } |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 918 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 919 | return CMD_SUCCESS; |
| 920 | } |
| 921 | |
| 922 | ALIAS (show_ipv6_ospf6_interface, |
| 923 | show_ipv6_ospf6_interface_cmd, |
| 924 | "show ipv6 ospf6 interface", |
| 925 | SHOW_STR |
| 926 | IP6_STR |
| 927 | OSPF6_STR |
| 928 | INTERFACE_STR |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 929 | ) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 930 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 931 | DEFUN (show_ipv6_ospf6_interface_ifname_prefix, |
| 932 | show_ipv6_ospf6_interface_ifname_prefix_cmd, |
| 933 | "show ipv6 ospf6 interface IFNAME prefix", |
| 934 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 935 | IP6_STR |
| 936 | OSPF6_STR |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 937 | INTERFACE_STR |
| 938 | IFNAME_STR |
| 939 | "Display connected prefixes to advertise\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 940 | ) |
| 941 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 942 | struct interface *ifp; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 943 | struct ospf6_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 944 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 945 | ifp = if_lookup_by_name (argv[0]); |
| 946 | if (ifp == NULL) |
| 947 | { |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 948 | vty_out (vty, "No such Interface: %s%s", argv[0], VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 949 | return CMD_WARNING; |
| 950 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 951 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 952 | oi = ifp->info; |
| 953 | if (oi == NULL) |
| 954 | { |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 955 | vty_out (vty, "OSPFv3 is not enabled on %s%s", argv[0], VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 956 | return CMD_WARNING; |
| 957 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 958 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 959 | argc--; |
| 960 | argv++; |
| 961 | ospf6_route_table_show (vty, argc, argv, oi->route_connected); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 962 | |
| 963 | return CMD_SUCCESS; |
| 964 | } |
| 965 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 966 | ALIAS (show_ipv6_ospf6_interface_ifname_prefix, |
| 967 | show_ipv6_ospf6_interface_ifname_prefix_detail_cmd, |
| 968 | "show ipv6 ospf6 interface IFNAME prefix (X:X::X:X|X:X::X:X/M|detail)", |
| 969 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 970 | IP6_STR |
| 971 | OSPF6_STR |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 972 | INTERFACE_STR |
| 973 | IFNAME_STR |
| 974 | "Display connected prefixes to advertise\n" |
| 975 | OSPF6_ROUTE_ADDRESS_STR |
| 976 | OSPF6_ROUTE_PREFIX_STR |
Denis Ovsienko | ea40219 | 2011-08-19 16:27:16 +0400 | [diff] [blame] | 977 | "Display details of the prefixes\n" |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 978 | ) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 979 | |
| 980 | ALIAS (show_ipv6_ospf6_interface_ifname_prefix, |
| 981 | show_ipv6_ospf6_interface_ifname_prefix_match_cmd, |
| 982 | "show ipv6 ospf6 interface IFNAME prefix X:X::X:X/M (match|detail)", |
| 983 | SHOW_STR |
| 984 | IP6_STR |
| 985 | OSPF6_STR |
| 986 | INTERFACE_STR |
| 987 | IFNAME_STR |
| 988 | "Display connected prefixes to advertise\n" |
| 989 | OSPF6_ROUTE_PREFIX_STR |
| 990 | OSPF6_ROUTE_MATCH_STR |
Denis Ovsienko | ea40219 | 2011-08-19 16:27:16 +0400 | [diff] [blame] | 991 | "Display details of the prefixes\n" |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 992 | ) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 993 | |
| 994 | DEFUN (show_ipv6_ospf6_interface_prefix, |
| 995 | show_ipv6_ospf6_interface_prefix_cmd, |
| 996 | "show ipv6 ospf6 interface prefix", |
| 997 | SHOW_STR |
| 998 | IP6_STR |
| 999 | OSPF6_STR |
| 1000 | INTERFACE_STR |
| 1001 | "Display connected prefixes to advertise\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1002 | ) |
| 1003 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 1004 | struct listnode *i; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1005 | struct ospf6_interface *oi; |
| 1006 | struct interface *ifp; |
| 1007 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1008 | for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp)) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1009 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1010 | oi = (struct ospf6_interface *) ifp->info; |
| 1011 | if (oi == NULL) |
| 1012 | continue; |
| 1013 | |
| 1014 | ospf6_route_table_show (vty, argc, argv, oi->route_connected); |
| 1015 | } |
| 1016 | |
| 1017 | return CMD_SUCCESS; |
| 1018 | } |
| 1019 | |
| 1020 | ALIAS (show_ipv6_ospf6_interface_prefix, |
| 1021 | show_ipv6_ospf6_interface_prefix_detail_cmd, |
| 1022 | "show ipv6 ospf6 interface prefix (X:X::X:X|X:X::X:X/M|detail)", |
| 1023 | SHOW_STR |
| 1024 | IP6_STR |
| 1025 | OSPF6_STR |
| 1026 | INTERFACE_STR |
| 1027 | "Display connected prefixes to advertise\n" |
| 1028 | OSPF6_ROUTE_ADDRESS_STR |
| 1029 | OSPF6_ROUTE_PREFIX_STR |
Denis Ovsienko | ea40219 | 2011-08-19 16:27:16 +0400 | [diff] [blame] | 1030 | "Display details of the prefixes\n" |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 1031 | ) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1032 | |
| 1033 | ALIAS (show_ipv6_ospf6_interface_prefix, |
| 1034 | show_ipv6_ospf6_interface_prefix_match_cmd, |
| 1035 | "show ipv6 ospf6 interface prefix X:X::X:X/M (match|detail)", |
| 1036 | SHOW_STR |
| 1037 | IP6_STR |
| 1038 | OSPF6_STR |
| 1039 | INTERFACE_STR |
| 1040 | "Display connected prefixes to advertise\n" |
| 1041 | OSPF6_ROUTE_PREFIX_STR |
| 1042 | OSPF6_ROUTE_MATCH_STR |
Denis Ovsienko | ea40219 | 2011-08-19 16:27:16 +0400 | [diff] [blame] | 1043 | "Display details of the prefixes\n" |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 1044 | ) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1045 | |
| 1046 | |
| 1047 | /* interface variable set command */ |
hasso | b596c71 | 2004-07-09 18:33:43 +0000 | [diff] [blame] | 1048 | DEFUN (ipv6_ospf6_ifmtu, |
| 1049 | ipv6_ospf6_ifmtu_cmd, |
| 1050 | "ipv6 ospf6 ifmtu <1-65535>", |
| 1051 | IP6_STR |
| 1052 | OSPF6_STR |
| 1053 | "Interface MTU\n" |
| 1054 | "OSPFv3 Interface MTU\n" |
| 1055 | ) |
| 1056 | { |
| 1057 | struct ospf6_interface *oi; |
| 1058 | struct interface *ifp; |
paul | 0c083ee | 2004-10-10 12:54:58 +0000 | [diff] [blame] | 1059 | unsigned int ifmtu, iobuflen; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1060 | struct listnode *node, *nnode; |
hasso | b596c71 | 2004-07-09 18:33:43 +0000 | [diff] [blame] | 1061 | struct ospf6_neighbor *on; |
| 1062 | |
| 1063 | ifp = (struct interface *) vty->index; |
| 1064 | assert (ifp); |
| 1065 | |
| 1066 | oi = (struct ospf6_interface *) ifp->info; |
| 1067 | if (oi == NULL) |
| 1068 | oi = ospf6_interface_create (ifp); |
| 1069 | assert (oi); |
| 1070 | |
| 1071 | ifmtu = strtol (argv[0], NULL, 10); |
| 1072 | |
| 1073 | if (oi->ifmtu == ifmtu) |
| 1074 | return CMD_SUCCESS; |
| 1075 | |
hasso | 1203e1c | 2004-07-23 21:34:27 +0000 | [diff] [blame] | 1076 | if (ifp->mtu6 != 0 && ifp->mtu6 < ifmtu) |
hasso | b596c71 | 2004-07-09 18:33:43 +0000 | [diff] [blame] | 1077 | { |
| 1078 | 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] | 1079 | ifp->name, ifp->mtu6, VNL); |
hasso | b596c71 | 2004-07-09 18:33:43 +0000 | [diff] [blame] | 1080 | return CMD_WARNING; |
| 1081 | } |
| 1082 | |
| 1083 | if (oi->ifmtu < ifmtu) |
| 1084 | { |
| 1085 | iobuflen = ospf6_iobuf_size (ifmtu); |
| 1086 | if (iobuflen < ifmtu) |
| 1087 | { |
| 1088 | 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] | 1089 | ifp->name, iobuflen, VNL); |
hasso | b596c71 | 2004-07-09 18:33:43 +0000 | [diff] [blame] | 1090 | oi->ifmtu = iobuflen; |
| 1091 | } |
| 1092 | else |
| 1093 | oi->ifmtu = ifmtu; |
| 1094 | } |
| 1095 | else |
| 1096 | oi->ifmtu = ifmtu; |
| 1097 | |
| 1098 | /* re-establish adjacencies */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1099 | for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on)) |
hasso | b596c71 | 2004-07-09 18:33:43 +0000 | [diff] [blame] | 1100 | { |
hasso | b596c71 | 2004-07-09 18:33:43 +0000 | [diff] [blame] | 1101 | THREAD_OFF (on->inactivity_timer); |
hasso | 3e834b1 | 2005-06-24 07:50:12 +0000 | [diff] [blame] | 1102 | thread_add_event (master, inactivity_timer, on, 0); |
hasso | b596c71 | 2004-07-09 18:33:43 +0000 | [diff] [blame] | 1103 | } |
| 1104 | |
| 1105 | return CMD_SUCCESS; |
| 1106 | } |
| 1107 | |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 1108 | DEFUN (no_ipv6_ospf6_ifmtu, |
| 1109 | no_ipv6_ospf6_ifmtu_cmd, |
| 1110 | "no ipv6 ospf6 ifmtu", |
| 1111 | NO_STR |
| 1112 | IP6_STR |
| 1113 | OSPF6_STR |
| 1114 | "Interface MTU\n" |
| 1115 | ) |
| 1116 | { |
| 1117 | struct ospf6_interface *oi; |
| 1118 | struct interface *ifp; |
paul | 0c083ee | 2004-10-10 12:54:58 +0000 | [diff] [blame] | 1119 | unsigned int iobuflen; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1120 | struct listnode *node, *nnode; |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 1121 | struct ospf6_neighbor *on; |
| 1122 | |
| 1123 | ifp = (struct interface *) vty->index; |
| 1124 | assert (ifp); |
| 1125 | |
| 1126 | oi = (struct ospf6_interface *) ifp->info; |
| 1127 | if (oi == NULL) |
| 1128 | oi = ospf6_interface_create (ifp); |
| 1129 | assert (oi); |
| 1130 | |
| 1131 | if (oi->ifmtu < ifp->mtu) |
| 1132 | { |
| 1133 | iobuflen = ospf6_iobuf_size (ifp->mtu); |
| 1134 | if (iobuflen < ifp->mtu) |
| 1135 | { |
| 1136 | vty_out (vty, "%s's ifmtu is adjusted to I/O buffer size (%d).%s", |
| 1137 | ifp->name, iobuflen, VNL); |
| 1138 | oi->ifmtu = iobuflen; |
| 1139 | } |
| 1140 | else |
| 1141 | oi->ifmtu = ifp->mtu; |
| 1142 | } |
| 1143 | else |
| 1144 | oi->ifmtu = ifp->mtu; |
| 1145 | |
| 1146 | /* re-establish adjacencies */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1147 | for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on)) |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 1148 | { |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 1149 | THREAD_OFF (on->inactivity_timer); |
hasso | 3e834b1 | 2005-06-24 07:50:12 +0000 | [diff] [blame] | 1150 | thread_add_event (master, inactivity_timer, on, 0); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 1151 | } |
| 1152 | |
| 1153 | return CMD_SUCCESS; |
| 1154 | } |
| 1155 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1156 | DEFUN (ipv6_ospf6_cost, |
| 1157 | ipv6_ospf6_cost_cmd, |
| 1158 | "ipv6 ospf6 cost <1-65535>", |
| 1159 | IP6_STR |
| 1160 | OSPF6_STR |
| 1161 | "Interface cost\n" |
| 1162 | "Outgoing metric of this interface\n" |
| 1163 | ) |
| 1164 | { |
| 1165 | struct ospf6_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1166 | struct interface *ifp; |
paul | 0c083ee | 2004-10-10 12:54:58 +0000 | [diff] [blame] | 1167 | unsigned long int lcost; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1168 | |
| 1169 | ifp = (struct interface *) vty->index; |
| 1170 | assert (ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1171 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1172 | oi = (struct ospf6_interface *) ifp->info; |
| 1173 | if (oi == NULL) |
| 1174 | oi = ospf6_interface_create (ifp); |
| 1175 | assert (oi); |
| 1176 | |
paul | 0c083ee | 2004-10-10 12:54:58 +0000 | [diff] [blame] | 1177 | lcost = strtol (argv[0], NULL, 10); |
| 1178 | |
| 1179 | if (lcost > UINT32_MAX) |
| 1180 | { |
| 1181 | vty_out (vty, "Cost %ld is out of range%s", lcost, VNL); |
| 1182 | return CMD_WARNING; |
| 1183 | } |
| 1184 | |
| 1185 | if (oi->cost == lcost) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1186 | return CMD_SUCCESS; |
paul | 0c083ee | 2004-10-10 12:54:58 +0000 | [diff] [blame] | 1187 | |
| 1188 | oi->cost = lcost; |
| 1189 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1190 | /* update cost held in route_connected list in ospf6_interface */ |
| 1191 | ospf6_interface_connected_route_update (oi->interface); |
| 1192 | |
| 1193 | /* execute LSA hooks */ |
| 1194 | if (oi->area) |
| 1195 | { |
| 1196 | OSPF6_LINK_LSA_SCHEDULE (oi); |
| 1197 | OSPF6_ROUTER_LSA_SCHEDULE (oi->area); |
| 1198 | OSPF6_NETWORK_LSA_SCHEDULE (oi); |
| 1199 | OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi); |
| 1200 | OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area); |
| 1201 | } |
| 1202 | |
| 1203 | return CMD_SUCCESS; |
| 1204 | } |
| 1205 | |
| 1206 | DEFUN (ipv6_ospf6_hellointerval, |
| 1207 | ipv6_ospf6_hellointerval_cmd, |
| 1208 | "ipv6 ospf6 hello-interval <1-65535>", |
| 1209 | IP6_STR |
| 1210 | OSPF6_STR |
| 1211 | "Interval time of Hello packets\n" |
| 1212 | SECONDS_STR |
| 1213 | ) |
| 1214 | { |
| 1215 | struct ospf6_interface *oi; |
| 1216 | struct interface *ifp; |
| 1217 | |
| 1218 | ifp = (struct interface *) vty->index; |
| 1219 | assert (ifp); |
| 1220 | |
| 1221 | oi = (struct ospf6_interface *) ifp->info; |
| 1222 | if (oi == NULL) |
| 1223 | oi = ospf6_interface_create (ifp); |
| 1224 | assert (oi); |
| 1225 | |
| 1226 | oi->hello_interval = strtol (argv[0], NULL, 10); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1227 | return CMD_SUCCESS; |
| 1228 | } |
| 1229 | |
| 1230 | /* interface variable set command */ |
| 1231 | DEFUN (ipv6_ospf6_deadinterval, |
| 1232 | ipv6_ospf6_deadinterval_cmd, |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1233 | "ipv6 ospf6 dead-interval <1-65535>", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1234 | IP6_STR |
| 1235 | OSPF6_STR |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1236 | "Interval time after which a neighbor is declared down\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1237 | SECONDS_STR |
| 1238 | ) |
| 1239 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1240 | struct ospf6_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1241 | struct interface *ifp; |
| 1242 | |
| 1243 | ifp = (struct interface *) vty->index; |
| 1244 | assert (ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1245 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1246 | oi = (struct ospf6_interface *) ifp->info; |
| 1247 | if (oi == NULL) |
| 1248 | oi = ospf6_interface_create (ifp); |
| 1249 | assert (oi); |
| 1250 | |
| 1251 | oi->dead_interval = strtol (argv[0], NULL, 10); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1252 | return CMD_SUCCESS; |
| 1253 | } |
| 1254 | |
| 1255 | /* interface variable set command */ |
| 1256 | DEFUN (ipv6_ospf6_transmitdelay, |
| 1257 | ipv6_ospf6_transmitdelay_cmd, |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1258 | "ipv6 ospf6 transmit-delay <1-3600>", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1259 | IP6_STR |
| 1260 | OSPF6_STR |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1261 | "Transmit delay of this interface\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1262 | SECONDS_STR |
| 1263 | ) |
| 1264 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1265 | struct ospf6_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1266 | struct interface *ifp; |
| 1267 | |
| 1268 | ifp = (struct interface *) vty->index; |
| 1269 | assert (ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1270 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1271 | oi = (struct ospf6_interface *) ifp->info; |
| 1272 | if (oi == NULL) |
| 1273 | oi = ospf6_interface_create (ifp); |
| 1274 | assert (oi); |
| 1275 | |
| 1276 | oi->transdelay = strtol (argv[0], NULL, 10); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1277 | return CMD_SUCCESS; |
| 1278 | } |
| 1279 | |
| 1280 | /* interface variable set command */ |
| 1281 | DEFUN (ipv6_ospf6_retransmitinterval, |
| 1282 | ipv6_ospf6_retransmitinterval_cmd, |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1283 | "ipv6 ospf6 retransmit-interval <1-65535>", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1284 | IP6_STR |
| 1285 | OSPF6_STR |
| 1286 | "Time between retransmitting lost link state advertisements\n" |
| 1287 | SECONDS_STR |
| 1288 | ) |
| 1289 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1290 | struct ospf6_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1291 | struct interface *ifp; |
| 1292 | |
| 1293 | ifp = (struct interface *) vty->index; |
| 1294 | assert (ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1295 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1296 | oi = (struct ospf6_interface *) ifp->info; |
| 1297 | if (oi == NULL) |
| 1298 | oi = ospf6_interface_create (ifp); |
| 1299 | assert (oi); |
| 1300 | |
| 1301 | oi->rxmt_interval = strtol (argv[0], NULL, 10); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1302 | return CMD_SUCCESS; |
| 1303 | } |
| 1304 | |
| 1305 | /* interface variable set command */ |
| 1306 | DEFUN (ipv6_ospf6_priority, |
| 1307 | ipv6_ospf6_priority_cmd, |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1308 | "ipv6 ospf6 priority <0-255>", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1309 | IP6_STR |
| 1310 | OSPF6_STR |
| 1311 | "Router priority\n" |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1312 | "Priority value\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1313 | ) |
| 1314 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1315 | struct ospf6_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1316 | struct interface *ifp; |
| 1317 | |
| 1318 | ifp = (struct interface *) vty->index; |
| 1319 | assert (ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1320 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1321 | oi = (struct ospf6_interface *) ifp->info; |
| 1322 | if (oi == NULL) |
| 1323 | oi = ospf6_interface_create (ifp); |
| 1324 | assert (oi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1325 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1326 | oi->priority = strtol (argv[0], NULL, 10); |
| 1327 | |
| 1328 | if (oi->area) |
| 1329 | ospf6_interface_state_change (dr_election (oi), oi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1330 | |
| 1331 | return CMD_SUCCESS; |
| 1332 | } |
| 1333 | |
| 1334 | DEFUN (ipv6_ospf6_instance, |
| 1335 | ipv6_ospf6_instance_cmd, |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1336 | "ipv6 ospf6 instance-id <0-255>", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1337 | IP6_STR |
| 1338 | OSPF6_STR |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1339 | "Instance ID for this interface\n" |
| 1340 | "Instance ID value\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1341 | ) |
| 1342 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1343 | struct ospf6_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1344 | struct interface *ifp; |
| 1345 | |
| 1346 | ifp = (struct interface *)vty->index; |
| 1347 | assert (ifp); |
| 1348 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1349 | oi = (struct ospf6_interface *)ifp->info; |
| 1350 | if (oi == NULL) |
| 1351 | oi = ospf6_interface_create (ifp); |
| 1352 | assert (oi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1353 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1354 | oi->instance_id = strtol (argv[0], NULL, 10); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1355 | return CMD_SUCCESS; |
| 1356 | } |
| 1357 | |
| 1358 | DEFUN (ipv6_ospf6_passive, |
| 1359 | ipv6_ospf6_passive_cmd, |
| 1360 | "ipv6 ospf6 passive", |
| 1361 | IP6_STR |
| 1362 | OSPF6_STR |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1363 | "passive interface, No adjacency will be formed on this interface\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1364 | ) |
| 1365 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1366 | struct ospf6_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1367 | struct interface *ifp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1368 | struct listnode *node, *nnode; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1369 | struct ospf6_neighbor *on; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1370 | |
| 1371 | ifp = (struct interface *) vty->index; |
| 1372 | assert (ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1373 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1374 | oi = (struct ospf6_interface *) ifp->info; |
| 1375 | if (oi == NULL) |
| 1376 | oi = ospf6_interface_create (ifp); |
| 1377 | assert (oi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1378 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1379 | SET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE); |
| 1380 | THREAD_OFF (oi->thread_send_hello); |
| 1381 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1382 | for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1383 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1384 | THREAD_OFF (on->inactivity_timer); |
hasso | 3e834b1 | 2005-06-24 07:50:12 +0000 | [diff] [blame] | 1385 | thread_add_event (master, inactivity_timer, on, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1386 | } |
| 1387 | |
| 1388 | return CMD_SUCCESS; |
| 1389 | } |
| 1390 | |
| 1391 | DEFUN (no_ipv6_ospf6_passive, |
| 1392 | no_ipv6_ospf6_passive_cmd, |
| 1393 | "no ipv6 ospf6 passive", |
| 1394 | NO_STR |
| 1395 | IP6_STR |
| 1396 | OSPF6_STR |
| 1397 | "passive interface: No Adjacency will be formed on this I/F\n" |
| 1398 | ) |
| 1399 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1400 | struct ospf6_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1401 | struct interface *ifp; |
| 1402 | |
| 1403 | ifp = (struct interface *) vty->index; |
| 1404 | assert (ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1405 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1406 | oi = (struct ospf6_interface *) ifp->info; |
| 1407 | if (oi == NULL) |
| 1408 | oi = ospf6_interface_create (ifp); |
| 1409 | assert (oi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1410 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1411 | UNSET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE); |
| 1412 | THREAD_OFF (oi->thread_send_hello); |
| 1413 | oi->thread_send_hello = |
| 1414 | thread_add_event (master, ospf6_hello_send, oi, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1415 | |
| 1416 | return CMD_SUCCESS; |
| 1417 | } |
| 1418 | |
Dmitrij Tejblum | d42306d | 2011-04-22 19:27:54 +0400 | [diff] [blame] | 1419 | DEFUN (ipv6_ospf6_mtu_ignore, |
| 1420 | ipv6_ospf6_mtu_ignore_cmd, |
| 1421 | "ipv6 ospf6 mtu-ignore", |
| 1422 | IP6_STR |
| 1423 | OSPF6_STR |
| 1424 | "Ignore MTU mismatch on this interface\n" |
| 1425 | ) |
| 1426 | { |
| 1427 | struct ospf6_interface *oi; |
| 1428 | struct interface *ifp; |
| 1429 | |
| 1430 | ifp = (struct interface *) vty->index; |
| 1431 | assert (ifp); |
| 1432 | |
| 1433 | oi = (struct ospf6_interface *) ifp->info; |
| 1434 | if (oi == NULL) |
| 1435 | oi = ospf6_interface_create (ifp); |
| 1436 | assert (oi); |
| 1437 | |
| 1438 | oi->mtu_ignore = 1; |
| 1439 | |
| 1440 | return CMD_SUCCESS; |
| 1441 | } |
| 1442 | |
| 1443 | DEFUN (no_ipv6_ospf6_mtu_ignore, |
| 1444 | no_ipv6_ospf6_mtu_ignore_cmd, |
| 1445 | "no ipv6 ospf6 mtu-ignore", |
| 1446 | NO_STR |
| 1447 | IP6_STR |
| 1448 | OSPF6_STR |
| 1449 | "Ignore MTU mismatch on this interface\n" |
| 1450 | ) |
| 1451 | { |
| 1452 | struct ospf6_interface *oi; |
| 1453 | struct interface *ifp; |
| 1454 | |
| 1455 | ifp = (struct interface *) vty->index; |
| 1456 | assert (ifp); |
| 1457 | |
| 1458 | oi = (struct ospf6_interface *) ifp->info; |
| 1459 | if (oi == NULL) |
| 1460 | oi = ospf6_interface_create (ifp); |
| 1461 | assert (oi); |
| 1462 | |
| 1463 | oi->mtu_ignore = 0; |
| 1464 | |
| 1465 | return CMD_SUCCESS; |
| 1466 | } |
| 1467 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1468 | DEFUN (ipv6_ospf6_advertise_prefix_list, |
| 1469 | ipv6_ospf6_advertise_prefix_list_cmd, |
| 1470 | "ipv6 ospf6 advertise prefix-list WORD", |
| 1471 | IP6_STR |
| 1472 | OSPF6_STR |
| 1473 | "Advertising options\n" |
| 1474 | "Filter prefix using prefix-list\n" |
| 1475 | "Prefix list name\n" |
| 1476 | ) |
| 1477 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1478 | struct ospf6_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1479 | struct interface *ifp; |
| 1480 | |
| 1481 | ifp = (struct interface *) vty->index; |
| 1482 | assert (ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1483 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1484 | oi = (struct ospf6_interface *) ifp->info; |
| 1485 | if (oi == NULL) |
| 1486 | oi = ospf6_interface_create (ifp); |
| 1487 | assert (oi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1488 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1489 | if (oi->plist_name) |
| 1490 | XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name); |
| 1491 | oi->plist_name = XSTRDUP (MTYPE_PREFIX_LIST_STR, argv[0]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1492 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1493 | ospf6_interface_connected_route_update (oi->interface); |
David Ward | 2470e99 | 2010-01-05 02:45:39 +0000 | [diff] [blame] | 1494 | |
| 1495 | if (oi->area) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1496 | { |
David Ward | 2470e99 | 2010-01-05 02:45:39 +0000 | [diff] [blame] | 1497 | OSPF6_LINK_LSA_SCHEDULE (oi); |
| 1498 | if (oi->state == OSPF6_INTERFACE_DR) |
| 1499 | { |
| 1500 | OSPF6_NETWORK_LSA_SCHEDULE (oi); |
| 1501 | OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi); |
| 1502 | } |
| 1503 | OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1504 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1505 | |
| 1506 | return CMD_SUCCESS; |
| 1507 | } |
| 1508 | |
| 1509 | DEFUN (no_ipv6_ospf6_advertise_prefix_list, |
| 1510 | no_ipv6_ospf6_advertise_prefix_list_cmd, |
| 1511 | "no ipv6 ospf6 advertise prefix-list", |
| 1512 | NO_STR |
| 1513 | IP6_STR |
| 1514 | OSPF6_STR |
| 1515 | "Advertising options\n" |
| 1516 | "Filter prefix using prefix-list\n" |
| 1517 | ) |
| 1518 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1519 | struct ospf6_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1520 | struct interface *ifp; |
| 1521 | |
| 1522 | ifp = (struct interface *) vty->index; |
| 1523 | assert (ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1524 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1525 | oi = (struct ospf6_interface *) ifp->info; |
| 1526 | if (oi == NULL) |
| 1527 | oi = ospf6_interface_create (ifp); |
| 1528 | assert (oi); |
| 1529 | |
| 1530 | if (oi->plist_name) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1531 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1532 | XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name); |
| 1533 | oi->plist_name = NULL; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1534 | } |
| 1535 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1536 | ospf6_interface_connected_route_update (oi->interface); |
David Ward | 2470e99 | 2010-01-05 02:45:39 +0000 | [diff] [blame] | 1537 | |
| 1538 | if (oi->area) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1539 | { |
David Ward | 2470e99 | 2010-01-05 02:45:39 +0000 | [diff] [blame] | 1540 | OSPF6_LINK_LSA_SCHEDULE (oi); |
| 1541 | if (oi->state == OSPF6_INTERFACE_DR) |
| 1542 | { |
| 1543 | OSPF6_NETWORK_LSA_SCHEDULE (oi); |
| 1544 | OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi); |
| 1545 | } |
| 1546 | OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1547 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1548 | |
| 1549 | return CMD_SUCCESS; |
| 1550 | } |
| 1551 | |
Dinesh Dutt | c5926a9 | 2013-08-24 07:55:00 +0000 | [diff] [blame] | 1552 | DEFUN (ipv6_ospf6_network, |
| 1553 | ipv6_ospf6_network_cmd, |
| 1554 | "ipv6 ospf6 network (broadcast|point-to-point)", |
| 1555 | IP6_STR |
| 1556 | OSPF6_STR |
| 1557 | "Network Type\n" |
| 1558 | "Specify OSPFv6 broadcast network\n" |
| 1559 | "Specify OSPF6 point-to-point network\n" |
| 1560 | ) |
| 1561 | { |
| 1562 | struct ospf6_interface *oi; |
| 1563 | struct interface *ifp; |
| 1564 | |
| 1565 | ifp = (struct interface *) vty->index; |
| 1566 | assert (ifp); |
| 1567 | |
| 1568 | oi = (struct ospf6_interface *) ifp->info; |
| 1569 | if (oi == NULL) { |
| 1570 | oi = ospf6_interface_create (ifp); |
| 1571 | } |
| 1572 | assert (oi); |
| 1573 | |
| 1574 | if (strncmp (argv[0], "b", 1) == 0) |
| 1575 | { |
| 1576 | if (oi->type == OSPF_IFTYPE_BROADCAST) |
| 1577 | return CMD_SUCCESS; |
| 1578 | |
| 1579 | oi->type = OSPF_IFTYPE_BROADCAST; |
| 1580 | } |
| 1581 | else if (strncmp (argv[0], "point-to-p", 10) == 0) |
| 1582 | { |
| 1583 | if (oi->type == OSPF_IFTYPE_POINTOPOINT) { |
| 1584 | return CMD_SUCCESS; |
| 1585 | } |
| 1586 | oi->type = OSPF_IFTYPE_POINTOPOINT; |
| 1587 | } |
| 1588 | |
| 1589 | /* Reset the interface */ |
| 1590 | thread_add_event (master, interface_down, oi, 0); |
| 1591 | thread_add_event (master, interface_up, oi, 0); |
| 1592 | |
| 1593 | return CMD_SUCCESS; |
| 1594 | } |
| 1595 | |
| 1596 | DEFUN (no_ipv6_ospf6_network, |
| 1597 | no_ipv6_ospf6_network_cmd, |
| 1598 | "no ipv6 ospf6 network", |
| 1599 | NO_STR |
| 1600 | IP6_STR |
| 1601 | OSPF6_STR |
| 1602 | "Network Type\n" |
| 1603 | "Default to whatever interface type system specifies" |
| 1604 | ) |
| 1605 | { |
| 1606 | struct ospf6_interface *oi; |
| 1607 | struct interface *ifp; |
| 1608 | int type; |
| 1609 | |
| 1610 | ifp = (struct interface *) vty->index; |
| 1611 | assert (ifp); |
| 1612 | |
| 1613 | oi = (struct ospf6_interface *) ifp->info; |
| 1614 | if (oi == NULL) { |
| 1615 | return CMD_SUCCESS; |
| 1616 | } |
| 1617 | |
| 1618 | type = ospf6_default_iftype (ifp); |
| 1619 | if (oi->type == type) |
| 1620 | { |
| 1621 | return CMD_SUCCESS; |
| 1622 | } |
| 1623 | oi->type = type; |
| 1624 | |
| 1625 | /* Reset the interface */ |
| 1626 | thread_add_event (master, interface_down, oi, 0); |
| 1627 | thread_add_event (master, interface_up, oi, 0); |
| 1628 | |
| 1629 | return CMD_SUCCESS; |
| 1630 | } |
| 1631 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 1632 | static int |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1633 | config_write_ospf6_interface (struct vty *vty) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1634 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 1635 | struct listnode *i; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1636 | struct ospf6_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1637 | struct interface *ifp; |
| 1638 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1639 | for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1640 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1641 | oi = (struct ospf6_interface *) ifp->info; |
| 1642 | if (oi == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1643 | continue; |
| 1644 | |
| 1645 | vty_out (vty, "interface %s%s", |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 1646 | oi->interface->name, VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1647 | |
| 1648 | if (ifp->desc) |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 1649 | vty_out (vty, " description %s%s", ifp->desc, VNL); |
hasso | 1203e1c | 2004-07-23 21:34:27 +0000 | [diff] [blame] | 1650 | if (ifp->mtu6 != oi->ifmtu) |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 1651 | vty_out (vty, " ipv6 ospf6 ifmtu %d%s", oi->ifmtu, VNL); |
Vyacheslav Trushkin | b51a3a3 | 2012-02-10 10:42:45 +0400 | [diff] [blame] | 1652 | |
| 1653 | if (oi->cost != OSPF6_INTERFACE_COST) |
| 1654 | vty_out (vty, " ipv6 ospf6 cost %d%s", |
| 1655 | oi->cost, VNL); |
| 1656 | |
| 1657 | if (oi->hello_interval != OSPF6_INTERFACE_HELLO_INTERVAL) |
| 1658 | vty_out (vty, " ipv6 ospf6 hello-interval %d%s", |
| 1659 | oi->hello_interval, VNL); |
| 1660 | |
| 1661 | if (oi->dead_interval != OSPF6_INTERFACE_DEAD_INTERVAL) |
| 1662 | vty_out (vty, " ipv6 ospf6 dead-interval %d%s", |
| 1663 | oi->dead_interval, VNL); |
| 1664 | |
| 1665 | if (oi->rxmt_interval != OSPF6_INTERFACE_RXMT_INTERVAL) |
| 1666 | vty_out (vty, " ipv6 ospf6 retransmit-interval %d%s", |
| 1667 | oi->rxmt_interval, VNL); |
| 1668 | |
| 1669 | if (oi->priority != OSPF6_INTERFACE_PRIORITY) |
| 1670 | vty_out (vty, " ipv6 ospf6 priority %d%s", |
| 1671 | oi->priority, VNL); |
| 1672 | |
| 1673 | if (oi->transdelay != OSPF6_INTERFACE_TRANSDELAY) |
| 1674 | vty_out (vty, " ipv6 ospf6 transmit-delay %d%s", |
| 1675 | oi->transdelay, VNL); |
| 1676 | |
| 1677 | if (oi->instance_id != OSPF6_INTERFACE_INSTANCE_ID) |
| 1678 | vty_out (vty, " ipv6 ospf6 instance-id %d%s", |
| 1679 | oi->instance_id, VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1680 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1681 | if (oi->plist_name) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1682 | vty_out (vty, " ipv6 ospf6 advertise prefix-list %s%s", |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 1683 | oi->plist_name, VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1684 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1685 | if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE)) |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 1686 | vty_out (vty, " ipv6 ospf6 passive%s", VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1687 | |
Dmitrij Tejblum | d42306d | 2011-04-22 19:27:54 +0400 | [diff] [blame] | 1688 | if (oi->mtu_ignore) |
| 1689 | vty_out (vty, " ipv6 ospf6 mtu-ignore%s", VNL); |
| 1690 | |
Dinesh Dutt | c5926a9 | 2013-08-24 07:55:00 +0000 | [diff] [blame] | 1691 | if (oi->type == OSPF_IFTYPE_POINTOPOINT) |
| 1692 | vty_out (vty, " ipv6 ospf6 network point-to-point%s", VNL); |
| 1693 | else if (oi->type == OSPF_IFTYPE_BROADCAST) |
| 1694 | vty_out (vty, " ipv6 ospf6 network broadcast%s", VNL); |
| 1695 | |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 1696 | vty_out (vty, "!%s", VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1697 | } |
| 1698 | return 0; |
| 1699 | } |
| 1700 | |
Stephen Hemminger | 7fc626d | 2008-12-01 11:10:34 -0800 | [diff] [blame] | 1701 | static struct cmd_node interface_node = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1702 | { |
| 1703 | INTERFACE_NODE, |
| 1704 | "%s(config-if)# ", |
hasso | 69b4a81 | 2004-08-26 18:10:36 +0000 | [diff] [blame] | 1705 | 1 /* VTYSH */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1706 | }; |
| 1707 | |
| 1708 | void |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 1709 | ospf6_interface_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1710 | { |
| 1711 | /* Install interface node. */ |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1712 | install_node (&interface_node, config_write_ospf6_interface); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1713 | |
| 1714 | install_element (VIEW_NODE, &show_ipv6_ospf6_interface_cmd); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1715 | install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_cmd); |
| 1716 | install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_detail_cmd); |
| 1717 | install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_match_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1718 | install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_cmd); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1719 | install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_cmd); |
| 1720 | install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd); |
| 1721 | install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1722 | install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_cmd); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1723 | install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_cmd); |
| 1724 | install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_detail_cmd); |
| 1725 | install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_match_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1726 | install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_cmd); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1727 | install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_cmd); |
| 1728 | install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd); |
| 1729 | install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1730 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1731 | install_element (CONFIG_NODE, &interface_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1732 | install_default (INTERFACE_NODE); |
| 1733 | install_element (INTERFACE_NODE, &interface_desc_cmd); |
| 1734 | install_element (INTERFACE_NODE, &no_interface_desc_cmd); |
| 1735 | install_element (INTERFACE_NODE, &ipv6_ospf6_cost_cmd); |
hasso | b596c71 | 2004-07-09 18:33:43 +0000 | [diff] [blame] | 1736 | install_element (INTERFACE_NODE, &ipv6_ospf6_ifmtu_cmd); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 1737 | install_element (INTERFACE_NODE, &no_ipv6_ospf6_ifmtu_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1738 | install_element (INTERFACE_NODE, &ipv6_ospf6_deadinterval_cmd); |
| 1739 | install_element (INTERFACE_NODE, &ipv6_ospf6_hellointerval_cmd); |
| 1740 | install_element (INTERFACE_NODE, &ipv6_ospf6_priority_cmd); |
| 1741 | install_element (INTERFACE_NODE, &ipv6_ospf6_retransmitinterval_cmd); |
| 1742 | install_element (INTERFACE_NODE, &ipv6_ospf6_transmitdelay_cmd); |
| 1743 | install_element (INTERFACE_NODE, &ipv6_ospf6_instance_cmd); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1744 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1745 | install_element (INTERFACE_NODE, &ipv6_ospf6_passive_cmd); |
| 1746 | install_element (INTERFACE_NODE, &no_ipv6_ospf6_passive_cmd); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1747 | |
Dmitrij Tejblum | d42306d | 2011-04-22 19:27:54 +0400 | [diff] [blame] | 1748 | install_element (INTERFACE_NODE, &ipv6_ospf6_mtu_ignore_cmd); |
| 1749 | install_element (INTERFACE_NODE, &no_ipv6_ospf6_mtu_ignore_cmd); |
| 1750 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1751 | install_element (INTERFACE_NODE, &ipv6_ospf6_advertise_prefix_list_cmd); |
| 1752 | install_element (INTERFACE_NODE, &no_ipv6_ospf6_advertise_prefix_list_cmd); |
Dinesh Dutt | c5926a9 | 2013-08-24 07:55:00 +0000 | [diff] [blame] | 1753 | |
| 1754 | install_element (INTERFACE_NODE, &ipv6_ospf6_network_cmd); |
| 1755 | install_element (INTERFACE_NODE, &no_ipv6_ospf6_network_cmd); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1756 | } |
| 1757 | |
| 1758 | DEFUN (debug_ospf6_interface, |
| 1759 | debug_ospf6_interface_cmd, |
| 1760 | "debug ospf6 interface", |
| 1761 | DEBUG_STR |
| 1762 | OSPF6_STR |
| 1763 | "Debug OSPFv3 Interface\n" |
| 1764 | ) |
| 1765 | { |
| 1766 | OSPF6_DEBUG_INTERFACE_ON (); |
| 1767 | return CMD_SUCCESS; |
| 1768 | } |
| 1769 | |
| 1770 | DEFUN (no_debug_ospf6_interface, |
| 1771 | no_debug_ospf6_interface_cmd, |
| 1772 | "no debug ospf6 interface", |
| 1773 | NO_STR |
| 1774 | DEBUG_STR |
| 1775 | OSPF6_STR |
| 1776 | "Debug OSPFv3 Interface\n" |
| 1777 | ) |
| 1778 | { |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 1779 | OSPF6_DEBUG_INTERFACE_OFF (); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1780 | return CMD_SUCCESS; |
| 1781 | } |
| 1782 | |
| 1783 | int |
| 1784 | config_write_ospf6_debug_interface (struct vty *vty) |
| 1785 | { |
| 1786 | if (IS_OSPF6_DEBUG_INTERFACE) |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 1787 | vty_out (vty, "debug ospf6 interface%s", VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1788 | return 0; |
| 1789 | } |
| 1790 | |
| 1791 | void |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 1792 | install_element_ospf6_debug_interface (void) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1793 | { |
| 1794 | install_element (ENABLE_NODE, &debug_ospf6_interface_cmd); |
| 1795 | install_element (ENABLE_NODE, &no_debug_ospf6_interface_cmd); |
| 1796 | install_element (CONFIG_NODE, &debug_ospf6_interface_cmd); |
| 1797 | install_element (CONFIG_NODE, &no_debug_ospf6_interface_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1798 | } |
| 1799 | |
| 1800 | |