1 /* Interface related function for RIP.
2 * Copyright (C) 1997, 98 Kunihiro Ishiguro <kunihiro@zebra.org>
4 * This file is part of GNU Zebra.
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
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.
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
25 #include "sockunion.h"
38 #include "zebra/connected.h"
40 #include "ripd/ripd.h"
41 #include "ripd/rip_debug.h"
42 #include "ripd/rip_interface.h"
44 DEFINE_HOOK(rip_ifaddr_add
, (struct connected
*ifc
), (ifc
))
45 DEFINE_HOOK(rip_ifaddr_del
, (struct connected
*ifc
), (ifc
))
47 /* static prototypes */
48 static void rip_enable_apply (struct interface
*);
49 static void rip_passive_interface_apply (struct interface
*);
50 static int rip_if_down(struct interface
*ifp
);
51 static int rip_enable_if_lookup (const char *ifname
);
52 static int rip_enable_network_lookup2 (struct connected
*connected
);
53 static void rip_enable_apply_all (void);
55 const struct message ri_version_msg
[] =
57 {RI_RIP_VERSION_1
, "1"},
58 {RI_RIP_VERSION_2
, "2"},
59 {RI_RIP_VERSION_1_AND_2
, "1 2"},
60 {RI_RIP_VERSION_NONE
, "none"},
63 extern struct zebra_privs_t ripd_privs
;
65 /* RIP enabled network vector. */
66 vector rip_enable_interface
;
68 /* RIP enabled interface table. */
69 struct route_table
*rip_enable_network
;
71 /* Vector to store passive-interface name. */
72 static int passive_default
; /* are we in passive-interface default mode? */
73 vector Vrip_passive_nondefault
;
75 /* Join to the RIP version 2 multicast group. */
77 ipv4_multicast_join (int sock
,
84 ret
= setsockopt_ipv4_multicast (sock
,
91 zlog_info("can't setsockopt IP_ADD_MEMBERSHIP %s", safe_strerror(errno
));
96 /* Leave from the RIP version 2 multicast group. */
98 ipv4_multicast_leave (int sock
,
105 ret
= setsockopt_ipv4_multicast (sock
,
112 zlog_info("can't setsockopt IP_DROP_MEMBERSHIP");
117 static void rip_interface_reset (struct rip_interface
*);
119 /* Allocate new RIP's interface configuration. */
120 static struct rip_interface
*
121 rip_interface_new (void)
123 struct rip_interface
*ri
;
125 ri
= XCALLOC (MTYPE_RIP_INTERFACE
, sizeof (struct rip_interface
));
127 rip_interface_reset (ri
);
133 rip_interface_multicast_set (int sock
, struct connected
*connected
)
137 assert (connected
!= NULL
);
139 addr
= CONNECTED_ID(connected
)->u
.prefix4
;
141 if (setsockopt_ipv4_multicast_if (sock
, addr
, connected
->ifp
->ifindex
) < 0)
143 zlog_warn ("Can't setsockopt IP_MULTICAST_IF on fd %d to "
144 "ifindex %d for interface %s",
145 sock
, connected
->ifp
->ifindex
,
146 connected
->ifp
->name
);
152 /* Send RIP request packet to specified interface. */
154 rip_request_interface_send (struct interface
*ifp
, u_char version
)
156 struct sockaddr_in to
;
158 /* RIPv2 support multicast. */
159 if (version
== RIPv2
&& if_is_multicast (ifp
))
162 if (IS_RIP_DEBUG_EVENT
)
163 zlog_debug ("multicast request on %s", ifp
->name
);
165 rip_request_send (NULL
, ifp
, version
, NULL
);
169 /* RIPv1 and non multicast interface. */
170 if (if_is_pointopoint (ifp
) || if_is_broadcast (ifp
))
172 struct listnode
*cnode
, *cnnode
;
173 struct connected
*connected
;
175 if (IS_RIP_DEBUG_EVENT
)
176 zlog_debug ("broadcast request to %s", ifp
->name
);
178 for (ALL_LIST_ELEMENTS (ifp
->connected
, cnode
, cnnode
, connected
))
180 if (connected
->address
->family
== AF_INET
)
182 memset (&to
, 0, sizeof (struct sockaddr_in
));
183 to
.sin_port
= htons (RIP_PORT_DEFAULT
);
184 if (connected
->destination
)
185 /* use specified broadcast or peer destination addr */
186 to
.sin_addr
= connected
->destination
->u
.prefix4
;
187 else if (connected
->address
->prefixlen
< IPV4_MAX_PREFIXLEN
)
188 /* calculate the appropriate broadcast address */
190 ipv4_broadcast_addr(connected
->address
->u
.prefix4
.s_addr
,
191 connected
->address
->prefixlen
);
193 /* do not know where to send the packet */
196 if (IS_RIP_DEBUG_EVENT
)
197 zlog_debug ("SEND request to %s", inet_ntoa (to
.sin_addr
));
199 rip_request_send (&to
, ifp
, version
, connected
);
205 /* This will be executed when interface goes up. */
207 rip_request_interface (struct interface
*ifp
)
209 struct rip_interface
*ri
;
211 /* In default ripd doesn't send RIP_REQUEST to the loopback interface. */
212 if (if_is_loopback (ifp
))
215 /* If interface is down, don't send RIP packet. */
216 if (! if_is_operative (ifp
))
219 /* Fetch RIP interface information. */
223 /* If there is no version configuration in the interface,
224 use rip's version setting. */
226 int vsend
= ((ri
->ri_send
== RI_RIP_UNSPEC
) ?
227 rip
->version_send
: ri
->ri_send
);
229 rip_request_interface_send (ifp
, RIPv1
);
231 rip_request_interface_send (ifp
, RIPv2
);
236 /* Send RIP request to the neighbor. */
238 rip_request_neighbor (struct in_addr addr
)
240 struct sockaddr_in to
;
242 memset (&to
, 0, sizeof (struct sockaddr_in
));
243 to
.sin_port
= htons (RIP_PORT_DEFAULT
);
246 rip_request_send (&to
, NULL
, rip
->version_send
, NULL
);
249 /* Request routes at all interfaces. */
251 rip_request_neighbor_all (void)
253 struct route_node
*rp
;
258 if (IS_RIP_DEBUG_EVENT
)
259 zlog_debug ("request to the all neighbor");
261 /* Send request to all neighbor. */
262 for (rp
= route_top (rip
->neighbor
); rp
; rp
= route_next (rp
))
264 rip_request_neighbor (rp
->p
.u
.prefix4
);
268 /* Multicast packet receive socket. */
270 rip_multicast_join (struct interface
*ifp
, int sock
)
272 struct listnode
*cnode
;
273 struct connected
*ifc
;
275 if (if_is_operative (ifp
) && if_is_multicast (ifp
))
277 if (IS_RIP_DEBUG_EVENT
)
278 zlog_debug ("multicast join at %s", ifp
->name
);
280 for (ALL_LIST_ELEMENTS_RO (ifp
->connected
, cnode
, ifc
))
282 struct prefix_ipv4
*p
;
283 struct in_addr group
;
285 p
= (struct prefix_ipv4
*) ifc
->address
;
287 if (p
->family
!= AF_INET
)
290 group
.s_addr
= htonl (INADDR_RIP_GROUP
);
291 if (ipv4_multicast_join (sock
, group
, p
->prefix
, ifp
->ifindex
) < 0)
300 /* Leave from multicast group. */
302 rip_multicast_leave (struct interface
*ifp
, int sock
)
304 struct listnode
*cnode
;
305 struct connected
*connected
;
307 if (if_is_up (ifp
) && if_is_multicast (ifp
))
309 if (IS_RIP_DEBUG_EVENT
)
310 zlog_debug ("multicast leave from %s", ifp
->name
);
312 for (ALL_LIST_ELEMENTS_RO (ifp
->connected
, cnode
, connected
))
314 struct prefix_ipv4
*p
;
315 struct in_addr group
;
317 p
= (struct prefix_ipv4
*) connected
->address
;
319 if (p
->family
!= AF_INET
)
322 group
.s_addr
= htonl (INADDR_RIP_GROUP
);
323 if (ipv4_multicast_leave (sock
, group
, p
->prefix
, ifp
->ifindex
) == 0)
329 /* Is there and address on interface that I could use ? */
331 rip_if_ipv4_address_check (struct interface
*ifp
)
334 struct connected
*connected
;
337 for (ALL_LIST_ELEMENTS_RO (ifp
->connected
, nn
, connected
))
341 p
= connected
->address
;
343 if (p
->family
== AF_INET
)
353 /* Does this address belongs to me ? */
355 if_check_address (struct in_addr addr
)
357 struct listnode
*node
;
358 struct interface
*ifp
;
360 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), node
, ifp
))
362 struct listnode
*cnode
;
363 struct connected
*connected
;
365 for (ALL_LIST_ELEMENTS_RO (ifp
->connected
, cnode
, connected
))
367 struct prefix_ipv4
*p
;
369 p
= (struct prefix_ipv4
*) connected
->address
;
371 if (p
->family
!= AF_INET
)
374 if (IPV4_ADDR_CMP (&p
->prefix
, &addr
) == 0)
381 /* Inteface link down message processing. */
383 rip_interface_down (int command
, struct zclient
*zclient
, zebra_size_t length
,
386 struct interface
*ifp
;
391 /* zebra_interface_state_read() updates interface structure in
393 ifp
= zebra_interface_state_read (s
, vrf_id
);
400 if (IS_RIP_DEBUG_ZEBRA
)
401 zlog_debug ("interface %s index %d flags %llx metric %d mtu %d is down",
402 ifp
->name
, ifp
->ifindex
, (unsigned long long)ifp
->flags
,
403 ifp
->metric
, ifp
->mtu
);
408 /* Inteface link up message processing */
410 rip_interface_up (int command
, struct zclient
*zclient
, zebra_size_t length
,
413 struct interface
*ifp
;
415 /* zebra_interface_state_read () updates interface structure in
417 ifp
= zebra_interface_state_read (zclient
->ibuf
, vrf_id
);
422 if (IS_RIP_DEBUG_ZEBRA
)
423 zlog_debug ("interface %s index %d flags %#llx metric %d mtu %d is up",
424 ifp
->name
, ifp
->ifindex
, (unsigned long long) ifp
->flags
,
425 ifp
->metric
, ifp
->mtu
);
427 /* Check if this interface is RIP enabled or not.*/
428 rip_enable_apply (ifp
);
430 /* Check for a passive interface */
431 rip_passive_interface_apply (ifp
);
433 /* Apply distribute list to the all interface. */
434 rip_distribute_update_interface (ifp
);
439 /* Inteface addition message from zebra. */
441 rip_interface_add (int command
, struct zclient
*zclient
, zebra_size_t length
,
444 struct interface
*ifp
;
446 ifp
= zebra_interface_add_read (zclient
->ibuf
, vrf_id
);
448 if (IS_RIP_DEBUG_ZEBRA
)
449 zlog_debug ("interface add %s index %d flags %#llx metric %d mtu %d",
450 ifp
->name
, ifp
->ifindex
, (unsigned long long) ifp
->flags
,
451 ifp
->metric
, ifp
->mtu
);
453 /* Check if this interface is RIP enabled or not.*/
454 rip_enable_apply (ifp
);
456 /* Check for a passive interface */
457 rip_passive_interface_apply (ifp
);
459 /* Apply distribute list to the all interface. */
460 rip_distribute_update_interface (ifp
);
462 /* rip_request_neighbor_all (); */
464 /* Check interface routemap. */
465 rip_if_rmap_update_interface (ifp
);
471 rip_interface_delete (int command
, struct zclient
*zclient
,
472 zebra_size_t length
, vrf_id_t vrf_id
)
474 struct interface
*ifp
;
479 /* zebra_interface_state_read() updates interface structure in iflist */
480 ifp
= zebra_interface_state_read (s
, vrf_id
);
485 if (if_is_up (ifp
)) {
489 zlog_info("interface delete %s index %d flags %#llx metric %d mtu %d",
490 ifp
->name
, ifp
->ifindex
, (unsigned long long) ifp
->flags
,
491 ifp
->metric
, ifp
->mtu
);
493 /* To support pseudo interface do not free interface structure. */
494 /* if_delete(ifp); */
495 ifp
->ifindex
= IFINDEX_DELETED
;
501 rip_interface_clean (struct rip_interface
*ri
)
503 ri
->enable_network
= 0;
504 ri
->enable_interface
= 0;
509 thread_cancel (ri
->t_wakeup
);
515 rip_interfaces_clean (void)
517 struct listnode
*node
;
518 struct interface
*ifp
;
520 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), node
, ifp
))
521 rip_interface_clean (ifp
->info
);
525 rip_interface_reset (struct rip_interface
*ri
)
527 /* Default authentication type is simple password for Cisco
529 ri
->auth_type
= RIP_NO_AUTH
;
530 ri
->md5_auth_len
= RIP_AUTH_MD5_COMPAT_SIZE
;
532 /* Set default split-horizon behavior. If the interface is Frame
533 Relay or SMDS is enabled, the default value for split-horizon is
534 off. But currently Zebra does detect Frame Relay or SMDS
535 interface. So all interface is set to split horizon. */
536 ri
->split_horizon_default
= RIP_SPLIT_HORIZON
;
537 ri
->split_horizon
= ri
->split_horizon_default
;
539 ri
->ri_send
= RI_RIP_UNSPEC
;
540 ri
->ri_receive
= RI_RIP_UNSPEC
;
542 ri
->v2_broadcast
= 0;
551 free (ri
->key_chain
);
552 ri
->key_chain
= NULL
;
555 ri
->list
[RIP_FILTER_IN
] = NULL
;
556 ri
->list
[RIP_FILTER_OUT
] = NULL
;
558 ri
->prefix
[RIP_FILTER_IN
] = NULL
;
559 ri
->prefix
[RIP_FILTER_OUT
] = NULL
;
561 ri
->recv_badpackets
= 0;
562 ri
->recv_badroutes
= 0;
563 ri
->sent_updates
= 0;
567 rip_interface_clean (ri
);
571 rip_interfaces_reset (void)
573 struct listnode
*node
;
574 struct interface
*ifp
;
576 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), node
, ifp
))
577 rip_interface_reset (ifp
->info
);
581 rip_if_down(struct interface
*ifp
)
583 struct route_node
*rp
;
584 struct rip_info
*rinfo
;
585 struct rip_interface
*ri
= NULL
;
586 struct list
*list
= NULL
;
587 struct listnode
*listnode
= NULL
, *nextnode
= NULL
;
590 for (rp
= route_top (rip
->table
); rp
; rp
= route_next (rp
))
591 if ((list
= rp
->info
) != NULL
)
592 for (ALL_LIST_ELEMENTS (list
, listnode
, nextnode
, rinfo
))
593 if (rinfo
->ifindex
== ifp
->ifindex
)
594 rip_ecmp_delete (rinfo
);
600 if (IS_RIP_DEBUG_EVENT
)
601 zlog_debug ("turn off %s", ifp
->name
);
603 /* Leave from multicast group. */
604 rip_multicast_leave (ifp
, rip
->sock
);
613 /* Needed for stop RIP process. */
617 struct interface
*ifp
;
618 struct listnode
*node
, *nnode
;
620 for (ALL_LIST_ELEMENTS (vrf_iflist (VRF_DEFAULT
), node
, nnode
, ifp
))
625 rip_apply_address_add (struct connected
*ifc
)
627 struct prefix_ipv4 address
;
633 if (! if_is_up(ifc
->ifp
))
638 memset (&address
, 0, sizeof (address
));
639 address
.family
= p
->family
;
640 address
.prefix
= p
->u
.prefix4
;
641 address
.prefixlen
= p
->prefixlen
;
642 apply_mask_ipv4(&address
);
644 /* Check if this interface is RIP enabled or not
645 or Check if this address's prefix is RIP enabled */
646 if ((rip_enable_if_lookup(ifc
->ifp
->name
) >= 0) ||
647 (rip_enable_network_lookup2(ifc
) >= 0))
648 rip_redistribute_add(ZEBRA_ROUTE_CONNECT
, RIP_ROUTE_INTERFACE
,
649 &address
, ifc
->ifp
->ifindex
, NULL
, 0, 0, 0);
654 rip_interface_address_add (int command
, struct zclient
*zclient
,
655 zebra_size_t length
, vrf_id_t vrf_id
)
657 struct connected
*ifc
;
660 ifc
= zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_ADD
,
661 zclient
->ibuf
, vrf_id
);
668 if (p
->family
== AF_INET
)
670 if (IS_RIP_DEBUG_ZEBRA
)
671 zlog_debug ("connected address %s/%d is added",
672 inet_ntoa (p
->u
.prefix4
), p
->prefixlen
);
674 rip_enable_apply(ifc
->ifp
);
675 /* Check if this prefix needs to be redistributed */
676 rip_apply_address_add(ifc
);
678 hook_call(rip_ifaddr_add
, ifc
);
685 rip_apply_address_del (struct connected
*ifc
) {
686 struct prefix_ipv4 address
;
692 if (! if_is_up(ifc
->ifp
))
697 memset (&address
, 0, sizeof (address
));
698 address
.family
= p
->family
;
699 address
.prefix
= p
->u
.prefix4
;
700 address
.prefixlen
= p
->prefixlen
;
701 apply_mask_ipv4(&address
);
703 rip_redistribute_delete(ZEBRA_ROUTE_CONNECT
, RIP_ROUTE_INTERFACE
,
704 &address
, ifc
->ifp
->ifindex
);
708 rip_interface_address_delete (int command
, struct zclient
*zclient
,
709 zebra_size_t length
, vrf_id_t vrf_id
)
711 struct connected
*ifc
;
714 ifc
= zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_DELETE
,
715 zclient
->ibuf
, vrf_id
);
720 if (p
->family
== AF_INET
)
722 if (IS_RIP_DEBUG_ZEBRA
)
723 zlog_debug ("connected address %s/%d is deleted",
724 inet_ntoa (p
->u
.prefix4
), p
->prefixlen
);
726 hook_call(rip_ifaddr_del
, ifc
);
728 /* Chech wether this prefix needs to be removed */
729 rip_apply_address_del(ifc
);
733 connected_free (ifc
);
740 /* Check interface is enabled by network statement. */
741 /* Check wether the interface has at least a connected prefix that
742 * is within the ripng_enable_network table. */
744 rip_enable_network_lookup_if (struct interface
*ifp
)
746 struct listnode
*node
, *nnode
;
747 struct connected
*connected
;
748 struct prefix_ipv4 address
;
750 for (ALL_LIST_ELEMENTS (ifp
->connected
, node
, nnode
, connected
))
753 struct route_node
*node
;
755 p
= connected
->address
;
757 if (p
->family
== AF_INET
)
759 address
.family
= AF_INET
;
760 address
.prefix
= p
->u
.prefix4
;
761 address
.prefixlen
= IPV4_MAX_BITLEN
;
763 node
= route_node_match (rip_enable_network
,
764 (struct prefix
*)&address
);
767 route_unlock_node (node
);
775 /* Check wether connected is within the ripng_enable_network table. */
777 rip_enable_network_lookup2 (struct connected
*connected
)
779 struct prefix_ipv4 address
;
782 p
= connected
->address
;
784 if (p
->family
== AF_INET
) {
785 struct route_node
*node
;
787 address
.family
= p
->family
;
788 address
.prefix
= p
->u
.prefix4
;
789 address
.prefixlen
= IPV4_MAX_BITLEN
;
791 /* LPM on p->family, p->u.prefix4/IPV4_MAX_BITLEN within rip_enable_network */
792 node
= route_node_match (rip_enable_network
,
793 (struct prefix
*)&address
);
796 route_unlock_node (node
);
803 /* Add RIP enable network. */
805 rip_enable_network_add (struct prefix
*p
)
807 struct route_node
*node
;
809 node
= route_node_get (rip_enable_network
, p
);
813 route_unlock_node (node
);
817 node
->info
= (void *)1;
819 /* XXX: One should find a better solution than a generic one */
820 rip_enable_apply_all();
825 /* Delete RIP enable network. */
827 rip_enable_network_delete (struct prefix
*p
)
829 struct route_node
*node
;
831 node
= route_node_lookup (rip_enable_network
, p
);
836 /* Unlock info lock. */
837 route_unlock_node (node
);
839 /* Unlock lookup lock. */
840 route_unlock_node (node
);
842 /* XXX: One should find a better solution than a generic one */
843 rip_enable_apply_all ();
850 /* Check interface is enabled by ifname statement. */
852 rip_enable_if_lookup (const char *ifname
)
857 for (i
= 0; i
< vector_active (rip_enable_interface
); i
++)
858 if ((str
= vector_slot (rip_enable_interface
, i
)) != NULL
)
859 if (strcmp (str
, ifname
) == 0)
864 /* Add interface to rip_enable_if. */
866 rip_enable_if_add (const char *ifname
)
870 ret
= rip_enable_if_lookup (ifname
);
874 vector_set (rip_enable_interface
, strdup (ifname
));
876 rip_enable_apply_all(); /* TODOVJ */
881 /* Delete interface from rip_enable_if. */
883 rip_enable_if_delete (const char *ifname
)
888 index
= rip_enable_if_lookup (ifname
);
892 str
= vector_slot (rip_enable_interface
, index
);
894 vector_unset (rip_enable_interface
, index
);
896 rip_enable_apply_all(); /* TODOVJ */
901 /* Join to multicast group and send request to the interface. */
903 rip_interface_wakeup (struct thread
*t
)
905 struct interface
*ifp
;
906 struct rip_interface
*ri
;
909 ifp
= THREAD_ARG (t
);
914 /* Join to multicast group. */
915 if (rip_multicast_join (ifp
, rip
->sock
) < 0)
917 zlog_err ("multicast join failed, interface %s not running", ifp
->name
);
921 /* Set running flag. */
924 /* Send RIP request to the interface. */
925 rip_request_interface (ifp
);
931 rip_connect_set (struct interface
*ifp
, int set
)
933 struct listnode
*node
, *nnode
;
934 struct connected
*connected
;
935 struct prefix_ipv4 address
;
937 for (ALL_LIST_ELEMENTS (ifp
->connected
, node
, nnode
, connected
))
940 p
= connected
->address
;
942 if (p
->family
!= AF_INET
)
945 address
.family
= AF_INET
;
946 address
.prefix
= p
->u
.prefix4
;
947 address
.prefixlen
= p
->prefixlen
;
948 apply_mask_ipv4 (&address
);
951 /* Check once more wether this prefix is within a "network IF_OR_PREF" one */
952 if ((rip_enable_if_lookup(connected
->ifp
->name
) >= 0) ||
953 (rip_enable_network_lookup2(connected
) >= 0))
954 rip_redistribute_add (ZEBRA_ROUTE_CONNECT
, RIP_ROUTE_INTERFACE
,
955 &address
, connected
->ifp
->ifindex
,
959 rip_redistribute_delete (ZEBRA_ROUTE_CONNECT
, RIP_ROUTE_INTERFACE
,
960 &address
, connected
->ifp
->ifindex
);
961 if (rip_redistribute_check (ZEBRA_ROUTE_CONNECT
))
962 rip_redistribute_add (ZEBRA_ROUTE_CONNECT
, RIP_ROUTE_REDISTRIBUTE
,
963 &address
, connected
->ifp
->ifindex
,
969 /* Update interface status. */
971 rip_enable_apply (struct interface
*ifp
)
974 struct rip_interface
*ri
= NULL
;
976 /* Check interface. */
977 if (! if_is_operative (ifp
))
982 /* Check network configuration. */
983 ret
= rip_enable_network_lookup_if (ifp
);
985 /* If the interface is matched. */
987 ri
->enable_network
= 1;
989 ri
->enable_network
= 0;
991 /* Check interface name configuration. */
992 ret
= rip_enable_if_lookup (ifp
->name
);
994 ri
->enable_interface
= 1;
996 ri
->enable_interface
= 0;
998 /* any interface MUST have an IPv4 address */
999 if ( ! rip_if_ipv4_address_check (ifp
) )
1001 ri
->enable_network
= 0;
1002 ri
->enable_interface
= 0;
1005 /* Update running status of the interface. */
1006 if (ri
->enable_network
|| ri
->enable_interface
)
1009 if (IS_RIP_DEBUG_EVENT
)
1010 zlog_debug ("turn on %s", ifp
->name
);
1012 /* Add interface wake up thread. */
1013 thread_add_timer(master
, rip_interface_wakeup
, ifp
, 1,
1015 rip_connect_set (ifp
, 1);
1022 /* Might as well clean up the route table as well
1023 * rip_if_down sets to 0 ri->running, and displays "turn off %s"
1027 rip_connect_set (ifp
, 0);
1032 /* Apply network configuration to all interface. */
1034 rip_enable_apply_all ()
1036 struct interface
*ifp
;
1037 struct listnode
*node
, *nnode
;
1039 /* Check each interface. */
1040 for (ALL_LIST_ELEMENTS (vrf_iflist (VRF_DEFAULT
), node
, nnode
, ifp
))
1041 rip_enable_apply (ifp
);
1045 rip_neighbor_lookup (struct sockaddr_in
*from
)
1047 struct prefix_ipv4 p
;
1048 struct route_node
*node
;
1050 memset (&p
, 0, sizeof (struct prefix_ipv4
));
1052 p
.prefix
= from
->sin_addr
;
1053 p
.prefixlen
= IPV4_MAX_BITLEN
;
1055 node
= route_node_lookup (rip
->neighbor
, (struct prefix
*) &p
);
1058 route_unlock_node (node
);
1064 /* Add new RIP neighbor to the neighbor tree. */
1066 rip_neighbor_add (struct prefix_ipv4
*p
)
1068 struct route_node
*node
;
1070 node
= route_node_get (rip
->neighbor
, (struct prefix
*) p
);
1075 node
->info
= rip
->neighbor
;
1080 /* Delete RIP neighbor from the neighbor tree. */
1082 rip_neighbor_delete (struct prefix_ipv4
*p
)
1084 struct route_node
*node
;
1086 /* Lock for look up. */
1087 node
= route_node_lookup (rip
->neighbor
, (struct prefix
*) p
);
1093 /* Unlock lookup lock. */
1094 route_unlock_node (node
);
1096 /* Unlock real neighbor information lock. */
1097 route_unlock_node (node
);
1102 /* Clear all network and neighbor configuration. */
1104 rip_clean_network ()
1108 struct route_node
*rn
;
1110 /* rip_enable_network. */
1111 for (rn
= route_top (rip_enable_network
); rn
; rn
= route_next (rn
))
1115 route_unlock_node (rn
);
1118 /* rip_enable_interface. */
1119 for (i
= 0; i
< vector_active (rip_enable_interface
); i
++)
1120 if ((str
= vector_slot (rip_enable_interface
, i
)) != NULL
)
1123 vector_slot (rip_enable_interface
, i
) = NULL
;
1127 /* Utility function for looking up passive interface settings. */
1129 rip_passive_nondefault_lookup (const char *ifname
)
1134 for (i
= 0; i
< vector_active (Vrip_passive_nondefault
); i
++)
1135 if ((str
= vector_slot (Vrip_passive_nondefault
, i
)) != NULL
)
1136 if (strcmp (str
, ifname
) == 0)
1142 rip_passive_interface_apply (struct interface
*ifp
)
1144 struct rip_interface
*ri
;
1148 ri
->passive
= ((rip_passive_nondefault_lookup (ifp
->name
) < 0) ?
1149 passive_default
: !passive_default
);
1151 if (IS_RIP_DEBUG_ZEBRA
)
1152 zlog_debug ("interface %s: passive = %d",ifp
->name
,ri
->passive
);
1156 rip_passive_interface_apply_all (void)
1158 struct interface
*ifp
;
1159 struct listnode
*node
, *nnode
;
1161 for (ALL_LIST_ELEMENTS (vrf_iflist (VRF_DEFAULT
), node
, nnode
, ifp
))
1162 rip_passive_interface_apply (ifp
);
1165 /* Passive interface. */
1167 rip_passive_nondefault_set (struct vty
*vty
, const char *ifname
)
1169 if (rip_passive_nondefault_lookup (ifname
) >= 0)
1172 vector_set (Vrip_passive_nondefault
, strdup (ifname
));
1174 rip_passive_interface_apply_all ();
1180 rip_passive_nondefault_unset (struct vty
*vty
, const char *ifname
)
1185 i
= rip_passive_nondefault_lookup (ifname
);
1189 str
= vector_slot (Vrip_passive_nondefault
, i
);
1191 vector_unset (Vrip_passive_nondefault
, i
);
1193 rip_passive_interface_apply_all ();
1198 /* Free all configured RIP passive-interface settings. */
1200 rip_passive_nondefault_clean (void)
1205 for (i
= 0; i
< vector_active (Vrip_passive_nondefault
); i
++)
1206 if ((str
= vector_slot (Vrip_passive_nondefault
, i
)) != NULL
)
1209 vector_slot (Vrip_passive_nondefault
, i
) = NULL
;
1211 rip_passive_interface_apply_all ();
1214 /* RIP enable network or interface configuration. */
1217 "network <A.B.C.D/M|WORD>",
1218 "Enable routing on an IP network\n"
1219 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1222 int idx_ipv4_word
= 1;
1224 struct prefix_ipv4 p
;
1226 ret
= str2prefix_ipv4 (argv
[idx_ipv4_word
]->arg
, &p
);
1229 ret
= rip_enable_network_add ((struct prefix
*) &p
);
1231 ret
= rip_enable_if_add (argv
[idx_ipv4_word
]->arg
);
1235 vty_out (vty
, "There is a same network configuration %s%s", argv
[idx_ipv4_word
]->arg
,
1243 /* RIP enable network or interface configuration. */
1244 DEFUN (no_rip_network
,
1246 "no network <A.B.C.D/M|WORD>",
1248 "Enable routing on an IP network\n"
1249 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1252 int idx_ipv4_word
= 2;
1254 struct prefix_ipv4 p
;
1256 ret
= str2prefix_ipv4 (argv
[idx_ipv4_word
]->arg
, &p
);
1259 ret
= rip_enable_network_delete ((struct prefix
*) &p
);
1261 ret
= rip_enable_if_delete (argv
[idx_ipv4_word
]->arg
);
1265 vty_out (vty
, "Can't find network configuration %s%s", argv
[idx_ipv4_word
]->arg
,
1273 /* RIP neighbor configuration set. */
1274 DEFUN (rip_neighbor
,
1277 "Specify a neighbor router\n"
1278 "Neighbor address\n")
1282 struct prefix_ipv4 p
;
1284 ret
= str2prefix_ipv4 (argv
[idx_ipv4
]->arg
, &p
);
1288 vty_out (vty
, "Please specify address by A.B.C.D%s", VTY_NEWLINE
);
1292 rip_neighbor_add (&p
);
1297 /* RIP neighbor configuration unset. */
1298 DEFUN (no_rip_neighbor
,
1299 no_rip_neighbor_cmd
,
1300 "no neighbor A.B.C.D",
1302 "Specify a neighbor router\n"
1303 "Neighbor address\n")
1307 struct prefix_ipv4 p
;
1309 ret
= str2prefix_ipv4 (argv
[idx_ipv4
]->arg
, &p
);
1313 vty_out (vty
, "Please specify address by A.B.C.D%s", VTY_NEWLINE
);
1317 rip_neighbor_delete (&p
);
1322 DEFUN (ip_rip_receive_version
,
1323 ip_rip_receive_version_cmd
,
1324 "ip rip receive version <(1-2)|none>",
1326 "Routing Information Protocol\n"
1327 "Advertisement reception\n"
1333 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1335 struct rip_interface
*ri
;
1339 switch (argv
[idx_type
]->arg
[0])
1342 ri
->ri_receive
= RI_RIP_VERSION_1
;
1345 ri
->ri_receive
= RI_RIP_VERSION_2
;
1348 ri
->ri_receive
= RI_RIP_VERSION_NONE
;
1357 DEFUN (ip_rip_receive_version_1
,
1358 ip_rip_receive_version_1_cmd
,
1359 "ip rip receive version (1-1) (2-2)",
1361 "Routing Information Protocol\n"
1362 "Advertisement reception\n"
1367 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1368 struct rip_interface
*ri
;
1372 /* Version 1 and 2. */
1373 ri
->ri_receive
= RI_RIP_VERSION_1_AND_2
;
1377 DEFUN (ip_rip_receive_version_2
,
1378 ip_rip_receive_version_2_cmd
,
1379 "ip rip receive version (2-2) (1-1)",
1381 "Routing Information Protocol\n"
1382 "Advertisement reception\n"
1387 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1388 struct rip_interface
*ri
;
1392 /* Version 1 and 2. */
1393 ri
->ri_receive
= RI_RIP_VERSION_1_AND_2
;
1397 DEFUN (no_ip_rip_receive_version
,
1398 no_ip_rip_receive_version_cmd
,
1399 "no ip rip receive version [(1-2)]",
1402 "Routing Information Protocol\n"
1403 "Advertisement reception\n"
1408 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1409 struct rip_interface
*ri
;
1413 ri
->ri_receive
= RI_RIP_UNSPEC
;
1418 DEFUN (ip_rip_send_version
,
1419 ip_rip_send_version_cmd
,
1420 "ip rip send version (1-2)",
1422 "Routing Information Protocol\n"
1423 "Advertisement transmission\n"
1428 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1430 struct rip_interface
*ri
;
1435 if (atoi (argv
[idx_type
]->arg
) == 1)
1437 ri
->ri_send
= RI_RIP_VERSION_1
;
1440 if (atoi (argv
[idx_type
]->arg
) == 2)
1442 ri
->ri_send
= RI_RIP_VERSION_2
;
1448 DEFUN (ip_rip_send_version_1
,
1449 ip_rip_send_version_1_cmd
,
1450 "ip rip send version (1-1) (2-2)",
1452 "Routing Information Protocol\n"
1453 "Advertisement transmission\n"
1458 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1459 struct rip_interface
*ri
;
1463 /* Version 1 and 2. */
1464 ri
->ri_send
= RI_RIP_VERSION_1_AND_2
;
1468 DEFUN (ip_rip_send_version_2
,
1469 ip_rip_send_version_2_cmd
,
1470 "ip rip send version (2-2) (1-1)",
1472 "Routing Information Protocol\n"
1473 "Advertisement transmission\n"
1478 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1479 struct rip_interface
*ri
;
1483 /* Version 1 and 2. */
1484 ri
->ri_send
= RI_RIP_VERSION_1_AND_2
;
1488 DEFUN (no_ip_rip_send_version
,
1489 no_ip_rip_send_version_cmd
,
1490 "no ip rip send version [(1-2)]",
1493 "Routing Information Protocol\n"
1494 "Advertisement transmission\n"
1499 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1500 struct rip_interface
*ri
;
1504 ri
->ri_send
= RI_RIP_UNSPEC
;
1509 DEFUN (ip_rip_v2_broadcast
,
1510 ip_rip_v2_broadcast_cmd
,
1511 "ip rip v2-broadcast",
1513 "Routing Information Protocol\n"
1514 "Send ip broadcast v2 update\n")
1516 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1517 struct rip_interface
*ri
;
1521 ri
->v2_broadcast
= 1;
1525 DEFUN (no_ip_rip_v2_broadcast
,
1526 no_ip_rip_v2_broadcast_cmd
,
1527 "no ip rip v2-broadcast",
1530 "Routing Information Protocol\n"
1531 "Send ip broadcast v2 update\n")
1533 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1534 struct rip_interface
*ri
;
1538 ri
->v2_broadcast
= 0;
1542 DEFUN (ip_rip_authentication_mode
,
1543 ip_rip_authentication_mode_cmd
,
1544 "ip rip authentication mode <md5|text> [auth-length <rfc|old-ripd>]",
1546 "Routing Information Protocol\n"
1547 "Authentication control\n"
1548 "Authentication mode\n"
1549 "Keyed message digest\n"
1550 "Clear text authentication\n"
1551 "MD5 authentication data length\n"
1553 "Old ripd compatible\n")
1555 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1556 char *cryptmode
= argv
[4]->text
;
1557 char *authlen
= (argc
> 5) ? argv
[6]->text
: NULL
;
1558 struct rip_interface
*ri
;
1563 if (strmatch ("md5", cryptmode
))
1564 auth_type
= RIP_AUTH_MD5
;
1566 assert (strmatch ("text", cryptmode
));
1567 auth_type
= RIP_AUTH_SIMPLE_PASSWORD
;
1570 ri
->auth_type
= auth_type
;
1574 if (auth_type
!= RIP_AUTH_MD5
)
1576 vty_out (vty
, "auth length argument only valid for md5%s", VTY_NEWLINE
);
1579 if (strmatch ("rfc", authlen
))
1580 ri
->md5_auth_len
= RIP_AUTH_MD5_SIZE
;
1583 assert (strmatch ("old-ripd", authlen
));
1584 ri
->md5_auth_len
= RIP_AUTH_MD5_COMPAT_SIZE
;
1591 DEFUN (no_ip_rip_authentication_mode
,
1592 no_ip_rip_authentication_mode_cmd
,
1593 "no ip rip authentication mode [<md5|text> [auth-length <rfc|old-ripd>]]",
1596 "Routing Information Protocol\n"
1597 "Authentication control\n"
1598 "Authentication mode\n"
1599 "Keyed message digest\n"
1600 "Clear text authentication\n"
1601 "MD5 authentication data length\n"
1603 "Old ripd compatible\n")
1605 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1606 struct rip_interface
*ri
;
1610 ri
->auth_type
= RIP_NO_AUTH
;
1611 ri
->md5_auth_len
= RIP_AUTH_MD5_COMPAT_SIZE
;
1616 DEFUN (ip_rip_authentication_string
,
1617 ip_rip_authentication_string_cmd
,
1618 "ip rip authentication string LINE",
1620 "Routing Information Protocol\n"
1621 "Authentication control\n"
1622 "Authentication string\n"
1623 "Authentication string\n")
1625 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1627 struct rip_interface
*ri
;
1631 if (strlen (argv
[idx_line
]->arg
) > 16)
1633 vty_out (vty
, "%% RIPv2 authentication string must be shorter than 16%s",
1640 vty_out (vty
, "%% key-chain configuration exists%s", VTY_NEWLINE
);
1645 free (ri
->auth_str
);
1647 ri
->auth_str
= strdup (argv
[idx_line
]->arg
);
1652 DEFUN (no_ip_rip_authentication_string
,
1653 no_ip_rip_authentication_string_cmd
,
1654 "no ip rip authentication string [LINE]",
1657 "Routing Information Protocol\n"
1658 "Authentication control\n"
1659 "Authentication string\n"
1660 "Authentication string\n")
1662 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1663 struct rip_interface
*ri
;
1668 free (ri
->auth_str
);
1670 ri
->auth_str
= NULL
;
1676 DEFUN (ip_rip_authentication_key_chain
,
1677 ip_rip_authentication_key_chain_cmd
,
1678 "ip rip authentication key-chain LINE",
1680 "Routing Information Protocol\n"
1681 "Authentication control\n"
1682 "Authentication key-chain\n"
1683 "name of key-chain\n")
1685 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1687 struct rip_interface
*ri
;
1693 vty_out (vty
, "%% authentication string configuration exists%s",
1699 free (ri
->key_chain
);
1701 ri
->key_chain
= strdup (argv
[idx_line
]->arg
);
1706 DEFUN (no_ip_rip_authentication_key_chain
,
1707 no_ip_rip_authentication_key_chain_cmd
,
1708 "no ip rip authentication key-chain [LINE]",
1711 "Routing Information Protocol\n"
1712 "Authentication control\n"
1713 "Authentication key-chain\n"
1714 "name of key-chain\n")
1716 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1717 struct rip_interface
*ri
;
1722 free (ri
->key_chain
);
1724 ri
->key_chain
= NULL
;
1730 /* CHANGED: ip rip split-horizon
1731 Cisco and Zebra's command is
1734 DEFUN (ip_rip_split_horizon
,
1735 ip_rip_split_horizon_cmd
,
1736 "ip rip split-horizon",
1738 "Routing Information Protocol\n"
1739 "Perform split horizon\n")
1741 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1742 struct rip_interface
*ri
;
1746 ri
->split_horizon
= RIP_SPLIT_HORIZON
;
1750 DEFUN (ip_rip_split_horizon_poisoned_reverse
,
1751 ip_rip_split_horizon_poisoned_reverse_cmd
,
1752 "ip rip split-horizon poisoned-reverse",
1754 "Routing Information Protocol\n"
1755 "Perform split horizon\n"
1756 "With poisoned-reverse\n")
1758 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1759 struct rip_interface
*ri
;
1763 ri
->split_horizon
= RIP_SPLIT_HORIZON_POISONED_REVERSE
;
1767 /* CHANGED: no ip rip split-horizon
1768 Cisco and Zebra's command is
1771 DEFUN (no_ip_rip_split_horizon
,
1772 no_ip_rip_split_horizon_cmd
,
1773 "no ip rip split-horizon",
1776 "Routing Information Protocol\n"
1777 "Perform split horizon\n")
1779 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1780 struct rip_interface
*ri
;
1784 ri
->split_horizon
= RIP_NO_SPLIT_HORIZON
;
1788 DEFUN (no_ip_rip_split_horizon_poisoned_reverse
,
1789 no_ip_rip_split_horizon_poisoned_reverse_cmd
,
1790 "no ip rip split-horizon poisoned-reverse",
1793 "Routing Information Protocol\n"
1794 "Perform split horizon\n"
1795 "With poisoned-reverse\n")
1797 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1798 struct rip_interface
*ri
;
1802 switch( ri
->split_horizon
)
1804 case RIP_SPLIT_HORIZON_POISONED_REVERSE
:
1805 ri
->split_horizon
= RIP_SPLIT_HORIZON
;
1813 DEFUN (rip_passive_interface
,
1814 rip_passive_interface_cmd
,
1815 "passive-interface <IFNAME|default>",
1816 "Suppress routing updates on an interface\n"
1818 "default for all interfaces\n")
1820 if (argv
[1]->type
== WORD_TKN
) { // user passed 'default'
1821 passive_default
= 1;
1822 rip_passive_nondefault_clean();
1825 if (passive_default
)
1826 return rip_passive_nondefault_unset (vty
, argv
[1]->arg
);
1828 return rip_passive_nondefault_set (vty
, argv
[1]->arg
);
1831 DEFUN (no_rip_passive_interface
,
1832 no_rip_passive_interface_cmd
,
1833 "no passive-interface <IFNAME|default>",
1835 "Suppress routing updates on an interface\n"
1837 "default for all interfaces\n")
1839 if (argv
[2]->type
== WORD_TKN
) {
1840 passive_default
= 0;
1841 rip_passive_nondefault_clean();
1844 if (passive_default
)
1845 return rip_passive_nondefault_set (vty
, argv
[2]->arg
);
1847 return rip_passive_nondefault_unset (vty
, argv
[2]->arg
);
1850 /* Write rip configuration of each interface. */
1852 rip_interface_config_write (struct vty
*vty
)
1854 struct listnode
*node
;
1855 struct interface
*ifp
;
1857 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), node
, ifp
))
1859 struct rip_interface
*ri
;
1861 if (ifp
->ifindex
== IFINDEX_DELETED
)
1866 /* Do not display the interface if there is no
1867 * configuration about it.
1870 (ri
->split_horizon
== ri
->split_horizon_default
) &&
1871 (ri
->ri_send
== RI_RIP_UNSPEC
) &&
1872 (ri
->ri_receive
== RI_RIP_UNSPEC
) &&
1873 (ri
->auth_type
!= RIP_AUTH_MD5
) &&
1874 (!ri
->v2_broadcast
) &&
1875 (ri
->md5_auth_len
!= RIP_AUTH_MD5_SIZE
) &&
1880 vty_out (vty
, "interface %s%s", ifp
->name
,
1884 vty_out (vty
, " description %s%s", ifp
->desc
,
1887 /* Split horizon. */
1888 if (ri
->split_horizon
!= ri
->split_horizon_default
)
1890 switch (ri
->split_horizon
) {
1891 case RIP_SPLIT_HORIZON
:
1892 vty_out (vty
, " ip rip split-horizon%s", VTY_NEWLINE
);
1894 case RIP_SPLIT_HORIZON_POISONED_REVERSE
:
1895 vty_out (vty
, " ip rip split-horizon poisoned-reverse%s",
1898 case RIP_NO_SPLIT_HORIZON
:
1900 vty_out (vty
, " no ip rip split-horizon%s", VTY_NEWLINE
);
1905 /* RIP version setting. */
1906 if (ri
->ri_send
!= RI_RIP_UNSPEC
)
1907 vty_out (vty
, " ip rip send version %s%s",
1908 lookup (ri_version_msg
, ri
->ri_send
),
1911 if (ri
->ri_receive
!= RI_RIP_UNSPEC
)
1912 vty_out (vty
, " ip rip receive version %s%s",
1913 lookup (ri_version_msg
, ri
->ri_receive
),
1916 if (ri
->v2_broadcast
)
1917 vty_out (vty
, " ip rip v2-broadcast%s", VTY_NEWLINE
);
1919 /* RIP authentication. */
1920 if (ri
->auth_type
== RIP_AUTH_SIMPLE_PASSWORD
)
1921 vty_out (vty
, " ip rip authentication mode text%s", VTY_NEWLINE
);
1923 if (ri
->auth_type
== RIP_AUTH_MD5
)
1925 vty_out (vty
, " ip rip authentication mode md5");
1926 if (ri
->md5_auth_len
== RIP_AUTH_MD5_COMPAT_SIZE
)
1927 vty_out (vty
, " auth-length old-ripd");
1929 vty_out (vty
, " auth-length rfc");
1930 vty_out (vty
, "%s", VTY_NEWLINE
);
1934 vty_out (vty
, " ip rip authentication string %s%s",
1935 ri
->auth_str
, VTY_NEWLINE
);
1938 vty_out (vty
, " ip rip authentication key-chain %s%s",
1939 ri
->key_chain
, VTY_NEWLINE
);
1941 vty_out (vty
, "!%s", VTY_NEWLINE
);
1947 config_write_rip_network (struct vty
*vty
, int config_mode
)
1951 struct route_node
*node
;
1953 /* Network type RIP enable interface statement. */
1954 for (node
= route_top (rip_enable_network
); node
; node
= route_next (node
))
1956 vty_out (vty
, "%s%s/%d%s",
1957 config_mode
? " network " : " ",
1958 inet_ntoa (node
->p
.u
.prefix4
),
1962 /* Interface name RIP enable statement. */
1963 for (i
= 0; i
< vector_active (rip_enable_interface
); i
++)
1964 if ((ifname
= vector_slot (rip_enable_interface
, i
)) != NULL
)
1965 vty_out (vty
, "%s%s%s",
1966 config_mode
? " network " : " ",
1970 /* RIP neighbors listing. */
1971 for (node
= route_top (rip
->neighbor
); node
; node
= route_next (node
))
1973 vty_out (vty
, "%s%s%s",
1974 config_mode
? " neighbor " : " ",
1975 inet_ntoa (node
->p
.u
.prefix4
),
1978 /* RIP passive interface listing. */
1980 if (passive_default
)
1981 vty_out (vty
, " passive-interface default%s", VTY_NEWLINE
);
1982 for (i
= 0; i
< vector_active (Vrip_passive_nondefault
); i
++)
1983 if ((ifname
= vector_slot (Vrip_passive_nondefault
, i
)) != NULL
)
1984 vty_out (vty
, " %spassive-interface %s%s",
1985 (passive_default
? "no " : ""), ifname
, VTY_NEWLINE
);
1991 static struct cmd_node interface_node
=
1998 /* Called when interface structure allocated. */
2000 rip_interface_new_hook (struct interface
*ifp
)
2002 ifp
->info
= rip_interface_new ();
2006 /* Called when interface structure deleted. */
2008 rip_interface_delete_hook (struct interface
*ifp
)
2010 XFREE (MTYPE_RIP_INTERFACE
, ifp
->info
);
2015 /* Allocate and initialize interface vector. */
2019 /* Default initial size of interface vector. */
2020 if_add_hook (IF_NEW_HOOK
, rip_interface_new_hook
);
2021 if_add_hook (IF_DELETE_HOOK
, rip_interface_delete_hook
);
2023 /* RIP network init. */
2024 rip_enable_interface
= vector_init (1);
2025 rip_enable_network
= route_table_init ();
2027 /* RIP passive interface. */
2028 Vrip_passive_nondefault
= vector_init (1);
2030 /* Install interface node. */
2031 install_node (&interface_node
, rip_interface_config_write
);
2034 /* Install commands. */
2035 install_element (RIP_NODE
, &rip_network_cmd
);
2036 install_element (RIP_NODE
, &no_rip_network_cmd
);
2037 install_element (RIP_NODE
, &rip_neighbor_cmd
);
2038 install_element (RIP_NODE
, &no_rip_neighbor_cmd
);
2040 install_element (RIP_NODE
, &rip_passive_interface_cmd
);
2041 install_element (RIP_NODE
, &no_rip_passive_interface_cmd
);
2043 install_element (INTERFACE_NODE
, &ip_rip_send_version_cmd
);
2044 install_element (INTERFACE_NODE
, &ip_rip_send_version_1_cmd
);
2045 install_element (INTERFACE_NODE
, &ip_rip_send_version_2_cmd
);
2046 install_element (INTERFACE_NODE
, &no_ip_rip_send_version_cmd
);
2048 install_element (INTERFACE_NODE
, &ip_rip_receive_version_cmd
);
2049 install_element (INTERFACE_NODE
, &ip_rip_receive_version_1_cmd
);
2050 install_element (INTERFACE_NODE
, &ip_rip_receive_version_2_cmd
);
2051 install_element (INTERFACE_NODE
, &no_ip_rip_receive_version_cmd
);
2053 install_element (INTERFACE_NODE
, &ip_rip_v2_broadcast_cmd
);
2054 install_element (INTERFACE_NODE
, &no_ip_rip_v2_broadcast_cmd
);
2056 install_element (INTERFACE_NODE
, &ip_rip_authentication_mode_cmd
);
2057 install_element (INTERFACE_NODE
, &no_ip_rip_authentication_mode_cmd
);
2059 install_element (INTERFACE_NODE
, &ip_rip_authentication_key_chain_cmd
);
2060 install_element (INTERFACE_NODE
, &no_ip_rip_authentication_key_chain_cmd
);
2062 install_element (INTERFACE_NODE
, &ip_rip_authentication_string_cmd
);
2063 install_element (INTERFACE_NODE
, &no_ip_rip_authentication_string_cmd
);
2065 install_element (INTERFACE_NODE
, &ip_rip_split_horizon_cmd
);
2066 install_element (INTERFACE_NODE
, &ip_rip_split_horizon_poisoned_reverse_cmd
);
2067 install_element (INTERFACE_NODE
, &no_ip_rip_split_horizon_cmd
);
2068 install_element (INTERFACE_NODE
, &no_ip_rip_split_horizon_poisoned_reverse_cmd
);