paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Interface related function for RIPng. |
| 3 | * Copyright (C) 1998 Kunihiro Ishiguro |
| 4 | * |
| 5 | * This file is part of GNU Zebra. |
| 6 | * |
| 7 | * GNU Zebra is free software; you can redistribute it and/or modify it |
| 8 | * under the terms of the GNU General Public License as published by the |
| 9 | * Free Software Foundation; either version 2, or (at your option) any |
| 10 | * later version. |
| 11 | * |
| 12 | * GNU Zebra is distributed in the hope that it will be useful, but |
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with GNU Zebra; see the file COPYING. If not, write to the Free |
| 19 | * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
| 20 | * 02111-1307, USA. |
| 21 | */ |
| 22 | |
| 23 | #include <zebra.h> |
| 24 | |
| 25 | #include "linklist.h" |
| 26 | #include "if.h" |
| 27 | #include "prefix.h" |
| 28 | #include "memory.h" |
| 29 | #include "network.h" |
| 30 | #include "filter.h" |
| 31 | #include "log.h" |
| 32 | #include "stream.h" |
| 33 | #include "zclient.h" |
| 34 | #include "command.h" |
| 35 | #include "table.h" |
| 36 | #include "thread.h" |
gdt | 4d4653a | 2004-07-01 19:26:33 +0000 | [diff] [blame] | 37 | #include "privs.h" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 38 | |
| 39 | #include "ripngd/ripngd.h" |
| 40 | #include "ripngd/ripng_debug.h" |
| 41 | |
| 42 | /* If RFC2133 definition is used. */ |
| 43 | #ifndef IPV6_JOIN_GROUP |
| 44 | #define IPV6_JOIN_GROUP IPV6_ADD_MEMBERSHIP |
| 45 | #endif |
| 46 | #ifndef IPV6_LEAVE_GROUP |
| 47 | #define IPV6_LEAVE_GROUP IPV6_DROP_MEMBERSHIP |
| 48 | #endif |
| 49 | |
gdt | 4d4653a | 2004-07-01 19:26:33 +0000 | [diff] [blame] | 50 | extern struct zebra_privs_t ripngd_privs; |
| 51 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 52 | /* Static utility function. */ |
| 53 | static void ripng_enable_apply (struct interface *); |
| 54 | static void ripng_passive_interface_apply (struct interface *); |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 55 | static int ripng_enable_if_lookup (const char *); |
| 56 | static int ripng_enable_network_lookup2 (struct connected *); |
| 57 | static void ripng_enable_apply_all (void); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 58 | |
| 59 | /* Join to the all rip routers multicast group. */ |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 60 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 61 | ripng_multicast_join (struct interface *ifp) |
| 62 | { |
| 63 | int ret; |
| 64 | struct ipv6_mreq mreq; |
ajs | 656b4ee | 2005-01-30 18:08:12 +0000 | [diff] [blame] | 65 | int save_errno; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 66 | |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 67 | if (if_is_up (ifp) && if_is_multicast (ifp)) { |
| 68 | memset (&mreq, 0, sizeof (mreq)); |
| 69 | inet_pton(AF_INET6, RIPNG_GROUP, &mreq.ipv6mr_multiaddr); |
| 70 | mreq.ipv6mr_interface = ifp->ifindex; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 71 | |
gdt | 4d4653a | 2004-07-01 19:26:33 +0000 | [diff] [blame] | 72 | /* |
| 73 | * NetBSD 1.6.2 requires root to join groups on gif(4). |
| 74 | * While this is bogus, privs are available and easy to use |
| 75 | * for this call as a workaround. |
| 76 | */ |
| 77 | if (ripngd_privs.change (ZPRIVS_RAISE)) |
| 78 | zlog_err ("ripng_multicast_join: could not raise privs"); |
| 79 | |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 80 | ret = setsockopt (ripng->sock, IPPROTO_IPV6, IPV6_JOIN_GROUP, |
| 81 | (char *) &mreq, sizeof (mreq)); |
ajs | 656b4ee | 2005-01-30 18:08:12 +0000 | [diff] [blame] | 82 | save_errno = errno; |
gdt | ddf1c26 | 2004-01-04 01:02:55 +0000 | [diff] [blame] | 83 | |
gdt | 4d4653a | 2004-07-01 19:26:33 +0000 | [diff] [blame] | 84 | if (ripngd_privs.change (ZPRIVS_LOWER)) |
| 85 | zlog_err ("ripng_multicast_join: could not lower privs"); |
| 86 | |
ajs | 656b4ee | 2005-01-30 18:08:12 +0000 | [diff] [blame] | 87 | if (ret < 0 && save_errno == EADDRINUSE) |
gdt | ddf1c26 | 2004-01-04 01:02:55 +0000 | [diff] [blame] | 88 | { |
| 89 | /* |
| 90 | * Group is already joined. This occurs due to sloppy group |
| 91 | * management, in particular declining to leave the group on |
| 92 | * an interface that has just gone down. |
| 93 | */ |
| 94 | zlog_warn ("ripng join on %s EADDRINUSE (ignoring)\n", ifp->name); |
| 95 | return 0; /* not an error */ |
| 96 | } |
| 97 | |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 98 | if (ret < 0) |
ajs | 656b4ee | 2005-01-30 18:08:12 +0000 | [diff] [blame] | 99 | zlog_warn ("can't setsockopt IPV6_JOIN_GROUP: %s", |
| 100 | safe_strerror (save_errno)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 101 | |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 102 | if (IS_RIPNG_DEBUG_EVENT) |
ajs | 2e23ab2 | 2004-12-08 19:46:50 +0000 | [diff] [blame] | 103 | zlog_debug ("RIPng %s join to all-rip-routers multicast group", ifp->name); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 104 | |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 105 | if (ret < 0) |
| 106 | return -1; |
| 107 | } |
| 108 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 109 | } |
| 110 | |
| 111 | /* Leave from the all rip routers multicast group. */ |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 112 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 113 | ripng_multicast_leave (struct interface *ifp) |
| 114 | { |
| 115 | int ret; |
| 116 | struct ipv6_mreq mreq; |
| 117 | |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 118 | if (if_is_up (ifp) && if_is_multicast (ifp)) { |
| 119 | memset (&mreq, 0, sizeof (mreq)); |
| 120 | inet_pton(AF_INET6, RIPNG_GROUP, &mreq.ipv6mr_multiaddr); |
| 121 | mreq.ipv6mr_interface = ifp->ifindex; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 122 | |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 123 | ret = setsockopt (ripng->sock, IPPROTO_IPV6, IPV6_LEAVE_GROUP, |
| 124 | (char *) &mreq, sizeof (mreq)); |
| 125 | if (ret < 0) |
ajs | 6099b3b | 2004-11-20 02:06:59 +0000 | [diff] [blame] | 126 | zlog_warn ("can't setsockopt IPV6_LEAVE_GROUP: %s\n", safe_strerror (errno)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 127 | |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 128 | if (IS_RIPNG_DEBUG_EVENT) |
ajs | 2e23ab2 | 2004-12-08 19:46:50 +0000 | [diff] [blame] | 129 | zlog_debug ("RIPng %s leave from all-rip-routers multicast group", |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 130 | ifp->name); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 131 | |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 132 | if (ret < 0) |
| 133 | return -1; |
| 134 | } |
| 135 | |
| 136 | return 0; |
| 137 | } |
| 138 | |
| 139 | /* How many link local IPv6 address could be used on the interface ? */ |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 140 | static int |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 141 | ripng_if_ipv6_lladdress_check (struct interface *ifp) |
| 142 | { |
| 143 | struct listnode *nn; |
| 144 | struct connected *connected; |
| 145 | int count = 0; |
| 146 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 147 | for (ALL_LIST_ELEMENTS_RO (ifp->connected, nn, connected)) |
| 148 | { |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 149 | struct prefix *p; |
| 150 | p = connected->address; |
| 151 | |
| 152 | if ((p->family == AF_INET6) && |
| 153 | IN6_IS_ADDR_LINKLOCAL (&p->u.prefix6)) |
| 154 | count++; |
| 155 | } |
| 156 | |
| 157 | return count; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 158 | } |
| 159 | |
| 160 | /* Check max mtu size. */ |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 161 | static unsigned int |
| 162 | ripng_check_max_mtu (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 163 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 164 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 165 | struct interface *ifp; |
hasso | 98b718a | 2004-10-11 12:57:57 +0000 | [diff] [blame] | 166 | unsigned int mtu; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 167 | |
| 168 | mtu = 0; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 169 | for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp)) |
| 170 | if (mtu < ifp->mtu6) |
| 171 | mtu = ifp->mtu6; |
| 172 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 173 | return mtu; |
| 174 | } |
| 175 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 176 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 177 | ripng_if_down (struct interface *ifp) |
| 178 | { |
| 179 | struct route_node *rp; |
| 180 | struct ripng_info *rinfo; |
| 181 | struct ripng_interface *ri; |
| 182 | |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 183 | if (ripng) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 184 | { |
| 185 | for (rp = route_top (ripng->table); rp; rp = route_next (rp)) |
| 186 | if ((rinfo = rp->info) != NULL) |
| 187 | { |
| 188 | /* Routes got through this interface. */ |
| 189 | if (rinfo->ifindex == ifp->ifindex |
| 190 | && rinfo->type == ZEBRA_ROUTE_RIPNG |
| 191 | && rinfo->sub_type == RIPNG_ROUTE_RTE) |
| 192 | { |
| 193 | ripng_zebra_ipv6_delete ((struct prefix_ipv6 *) &rp->p, |
| 194 | &rinfo->nexthop, |
| 195 | rinfo->ifindex); |
| 196 | |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 197 | ripng_redistribute_delete (rinfo->type, rinfo->sub_type, |
| 198 | (struct prefix_ipv6 *)&rp->p, |
| 199 | rinfo->ifindex); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 200 | } |
| 201 | else |
| 202 | { |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 203 | /* All redistributed routes got through this interface, |
| 204 | * but the static and system ones are kept. */ |
| 205 | if ((rinfo->ifindex == ifp->ifindex) && |
| 206 | (rinfo->type != ZEBRA_ROUTE_STATIC) && |
| 207 | (rinfo->type != ZEBRA_ROUTE_SYSTEM)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 208 | ripng_redistribute_delete (rinfo->type, rinfo->sub_type, |
| 209 | (struct prefix_ipv6 *) &rp->p, |
| 210 | rinfo->ifindex); |
| 211 | } |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | ri = ifp->info; |
| 216 | |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 217 | if (ri->running) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 218 | { |
| 219 | if (IS_RIPNG_DEBUG_EVENT) |
ajs | 2e23ab2 | 2004-12-08 19:46:50 +0000 | [diff] [blame] | 220 | zlog_debug ("turn off %s", ifp->name); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 221 | |
| 222 | /* Leave from multicast group. */ |
| 223 | ripng_multicast_leave (ifp); |
| 224 | |
| 225 | ri->running = 0; |
| 226 | } |
| 227 | |
| 228 | return 0; |
| 229 | } |
| 230 | |
| 231 | /* Inteface link up message processing. */ |
| 232 | int |
| 233 | ripng_interface_up (int command, struct zclient *zclient, zebra_size_t length) |
| 234 | { |
| 235 | struct stream *s; |
| 236 | struct interface *ifp; |
| 237 | |
| 238 | /* zebra_interface_state_read() updates interface structure in iflist. */ |
| 239 | s = zclient->ibuf; |
| 240 | ifp = zebra_interface_state_read (s); |
| 241 | |
| 242 | if (ifp == NULL) |
| 243 | return 0; |
| 244 | |
| 245 | if (IS_RIPNG_DEBUG_ZEBRA) |
ajs | 2e23ab2 | 2004-12-08 19:46:50 +0000 | [diff] [blame] | 246 | zlog_debug ("interface up %s index %d flags %ld metric %d mtu %d", |
hasso | 1203e1c | 2004-07-23 21:34:27 +0000 | [diff] [blame] | 247 | ifp->name, ifp->ifindex, ifp->flags, ifp->metric, ifp->mtu6); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 248 | |
| 249 | /* Check if this interface is RIPng enabled or not. */ |
| 250 | ripng_enable_apply (ifp); |
| 251 | |
| 252 | /* Check for a passive interface. */ |
| 253 | ripng_passive_interface_apply (ifp); |
| 254 | |
| 255 | /* Apply distribute list to the all interface. */ |
| 256 | ripng_distribute_update_interface (ifp); |
| 257 | |
| 258 | return 0; |
| 259 | } |
| 260 | |
| 261 | /* Inteface link down message processing. */ |
| 262 | int |
| 263 | ripng_interface_down (int command, struct zclient *zclient, |
| 264 | zebra_size_t length) |
| 265 | { |
| 266 | struct stream *s; |
| 267 | struct interface *ifp; |
| 268 | |
| 269 | /* zebra_interface_state_read() updates interface structure in iflist. */ |
| 270 | s = zclient->ibuf; |
| 271 | ifp = zebra_interface_state_read (s); |
| 272 | |
| 273 | if (ifp == NULL) |
| 274 | return 0; |
| 275 | |
| 276 | ripng_if_down (ifp); |
| 277 | |
| 278 | if (IS_RIPNG_DEBUG_ZEBRA) |
ajs | 2e23ab2 | 2004-12-08 19:46:50 +0000 | [diff] [blame] | 279 | zlog_debug ("interface down %s index %d flags %ld metric %d mtu %d", |
hasso | 1203e1c | 2004-07-23 21:34:27 +0000 | [diff] [blame] | 280 | ifp->name, ifp->ifindex, ifp->flags, ifp->metric, ifp->mtu6); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 281 | |
| 282 | return 0; |
| 283 | } |
| 284 | |
| 285 | /* Inteface addition message from zebra. */ |
| 286 | int |
| 287 | ripng_interface_add (int command, struct zclient *zclient, zebra_size_t length) |
| 288 | { |
| 289 | struct interface *ifp; |
| 290 | |
| 291 | ifp = zebra_interface_add_read (zclient->ibuf); |
| 292 | |
| 293 | if (IS_RIPNG_DEBUG_ZEBRA) |
ajs | 2e23ab2 | 2004-12-08 19:46:50 +0000 | [diff] [blame] | 294 | zlog_debug ("RIPng interface add %s index %d flags %ld metric %d mtu %d", |
hasso | 1203e1c | 2004-07-23 21:34:27 +0000 | [diff] [blame] | 295 | ifp->name, ifp->ifindex, ifp->flags, ifp->metric, ifp->mtu6); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 296 | |
| 297 | /* Check is this interface is RIP enabled or not.*/ |
| 298 | ripng_enable_apply (ifp); |
| 299 | |
| 300 | /* Apply distribute list to the interface. */ |
| 301 | ripng_distribute_update_interface (ifp); |
| 302 | |
| 303 | /* Check interface routemap. */ |
| 304 | ripng_if_rmap_update_interface (ifp); |
| 305 | |
| 306 | return 0; |
| 307 | } |
| 308 | |
| 309 | int |
| 310 | ripng_interface_delete (int command, struct zclient *zclient, |
| 311 | zebra_size_t length) |
| 312 | { |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 313 | struct interface *ifp; |
| 314 | struct stream *s; |
| 315 | |
| 316 | s = zclient->ibuf; |
| 317 | /* zebra_interface_state_read() updates interface structure in iflist */ |
| 318 | ifp = zebra_interface_state_read(s); |
| 319 | |
| 320 | if (ifp == NULL) |
| 321 | return 0; |
| 322 | |
| 323 | if (if_is_up (ifp)) { |
| 324 | ripng_if_down(ifp); |
| 325 | } |
| 326 | |
| 327 | zlog_info("interface delete %s index %d flags %ld metric %d mtu %d", |
hasso | 1203e1c | 2004-07-23 21:34:27 +0000 | [diff] [blame] | 328 | ifp->name, ifp->ifindex, ifp->flags, ifp->metric, ifp->mtu6); |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 329 | |
| 330 | /* To support pseudo interface do not free interface structure. */ |
| 331 | /* if_delete(ifp); */ |
ajs | d2fc889 | 2005-04-02 18:38:43 +0000 | [diff] [blame] | 332 | ifp->ifindex = IFINDEX_INTERNAL; |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 333 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 334 | return 0; |
| 335 | } |
| 336 | |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 337 | void |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 338 | ripng_interface_clean (void) |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 339 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 340 | struct listnode *node, *nnode; |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 341 | struct interface *ifp; |
| 342 | struct ripng_interface *ri; |
| 343 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 344 | for (ALL_LIST_ELEMENTS (iflist, node, nnode, ifp)) |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 345 | { |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 346 | ri = ifp->info; |
| 347 | |
| 348 | ri->enable_network = 0; |
| 349 | ri->enable_interface = 0; |
| 350 | ri->running = 0; |
| 351 | |
| 352 | if (ri->t_wakeup) |
| 353 | { |
| 354 | thread_cancel (ri->t_wakeup); |
| 355 | ri->t_wakeup = NULL; |
| 356 | } |
| 357 | } |
| 358 | } |
| 359 | |
| 360 | void |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 361 | ripng_interface_reset (void) |
| 362 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 363 | struct listnode *node; |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 364 | struct interface *ifp; |
| 365 | struct ripng_interface *ri; |
| 366 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 367 | for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp)) |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 368 | { |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 369 | ri = ifp->info; |
| 370 | |
| 371 | ri->enable_network = 0; |
| 372 | ri->enable_interface = 0; |
| 373 | ri->running = 0; |
| 374 | |
| 375 | ri->split_horizon = RIPNG_NO_SPLIT_HORIZON; |
| 376 | ri->split_horizon_default = RIPNG_NO_SPLIT_HORIZON; |
| 377 | |
| 378 | ri->list[RIPNG_FILTER_IN] = NULL; |
| 379 | ri->list[RIPNG_FILTER_OUT] = NULL; |
| 380 | |
| 381 | ri->prefix[RIPNG_FILTER_IN] = NULL; |
| 382 | ri->prefix[RIPNG_FILTER_OUT] = NULL; |
| 383 | |
| 384 | if (ri->t_wakeup) |
| 385 | { |
| 386 | thread_cancel (ri->t_wakeup); |
| 387 | ri->t_wakeup = NULL; |
| 388 | } |
| 389 | |
| 390 | ri->passive = 0; |
| 391 | } |
| 392 | } |
| 393 | |
| 394 | static void |
| 395 | ripng_apply_address_add (struct connected *ifc) { |
| 396 | struct prefix_ipv6 address; |
| 397 | struct prefix *p; |
| 398 | |
| 399 | if (!ripng) |
| 400 | return; |
| 401 | |
| 402 | if (! if_is_up(ifc->ifp)) |
| 403 | return; |
| 404 | |
| 405 | p = ifc->address; |
| 406 | |
| 407 | memset (&address, 0, sizeof (address)); |
| 408 | address.family = p->family; |
| 409 | address.prefix = p->u.prefix6; |
| 410 | address.prefixlen = p->prefixlen; |
| 411 | apply_mask_ipv6(&address); |
| 412 | |
| 413 | /* Check if this interface is RIP enabled or not |
| 414 | or Check if this address's prefix is RIP enabled */ |
| 415 | if ((ripng_enable_if_lookup(ifc->ifp->name) >= 0) || |
| 416 | (ripng_enable_network_lookup2(ifc) >= 0)) |
| 417 | ripng_redistribute_add(ZEBRA_ROUTE_CONNECT, RIPNG_ROUTE_INTERFACE, |
| 418 | &address, ifc->ifp->ifindex, NULL); |
| 419 | |
| 420 | } |
| 421 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 422 | int |
| 423 | ripng_interface_address_add (int command, struct zclient *zclient, |
| 424 | zebra_size_t length) |
| 425 | { |
| 426 | struct connected *c; |
| 427 | struct prefix *p; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 428 | |
paul | 0a58935 | 2004-05-08 11:48:26 +0000 | [diff] [blame] | 429 | c = zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_ADD, |
| 430 | zclient->ibuf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 431 | |
| 432 | if (c == NULL) |
| 433 | return 0; |
| 434 | |
| 435 | p = c->address; |
| 436 | |
| 437 | if (p->family == AF_INET6) |
| 438 | { |
Paul Jakma | 995b965 | 2006-05-11 13:20:47 +0000 | [diff] [blame] | 439 | struct ripng_interface *ri = c->ifp->info; |
| 440 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 441 | if (IS_RIPNG_DEBUG_ZEBRA) |
ajs | 2e23ab2 | 2004-12-08 19:46:50 +0000 | [diff] [blame] | 442 | zlog_debug ("RIPng connected address %s/%d add", |
hasso | 3a2ce6a | 2005-04-08 01:30:51 +0000 | [diff] [blame] | 443 | inet6_ntoa(p->u.prefix6), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 444 | p->prefixlen); |
| 445 | |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 446 | /* Check is this prefix needs to be redistributed. */ |
| 447 | ripng_apply_address_add(c); |
| 448 | |
| 449 | /* Let's try once again whether the interface could be activated */ |
Paul Jakma | 995b965 | 2006-05-11 13:20:47 +0000 | [diff] [blame] | 450 | if (!ri->running) { |
| 451 | /* Check if this interface is RIP enabled or not.*/ |
| 452 | ripng_enable_apply (c->ifp); |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 453 | |
Paul Jakma | 995b965 | 2006-05-11 13:20:47 +0000 | [diff] [blame] | 454 | /* Apply distribute list to the interface. */ |
| 455 | ripng_distribute_update_interface (c->ifp); |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 456 | |
Paul Jakma | 995b965 | 2006-05-11 13:20:47 +0000 | [diff] [blame] | 457 | /* Check interface routemap. */ |
| 458 | ripng_if_rmap_update_interface (c->ifp); |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 459 | } |
| 460 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 461 | } |
| 462 | |
| 463 | return 0; |
| 464 | } |
| 465 | |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 466 | static void |
| 467 | ripng_apply_address_del (struct connected *ifc) { |
| 468 | struct prefix_ipv6 address; |
| 469 | struct prefix *p; |
| 470 | |
| 471 | if (!ripng) |
| 472 | return; |
| 473 | |
| 474 | if (! if_is_up(ifc->ifp)) |
| 475 | return; |
| 476 | |
| 477 | p = ifc->address; |
| 478 | |
| 479 | memset (&address, 0, sizeof (address)); |
| 480 | address.family = p->family; |
| 481 | address.prefix = p->u.prefix6; |
| 482 | address.prefixlen = p->prefixlen; |
| 483 | apply_mask_ipv6(&address); |
| 484 | |
| 485 | ripng_redistribute_delete(ZEBRA_ROUTE_CONNECT, RIPNG_ROUTE_INTERFACE, |
| 486 | &address, ifc->ifp->ifindex); |
| 487 | } |
| 488 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 489 | int |
| 490 | ripng_interface_address_delete (int command, struct zclient *zclient, |
| 491 | zebra_size_t length) |
| 492 | { |
| 493 | struct connected *ifc; |
| 494 | struct prefix *p; |
| 495 | char buf[INET6_ADDRSTRLEN]; |
| 496 | |
paul | 0a58935 | 2004-05-08 11:48:26 +0000 | [diff] [blame] | 497 | ifc = zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_DELETE, |
| 498 | zclient->ibuf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 499 | |
| 500 | if (ifc) |
| 501 | { |
| 502 | p = ifc->address; |
| 503 | |
| 504 | if (p->family == AF_INET6) |
| 505 | { |
| 506 | if (IS_RIPNG_DEBUG_ZEBRA) |
ajs | 2e23ab2 | 2004-12-08 19:46:50 +0000 | [diff] [blame] | 507 | zlog_debug ("RIPng connected address %s/%d delete", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 508 | inet_ntop (AF_INET6, &p->u.prefix6, buf, |
| 509 | INET6_ADDRSTRLEN), |
| 510 | p->prefixlen); |
| 511 | |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 512 | /* Check wether this prefix needs to be removed. */ |
| 513 | ripng_apply_address_del(ifc); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 514 | } |
| 515 | connected_free (ifc); |
| 516 | } |
| 517 | |
| 518 | return 0; |
| 519 | } |
| 520 | |
| 521 | /* RIPng enable interface vector. */ |
| 522 | vector ripng_enable_if; |
| 523 | |
| 524 | /* RIPng enable network table. */ |
| 525 | struct route_table *ripng_enable_network; |
| 526 | |
| 527 | /* Lookup RIPng enable network. */ |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 528 | /* Check wether the interface has at least a connected prefix that |
| 529 | * is within the ripng_enable_network table. */ |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 530 | static int |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 531 | ripng_enable_network_lookup_if (struct interface *ifp) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 532 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 533 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 534 | struct connected *connected; |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 535 | struct prefix_ipv6 address; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 536 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 537 | for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, connected)) |
| 538 | { |
| 539 | struct prefix *p; |
| 540 | struct route_node *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 541 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 542 | p = connected->address; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 543 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 544 | if (p->family == AF_INET6) |
| 545 | { |
| 546 | address.family = AF_INET6; |
| 547 | address.prefix = p->u.prefix6; |
| 548 | address.prefixlen = IPV6_MAX_BITLEN; |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 549 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 550 | node = route_node_match (ripng_enable_network, |
| 551 | (struct prefix *)&address); |
| 552 | if (node) |
| 553 | { |
| 554 | route_unlock_node (node); |
| 555 | return 1; |
| 556 | } |
| 557 | } |
| 558 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 559 | return -1; |
| 560 | } |
| 561 | |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 562 | /* Check wether connected is within the ripng_enable_network table. */ |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 563 | static int |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 564 | ripng_enable_network_lookup2 (struct connected *connected) |
| 565 | { |
| 566 | struct prefix_ipv6 address; |
| 567 | struct prefix *p; |
| 568 | |
| 569 | p = connected->address; |
| 570 | |
| 571 | if (p->family == AF_INET6) { |
| 572 | struct route_node *node; |
| 573 | |
| 574 | address.family = p->family; |
| 575 | address.prefix = p->u.prefix6; |
| 576 | address.prefixlen = IPV6_MAX_BITLEN; |
| 577 | |
| 578 | /* LPM on p->family, p->u.prefix6/IPV6_MAX_BITLEN within ripng_enable_network */ |
| 579 | node = route_node_match (ripng_enable_network, |
| 580 | (struct prefix *)&address); |
| 581 | |
| 582 | if (node) { |
| 583 | route_unlock_node (node); |
| 584 | return 1; |
| 585 | } |
| 586 | } |
| 587 | |
| 588 | return -1; |
| 589 | } |
| 590 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 591 | /* Add RIPng enable network. */ |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 592 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 593 | ripng_enable_network_add (struct prefix *p) |
| 594 | { |
| 595 | struct route_node *node; |
| 596 | |
| 597 | node = route_node_get (ripng_enable_network, p); |
| 598 | |
| 599 | if (node->info) |
| 600 | { |
| 601 | route_unlock_node (node); |
| 602 | return -1; |
| 603 | } |
| 604 | else |
hasso | 7a1d583 | 2004-10-08 06:32:23 +0000 | [diff] [blame] | 605 | node->info = (char *) "enabled"; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 606 | |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 607 | /* XXX: One should find a better solution than a generic one */ |
| 608 | ripng_enable_apply_all(); |
| 609 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 610 | return 1; |
| 611 | } |
| 612 | |
| 613 | /* Delete RIPng enable network. */ |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 614 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 615 | ripng_enable_network_delete (struct prefix *p) |
| 616 | { |
| 617 | struct route_node *node; |
| 618 | |
| 619 | node = route_node_lookup (ripng_enable_network, p); |
| 620 | if (node) |
| 621 | { |
| 622 | node->info = NULL; |
| 623 | |
| 624 | /* Unlock info lock. */ |
| 625 | route_unlock_node (node); |
| 626 | |
| 627 | /* Unlock lookup lock. */ |
| 628 | route_unlock_node (node); |
| 629 | |
| 630 | return 1; |
| 631 | } |
| 632 | return -1; |
| 633 | } |
| 634 | |
| 635 | /* Lookup function. */ |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 636 | static int |
hasso | 98b718a | 2004-10-11 12:57:57 +0000 | [diff] [blame] | 637 | ripng_enable_if_lookup (const char *ifname) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 638 | { |
hasso | 7a1d583 | 2004-10-08 06:32:23 +0000 | [diff] [blame] | 639 | unsigned int i; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 640 | char *str; |
| 641 | |
paul | 55468c8 | 2005-03-14 20:19:01 +0000 | [diff] [blame] | 642 | for (i = 0; i < vector_active (ripng_enable_if); i++) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 643 | if ((str = vector_slot (ripng_enable_if, i)) != NULL) |
| 644 | if (strcmp (str, ifname) == 0) |
| 645 | return i; |
| 646 | return -1; |
| 647 | } |
| 648 | |
| 649 | /* Add interface to ripng_enable_if. */ |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 650 | static int |
hasso | 98b718a | 2004-10-11 12:57:57 +0000 | [diff] [blame] | 651 | ripng_enable_if_add (const char *ifname) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 652 | { |
| 653 | int ret; |
| 654 | |
| 655 | ret = ripng_enable_if_lookup (ifname); |
| 656 | if (ret >= 0) |
| 657 | return -1; |
| 658 | |
| 659 | vector_set (ripng_enable_if, strdup (ifname)); |
| 660 | |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 661 | ripng_enable_apply_all(); |
| 662 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 663 | return 1; |
| 664 | } |
| 665 | |
| 666 | /* Delete interface from ripng_enable_if. */ |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 667 | static int |
hasso | 98b718a | 2004-10-11 12:57:57 +0000 | [diff] [blame] | 668 | ripng_enable_if_delete (const char *ifname) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 669 | { |
| 670 | int index; |
| 671 | char *str; |
| 672 | |
| 673 | index = ripng_enable_if_lookup (ifname); |
| 674 | if (index < 0) |
| 675 | return -1; |
| 676 | |
| 677 | str = vector_slot (ripng_enable_if, index); |
| 678 | free (str); |
| 679 | vector_unset (ripng_enable_if, index); |
| 680 | |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 681 | ripng_enable_apply_all(); |
| 682 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 683 | return 1; |
| 684 | } |
| 685 | |
| 686 | /* Wake up interface. */ |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 687 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 688 | ripng_interface_wakeup (struct thread *t) |
| 689 | { |
| 690 | struct interface *ifp; |
| 691 | struct ripng_interface *ri; |
| 692 | |
| 693 | /* Get interface. */ |
| 694 | ifp = THREAD_ARG (t); |
| 695 | |
| 696 | ri = ifp->info; |
| 697 | ri->t_wakeup = NULL; |
| 698 | |
| 699 | /* Join to multicast group. */ |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 700 | if (ripng_multicast_join (ifp) < 0) { |
| 701 | zlog_err ("multicast join failed, interface %s not running", ifp->name); |
| 702 | return 0; |
| 703 | } |
| 704 | |
| 705 | /* Set running flag. */ |
| 706 | ri->running = 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 707 | |
| 708 | /* Send RIP request to the interface. */ |
| 709 | ripng_request (ifp); |
| 710 | |
| 711 | return 0; |
| 712 | } |
| 713 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 714 | static void |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 715 | ripng_connect_set (struct interface *ifp, int set) |
| 716 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 717 | struct listnode *node, *nnode; |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 718 | struct connected *connected; |
| 719 | struct prefix_ipv6 address; |
| 720 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 721 | for (ALL_LIST_ELEMENTS (ifp->connected, node, nnode, connected)) |
| 722 | { |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 723 | struct prefix *p; |
| 724 | p = connected->address; |
| 725 | |
| 726 | if (p->family != AF_INET6) |
| 727 | continue; |
| 728 | |
| 729 | address.family = AF_INET6; |
| 730 | address.prefix = p->u.prefix6; |
| 731 | address.prefixlen = p->prefixlen; |
| 732 | apply_mask_ipv6 (&address); |
| 733 | |
| 734 | if (set) { |
| 735 | /* Check once more wether this prefix is within a "network IF_OR_PREF" one */ |
| 736 | if ((ripng_enable_if_lookup(connected->ifp->name) >= 0) || |
| 737 | (ripng_enable_network_lookup2(connected) >= 0)) |
| 738 | ripng_redistribute_add (ZEBRA_ROUTE_CONNECT, RIPNG_ROUTE_INTERFACE, |
| 739 | &address, connected->ifp->ifindex, NULL); |
| 740 | } else { |
| 741 | ripng_redistribute_delete (ZEBRA_ROUTE_CONNECT, RIPNG_ROUTE_INTERFACE, |
| 742 | &address, connected->ifp->ifindex); |
| 743 | if (ripng_redistribute_check (ZEBRA_ROUTE_CONNECT)) |
| 744 | ripng_redistribute_add (ZEBRA_ROUTE_CONNECT, RIPNG_ROUTE_REDISTRIBUTE, |
| 745 | &address, connected->ifp->ifindex, NULL); |
| 746 | } |
| 747 | } |
| 748 | } |
| 749 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 750 | /* Check RIPng is enabed on this interface. */ |
| 751 | void |
| 752 | ripng_enable_apply (struct interface *ifp) |
| 753 | { |
| 754 | int ret; |
| 755 | struct ripng_interface *ri = NULL; |
| 756 | |
| 757 | /* Check interface. */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 758 | if (! if_is_up (ifp)) |
| 759 | return; |
| 760 | |
| 761 | ri = ifp->info; |
| 762 | |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 763 | /* Is this interface a candidate for RIPng ? */ |
| 764 | ret = ripng_enable_network_lookup_if (ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 765 | |
| 766 | /* If the interface is matched. */ |
| 767 | if (ret > 0) |
| 768 | ri->enable_network = 1; |
| 769 | else |
| 770 | ri->enable_network = 0; |
| 771 | |
| 772 | /* Check interface name configuration. */ |
| 773 | ret = ripng_enable_if_lookup (ifp->name); |
| 774 | if (ret >= 0) |
| 775 | ri->enable_interface = 1; |
| 776 | else |
| 777 | ri->enable_interface = 0; |
| 778 | |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 779 | /* any candidate interface MUST have a link-local IPv6 address */ |
| 780 | if ((! ripng_if_ipv6_lladdress_check (ifp)) && |
| 781 | (ri->enable_network || ri->enable_interface)) { |
| 782 | ri->enable_network = 0; |
| 783 | ri->enable_interface = 0; |
| 784 | zlog_warn("Interface %s does not have any link-local address", |
| 785 | ifp->name); |
| 786 | } |
| 787 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 788 | /* Update running status of the interface. */ |
| 789 | if (ri->enable_network || ri->enable_interface) |
| 790 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 791 | { |
| 792 | if (IS_RIPNG_DEBUG_EVENT) |
ajs | 2e23ab2 | 2004-12-08 19:46:50 +0000 | [diff] [blame] | 793 | zlog_debug ("RIPng turn on %s", ifp->name); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 794 | |
| 795 | /* Add interface wake up thread. */ |
| 796 | if (! ri->t_wakeup) |
| 797 | ri->t_wakeup = thread_add_timer (master, ripng_interface_wakeup, |
| 798 | ifp, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 799 | |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 800 | ripng_connect_set (ifp, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 801 | } |
| 802 | } |
| 803 | else |
| 804 | { |
| 805 | if (ri->running) |
| 806 | { |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 807 | /* Might as well clean up the route table as well |
| 808 | * ripng_if_down sets to 0 ri->running, and displays "turn off %s" |
| 809 | **/ |
| 810 | ripng_if_down(ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 811 | |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 812 | ripng_connect_set (ifp, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 813 | } |
| 814 | } |
| 815 | } |
| 816 | |
| 817 | /* Set distribute list to all interfaces. */ |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 818 | static void |
| 819 | ripng_enable_apply_all (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 820 | { |
| 821 | struct interface *ifp; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 822 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 823 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 824 | for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp)) |
| 825 | ripng_enable_apply (ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 826 | } |
| 827 | |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 828 | /* Clear all network and neighbor configuration */ |
| 829 | void |
| 830 | ripng_clean_network () |
| 831 | { |
hasso | 7a1d583 | 2004-10-08 06:32:23 +0000 | [diff] [blame] | 832 | unsigned int i; |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 833 | char *str; |
| 834 | struct route_node *rn; |
| 835 | |
| 836 | /* ripng_enable_network */ |
| 837 | for (rn = route_top (ripng_enable_network); rn; rn = route_next (rn)) |
| 838 | if (rn->info) { |
| 839 | rn->info = NULL; |
| 840 | route_unlock_node(rn); |
| 841 | } |
| 842 | |
| 843 | /* ripng_enable_if */ |
paul | 55468c8 | 2005-03-14 20:19:01 +0000 | [diff] [blame] | 844 | for (i = 0; i < vector_active (ripng_enable_if); i++) |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 845 | if ((str = vector_slot (ripng_enable_if, i)) != NULL) { |
| 846 | free (str); |
| 847 | vector_slot (ripng_enable_if, i) = NULL; |
| 848 | } |
| 849 | } |
| 850 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 851 | /* Vector to store passive-interface name. */ |
| 852 | vector Vripng_passive_interface; |
| 853 | |
| 854 | /* Utility function for looking up passive interface settings. */ |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 855 | static int |
hasso | 98b718a | 2004-10-11 12:57:57 +0000 | [diff] [blame] | 856 | ripng_passive_interface_lookup (const char *ifname) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 857 | { |
hasso | 7a1d583 | 2004-10-08 06:32:23 +0000 | [diff] [blame] | 858 | unsigned int i; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 859 | char *str; |
| 860 | |
paul | 55468c8 | 2005-03-14 20:19:01 +0000 | [diff] [blame] | 861 | for (i = 0; i < vector_active (Vripng_passive_interface); i++) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 862 | if ((str = vector_slot (Vripng_passive_interface, i)) != NULL) |
| 863 | if (strcmp (str, ifname) == 0) |
| 864 | return i; |
| 865 | return -1; |
| 866 | } |
| 867 | |
| 868 | void |
| 869 | ripng_passive_interface_apply (struct interface *ifp) |
| 870 | { |
| 871 | int ret; |
| 872 | struct ripng_interface *ri; |
| 873 | |
| 874 | ri = ifp->info; |
| 875 | |
| 876 | ret = ripng_passive_interface_lookup (ifp->name); |
| 877 | if (ret < 0) |
| 878 | ri->passive = 0; |
| 879 | else |
| 880 | ri->passive = 1; |
| 881 | } |
| 882 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 883 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 884 | ripng_passive_interface_apply_all (void) |
| 885 | { |
| 886 | struct interface *ifp; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 887 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 888 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 889 | for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp)) |
| 890 | ripng_passive_interface_apply (ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 891 | } |
| 892 | |
| 893 | /* Passive interface. */ |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 894 | static int |
hasso | 98b718a | 2004-10-11 12:57:57 +0000 | [diff] [blame] | 895 | ripng_passive_interface_set (struct vty *vty, const char *ifname) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 896 | { |
| 897 | if (ripng_passive_interface_lookup (ifname) >= 0) |
| 898 | return CMD_WARNING; |
| 899 | |
| 900 | vector_set (Vripng_passive_interface, strdup (ifname)); |
| 901 | |
| 902 | ripng_passive_interface_apply_all (); |
| 903 | |
| 904 | return CMD_SUCCESS; |
| 905 | } |
| 906 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 907 | static int |
hasso | 98b718a | 2004-10-11 12:57:57 +0000 | [diff] [blame] | 908 | ripng_passive_interface_unset (struct vty *vty, const char *ifname) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 909 | { |
| 910 | int i; |
| 911 | char *str; |
| 912 | |
| 913 | i = ripng_passive_interface_lookup (ifname); |
| 914 | if (i < 0) |
| 915 | return CMD_WARNING; |
| 916 | |
| 917 | str = vector_slot (Vripng_passive_interface, i); |
| 918 | free (str); |
| 919 | vector_unset (Vripng_passive_interface, i); |
| 920 | |
| 921 | ripng_passive_interface_apply_all (); |
| 922 | |
| 923 | return CMD_SUCCESS; |
| 924 | } |
| 925 | |
| 926 | /* Free all configured RIP passive-interface settings. */ |
| 927 | void |
| 928 | ripng_passive_interface_clean (void) |
| 929 | { |
hasso | 7a1d583 | 2004-10-08 06:32:23 +0000 | [diff] [blame] | 930 | unsigned int i; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 931 | char *str; |
| 932 | |
paul | 55468c8 | 2005-03-14 20:19:01 +0000 | [diff] [blame] | 933 | for (i = 0; i < vector_active (Vripng_passive_interface); i++) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 934 | if ((str = vector_slot (Vripng_passive_interface, i)) != NULL) |
| 935 | { |
| 936 | free (str); |
| 937 | vector_slot (Vripng_passive_interface, i) = NULL; |
| 938 | } |
| 939 | ripng_passive_interface_apply_all (); |
| 940 | } |
| 941 | |
| 942 | /* Write RIPng enable network and interface to the vty. */ |
| 943 | int |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 944 | ripng_network_write (struct vty *vty, int config_mode) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 945 | { |
hasso | 7a1d583 | 2004-10-08 06:32:23 +0000 | [diff] [blame] | 946 | unsigned int i; |
hasso | 98b718a | 2004-10-11 12:57:57 +0000 | [diff] [blame] | 947 | const char *ifname; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 948 | struct route_node *node; |
| 949 | char buf[BUFSIZ]; |
| 950 | |
| 951 | /* Write enable network. */ |
| 952 | for (node = route_top (ripng_enable_network); node; node = route_next (node)) |
| 953 | if (node->info) |
| 954 | { |
| 955 | struct prefix *p = &node->p; |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 956 | vty_out (vty, "%s%s/%d%s", |
| 957 | config_mode ? " network " : " ", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 958 | inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ), |
| 959 | p->prefixlen, |
| 960 | VTY_NEWLINE); |
| 961 | |
| 962 | } |
| 963 | |
| 964 | /* Write enable interface. */ |
paul | 55468c8 | 2005-03-14 20:19:01 +0000 | [diff] [blame] | 965 | for (i = 0; i < vector_active (ripng_enable_if); i++) |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 966 | if ((ifname = vector_slot (ripng_enable_if, i)) != NULL) |
| 967 | vty_out (vty, "%s%s%s", |
| 968 | config_mode ? " network " : " ", |
| 969 | ifname, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 970 | VTY_NEWLINE); |
| 971 | |
| 972 | /* Write passive interface. */ |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 973 | if (config_mode) |
paul | 55468c8 | 2005-03-14 20:19:01 +0000 | [diff] [blame] | 974 | for (i = 0; i < vector_active (Vripng_passive_interface); i++) |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 975 | if ((ifname = vector_slot (Vripng_passive_interface, i)) != NULL) |
| 976 | vty_out (vty, " passive-interface %s%s", ifname, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 977 | |
| 978 | return 0; |
| 979 | } |
| 980 | |
| 981 | /* RIPng enable on specified interface or matched network. */ |
| 982 | DEFUN (ripng_network, |
| 983 | ripng_network_cmd, |
| 984 | "network IF_OR_ADDR", |
| 985 | "RIPng enable on specified interface or network.\n" |
| 986 | "Interface or address") |
| 987 | { |
| 988 | int ret; |
| 989 | struct prefix p; |
| 990 | |
| 991 | ret = str2prefix (argv[0], &p); |
| 992 | |
| 993 | /* Given string is IPv6 network or interface name. */ |
| 994 | if (ret) |
| 995 | ret = ripng_enable_network_add (&p); |
| 996 | else |
| 997 | ret = ripng_enable_if_add (argv[0]); |
| 998 | |
| 999 | if (ret < 0) |
| 1000 | { |
| 1001 | vty_out (vty, "There is same network configuration %s%s", argv[0], |
| 1002 | VTY_NEWLINE); |
| 1003 | return CMD_WARNING; |
| 1004 | } |
| 1005 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1006 | return CMD_SUCCESS; |
| 1007 | } |
| 1008 | |
| 1009 | /* RIPng enable on specified interface or matched network. */ |
| 1010 | DEFUN (no_ripng_network, |
| 1011 | no_ripng_network_cmd, |
| 1012 | "no network IF_OR_ADDR", |
| 1013 | NO_STR |
| 1014 | "RIPng enable on specified interface or network.\n" |
| 1015 | "Interface or address") |
| 1016 | { |
| 1017 | int ret; |
| 1018 | struct prefix p; |
| 1019 | |
| 1020 | ret = str2prefix (argv[0], &p); |
| 1021 | |
| 1022 | /* Given string is interface name. */ |
| 1023 | if (ret) |
| 1024 | ret = ripng_enable_network_delete (&p); |
| 1025 | else |
| 1026 | ret = ripng_enable_if_delete (argv[0]); |
| 1027 | |
| 1028 | if (ret < 0) |
| 1029 | { |
| 1030 | vty_out (vty, "can't find network %s%s", argv[0], |
| 1031 | VTY_NEWLINE); |
| 1032 | return CMD_WARNING; |
| 1033 | } |
| 1034 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1035 | return CMD_SUCCESS; |
| 1036 | } |
| 1037 | |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 1038 | DEFUN (ipv6_ripng_split_horizon, |
| 1039 | ipv6_ripng_split_horizon_cmd, |
| 1040 | "ipv6 ripng split-horizon", |
| 1041 | IPV6_STR |
| 1042 | "Routing Information Protocol\n" |
| 1043 | "Perform split horizon\n") |
| 1044 | { |
| 1045 | struct interface *ifp; |
| 1046 | struct ripng_interface *ri; |
| 1047 | |
| 1048 | ifp = vty->index; |
| 1049 | ri = ifp->info; |
| 1050 | |
| 1051 | ri->split_horizon = RIPNG_SPLIT_HORIZON; |
| 1052 | return CMD_SUCCESS; |
| 1053 | } |
| 1054 | |
| 1055 | DEFUN (ipv6_ripng_split_horizon_poisoned_reverse, |
| 1056 | ipv6_ripng_split_horizon_poisoned_reverse_cmd, |
| 1057 | "ipv6 ripng split-horizon poisoned-reverse", |
| 1058 | IPV6_STR |
| 1059 | "Routing Information Protocol\n" |
| 1060 | "Perform split horizon\n" |
| 1061 | "With poisoned-reverse\n") |
| 1062 | { |
| 1063 | struct interface *ifp; |
| 1064 | struct ripng_interface *ri; |
| 1065 | |
| 1066 | ifp = vty->index; |
| 1067 | ri = ifp->info; |
| 1068 | |
| 1069 | ri->split_horizon = RIPNG_SPLIT_HORIZON_POISONED_REVERSE; |
| 1070 | return CMD_SUCCESS; |
| 1071 | } |
| 1072 | |
| 1073 | DEFUN (no_ipv6_ripng_split_horizon, |
| 1074 | no_ipv6_ripng_split_horizon_cmd, |
| 1075 | "no ipv6 ripng split-horizon", |
| 1076 | NO_STR |
| 1077 | IPV6_STR |
| 1078 | "Routing Information Protocol\n" |
| 1079 | "Perform split horizon\n") |
| 1080 | { |
| 1081 | struct interface *ifp; |
| 1082 | struct ripng_interface *ri; |
| 1083 | |
| 1084 | ifp = vty->index; |
| 1085 | ri = ifp->info; |
| 1086 | |
| 1087 | ri->split_horizon = RIPNG_NO_SPLIT_HORIZON; |
| 1088 | return CMD_SUCCESS; |
| 1089 | } |
| 1090 | |
| 1091 | ALIAS (no_ipv6_ripng_split_horizon, |
| 1092 | no_ipv6_ripng_split_horizon_poisoned_reverse_cmd, |
| 1093 | "no ipv6 ripng split-horizon poisoned-reverse", |
| 1094 | NO_STR |
| 1095 | IPV6_STR |
| 1096 | "Routing Information Protocol\n" |
| 1097 | "Perform split horizon\n" |
| 1098 | "With poisoned-reverse\n") |
| 1099 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1100 | DEFUN (ripng_passive_interface, |
| 1101 | ripng_passive_interface_cmd, |
| 1102 | "passive-interface IFNAME", |
| 1103 | "Suppress routing updates on an interface\n" |
| 1104 | "Interface name\n") |
| 1105 | { |
| 1106 | return ripng_passive_interface_set (vty, argv[0]); |
| 1107 | } |
| 1108 | |
| 1109 | DEFUN (no_ripng_passive_interface, |
| 1110 | no_ripng_passive_interface_cmd, |
| 1111 | "no passive-interface IFNAME", |
| 1112 | NO_STR |
| 1113 | "Suppress routing updates on an interface\n" |
| 1114 | "Interface name\n") |
| 1115 | { |
| 1116 | return ripng_passive_interface_unset (vty, argv[0]); |
| 1117 | } |
| 1118 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 1119 | static struct ripng_interface * |
| 1120 | ri_new (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1121 | { |
| 1122 | struct ripng_interface *ri; |
| 1123 | ri = XCALLOC (MTYPE_IF, sizeof (struct ripng_interface)); |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 1124 | |
| 1125 | /* Set default split-horizon behavior. If the interface is Frame |
| 1126 | Relay or SMDS is enabled, the default value for split-horizon is |
| 1127 | off. But currently Zebra does detect Frame Relay or SMDS |
| 1128 | interface. So all interface is set to split horizon. */ |
| 1129 | ri->split_horizon_default = RIPNG_SPLIT_HORIZON; |
| 1130 | ri->split_horizon = ri->split_horizon_default; |
| 1131 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1132 | return ri; |
| 1133 | } |
| 1134 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 1135 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1136 | ripng_if_new_hook (struct interface *ifp) |
| 1137 | { |
| 1138 | ifp->info = ri_new (); |
| 1139 | return 0; |
| 1140 | } |
| 1141 | |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 1142 | /* Called when interface structure deleted. */ |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 1143 | static int |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 1144 | ripng_if_delete_hook (struct interface *ifp) |
| 1145 | { |
| 1146 | XFREE (MTYPE_IF, ifp->info); |
| 1147 | ifp->info = NULL; |
| 1148 | return 0; |
| 1149 | } |
| 1150 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1151 | /* Configuration write function for ripngd. */ |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 1152 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1153 | interface_config_write (struct vty *vty) |
| 1154 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 1155 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1156 | struct interface *ifp; |
| 1157 | struct ripng_interface *ri; |
| 1158 | int write = 0; |
| 1159 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1160 | for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1161 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1162 | ri = ifp->info; |
| 1163 | |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 1164 | /* Do not display the interface if there is no |
| 1165 | * configuration about it. |
| 1166 | **/ |
| 1167 | if ((!ifp->desc) && |
| 1168 | (ri->split_horizon == ri->split_horizon_default)) |
| 1169 | continue; |
| 1170 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1171 | vty_out (vty, "interface %s%s", ifp->name, |
| 1172 | VTY_NEWLINE); |
| 1173 | if (ifp->desc) |
| 1174 | vty_out (vty, " description %s%s", ifp->desc, |
| 1175 | VTY_NEWLINE); |
| 1176 | |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 1177 | /* Split horizon. */ |
| 1178 | if (ri->split_horizon != ri->split_horizon_default) |
| 1179 | { |
| 1180 | switch (ri->split_horizon) { |
| 1181 | case RIPNG_SPLIT_HORIZON: |
| 1182 | vty_out (vty, " ipv6 ripng split-horizon%s", VTY_NEWLINE); |
| 1183 | break; |
| 1184 | case RIPNG_SPLIT_HORIZON_POISONED_REVERSE: |
| 1185 | vty_out (vty, " ipv6 ripng split-horizon poisoned-reverse%s", |
| 1186 | VTY_NEWLINE); |
| 1187 | break; |
| 1188 | case RIPNG_NO_SPLIT_HORIZON: |
| 1189 | default: |
| 1190 | vty_out (vty, " no ipv6 ripng split-horizon%s", VTY_NEWLINE); |
| 1191 | break; |
| 1192 | } |
| 1193 | } |
| 1194 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1195 | vty_out (vty, "!%s", VTY_NEWLINE); |
| 1196 | |
| 1197 | write++; |
| 1198 | } |
| 1199 | return write; |
| 1200 | } |
| 1201 | |
| 1202 | /* ripngd's interface node. */ |
Stephen Hemminger | 7fc626d | 2008-12-01 11:10:34 -0800 | [diff] [blame] | 1203 | static struct cmd_node interface_node = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1204 | { |
| 1205 | INTERFACE_NODE, |
| 1206 | "%s(config-if)# ", |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 1207 | 1 /* VTYSH */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1208 | }; |
| 1209 | |
| 1210 | /* Initialization of interface. */ |
| 1211 | void |
| 1212 | ripng_if_init () |
| 1213 | { |
| 1214 | /* Interface initialize. */ |
| 1215 | iflist = list_new (); |
| 1216 | if_add_hook (IF_NEW_HOOK, ripng_if_new_hook); |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 1217 | if_add_hook (IF_DELETE_HOOK, ripng_if_delete_hook); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1218 | |
| 1219 | /* RIPng enable network init. */ |
| 1220 | ripng_enable_network = route_table_init (); |
| 1221 | |
| 1222 | /* RIPng enable interface init. */ |
| 1223 | ripng_enable_if = vector_init (1); |
| 1224 | |
| 1225 | /* RIPng passive interface. */ |
| 1226 | Vripng_passive_interface = vector_init (1); |
| 1227 | |
| 1228 | /* Install interface node. */ |
| 1229 | install_node (&interface_node, interface_config_write); |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 1230 | |
| 1231 | /* Install commands. */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1232 | install_element (CONFIG_NODE, &interface_cmd); |
paul | 32d2463 | 2003-05-23 09:25:20 +0000 | [diff] [blame] | 1233 | install_element (CONFIG_NODE, &no_interface_cmd); |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 1234 | install_default (INTERFACE_NODE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1235 | install_element (INTERFACE_NODE, &interface_desc_cmd); |
| 1236 | install_element (INTERFACE_NODE, &no_interface_desc_cmd); |
| 1237 | |
| 1238 | install_element (RIPNG_NODE, &ripng_network_cmd); |
| 1239 | install_element (RIPNG_NODE, &no_ripng_network_cmd); |
| 1240 | install_element (RIPNG_NODE, &ripng_passive_interface_cmd); |
| 1241 | install_element (RIPNG_NODE, &no_ripng_passive_interface_cmd); |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 1242 | |
| 1243 | install_element (INTERFACE_NODE, &ipv6_ripng_split_horizon_cmd); |
| 1244 | install_element (INTERFACE_NODE, &ipv6_ripng_split_horizon_poisoned_reverse_cmd); |
| 1245 | install_element (INTERFACE_NODE, &no_ipv6_ripng_split_horizon_cmd); |
| 1246 | install_element (INTERFACE_NODE, &no_ipv6_ripng_split_horizon_poisoned_reverse_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1247 | } |