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