blob: 35884634690999e814a5ef6b35e87934b25595fd [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"
paul718e3742002-12-13 20:15:29 +000038
39#include "ripngd/ripngd.h"
40#include "ripngd/ripng_debug.h"
David Lamparter6b0655a2014-06-04 06:53:35 +020041
paul718e3742002-12-13 20:15:29 +000042/* 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
gdt4d4653a2004-07-01 19:26:33 +000050extern struct zebra_privs_t ripngd_privs;
51
paul718e3742002-12-13 20:15:29 +000052/* Static utility function. */
53static void ripng_enable_apply (struct interface *);
54static void ripng_passive_interface_apply (struct interface *);
Paul Jakma6ac29a52008-08-15 13:45:30 +010055static int ripng_enable_if_lookup (const char *);
56static int ripng_enable_network_lookup2 (struct connected *);
57static void ripng_enable_apply_all (void);
paul718e3742002-12-13 20:15:29 +000058
59/* Join to the all rip routers multicast group. */
Paul Jakma6ac29a52008-08-15 13:45:30 +010060static int
paul718e3742002-12-13 20:15:29 +000061ripng_multicast_join (struct interface *ifp)
62{
63 int ret;
64 struct ipv6_mreq mreq;
ajs656b4ee2005-01-30 18:08:12 +000065 int save_errno;
paul718e3742002-12-13 20:15:29 +000066
hassoa94434b2003-05-25 17:10:12 +000067 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;
paul718e3742002-12-13 20:15:29 +000071
gdt4d4653a2004-07-01 19:26:33 +000072 /*
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
hassoa94434b2003-05-25 17:10:12 +000080 ret = setsockopt (ripng->sock, IPPROTO_IPV6, IPV6_JOIN_GROUP,
81 (char *) &mreq, sizeof (mreq));
ajs656b4ee2005-01-30 18:08:12 +000082 save_errno = errno;
gdtddf1c262004-01-04 01:02:55 +000083
gdt4d4653a2004-07-01 19:26:33 +000084 if (ripngd_privs.change (ZPRIVS_LOWER))
85 zlog_err ("ripng_multicast_join: could not lower privs");
86
ajs656b4ee2005-01-30 18:08:12 +000087 if (ret < 0 && save_errno == EADDRINUSE)
gdtddf1c262004-01-04 01:02:55 +000088 {
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
hassoa94434b2003-05-25 17:10:12 +000098 if (ret < 0)
ajs656b4ee2005-01-30 18:08:12 +000099 zlog_warn ("can't setsockopt IPV6_JOIN_GROUP: %s",
100 safe_strerror (save_errno));
paul718e3742002-12-13 20:15:29 +0000101
hassoa94434b2003-05-25 17:10:12 +0000102 if (IS_RIPNG_DEBUG_EVENT)
ajs2e23ab22004-12-08 19:46:50 +0000103 zlog_debug ("RIPng %s join to all-rip-routers multicast group", ifp->name);
paul718e3742002-12-13 20:15:29 +0000104
hassoa94434b2003-05-25 17:10:12 +0000105 if (ret < 0)
106 return -1;
107 }
108 return 0;
paul718e3742002-12-13 20:15:29 +0000109}
110
111/* Leave from the all rip routers multicast group. */
Paul Jakma6ac29a52008-08-15 13:45:30 +0100112static int
paul718e3742002-12-13 20:15:29 +0000113ripng_multicast_leave (struct interface *ifp)
114{
115 int ret;
116 struct ipv6_mreq mreq;
117
hassoa94434b2003-05-25 17:10:12 +0000118 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;
paul718e3742002-12-13 20:15:29 +0000122
hassoa94434b2003-05-25 17:10:12 +0000123 ret = setsockopt (ripng->sock, IPPROTO_IPV6, IPV6_LEAVE_GROUP,
124 (char *) &mreq, sizeof (mreq));
125 if (ret < 0)
ajs6099b3b2004-11-20 02:06:59 +0000126 zlog_warn ("can't setsockopt IPV6_LEAVE_GROUP: %s\n", safe_strerror (errno));
paul718e3742002-12-13 20:15:29 +0000127
hassoa94434b2003-05-25 17:10:12 +0000128 if (IS_RIPNG_DEBUG_EVENT)
ajs2e23ab22004-12-08 19:46:50 +0000129 zlog_debug ("RIPng %s leave from all-rip-routers multicast group",
hassoa94434b2003-05-25 17:10:12 +0000130 ifp->name);
paul718e3742002-12-13 20:15:29 +0000131
hassoa94434b2003-05-25 17:10:12 +0000132 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 Jakma6ac29a52008-08-15 13:45:30 +0100140static int
hassoa94434b2003-05-25 17:10:12 +0000141ripng_if_ipv6_lladdress_check (struct interface *ifp)
142{
143 struct listnode *nn;
144 struct connected *connected;
145 int count = 0;
146
paul1eb8ef22005-04-07 07:30:20 +0000147 for (ALL_LIST_ELEMENTS_RO (ifp->connected, nn, connected))
148 {
hassoa94434b2003-05-25 17:10:12 +0000149 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;
paul718e3742002-12-13 20:15:29 +0000158}
159
Paul Jakma6ac29a52008-08-15 13:45:30 +0100160static int
paul718e3742002-12-13 20:15:29 +0000161ripng_if_down (struct interface *ifp)
162{
163 struct route_node *rp;
164 struct ripng_info *rinfo;
165 struct ripng_interface *ri;
Feng Lue97c31a2015-05-22 11:39:53 +0200166 struct list *list = NULL;
167 struct listnode *listnode = NULL, *nextnode = NULL;
paul718e3742002-12-13 20:15:29 +0000168
hassoa94434b2003-05-25 17:10:12 +0000169 if (ripng)
Feng Lue97c31a2015-05-22 11:39:53 +0200170 for (rp = route_top (ripng->table); rp; rp = route_next (rp))
171 if ((list = rp->info) != NULL)
172 for (ALL_LIST_ELEMENTS (list, listnode, nextnode, rinfo))
173 if (rinfo->ifindex == ifp->ifindex)
174 ripng_ecmp_delete (rinfo);
paul718e3742002-12-13 20:15:29 +0000175
176 ri = ifp->info;
177
hassoa94434b2003-05-25 17:10:12 +0000178 if (ri->running)
paul718e3742002-12-13 20:15:29 +0000179 {
180 if (IS_RIPNG_DEBUG_EVENT)
ajs2e23ab22004-12-08 19:46:50 +0000181 zlog_debug ("turn off %s", ifp->name);
paul718e3742002-12-13 20:15:29 +0000182
183 /* Leave from multicast group. */
184 ripng_multicast_leave (ifp);
185
186 ri->running = 0;
187 }
188
189 return 0;
190}
191
192/* Inteface link up message processing. */
193int
194ripng_interface_up (int command, struct zclient *zclient, zebra_size_t length)
195{
196 struct stream *s;
197 struct interface *ifp;
198
199 /* zebra_interface_state_read() updates interface structure in iflist. */
200 s = zclient->ibuf;
201 ifp = zebra_interface_state_read (s);
202
203 if (ifp == NULL)
204 return 0;
205
206 if (IS_RIPNG_DEBUG_ZEBRA)
Stephen Hemminger30d20592009-07-28 11:58:51 +0100207 zlog_debug ("interface up %s index %d flags %llx metric %d mtu %d",
208 ifp->name, ifp->ifindex, (unsigned long long)ifp->flags,
209 ifp->metric, ifp->mtu6);
paul718e3742002-12-13 20:15:29 +0000210
211 /* Check if this interface is RIPng enabled or not. */
212 ripng_enable_apply (ifp);
213
214 /* Check for a passive interface. */
215 ripng_passive_interface_apply (ifp);
216
217 /* Apply distribute list to the all interface. */
218 ripng_distribute_update_interface (ifp);
219
220 return 0;
221}
222
223/* Inteface link down message processing. */
224int
225ripng_interface_down (int command, struct zclient *zclient,
226 zebra_size_t length)
227{
228 struct stream *s;
229 struct interface *ifp;
230
231 /* zebra_interface_state_read() updates interface structure in iflist. */
232 s = zclient->ibuf;
233 ifp = zebra_interface_state_read (s);
234
235 if (ifp == NULL)
236 return 0;
237
238 ripng_if_down (ifp);
239
240 if (IS_RIPNG_DEBUG_ZEBRA)
Stephen Hemminger5eb9d112009-12-10 15:52:33 +0300241 zlog_debug ("interface down %s index %d flags %#llx metric %d mtu %d",
242 ifp->name, ifp->ifindex,
243 (unsigned long long) ifp->flags, ifp->metric, ifp->mtu6);
paul718e3742002-12-13 20:15:29 +0000244
245 return 0;
246}
247
248/* Inteface addition message from zebra. */
249int
250ripng_interface_add (int command, struct zclient *zclient, zebra_size_t length)
251{
252 struct interface *ifp;
253
254 ifp = zebra_interface_add_read (zclient->ibuf);
255
256 if (IS_RIPNG_DEBUG_ZEBRA)
Stephen Hemminger5eb9d112009-12-10 15:52:33 +0300257 zlog_debug ("RIPng interface add %s index %d flags %#llx metric %d mtu %d",
258 ifp->name, ifp->ifindex, (unsigned long long) ifp->flags,
259 ifp->metric, ifp->mtu6);
paul718e3742002-12-13 20:15:29 +0000260
261 /* Check is this interface is RIP enabled or not.*/
262 ripng_enable_apply (ifp);
263
264 /* Apply distribute list to the interface. */
265 ripng_distribute_update_interface (ifp);
266
267 /* Check interface routemap. */
268 ripng_if_rmap_update_interface (ifp);
269
270 return 0;
271}
272
273int
274ripng_interface_delete (int command, struct zclient *zclient,
275 zebra_size_t length)
276{
hassoa94434b2003-05-25 17:10:12 +0000277 struct interface *ifp;
278 struct stream *s;
279
280 s = zclient->ibuf;
281 /* zebra_interface_state_read() updates interface structure in iflist */
282 ifp = zebra_interface_state_read(s);
283
284 if (ifp == NULL)
285 return 0;
286
287 if (if_is_up (ifp)) {
288 ripng_if_down(ifp);
289 }
290
Stephen Hemminger5eb9d112009-12-10 15:52:33 +0300291 zlog_info("interface delete %s index %d flags %#llx metric %d mtu %d",
292 ifp->name, ifp->ifindex, (unsigned long long) ifp->flags,
293 ifp->metric, ifp->mtu6);
hassoa94434b2003-05-25 17:10:12 +0000294
295 /* To support pseudo interface do not free interface structure. */
296 /* if_delete(ifp); */
ajsd2fc8892005-04-02 18:38:43 +0000297 ifp->ifindex = IFINDEX_INTERNAL;
hassoa94434b2003-05-25 17:10:12 +0000298
paul718e3742002-12-13 20:15:29 +0000299 return 0;
300}
301
hassoa94434b2003-05-25 17:10:12 +0000302void
Paul Jakma6ac29a52008-08-15 13:45:30 +0100303ripng_interface_clean (void)
hassoa94434b2003-05-25 17:10:12 +0000304{
paul1eb8ef22005-04-07 07:30:20 +0000305 struct listnode *node, *nnode;
hassoa94434b2003-05-25 17:10:12 +0000306 struct interface *ifp;
307 struct ripng_interface *ri;
308
paul1eb8ef22005-04-07 07:30:20 +0000309 for (ALL_LIST_ELEMENTS (iflist, node, nnode, ifp))
hassoa94434b2003-05-25 17:10:12 +0000310 {
hassoa94434b2003-05-25 17:10:12 +0000311 ri = ifp->info;
312
313 ri->enable_network = 0;
314 ri->enable_interface = 0;
315 ri->running = 0;
316
317 if (ri->t_wakeup)
318 {
319 thread_cancel (ri->t_wakeup);
320 ri->t_wakeup = NULL;
321 }
322 }
323}
324
325void
Paul Jakma6ac29a52008-08-15 13:45:30 +0100326ripng_interface_reset (void)
327{
hasso52dc7ee2004-09-23 19:18:23 +0000328 struct listnode *node;
hassoa94434b2003-05-25 17:10:12 +0000329 struct interface *ifp;
330 struct ripng_interface *ri;
331
paul1eb8ef22005-04-07 07:30:20 +0000332 for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
hassoa94434b2003-05-25 17:10:12 +0000333 {
hassoa94434b2003-05-25 17:10:12 +0000334 ri = ifp->info;
335
336 ri->enable_network = 0;
337 ri->enable_interface = 0;
338 ri->running = 0;
339
340 ri->split_horizon = RIPNG_NO_SPLIT_HORIZON;
341 ri->split_horizon_default = RIPNG_NO_SPLIT_HORIZON;
342
343 ri->list[RIPNG_FILTER_IN] = NULL;
344 ri->list[RIPNG_FILTER_OUT] = NULL;
345
346 ri->prefix[RIPNG_FILTER_IN] = NULL;
347 ri->prefix[RIPNG_FILTER_OUT] = NULL;
348
349 if (ri->t_wakeup)
350 {
351 thread_cancel (ri->t_wakeup);
352 ri->t_wakeup = NULL;
353 }
354
355 ri->passive = 0;
356 }
357}
358
359static void
360ripng_apply_address_add (struct connected *ifc) {
361 struct prefix_ipv6 address;
362 struct prefix *p;
363
364 if (!ripng)
365 return;
366
367 if (! if_is_up(ifc->ifp))
368 return;
369
370 p = ifc->address;
371
372 memset (&address, 0, sizeof (address));
373 address.family = p->family;
374 address.prefix = p->u.prefix6;
375 address.prefixlen = p->prefixlen;
376 apply_mask_ipv6(&address);
377
378 /* Check if this interface is RIP enabled or not
379 or Check if this address's prefix is RIP enabled */
380 if ((ripng_enable_if_lookup(ifc->ifp->name) >= 0) ||
381 (ripng_enable_network_lookup2(ifc) >= 0))
382 ripng_redistribute_add(ZEBRA_ROUTE_CONNECT, RIPNG_ROUTE_INTERFACE,
383 &address, ifc->ifp->ifindex, NULL);
384
385}
386
paul718e3742002-12-13 20:15:29 +0000387int
388ripng_interface_address_add (int command, struct zclient *zclient,
389 zebra_size_t length)
390{
391 struct connected *c;
392 struct prefix *p;
paul718e3742002-12-13 20:15:29 +0000393
paul0a589352004-05-08 11:48:26 +0000394 c = zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_ADD,
395 zclient->ibuf);
paul718e3742002-12-13 20:15:29 +0000396
397 if (c == NULL)
398 return 0;
399
400 p = c->address;
401
402 if (p->family == AF_INET6)
403 {
Paul Jakma995b9652006-05-11 13:20:47 +0000404 struct ripng_interface *ri = c->ifp->info;
405
paul718e3742002-12-13 20:15:29 +0000406 if (IS_RIPNG_DEBUG_ZEBRA)
ajs2e23ab22004-12-08 19:46:50 +0000407 zlog_debug ("RIPng connected address %s/%d add",
hasso3a2ce6a2005-04-08 01:30:51 +0000408 inet6_ntoa(p->u.prefix6),
paul718e3742002-12-13 20:15:29 +0000409 p->prefixlen);
410
hassoa94434b2003-05-25 17:10:12 +0000411 /* Check is this prefix needs to be redistributed. */
412 ripng_apply_address_add(c);
413
414 /* Let's try once again whether the interface could be activated */
Paul Jakma995b9652006-05-11 13:20:47 +0000415 if (!ri->running) {
416 /* Check if this interface is RIP enabled or not.*/
417 ripng_enable_apply (c->ifp);
hassoa94434b2003-05-25 17:10:12 +0000418
Paul Jakma995b9652006-05-11 13:20:47 +0000419 /* Apply distribute list to the interface. */
420 ripng_distribute_update_interface (c->ifp);
hassoa94434b2003-05-25 17:10:12 +0000421
Paul Jakma995b9652006-05-11 13:20:47 +0000422 /* Check interface routemap. */
423 ripng_if_rmap_update_interface (c->ifp);
hassoa94434b2003-05-25 17:10:12 +0000424 }
425
paul718e3742002-12-13 20:15:29 +0000426 }
427
428 return 0;
429}
430
hassoa94434b2003-05-25 17:10:12 +0000431static void
432ripng_apply_address_del (struct connected *ifc) {
433 struct prefix_ipv6 address;
434 struct prefix *p;
435
436 if (!ripng)
437 return;
438
439 if (! if_is_up(ifc->ifp))
440 return;
441
442 p = ifc->address;
443
444 memset (&address, 0, sizeof (address));
445 address.family = p->family;
446 address.prefix = p->u.prefix6;
447 address.prefixlen = p->prefixlen;
448 apply_mask_ipv6(&address);
449
450 ripng_redistribute_delete(ZEBRA_ROUTE_CONNECT, RIPNG_ROUTE_INTERFACE,
451 &address, ifc->ifp->ifindex);
452}
453
paul718e3742002-12-13 20:15:29 +0000454int
455ripng_interface_address_delete (int command, struct zclient *zclient,
456 zebra_size_t length)
457{
458 struct connected *ifc;
459 struct prefix *p;
460 char buf[INET6_ADDRSTRLEN];
461
paul0a589352004-05-08 11:48:26 +0000462 ifc = zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_DELETE,
463 zclient->ibuf);
paul718e3742002-12-13 20:15:29 +0000464
465 if (ifc)
466 {
467 p = ifc->address;
468
469 if (p->family == AF_INET6)
470 {
471 if (IS_RIPNG_DEBUG_ZEBRA)
ajs2e23ab22004-12-08 19:46:50 +0000472 zlog_debug ("RIPng connected address %s/%d delete",
paul718e3742002-12-13 20:15:29 +0000473 inet_ntop (AF_INET6, &p->u.prefix6, buf,
474 INET6_ADDRSTRLEN),
475 p->prefixlen);
476
hassoa94434b2003-05-25 17:10:12 +0000477 /* Check wether this prefix needs to be removed. */
478 ripng_apply_address_del(ifc);
paul718e3742002-12-13 20:15:29 +0000479 }
480 connected_free (ifc);
481 }
482
483 return 0;
484}
David Lamparter6b0655a2014-06-04 06:53:35 +0200485
paul718e3742002-12-13 20:15:29 +0000486/* RIPng enable interface vector. */
487vector ripng_enable_if;
488
489/* RIPng enable network table. */
490struct route_table *ripng_enable_network;
491
492/* Lookup RIPng enable network. */
hassoa94434b2003-05-25 17:10:12 +0000493/* Check wether the interface has at least a connected prefix that
494 * is within the ripng_enable_network table. */
Paul Jakma6ac29a52008-08-15 13:45:30 +0100495static int
hassoa94434b2003-05-25 17:10:12 +0000496ripng_enable_network_lookup_if (struct interface *ifp)
paul718e3742002-12-13 20:15:29 +0000497{
paul1eb8ef22005-04-07 07:30:20 +0000498 struct listnode *node;
paul718e3742002-12-13 20:15:29 +0000499 struct connected *connected;
hassoa94434b2003-05-25 17:10:12 +0000500 struct prefix_ipv6 address;
paul718e3742002-12-13 20:15:29 +0000501
paul1eb8ef22005-04-07 07:30:20 +0000502 for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, connected))
503 {
504 struct prefix *p;
505 struct route_node *node;
paul718e3742002-12-13 20:15:29 +0000506
paul1eb8ef22005-04-07 07:30:20 +0000507 p = connected->address;
paul718e3742002-12-13 20:15:29 +0000508
paul1eb8ef22005-04-07 07:30:20 +0000509 if (p->family == AF_INET6)
510 {
511 address.family = AF_INET6;
512 address.prefix = p->u.prefix6;
513 address.prefixlen = IPV6_MAX_BITLEN;
hassoa94434b2003-05-25 17:10:12 +0000514
paul1eb8ef22005-04-07 07:30:20 +0000515 node = route_node_match (ripng_enable_network,
516 (struct prefix *)&address);
517 if (node)
518 {
519 route_unlock_node (node);
520 return 1;
521 }
522 }
523 }
paul718e3742002-12-13 20:15:29 +0000524 return -1;
525}
526
hassoa94434b2003-05-25 17:10:12 +0000527/* Check wether connected is within the ripng_enable_network table. */
Paul Jakma6ac29a52008-08-15 13:45:30 +0100528static int
hassoa94434b2003-05-25 17:10:12 +0000529ripng_enable_network_lookup2 (struct connected *connected)
530{
531 struct prefix_ipv6 address;
532 struct prefix *p;
533
534 p = connected->address;
535
536 if (p->family == AF_INET6) {
537 struct route_node *node;
538
539 address.family = p->family;
540 address.prefix = p->u.prefix6;
541 address.prefixlen = IPV6_MAX_BITLEN;
542
543 /* LPM on p->family, p->u.prefix6/IPV6_MAX_BITLEN within ripng_enable_network */
544 node = route_node_match (ripng_enable_network,
545 (struct prefix *)&address);
546
547 if (node) {
548 route_unlock_node (node);
549 return 1;
550 }
551 }
552
553 return -1;
554}
555
paul718e3742002-12-13 20:15:29 +0000556/* Add RIPng enable network. */
Paul Jakma6ac29a52008-08-15 13:45:30 +0100557static int
paul718e3742002-12-13 20:15:29 +0000558ripng_enable_network_add (struct prefix *p)
559{
560 struct route_node *node;
561
562 node = route_node_get (ripng_enable_network, p);
563
564 if (node->info)
565 {
566 route_unlock_node (node);
567 return -1;
568 }
569 else
hasso7a1d5832004-10-08 06:32:23 +0000570 node->info = (char *) "enabled";
paul718e3742002-12-13 20:15:29 +0000571
hassoa94434b2003-05-25 17:10:12 +0000572 /* XXX: One should find a better solution than a generic one */
573 ripng_enable_apply_all();
574
paul718e3742002-12-13 20:15:29 +0000575 return 1;
576}
577
578/* Delete RIPng enable network. */
Paul Jakma6ac29a52008-08-15 13:45:30 +0100579static int
paul718e3742002-12-13 20:15:29 +0000580ripng_enable_network_delete (struct prefix *p)
581{
582 struct route_node *node;
583
584 node = route_node_lookup (ripng_enable_network, p);
585 if (node)
586 {
587 node->info = NULL;
588
589 /* Unlock info lock. */
590 route_unlock_node (node);
591
592 /* Unlock lookup lock. */
593 route_unlock_node (node);
594
595 return 1;
596 }
597 return -1;
598}
599
600/* Lookup function. */
Paul Jakma6ac29a52008-08-15 13:45:30 +0100601static int
hasso98b718a2004-10-11 12:57:57 +0000602ripng_enable_if_lookup (const char *ifname)
paul718e3742002-12-13 20:15:29 +0000603{
hasso7a1d5832004-10-08 06:32:23 +0000604 unsigned int i;
paul718e3742002-12-13 20:15:29 +0000605 char *str;
606
paul55468c82005-03-14 20:19:01 +0000607 for (i = 0; i < vector_active (ripng_enable_if); i++)
paul718e3742002-12-13 20:15:29 +0000608 if ((str = vector_slot (ripng_enable_if, i)) != NULL)
609 if (strcmp (str, ifname) == 0)
610 return i;
611 return -1;
612}
613
614/* Add interface to ripng_enable_if. */
Paul Jakma6ac29a52008-08-15 13:45:30 +0100615static int
hasso98b718a2004-10-11 12:57:57 +0000616ripng_enable_if_add (const char *ifname)
paul718e3742002-12-13 20:15:29 +0000617{
618 int ret;
619
620 ret = ripng_enable_if_lookup (ifname);
621 if (ret >= 0)
622 return -1;
623
624 vector_set (ripng_enable_if, strdup (ifname));
625
hassoa94434b2003-05-25 17:10:12 +0000626 ripng_enable_apply_all();
627
paul718e3742002-12-13 20:15:29 +0000628 return 1;
629}
630
631/* Delete interface from ripng_enable_if. */
Paul Jakma6ac29a52008-08-15 13:45:30 +0100632static int
hasso98b718a2004-10-11 12:57:57 +0000633ripng_enable_if_delete (const char *ifname)
paul718e3742002-12-13 20:15:29 +0000634{
635 int index;
636 char *str;
637
638 index = ripng_enable_if_lookup (ifname);
639 if (index < 0)
640 return -1;
641
642 str = vector_slot (ripng_enable_if, index);
643 free (str);
644 vector_unset (ripng_enable_if, index);
645
hassoa94434b2003-05-25 17:10:12 +0000646 ripng_enable_apply_all();
647
paul718e3742002-12-13 20:15:29 +0000648 return 1;
649}
650
651/* Wake up interface. */
Paul Jakma6ac29a52008-08-15 13:45:30 +0100652static int
paul718e3742002-12-13 20:15:29 +0000653ripng_interface_wakeup (struct thread *t)
654{
655 struct interface *ifp;
656 struct ripng_interface *ri;
657
658 /* Get interface. */
659 ifp = THREAD_ARG (t);
660
661 ri = ifp->info;
662 ri->t_wakeup = NULL;
663
664 /* Join to multicast group. */
hassoa94434b2003-05-25 17:10:12 +0000665 if (ripng_multicast_join (ifp) < 0) {
666 zlog_err ("multicast join failed, interface %s not running", ifp->name);
667 return 0;
668 }
669
670 /* Set running flag. */
671 ri->running = 1;
paul718e3742002-12-13 20:15:29 +0000672
673 /* Send RIP request to the interface. */
674 ripng_request (ifp);
675
676 return 0;
677}
678
Paul Jakma6ac29a52008-08-15 13:45:30 +0100679static void
hassoa94434b2003-05-25 17:10:12 +0000680ripng_connect_set (struct interface *ifp, int set)
681{
paul1eb8ef22005-04-07 07:30:20 +0000682 struct listnode *node, *nnode;
hassoa94434b2003-05-25 17:10:12 +0000683 struct connected *connected;
684 struct prefix_ipv6 address;
685
paul1eb8ef22005-04-07 07:30:20 +0000686 for (ALL_LIST_ELEMENTS (ifp->connected, node, nnode, connected))
687 {
hassoa94434b2003-05-25 17:10:12 +0000688 struct prefix *p;
689 p = connected->address;
690
691 if (p->family != AF_INET6)
692 continue;
693
694 address.family = AF_INET6;
695 address.prefix = p->u.prefix6;
696 address.prefixlen = p->prefixlen;
697 apply_mask_ipv6 (&address);
698
699 if (set) {
700 /* Check once more wether this prefix is within a "network IF_OR_PREF" one */
701 if ((ripng_enable_if_lookup(connected->ifp->name) >= 0) ||
702 (ripng_enable_network_lookup2(connected) >= 0))
703 ripng_redistribute_add (ZEBRA_ROUTE_CONNECT, RIPNG_ROUTE_INTERFACE,
704 &address, connected->ifp->ifindex, NULL);
705 } else {
706 ripng_redistribute_delete (ZEBRA_ROUTE_CONNECT, RIPNG_ROUTE_INTERFACE,
707 &address, connected->ifp->ifindex);
708 if (ripng_redistribute_check (ZEBRA_ROUTE_CONNECT))
709 ripng_redistribute_add (ZEBRA_ROUTE_CONNECT, RIPNG_ROUTE_REDISTRIBUTE,
710 &address, connected->ifp->ifindex, NULL);
711 }
712 }
713}
714
paul718e3742002-12-13 20:15:29 +0000715/* Check RIPng is enabed on this interface. */
716void
717ripng_enable_apply (struct interface *ifp)
718{
719 int ret;
720 struct ripng_interface *ri = NULL;
721
722 /* Check interface. */
paul718e3742002-12-13 20:15:29 +0000723 if (! if_is_up (ifp))
724 return;
725
726 ri = ifp->info;
727
hassoa94434b2003-05-25 17:10:12 +0000728 /* Is this interface a candidate for RIPng ? */
729 ret = ripng_enable_network_lookup_if (ifp);
paul718e3742002-12-13 20:15:29 +0000730
731 /* If the interface is matched. */
732 if (ret > 0)
733 ri->enable_network = 1;
734 else
735 ri->enable_network = 0;
736
737 /* Check interface name configuration. */
738 ret = ripng_enable_if_lookup (ifp->name);
739 if (ret >= 0)
740 ri->enable_interface = 1;
741 else
742 ri->enable_interface = 0;
743
hassoa94434b2003-05-25 17:10:12 +0000744 /* any candidate interface MUST have a link-local IPv6 address */
745 if ((! ripng_if_ipv6_lladdress_check (ifp)) &&
746 (ri->enable_network || ri->enable_interface)) {
747 ri->enable_network = 0;
748 ri->enable_interface = 0;
749 zlog_warn("Interface %s does not have any link-local address",
750 ifp->name);
751 }
752
paul718e3742002-12-13 20:15:29 +0000753 /* Update running status of the interface. */
754 if (ri->enable_network || ri->enable_interface)
755 {
paul718e3742002-12-13 20:15:29 +0000756 {
757 if (IS_RIPNG_DEBUG_EVENT)
ajs2e23ab22004-12-08 19:46:50 +0000758 zlog_debug ("RIPng turn on %s", ifp->name);
paul718e3742002-12-13 20:15:29 +0000759
760 /* Add interface wake up thread. */
761 if (! ri->t_wakeup)
762 ri->t_wakeup = thread_add_timer (master, ripng_interface_wakeup,
763 ifp, 1);
paul718e3742002-12-13 20:15:29 +0000764
hassoa94434b2003-05-25 17:10:12 +0000765 ripng_connect_set (ifp, 1);
paul718e3742002-12-13 20:15:29 +0000766 }
767 }
768 else
769 {
770 if (ri->running)
771 {
hassoa94434b2003-05-25 17:10:12 +0000772 /* Might as well clean up the route table as well
773 * ripng_if_down sets to 0 ri->running, and displays "turn off %s"
774 **/
775 ripng_if_down(ifp);
paul718e3742002-12-13 20:15:29 +0000776
hassoa94434b2003-05-25 17:10:12 +0000777 ripng_connect_set (ifp, 0);
paul718e3742002-12-13 20:15:29 +0000778 }
779 }
780}
781
782/* Set distribute list to all interfaces. */
Paul Jakma6ac29a52008-08-15 13:45:30 +0100783static void
784ripng_enable_apply_all (void)
paul718e3742002-12-13 20:15:29 +0000785{
786 struct interface *ifp;
hasso52dc7ee2004-09-23 19:18:23 +0000787 struct listnode *node;
paul718e3742002-12-13 20:15:29 +0000788
paul1eb8ef22005-04-07 07:30:20 +0000789 for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
790 ripng_enable_apply (ifp);
paul718e3742002-12-13 20:15:29 +0000791}
David Lamparter6b0655a2014-06-04 06:53:35 +0200792
hassoa94434b2003-05-25 17:10:12 +0000793/* Clear all network and neighbor configuration */
794void
795ripng_clean_network ()
796{
hasso7a1d5832004-10-08 06:32:23 +0000797 unsigned int i;
hassoa94434b2003-05-25 17:10:12 +0000798 char *str;
799 struct route_node *rn;
800
801 /* ripng_enable_network */
802 for (rn = route_top (ripng_enable_network); rn; rn = route_next (rn))
803 if (rn->info) {
804 rn->info = NULL;
805 route_unlock_node(rn);
806 }
807
808 /* ripng_enable_if */
paul55468c82005-03-14 20:19:01 +0000809 for (i = 0; i < vector_active (ripng_enable_if); i++)
hassoa94434b2003-05-25 17:10:12 +0000810 if ((str = vector_slot (ripng_enable_if, i)) != NULL) {
811 free (str);
812 vector_slot (ripng_enable_if, i) = NULL;
813 }
814}
David Lamparter6b0655a2014-06-04 06:53:35 +0200815
paul718e3742002-12-13 20:15:29 +0000816/* Vector to store passive-interface name. */
817vector Vripng_passive_interface;
818
819/* Utility function for looking up passive interface settings. */
Paul Jakma6ac29a52008-08-15 13:45:30 +0100820static int
hasso98b718a2004-10-11 12:57:57 +0000821ripng_passive_interface_lookup (const char *ifname)
paul718e3742002-12-13 20:15:29 +0000822{
hasso7a1d5832004-10-08 06:32:23 +0000823 unsigned int i;
paul718e3742002-12-13 20:15:29 +0000824 char *str;
825
paul55468c82005-03-14 20:19:01 +0000826 for (i = 0; i < vector_active (Vripng_passive_interface); i++)
paul718e3742002-12-13 20:15:29 +0000827 if ((str = vector_slot (Vripng_passive_interface, i)) != NULL)
828 if (strcmp (str, ifname) == 0)
829 return i;
830 return -1;
831}
832
833void
834ripng_passive_interface_apply (struct interface *ifp)
835{
836 int ret;
837 struct ripng_interface *ri;
838
839 ri = ifp->info;
840
841 ret = ripng_passive_interface_lookup (ifp->name);
842 if (ret < 0)
843 ri->passive = 0;
844 else
845 ri->passive = 1;
846}
847
Paul Jakma6ac29a52008-08-15 13:45:30 +0100848static void
paul718e3742002-12-13 20:15:29 +0000849ripng_passive_interface_apply_all (void)
850{
851 struct interface *ifp;
hasso52dc7ee2004-09-23 19:18:23 +0000852 struct listnode *node;
paul718e3742002-12-13 20:15:29 +0000853
paul1eb8ef22005-04-07 07:30:20 +0000854 for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
855 ripng_passive_interface_apply (ifp);
paul718e3742002-12-13 20:15:29 +0000856}
857
858/* Passive interface. */
Paul Jakma6ac29a52008-08-15 13:45:30 +0100859static int
hasso98b718a2004-10-11 12:57:57 +0000860ripng_passive_interface_set (struct vty *vty, const char *ifname)
paul718e3742002-12-13 20:15:29 +0000861{
862 if (ripng_passive_interface_lookup (ifname) >= 0)
863 return CMD_WARNING;
864
865 vector_set (Vripng_passive_interface, strdup (ifname));
866
867 ripng_passive_interface_apply_all ();
868
869 return CMD_SUCCESS;
870}
871
Paul Jakma6ac29a52008-08-15 13:45:30 +0100872static int
hasso98b718a2004-10-11 12:57:57 +0000873ripng_passive_interface_unset (struct vty *vty, const char *ifname)
paul718e3742002-12-13 20:15:29 +0000874{
875 int i;
876 char *str;
877
878 i = ripng_passive_interface_lookup (ifname);
879 if (i < 0)
880 return CMD_WARNING;
881
882 str = vector_slot (Vripng_passive_interface, i);
883 free (str);
884 vector_unset (Vripng_passive_interface, i);
885
886 ripng_passive_interface_apply_all ();
887
888 return CMD_SUCCESS;
889}
890
891/* Free all configured RIP passive-interface settings. */
892void
893ripng_passive_interface_clean (void)
894{
hasso7a1d5832004-10-08 06:32:23 +0000895 unsigned int i;
paul718e3742002-12-13 20:15:29 +0000896 char *str;
897
paul55468c82005-03-14 20:19:01 +0000898 for (i = 0; i < vector_active (Vripng_passive_interface); i++)
paul718e3742002-12-13 20:15:29 +0000899 if ((str = vector_slot (Vripng_passive_interface, i)) != NULL)
900 {
901 free (str);
902 vector_slot (Vripng_passive_interface, i) = NULL;
903 }
904 ripng_passive_interface_apply_all ();
905}
906
907/* Write RIPng enable network and interface to the vty. */
908int
hassoa94434b2003-05-25 17:10:12 +0000909ripng_network_write (struct vty *vty, int config_mode)
paul718e3742002-12-13 20:15:29 +0000910{
hasso7a1d5832004-10-08 06:32:23 +0000911 unsigned int i;
hasso98b718a2004-10-11 12:57:57 +0000912 const char *ifname;
paul718e3742002-12-13 20:15:29 +0000913 struct route_node *node;
914 char buf[BUFSIZ];
915
916 /* Write enable network. */
917 for (node = route_top (ripng_enable_network); node; node = route_next (node))
918 if (node->info)
919 {
920 struct prefix *p = &node->p;
hassoa94434b2003-05-25 17:10:12 +0000921 vty_out (vty, "%s%s/%d%s",
922 config_mode ? " network " : " ",
paul718e3742002-12-13 20:15:29 +0000923 inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ),
924 p->prefixlen,
925 VTY_NEWLINE);
926
927 }
928
929 /* Write enable interface. */
paul55468c82005-03-14 20:19:01 +0000930 for (i = 0; i < vector_active (ripng_enable_if); i++)
hassoa94434b2003-05-25 17:10:12 +0000931 if ((ifname = vector_slot (ripng_enable_if, i)) != NULL)
932 vty_out (vty, "%s%s%s",
933 config_mode ? " network " : " ",
934 ifname,
paul718e3742002-12-13 20:15:29 +0000935 VTY_NEWLINE);
936
937 /* Write passive interface. */
hassoa94434b2003-05-25 17:10:12 +0000938 if (config_mode)
paul55468c82005-03-14 20:19:01 +0000939 for (i = 0; i < vector_active (Vripng_passive_interface); i++)
hassoa94434b2003-05-25 17:10:12 +0000940 if ((ifname = vector_slot (Vripng_passive_interface, i)) != NULL)
941 vty_out (vty, " passive-interface %s%s", ifname, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +0000942
943 return 0;
944}
945
946/* RIPng enable on specified interface or matched network. */
947DEFUN (ripng_network,
948 ripng_network_cmd,
949 "network IF_OR_ADDR",
950 "RIPng enable on specified interface or network.\n"
951 "Interface or address")
952{
953 int ret;
954 struct prefix p;
955
956 ret = str2prefix (argv[0], &p);
957
958 /* Given string is IPv6 network or interface name. */
959 if (ret)
960 ret = ripng_enable_network_add (&p);
961 else
962 ret = ripng_enable_if_add (argv[0]);
963
964 if (ret < 0)
965 {
966 vty_out (vty, "There is same network configuration %s%s", argv[0],
967 VTY_NEWLINE);
968 return CMD_WARNING;
969 }
970
paul718e3742002-12-13 20:15:29 +0000971 return CMD_SUCCESS;
972}
973
974/* RIPng enable on specified interface or matched network. */
975DEFUN (no_ripng_network,
976 no_ripng_network_cmd,
977 "no network IF_OR_ADDR",
978 NO_STR
979 "RIPng enable on specified interface or network.\n"
980 "Interface or address")
981{
982 int ret;
983 struct prefix p;
984
985 ret = str2prefix (argv[0], &p);
986
987 /* Given string is interface name. */
988 if (ret)
989 ret = ripng_enable_network_delete (&p);
990 else
991 ret = ripng_enable_if_delete (argv[0]);
992
993 if (ret < 0)
994 {
995 vty_out (vty, "can't find network %s%s", argv[0],
996 VTY_NEWLINE);
997 return CMD_WARNING;
998 }
999
paul718e3742002-12-13 20:15:29 +00001000 return CMD_SUCCESS;
1001}
1002
hassoa94434b2003-05-25 17:10:12 +00001003DEFUN (ipv6_ripng_split_horizon,
1004 ipv6_ripng_split_horizon_cmd,
1005 "ipv6 ripng split-horizon",
1006 IPV6_STR
1007 "Routing Information Protocol\n"
1008 "Perform split horizon\n")
1009{
1010 struct interface *ifp;
1011 struct ripng_interface *ri;
1012
1013 ifp = vty->index;
1014 ri = ifp->info;
1015
1016 ri->split_horizon = RIPNG_SPLIT_HORIZON;
1017 return CMD_SUCCESS;
1018}
1019
1020DEFUN (ipv6_ripng_split_horizon_poisoned_reverse,
1021 ipv6_ripng_split_horizon_poisoned_reverse_cmd,
1022 "ipv6 ripng split-horizon poisoned-reverse",
1023 IPV6_STR
1024 "Routing Information Protocol\n"
1025 "Perform split horizon\n"
1026 "With poisoned-reverse\n")
1027{
1028 struct interface *ifp;
1029 struct ripng_interface *ri;
1030
1031 ifp = vty->index;
1032 ri = ifp->info;
1033
1034 ri->split_horizon = RIPNG_SPLIT_HORIZON_POISONED_REVERSE;
1035 return CMD_SUCCESS;
1036}
1037
1038DEFUN (no_ipv6_ripng_split_horizon,
1039 no_ipv6_ripng_split_horizon_cmd,
1040 "no ipv6 ripng split-horizon",
1041 NO_STR
1042 IPV6_STR
1043 "Routing Information Protocol\n"
1044 "Perform split horizon\n")
1045{
1046 struct interface *ifp;
1047 struct ripng_interface *ri;
1048
1049 ifp = vty->index;
1050 ri = ifp->info;
1051
1052 ri->split_horizon = RIPNG_NO_SPLIT_HORIZON;
1053 return CMD_SUCCESS;
1054}
1055
1056ALIAS (no_ipv6_ripng_split_horizon,
1057 no_ipv6_ripng_split_horizon_poisoned_reverse_cmd,
1058 "no ipv6 ripng split-horizon poisoned-reverse",
1059 NO_STR
1060 IPV6_STR
1061 "Routing Information Protocol\n"
1062 "Perform split horizon\n"
1063 "With poisoned-reverse\n")
1064
paul718e3742002-12-13 20:15:29 +00001065DEFUN (ripng_passive_interface,
1066 ripng_passive_interface_cmd,
1067 "passive-interface IFNAME",
1068 "Suppress routing updates on an interface\n"
1069 "Interface name\n")
1070{
1071 return ripng_passive_interface_set (vty, argv[0]);
1072}
1073
1074DEFUN (no_ripng_passive_interface,
1075 no_ripng_passive_interface_cmd,
1076 "no passive-interface IFNAME",
1077 NO_STR
1078 "Suppress routing updates on an interface\n"
1079 "Interface name\n")
1080{
1081 return ripng_passive_interface_unset (vty, argv[0]);
1082}
David Lamparter6b0655a2014-06-04 06:53:35 +02001083
Paul Jakma6ac29a52008-08-15 13:45:30 +01001084static struct ripng_interface *
1085ri_new (void)
paul718e3742002-12-13 20:15:29 +00001086{
1087 struct ripng_interface *ri;
1088 ri = XCALLOC (MTYPE_IF, sizeof (struct ripng_interface));
hassoa94434b2003-05-25 17:10:12 +00001089
1090 /* Set default split-horizon behavior. If the interface is Frame
1091 Relay or SMDS is enabled, the default value for split-horizon is
1092 off. But currently Zebra does detect Frame Relay or SMDS
1093 interface. So all interface is set to split horizon. */
1094 ri->split_horizon_default = RIPNG_SPLIT_HORIZON;
1095 ri->split_horizon = ri->split_horizon_default;
1096
paul718e3742002-12-13 20:15:29 +00001097 return ri;
1098}
1099
Paul Jakma6ac29a52008-08-15 13:45:30 +01001100static int
paul718e3742002-12-13 20:15:29 +00001101ripng_if_new_hook (struct interface *ifp)
1102{
1103 ifp->info = ri_new ();
1104 return 0;
1105}
1106
hassoa94434b2003-05-25 17:10:12 +00001107/* Called when interface structure deleted. */
Paul Jakma6ac29a52008-08-15 13:45:30 +01001108static int
hassoa94434b2003-05-25 17:10:12 +00001109ripng_if_delete_hook (struct interface *ifp)
1110{
1111 XFREE (MTYPE_IF, ifp->info);
1112 ifp->info = NULL;
1113 return 0;
1114}
1115
paul718e3742002-12-13 20:15:29 +00001116/* Configuration write function for ripngd. */
Paul Jakma6ac29a52008-08-15 13:45:30 +01001117static int
paul718e3742002-12-13 20:15:29 +00001118interface_config_write (struct vty *vty)
1119{
hasso52dc7ee2004-09-23 19:18:23 +00001120 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00001121 struct interface *ifp;
1122 struct ripng_interface *ri;
1123 int write = 0;
1124
paul1eb8ef22005-04-07 07:30:20 +00001125 for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
paul718e3742002-12-13 20:15:29 +00001126 {
paul718e3742002-12-13 20:15:29 +00001127 ri = ifp->info;
1128
hassoa94434b2003-05-25 17:10:12 +00001129 /* Do not display the interface if there is no
1130 * configuration about it.
1131 **/
1132 if ((!ifp->desc) &&
1133 (ri->split_horizon == ri->split_horizon_default))
1134 continue;
1135
paul718e3742002-12-13 20:15:29 +00001136 vty_out (vty, "interface %s%s", ifp->name,
1137 VTY_NEWLINE);
1138 if (ifp->desc)
1139 vty_out (vty, " description %s%s", ifp->desc,
1140 VTY_NEWLINE);
1141
hassoa94434b2003-05-25 17:10:12 +00001142 /* Split horizon. */
1143 if (ri->split_horizon != ri->split_horizon_default)
1144 {
1145 switch (ri->split_horizon) {
1146 case RIPNG_SPLIT_HORIZON:
1147 vty_out (vty, " ipv6 ripng split-horizon%s", VTY_NEWLINE);
1148 break;
1149 case RIPNG_SPLIT_HORIZON_POISONED_REVERSE:
1150 vty_out (vty, " ipv6 ripng split-horizon poisoned-reverse%s",
1151 VTY_NEWLINE);
1152 break;
1153 case RIPNG_NO_SPLIT_HORIZON:
1154 default:
1155 vty_out (vty, " no ipv6 ripng split-horizon%s", VTY_NEWLINE);
1156 break;
1157 }
1158 }
1159
paul718e3742002-12-13 20:15:29 +00001160 vty_out (vty, "!%s", VTY_NEWLINE);
1161
1162 write++;
1163 }
1164 return write;
1165}
1166
1167/* ripngd's interface node. */
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08001168static struct cmd_node interface_node =
paul718e3742002-12-13 20:15:29 +00001169{
1170 INTERFACE_NODE,
1171 "%s(config-if)# ",
hassoa94434b2003-05-25 17:10:12 +00001172 1 /* VTYSH */
paul718e3742002-12-13 20:15:29 +00001173};
1174
1175/* Initialization of interface. */
1176void
1177ripng_if_init ()
1178{
1179 /* Interface initialize. */
1180 iflist = list_new ();
1181 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}