blob: c7865d1e9bf9e8b8a34e5c3d7822db603757536b [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/*
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"
gdt4d4653a2004-07-01 19:26:33 +000037#include "privs.h"
Feng Lu126215c2015-05-22 11:39:58 +020038#include "vrf.h"
paul718e3742002-12-13 20:15:29 +000039
40#include "ripngd/ripngd.h"
41#include "ripngd/ripng_debug.h"
David Lamparter6b0655a2014-06-04 06:53:35 +020042
paul718e3742002-12-13 20:15:29 +000043/* If RFC2133 definition is used. */
44#ifndef IPV6_JOIN_GROUP
45#define IPV6_JOIN_GROUP IPV6_ADD_MEMBERSHIP
46#endif
47#ifndef IPV6_LEAVE_GROUP
48#define IPV6_LEAVE_GROUP IPV6_DROP_MEMBERSHIP
49#endif
50
gdt4d4653a2004-07-01 19:26:33 +000051extern struct zebra_privs_t ripngd_privs;
52
paul718e3742002-12-13 20:15:29 +000053/* Static utility function. */
54static void ripng_enable_apply (struct interface *);
55static void ripng_passive_interface_apply (struct interface *);
Paul Jakma6ac29a52008-08-15 13:45:30 +010056static int ripng_enable_if_lookup (const char *);
57static int ripng_enable_network_lookup2 (struct connected *);
58static void ripng_enable_apply_all (void);
paul718e3742002-12-13 20:15:29 +000059
60/* Join to the all rip routers multicast group. */
Paul Jakma6ac29a52008-08-15 13:45:30 +010061static int
paul718e3742002-12-13 20:15:29 +000062ripng_multicast_join (struct interface *ifp)
63{
64 int ret;
65 struct ipv6_mreq mreq;
ajs656b4ee2005-01-30 18:08:12 +000066 int save_errno;
paul718e3742002-12-13 20:15:29 +000067
hassoa94434b2003-05-25 17:10:12 +000068 if (if_is_up (ifp) && if_is_multicast (ifp)) {
69 memset (&mreq, 0, sizeof (mreq));
70 inet_pton(AF_INET6, RIPNG_GROUP, &mreq.ipv6mr_multiaddr);
71 mreq.ipv6mr_interface = ifp->ifindex;
paul718e3742002-12-13 20:15:29 +000072
gdt4d4653a2004-07-01 19:26:33 +000073 /*
74 * NetBSD 1.6.2 requires root to join groups on gif(4).
75 * While this is bogus, privs are available and easy to use
76 * for this call as a workaround.
77 */
78 if (ripngd_privs.change (ZPRIVS_RAISE))
79 zlog_err ("ripng_multicast_join: could not raise privs");
80
hassoa94434b2003-05-25 17:10:12 +000081 ret = setsockopt (ripng->sock, IPPROTO_IPV6, IPV6_JOIN_GROUP,
82 (char *) &mreq, sizeof (mreq));
ajs656b4ee2005-01-30 18:08:12 +000083 save_errno = errno;
gdtddf1c262004-01-04 01:02:55 +000084
gdt4d4653a2004-07-01 19:26:33 +000085 if (ripngd_privs.change (ZPRIVS_LOWER))
86 zlog_err ("ripng_multicast_join: could not lower privs");
87
ajs656b4ee2005-01-30 18:08:12 +000088 if (ret < 0 && save_errno == EADDRINUSE)
gdtddf1c262004-01-04 01:02:55 +000089 {
90 /*
91 * Group is already joined. This occurs due to sloppy group
92 * management, in particular declining to leave the group on
93 * an interface that has just gone down.
94 */
95 zlog_warn ("ripng join on %s EADDRINUSE (ignoring)\n", ifp->name);
96 return 0; /* not an error */
97 }
98
hassoa94434b2003-05-25 17:10:12 +000099 if (ret < 0)
ajs656b4ee2005-01-30 18:08:12 +0000100 zlog_warn ("can't setsockopt IPV6_JOIN_GROUP: %s",
101 safe_strerror (save_errno));
paul718e3742002-12-13 20:15:29 +0000102
hassoa94434b2003-05-25 17:10:12 +0000103 if (IS_RIPNG_DEBUG_EVENT)
ajs2e23ab22004-12-08 19:46:50 +0000104 zlog_debug ("RIPng %s join to all-rip-routers multicast group", ifp->name);
paul718e3742002-12-13 20:15:29 +0000105
hassoa94434b2003-05-25 17:10:12 +0000106 if (ret < 0)
107 return -1;
108 }
109 return 0;
paul718e3742002-12-13 20:15:29 +0000110}
111
112/* Leave from the all rip routers multicast group. */
Paul Jakma6ac29a52008-08-15 13:45:30 +0100113static int
paul718e3742002-12-13 20:15:29 +0000114ripng_multicast_leave (struct interface *ifp)
115{
116 int ret;
117 struct ipv6_mreq mreq;
118
hassoa94434b2003-05-25 17:10:12 +0000119 if (if_is_up (ifp) && if_is_multicast (ifp)) {
120 memset (&mreq, 0, sizeof (mreq));
121 inet_pton(AF_INET6, RIPNG_GROUP, &mreq.ipv6mr_multiaddr);
122 mreq.ipv6mr_interface = ifp->ifindex;
paul718e3742002-12-13 20:15:29 +0000123
hassoa94434b2003-05-25 17:10:12 +0000124 ret = setsockopt (ripng->sock, IPPROTO_IPV6, IPV6_LEAVE_GROUP,
125 (char *) &mreq, sizeof (mreq));
126 if (ret < 0)
ajs6099b3b2004-11-20 02:06:59 +0000127 zlog_warn ("can't setsockopt IPV6_LEAVE_GROUP: %s\n", safe_strerror (errno));
paul718e3742002-12-13 20:15:29 +0000128
hassoa94434b2003-05-25 17:10:12 +0000129 if (IS_RIPNG_DEBUG_EVENT)
ajs2e23ab22004-12-08 19:46:50 +0000130 zlog_debug ("RIPng %s leave from all-rip-routers multicast group",
hassoa94434b2003-05-25 17:10:12 +0000131 ifp->name);
paul718e3742002-12-13 20:15:29 +0000132
hassoa94434b2003-05-25 17:10:12 +0000133 if (ret < 0)
134 return -1;
135 }
136
137 return 0;
138}
139
140/* How many link local IPv6 address could be used on the interface ? */
Paul Jakma6ac29a52008-08-15 13:45:30 +0100141static int
hassoa94434b2003-05-25 17:10:12 +0000142ripng_if_ipv6_lladdress_check (struct interface *ifp)
143{
144 struct listnode *nn;
145 struct connected *connected;
146 int count = 0;
147
paul1eb8ef22005-04-07 07:30:20 +0000148 for (ALL_LIST_ELEMENTS_RO (ifp->connected, nn, connected))
149 {
hassoa94434b2003-05-25 17:10:12 +0000150 struct prefix *p;
151 p = connected->address;
152
153 if ((p->family == AF_INET6) &&
154 IN6_IS_ADDR_LINKLOCAL (&p->u.prefix6))
155 count++;
156 }
157
158 return count;
paul718e3742002-12-13 20:15:29 +0000159}
160
Paul Jakma6ac29a52008-08-15 13:45:30 +0100161static int
paul718e3742002-12-13 20:15:29 +0000162ripng_if_down (struct interface *ifp)
163{
164 struct route_node *rp;
165 struct ripng_info *rinfo;
166 struct ripng_interface *ri;
Feng Lue97c31a2015-05-22 11:39:53 +0200167 struct list *list = NULL;
168 struct listnode *listnode = NULL, *nextnode = NULL;
paul718e3742002-12-13 20:15:29 +0000169
hassoa94434b2003-05-25 17:10:12 +0000170 if (ripng)
Feng Lue97c31a2015-05-22 11:39:53 +0200171 for (rp = route_top (ripng->table); rp; rp = route_next (rp))
172 if ((list = rp->info) != NULL)
173 for (ALL_LIST_ELEMENTS (list, listnode, nextnode, rinfo))
174 if (rinfo->ifindex == ifp->ifindex)
175 ripng_ecmp_delete (rinfo);
paul718e3742002-12-13 20:15:29 +0000176
177 ri = ifp->info;
178
hassoa94434b2003-05-25 17:10:12 +0000179 if (ri->running)
paul718e3742002-12-13 20:15:29 +0000180 {
181 if (IS_RIPNG_DEBUG_EVENT)
ajs2e23ab22004-12-08 19:46:50 +0000182 zlog_debug ("turn off %s", ifp->name);
paul718e3742002-12-13 20:15:29 +0000183
184 /* Leave from multicast group. */
185 ripng_multicast_leave (ifp);
186
187 ri->running = 0;
188 }
189
190 return 0;
191}
192
193/* Inteface link up message processing. */
194int
195ripng_interface_up (int command, struct zclient *zclient, zebra_size_t length)
196{
197 struct stream *s;
198 struct interface *ifp;
199
200 /* zebra_interface_state_read() updates interface structure in iflist. */
201 s = zclient->ibuf;
202 ifp = zebra_interface_state_read (s);
203
204 if (ifp == NULL)
205 return 0;
206
207 if (IS_RIPNG_DEBUG_ZEBRA)
Stephen Hemminger30d20592009-07-28 11:58:51 +0100208 zlog_debug ("interface up %s index %d flags %llx metric %d mtu %d",
209 ifp->name, ifp->ifindex, (unsigned long long)ifp->flags,
210 ifp->metric, ifp->mtu6);
paul718e3742002-12-13 20:15:29 +0000211
212 /* Check if this interface is RIPng enabled or not. */
213 ripng_enable_apply (ifp);
214
215 /* Check for a passive interface. */
216 ripng_passive_interface_apply (ifp);
217
218 /* Apply distribute list to the all interface. */
219 ripng_distribute_update_interface (ifp);
220
221 return 0;
222}
223
224/* Inteface link down message processing. */
225int
226ripng_interface_down (int command, struct zclient *zclient,
227 zebra_size_t length)
228{
229 struct stream *s;
230 struct interface *ifp;
231
232 /* zebra_interface_state_read() updates interface structure in iflist. */
233 s = zclient->ibuf;
234 ifp = zebra_interface_state_read (s);
235
236 if (ifp == NULL)
237 return 0;
238
239 ripng_if_down (ifp);
240
241 if (IS_RIPNG_DEBUG_ZEBRA)
Stephen Hemminger5eb9d112009-12-10 15:52:33 +0300242 zlog_debug ("interface down %s index %d flags %#llx metric %d mtu %d",
243 ifp->name, ifp->ifindex,
244 (unsigned long long) ifp->flags, ifp->metric, ifp->mtu6);
paul718e3742002-12-13 20:15:29 +0000245
246 return 0;
247}
248
249/* Inteface addition message from zebra. */
250int
251ripng_interface_add (int command, struct zclient *zclient, zebra_size_t length)
252{
253 struct interface *ifp;
254
255 ifp = zebra_interface_add_read (zclient->ibuf);
256
257 if (IS_RIPNG_DEBUG_ZEBRA)
Stephen Hemminger5eb9d112009-12-10 15:52:33 +0300258 zlog_debug ("RIPng interface add %s index %d flags %#llx metric %d mtu %d",
259 ifp->name, ifp->ifindex, (unsigned long long) ifp->flags,
260 ifp->metric, ifp->mtu6);
paul718e3742002-12-13 20:15:29 +0000261
262 /* Check is this interface is RIP enabled or not.*/
263 ripng_enable_apply (ifp);
264
265 /* Apply distribute list to the interface. */
266 ripng_distribute_update_interface (ifp);
267
268 /* Check interface routemap. */
269 ripng_if_rmap_update_interface (ifp);
270
271 return 0;
272}
273
274int
275ripng_interface_delete (int command, struct zclient *zclient,
276 zebra_size_t length)
277{
hassoa94434b2003-05-25 17:10:12 +0000278 struct interface *ifp;
279 struct stream *s;
280
281 s = zclient->ibuf;
282 /* zebra_interface_state_read() updates interface structure in iflist */
283 ifp = zebra_interface_state_read(s);
284
285 if (ifp == NULL)
286 return 0;
287
288 if (if_is_up (ifp)) {
289 ripng_if_down(ifp);
290 }
291
Stephen Hemminger5eb9d112009-12-10 15:52:33 +0300292 zlog_info("interface delete %s index %d flags %#llx metric %d mtu %d",
293 ifp->name, ifp->ifindex, (unsigned long long) ifp->flags,
294 ifp->metric, ifp->mtu6);
hassoa94434b2003-05-25 17:10:12 +0000295
296 /* To support pseudo interface do not free interface structure. */
297 /* if_delete(ifp); */
ajsd2fc8892005-04-02 18:38:43 +0000298 ifp->ifindex = IFINDEX_INTERNAL;
hassoa94434b2003-05-25 17:10:12 +0000299
paul718e3742002-12-13 20:15:29 +0000300 return 0;
301}
302
hassoa94434b2003-05-25 17:10:12 +0000303void
Paul Jakma6ac29a52008-08-15 13:45:30 +0100304ripng_interface_clean (void)
hassoa94434b2003-05-25 17:10:12 +0000305{
paul1eb8ef22005-04-07 07:30:20 +0000306 struct listnode *node, *nnode;
hassoa94434b2003-05-25 17:10:12 +0000307 struct interface *ifp;
308 struct ripng_interface *ri;
309
paul1eb8ef22005-04-07 07:30:20 +0000310 for (ALL_LIST_ELEMENTS (iflist, node, nnode, ifp))
hassoa94434b2003-05-25 17:10:12 +0000311 {
hassoa94434b2003-05-25 17:10:12 +0000312 ri = ifp->info;
313
314 ri->enable_network = 0;
315 ri->enable_interface = 0;
316 ri->running = 0;
317
318 if (ri->t_wakeup)
319 {
320 thread_cancel (ri->t_wakeup);
321 ri->t_wakeup = NULL;
322 }
323 }
324}
325
326void
Paul Jakma6ac29a52008-08-15 13:45:30 +0100327ripng_interface_reset (void)
328{
hasso52dc7ee2004-09-23 19:18:23 +0000329 struct listnode *node;
hassoa94434b2003-05-25 17:10:12 +0000330 struct interface *ifp;
331 struct ripng_interface *ri;
332
paul1eb8ef22005-04-07 07:30:20 +0000333 for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
hassoa94434b2003-05-25 17:10:12 +0000334 {
hassoa94434b2003-05-25 17:10:12 +0000335 ri = ifp->info;
336
337 ri->enable_network = 0;
338 ri->enable_interface = 0;
339 ri->running = 0;
340
341 ri->split_horizon = RIPNG_NO_SPLIT_HORIZON;
342 ri->split_horizon_default = RIPNG_NO_SPLIT_HORIZON;
343
344 ri->list[RIPNG_FILTER_IN] = NULL;
345 ri->list[RIPNG_FILTER_OUT] = NULL;
346
347 ri->prefix[RIPNG_FILTER_IN] = NULL;
348 ri->prefix[RIPNG_FILTER_OUT] = NULL;
349
350 if (ri->t_wakeup)
351 {
352 thread_cancel (ri->t_wakeup);
353 ri->t_wakeup = NULL;
354 }
355
356 ri->passive = 0;
357 }
358}
359
360static void
361ripng_apply_address_add (struct connected *ifc) {
362 struct prefix_ipv6 address;
363 struct prefix *p;
364
365 if (!ripng)
366 return;
367
368 if (! if_is_up(ifc->ifp))
369 return;
370
371 p = ifc->address;
372
373 memset (&address, 0, sizeof (address));
374 address.family = p->family;
375 address.prefix = p->u.prefix6;
376 address.prefixlen = p->prefixlen;
377 apply_mask_ipv6(&address);
378
379 /* Check if this interface is RIP enabled or not
380 or Check if this address's prefix is RIP enabled */
381 if ((ripng_enable_if_lookup(ifc->ifp->name) >= 0) ||
382 (ripng_enable_network_lookup2(ifc) >= 0))
383 ripng_redistribute_add(ZEBRA_ROUTE_CONNECT, RIPNG_ROUTE_INTERFACE,
384 &address, ifc->ifp->ifindex, NULL);
385
386}
387
paul718e3742002-12-13 20:15:29 +0000388int
389ripng_interface_address_add (int command, struct zclient *zclient,
390 zebra_size_t length)
391{
392 struct connected *c;
393 struct prefix *p;
paul718e3742002-12-13 20:15:29 +0000394
paul0a589352004-05-08 11:48:26 +0000395 c = zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_ADD,
396 zclient->ibuf);
paul718e3742002-12-13 20:15:29 +0000397
398 if (c == NULL)
399 return 0;
400
401 p = c->address;
402
403 if (p->family == AF_INET6)
404 {
Paul Jakma995b9652006-05-11 13:20:47 +0000405 struct ripng_interface *ri = c->ifp->info;
406
paul718e3742002-12-13 20:15:29 +0000407 if (IS_RIPNG_DEBUG_ZEBRA)
ajs2e23ab22004-12-08 19:46:50 +0000408 zlog_debug ("RIPng connected address %s/%d add",
hasso3a2ce6a2005-04-08 01:30:51 +0000409 inet6_ntoa(p->u.prefix6),
paul718e3742002-12-13 20:15:29 +0000410 p->prefixlen);
411
hassoa94434b2003-05-25 17:10:12 +0000412 /* Check is this prefix needs to be redistributed. */
413 ripng_apply_address_add(c);
414
415 /* Let's try once again whether the interface could be activated */
Paul Jakma995b9652006-05-11 13:20:47 +0000416 if (!ri->running) {
417 /* Check if this interface is RIP enabled or not.*/
418 ripng_enable_apply (c->ifp);
hassoa94434b2003-05-25 17:10:12 +0000419
Paul Jakma995b9652006-05-11 13:20:47 +0000420 /* Apply distribute list to the interface. */
421 ripng_distribute_update_interface (c->ifp);
hassoa94434b2003-05-25 17:10:12 +0000422
Paul Jakma995b9652006-05-11 13:20:47 +0000423 /* Check interface routemap. */
424 ripng_if_rmap_update_interface (c->ifp);
hassoa94434b2003-05-25 17:10:12 +0000425 }
426
paul718e3742002-12-13 20:15:29 +0000427 }
428
429 return 0;
430}
431
hassoa94434b2003-05-25 17:10:12 +0000432static void
433ripng_apply_address_del (struct connected *ifc) {
434 struct prefix_ipv6 address;
435 struct prefix *p;
436
437 if (!ripng)
438 return;
439
440 if (! if_is_up(ifc->ifp))
441 return;
442
443 p = ifc->address;
444
445 memset (&address, 0, sizeof (address));
446 address.family = p->family;
447 address.prefix = p->u.prefix6;
448 address.prefixlen = p->prefixlen;
449 apply_mask_ipv6(&address);
450
451 ripng_redistribute_delete(ZEBRA_ROUTE_CONNECT, RIPNG_ROUTE_INTERFACE,
452 &address, ifc->ifp->ifindex);
453}
454
paul718e3742002-12-13 20:15:29 +0000455int
456ripng_interface_address_delete (int command, struct zclient *zclient,
457 zebra_size_t length)
458{
459 struct connected *ifc;
460 struct prefix *p;
461 char buf[INET6_ADDRSTRLEN];
462
paul0a589352004-05-08 11:48:26 +0000463 ifc = zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_DELETE,
464 zclient->ibuf);
paul718e3742002-12-13 20:15:29 +0000465
466 if (ifc)
467 {
468 p = ifc->address;
469
470 if (p->family == AF_INET6)
471 {
472 if (IS_RIPNG_DEBUG_ZEBRA)
ajs2e23ab22004-12-08 19:46:50 +0000473 zlog_debug ("RIPng connected address %s/%d delete",
paul718e3742002-12-13 20:15:29 +0000474 inet_ntop (AF_INET6, &p->u.prefix6, buf,
475 INET6_ADDRSTRLEN),
476 p->prefixlen);
477
hassoa94434b2003-05-25 17:10:12 +0000478 /* Check wether this prefix needs to be removed. */
479 ripng_apply_address_del(ifc);
paul718e3742002-12-13 20:15:29 +0000480 }
481 connected_free (ifc);
482 }
483
484 return 0;
485}
David Lamparter6b0655a2014-06-04 06:53:35 +0200486
paul718e3742002-12-13 20:15:29 +0000487/* RIPng enable interface vector. */
488vector ripng_enable_if;
489
490/* RIPng enable network table. */
491struct route_table *ripng_enable_network;
492
493/* Lookup RIPng enable network. */
hassoa94434b2003-05-25 17:10:12 +0000494/* Check wether the interface has at least a connected prefix that
495 * is within the ripng_enable_network table. */
Paul Jakma6ac29a52008-08-15 13:45:30 +0100496static int
hassoa94434b2003-05-25 17:10:12 +0000497ripng_enable_network_lookup_if (struct interface *ifp)
paul718e3742002-12-13 20:15:29 +0000498{
paul1eb8ef22005-04-07 07:30:20 +0000499 struct listnode *node;
paul718e3742002-12-13 20:15:29 +0000500 struct connected *connected;
hassoa94434b2003-05-25 17:10:12 +0000501 struct prefix_ipv6 address;
paul718e3742002-12-13 20:15:29 +0000502
paul1eb8ef22005-04-07 07:30:20 +0000503 for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, connected))
504 {
505 struct prefix *p;
506 struct route_node *node;
paul718e3742002-12-13 20:15:29 +0000507
paul1eb8ef22005-04-07 07:30:20 +0000508 p = connected->address;
paul718e3742002-12-13 20:15:29 +0000509
paul1eb8ef22005-04-07 07:30:20 +0000510 if (p->family == AF_INET6)
511 {
512 address.family = AF_INET6;
513 address.prefix = p->u.prefix6;
514 address.prefixlen = IPV6_MAX_BITLEN;
hassoa94434b2003-05-25 17:10:12 +0000515
paul1eb8ef22005-04-07 07:30:20 +0000516 node = route_node_match (ripng_enable_network,
517 (struct prefix *)&address);
518 if (node)
519 {
520 route_unlock_node (node);
521 return 1;
522 }
523 }
524 }
paul718e3742002-12-13 20:15:29 +0000525 return -1;
526}
527
hassoa94434b2003-05-25 17:10:12 +0000528/* Check wether connected is within the ripng_enable_network table. */
Paul Jakma6ac29a52008-08-15 13:45:30 +0100529static int
hassoa94434b2003-05-25 17:10:12 +0000530ripng_enable_network_lookup2 (struct connected *connected)
531{
532 struct prefix_ipv6 address;
533 struct prefix *p;
534
535 p = connected->address;
536
537 if (p->family == AF_INET6) {
538 struct route_node *node;
539
540 address.family = p->family;
541 address.prefix = p->u.prefix6;
542 address.prefixlen = IPV6_MAX_BITLEN;
543
544 /* LPM on p->family, p->u.prefix6/IPV6_MAX_BITLEN within ripng_enable_network */
545 node = route_node_match (ripng_enable_network,
546 (struct prefix *)&address);
547
548 if (node) {
549 route_unlock_node (node);
550 return 1;
551 }
552 }
553
554 return -1;
555}
556
paul718e3742002-12-13 20:15:29 +0000557/* Add RIPng enable network. */
Paul Jakma6ac29a52008-08-15 13:45:30 +0100558static int
paul718e3742002-12-13 20:15:29 +0000559ripng_enable_network_add (struct prefix *p)
560{
561 struct route_node *node;
562
563 node = route_node_get (ripng_enable_network, p);
564
565 if (node->info)
566 {
567 route_unlock_node (node);
568 return -1;
569 }
570 else
hasso7a1d5832004-10-08 06:32:23 +0000571 node->info = (char *) "enabled";
paul718e3742002-12-13 20:15:29 +0000572
hassoa94434b2003-05-25 17:10:12 +0000573 /* XXX: One should find a better solution than a generic one */
574 ripng_enable_apply_all();
575
paul718e3742002-12-13 20:15:29 +0000576 return 1;
577}
578
579/* Delete RIPng enable network. */
Paul Jakma6ac29a52008-08-15 13:45:30 +0100580static int
paul718e3742002-12-13 20:15:29 +0000581ripng_enable_network_delete (struct prefix *p)
582{
583 struct route_node *node;
584
585 node = route_node_lookup (ripng_enable_network, p);
586 if (node)
587 {
588 node->info = NULL;
589
590 /* Unlock info lock. */
591 route_unlock_node (node);
592
593 /* Unlock lookup lock. */
594 route_unlock_node (node);
595
596 return 1;
597 }
598 return -1;
599}
600
601/* Lookup function. */
Paul Jakma6ac29a52008-08-15 13:45:30 +0100602static int
hasso98b718a2004-10-11 12:57:57 +0000603ripng_enable_if_lookup (const char *ifname)
paul718e3742002-12-13 20:15:29 +0000604{
hasso7a1d5832004-10-08 06:32:23 +0000605 unsigned int i;
paul718e3742002-12-13 20:15:29 +0000606 char *str;
607
paul55468c82005-03-14 20:19:01 +0000608 for (i = 0; i < vector_active (ripng_enable_if); i++)
paul718e3742002-12-13 20:15:29 +0000609 if ((str = vector_slot (ripng_enable_if, i)) != NULL)
610 if (strcmp (str, ifname) == 0)
611 return i;
612 return -1;
613}
614
615/* Add interface to ripng_enable_if. */
Paul Jakma6ac29a52008-08-15 13:45:30 +0100616static int
hasso98b718a2004-10-11 12:57:57 +0000617ripng_enable_if_add (const char *ifname)
paul718e3742002-12-13 20:15:29 +0000618{
619 int ret;
620
621 ret = ripng_enable_if_lookup (ifname);
622 if (ret >= 0)
623 return -1;
624
625 vector_set (ripng_enable_if, strdup (ifname));
626
hassoa94434b2003-05-25 17:10:12 +0000627 ripng_enable_apply_all();
628
paul718e3742002-12-13 20:15:29 +0000629 return 1;
630}
631
632/* Delete interface from ripng_enable_if. */
Paul Jakma6ac29a52008-08-15 13:45:30 +0100633static int
hasso98b718a2004-10-11 12:57:57 +0000634ripng_enable_if_delete (const char *ifname)
paul718e3742002-12-13 20:15:29 +0000635{
636 int index;
637 char *str;
638
639 index = ripng_enable_if_lookup (ifname);
640 if (index < 0)
641 return -1;
642
643 str = vector_slot (ripng_enable_if, index);
644 free (str);
645 vector_unset (ripng_enable_if, index);
646
hassoa94434b2003-05-25 17:10:12 +0000647 ripng_enable_apply_all();
648
paul718e3742002-12-13 20:15:29 +0000649 return 1;
650}
651
652/* Wake up interface. */
Paul Jakma6ac29a52008-08-15 13:45:30 +0100653static int
paul718e3742002-12-13 20:15:29 +0000654ripng_interface_wakeup (struct thread *t)
655{
656 struct interface *ifp;
657 struct ripng_interface *ri;
658
659 /* Get interface. */
660 ifp = THREAD_ARG (t);
661
662 ri = ifp->info;
663 ri->t_wakeup = NULL;
664
665 /* Join to multicast group. */
hassoa94434b2003-05-25 17:10:12 +0000666 if (ripng_multicast_join (ifp) < 0) {
667 zlog_err ("multicast join failed, interface %s not running", ifp->name);
668 return 0;
669 }
670
671 /* Set running flag. */
672 ri->running = 1;
paul718e3742002-12-13 20:15:29 +0000673
674 /* Send RIP request to the interface. */
675 ripng_request (ifp);
676
677 return 0;
678}
679
Paul Jakma6ac29a52008-08-15 13:45:30 +0100680static void
hassoa94434b2003-05-25 17:10:12 +0000681ripng_connect_set (struct interface *ifp, int set)
682{
paul1eb8ef22005-04-07 07:30:20 +0000683 struct listnode *node, *nnode;
hassoa94434b2003-05-25 17:10:12 +0000684 struct connected *connected;
685 struct prefix_ipv6 address;
686
paul1eb8ef22005-04-07 07:30:20 +0000687 for (ALL_LIST_ELEMENTS (ifp->connected, node, nnode, connected))
688 {
hassoa94434b2003-05-25 17:10:12 +0000689 struct prefix *p;
690 p = connected->address;
691
692 if (p->family != AF_INET6)
693 continue;
694
695 address.family = AF_INET6;
696 address.prefix = p->u.prefix6;
697 address.prefixlen = p->prefixlen;
698 apply_mask_ipv6 (&address);
699
700 if (set) {
701 /* Check once more wether this prefix is within a "network IF_OR_PREF" one */
702 if ((ripng_enable_if_lookup(connected->ifp->name) >= 0) ||
703 (ripng_enable_network_lookup2(connected) >= 0))
704 ripng_redistribute_add (ZEBRA_ROUTE_CONNECT, RIPNG_ROUTE_INTERFACE,
705 &address, connected->ifp->ifindex, NULL);
706 } else {
707 ripng_redistribute_delete (ZEBRA_ROUTE_CONNECT, RIPNG_ROUTE_INTERFACE,
708 &address, connected->ifp->ifindex);
709 if (ripng_redistribute_check (ZEBRA_ROUTE_CONNECT))
710 ripng_redistribute_add (ZEBRA_ROUTE_CONNECT, RIPNG_ROUTE_REDISTRIBUTE,
711 &address, connected->ifp->ifindex, NULL);
712 }
713 }
714}
715
paul718e3742002-12-13 20:15:29 +0000716/* Check RIPng is enabed on this interface. */
717void
718ripng_enable_apply (struct interface *ifp)
719{
720 int ret;
721 struct ripng_interface *ri = NULL;
722
723 /* Check interface. */
paul718e3742002-12-13 20:15:29 +0000724 if (! if_is_up (ifp))
725 return;
726
727 ri = ifp->info;
728
hassoa94434b2003-05-25 17:10:12 +0000729 /* Is this interface a candidate for RIPng ? */
730 ret = ripng_enable_network_lookup_if (ifp);
paul718e3742002-12-13 20:15:29 +0000731
732 /* If the interface is matched. */
733 if (ret > 0)
734 ri->enable_network = 1;
735 else
736 ri->enable_network = 0;
737
738 /* Check interface name configuration. */
739 ret = ripng_enable_if_lookup (ifp->name);
740 if (ret >= 0)
741 ri->enable_interface = 1;
742 else
743 ri->enable_interface = 0;
744
hassoa94434b2003-05-25 17:10:12 +0000745 /* any candidate interface MUST have a link-local IPv6 address */
746 if ((! ripng_if_ipv6_lladdress_check (ifp)) &&
747 (ri->enable_network || ri->enable_interface)) {
748 ri->enable_network = 0;
749 ri->enable_interface = 0;
750 zlog_warn("Interface %s does not have any link-local address",
751 ifp->name);
752 }
753
paul718e3742002-12-13 20:15:29 +0000754 /* Update running status of the interface. */
755 if (ri->enable_network || ri->enable_interface)
756 {
paul718e3742002-12-13 20:15:29 +0000757 {
758 if (IS_RIPNG_DEBUG_EVENT)
ajs2e23ab22004-12-08 19:46:50 +0000759 zlog_debug ("RIPng turn on %s", ifp->name);
paul718e3742002-12-13 20:15:29 +0000760
761 /* Add interface wake up thread. */
762 if (! ri->t_wakeup)
763 ri->t_wakeup = thread_add_timer (master, ripng_interface_wakeup,
764 ifp, 1);
paul718e3742002-12-13 20:15:29 +0000765
hassoa94434b2003-05-25 17:10:12 +0000766 ripng_connect_set (ifp, 1);
paul718e3742002-12-13 20:15:29 +0000767 }
768 }
769 else
770 {
771 if (ri->running)
772 {
hassoa94434b2003-05-25 17:10:12 +0000773 /* Might as well clean up the route table as well
774 * ripng_if_down sets to 0 ri->running, and displays "turn off %s"
775 **/
776 ripng_if_down(ifp);
paul718e3742002-12-13 20:15:29 +0000777
hassoa94434b2003-05-25 17:10:12 +0000778 ripng_connect_set (ifp, 0);
paul718e3742002-12-13 20:15:29 +0000779 }
780 }
781}
782
783/* Set distribute list to all interfaces. */
Paul Jakma6ac29a52008-08-15 13:45:30 +0100784static void
785ripng_enable_apply_all (void)
paul718e3742002-12-13 20:15:29 +0000786{
787 struct interface *ifp;
hasso52dc7ee2004-09-23 19:18:23 +0000788 struct listnode *node;
paul718e3742002-12-13 20:15:29 +0000789
paul1eb8ef22005-04-07 07:30:20 +0000790 for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
791 ripng_enable_apply (ifp);
paul718e3742002-12-13 20:15:29 +0000792}
David Lamparter6b0655a2014-06-04 06:53:35 +0200793
hassoa94434b2003-05-25 17:10:12 +0000794/* Clear all network and neighbor configuration */
795void
796ripng_clean_network ()
797{
hasso7a1d5832004-10-08 06:32:23 +0000798 unsigned int i;
hassoa94434b2003-05-25 17:10:12 +0000799 char *str;
800 struct route_node *rn;
801
802 /* ripng_enable_network */
803 for (rn = route_top (ripng_enable_network); rn; rn = route_next (rn))
804 if (rn->info) {
805 rn->info = NULL;
806 route_unlock_node(rn);
807 }
808
809 /* ripng_enable_if */
paul55468c82005-03-14 20:19:01 +0000810 for (i = 0; i < vector_active (ripng_enable_if); i++)
hassoa94434b2003-05-25 17:10:12 +0000811 if ((str = vector_slot (ripng_enable_if, i)) != NULL) {
812 free (str);
813 vector_slot (ripng_enable_if, i) = NULL;
814 }
815}
David Lamparter6b0655a2014-06-04 06:53:35 +0200816
paul718e3742002-12-13 20:15:29 +0000817/* Vector to store passive-interface name. */
818vector Vripng_passive_interface;
819
820/* Utility function for looking up passive interface settings. */
Paul Jakma6ac29a52008-08-15 13:45:30 +0100821static int
hasso98b718a2004-10-11 12:57:57 +0000822ripng_passive_interface_lookup (const char *ifname)
paul718e3742002-12-13 20:15:29 +0000823{
hasso7a1d5832004-10-08 06:32:23 +0000824 unsigned int i;
paul718e3742002-12-13 20:15:29 +0000825 char *str;
826
paul55468c82005-03-14 20:19:01 +0000827 for (i = 0; i < vector_active (Vripng_passive_interface); i++)
paul718e3742002-12-13 20:15:29 +0000828 if ((str = vector_slot (Vripng_passive_interface, i)) != NULL)
829 if (strcmp (str, ifname) == 0)
830 return i;
831 return -1;
832}
833
834void
835ripng_passive_interface_apply (struct interface *ifp)
836{
837 int ret;
838 struct ripng_interface *ri;
839
840 ri = ifp->info;
841
842 ret = ripng_passive_interface_lookup (ifp->name);
843 if (ret < 0)
844 ri->passive = 0;
845 else
846 ri->passive = 1;
847}
848
Paul Jakma6ac29a52008-08-15 13:45:30 +0100849static void
paul718e3742002-12-13 20:15:29 +0000850ripng_passive_interface_apply_all (void)
851{
852 struct interface *ifp;
hasso52dc7ee2004-09-23 19:18:23 +0000853 struct listnode *node;
paul718e3742002-12-13 20:15:29 +0000854
paul1eb8ef22005-04-07 07:30:20 +0000855 for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
856 ripng_passive_interface_apply (ifp);
paul718e3742002-12-13 20:15:29 +0000857}
858
859/* Passive interface. */
Paul Jakma6ac29a52008-08-15 13:45:30 +0100860static int
hasso98b718a2004-10-11 12:57:57 +0000861ripng_passive_interface_set (struct vty *vty, const char *ifname)
paul718e3742002-12-13 20:15:29 +0000862{
863 if (ripng_passive_interface_lookup (ifname) >= 0)
864 return CMD_WARNING;
865
866 vector_set (Vripng_passive_interface, strdup (ifname));
867
868 ripng_passive_interface_apply_all ();
869
870 return CMD_SUCCESS;
871}
872
Paul Jakma6ac29a52008-08-15 13:45:30 +0100873static int
hasso98b718a2004-10-11 12:57:57 +0000874ripng_passive_interface_unset (struct vty *vty, const char *ifname)
paul718e3742002-12-13 20:15:29 +0000875{
876 int i;
877 char *str;
878
879 i = ripng_passive_interface_lookup (ifname);
880 if (i < 0)
881 return CMD_WARNING;
882
883 str = vector_slot (Vripng_passive_interface, i);
884 free (str);
885 vector_unset (Vripng_passive_interface, i);
886
887 ripng_passive_interface_apply_all ();
888
889 return CMD_SUCCESS;
890}
891
892/* Free all configured RIP passive-interface settings. */
893void
894ripng_passive_interface_clean (void)
895{
hasso7a1d5832004-10-08 06:32:23 +0000896 unsigned int i;
paul718e3742002-12-13 20:15:29 +0000897 char *str;
898
paul55468c82005-03-14 20:19:01 +0000899 for (i = 0; i < vector_active (Vripng_passive_interface); i++)
paul718e3742002-12-13 20:15:29 +0000900 if ((str = vector_slot (Vripng_passive_interface, i)) != NULL)
901 {
902 free (str);
903 vector_slot (Vripng_passive_interface, i) = NULL;
904 }
905 ripng_passive_interface_apply_all ();
906}
907
908/* Write RIPng enable network and interface to the vty. */
909int
hassoa94434b2003-05-25 17:10:12 +0000910ripng_network_write (struct vty *vty, int config_mode)
paul718e3742002-12-13 20:15:29 +0000911{
hasso7a1d5832004-10-08 06:32:23 +0000912 unsigned int i;
hasso98b718a2004-10-11 12:57:57 +0000913 const char *ifname;
paul718e3742002-12-13 20:15:29 +0000914 struct route_node *node;
915 char buf[BUFSIZ];
916
917 /* Write enable network. */
918 for (node = route_top (ripng_enable_network); node; node = route_next (node))
919 if (node->info)
920 {
921 struct prefix *p = &node->p;
hassoa94434b2003-05-25 17:10:12 +0000922 vty_out (vty, "%s%s/%d%s",
923 config_mode ? " network " : " ",
paul718e3742002-12-13 20:15:29 +0000924 inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ),
925 p->prefixlen,
926 VTY_NEWLINE);
927
928 }
929
930 /* Write enable interface. */
paul55468c82005-03-14 20:19:01 +0000931 for (i = 0; i < vector_active (ripng_enable_if); i++)
hassoa94434b2003-05-25 17:10:12 +0000932 if ((ifname = vector_slot (ripng_enable_if, i)) != NULL)
933 vty_out (vty, "%s%s%s",
934 config_mode ? " network " : " ",
935 ifname,
paul718e3742002-12-13 20:15:29 +0000936 VTY_NEWLINE);
937
938 /* Write passive interface. */
hassoa94434b2003-05-25 17:10:12 +0000939 if (config_mode)
paul55468c82005-03-14 20:19:01 +0000940 for (i = 0; i < vector_active (Vripng_passive_interface); i++)
hassoa94434b2003-05-25 17:10:12 +0000941 if ((ifname = vector_slot (Vripng_passive_interface, i)) != NULL)
942 vty_out (vty, " passive-interface %s%s", ifname, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +0000943
944 return 0;
945}
946
947/* RIPng enable on specified interface or matched network. */
948DEFUN (ripng_network,
949 ripng_network_cmd,
950 "network IF_OR_ADDR",
951 "RIPng enable on specified interface or network.\n"
952 "Interface or address")
953{
954 int ret;
955 struct prefix p;
956
957 ret = str2prefix (argv[0], &p);
958
959 /* Given string is IPv6 network or interface name. */
960 if (ret)
961 ret = ripng_enable_network_add (&p);
962 else
963 ret = ripng_enable_if_add (argv[0]);
964
965 if (ret < 0)
966 {
967 vty_out (vty, "There is same network configuration %s%s", argv[0],
968 VTY_NEWLINE);
969 return CMD_WARNING;
970 }
971
paul718e3742002-12-13 20:15:29 +0000972 return CMD_SUCCESS;
973}
974
975/* RIPng enable on specified interface or matched network. */
976DEFUN (no_ripng_network,
977 no_ripng_network_cmd,
978 "no network IF_OR_ADDR",
979 NO_STR
980 "RIPng enable on specified interface or network.\n"
981 "Interface or address")
982{
983 int ret;
984 struct prefix p;
985
986 ret = str2prefix (argv[0], &p);
987
988 /* Given string is interface name. */
989 if (ret)
990 ret = ripng_enable_network_delete (&p);
991 else
992 ret = ripng_enable_if_delete (argv[0]);
993
994 if (ret < 0)
995 {
996 vty_out (vty, "can't find network %s%s", argv[0],
997 VTY_NEWLINE);
998 return CMD_WARNING;
999 }
1000
paul718e3742002-12-13 20:15:29 +00001001 return CMD_SUCCESS;
1002}
1003
hassoa94434b2003-05-25 17:10:12 +00001004DEFUN (ipv6_ripng_split_horizon,
1005 ipv6_ripng_split_horizon_cmd,
1006 "ipv6 ripng split-horizon",
1007 IPV6_STR
1008 "Routing Information Protocol\n"
1009 "Perform split horizon\n")
1010{
1011 struct interface *ifp;
1012 struct ripng_interface *ri;
1013
1014 ifp = vty->index;
1015 ri = ifp->info;
1016
1017 ri->split_horizon = RIPNG_SPLIT_HORIZON;
1018 return CMD_SUCCESS;
1019}
1020
1021DEFUN (ipv6_ripng_split_horizon_poisoned_reverse,
1022 ipv6_ripng_split_horizon_poisoned_reverse_cmd,
1023 "ipv6 ripng split-horizon poisoned-reverse",
1024 IPV6_STR
1025 "Routing Information Protocol\n"
1026 "Perform split horizon\n"
1027 "With poisoned-reverse\n")
1028{
1029 struct interface *ifp;
1030 struct ripng_interface *ri;
1031
1032 ifp = vty->index;
1033 ri = ifp->info;
1034
1035 ri->split_horizon = RIPNG_SPLIT_HORIZON_POISONED_REVERSE;
1036 return CMD_SUCCESS;
1037}
1038
1039DEFUN (no_ipv6_ripng_split_horizon,
1040 no_ipv6_ripng_split_horizon_cmd,
1041 "no ipv6 ripng split-horizon",
1042 NO_STR
1043 IPV6_STR
1044 "Routing Information Protocol\n"
1045 "Perform split horizon\n")
1046{
1047 struct interface *ifp;
1048 struct ripng_interface *ri;
1049
1050 ifp = vty->index;
1051 ri = ifp->info;
1052
1053 ri->split_horizon = RIPNG_NO_SPLIT_HORIZON;
1054 return CMD_SUCCESS;
1055}
1056
1057ALIAS (no_ipv6_ripng_split_horizon,
1058 no_ipv6_ripng_split_horizon_poisoned_reverse_cmd,
1059 "no ipv6 ripng split-horizon poisoned-reverse",
1060 NO_STR
1061 IPV6_STR
1062 "Routing Information Protocol\n"
1063 "Perform split horizon\n"
1064 "With poisoned-reverse\n")
1065
paul718e3742002-12-13 20:15:29 +00001066DEFUN (ripng_passive_interface,
1067 ripng_passive_interface_cmd,
1068 "passive-interface IFNAME",
1069 "Suppress routing updates on an interface\n"
1070 "Interface name\n")
1071{
1072 return ripng_passive_interface_set (vty, argv[0]);
1073}
1074
1075DEFUN (no_ripng_passive_interface,
1076 no_ripng_passive_interface_cmd,
1077 "no passive-interface IFNAME",
1078 NO_STR
1079 "Suppress routing updates on an interface\n"
1080 "Interface name\n")
1081{
1082 return ripng_passive_interface_unset (vty, argv[0]);
1083}
David Lamparter6b0655a2014-06-04 06:53:35 +02001084
Paul Jakma6ac29a52008-08-15 13:45:30 +01001085static struct ripng_interface *
1086ri_new (void)
paul718e3742002-12-13 20:15:29 +00001087{
1088 struct ripng_interface *ri;
1089 ri = XCALLOC (MTYPE_IF, sizeof (struct ripng_interface));
hassoa94434b2003-05-25 17:10:12 +00001090
1091 /* Set default split-horizon behavior. If the interface is Frame
1092 Relay or SMDS is enabled, the default value for split-horizon is
1093 off. But currently Zebra does detect Frame Relay or SMDS
1094 interface. So all interface is set to split horizon. */
1095 ri->split_horizon_default = RIPNG_SPLIT_HORIZON;
1096 ri->split_horizon = ri->split_horizon_default;
1097
paul718e3742002-12-13 20:15:29 +00001098 return ri;
1099}
1100
Paul Jakma6ac29a52008-08-15 13:45:30 +01001101static int
paul718e3742002-12-13 20:15:29 +00001102ripng_if_new_hook (struct interface *ifp)
1103{
1104 ifp->info = ri_new ();
1105 return 0;
1106}
1107
hassoa94434b2003-05-25 17:10:12 +00001108/* Called when interface structure deleted. */
Paul Jakma6ac29a52008-08-15 13:45:30 +01001109static int
hassoa94434b2003-05-25 17:10:12 +00001110ripng_if_delete_hook (struct interface *ifp)
1111{
1112 XFREE (MTYPE_IF, ifp->info);
1113 ifp->info = NULL;
1114 return 0;
1115}
1116
paul718e3742002-12-13 20:15:29 +00001117/* Configuration write function for ripngd. */
Paul Jakma6ac29a52008-08-15 13:45:30 +01001118static int
paul718e3742002-12-13 20:15:29 +00001119interface_config_write (struct vty *vty)
1120{
hasso52dc7ee2004-09-23 19:18:23 +00001121 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00001122 struct interface *ifp;
1123 struct ripng_interface *ri;
1124 int write = 0;
1125
paul1eb8ef22005-04-07 07:30:20 +00001126 for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
paul718e3742002-12-13 20:15:29 +00001127 {
paul718e3742002-12-13 20:15:29 +00001128 ri = ifp->info;
1129
hassoa94434b2003-05-25 17:10:12 +00001130 /* Do not display the interface if there is no
1131 * configuration about it.
1132 **/
1133 if ((!ifp->desc) &&
1134 (ri->split_horizon == ri->split_horizon_default))
1135 continue;
1136
paul718e3742002-12-13 20:15:29 +00001137 vty_out (vty, "interface %s%s", ifp->name,
1138 VTY_NEWLINE);
1139 if (ifp->desc)
1140 vty_out (vty, " description %s%s", ifp->desc,
1141 VTY_NEWLINE);
1142
hassoa94434b2003-05-25 17:10:12 +00001143 /* Split horizon. */
1144 if (ri->split_horizon != ri->split_horizon_default)
1145 {
1146 switch (ri->split_horizon) {
1147 case RIPNG_SPLIT_HORIZON:
1148 vty_out (vty, " ipv6 ripng split-horizon%s", VTY_NEWLINE);
1149 break;
1150 case RIPNG_SPLIT_HORIZON_POISONED_REVERSE:
1151 vty_out (vty, " ipv6 ripng split-horizon poisoned-reverse%s",
1152 VTY_NEWLINE);
1153 break;
1154 case RIPNG_NO_SPLIT_HORIZON:
1155 default:
1156 vty_out (vty, " no ipv6 ripng split-horizon%s", VTY_NEWLINE);
1157 break;
1158 }
1159 }
1160
paul718e3742002-12-13 20:15:29 +00001161 vty_out (vty, "!%s", VTY_NEWLINE);
1162
1163 write++;
1164 }
1165 return write;
1166}
1167
1168/* ripngd's interface node. */
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08001169static struct cmd_node interface_node =
paul718e3742002-12-13 20:15:29 +00001170{
1171 INTERFACE_NODE,
1172 "%s(config-if)# ",
hassoa94434b2003-05-25 17:10:12 +00001173 1 /* VTYSH */
paul718e3742002-12-13 20:15:29 +00001174};
1175
1176/* Initialization of interface. */
1177void
1178ripng_if_init ()
1179{
1180 /* Interface initialize. */
paul718e3742002-12-13 20:15:29 +00001181 if_add_hook (IF_NEW_HOOK, ripng_if_new_hook);
hassoa94434b2003-05-25 17:10:12 +00001182 if_add_hook (IF_DELETE_HOOK, ripng_if_delete_hook);
paul718e3742002-12-13 20:15:29 +00001183
1184 /* RIPng enable network init. */
1185 ripng_enable_network = route_table_init ();
1186
1187 /* RIPng enable interface init. */
1188 ripng_enable_if = vector_init (1);
1189
1190 /* RIPng passive interface. */
1191 Vripng_passive_interface = vector_init (1);
1192
1193 /* Install interface node. */
1194 install_node (&interface_node, interface_config_write);
hassoa94434b2003-05-25 17:10:12 +00001195
1196 /* Install commands. */
paul718e3742002-12-13 20:15:29 +00001197 install_element (CONFIG_NODE, &interface_cmd);
paul32d24632003-05-23 09:25:20 +00001198 install_element (CONFIG_NODE, &no_interface_cmd);
hassoa94434b2003-05-25 17:10:12 +00001199 install_default (INTERFACE_NODE);
paul718e3742002-12-13 20:15:29 +00001200 install_element (INTERFACE_NODE, &interface_desc_cmd);
1201 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
1202
1203 install_element (RIPNG_NODE, &ripng_network_cmd);
1204 install_element (RIPNG_NODE, &no_ripng_network_cmd);
1205 install_element (RIPNG_NODE, &ripng_passive_interface_cmd);
1206 install_element (RIPNG_NODE, &no_ripng_passive_interface_cmd);
hassoa94434b2003-05-25 17:10:12 +00001207
1208 install_element (INTERFACE_NODE, &ipv6_ripng_split_horizon_cmd);
1209 install_element (INTERFACE_NODE, &ipv6_ripng_split_horizon_poisoned_reverse_cmd);
1210 install_element (INTERFACE_NODE, &no_ipv6_ripng_split_horizon_cmd);
1211 install_element (INTERFACE_NODE, &no_ipv6_ripng_split_horizon_poisoned_reverse_cmd);
paul718e3742002-12-13 20:15:29 +00001212}