]> git.proxmox.com Git - mirror_frr.git/blame - ripd/rip_interface.c
ospf6d: Add missing vrf lookup
[mirror_frr.git] / ripd / rip_interface.c
CommitLineData
718e3744 1/* Interface related function for RIP.
2 * Copyright (C) 1997, 98 Kunihiro Ishiguro <kunihiro@zebra.org>
3 *
4 * This file is part of GNU Zebra.
5 *
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
9 * later version.
10 *
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
896014f4
DL
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
718e3744 19 */
20
21#include <zebra.h>
22
23#include "command.h"
24#include "if.h"
25#include "sockunion.h"
26#include "prefix.h"
27#include "memory.h"
28#include "network.h"
29#include "table.h"
30#include "log.h"
31#include "stream.h"
32#include "thread.h"
33#include "zclient.h"
34#include "filter.h"
35#include "sockopt.h"
edd7c245 36#include "privs.h"
718e3744 37
38#include "zebra/connected.h"
39
40#include "ripd/ripd.h"
41#include "ripd/rip_debug.h"
dc63bfd4 42#include "ripd/rip_interface.h"
6b0655a2 43
d62a17ae 44DEFINE_HOOK(rip_ifaddr_add, (struct connected * ifc), (ifc))
45DEFINE_HOOK(rip_ifaddr_del, (struct connected * ifc), (ifc))
3012671f 46
dc63bfd4 47/* static prototypes */
d62a17ae 48static void rip_enable_apply(struct interface *);
49static void rip_passive_interface_apply(struct interface *);
dc63bfd4 50static int rip_if_down(struct interface *ifp);
d62a17ae 51static int rip_enable_if_lookup(const char *ifname);
52static int rip_enable_network_lookup2(struct connected *connected);
53static void rip_enable_apply_all(void);
6b0655a2 54
d62a17ae 55const struct message ri_version_msg[] = {{RI_RIP_VERSION_1, "1"},
56 {RI_RIP_VERSION_2, "2"},
57 {RI_RIP_VERSION_1_AND_2, "1 2"},
58 {RI_RIP_VERSION_NONE, "none"},
59 {0}};
718e3744 60
edd7c245 61extern struct zebra_privs_t ripd_privs;
62
718e3744 63/* RIP enabled network vector. */
64vector rip_enable_interface;
65
66/* RIP enabled interface table. */
67struct route_table *rip_enable_network;
68
69/* Vector to store passive-interface name. */
d62a17ae 70static int passive_default; /* are we in passive-interface default mode? */
4aaff3f8 71vector Vrip_passive_nondefault;
6b0655a2 72
718e3744 73/* Join to the RIP version 2 multicast group. */
d62a17ae 74static int ipv4_multicast_join(int sock, struct in_addr group,
75 struct in_addr ifa, ifindex_t ifindex)
718e3744 76{
d62a17ae 77 int ret;
718e3744 78
d62a17ae 79 ret = setsockopt_ipv4_multicast(sock, IP_ADD_MEMBERSHIP, ifa,
80 group.s_addr, ifindex);
718e3744 81
d62a17ae 82 if (ret < 0)
83 zlog_info("can't setsockopt IP_ADD_MEMBERSHIP %s",
84 safe_strerror(errno));
718e3744 85
d62a17ae 86 return ret;
718e3744 87}
88
89/* Leave from the RIP version 2 multicast group. */
d62a17ae 90static int ipv4_multicast_leave(int sock, struct in_addr group,
91 struct in_addr ifa, ifindex_t ifindex)
718e3744 92{
d62a17ae 93 int ret;
718e3744 94
d62a17ae 95 ret = setsockopt_ipv4_multicast(sock, IP_DROP_MEMBERSHIP, ifa,
96 group.s_addr, ifindex);
718e3744 97
d62a17ae 98 if (ret < 0)
99 zlog_info("can't setsockopt IP_DROP_MEMBERSHIP");
718e3744 100
d62a17ae 101 return ret;
718e3744 102}
6b0655a2 103
d62a17ae 104static void rip_interface_reset(struct rip_interface *);
1dec2166 105
718e3744 106/* Allocate new RIP's interface configuration. */
d62a17ae 107static struct rip_interface *rip_interface_new(void)
718e3744 108{
d62a17ae 109 struct rip_interface *ri;
718e3744 110
d62a17ae 111 ri = XCALLOC(MTYPE_RIP_INTERFACE, sizeof(struct rip_interface));
718e3744 112
d62a17ae 113 rip_interface_reset(ri);
718e3744 114
d62a17ae 115 return ri;
718e3744 116}
117
d62a17ae 118void rip_interface_multicast_set(int sock, struct connected *connected)
718e3744 119{
d62a17ae 120 struct in_addr addr;
4a3867d0 121
d62a17ae 122 assert(connected != NULL);
4a3867d0 123
d62a17ae 124 addr = CONNECTED_ID(connected)->u.prefix4;
125
126 if (setsockopt_ipv4_multicast_if(sock, addr, connected->ifp->ifindex)
127 < 0) {
128 zlog_warn(
129 "Can't setsockopt IP_MULTICAST_IF on fd %d to "
130 "ifindex %d for interface %s",
131 sock, connected->ifp->ifindex, connected->ifp->name);
132 }
4a3867d0 133
d62a17ae 134 return;
3fb9cd6e 135}
718e3744 136
137/* Send RIP request packet to specified interface. */
d62a17ae 138static void rip_request_interface_send(struct interface *ifp, u_char version)
718e3744 139{
d62a17ae 140 struct sockaddr_in to;
718e3744 141
d62a17ae 142 /* RIPv2 support multicast. */
143 if (version == RIPv2 && if_is_multicast(ifp)) {
718e3744 144
d62a17ae 145 if (IS_RIP_DEBUG_EVENT)
146 zlog_debug("multicast request on %s", ifp->name);
718e3744 147
d62a17ae 148 rip_request_send(NULL, ifp, version, NULL);
149 return;
150 }
718e3744 151
d62a17ae 152 /* RIPv1 and non multicast interface. */
153 if (if_is_pointopoint(ifp) || if_is_broadcast(ifp)) {
154 struct listnode *cnode, *cnnode;
155 struct connected *connected;
156
157 if (IS_RIP_DEBUG_EVENT)
158 zlog_debug("broadcast request to %s", ifp->name);
159
160 for (ALL_LIST_ELEMENTS(ifp->connected, cnode, cnnode,
161 connected)) {
162 if (connected->address->family == AF_INET) {
163 memset(&to, 0, sizeof(struct sockaddr_in));
164 to.sin_port = htons(RIP_PORT_DEFAULT);
165 if (connected->destination)
166 /* use specified broadcast or peer
167 * destination addr */
168 to.sin_addr = connected->destination->u
169 .prefix4;
170 else if (connected->address->prefixlen
171 < IPV4_MAX_PREFIXLEN)
172 /* calculate the appropriate broadcast
173 * address */
174 to.sin_addr
175 .s_addr = ipv4_broadcast_addr(
176 connected->address->u.prefix4
177 .s_addr,
178 connected->address->prefixlen);
179 else
180 /* do not know where to send the packet
181 */
182 continue;
183
184 if (IS_RIP_DEBUG_EVENT)
185 zlog_debug("SEND request to %s",
186 inet_ntoa(to.sin_addr));
187
188 rip_request_send(&to, ifp, version, connected);
189 }
190 }
718e3744 191 }
718e3744 192}
193
194/* This will be executed when interface goes up. */
d62a17ae 195static void rip_request_interface(struct interface *ifp)
718e3744 196{
d62a17ae 197 struct rip_interface *ri;
718e3744 198
d62a17ae 199 /* In default ripd doesn't send RIP_REQUEST to the loopback interface.
200 */
201 if (if_is_loopback(ifp))
202 return;
718e3744 203
d62a17ae 204 /* If interface is down, don't send RIP packet. */
205 if (!if_is_operative(ifp))
206 return;
718e3744 207
d62a17ae 208 /* Fetch RIP interface information. */
209 ri = ifp->info;
718e3744 210
211
d62a17ae 212 /* If there is no version configuration in the interface,
213 use rip's version setting. */
214 {
215 int vsend = ((ri->ri_send == RI_RIP_UNSPEC) ? rip->version_send
216 : ri->ri_send);
217 if (vsend & RIPv1)
218 rip_request_interface_send(ifp, RIPv1);
219 if (vsend & RIPv2)
220 rip_request_interface_send(ifp, RIPv2);
221 }
718e3744 222}
223
2c239705 224#if 0
718e3744 225/* Send RIP request to the neighbor. */
dc63bfd4 226static void
718e3744 227rip_request_neighbor (struct in_addr addr)
228{
229 struct sockaddr_in to;
230
231 memset (&to, 0, sizeof (struct sockaddr_in));
232 to.sin_port = htons (RIP_PORT_DEFAULT);
233 to.sin_addr = addr;
234
931cd54d 235 rip_request_send (&to, NULL, rip->version_send, NULL);
718e3744 236}
237
238/* Request routes at all interfaces. */
dc63bfd4 239static void
240rip_request_neighbor_all (void)
718e3744 241{
242 struct route_node *rp;
243
244 if (! rip)
245 return;
246
247 if (IS_RIP_DEBUG_EVENT)
5d6c3779 248 zlog_debug ("request to the all neighbor");
718e3744 249
250 /* Send request to all neighbor. */
251 for (rp = route_top (rip->neighbor); rp; rp = route_next (rp))
252 if (rp->info)
253 rip_request_neighbor (rp->p.u.prefix4);
254}
2c239705 255#endif
718e3744 256
257/* Multicast packet receive socket. */
d62a17ae 258static int rip_multicast_join(struct interface *ifp, int sock)
718e3744 259{
d62a17ae 260 struct listnode *cnode;
261 struct connected *ifc;
718e3744 262
d62a17ae 263 if (if_is_operative(ifp) && if_is_multicast(ifp)) {
264 if (IS_RIP_DEBUG_EVENT)
265 zlog_debug("multicast join at %s", ifp->name);
718e3744 266
d62a17ae 267 for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, ifc)) {
268 struct prefix_ipv4 *p;
269 struct in_addr group;
270
271 p = (struct prefix_ipv4 *)ifc->address;
272
273 if (p->family != AF_INET)
274 continue;
275
276 group.s_addr = htonl(INADDR_RIP_GROUP);
277 if (ipv4_multicast_join(sock, group, p->prefix,
278 ifp->ifindex)
279 < 0)
280 return -1;
281 else
282 return 0;
283 }
718e3744 284 }
d62a17ae 285 return 0;
718e3744 286}
287
288/* Leave from multicast group. */
d62a17ae 289static void rip_multicast_leave(struct interface *ifp, int sock)
718e3744 290{
d62a17ae 291 struct listnode *cnode;
292 struct connected *connected;
718e3744 293
d62a17ae 294 if (if_is_up(ifp) && if_is_multicast(ifp)) {
295 if (IS_RIP_DEBUG_EVENT)
296 zlog_debug("multicast leave from %s", ifp->name);
718e3744 297
d62a17ae 298 for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, connected)) {
299 struct prefix_ipv4 *p;
300 struct in_addr group;
301
302 p = (struct prefix_ipv4 *)connected->address;
303
304 if (p->family != AF_INET)
305 continue;
306
307 group.s_addr = htonl(INADDR_RIP_GROUP);
308 if (ipv4_multicast_leave(sock, group, p->prefix,
309 ifp->ifindex)
310 == 0)
311 return;
312 }
313 }
718e3744 314}
315
316/* Is there and address on interface that I could use ? */
d62a17ae 317static int rip_if_ipv4_address_check(struct interface *ifp)
718e3744 318{
d62a17ae 319 struct listnode *nn;
320 struct connected *connected;
321 int count = 0;
718e3744 322
d62a17ae 323 for (ALL_LIST_ELEMENTS_RO(ifp->connected, nn, connected)) {
324 struct prefix *p;
718e3744 325
d62a17ae 326 p = connected->address;
327
328 if (p->family == AF_INET)
329 count++;
330 }
718e3744 331
d62a17ae 332 return count;
718e3744 333}
d62a17ae 334
31a476c7 335
336/* Does this address belongs to me ? */
d62a17ae 337int if_check_address(struct in_addr addr)
338{
f4e14fdb 339 struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
d62a17ae 340 struct interface *ifp;
31a476c7 341
f4e14fdb 342 RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
d62a17ae 343 struct listnode *cnode;
344 struct connected *connected;
31a476c7 345
d62a17ae 346 for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, connected)) {
347 struct prefix_ipv4 *p;
31a476c7 348
d62a17ae 349 p = (struct prefix_ipv4 *)connected->address;
350
351 if (p->family != AF_INET)
352 continue;
353
354 if (IPV4_ADDR_CMP(&p->prefix, &addr) == 0)
355 return 1;
356 }
31a476c7 357 }
d62a17ae 358 return 0;
31a476c7 359}
360
718e3744 361/* Inteface link down message processing. */
d62a17ae 362int rip_interface_down(int command, struct zclient *zclient,
363 zebra_size_t length, vrf_id_t vrf_id)
718e3744 364{
d62a17ae 365 struct interface *ifp;
366 struct stream *s;
718e3744 367
d62a17ae 368 s = zclient->ibuf;
718e3744 369
d62a17ae 370 /* zebra_interface_state_read() updates interface structure in
371 iflist. */
372 ifp = zebra_interface_state_read(s, vrf_id);
718e3744 373
d62a17ae 374 if (ifp == NULL)
375 return 0;
718e3744 376
d62a17ae 377 rip_if_down(ifp);
718e3744 378
d62a17ae 379 if (IS_RIP_DEBUG_ZEBRA)
380 zlog_debug(
381 "interface %s index %d flags %llx metric %d mtu %d is down",
382 ifp->name, ifp->ifindex, (unsigned long long)ifp->flags,
383 ifp->metric, ifp->mtu);
384
385 return 0;
718e3744 386}
387
388/* Inteface link up message processing */
d62a17ae 389int rip_interface_up(int command, struct zclient *zclient, zebra_size_t length,
390 vrf_id_t vrf_id)
718e3744 391{
d62a17ae 392 struct interface *ifp;
393
394 /* zebra_interface_state_read () updates interface structure in
395 iflist. */
396 ifp = zebra_interface_state_read(zclient->ibuf, vrf_id);
718e3744 397
d62a17ae 398 if (ifp == NULL)
399 return 0;
718e3744 400
d62a17ae 401 if (IS_RIP_DEBUG_ZEBRA)
402 zlog_debug(
403 "interface %s index %d flags %#llx metric %d mtu %d is up",
404 ifp->name, ifp->ifindex, (unsigned long long)ifp->flags,
405 ifp->metric, ifp->mtu);
718e3744 406
d62a17ae 407 /* Check if this interface is RIP enabled or not.*/
408 rip_enable_apply(ifp);
718e3744 409
d62a17ae 410 /* Check for a passive interface */
411 rip_passive_interface_apply(ifp);
718e3744 412
d62a17ae 413 /* Apply distribute list to the all interface. */
414 rip_distribute_update_interface(ifp);
718e3744 415
d62a17ae 416 return 0;
718e3744 417}
418
419/* Inteface addition message from zebra. */
d62a17ae 420int rip_interface_add(int command, struct zclient *zclient, zebra_size_t length,
421 vrf_id_t vrf_id)
718e3744 422{
d62a17ae 423 struct interface *ifp;
718e3744 424
d62a17ae 425 ifp = zebra_interface_add_read(zclient->ibuf, vrf_id);
718e3744 426
d62a17ae 427 if (IS_RIP_DEBUG_ZEBRA)
428 zlog_debug(
429 "interface add %s index %d flags %#llx metric %d mtu %d",
430 ifp->name, ifp->ifindex, (unsigned long long)ifp->flags,
431 ifp->metric, ifp->mtu);
718e3744 432
d62a17ae 433 /* Check if this interface is RIP enabled or not.*/
434 rip_enable_apply(ifp);
718e3744 435
d62a17ae 436 /* Check for a passive interface */
437 rip_passive_interface_apply(ifp);
718e3744 438
d62a17ae 439 /* Apply distribute list to the all interface. */
440 rip_distribute_update_interface(ifp);
718e3744 441
d62a17ae 442 /* rip_request_neighbor_all (); */
16705130 443
d62a17ae 444 /* Check interface routemap. */
445 rip_if_rmap_update_interface(ifp);
446
447 return 0;
718e3744 448}
449
d62a17ae 450int rip_interface_delete(int command, struct zclient *zclient,
451 zebra_size_t length, vrf_id_t vrf_id)
718e3744 452{
d62a17ae 453 struct interface *ifp;
454 struct stream *s;
455
718e3744 456
d62a17ae 457 s = zclient->ibuf;
458 /* zebra_interface_state_read() updates interface structure in iflist */
459 ifp = zebra_interface_state_read(s, vrf_id);
718e3744 460
d62a17ae 461 if (ifp == NULL)
462 return 0;
463
464 if (if_is_up(ifp)) {
465 rip_if_down(ifp);
466 }
718e3744 467
d62a17ae 468 zlog_info("interface delete %s index %d flags %#llx metric %d mtu %d",
469 ifp->name, ifp->ifindex, (unsigned long long)ifp->flags,
470 ifp->metric, ifp->mtu);
718e3744 471
d62a17ae 472 /* To support pseudo interface do not free interface structure. */
473 /* if_delete(ifp); */
ff880b78 474 if_set_index(ifp, IFINDEX_INTERNAL);
718e3744 475
d62a17ae 476 return 0;
718e3744 477}
478
d62a17ae 479static void rip_interface_clean(struct rip_interface *ri)
4305dfd1 480{
d62a17ae 481 ri->enable_network = 0;
482 ri->enable_interface = 0;
483 ri->running = 0;
718e3744 484
d62a17ae 485 if (ri->t_wakeup) {
486 thread_cancel(ri->t_wakeup);
487 ri->t_wakeup = NULL;
488 }
4305dfd1 489}
718e3744 490
d62a17ae 491void rip_interfaces_clean(void)
718e3744 492{
f4e14fdb 493 struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
d62a17ae 494 struct interface *ifp;
718e3744 495
f4e14fdb 496 RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
d62a17ae 497 rip_interface_clean(ifp->info);
1dec2166 498}
718e3744 499
d62a17ae 500static void rip_interface_reset(struct rip_interface *ri)
4305dfd1 501{
d62a17ae 502 /* Default authentication type is simple password for Cisco
503 compatibility. */
504 ri->auth_type = RIP_NO_AUTH;
505 ri->md5_auth_len = RIP_AUTH_MD5_COMPAT_SIZE;
718e3744 506
d62a17ae 507 /* Set default split-horizon behavior. If the interface is Frame
508 Relay or SMDS is enabled, the default value for split-horizon is
509 off. But currently Zebra does detect Frame Relay or SMDS
510 interface. So all interface is set to split horizon. */
511 ri->split_horizon_default = RIP_SPLIT_HORIZON;
512 ri->split_horizon = ri->split_horizon_default;
718e3744 513
d62a17ae 514 ri->ri_send = RI_RIP_UNSPEC;
515 ri->ri_receive = RI_RIP_UNSPEC;
718e3744 516
d62a17ae 517 ri->v2_broadcast = 0;
f90310cf 518
d62a17ae 519 if (ri->auth_str) {
520 free(ri->auth_str);
521 ri->auth_str = NULL;
522 }
523 if (ri->key_chain) {
524 free(ri->key_chain);
525 ri->key_chain = NULL;
526 }
527
528 ri->list[RIP_FILTER_IN] = NULL;
529 ri->list[RIP_FILTER_OUT] = NULL;
718e3744 530
d62a17ae 531 ri->prefix[RIP_FILTER_IN] = NULL;
532 ri->prefix[RIP_FILTER_OUT] = NULL;
718e3744 533
d62a17ae 534 ri->recv_badpackets = 0;
535 ri->recv_badroutes = 0;
536 ri->sent_updates = 0;
4305dfd1 537
d62a17ae 538 ri->passive = 0;
718e3744 539
d62a17ae 540 rip_interface_clean(ri);
4305dfd1 541}
718e3744 542
d62a17ae 543void rip_interfaces_reset(void)
1dec2166 544{
f4e14fdb 545 struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
d62a17ae 546 struct interface *ifp;
718e3744 547
f4e14fdb 548 RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
d62a17ae 549 rip_interface_reset(ifp->info);
718e3744 550}
551
d62a17ae 552int rip_if_down(struct interface *ifp)
718e3744 553{
d62a17ae 554 struct route_node *rp;
555 struct rip_info *rinfo;
556 struct rip_interface *ri = NULL;
557 struct list *list = NULL;
558 struct listnode *listnode = NULL, *nextnode = NULL;
559 if (rip) {
560 for (rp = route_top(rip->table); rp; rp = route_next(rp))
561 if ((list = rp->info) != NULL)
562 for (ALL_LIST_ELEMENTS(list, listnode, nextnode,
563 rinfo))
564 if (rinfo->ifindex == ifp->ifindex)
565 rip_ecmp_delete(rinfo);
566
567 ri = ifp->info;
568
569 if (ri->running) {
570 if (IS_RIP_DEBUG_EVENT)
571 zlog_debug("turn off %s", ifp->name);
572
573 /* Leave from multicast group. */
574 rip_multicast_leave(ifp, rip->sock);
575
576 ri->running = 0;
577 }
578 }
579
580 return 0;
718e3744 581}
582
583/* Needed for stop RIP process. */
d62a17ae 584void rip_if_down_all()
718e3744 585{
f4e14fdb 586 struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
d62a17ae 587 struct interface *ifp;
718e3744 588
f4e14fdb 589 RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
d62a17ae 590 rip_if_down(ifp);
718e3744 591}
592
d62a17ae 593static void rip_apply_address_add(struct connected *ifc)
dc63bfd4 594{
d62a17ae 595 struct prefix_ipv4 address;
596 struct prefix *p;
16705130 597
d62a17ae 598 if (!rip)
599 return;
16705130 600
d62a17ae 601 if (!if_is_up(ifc->ifp))
602 return;
16705130 603
d62a17ae 604 p = ifc->address;
16705130 605
d62a17ae 606 memset(&address, 0, sizeof(address));
607 address.family = p->family;
608 address.prefix = p->u.prefix4;
609 address.prefixlen = p->prefixlen;
610 apply_mask_ipv4(&address);
16705130 611
d62a17ae 612 /* Check if this interface is RIP enabled or not
613 or Check if this address's prefix is RIP enabled */
614 if ((rip_enable_if_lookup(ifc->ifp->name) >= 0)
615 || (rip_enable_network_lookup2(ifc) >= 0))
616 rip_redistribute_add(ZEBRA_ROUTE_CONNECT, RIP_ROUTE_INTERFACE,
617 &address, ifc->ifp->ifindex, NULL, 0, 0,
618 0);
16705130 619}
620
d62a17ae 621int rip_interface_address_add(int command, struct zclient *zclient,
622 zebra_size_t length, vrf_id_t vrf_id)
718e3744 623{
d62a17ae 624 struct connected *ifc;
625 struct prefix *p;
718e3744 626
d62a17ae 627 ifc = zebra_interface_address_read(ZEBRA_INTERFACE_ADDRESS_ADD,
628 zclient->ibuf, vrf_id);
718e3744 629
d62a17ae 630 if (ifc == NULL)
631 return 0;
718e3744 632
d62a17ae 633 p = ifc->address;
718e3744 634
d62a17ae 635 if (p->family == AF_INET) {
636 if (IS_RIP_DEBUG_ZEBRA)
637 zlog_debug("connected address %s/%d is added",
638 inet_ntoa(p->u.prefix4), p->prefixlen);
16705130 639
d62a17ae 640 rip_enable_apply(ifc->ifp);
641 /* Check if this prefix needs to be redistributed */
642 rip_apply_address_add(ifc);
718e3744 643
d62a17ae 644 hook_call(rip_ifaddr_add, ifc);
645 }
718e3744 646
d62a17ae 647 return 0;
718e3744 648}
649
d62a17ae 650static void rip_apply_address_del(struct connected *ifc)
651{
652 struct prefix_ipv4 address;
653 struct prefix *p;
16705130 654
d62a17ae 655 if (!rip)
656 return;
16705130 657
d62a17ae 658 if (!if_is_up(ifc->ifp))
659 return;
16705130 660
d62a17ae 661 p = ifc->address;
16705130 662
d62a17ae 663 memset(&address, 0, sizeof(address));
664 address.family = p->family;
665 address.prefix = p->u.prefix4;
666 address.prefixlen = p->prefixlen;
667 apply_mask_ipv4(&address);
16705130 668
d62a17ae 669 rip_redistribute_delete(ZEBRA_ROUTE_CONNECT, RIP_ROUTE_INTERFACE,
670 &address, ifc->ifp->ifindex);
16705130 671}
672
d62a17ae 673int rip_interface_address_delete(int command, struct zclient *zclient,
674 zebra_size_t length, vrf_id_t vrf_id)
718e3744 675{
d62a17ae 676 struct connected *ifc;
677 struct prefix *p;
718e3744 678
d62a17ae 679 ifc = zebra_interface_address_read(ZEBRA_INTERFACE_ADDRESS_DELETE,
680 zclient->ibuf, vrf_id);
718e3744 681
d62a17ae 682 if (ifc) {
683 p = ifc->address;
684 if (p->family == AF_INET) {
685 if (IS_RIP_DEBUG_ZEBRA)
686 zlog_debug("connected address %s/%d is deleted",
687 inet_ntoa(p->u.prefix4),
688 p->prefixlen);
16705130 689
d62a17ae 690 hook_call(rip_ifaddr_del, ifc);
718e3744 691
d62a17ae 692 /* Chech wether this prefix needs to be removed */
693 rip_apply_address_del(ifc);
694 }
718e3744 695
d62a17ae 696 connected_free(ifc);
697 }
718e3744 698
d62a17ae 699 return 0;
718e3744 700}
6b0655a2 701
718e3744 702/* Check interface is enabled by network statement. */
16705130 703/* Check wether the interface has at least a connected prefix that
704 * is within the ripng_enable_network table. */
d62a17ae 705static int rip_enable_network_lookup_if(struct interface *ifp)
706{
707 struct listnode *node, *nnode;
708 struct connected *connected;
709 struct prefix_ipv4 address;
710
711 for (ALL_LIST_ELEMENTS(ifp->connected, node, nnode, connected)) {
712 struct prefix *p;
713 struct route_node *node;
714
715 p = connected->address;
716
717 if (p->family == AF_INET) {
718 address.family = AF_INET;
719 address.prefix = p->u.prefix4;
720 address.prefixlen = IPV4_MAX_BITLEN;
721
722 node = route_node_match(rip_enable_network,
723 (struct prefix *)&address);
724 if (node) {
725 route_unlock_node(node);
726 return 1;
727 }
728 }
729 }
730 return -1;
718e3744 731}
732
16705130 733/* Check wether connected is within the ripng_enable_network table. */
d62a17ae 734int rip_enable_network_lookup2(struct connected *connected)
16705130 735{
d62a17ae 736 struct prefix_ipv4 address;
737 struct prefix *p;
16705130 738
d62a17ae 739 p = connected->address;
16705130 740
d62a17ae 741 if (p->family == AF_INET) {
742 struct route_node *node;
16705130 743
d62a17ae 744 address.family = p->family;
745 address.prefix = p->u.prefix4;
746 address.prefixlen = IPV4_MAX_BITLEN;
16705130 747
d62a17ae 748 /* LPM on p->family, p->u.prefix4/IPV4_MAX_BITLEN within
749 * rip_enable_network */
750 node = route_node_match(rip_enable_network,
751 (struct prefix *)&address);
16705130 752
d62a17ae 753 if (node) {
754 route_unlock_node(node);
755 return 1;
756 }
757 }
16705130 758
d62a17ae 759 return -1;
16705130 760}
718e3744 761/* Add RIP enable network. */
d62a17ae 762static int rip_enable_network_add(struct prefix *p)
718e3744 763{
d62a17ae 764 struct route_node *node;
718e3744 765
d62a17ae 766 node = route_node_get(rip_enable_network, p);
718e3744 767
d62a17ae 768 if (node->info) {
769 route_unlock_node(node);
770 return -1;
771 } else
772 node->info = (void *)1;
718e3744 773
d62a17ae 774 /* XXX: One should find a better solution than a generic one */
775 rip_enable_apply_all();
16705130 776
d62a17ae 777 return 1;
718e3744 778}
779
780/* Delete RIP enable network. */
d62a17ae 781static int rip_enable_network_delete(struct prefix *p)
718e3744 782{
d62a17ae 783 struct route_node *node;
718e3744 784
d62a17ae 785 node = route_node_lookup(rip_enable_network, p);
786 if (node) {
787 node->info = NULL;
718e3744 788
d62a17ae 789 /* Unlock info lock. */
790 route_unlock_node(node);
718e3744 791
d62a17ae 792 /* Unlock lookup lock. */
793 route_unlock_node(node);
718e3744 794
d62a17ae 795 /* XXX: One should find a better solution than a generic one */
796 rip_enable_apply_all();
16705130 797
d62a17ae 798 return 1;
799 }
800 return -1;
718e3744 801}
802
803/* Check interface is enabled by ifname statement. */
d62a17ae 804static int rip_enable_if_lookup(const char *ifname)
718e3744 805{
d62a17ae 806 unsigned int i;
807 char *str;
718e3744 808
d62a17ae 809 for (i = 0; i < vector_active(rip_enable_interface); i++)
810 if ((str = vector_slot(rip_enable_interface, i)) != NULL)
811 if (strcmp(str, ifname) == 0)
812 return i;
813 return -1;
718e3744 814}
815
816/* Add interface to rip_enable_if. */
d62a17ae 817static int rip_enable_if_add(const char *ifname)
718e3744 818{
d62a17ae 819 int ret;
718e3744 820
d62a17ae 821 ret = rip_enable_if_lookup(ifname);
822 if (ret >= 0)
823 return -1;
718e3744 824
d62a17ae 825 vector_set(rip_enable_interface, strdup(ifname));
718e3744 826
d62a17ae 827 rip_enable_apply_all(); /* TODOVJ */
16705130 828
d62a17ae 829 return 1;
718e3744 830}
831
832/* Delete interface from rip_enable_if. */
d62a17ae 833static int rip_enable_if_delete(const char *ifname)
718e3744 834{
d62a17ae 835 int index;
836 char *str;
718e3744 837
d62a17ae 838 index = rip_enable_if_lookup(ifname);
839 if (index < 0)
840 return -1;
718e3744 841
d62a17ae 842 str = vector_slot(rip_enable_interface, index);
843 free(str);
844 vector_unset(rip_enable_interface, index);
718e3744 845
d62a17ae 846 rip_enable_apply_all(); /* TODOVJ */
16705130 847
d62a17ae 848 return 1;
718e3744 849}
850
851/* Join to multicast group and send request to the interface. */
d62a17ae 852static int rip_interface_wakeup(struct thread *t)
718e3744 853{
d62a17ae 854 struct interface *ifp;
855 struct rip_interface *ri;
718e3744 856
d62a17ae 857 /* Get interface. */
858 ifp = THREAD_ARG(t);
718e3744 859
d62a17ae 860 ri = ifp->info;
861 ri->t_wakeup = NULL;
718e3744 862
d62a17ae 863 /* Join to multicast group. */
864 if (rip_multicast_join(ifp, rip->sock) < 0) {
865 zlog_err("multicast join failed, interface %s not running",
866 ifp->name);
867 return 0;
868 }
718e3744 869
d62a17ae 870 /* Set running flag. */
871 ri->running = 1;
872
873 /* Send RIP request to the interface. */
874 rip_request_interface(ifp);
875
876 return 0;
877}
878
879static void rip_connect_set(struct interface *ifp, int set)
880{
881 struct listnode *node, *nnode;
882 struct connected *connected;
883 struct prefix_ipv4 address;
884
885 for (ALL_LIST_ELEMENTS(ifp->connected, node, nnode, connected)) {
886 struct prefix *p;
887 p = connected->address;
888
889 if (p->family != AF_INET)
890 continue;
891
892 address.family = AF_INET;
893 address.prefix = p->u.prefix4;
894 address.prefixlen = p->prefixlen;
895 apply_mask_ipv4(&address);
896
897 if (set) {
898 /* Check once more wether this prefix is within a
899 * "network IF_OR_PREF" one */
900 if ((rip_enable_if_lookup(connected->ifp->name) >= 0)
901 || (rip_enable_network_lookup2(connected) >= 0))
902 rip_redistribute_add(
903 ZEBRA_ROUTE_CONNECT,
904 RIP_ROUTE_INTERFACE, &address,
905 connected->ifp->ifindex, NULL, 0, 0, 0);
906 } else {
907 rip_redistribute_delete(ZEBRA_ROUTE_CONNECT,
908 RIP_ROUTE_INTERFACE, &address,
909 connected->ifp->ifindex);
910 if (rip_redistribute_check(ZEBRA_ROUTE_CONNECT))
911 rip_redistribute_add(
912 ZEBRA_ROUTE_CONNECT,
913 RIP_ROUTE_REDISTRIBUTE, &address,
914 connected->ifp->ifindex, NULL, 0, 0, 0);
915 }
916 }
718e3744 917}
918
919/* Update interface status. */
d62a17ae 920void rip_enable_apply(struct interface *ifp)
718e3744 921{
d62a17ae 922 int ret;
923 struct rip_interface *ri = NULL;
718e3744 924
d62a17ae 925 /* Check interface. */
926 if (!if_is_operative(ifp))
927 return;
718e3744 928
d62a17ae 929 ri = ifp->info;
930
931 /* Check network configuration. */
932 ret = rip_enable_network_lookup_if(ifp);
933
934 /* If the interface is matched. */
935 if (ret > 0)
936 ri->enable_network = 1;
937 else
938 ri->enable_network = 0;
939
940 /* Check interface name configuration. */
941 ret = rip_enable_if_lookup(ifp->name);
942 if (ret >= 0)
943 ri->enable_interface = 1;
944 else
945 ri->enable_interface = 0;
718e3744 946
d62a17ae 947 /* any interface MUST have an IPv4 address */
948 if (!rip_if_ipv4_address_check(ifp)) {
949 ri->enable_network = 0;
950 ri->enable_interface = 0;
718e3744 951 }
718e3744 952
d62a17ae 953 /* Update running status of the interface. */
954 if (ri->enable_network || ri->enable_interface) {
955 {
956 if (IS_RIP_DEBUG_EVENT)
957 zlog_debug("turn on %s", ifp->name);
958
959 /* Add interface wake up thread. */
960 thread_add_timer(master, rip_interface_wakeup, ifp, 1,
961 &ri->t_wakeup);
962 rip_connect_set(ifp, 1);
963 }
964 } else {
965 if (ri->running) {
966 /* Might as well clean up the route table as well
967 * rip_if_down sets to 0 ri->running, and displays "turn
968 *off %s"
969 **/
970 rip_if_down(ifp);
971
972 rip_connect_set(ifp, 0);
973 }
718e3744 974 }
718e3744 975}
976
977/* Apply network configuration to all interface. */
d62a17ae 978void rip_enable_apply_all()
718e3744 979{
f4e14fdb 980 struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
d62a17ae 981 struct interface *ifp;
718e3744 982
d62a17ae 983 /* Check each interface. */
f4e14fdb 984 RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
d62a17ae 985 rip_enable_apply(ifp);
718e3744 986}
987
d62a17ae 988int rip_neighbor_lookup(struct sockaddr_in *from)
718e3744 989{
d62a17ae 990 struct prefix_ipv4 p;
991 struct route_node *node;
718e3744 992
d62a17ae 993 memset(&p, 0, sizeof(struct prefix_ipv4));
994 p.family = AF_INET;
995 p.prefix = from->sin_addr;
996 p.prefixlen = IPV4_MAX_BITLEN;
718e3744 997
d62a17ae 998 node = route_node_lookup(rip->neighbor, (struct prefix *)&p);
999 if (node) {
1000 route_unlock_node(node);
1001 return 1;
1002 }
1003 return 0;
718e3744 1004}
1005
1006/* Add new RIP neighbor to the neighbor tree. */
d62a17ae 1007static int rip_neighbor_add(struct prefix_ipv4 *p)
718e3744 1008{
d62a17ae 1009 struct route_node *node;
718e3744 1010
d62a17ae 1011 node = route_node_get(rip->neighbor, (struct prefix *)p);
718e3744 1012
d62a17ae 1013 if (node->info)
1014 return -1;
718e3744 1015
d62a17ae 1016 node->info = rip->neighbor;
718e3744 1017
d62a17ae 1018 return 0;
718e3744 1019}
1020
1021/* Delete RIP neighbor from the neighbor tree. */
d62a17ae 1022static int rip_neighbor_delete(struct prefix_ipv4 *p)
718e3744 1023{
d62a17ae 1024 struct route_node *node;
718e3744 1025
d62a17ae 1026 /* Lock for look up. */
1027 node = route_node_lookup(rip->neighbor, (struct prefix *)p);
1028 if (!node)
1029 return -1;
718e3744 1030
d62a17ae 1031 node->info = NULL;
718e3744 1032
d62a17ae 1033 /* Unlock lookup lock. */
1034 route_unlock_node(node);
718e3744 1035
d62a17ae 1036 /* Unlock real neighbor information lock. */
1037 route_unlock_node(node);
1038
1039 return 0;
718e3744 1040}
1041
1042/* Clear all network and neighbor configuration. */
d62a17ae 1043void rip_clean_network()
1044{
1045 unsigned int i;
1046 char *str;
1047 struct route_node *rn;
1048
1049 /* rip_enable_network. */
1050 for (rn = route_top(rip_enable_network); rn; rn = route_next(rn))
1051 if (rn->info) {
1052 rn->info = NULL;
1053 route_unlock_node(rn);
1054 }
1055
1056 /* rip_enable_interface. */
1057 for (i = 0; i < vector_active(rip_enable_interface); i++)
1058 if ((str = vector_slot(rip_enable_interface, i)) != NULL) {
1059 free(str);
1060 vector_slot(rip_enable_interface, i) = NULL;
1061 }
718e3744 1062}
6b0655a2 1063
718e3744 1064/* Utility function for looking up passive interface settings. */
d62a17ae 1065static int rip_passive_nondefault_lookup(const char *ifname)
718e3744 1066{
d62a17ae 1067 unsigned int i;
1068 char *str;
718e3744 1069
d62a17ae 1070 for (i = 0; i < vector_active(Vrip_passive_nondefault); i++)
1071 if ((str = vector_slot(Vrip_passive_nondefault, i)) != NULL)
1072 if (strcmp(str, ifname) == 0)
1073 return i;
1074 return -1;
718e3744 1075}
1076
d62a17ae 1077void rip_passive_interface_apply(struct interface *ifp)
718e3744 1078{
d62a17ae 1079 struct rip_interface *ri;
718e3744 1080
d62a17ae 1081 ri = ifp->info;
718e3744 1082
d62a17ae 1083 ri->passive = ((rip_passive_nondefault_lookup(ifp->name) < 0)
1084 ? passive_default
1085 : !passive_default);
4aaff3f8 1086
d62a17ae 1087 if (IS_RIP_DEBUG_ZEBRA)
1088 zlog_debug("interface %s: passive = %d", ifp->name,
1089 ri->passive);
718e3744 1090}
1091
d62a17ae 1092static void rip_passive_interface_apply_all(void)
718e3744 1093{
f4e14fdb 1094 struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
d62a17ae 1095 struct interface *ifp;
718e3744 1096
f4e14fdb 1097 RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
d62a17ae 1098 rip_passive_interface_apply(ifp);
718e3744 1099}
1100
1101/* Passive interface. */
d62a17ae 1102static int rip_passive_nondefault_set(struct vty *vty, const char *ifname)
718e3744 1103{
d62a17ae 1104 if (rip_passive_nondefault_lookup(ifname) >= 0)
1105 return CMD_WARNING_CONFIG_FAILED;
718e3744 1106
d62a17ae 1107 vector_set(Vrip_passive_nondefault, strdup(ifname));
718e3744 1108
d62a17ae 1109 rip_passive_interface_apply_all();
718e3744 1110
d62a17ae 1111 return CMD_SUCCESS;
718e3744 1112}
1113
d62a17ae 1114static int rip_passive_nondefault_unset(struct vty *vty, const char *ifname)
718e3744 1115{
d62a17ae 1116 int i;
1117 char *str;
718e3744 1118
d62a17ae 1119 i = rip_passive_nondefault_lookup(ifname);
1120 if (i < 0)
1121 return CMD_WARNING_CONFIG_FAILED;
718e3744 1122
d62a17ae 1123 str = vector_slot(Vrip_passive_nondefault, i);
1124 free(str);
1125 vector_unset(Vrip_passive_nondefault, i);
718e3744 1126
d62a17ae 1127 rip_passive_interface_apply_all();
718e3744 1128
d62a17ae 1129 return CMD_SUCCESS;
718e3744 1130}
1131
1132/* Free all configured RIP passive-interface settings. */
d62a17ae 1133void rip_passive_nondefault_clean(void)
718e3744 1134{
d62a17ae 1135 unsigned int i;
1136 char *str;
718e3744 1137
d62a17ae 1138 for (i = 0; i < vector_active(Vrip_passive_nondefault); i++)
1139 if ((str = vector_slot(Vrip_passive_nondefault, i)) != NULL) {
1140 free(str);
1141 vector_slot(Vrip_passive_nondefault, i) = NULL;
1142 }
1143 rip_passive_interface_apply_all();
718e3744 1144}
6b0655a2 1145
718e3744 1146/* RIP enable network or interface configuration. */
1147DEFUN (rip_network,
1148 rip_network_cmd,
6147e2c6 1149 "network <A.B.C.D/M|WORD>",
718e3744 1150 "Enable routing on an IP network\n"
1151 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1152 "Interface name\n")
1153{
d62a17ae 1154 int idx_ipv4_word = 1;
1155 int ret;
1156 struct prefix_ipv4 p;
718e3744 1157
d62a17ae 1158 ret = str2prefix_ipv4(argv[idx_ipv4_word]->arg, &p);
718e3744 1159
d62a17ae 1160 if (ret)
1161 ret = rip_enable_network_add((struct prefix *)&p);
1162 else
1163 ret = rip_enable_if_add(argv[idx_ipv4_word]->arg);
718e3744 1164
d62a17ae 1165 if (ret < 0) {
1166 vty_out(vty, "There is a same network configuration %s\n",
1167 argv[idx_ipv4_word]->arg);
1168 return CMD_WARNING_CONFIG_FAILED;
1169 }
718e3744 1170
d62a17ae 1171 return CMD_SUCCESS;
718e3744 1172}
1173
1174/* RIP enable network or interface configuration. */
1175DEFUN (no_rip_network,
1176 no_rip_network_cmd,
6147e2c6 1177 "no network <A.B.C.D/M|WORD>",
718e3744 1178 NO_STR
1179 "Enable routing on an IP network\n"
1180 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1181 "Interface name\n")
1182{
d62a17ae 1183 int idx_ipv4_word = 2;
1184 int ret;
1185 struct prefix_ipv4 p;
718e3744 1186
d62a17ae 1187 ret = str2prefix_ipv4(argv[idx_ipv4_word]->arg, &p);
718e3744 1188
d62a17ae 1189 if (ret)
1190 ret = rip_enable_network_delete((struct prefix *)&p);
1191 else
1192 ret = rip_enable_if_delete(argv[idx_ipv4_word]->arg);
718e3744 1193
d62a17ae 1194 if (ret < 0) {
1195 vty_out(vty, "Can't find network configuration %s\n",
1196 argv[idx_ipv4_word]->arg);
1197 return CMD_WARNING_CONFIG_FAILED;
1198 }
718e3744 1199
d62a17ae 1200 return CMD_SUCCESS;
718e3744 1201}
1202
1203/* RIP neighbor configuration set. */
1204DEFUN (rip_neighbor,
1205 rip_neighbor_cmd,
1206 "neighbor A.B.C.D",
1207 "Specify a neighbor router\n"
1208 "Neighbor address\n")
1209{
d62a17ae 1210 int idx_ipv4 = 1;
1211 int ret;
1212 struct prefix_ipv4 p;
718e3744 1213
d62a17ae 1214 ret = str2prefix_ipv4(argv[idx_ipv4]->arg, &p);
1215
1216 if (ret <= 0) {
1217 vty_out(vty, "Please specify address by A.B.C.D\n");
1218 return CMD_WARNING_CONFIG_FAILED;
1219 }
718e3744 1220
d62a17ae 1221 rip_neighbor_add(&p);
718e3744 1222
d62a17ae 1223 return CMD_SUCCESS;
718e3744 1224}
1225
1226/* RIP neighbor configuration unset. */
1227DEFUN (no_rip_neighbor,
1228 no_rip_neighbor_cmd,
1229 "no neighbor A.B.C.D",
1230 NO_STR
1231 "Specify a neighbor router\n"
1232 "Neighbor address\n")
1233{
d62a17ae 1234 int idx_ipv4 = 2;
1235 int ret;
1236 struct prefix_ipv4 p;
718e3744 1237
d62a17ae 1238 ret = str2prefix_ipv4(argv[idx_ipv4]->arg, &p);
718e3744 1239
d62a17ae 1240 if (ret <= 0) {
1241 vty_out(vty, "Please specify address by A.B.C.D\n");
1242 return CMD_WARNING_CONFIG_FAILED;
1243 }
1244
1245 rip_neighbor_delete(&p);
718e3744 1246
d62a17ae 1247 return CMD_SUCCESS;
718e3744 1248}
1249
1250DEFUN (ip_rip_receive_version,
1251 ip_rip_receive_version_cmd,
bca63dc7 1252 "ip rip receive version <(1-2)|none>",
718e3744 1253 IP_STR
1254 "Routing Information Protocol\n"
1255 "Advertisement reception\n"
1256 "Version control\n"
7111c1a0 1257 "RIP version\n"
6aec4b41 1258 "None\n")
718e3744 1259{
d62a17ae 1260 VTY_DECLVAR_CONTEXT(interface, ifp);
1261 int idx_type = 4;
1262 struct rip_interface *ri;
1263
1264 ri = ifp->info;
1265
1266 switch (argv[idx_type]->arg[0]) {
1267 case '1':
1268 ri->ri_receive = RI_RIP_VERSION_1;
1269 return CMD_SUCCESS;
1270 case '2':
1271 ri->ri_receive = RI_RIP_VERSION_2;
1272 return CMD_SUCCESS;
1273 case 'n':
1274 ri->ri_receive = RI_RIP_VERSION_NONE;
1275 return CMD_SUCCESS;
1276 default:
1277 break;
1278 }
6aec4b41 1279
d62a17ae 1280 return CMD_WARNING_CONFIG_FAILED;
718e3744 1281}
1282
1283DEFUN (ip_rip_receive_version_1,
1284 ip_rip_receive_version_1_cmd,
7111c1a0 1285 "ip rip receive version <1 2|2 1>",
718e3744 1286 IP_STR
1287 "Routing Information Protocol\n"
1288 "Advertisement reception\n"
1289 "Version control\n"
1290 "RIP version 1\n"
7111c1a0 1291 "RIP version 2\n"
718e3744 1292 "RIP version 2\n"
1293 "RIP version 1\n")
1294{
d62a17ae 1295 VTY_DECLVAR_CONTEXT(interface, ifp);
1296 struct rip_interface *ri;
718e3744 1297
d62a17ae 1298 ri = ifp->info;
718e3744 1299
d62a17ae 1300 /* Version 1 and 2. */
1301 ri->ri_receive = RI_RIP_VERSION_1_AND_2;
1302 return CMD_SUCCESS;
718e3744 1303}
1304
1305DEFUN (no_ip_rip_receive_version,
1306 no_ip_rip_receive_version_cmd,
e83a9414 1307 "no ip rip receive version [(1-2)]",
718e3744 1308 NO_STR
1309 IP_STR
1310 "Routing Information Protocol\n"
1311 "Advertisement reception\n"
55c727dd 1312 "Version control\n"
7111c1a0 1313 "RIP version\n")
718e3744 1314{
d62a17ae 1315 VTY_DECLVAR_CONTEXT(interface, ifp);
1316 struct rip_interface *ri;
718e3744 1317
d62a17ae 1318 ri = ifp->info;
718e3744 1319
d62a17ae 1320 ri->ri_receive = RI_RIP_UNSPEC;
1321 return CMD_SUCCESS;
718e3744 1322}
1323
718e3744 1324
1325DEFUN (ip_rip_send_version,
1326 ip_rip_send_version_cmd,
e83a9414 1327 "ip rip send version (1-2)",
718e3744 1328 IP_STR
1329 "Routing Information Protocol\n"
1330 "Advertisement transmission\n"
1331 "Version control\n"
7111c1a0 1332 "RIP version\n")
718e3744 1333{
d62a17ae 1334 VTY_DECLVAR_CONTEXT(interface, ifp);
1335 int idx_type = 4;
1336 struct rip_interface *ri;
718e3744 1337
d62a17ae 1338 ri = ifp->info;
718e3744 1339
d62a17ae 1340 /* Version 1. */
1341 if (atoi(argv[idx_type]->arg) == 1) {
1342 ri->ri_send = RI_RIP_VERSION_1;
1343 return CMD_SUCCESS;
1344 }
1345 if (atoi(argv[idx_type]->arg) == 2) {
1346 ri->ri_send = RI_RIP_VERSION_2;
1347 return CMD_SUCCESS;
1348 }
1349 return CMD_WARNING_CONFIG_FAILED;
718e3744 1350}
1351
1352DEFUN (ip_rip_send_version_1,
1353 ip_rip_send_version_1_cmd,
7111c1a0 1354 "ip rip send version <1 2|2 1>",
718e3744 1355 IP_STR
1356 "Routing Information Protocol\n"
1357 "Advertisement transmission\n"
1358 "Version control\n"
1359 "RIP version 1\n"
7111c1a0 1360 "RIP version 2\n"
718e3744 1361 "RIP version 2\n"
1362 "RIP version 1\n")
1363{
d62a17ae 1364 VTY_DECLVAR_CONTEXT(interface, ifp);
1365 struct rip_interface *ri;
718e3744 1366
d62a17ae 1367 ri = ifp->info;
718e3744 1368
d62a17ae 1369 /* Version 1 and 2. */
1370 ri->ri_send = RI_RIP_VERSION_1_AND_2;
1371 return CMD_SUCCESS;
718e3744 1372}
1373
1374DEFUN (no_ip_rip_send_version,
1375 no_ip_rip_send_version_cmd,
e83a9414 1376 "no ip rip send version [(1-2)]",
718e3744 1377 NO_STR
1378 IP_STR
1379 "Routing Information Protocol\n"
1380 "Advertisement transmission\n"
55c727dd 1381 "Version control\n"
7111c1a0 1382 "RIP version\n")
718e3744 1383{
d62a17ae 1384 VTY_DECLVAR_CONTEXT(interface, ifp);
1385 struct rip_interface *ri;
718e3744 1386
d62a17ae 1387 ri = ifp->info;
718e3744 1388
d62a17ae 1389 ri->ri_send = RI_RIP_UNSPEC;
1390 return CMD_SUCCESS;
718e3744 1391}
1392
718e3744 1393
f90310cf
RW
1394DEFUN (ip_rip_v2_broadcast,
1395 ip_rip_v2_broadcast_cmd,
1396 "ip rip v2-broadcast",
1397 IP_STR
1398 "Routing Information Protocol\n"
1399 "Send ip broadcast v2 update\n")
1400{
d62a17ae 1401 VTY_DECLVAR_CONTEXT(interface, ifp);
1402 struct rip_interface *ri;
f90310cf 1403
d62a17ae 1404 ri = ifp->info;
f90310cf 1405
d62a17ae 1406 ri->v2_broadcast = 1;
1407 return CMD_SUCCESS;
f90310cf
RW
1408}
1409
1410DEFUN (no_ip_rip_v2_broadcast,
1411 no_ip_rip_v2_broadcast_cmd,
1412 "no ip rip v2-broadcast",
1413 NO_STR
1414 IP_STR
1415 "Routing Information Protocol\n"
1416 "Send ip broadcast v2 update\n")
1417{
d62a17ae 1418 VTY_DECLVAR_CONTEXT(interface, ifp);
1419 struct rip_interface *ri;
f90310cf 1420
d62a17ae 1421 ri = ifp->info;
f90310cf 1422
d62a17ae 1423 ri->v2_broadcast = 0;
1424 return CMD_SUCCESS;
f90310cf
RW
1425}
1426
718e3744 1427DEFUN (ip_rip_authentication_mode,
1428 ip_rip_authentication_mode_cmd,
55c727dd 1429 "ip rip authentication mode <md5|text> [auth-length <rfc|old-ripd>]",
718e3744 1430 IP_STR
1431 "Routing Information Protocol\n"
1432 "Authentication control\n"
1433 "Authentication mode\n"
1434 "Keyed message digest\n"
55c727dd
QY
1435 "Clear text authentication\n"
1436 "MD5 authentication data length\n"
1437 "RFC compatible\n"
1438 "Old ripd compatible\n")
718e3744 1439{
d62a17ae 1440 VTY_DECLVAR_CONTEXT(interface, ifp);
1441 char *cryptmode = argv[4]->text;
1442 char *authlen = (argc > 5) ? argv[6]->text : NULL;
1443 struct rip_interface *ri;
1444 int auth_type;
1445
1446 ri = ifp->info;
1447
1448 if (strmatch("md5", cryptmode))
1449 auth_type = RIP_AUTH_MD5;
1450 else {
1451 assert(strmatch("text", cryptmode));
1452 auth_type = RIP_AUTH_SIMPLE_PASSWORD;
1453 }
1454
1455 ri->auth_type = auth_type;
1456
1457 if (argc > 5) {
1458 if (auth_type != RIP_AUTH_MD5) {
1459 vty_out(vty,
1460 "auth length argument only valid for md5\n");
1461 return CMD_WARNING_CONFIG_FAILED;
1462 }
1463 if (strmatch("rfc", authlen))
1464 ri->md5_auth_len = RIP_AUTH_MD5_SIZE;
1465 else {
1466 assert(strmatch("old-ripd", authlen));
1467 ri->md5_auth_len = RIP_AUTH_MD5_COMPAT_SIZE;
1468 }
1469 }
1470
1471 return CMD_SUCCESS;
718e3744 1472}
1473
1474DEFUN (no_ip_rip_authentication_mode,
1475 no_ip_rip_authentication_mode_cmd,
55c727dd 1476 "no ip rip authentication mode [<md5|text> [auth-length <rfc|old-ripd>]]",
718e3744 1477 NO_STR
1478 IP_STR
1479 "Routing Information Protocol\n"
1480 "Authentication control\n"
55c727dd
QY
1481 "Authentication mode\n"
1482 "Keyed message digest\n"
1483 "Clear text authentication\n"
1484 "MD5 authentication data length\n"
1485 "RFC compatible\n"
1486 "Old ripd compatible\n")
718e3744 1487{
d62a17ae 1488 VTY_DECLVAR_CONTEXT(interface, ifp);
1489 struct rip_interface *ri;
718e3744 1490
d62a17ae 1491 ri = ifp->info;
718e3744 1492
d62a17ae 1493 ri->auth_type = RIP_NO_AUTH;
1494 ri->md5_auth_len = RIP_AUTH_MD5_COMPAT_SIZE;
718e3744 1495
d62a17ae 1496 return CMD_SUCCESS;
718e3744 1497}
1498
718e3744 1499DEFUN (ip_rip_authentication_string,
1500 ip_rip_authentication_string_cmd,
1501 "ip rip authentication string LINE",
1502 IP_STR
1503 "Routing Information Protocol\n"
1504 "Authentication control\n"
1505 "Authentication string\n"
1506 "Authentication string\n")
1507{
d62a17ae 1508 VTY_DECLVAR_CONTEXT(interface, ifp);
1509 int idx_line = 4;
1510 struct rip_interface *ri;
718e3744 1511
d62a17ae 1512 ri = ifp->info;
718e3744 1513
d62a17ae 1514 if (strlen(argv[idx_line]->arg) > 16) {
1515 vty_out(vty,
1516 "%% RIPv2 authentication string must be shorter than 16\n");
1517 return CMD_WARNING_CONFIG_FAILED;
1518 }
718e3744 1519
d62a17ae 1520 if (ri->key_chain) {
1521 vty_out(vty, "%% key-chain configuration exists\n");
1522 return CMD_WARNING_CONFIG_FAILED;
1523 }
718e3744 1524
d62a17ae 1525 if (ri->auth_str)
1526 free(ri->auth_str);
718e3744 1527
d62a17ae 1528 ri->auth_str = strdup(argv[idx_line]->arg);
718e3744 1529
d62a17ae 1530 return CMD_SUCCESS;
718e3744 1531}
1532
1533DEFUN (no_ip_rip_authentication_string,
1534 no_ip_rip_authentication_string_cmd,
55c727dd 1535 "no ip rip authentication string [LINE]",
718e3744 1536 NO_STR
1537 IP_STR
1538 "Routing Information Protocol\n"
1539 "Authentication control\n"
55c727dd 1540 "Authentication string\n"
718e3744 1541 "Authentication string\n")
1542{
d62a17ae 1543 VTY_DECLVAR_CONTEXT(interface, ifp);
1544 struct rip_interface *ri;
718e3744 1545
d62a17ae 1546 ri = ifp->info;
718e3744 1547
d62a17ae 1548 if (ri->auth_str)
1549 free(ri->auth_str);
718e3744 1550
d62a17ae 1551 ri->auth_str = NULL;
718e3744 1552
d62a17ae 1553 return CMD_SUCCESS;
718e3744 1554}
1555
718e3744 1556
1557DEFUN (ip_rip_authentication_key_chain,
1558 ip_rip_authentication_key_chain_cmd,
1559 "ip rip authentication key-chain LINE",
1560 IP_STR
1561 "Routing Information Protocol\n"
1562 "Authentication control\n"
1563 "Authentication key-chain\n"
1564 "name of key-chain\n")
1565{
d62a17ae 1566 VTY_DECLVAR_CONTEXT(interface, ifp);
1567 int idx_line = 4;
1568 struct rip_interface *ri;
718e3744 1569
d62a17ae 1570 ri = ifp->info;
718e3744 1571
d62a17ae 1572 if (ri->auth_str) {
1573 vty_out(vty, "%% authentication string configuration exists\n");
1574 return CMD_WARNING_CONFIG_FAILED;
1575 }
718e3744 1576
d62a17ae 1577 if (ri->key_chain)
1578 free(ri->key_chain);
718e3744 1579
d62a17ae 1580 ri->key_chain = strdup(argv[idx_line]->arg);
718e3744 1581
d62a17ae 1582 return CMD_SUCCESS;
718e3744 1583}
1584
1585DEFUN (no_ip_rip_authentication_key_chain,
1586 no_ip_rip_authentication_key_chain_cmd,
55c727dd 1587 "no ip rip authentication key-chain [LINE]",
718e3744 1588 NO_STR
1589 IP_STR
1590 "Routing Information Protocol\n"
1591 "Authentication control\n"
55c727dd
QY
1592 "Authentication key-chain\n"
1593 "name of key-chain\n")
718e3744 1594{
d62a17ae 1595 VTY_DECLVAR_CONTEXT(interface, ifp);
1596 struct rip_interface *ri;
718e3744 1597
d62a17ae 1598 ri = ifp->info;
718e3744 1599
d62a17ae 1600 if (ri->key_chain)
1601 free(ri->key_chain);
718e3744 1602
d62a17ae 1603 ri->key_chain = NULL;
718e3744 1604
d62a17ae 1605 return CMD_SUCCESS;
718e3744 1606}
1607
718e3744 1608
16705130 1609/* CHANGED: ip rip split-horizon
1610 Cisco and Zebra's command is
1611 ip split-horizon
1612 */
1613DEFUN (ip_rip_split_horizon,
1614 ip_rip_split_horizon_cmd,
1615 "ip rip split-horizon",
718e3744 1616 IP_STR
16705130 1617 "Routing Information Protocol\n"
718e3744 1618 "Perform split horizon\n")
1619{
d62a17ae 1620 VTY_DECLVAR_CONTEXT(interface, ifp);
1621 struct rip_interface *ri;
718e3744 1622
d62a17ae 1623 ri = ifp->info;
718e3744 1624
d62a17ae 1625 ri->split_horizon = RIP_SPLIT_HORIZON;
1626 return CMD_SUCCESS;
718e3744 1627}
1628
16705130 1629DEFUN (ip_rip_split_horizon_poisoned_reverse,
1630 ip_rip_split_horizon_poisoned_reverse_cmd,
1631 "ip rip split-horizon poisoned-reverse",
1632 IP_STR
1633 "Routing Information Protocol\n"
1634 "Perform split horizon\n"
1635 "With poisoned-reverse\n")
1636{
d62a17ae 1637 VTY_DECLVAR_CONTEXT(interface, ifp);
1638 struct rip_interface *ri;
16705130 1639
d62a17ae 1640 ri = ifp->info;
16705130 1641
d62a17ae 1642 ri->split_horizon = RIP_SPLIT_HORIZON_POISONED_REVERSE;
1643 return CMD_SUCCESS;
16705130 1644}
1645
1646/* CHANGED: no ip rip split-horizon
1647 Cisco and Zebra's command is
1648 no ip split-horizon
1649 */
1650DEFUN (no_ip_rip_split_horizon,
1651 no_ip_rip_split_horizon_cmd,
1652 "no ip rip split-horizon",
718e3744 1653 NO_STR
1654 IP_STR
16705130 1655 "Routing Information Protocol\n"
718e3744 1656 "Perform split horizon\n")
1657{
d62a17ae 1658 VTY_DECLVAR_CONTEXT(interface, ifp);
1659 struct rip_interface *ri;
718e3744 1660
d62a17ae 1661 ri = ifp->info;
718e3744 1662
d62a17ae 1663 ri->split_horizon = RIP_NO_SPLIT_HORIZON;
1664 return CMD_SUCCESS;
718e3744 1665}
1666
fac3e841 1667DEFUN (no_ip_rip_split_horizon_poisoned_reverse,
16705130 1668 no_ip_rip_split_horizon_poisoned_reverse_cmd,
1669 "no ip rip split-horizon poisoned-reverse",
1670 NO_STR
1671 IP_STR
1672 "Routing Information Protocol\n"
1673 "Perform split horizon\n"
1674 "With poisoned-reverse\n")
fac3e841 1675{
d62a17ae 1676 VTY_DECLVAR_CONTEXT(interface, ifp);
1677 struct rip_interface *ri;
fac3e841 1678
d62a17ae 1679 ri = ifp->info;
fac3e841 1680
d62a17ae 1681 switch (ri->split_horizon) {
1682 case RIP_SPLIT_HORIZON_POISONED_REVERSE:
1683 ri->split_horizon = RIP_SPLIT_HORIZON;
1684 default:
1685 break;
1686 }
fac3e841 1687
d62a17ae 1688 return CMD_SUCCESS;
fac3e841 1689}
16705130 1690
718e3744 1691DEFUN (rip_passive_interface,
1692 rip_passive_interface_cmd,
6147e2c6 1693 "passive-interface <IFNAME|default>",
718e3744 1694 "Suppress routing updates on an interface\n"
56e475cb 1695 "Interface name\n"
1696 "default for all interfaces\n")
718e3744 1697{
d62a17ae 1698 if (argv[1]->type == WORD_TKN) { // user passed 'default'
1699 passive_default = 1;
1700 rip_passive_nondefault_clean();
1701 return CMD_SUCCESS;
1702 }
1703 if (passive_default)
1704 return rip_passive_nondefault_unset(vty, argv[1]->arg);
1705 else
1706 return rip_passive_nondefault_set(vty, argv[1]->arg);
718e3744 1707}
1708
1709DEFUN (no_rip_passive_interface,
1710 no_rip_passive_interface_cmd,
6147e2c6 1711 "no passive-interface <IFNAME|default>",
718e3744 1712 NO_STR
1713 "Suppress routing updates on an interface\n"
56e475cb 1714 "Interface name\n"
1715 "default for all interfaces\n")
718e3744 1716{
d62a17ae 1717 if (argv[2]->type == WORD_TKN) {
1718 passive_default = 0;
1719 rip_passive_nondefault_clean();
1720 return CMD_SUCCESS;
1721 }
1722 if (passive_default)
1723 return rip_passive_nondefault_set(vty, argv[2]->arg);
1724 else
1725 return rip_passive_nondefault_unset(vty, argv[2]->arg);
718e3744 1726}
6b0655a2 1727
718e3744 1728/* Write rip configuration of each interface. */
d62a17ae 1729static int rip_interface_config_write(struct vty *vty)
1730{
f4e14fdb 1731 struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
d62a17ae 1732 struct interface *ifp;
1733
f4e14fdb 1734 RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
d62a17ae 1735 struct rip_interface *ri;
1736
d62a17ae 1737 ri = ifp->info;
1738
1739 /* Do not display the interface if there is no
1740 * configuration about it.
1741 **/
1742 if ((!ifp->desc)
1743 && (ri->split_horizon == ri->split_horizon_default)
1744 && (ri->ri_send == RI_RIP_UNSPEC)
1745 && (ri->ri_receive == RI_RIP_UNSPEC)
1746 && (ri->auth_type != RIP_AUTH_MD5) && (!ri->v2_broadcast)
1747 && (ri->md5_auth_len != RIP_AUTH_MD5_SIZE)
1748 && (!ri->auth_str) && (!ri->key_chain))
1749 continue;
1750
a8b828f3 1751 vty_frame(vty, "interface %s\n", ifp->name);
d62a17ae 1752
1753 if (ifp->desc)
1754 vty_out(vty, " description %s\n", ifp->desc);
1755
1756 /* Split horizon. */
1757 if (ri->split_horizon != ri->split_horizon_default) {
1758 switch (ri->split_horizon) {
1759 case RIP_SPLIT_HORIZON:
1760 vty_out(vty, " ip rip split-horizon\n");
1761 break;
1762 case RIP_SPLIT_HORIZON_POISONED_REVERSE:
1763 vty_out(vty,
1764 " ip rip split-horizon poisoned-reverse\n");
1765 break;
1766 case RIP_NO_SPLIT_HORIZON:
1767 default:
1768 vty_out(vty, " no ip rip split-horizon\n");
1769 break;
1770 }
1771 }
1772
1773 /* RIP version setting. */
1774 if (ri->ri_send != RI_RIP_UNSPEC)
1775 vty_out(vty, " ip rip send version %s\n",
1776 lookup_msg(ri_version_msg, ri->ri_send, NULL));
1777
1778 if (ri->ri_receive != RI_RIP_UNSPEC)
1779 vty_out(vty, " ip rip receive version %s \n",
1780 lookup_msg(ri_version_msg, ri->ri_receive,
1781 NULL));
1782
1783 if (ri->v2_broadcast)
1784 vty_out(vty, " ip rip v2-broadcast\n");
1785
1786 /* RIP authentication. */
1787 if (ri->auth_type == RIP_AUTH_SIMPLE_PASSWORD)
1788 vty_out(vty, " ip rip authentication mode text\n");
1789
1790 if (ri->auth_type == RIP_AUTH_MD5) {
1791 vty_out(vty, " ip rip authentication mode md5");
1792 if (ri->md5_auth_len == RIP_AUTH_MD5_COMPAT_SIZE)
1793 vty_out(vty, " auth-length old-ripd");
1794 else
1795 vty_out(vty, " auth-length rfc");
1796 vty_out(vty, "\n");
1797 }
1798
1799 if (ri->auth_str)
1800 vty_out(vty, " ip rip authentication string %s\n",
1801 ri->auth_str);
1802
1803 if (ri->key_chain)
1804 vty_out(vty, " ip rip authentication key-chain %s\n",
1805 ri->key_chain);
1806
a8b828f3 1807 vty_endframe(vty, "!\n");
d62a17ae 1808 }
1809 return 0;
1810}
1811
1812int config_write_rip_network(struct vty *vty, int config_mode)
1813{
1814 unsigned int i;
1815 char *ifname;
1816 struct route_node *node;
1817
1818 /* Network type RIP enable interface statement. */
1819 for (node = route_top(rip_enable_network); node;
1820 node = route_next(node))
1821 if (node->info)
1822 vty_out(vty, "%s%s/%d\n",
1823 config_mode ? " network " : " ",
1824 inet_ntoa(node->p.u.prefix4),
1825 node->p.prefixlen);
1826
1827 /* Interface name RIP enable statement. */
1828 for (i = 0; i < vector_active(rip_enable_interface); i++)
1829 if ((ifname = vector_slot(rip_enable_interface, i)) != NULL)
1830 vty_out(vty, "%s%s\n",
1831 config_mode ? " network " : " ", ifname);
1832
1833 /* RIP neighbors listing. */
1834 for (node = route_top(rip->neighbor); node; node = route_next(node))
1835 if (node->info)
1836 vty_out(vty, "%s%s\n",
1837 config_mode ? " neighbor " : " ",
1838 inet_ntoa(node->p.u.prefix4));
1839
1840 /* RIP passive interface listing. */
1841 if (config_mode) {
1842 if (passive_default)
1843 vty_out(vty, " passive-interface default\n");
1844 for (i = 0; i < vector_active(Vrip_passive_nondefault); i++)
1845 if ((ifname = vector_slot(Vrip_passive_nondefault, i))
1846 != NULL)
1847 vty_out(vty, " %spassive-interface %s\n",
1848 (passive_default ? "no " : ""), ifname);
718e3744 1849 }
1850
d62a17ae 1851 return 0;
1852}
1853
1854static struct cmd_node interface_node = {
9d303b37 1855 INTERFACE_NODE, "%s(config-if)# ", 1,
718e3744 1856};
1857
1858/* Called when interface structure allocated. */
d62a17ae 1859static int rip_interface_new_hook(struct interface *ifp)
718e3744 1860{
d62a17ae 1861 ifp->info = rip_interface_new();
1862 return 0;
718e3744 1863}
1864
1865/* Called when interface structure deleted. */
d62a17ae 1866static int rip_interface_delete_hook(struct interface *ifp)
718e3744 1867{
d62a17ae 1868 XFREE(MTYPE_RIP_INTERFACE, ifp->info);
1869 ifp->info = NULL;
1870 return 0;
718e3744 1871}
1872
1873/* Allocate and initialize interface vector. */
d62a17ae 1874void rip_if_init(void)
718e3744 1875{
d62a17ae 1876 /* Default initial size of interface vector. */
ce19a04a
DL
1877 hook_register_prio(if_add, 0, rip_interface_new_hook);
1878 hook_register_prio(if_del, 0, rip_interface_delete_hook);
d62a17ae 1879
1880 /* RIP network init. */
1881 rip_enable_interface = vector_init(1);
1882 rip_enable_network = route_table_init();
718e3744 1883
d62a17ae 1884 /* RIP passive interface. */
1885 Vrip_passive_nondefault = vector_init(1);
718e3744 1886
d62a17ae 1887 /* Install interface node. */
1888 install_node(&interface_node, rip_interface_config_write);
1889 if_cmd_init();
718e3744 1890
d62a17ae 1891 /* Install commands. */
1892 install_element(RIP_NODE, &rip_network_cmd);
1893 install_element(RIP_NODE, &no_rip_network_cmd);
1894 install_element(RIP_NODE, &rip_neighbor_cmd);
1895 install_element(RIP_NODE, &no_rip_neighbor_cmd);
718e3744 1896
d62a17ae 1897 install_element(RIP_NODE, &rip_passive_interface_cmd);
1898 install_element(RIP_NODE, &no_rip_passive_interface_cmd);
718e3744 1899
d62a17ae 1900 install_element(INTERFACE_NODE, &ip_rip_send_version_cmd);
1901 install_element(INTERFACE_NODE, &ip_rip_send_version_1_cmd);
1902 install_element(INTERFACE_NODE, &no_ip_rip_send_version_cmd);
718e3744 1903
d62a17ae 1904 install_element(INTERFACE_NODE, &ip_rip_receive_version_cmd);
1905 install_element(INTERFACE_NODE, &ip_rip_receive_version_1_cmd);
1906 install_element(INTERFACE_NODE, &no_ip_rip_receive_version_cmd);
718e3744 1907
d62a17ae 1908 install_element(INTERFACE_NODE, &ip_rip_v2_broadcast_cmd);
1909 install_element(INTERFACE_NODE, &no_ip_rip_v2_broadcast_cmd);
f90310cf 1910
d62a17ae 1911 install_element(INTERFACE_NODE, &ip_rip_authentication_mode_cmd);
1912 install_element(INTERFACE_NODE, &no_ip_rip_authentication_mode_cmd);
718e3744 1913
d62a17ae 1914 install_element(INTERFACE_NODE, &ip_rip_authentication_key_chain_cmd);
1915 install_element(INTERFACE_NODE,
1916 &no_ip_rip_authentication_key_chain_cmd);
718e3744 1917
d62a17ae 1918 install_element(INTERFACE_NODE, &ip_rip_authentication_string_cmd);
1919 install_element(INTERFACE_NODE, &no_ip_rip_authentication_string_cmd);
718e3744 1920
d62a17ae 1921 install_element(INTERFACE_NODE, &ip_rip_split_horizon_cmd);
1922 install_element(INTERFACE_NODE,
1923 &ip_rip_split_horizon_poisoned_reverse_cmd);
1924 install_element(INTERFACE_NODE, &no_ip_rip_split_horizon_cmd);
1925 install_element(INTERFACE_NODE,
1926 &no_ip_rip_split_horizon_poisoned_reverse_cmd);
718e3744 1927}