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"},
64 extern struct zebra_privs_t ripd_privs
;
66 /* RIP enabled network vector. */
67 vector rip_enable_interface
;
69 /* RIP enabled interface table. */
70 struct route_table
*rip_enable_network
;
72 /* Vector to store passive-interface name. */
73 static int passive_default
; /* are we in passive-interface default mode? */
74 vector Vrip_passive_nondefault
;
76 /* Join to the RIP version 2 multicast group. */
78 ipv4_multicast_join (int sock
,
85 ret
= setsockopt_ipv4_multicast (sock
,
92 zlog_info("can't setsockopt IP_ADD_MEMBERSHIP %s", safe_strerror(errno
));
97 /* Leave from the RIP version 2 multicast group. */
99 ipv4_multicast_leave (int sock
,
100 struct in_addr group
,
106 ret
= setsockopt_ipv4_multicast (sock
,
113 zlog_info("can't setsockopt IP_DROP_MEMBERSHIP");
118 static void rip_interface_reset (struct rip_interface
*);
120 /* Allocate new RIP's interface configuration. */
121 static struct rip_interface
*
122 rip_interface_new (void)
124 struct rip_interface
*ri
;
126 ri
= XCALLOC (MTYPE_RIP_INTERFACE
, sizeof (struct rip_interface
));
128 rip_interface_reset (ri
);
134 rip_interface_multicast_set (int sock
, struct connected
*connected
)
138 assert (connected
!= NULL
);
140 addr
= CONNECTED_ID(connected
)->u
.prefix4
;
142 if (setsockopt_ipv4_multicast_if (sock
, addr
, connected
->ifp
->ifindex
) < 0)
144 zlog_warn ("Can't setsockopt IP_MULTICAST_IF on fd %d to "
145 "ifindex %d for interface %s",
146 sock
, connected
->ifp
->ifindex
,
147 connected
->ifp
->name
);
153 /* Send RIP request packet to specified interface. */
155 rip_request_interface_send (struct interface
*ifp
, u_char version
)
157 struct sockaddr_in to
;
159 /* RIPv2 support multicast. */
160 if (version
== RIPv2
&& if_is_multicast (ifp
))
163 if (IS_RIP_DEBUG_EVENT
)
164 zlog_debug ("multicast request on %s", ifp
->name
);
166 rip_request_send (NULL
, ifp
, version
, NULL
);
170 /* RIPv1 and non multicast interface. */
171 if (if_is_pointopoint (ifp
) || if_is_broadcast (ifp
))
173 struct listnode
*cnode
, *cnnode
;
174 struct connected
*connected
;
176 if (IS_RIP_DEBUG_EVENT
)
177 zlog_debug ("broadcast request to %s", ifp
->name
);
179 for (ALL_LIST_ELEMENTS (ifp
->connected
, cnode
, cnnode
, connected
))
181 if (connected
->address
->family
== AF_INET
)
183 memset (&to
, 0, sizeof (struct sockaddr_in
));
184 to
.sin_port
= htons (RIP_PORT_DEFAULT
);
185 if (connected
->destination
)
186 /* use specified broadcast or peer destination addr */
187 to
.sin_addr
= connected
->destination
->u
.prefix4
;
188 else if (connected
->address
->prefixlen
< IPV4_MAX_PREFIXLEN
)
189 /* calculate the appropriate broadcast address */
191 ipv4_broadcast_addr(connected
->address
->u
.prefix4
.s_addr
,
192 connected
->address
->prefixlen
);
194 /* do not know where to send the packet */
197 if (IS_RIP_DEBUG_EVENT
)
198 zlog_debug ("SEND request to %s", inet_ntoa (to
.sin_addr
));
200 rip_request_send (&to
, ifp
, version
, connected
);
206 /* This will be executed when interface goes up. */
208 rip_request_interface (struct interface
*ifp
)
210 struct rip_interface
*ri
;
212 /* In default ripd doesn't send RIP_REQUEST to the loopback interface. */
213 if (if_is_loopback (ifp
))
216 /* If interface is down, don't send RIP packet. */
217 if (! if_is_operative (ifp
))
220 /* Fetch RIP interface information. */
224 /* If there is no version configuration in the interface,
225 use rip's version setting. */
227 int vsend
= ((ri
->ri_send
== RI_RIP_UNSPEC
) ?
228 rip
->version_send
: ri
->ri_send
);
230 rip_request_interface_send (ifp
, RIPv1
);
232 rip_request_interface_send (ifp
, RIPv2
);
237 /* Send RIP request to the neighbor. */
239 rip_request_neighbor (struct in_addr addr
)
241 struct sockaddr_in to
;
243 memset (&to
, 0, sizeof (struct sockaddr_in
));
244 to
.sin_port
= htons (RIP_PORT_DEFAULT
);
247 rip_request_send (&to
, NULL
, rip
->version_send
, NULL
);
250 /* Request routes at all interfaces. */
252 rip_request_neighbor_all (void)
254 struct route_node
*rp
;
259 if (IS_RIP_DEBUG_EVENT
)
260 zlog_debug ("request to the all neighbor");
262 /* Send request to all neighbor. */
263 for (rp
= route_top (rip
->neighbor
); rp
; rp
= route_next (rp
))
265 rip_request_neighbor (rp
->p
.u
.prefix4
);
269 /* Multicast packet receive socket. */
271 rip_multicast_join (struct interface
*ifp
, int sock
)
273 struct listnode
*cnode
;
274 struct connected
*ifc
;
276 if (if_is_operative (ifp
) && if_is_multicast (ifp
))
278 if (IS_RIP_DEBUG_EVENT
)
279 zlog_debug ("multicast join at %s", ifp
->name
);
281 for (ALL_LIST_ELEMENTS_RO (ifp
->connected
, cnode
, ifc
))
283 struct prefix_ipv4
*p
;
284 struct in_addr group
;
286 p
= (struct prefix_ipv4
*) ifc
->address
;
288 if (p
->family
!= AF_INET
)
291 group
.s_addr
= htonl (INADDR_RIP_GROUP
);
292 if (ipv4_multicast_join (sock
, group
, p
->prefix
, ifp
->ifindex
) < 0)
301 /* Leave from multicast group. */
303 rip_multicast_leave (struct interface
*ifp
, int sock
)
305 struct listnode
*cnode
;
306 struct connected
*connected
;
308 if (if_is_up (ifp
) && if_is_multicast (ifp
))
310 if (IS_RIP_DEBUG_EVENT
)
311 zlog_debug ("multicast leave from %s", ifp
->name
);
313 for (ALL_LIST_ELEMENTS_RO (ifp
->connected
, cnode
, connected
))
315 struct prefix_ipv4
*p
;
316 struct in_addr group
;
318 p
= (struct prefix_ipv4
*) connected
->address
;
320 if (p
->family
!= AF_INET
)
323 group
.s_addr
= htonl (INADDR_RIP_GROUP
);
324 if (ipv4_multicast_leave (sock
, group
, p
->prefix
, ifp
->ifindex
) == 0)
330 /* Is there and address on interface that I could use ? */
332 rip_if_ipv4_address_check (struct interface
*ifp
)
335 struct connected
*connected
;
338 for (ALL_LIST_ELEMENTS_RO (ifp
->connected
, nn
, connected
))
342 p
= connected
->address
;
344 if (p
->family
== AF_INET
)
354 /* Does this address belongs to me ? */
356 if_check_address (struct in_addr addr
)
358 struct listnode
*node
;
359 struct interface
*ifp
;
361 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), node
, ifp
))
363 struct listnode
*cnode
;
364 struct connected
*connected
;
366 for (ALL_LIST_ELEMENTS_RO (ifp
->connected
, cnode
, connected
))
368 struct prefix_ipv4
*p
;
370 p
= (struct prefix_ipv4
*) connected
->address
;
372 if (p
->family
!= AF_INET
)
375 if (IPV4_ADDR_CMP (&p
->prefix
, &addr
) == 0)
382 /* Inteface link down message processing. */
384 rip_interface_down (int command
, struct zclient
*zclient
, zebra_size_t length
,
387 struct interface
*ifp
;
392 /* zebra_interface_state_read() updates interface structure in
394 ifp
= zebra_interface_state_read (s
, vrf_id
);
401 if (IS_RIP_DEBUG_ZEBRA
)
402 zlog_debug ("interface %s index %d flags %llx metric %d mtu %d is down",
403 ifp
->name
, ifp
->ifindex
, (unsigned long long)ifp
->flags
,
404 ifp
->metric
, ifp
->mtu
);
409 /* Inteface link up message processing */
411 rip_interface_up (int command
, struct zclient
*zclient
, zebra_size_t length
,
414 struct interface
*ifp
;
416 /* zebra_interface_state_read () updates interface structure in
418 ifp
= zebra_interface_state_read (zclient
->ibuf
, vrf_id
);
423 if (IS_RIP_DEBUG_ZEBRA
)
424 zlog_debug ("interface %s index %d flags %#llx metric %d mtu %d is up",
425 ifp
->name
, ifp
->ifindex
, (unsigned long long) ifp
->flags
,
426 ifp
->metric
, ifp
->mtu
);
428 /* Check if this interface is RIP enabled or not.*/
429 rip_enable_apply (ifp
);
431 /* Check for a passive interface */
432 rip_passive_interface_apply (ifp
);
434 /* Apply distribute list to the all interface. */
435 rip_distribute_update_interface (ifp
);
440 /* Inteface addition message from zebra. */
442 rip_interface_add (int command
, struct zclient
*zclient
, zebra_size_t length
,
445 struct interface
*ifp
;
447 ifp
= zebra_interface_add_read (zclient
->ibuf
, vrf_id
);
449 if (IS_RIP_DEBUG_ZEBRA
)
450 zlog_debug ("interface add %s index %d flags %#llx metric %d mtu %d",
451 ifp
->name
, ifp
->ifindex
, (unsigned long long) ifp
->flags
,
452 ifp
->metric
, ifp
->mtu
);
454 /* Check if this interface is RIP enabled or not.*/
455 rip_enable_apply (ifp
);
457 /* Check for a passive interface */
458 rip_passive_interface_apply (ifp
);
460 /* Apply distribute list to the all interface. */
461 rip_distribute_update_interface (ifp
);
463 /* rip_request_neighbor_all (); */
465 /* Check interface routemap. */
466 rip_if_rmap_update_interface (ifp
);
472 rip_interface_delete (int command
, struct zclient
*zclient
,
473 zebra_size_t length
, vrf_id_t vrf_id
)
475 struct interface
*ifp
;
480 /* zebra_interface_state_read() updates interface structure in iflist */
481 ifp
= zebra_interface_state_read (s
, vrf_id
);
486 if (if_is_up (ifp
)) {
490 zlog_info("interface delete %s index %d flags %#llx metric %d mtu %d",
491 ifp
->name
, ifp
->ifindex
, (unsigned long long) ifp
->flags
,
492 ifp
->metric
, ifp
->mtu
);
494 /* To support pseudo interface do not free interface structure. */
495 /* if_delete(ifp); */
496 ifp
->ifindex
= IFINDEX_DELETED
;
502 rip_interface_clean (struct rip_interface
*ri
)
504 ri
->enable_network
= 0;
505 ri
->enable_interface
= 0;
510 thread_cancel (ri
->t_wakeup
);
516 rip_interfaces_clean (void)
518 struct listnode
*node
;
519 struct interface
*ifp
;
521 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), node
, ifp
))
522 rip_interface_clean (ifp
->info
);
526 rip_interface_reset (struct rip_interface
*ri
)
528 /* Default authentication type is simple password for Cisco
530 ri
->auth_type
= RIP_NO_AUTH
;
531 ri
->md5_auth_len
= RIP_AUTH_MD5_COMPAT_SIZE
;
533 /* Set default split-horizon behavior. If the interface is Frame
534 Relay or SMDS is enabled, the default value for split-horizon is
535 off. But currently Zebra does detect Frame Relay or SMDS
536 interface. So all interface is set to split horizon. */
537 ri
->split_horizon_default
= RIP_SPLIT_HORIZON
;
538 ri
->split_horizon
= ri
->split_horizon_default
;
540 ri
->ri_send
= RI_RIP_UNSPEC
;
541 ri
->ri_receive
= RI_RIP_UNSPEC
;
543 ri
->v2_broadcast
= 0;
552 free (ri
->key_chain
);
553 ri
->key_chain
= NULL
;
556 ri
->list
[RIP_FILTER_IN
] = NULL
;
557 ri
->list
[RIP_FILTER_OUT
] = NULL
;
559 ri
->prefix
[RIP_FILTER_IN
] = NULL
;
560 ri
->prefix
[RIP_FILTER_OUT
] = NULL
;
562 ri
->recv_badpackets
= 0;
563 ri
->recv_badroutes
= 0;
564 ri
->sent_updates
= 0;
568 rip_interface_clean (ri
);
572 rip_interfaces_reset (void)
574 struct listnode
*node
;
575 struct interface
*ifp
;
577 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), node
, ifp
))
578 rip_interface_reset (ifp
->info
);
582 rip_if_down(struct interface
*ifp
)
584 struct route_node
*rp
;
585 struct rip_info
*rinfo
;
586 struct rip_interface
*ri
= NULL
;
587 struct list
*list
= NULL
;
588 struct listnode
*listnode
= NULL
, *nextnode
= NULL
;
591 for (rp
= route_top (rip
->table
); rp
; rp
= route_next (rp
))
592 if ((list
= rp
->info
) != NULL
)
593 for (ALL_LIST_ELEMENTS (list
, listnode
, nextnode
, rinfo
))
594 if (rinfo
->ifindex
== ifp
->ifindex
)
595 rip_ecmp_delete (rinfo
);
601 if (IS_RIP_DEBUG_EVENT
)
602 zlog_debug ("turn off %s", ifp
->name
);
604 /* Leave from multicast group. */
605 rip_multicast_leave (ifp
, rip
->sock
);
614 /* Needed for stop RIP process. */
618 struct interface
*ifp
;
619 struct listnode
*node
, *nnode
;
621 for (ALL_LIST_ELEMENTS (vrf_iflist (VRF_DEFAULT
), node
, nnode
, ifp
))
626 rip_apply_address_add (struct connected
*ifc
)
628 struct prefix_ipv4 address
;
634 if (! if_is_up(ifc
->ifp
))
639 memset (&address
, 0, sizeof (address
));
640 address
.family
= p
->family
;
641 address
.prefix
= p
->u
.prefix4
;
642 address
.prefixlen
= p
->prefixlen
;
643 apply_mask_ipv4(&address
);
645 /* Check if this interface is RIP enabled or not
646 or Check if this address's prefix is RIP enabled */
647 if ((rip_enable_if_lookup(ifc
->ifp
->name
) >= 0) ||
648 (rip_enable_network_lookup2(ifc
) >= 0))
649 rip_redistribute_add(ZEBRA_ROUTE_CONNECT
, RIP_ROUTE_INTERFACE
,
650 &address
, ifc
->ifp
->ifindex
, NULL
, 0, 0, 0);
655 rip_interface_address_add (int command
, struct zclient
*zclient
,
656 zebra_size_t length
, vrf_id_t vrf_id
)
658 struct connected
*ifc
;
661 ifc
= zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_ADD
,
662 zclient
->ibuf
, vrf_id
);
669 if (p
->family
== AF_INET
)
671 if (IS_RIP_DEBUG_ZEBRA
)
672 zlog_debug ("connected address %s/%d is added",
673 inet_ntoa (p
->u
.prefix4
), p
->prefixlen
);
675 rip_enable_apply(ifc
->ifp
);
676 /* Check if this prefix needs to be redistributed */
677 rip_apply_address_add(ifc
);
679 hook_call(rip_ifaddr_add
, ifc
);
686 rip_apply_address_del (struct connected
*ifc
) {
687 struct prefix_ipv4 address
;
693 if (! if_is_up(ifc
->ifp
))
698 memset (&address
, 0, sizeof (address
));
699 address
.family
= p
->family
;
700 address
.prefix
= p
->u
.prefix4
;
701 address
.prefixlen
= p
->prefixlen
;
702 apply_mask_ipv4(&address
);
704 rip_redistribute_delete(ZEBRA_ROUTE_CONNECT
, RIP_ROUTE_INTERFACE
,
705 &address
, ifc
->ifp
->ifindex
);
709 rip_interface_address_delete (int command
, struct zclient
*zclient
,
710 zebra_size_t length
, vrf_id_t vrf_id
)
712 struct connected
*ifc
;
715 ifc
= zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_DELETE
,
716 zclient
->ibuf
, vrf_id
);
721 if (p
->family
== AF_INET
)
723 if (IS_RIP_DEBUG_ZEBRA
)
724 zlog_debug ("connected address %s/%d is deleted",
725 inet_ntoa (p
->u
.prefix4
), p
->prefixlen
);
727 hook_call(rip_ifaddr_del
, ifc
);
729 /* Chech wether this prefix needs to be removed */
730 rip_apply_address_del(ifc
);
734 connected_free (ifc
);
741 /* Check interface is enabled by network statement. */
742 /* Check wether the interface has at least a connected prefix that
743 * is within the ripng_enable_network table. */
745 rip_enable_network_lookup_if (struct interface
*ifp
)
747 struct listnode
*node
, *nnode
;
748 struct connected
*connected
;
749 struct prefix_ipv4 address
;
751 for (ALL_LIST_ELEMENTS (ifp
->connected
, node
, nnode
, connected
))
754 struct route_node
*node
;
756 p
= connected
->address
;
758 if (p
->family
== AF_INET
)
760 address
.family
= AF_INET
;
761 address
.prefix
= p
->u
.prefix4
;
762 address
.prefixlen
= IPV4_MAX_BITLEN
;
764 node
= route_node_match (rip_enable_network
,
765 (struct prefix
*)&address
);
768 route_unlock_node (node
);
776 /* Check wether connected is within the ripng_enable_network table. */
778 rip_enable_network_lookup2 (struct connected
*connected
)
780 struct prefix_ipv4 address
;
783 p
= connected
->address
;
785 if (p
->family
== AF_INET
) {
786 struct route_node
*node
;
788 address
.family
= p
->family
;
789 address
.prefix
= p
->u
.prefix4
;
790 address
.prefixlen
= IPV4_MAX_BITLEN
;
792 /* LPM on p->family, p->u.prefix4/IPV4_MAX_BITLEN within rip_enable_network */
793 node
= route_node_match (rip_enable_network
,
794 (struct prefix
*)&address
);
797 route_unlock_node (node
);
804 /* Add RIP enable network. */
806 rip_enable_network_add (struct prefix
*p
)
808 struct route_node
*node
;
810 node
= route_node_get (rip_enable_network
, p
);
814 route_unlock_node (node
);
818 node
->info
= (void *)1;
820 /* XXX: One should find a better solution than a generic one */
821 rip_enable_apply_all();
826 /* Delete RIP enable network. */
828 rip_enable_network_delete (struct prefix
*p
)
830 struct route_node
*node
;
832 node
= route_node_lookup (rip_enable_network
, p
);
837 /* Unlock info lock. */
838 route_unlock_node (node
);
840 /* Unlock lookup lock. */
841 route_unlock_node (node
);
843 /* XXX: One should find a better solution than a generic one */
844 rip_enable_apply_all ();
851 /* Check interface is enabled by ifname statement. */
853 rip_enable_if_lookup (const char *ifname
)
858 for (i
= 0; i
< vector_active (rip_enable_interface
); i
++)
859 if ((str
= vector_slot (rip_enable_interface
, i
)) != NULL
)
860 if (strcmp (str
, ifname
) == 0)
865 /* Add interface to rip_enable_if. */
867 rip_enable_if_add (const char *ifname
)
871 ret
= rip_enable_if_lookup (ifname
);
875 vector_set (rip_enable_interface
, strdup (ifname
));
877 rip_enable_apply_all(); /* TODOVJ */
882 /* Delete interface from rip_enable_if. */
884 rip_enable_if_delete (const char *ifname
)
889 index
= rip_enable_if_lookup (ifname
);
893 str
= vector_slot (rip_enable_interface
, index
);
895 vector_unset (rip_enable_interface
, index
);
897 rip_enable_apply_all(); /* TODOVJ */
902 /* Join to multicast group and send request to the interface. */
904 rip_interface_wakeup (struct thread
*t
)
906 struct interface
*ifp
;
907 struct rip_interface
*ri
;
910 ifp
= THREAD_ARG (t
);
915 /* Join to multicast group. */
916 if (rip_multicast_join (ifp
, rip
->sock
) < 0)
918 zlog_err ("multicast join failed, interface %s not running", ifp
->name
);
922 /* Set running flag. */
925 /* Send RIP request to the interface. */
926 rip_request_interface (ifp
);
932 rip_connect_set (struct interface
*ifp
, int set
)
934 struct listnode
*node
, *nnode
;
935 struct connected
*connected
;
936 struct prefix_ipv4 address
;
938 for (ALL_LIST_ELEMENTS (ifp
->connected
, node
, nnode
, connected
))
941 p
= connected
->address
;
943 if (p
->family
!= AF_INET
)
946 address
.family
= AF_INET
;
947 address
.prefix
= p
->u
.prefix4
;
948 address
.prefixlen
= p
->prefixlen
;
949 apply_mask_ipv4 (&address
);
952 /* Check once more wether this prefix is within a "network IF_OR_PREF" one */
953 if ((rip_enable_if_lookup(connected
->ifp
->name
) >= 0) ||
954 (rip_enable_network_lookup2(connected
) >= 0))
955 rip_redistribute_add (ZEBRA_ROUTE_CONNECT
, RIP_ROUTE_INTERFACE
,
956 &address
, connected
->ifp
->ifindex
,
960 rip_redistribute_delete (ZEBRA_ROUTE_CONNECT
, RIP_ROUTE_INTERFACE
,
961 &address
, connected
->ifp
->ifindex
);
962 if (rip_redistribute_check (ZEBRA_ROUTE_CONNECT
))
963 rip_redistribute_add (ZEBRA_ROUTE_CONNECT
, RIP_ROUTE_REDISTRIBUTE
,
964 &address
, connected
->ifp
->ifindex
,
970 /* Update interface status. */
972 rip_enable_apply (struct interface
*ifp
)
975 struct rip_interface
*ri
= NULL
;
977 /* Check interface. */
978 if (! if_is_operative (ifp
))
983 /* Check network configuration. */
984 ret
= rip_enable_network_lookup_if (ifp
);
986 /* If the interface is matched. */
988 ri
->enable_network
= 1;
990 ri
->enable_network
= 0;
992 /* Check interface name configuration. */
993 ret
= rip_enable_if_lookup (ifp
->name
);
995 ri
->enable_interface
= 1;
997 ri
->enable_interface
= 0;
999 /* any interface MUST have an IPv4 address */
1000 if ( ! rip_if_ipv4_address_check (ifp
) )
1002 ri
->enable_network
= 0;
1003 ri
->enable_interface
= 0;
1006 /* Update running status of the interface. */
1007 if (ri
->enable_network
|| ri
->enable_interface
)
1010 if (IS_RIP_DEBUG_EVENT
)
1011 zlog_debug ("turn on %s", ifp
->name
);
1013 /* Add interface wake up thread. */
1014 thread_add_timer(master
, rip_interface_wakeup
, ifp
, 1,
1016 rip_connect_set (ifp
, 1);
1023 /* Might as well clean up the route table as well
1024 * rip_if_down sets to 0 ri->running, and displays "turn off %s"
1028 rip_connect_set (ifp
, 0);
1033 /* Apply network configuration to all interface. */
1035 rip_enable_apply_all ()
1037 struct interface
*ifp
;
1038 struct listnode
*node
, *nnode
;
1040 /* Check each interface. */
1041 for (ALL_LIST_ELEMENTS (vrf_iflist (VRF_DEFAULT
), node
, nnode
, ifp
))
1042 rip_enable_apply (ifp
);
1046 rip_neighbor_lookup (struct sockaddr_in
*from
)
1048 struct prefix_ipv4 p
;
1049 struct route_node
*node
;
1051 memset (&p
, 0, sizeof (struct prefix_ipv4
));
1053 p
.prefix
= from
->sin_addr
;
1054 p
.prefixlen
= IPV4_MAX_BITLEN
;
1056 node
= route_node_lookup (rip
->neighbor
, (struct prefix
*) &p
);
1059 route_unlock_node (node
);
1065 /* Add new RIP neighbor to the neighbor tree. */
1067 rip_neighbor_add (struct prefix_ipv4
*p
)
1069 struct route_node
*node
;
1071 node
= route_node_get (rip
->neighbor
, (struct prefix
*) p
);
1076 node
->info
= rip
->neighbor
;
1081 /* Delete RIP neighbor from the neighbor tree. */
1083 rip_neighbor_delete (struct prefix_ipv4
*p
)
1085 struct route_node
*node
;
1087 /* Lock for look up. */
1088 node
= route_node_lookup (rip
->neighbor
, (struct prefix
*) p
);
1094 /* Unlock lookup lock. */
1095 route_unlock_node (node
);
1097 /* Unlock real neighbor information lock. */
1098 route_unlock_node (node
);
1103 /* Clear all network and neighbor configuration. */
1105 rip_clean_network ()
1109 struct route_node
*rn
;
1111 /* rip_enable_network. */
1112 for (rn
= route_top (rip_enable_network
); rn
; rn
= route_next (rn
))
1116 route_unlock_node (rn
);
1119 /* rip_enable_interface. */
1120 for (i
= 0; i
< vector_active (rip_enable_interface
); i
++)
1121 if ((str
= vector_slot (rip_enable_interface
, i
)) != NULL
)
1124 vector_slot (rip_enable_interface
, i
) = NULL
;
1128 /* Utility function for looking up passive interface settings. */
1130 rip_passive_nondefault_lookup (const char *ifname
)
1135 for (i
= 0; i
< vector_active (Vrip_passive_nondefault
); i
++)
1136 if ((str
= vector_slot (Vrip_passive_nondefault
, i
)) != NULL
)
1137 if (strcmp (str
, ifname
) == 0)
1143 rip_passive_interface_apply (struct interface
*ifp
)
1145 struct rip_interface
*ri
;
1149 ri
->passive
= ((rip_passive_nondefault_lookup (ifp
->name
) < 0) ?
1150 passive_default
: !passive_default
);
1152 if (IS_RIP_DEBUG_ZEBRA
)
1153 zlog_debug ("interface %s: passive = %d",ifp
->name
,ri
->passive
);
1157 rip_passive_interface_apply_all (void)
1159 struct interface
*ifp
;
1160 struct listnode
*node
, *nnode
;
1162 for (ALL_LIST_ELEMENTS (vrf_iflist (VRF_DEFAULT
), node
, nnode
, ifp
))
1163 rip_passive_interface_apply (ifp
);
1166 /* Passive interface. */
1168 rip_passive_nondefault_set (struct vty
*vty
, const char *ifname
)
1170 if (rip_passive_nondefault_lookup (ifname
) >= 0)
1173 vector_set (Vrip_passive_nondefault
, strdup (ifname
));
1175 rip_passive_interface_apply_all ();
1181 rip_passive_nondefault_unset (struct vty
*vty
, const char *ifname
)
1186 i
= rip_passive_nondefault_lookup (ifname
);
1190 str
= vector_slot (Vrip_passive_nondefault
, i
);
1192 vector_unset (Vrip_passive_nondefault
, i
);
1194 rip_passive_interface_apply_all ();
1199 /* Free all configured RIP passive-interface settings. */
1201 rip_passive_nondefault_clean (void)
1206 for (i
= 0; i
< vector_active (Vrip_passive_nondefault
); i
++)
1207 if ((str
= vector_slot (Vrip_passive_nondefault
, i
)) != NULL
)
1210 vector_slot (Vrip_passive_nondefault
, i
) = NULL
;
1212 rip_passive_interface_apply_all ();
1215 /* RIP enable network or interface configuration. */
1218 "network <A.B.C.D/M|WORD>",
1219 "Enable routing on an IP network\n"
1220 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1223 int idx_ipv4_word
= 1;
1225 struct prefix_ipv4 p
;
1227 ret
= str2prefix_ipv4 (argv
[idx_ipv4_word
]->arg
, &p
);
1230 ret
= rip_enable_network_add ((struct prefix
*) &p
);
1232 ret
= rip_enable_if_add (argv
[idx_ipv4_word
]->arg
);
1236 vty_outln (vty
, "There is a same network configuration %s",
1237 argv
[idx_ipv4_word
]->arg
);
1244 /* RIP enable network or interface configuration. */
1245 DEFUN (no_rip_network
,
1247 "no network <A.B.C.D/M|WORD>",
1249 "Enable routing on an IP network\n"
1250 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1253 int idx_ipv4_word
= 2;
1255 struct prefix_ipv4 p
;
1257 ret
= str2prefix_ipv4 (argv
[idx_ipv4_word
]->arg
, &p
);
1260 ret
= rip_enable_network_delete ((struct prefix
*) &p
);
1262 ret
= rip_enable_if_delete (argv
[idx_ipv4_word
]->arg
);
1266 vty_outln (vty
, "Can't find network configuration %s",
1267 argv
[idx_ipv4_word
]->arg
);
1274 /* RIP neighbor configuration set. */
1275 DEFUN (rip_neighbor
,
1278 "Specify a neighbor router\n"
1279 "Neighbor address\n")
1283 struct prefix_ipv4 p
;
1285 ret
= str2prefix_ipv4 (argv
[idx_ipv4
]->arg
, &p
);
1289 vty_outln (vty
, "Please specify address by A.B.C.D");
1293 rip_neighbor_add (&p
);
1298 /* RIP neighbor configuration unset. */
1299 DEFUN (no_rip_neighbor
,
1300 no_rip_neighbor_cmd
,
1301 "no neighbor A.B.C.D",
1303 "Specify a neighbor router\n"
1304 "Neighbor address\n")
1308 struct prefix_ipv4 p
;
1310 ret
= str2prefix_ipv4 (argv
[idx_ipv4
]->arg
, &p
);
1314 vty_outln (vty
, "Please specify address by A.B.C.D");
1318 rip_neighbor_delete (&p
);
1323 DEFUN (ip_rip_receive_version
,
1324 ip_rip_receive_version_cmd
,
1325 "ip rip receive version <(1-2)|none>",
1327 "Routing Information Protocol\n"
1328 "Advertisement reception\n"
1334 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1336 struct rip_interface
*ri
;
1340 switch (argv
[idx_type
]->arg
[0])
1343 ri
->ri_receive
= RI_RIP_VERSION_1
;
1346 ri
->ri_receive
= RI_RIP_VERSION_2
;
1349 ri
->ri_receive
= RI_RIP_VERSION_NONE
;
1358 DEFUN (ip_rip_receive_version_1
,
1359 ip_rip_receive_version_1_cmd
,
1360 "ip rip receive version (1-1) (2-2)",
1362 "Routing Information Protocol\n"
1363 "Advertisement reception\n"
1368 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1369 struct rip_interface
*ri
;
1373 /* Version 1 and 2. */
1374 ri
->ri_receive
= RI_RIP_VERSION_1_AND_2
;
1378 DEFUN (ip_rip_receive_version_2
,
1379 ip_rip_receive_version_2_cmd
,
1380 "ip rip receive version (2-2) (1-1)",
1382 "Routing Information Protocol\n"
1383 "Advertisement reception\n"
1388 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1389 struct rip_interface
*ri
;
1393 /* Version 1 and 2. */
1394 ri
->ri_receive
= RI_RIP_VERSION_1_AND_2
;
1398 DEFUN (no_ip_rip_receive_version
,
1399 no_ip_rip_receive_version_cmd
,
1400 "no ip rip receive version [(1-2)]",
1403 "Routing Information Protocol\n"
1404 "Advertisement reception\n"
1409 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1410 struct rip_interface
*ri
;
1414 ri
->ri_receive
= RI_RIP_UNSPEC
;
1419 DEFUN (ip_rip_send_version
,
1420 ip_rip_send_version_cmd
,
1421 "ip rip send version (1-2)",
1423 "Routing Information Protocol\n"
1424 "Advertisement transmission\n"
1429 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1431 struct rip_interface
*ri
;
1436 if (atoi (argv
[idx_type
]->arg
) == 1)
1438 ri
->ri_send
= RI_RIP_VERSION_1
;
1441 if (atoi (argv
[idx_type
]->arg
) == 2)
1443 ri
->ri_send
= RI_RIP_VERSION_2
;
1449 DEFUN (ip_rip_send_version_1
,
1450 ip_rip_send_version_1_cmd
,
1451 "ip rip send version (1-1) (2-2)",
1453 "Routing Information Protocol\n"
1454 "Advertisement transmission\n"
1459 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1460 struct rip_interface
*ri
;
1464 /* Version 1 and 2. */
1465 ri
->ri_send
= RI_RIP_VERSION_1_AND_2
;
1469 DEFUN (ip_rip_send_version_2
,
1470 ip_rip_send_version_2_cmd
,
1471 "ip rip send version (2-2) (1-1)",
1473 "Routing Information Protocol\n"
1474 "Advertisement transmission\n"
1479 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1480 struct rip_interface
*ri
;
1484 /* Version 1 and 2. */
1485 ri
->ri_send
= RI_RIP_VERSION_1_AND_2
;
1489 DEFUN (no_ip_rip_send_version
,
1490 no_ip_rip_send_version_cmd
,
1491 "no ip rip send version [(1-2)]",
1494 "Routing Information Protocol\n"
1495 "Advertisement transmission\n"
1500 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1501 struct rip_interface
*ri
;
1505 ri
->ri_send
= RI_RIP_UNSPEC
;
1510 DEFUN (ip_rip_v2_broadcast
,
1511 ip_rip_v2_broadcast_cmd
,
1512 "ip rip v2-broadcast",
1514 "Routing Information Protocol\n"
1515 "Send ip broadcast v2 update\n")
1517 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1518 struct rip_interface
*ri
;
1522 ri
->v2_broadcast
= 1;
1526 DEFUN (no_ip_rip_v2_broadcast
,
1527 no_ip_rip_v2_broadcast_cmd
,
1528 "no ip rip v2-broadcast",
1531 "Routing Information Protocol\n"
1532 "Send ip broadcast v2 update\n")
1534 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1535 struct rip_interface
*ri
;
1539 ri
->v2_broadcast
= 0;
1543 DEFUN (ip_rip_authentication_mode
,
1544 ip_rip_authentication_mode_cmd
,
1545 "ip rip authentication mode <md5|text> [auth-length <rfc|old-ripd>]",
1547 "Routing Information Protocol\n"
1548 "Authentication control\n"
1549 "Authentication mode\n"
1550 "Keyed message digest\n"
1551 "Clear text authentication\n"
1552 "MD5 authentication data length\n"
1554 "Old ripd compatible\n")
1556 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1557 char *cryptmode
= argv
[4]->text
;
1558 char *authlen
= (argc
> 5) ? argv
[6]->text
: NULL
;
1559 struct rip_interface
*ri
;
1564 if (strmatch ("md5", cryptmode
))
1565 auth_type
= RIP_AUTH_MD5
;
1567 assert (strmatch ("text", cryptmode
));
1568 auth_type
= RIP_AUTH_SIMPLE_PASSWORD
;
1571 ri
->auth_type
= auth_type
;
1575 if (auth_type
!= RIP_AUTH_MD5
)
1577 vty_outln (vty
, "auth length argument only valid for md5");
1580 if (strmatch ("rfc", authlen
))
1581 ri
->md5_auth_len
= RIP_AUTH_MD5_SIZE
;
1584 assert (strmatch ("old-ripd", authlen
));
1585 ri
->md5_auth_len
= RIP_AUTH_MD5_COMPAT_SIZE
;
1592 DEFUN (no_ip_rip_authentication_mode
,
1593 no_ip_rip_authentication_mode_cmd
,
1594 "no ip rip authentication mode [<md5|text> [auth-length <rfc|old-ripd>]]",
1597 "Routing Information Protocol\n"
1598 "Authentication control\n"
1599 "Authentication mode\n"
1600 "Keyed message digest\n"
1601 "Clear text authentication\n"
1602 "MD5 authentication data length\n"
1604 "Old ripd compatible\n")
1606 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1607 struct rip_interface
*ri
;
1611 ri
->auth_type
= RIP_NO_AUTH
;
1612 ri
->md5_auth_len
= RIP_AUTH_MD5_COMPAT_SIZE
;
1617 DEFUN (ip_rip_authentication_string
,
1618 ip_rip_authentication_string_cmd
,
1619 "ip rip authentication string LINE",
1621 "Routing Information Protocol\n"
1622 "Authentication control\n"
1623 "Authentication string\n"
1624 "Authentication string\n")
1626 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1628 struct rip_interface
*ri
;
1632 if (strlen (argv
[idx_line
]->arg
) > 16)
1635 "%% RIPv2 authentication string must be shorter than 16");
1641 vty_outln (vty
, "%% key-chain configuration exists");
1646 free (ri
->auth_str
);
1648 ri
->auth_str
= strdup (argv
[idx_line
]->arg
);
1653 DEFUN (no_ip_rip_authentication_string
,
1654 no_ip_rip_authentication_string_cmd
,
1655 "no ip rip authentication string [LINE]",
1658 "Routing Information Protocol\n"
1659 "Authentication control\n"
1660 "Authentication string\n"
1661 "Authentication string\n")
1663 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1664 struct rip_interface
*ri
;
1669 free (ri
->auth_str
);
1671 ri
->auth_str
= NULL
;
1677 DEFUN (ip_rip_authentication_key_chain
,
1678 ip_rip_authentication_key_chain_cmd
,
1679 "ip rip authentication key-chain LINE",
1681 "Routing Information Protocol\n"
1682 "Authentication control\n"
1683 "Authentication key-chain\n"
1684 "name of key-chain\n")
1686 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1688 struct rip_interface
*ri
;
1694 vty_outln (vty
,"%% authentication string configuration exists");
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_outln (vty
, "interface %s",ifp
->name
);
1883 vty_outln (vty
, " description %s",ifp
->desc
);
1885 /* Split horizon. */
1886 if (ri
->split_horizon
!= ri
->split_horizon_default
)
1888 switch (ri
->split_horizon
) {
1889 case RIP_SPLIT_HORIZON
:
1890 vty_outln (vty
, " ip rip split-horizon");
1892 case RIP_SPLIT_HORIZON_POISONED_REVERSE
:
1893 vty_outln (vty
," ip rip split-horizon poisoned-reverse");
1895 case RIP_NO_SPLIT_HORIZON
:
1897 vty_outln (vty
, " no ip rip split-horizon");
1902 /* RIP version setting. */
1903 if (ri
->ri_send
!= RI_RIP_UNSPEC
)
1904 vty_outln (vty
, " ip rip send version %s",
1905 lookup_msg(ri_version_msg
, ri
->ri_send
, NULL
));
1907 if (ri
->ri_receive
!= RI_RIP_UNSPEC
)
1908 vty_outln (vty
, " ip rip receive version %s ",
1909 lookup_msg(ri_version_msg
, ri
->ri_receive
, NULL
));
1911 if (ri
->v2_broadcast
)
1912 vty_outln (vty
, " ip rip v2-broadcast");
1914 /* RIP authentication. */
1915 if (ri
->auth_type
== RIP_AUTH_SIMPLE_PASSWORD
)
1916 vty_outln (vty
, " ip rip authentication mode text");
1918 if (ri
->auth_type
== RIP_AUTH_MD5
)
1920 vty_out (vty
, " ip rip authentication mode md5");
1921 if (ri
->md5_auth_len
== RIP_AUTH_MD5_COMPAT_SIZE
)
1922 vty_out (vty
, " auth-length old-ripd");
1924 vty_out (vty
, " auth-length rfc");
1925 vty_outln (vty
, "");
1929 vty_outln (vty
, " ip rip authentication string %s",
1933 vty_outln (vty
, " ip rip authentication key-chain %s",
1936 vty_outln (vty
, "!");
1942 config_write_rip_network (struct vty
*vty
, int config_mode
)
1946 struct route_node
*node
;
1948 /* Network type RIP enable interface statement. */
1949 for (node
= route_top (rip_enable_network
); node
; node
= route_next (node
))
1951 vty_outln (vty
, "%s%s/%d",
1952 config_mode
? " network " : " ",
1953 inet_ntoa (node
->p
.u
.prefix4
),
1956 /* Interface name RIP enable statement. */
1957 for (i
= 0; i
< vector_active (rip_enable_interface
); i
++)
1958 if ((ifname
= vector_slot (rip_enable_interface
, i
)) != NULL
)
1959 vty_outln (vty
, "%s%s",
1960 config_mode
? " network " : " ",
1963 /* RIP neighbors listing. */
1964 for (node
= route_top (rip
->neighbor
); node
; node
= route_next (node
))
1966 vty_outln (vty
, "%s%s",
1967 config_mode
? " neighbor " : " ",
1968 inet_ntoa(node
->p
.u
.prefix4
));
1970 /* RIP passive interface listing. */
1972 if (passive_default
)
1973 vty_outln (vty
, " passive-interface default");
1974 for (i
= 0; i
< vector_active (Vrip_passive_nondefault
); i
++)
1975 if ((ifname
= vector_slot (Vrip_passive_nondefault
, i
)) != NULL
)
1976 vty_outln (vty
, " %spassive-interface %s",
1977 (passive_default
? "no " : ""), ifname
);
1983 static struct cmd_node interface_node
=
1990 /* Called when interface structure allocated. */
1992 rip_interface_new_hook (struct interface
*ifp
)
1994 ifp
->info
= rip_interface_new ();
1998 /* Called when interface structure deleted. */
2000 rip_interface_delete_hook (struct interface
*ifp
)
2002 XFREE (MTYPE_RIP_INTERFACE
, ifp
->info
);
2007 /* Allocate and initialize interface vector. */
2011 /* Default initial size of interface vector. */
2012 if_add_hook (IF_NEW_HOOK
, rip_interface_new_hook
);
2013 if_add_hook (IF_DELETE_HOOK
, rip_interface_delete_hook
);
2015 /* RIP network init. */
2016 rip_enable_interface
= vector_init (1);
2017 rip_enable_network
= route_table_init ();
2019 /* RIP passive interface. */
2020 Vrip_passive_nondefault
= vector_init (1);
2022 /* Install interface node. */
2023 install_node (&interface_node
, rip_interface_config_write
);
2026 /* Install commands. */
2027 install_element (RIP_NODE
, &rip_network_cmd
);
2028 install_element (RIP_NODE
, &no_rip_network_cmd
);
2029 install_element (RIP_NODE
, &rip_neighbor_cmd
);
2030 install_element (RIP_NODE
, &no_rip_neighbor_cmd
);
2032 install_element (RIP_NODE
, &rip_passive_interface_cmd
);
2033 install_element (RIP_NODE
, &no_rip_passive_interface_cmd
);
2035 install_element (INTERFACE_NODE
, &ip_rip_send_version_cmd
);
2036 install_element (INTERFACE_NODE
, &ip_rip_send_version_1_cmd
);
2037 install_element (INTERFACE_NODE
, &ip_rip_send_version_2_cmd
);
2038 install_element (INTERFACE_NODE
, &no_ip_rip_send_version_cmd
);
2040 install_element (INTERFACE_NODE
, &ip_rip_receive_version_cmd
);
2041 install_element (INTERFACE_NODE
, &ip_rip_receive_version_1_cmd
);
2042 install_element (INTERFACE_NODE
, &ip_rip_receive_version_2_cmd
);
2043 install_element (INTERFACE_NODE
, &no_ip_rip_receive_version_cmd
);
2045 install_element (INTERFACE_NODE
, &ip_rip_v2_broadcast_cmd
);
2046 install_element (INTERFACE_NODE
, &no_ip_rip_v2_broadcast_cmd
);
2048 install_element (INTERFACE_NODE
, &ip_rip_authentication_mode_cmd
);
2049 install_element (INTERFACE_NODE
, &no_ip_rip_authentication_mode_cmd
);
2051 install_element (INTERFACE_NODE
, &ip_rip_authentication_key_chain_cmd
);
2052 install_element (INTERFACE_NODE
, &no_ip_rip_authentication_key_chain_cmd
);
2054 install_element (INTERFACE_NODE
, &ip_rip_authentication_string_cmd
);
2055 install_element (INTERFACE_NODE
, &no_ip_rip_authentication_string_cmd
);
2057 install_element (INTERFACE_NODE
, &ip_rip_split_horizon_cmd
);
2058 install_element (INTERFACE_NODE
, &ip_rip_split_horizon_poisoned_reverse_cmd
);
2059 install_element (INTERFACE_NODE
, &no_ip_rip_split_horizon_cmd
);
2060 install_element (INTERFACE_NODE
, &no_ip_rip_split_horizon_poisoned_reverse_cmd
);