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
17 * along with GNU Zebra; see the file COPYING. If not, write to the Free
18 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
26 #include "sockunion.h"
39 #include "zebra/connected.h"
41 #include "ripd/ripd.h"
42 #include "ripd/rip_debug.h"
43 #include "ripd/rip_interface.h"
45 /* static prototypes */
46 static void rip_enable_apply (struct interface
*);
47 static void rip_passive_interface_apply (struct interface
*);
48 static int rip_if_down(struct interface
*ifp
);
49 static int rip_enable_if_lookup (const char *ifname
);
50 static int rip_enable_network_lookup2 (struct connected
*connected
);
51 static void rip_enable_apply_all (void);
53 struct message ri_version_msg
[] =
55 {RI_RIP_VERSION_1
, "1"},
56 {RI_RIP_VERSION_2
, "2"},
57 {RI_RIP_VERSION_1_AND_2
, "1 2"},
60 extern struct zebra_privs_t ripd_privs
;
62 /* RIP enabled network vector. */
63 vector rip_enable_interface
;
65 /* RIP enabled interface table. */
66 struct route_table
*rip_enable_network
;
68 /* Vector to store passive-interface name. */
69 static int passive_default
; /* are we in passive-interface default mode? */
70 vector Vrip_passive_nondefault
;
72 /* Join to the RIP version 2 multicast group. */
74 ipv4_multicast_join (int sock
,
81 ret
= setsockopt_ipv4_multicast (sock
,
87 zlog (NULL
, LOG_INFO
, "can't setsockopt IP_ADD_MEMBERSHIP %s",
88 safe_strerror (errno
));
93 /* Leave from the RIP version 2 multicast group. */
95 ipv4_multicast_leave (int sock
,
102 ret
= setsockopt_ipv4_multicast (sock
,
108 zlog (NULL
, LOG_INFO
, "can't setsockopt IP_DROP_MEMBERSHIP");
113 /* Allocate new RIP's interface configuration. */
114 static struct rip_interface
*
115 rip_interface_new (void)
117 struct rip_interface
*ri
;
119 ri
= XCALLOC (MTYPE_RIP_INTERFACE
, sizeof (struct rip_interface
));
121 /* Default authentication type is simple password for Cisco
123 ri
->auth_type
= RIP_NO_AUTH
;
124 ri
->md5_auth_len
= RIP_AUTH_MD5_COMPAT_SIZE
;
126 /* Set default split-horizon behavior. If the interface is Frame
127 Relay or SMDS is enabled, the default value for split-horizon is
128 off. But currently Zebra does detect Frame Relay or SMDS
129 interface. So all interface is set to split horizon. */
130 ri
->split_horizon_default
= RIP_SPLIT_HORIZON
;
131 ri
->split_horizon
= ri
->split_horizon_default
;
137 rip_interface_multicast_set (int sock
, struct connected
*connected
)
139 assert (connected
!= NULL
);
141 if (setsockopt_ipv4_multicast_if (sock
, 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 (iflist
, 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
)
385 struct interface
*ifp
;
390 /* zebra_interface_state_read() updates interface structure in
392 ifp
= zebra_interface_state_read(s
);
399 if (IS_RIP_DEBUG_ZEBRA
)
400 zlog_debug ("interface %s index %d flags %llx metric %d mtu %d is down",
401 ifp
->name
, ifp
->ifindex
, (unsigned long long)ifp
->flags
,
402 ifp
->metric
, ifp
->mtu
);
407 /* Inteface link up message processing */
409 rip_interface_up (int command
, struct zclient
*zclient
, zebra_size_t length
)
411 struct interface
*ifp
;
413 /* zebra_interface_state_read () updates interface structure in
415 ifp
= zebra_interface_state_read (zclient
->ibuf
);
420 if (IS_RIP_DEBUG_ZEBRA
)
421 zlog_debug ("interface %s index %d flags %#llx metric %d mtu %d is up",
422 ifp
->name
, ifp
->ifindex
, (unsigned long long) ifp
->flags
,
423 ifp
->metric
, ifp
->mtu
);
425 /* Check if this interface is RIP enabled or not.*/
426 rip_enable_apply (ifp
);
428 /* Check for a passive interface */
429 rip_passive_interface_apply (ifp
);
431 /* Apply distribute list to the all interface. */
432 rip_distribute_update_interface (ifp
);
437 /* Inteface addition message from zebra. */
439 rip_interface_add (int command
, struct zclient
*zclient
, zebra_size_t length
)
441 struct interface
*ifp
;
443 ifp
= zebra_interface_add_read (zclient
->ibuf
);
445 if (IS_RIP_DEBUG_ZEBRA
)
446 zlog_debug ("interface add %s index %d flags %#llx metric %d mtu %d",
447 ifp
->name
, ifp
->ifindex
, (unsigned long long) ifp
->flags
,
448 ifp
->metric
, ifp
->mtu
);
450 /* Check if this interface is RIP enabled or not.*/
451 rip_enable_apply (ifp
);
453 /* Check for a passive interface */
454 rip_passive_interface_apply (ifp
);
456 /* Apply distribute list to the all interface. */
457 rip_distribute_update_interface (ifp
);
459 /* rip_request_neighbor_all (); */
461 /* Check interface routemap. */
462 rip_if_rmap_update_interface (ifp
);
468 rip_interface_delete (int command
, struct zclient
*zclient
,
471 struct interface
*ifp
;
476 /* zebra_interface_state_read() updates interface structure in iflist */
477 ifp
= zebra_interface_state_read(s
);
482 if (if_is_up (ifp
)) {
486 zlog_info("interface delete %s index %d flags %#llx metric %d mtu %d",
487 ifp
->name
, ifp
->ifindex
, (unsigned long long) ifp
->flags
,
488 ifp
->metric
, ifp
->mtu
);
490 /* To support pseudo interface do not free interface structure. */
491 /* if_delete(ifp); */
492 ifp
->ifindex
= IFINDEX_INTERNAL
;
498 rip_interface_clean (void)
500 struct listnode
*node
;
501 struct interface
*ifp
;
502 struct rip_interface
*ri
;
504 for (ALL_LIST_ELEMENTS_RO (iflist
, node
, ifp
))
508 ri
->enable_network
= 0;
509 ri
->enable_interface
= 0;
514 thread_cancel (ri
->t_wakeup
);
521 rip_interface_reset (void)
523 struct listnode
*node
;
524 struct interface
*ifp
;
525 struct rip_interface
*ri
;
527 for (ALL_LIST_ELEMENTS_RO (iflist
, node
, ifp
))
531 ri
->enable_network
= 0;
532 ri
->enable_interface
= 0;
535 ri
->ri_send
= RI_RIP_UNSPEC
;
536 ri
->ri_receive
= RI_RIP_UNSPEC
;
538 ri
->auth_type
= RIP_NO_AUTH
;
547 free (ri
->key_chain
);
548 ri
->key_chain
= NULL
;
551 ri
->split_horizon
= RIP_NO_SPLIT_HORIZON
;
552 ri
->split_horizon_default
= RIP_NO_SPLIT_HORIZON
;
554 ri
->list
[RIP_FILTER_IN
] = NULL
;
555 ri
->list
[RIP_FILTER_OUT
] = NULL
;
557 ri
->prefix
[RIP_FILTER_IN
] = NULL
;
558 ri
->prefix
[RIP_FILTER_OUT
] = NULL
;
562 thread_cancel (ri
->t_wakeup
);
566 ri
->recv_badpackets
= 0;
567 ri
->recv_badroutes
= 0;
568 ri
->sent_updates
= 0;
575 rip_if_down(struct interface
*ifp
)
577 struct route_node
*rp
;
578 struct rip_info
*rinfo
;
579 struct rip_interface
*ri
= NULL
;
582 for (rp
= route_top (rip
->table
); rp
; rp
= route_next (rp
))
583 if ((rinfo
= rp
->info
) != NULL
)
585 /* Routes got through this interface. */
586 if (rinfo
->ifindex
== ifp
->ifindex
&&
587 rinfo
->type
== ZEBRA_ROUTE_RIP
&&
588 rinfo
->sub_type
== RIP_ROUTE_RTE
)
590 rip_zebra_ipv4_delete ((struct prefix_ipv4
*) &rp
->p
,
594 rip_redistribute_delete (rinfo
->type
,rinfo
->sub_type
,
595 (struct prefix_ipv4
*)&rp
->p
,
600 /* All redistributed routes but static and system */
601 if ((rinfo
->ifindex
== ifp
->ifindex
) &&
602 /* (rinfo->type != ZEBRA_ROUTE_STATIC) && */
603 (rinfo
->type
!= ZEBRA_ROUTE_SYSTEM
))
604 rip_redistribute_delete (rinfo
->type
,rinfo
->sub_type
,
605 (struct prefix_ipv4
*)&rp
->p
,
615 if (IS_RIP_DEBUG_EVENT
)
616 zlog_debug ("turn off %s", ifp
->name
);
618 /* Leave from multicast group. */
619 rip_multicast_leave (ifp
, rip
->sock
);
627 /* Needed for stop RIP process. */
631 struct interface
*ifp
;
632 struct listnode
*node
, *nnode
;
634 for (ALL_LIST_ELEMENTS (iflist
, node
, nnode
, ifp
))
639 rip_apply_address_add (struct connected
*ifc
)
641 struct prefix_ipv4 address
;
647 if (! if_is_up(ifc
->ifp
))
652 memset (&address
, 0, sizeof (address
));
653 address
.family
= p
->family
;
654 address
.prefix
= p
->u
.prefix4
;
655 address
.prefixlen
= p
->prefixlen
;
656 apply_mask_ipv4(&address
);
658 /* Check if this interface is RIP enabled or not
659 or Check if this address's prefix is RIP enabled */
660 if ((rip_enable_if_lookup(ifc
->ifp
->name
) >= 0) ||
661 (rip_enable_network_lookup2(ifc
) >= 0))
662 rip_redistribute_add(ZEBRA_ROUTE_CONNECT
, RIP_ROUTE_INTERFACE
,
663 &address
, ifc
->ifp
->ifindex
, NULL
, 0, 0);
668 rip_interface_address_add (int command
, struct zclient
*zclient
,
671 struct connected
*ifc
;
674 ifc
= zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_ADD
,
682 if (p
->family
== AF_INET
)
684 if (IS_RIP_DEBUG_ZEBRA
)
685 zlog_debug ("connected address %s/%d is added",
686 inet_ntoa (p
->u
.prefix4
), p
->prefixlen
);
688 rip_enable_apply(ifc
->ifp
);
689 /* Check if this prefix needs to be redistributed */
690 rip_apply_address_add(ifc
);
693 rip_ifaddr_add (ifc
->ifp
, ifc
);
694 #endif /* HAVE_SNMP */
701 rip_apply_address_del (struct connected
*ifc
) {
702 struct prefix_ipv4 address
;
708 if (! if_is_up(ifc
->ifp
))
713 memset (&address
, 0, sizeof (address
));
714 address
.family
= p
->family
;
715 address
.prefix
= p
->u
.prefix4
;
716 address
.prefixlen
= p
->prefixlen
;
717 apply_mask_ipv4(&address
);
719 rip_redistribute_delete(ZEBRA_ROUTE_CONNECT
, RIP_ROUTE_INTERFACE
,
720 &address
, ifc
->ifp
->ifindex
);
724 rip_interface_address_delete (int command
, struct zclient
*zclient
,
727 struct connected
*ifc
;
730 ifc
= zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_DELETE
,
736 if (p
->family
== AF_INET
)
738 if (IS_RIP_DEBUG_ZEBRA
)
739 zlog_debug ("connected address %s/%d is deleted",
740 inet_ntoa (p
->u
.prefix4
), p
->prefixlen
);
743 rip_ifaddr_delete (ifc
->ifp
, ifc
);
744 #endif /* HAVE_SNMP */
746 /* Chech wether this prefix needs to be removed */
747 rip_apply_address_del(ifc
);
751 connected_free (ifc
);
758 /* Check interface is enabled by network statement. */
759 /* Check wether the interface has at least a connected prefix that
760 * is within the ripng_enable_network table. */
762 rip_enable_network_lookup_if (struct interface
*ifp
)
764 struct listnode
*node
, *nnode
;
765 struct connected
*connected
;
766 struct prefix_ipv4 address
;
768 for (ALL_LIST_ELEMENTS (ifp
->connected
, node
, nnode
, connected
))
771 struct route_node
*node
;
773 p
= connected
->address
;
775 if (p
->family
== AF_INET
)
777 address
.family
= AF_INET
;
778 address
.prefix
= p
->u
.prefix4
;
779 address
.prefixlen
= IPV4_MAX_BITLEN
;
781 node
= route_node_match (rip_enable_network
,
782 (struct prefix
*)&address
);
785 route_unlock_node (node
);
793 /* Check wether connected is within the ripng_enable_network table. */
795 rip_enable_network_lookup2 (struct connected
*connected
)
797 struct prefix_ipv4 address
;
800 p
= connected
->address
;
802 if (p
->family
== AF_INET
) {
803 struct route_node
*node
;
805 address
.family
= p
->family
;
806 address
.prefix
= p
->u
.prefix4
;
807 address
.prefixlen
= IPV4_MAX_BITLEN
;
809 /* LPM on p->family, p->u.prefix4/IPV4_MAX_BITLEN within rip_enable_network */
810 node
= route_node_match (rip_enable_network
,
811 (struct prefix
*)&address
);
814 route_unlock_node (node
);
821 /* Add RIP enable network. */
823 rip_enable_network_add (struct prefix
*p
)
825 struct route_node
*node
;
827 node
= route_node_get (rip_enable_network
, p
);
831 route_unlock_node (node
);
835 node
->info
= (void *)1;
837 /* XXX: One should find a better solution than a generic one */
838 rip_enable_apply_all();
843 /* Delete RIP enable network. */
845 rip_enable_network_delete (struct prefix
*p
)
847 struct route_node
*node
;
849 node
= route_node_lookup (rip_enable_network
, p
);
854 /* Unlock info lock. */
855 route_unlock_node (node
);
857 /* Unlock lookup lock. */
858 route_unlock_node (node
);
860 /* XXX: One should find a better solution than a generic one */
861 rip_enable_apply_all ();
868 /* Check interface is enabled by ifname statement. */
870 rip_enable_if_lookup (const char *ifname
)
875 for (i
= 0; i
< vector_active (rip_enable_interface
); i
++)
876 if ((str
= vector_slot (rip_enable_interface
, i
)) != NULL
)
877 if (strcmp (str
, ifname
) == 0)
882 /* Add interface to rip_enable_if. */
884 rip_enable_if_add (const char *ifname
)
888 ret
= rip_enable_if_lookup (ifname
);
892 vector_set (rip_enable_interface
, strdup (ifname
));
894 rip_enable_apply_all(); /* TODOVJ */
899 /* Delete interface from rip_enable_if. */
901 rip_enable_if_delete (const char *ifname
)
906 index
= rip_enable_if_lookup (ifname
);
910 str
= vector_slot (rip_enable_interface
, index
);
912 vector_unset (rip_enable_interface
, index
);
914 rip_enable_apply_all(); /* TODOVJ */
919 /* Join to multicast group and send request to the interface. */
921 rip_interface_wakeup (struct thread
*t
)
923 struct interface
*ifp
;
924 struct rip_interface
*ri
;
927 ifp
= THREAD_ARG (t
);
932 /* Join to multicast group. */
933 if (rip_multicast_join (ifp
, rip
->sock
) < 0)
935 zlog_err ("multicast join failed, interface %s not running", ifp
->name
);
939 /* Set running flag. */
942 /* Send RIP request to the interface. */
943 rip_request_interface (ifp
);
949 rip_connect_set (struct interface
*ifp
, int set
)
951 struct listnode
*node
, *nnode
;
952 struct connected
*connected
;
953 struct prefix_ipv4 address
;
955 for (ALL_LIST_ELEMENTS (ifp
->connected
, node
, nnode
, connected
))
958 p
= connected
->address
;
960 if (p
->family
!= AF_INET
)
963 address
.family
= AF_INET
;
964 address
.prefix
= p
->u
.prefix4
;
965 address
.prefixlen
= p
->prefixlen
;
966 apply_mask_ipv4 (&address
);
969 /* Check once more wether this prefix is within a "network IF_OR_PREF" one */
970 if ((rip_enable_if_lookup(connected
->ifp
->name
) >= 0) ||
971 (rip_enable_network_lookup2(connected
) >= 0))
972 rip_redistribute_add (ZEBRA_ROUTE_CONNECT
, RIP_ROUTE_INTERFACE
,
973 &address
, connected
->ifp
->ifindex
,
977 rip_redistribute_delete (ZEBRA_ROUTE_CONNECT
, RIP_ROUTE_INTERFACE
,
978 &address
, connected
->ifp
->ifindex
);
979 if (rip_redistribute_check (ZEBRA_ROUTE_CONNECT
))
980 rip_redistribute_add (ZEBRA_ROUTE_CONNECT
, RIP_ROUTE_REDISTRIBUTE
,
981 &address
, connected
->ifp
->ifindex
,
987 /* Update interface status. */
989 rip_enable_apply (struct interface
*ifp
)
992 struct rip_interface
*ri
= NULL
;
994 /* Check interface. */
995 if (! if_is_operative (ifp
))
1000 /* Check network configuration. */
1001 ret
= rip_enable_network_lookup_if (ifp
);
1003 /* If the interface is matched. */
1005 ri
->enable_network
= 1;
1007 ri
->enable_network
= 0;
1009 /* Check interface name configuration. */
1010 ret
= rip_enable_if_lookup (ifp
->name
);
1012 ri
->enable_interface
= 1;
1014 ri
->enable_interface
= 0;
1016 /* any interface MUST have an IPv4 address */
1017 if ( ! rip_if_ipv4_address_check (ifp
) )
1019 ri
->enable_network
= 0;
1020 ri
->enable_interface
= 0;
1023 /* Update running status of the interface. */
1024 if (ri
->enable_network
|| ri
->enable_interface
)
1027 if (IS_RIP_DEBUG_EVENT
)
1028 zlog_debug ("turn on %s", ifp
->name
);
1030 /* Add interface wake up thread. */
1032 ri
->t_wakeup
= thread_add_timer (master
, rip_interface_wakeup
,
1034 rip_connect_set (ifp
, 1);
1041 /* Might as well clean up the route table as well
1042 * rip_if_down sets to 0 ri->running, and displays "turn off %s"
1046 rip_connect_set (ifp
, 0);
1051 /* Apply network configuration to all interface. */
1053 rip_enable_apply_all ()
1055 struct interface
*ifp
;
1056 struct listnode
*node
, *nnode
;
1058 /* Check each interface. */
1059 for (ALL_LIST_ELEMENTS (iflist
, node
, nnode
, ifp
))
1060 rip_enable_apply (ifp
);
1064 rip_neighbor_lookup (struct sockaddr_in
*from
)
1066 struct prefix_ipv4 p
;
1067 struct route_node
*node
;
1069 memset (&p
, 0, sizeof (struct prefix_ipv4
));
1071 p
.prefix
= from
->sin_addr
;
1072 p
.prefixlen
= IPV4_MAX_BITLEN
;
1074 node
= route_node_lookup (rip
->neighbor
, (struct prefix
*) &p
);
1077 route_unlock_node (node
);
1083 /* Add new RIP neighbor to the neighbor tree. */
1085 rip_neighbor_add (struct prefix_ipv4
*p
)
1087 struct route_node
*node
;
1089 node
= route_node_get (rip
->neighbor
, (struct prefix
*) p
);
1094 node
->info
= rip
->neighbor
;
1099 /* Delete RIP neighbor from the neighbor tree. */
1101 rip_neighbor_delete (struct prefix_ipv4
*p
)
1103 struct route_node
*node
;
1105 /* Lock for look up. */
1106 node
= route_node_lookup (rip
->neighbor
, (struct prefix
*) p
);
1112 /* Unlock lookup lock. */
1113 route_unlock_node (node
);
1115 /* Unlock real neighbor information lock. */
1116 route_unlock_node (node
);
1121 /* Clear all network and neighbor configuration. */
1123 rip_clean_network ()
1127 struct route_node
*rn
;
1129 /* rip_enable_network. */
1130 for (rn
= route_top (rip_enable_network
); rn
; rn
= route_next (rn
))
1134 route_unlock_node (rn
);
1137 /* rip_enable_interface. */
1138 for (i
= 0; i
< vector_active (rip_enable_interface
); i
++)
1139 if ((str
= vector_slot (rip_enable_interface
, i
)) != NULL
)
1142 vector_slot (rip_enable_interface
, i
) = NULL
;
1146 /* Utility function for looking up passive interface settings. */
1148 rip_passive_nondefault_lookup (const char *ifname
)
1153 for (i
= 0; i
< vector_active (Vrip_passive_nondefault
); i
++)
1154 if ((str
= vector_slot (Vrip_passive_nondefault
, i
)) != NULL
)
1155 if (strcmp (str
, ifname
) == 0)
1161 rip_passive_interface_apply (struct interface
*ifp
)
1163 struct rip_interface
*ri
;
1167 ri
->passive
= ((rip_passive_nondefault_lookup (ifp
->name
) < 0) ?
1168 passive_default
: !passive_default
);
1170 if (IS_RIP_DEBUG_ZEBRA
)
1171 zlog_debug ("interface %s: passive = %d",ifp
->name
,ri
->passive
);
1175 rip_passive_interface_apply_all (void)
1177 struct interface
*ifp
;
1178 struct listnode
*node
, *nnode
;
1180 for (ALL_LIST_ELEMENTS (iflist
, node
, nnode
, ifp
))
1181 rip_passive_interface_apply (ifp
);
1184 /* Passive interface. */
1186 rip_passive_nondefault_set (struct vty
*vty
, const char *ifname
)
1188 if (rip_passive_nondefault_lookup (ifname
) >= 0)
1191 vector_set (Vrip_passive_nondefault
, strdup (ifname
));
1193 rip_passive_interface_apply_all ();
1199 rip_passive_nondefault_unset (struct vty
*vty
, const char *ifname
)
1204 i
= rip_passive_nondefault_lookup (ifname
);
1208 str
= vector_slot (Vrip_passive_nondefault
, i
);
1210 vector_unset (Vrip_passive_nondefault
, i
);
1212 rip_passive_interface_apply_all ();
1217 /* Free all configured RIP passive-interface settings. */
1219 rip_passive_nondefault_clean (void)
1224 for (i
= 0; i
< vector_active (Vrip_passive_nondefault
); i
++)
1225 if ((str
= vector_slot (Vrip_passive_nondefault
, i
)) != NULL
)
1228 vector_slot (Vrip_passive_nondefault
, i
) = NULL
;
1230 rip_passive_interface_apply_all ();
1233 /* RIP enable network or interface configuration. */
1236 "network (A.B.C.D/M|WORD)",
1237 "Enable routing on an IP network\n"
1238 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1242 struct prefix_ipv4 p
;
1244 ret
= str2prefix_ipv4 (argv
[0], &p
);
1247 ret
= rip_enable_network_add ((struct prefix
*) &p
);
1249 ret
= rip_enable_if_add (argv
[0]);
1253 vty_out (vty
, "There is a same network configuration %s%s", argv
[0],
1261 /* RIP enable network or interface configuration. */
1262 DEFUN (no_rip_network
,
1264 "no network (A.B.C.D/M|WORD)",
1266 "Enable routing on an IP network\n"
1267 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1271 struct prefix_ipv4 p
;
1273 ret
= str2prefix_ipv4 (argv
[0], &p
);
1276 ret
= rip_enable_network_delete ((struct prefix
*) &p
);
1278 ret
= rip_enable_if_delete (argv
[0]);
1282 vty_out (vty
, "Can't find network configuration %s%s", argv
[0],
1290 /* RIP neighbor configuration set. */
1291 DEFUN (rip_neighbor
,
1294 "Specify a neighbor router\n"
1295 "Neighbor address\n")
1298 struct prefix_ipv4 p
;
1300 ret
= str2prefix_ipv4 (argv
[0], &p
);
1304 vty_out (vty
, "Please specify address by A.B.C.D%s", VTY_NEWLINE
);
1308 rip_neighbor_add (&p
);
1313 /* RIP neighbor configuration unset. */
1314 DEFUN (no_rip_neighbor
,
1315 no_rip_neighbor_cmd
,
1316 "no neighbor A.B.C.D",
1318 "Specify a neighbor router\n"
1319 "Neighbor address\n")
1322 struct prefix_ipv4 p
;
1324 ret
= str2prefix_ipv4 (argv
[0], &p
);
1328 vty_out (vty
, "Please specify address by A.B.C.D%s", VTY_NEWLINE
);
1332 rip_neighbor_delete (&p
);
1337 DEFUN (ip_rip_receive_version
,
1338 ip_rip_receive_version_cmd
,
1339 "ip rip receive version (1|2)",
1341 "Routing Information Protocol\n"
1342 "Advertisement reception\n"
1347 struct interface
*ifp
;
1348 struct rip_interface
*ri
;
1350 ifp
= (struct interface
*)vty
->index
;
1354 if (atoi (argv
[0]) == 1)
1356 ri
->ri_receive
= RI_RIP_VERSION_1
;
1359 if (atoi (argv
[0]) == 2)
1361 ri
->ri_receive
= RI_RIP_VERSION_2
;
1367 DEFUN (ip_rip_receive_version_1
,
1368 ip_rip_receive_version_1_cmd
,
1369 "ip rip receive version 1 2",
1371 "Routing Information Protocol\n"
1372 "Advertisement reception\n"
1377 struct interface
*ifp
;
1378 struct rip_interface
*ri
;
1380 ifp
= (struct interface
*)vty
->index
;
1383 /* Version 1 and 2. */
1384 ri
->ri_receive
= RI_RIP_VERSION_1_AND_2
;
1388 DEFUN (ip_rip_receive_version_2
,
1389 ip_rip_receive_version_2_cmd
,
1390 "ip rip receive version 2 1",
1392 "Routing Information Protocol\n"
1393 "Advertisement reception\n"
1398 struct interface
*ifp
;
1399 struct rip_interface
*ri
;
1401 ifp
= (struct interface
*)vty
->index
;
1404 /* Version 1 and 2. */
1405 ri
->ri_receive
= RI_RIP_VERSION_1_AND_2
;
1409 DEFUN (no_ip_rip_receive_version
,
1410 no_ip_rip_receive_version_cmd
,
1411 "no ip rip receive version",
1414 "Routing Information Protocol\n"
1415 "Advertisement reception\n"
1416 "Version control\n")
1418 struct interface
*ifp
;
1419 struct rip_interface
*ri
;
1421 ifp
= (struct interface
*)vty
->index
;
1424 ri
->ri_receive
= RI_RIP_UNSPEC
;
1428 ALIAS (no_ip_rip_receive_version
,
1429 no_ip_rip_receive_version_num_cmd
,
1430 "no ip rip receive version (1|2)",
1433 "Routing Information Protocol\n"
1434 "Advertisement reception\n"
1439 DEFUN (ip_rip_send_version
,
1440 ip_rip_send_version_cmd
,
1441 "ip rip send version (1|2)",
1443 "Routing Information Protocol\n"
1444 "Advertisement transmission\n"
1449 struct interface
*ifp
;
1450 struct rip_interface
*ri
;
1452 ifp
= (struct interface
*)vty
->index
;
1456 if (atoi (argv
[0]) == 1)
1458 ri
->ri_send
= RI_RIP_VERSION_1
;
1461 if (atoi (argv
[0]) == 2)
1463 ri
->ri_send
= RI_RIP_VERSION_2
;
1469 DEFUN (ip_rip_send_version_1
,
1470 ip_rip_send_version_1_cmd
,
1471 "ip rip send version 1 2",
1473 "Routing Information Protocol\n"
1474 "Advertisement transmission\n"
1479 struct interface
*ifp
;
1480 struct rip_interface
*ri
;
1482 ifp
= (struct interface
*)vty
->index
;
1485 /* Version 1 and 2. */
1486 ri
->ri_send
= RI_RIP_VERSION_1_AND_2
;
1490 DEFUN (ip_rip_send_version_2
,
1491 ip_rip_send_version_2_cmd
,
1492 "ip rip send version 2 1",
1494 "Routing Information Protocol\n"
1495 "Advertisement transmission\n"
1500 struct interface
*ifp
;
1501 struct rip_interface
*ri
;
1503 ifp
= (struct interface
*)vty
->index
;
1506 /* Version 1 and 2. */
1507 ri
->ri_send
= RI_RIP_VERSION_1_AND_2
;
1511 DEFUN (no_ip_rip_send_version
,
1512 no_ip_rip_send_version_cmd
,
1513 "no ip rip send version",
1516 "Routing Information Protocol\n"
1517 "Advertisement transmission\n"
1518 "Version control\n")
1520 struct interface
*ifp
;
1521 struct rip_interface
*ri
;
1523 ifp
= (struct interface
*)vty
->index
;
1526 ri
->ri_send
= RI_RIP_UNSPEC
;
1530 ALIAS (no_ip_rip_send_version
,
1531 no_ip_rip_send_version_num_cmd
,
1532 "no ip rip send version (1|2)",
1535 "Routing Information Protocol\n"
1536 "Advertisement transmission\n"
1541 DEFUN (ip_rip_authentication_mode
,
1542 ip_rip_authentication_mode_cmd
,
1543 "ip rip authentication mode (md5|text)",
1545 "Routing Information Protocol\n"
1546 "Authentication control\n"
1547 "Authentication mode\n"
1548 "Keyed message digest\n"
1549 "Clear text authentication\n")
1551 struct interface
*ifp
;
1552 struct rip_interface
*ri
;
1555 ifp
= (struct interface
*)vty
->index
;
1558 if ( (argc
< 1) || (argc
> 2) )
1560 vty_out (vty
, "incorrect argument count%s", VTY_NEWLINE
);
1564 if (strncmp ("md5", argv
[0], strlen (argv
[0])) == 0)
1565 auth_type
= RIP_AUTH_MD5
;
1566 else if (strncmp ("text", argv
[0], strlen (argv
[0])) == 0)
1567 auth_type
= RIP_AUTH_SIMPLE_PASSWORD
;
1570 vty_out (vty
, "mode should be md5 or text%s", VTY_NEWLINE
);
1576 ri
->auth_type
= auth_type
;
1580 if ( (argc
== 2) && (auth_type
!= RIP_AUTH_MD5
) )
1582 vty_out (vty
, "auth length argument only valid for md5%s", VTY_NEWLINE
);
1586 if (strncmp ("r", argv
[1], 1) == 0)
1587 ri
->md5_auth_len
= RIP_AUTH_MD5_SIZE
;
1588 else if (strncmp ("o", argv
[1], 1) == 0)
1589 ri
->md5_auth_len
= RIP_AUTH_MD5_COMPAT_SIZE
;
1593 ri
->auth_type
= auth_type
;
1598 ALIAS (ip_rip_authentication_mode
,
1599 ip_rip_authentication_mode_authlen_cmd
,
1600 "ip rip authentication mode (md5|text) auth-length (rfc|old-ripd)",
1602 "Routing Information Protocol\n"
1603 "Authentication control\n"
1604 "Authentication mode\n"
1605 "Keyed message digest\n"
1606 "Clear text authentication\n"
1607 "MD5 authentication data length\n"
1609 "Old ripd compatible\n")
1611 DEFUN (no_ip_rip_authentication_mode
,
1612 no_ip_rip_authentication_mode_cmd
,
1613 "no ip rip authentication mode",
1616 "Routing Information Protocol\n"
1617 "Authentication control\n"
1618 "Authentication mode\n")
1620 struct interface
*ifp
;
1621 struct rip_interface
*ri
;
1623 ifp
= (struct interface
*)vty
->index
;
1626 ri
->auth_type
= RIP_NO_AUTH
;
1627 ri
->md5_auth_len
= RIP_AUTH_MD5_COMPAT_SIZE
;
1632 ALIAS (no_ip_rip_authentication_mode
,
1633 no_ip_rip_authentication_mode_type_cmd
,
1634 "no ip rip authentication mode (md5|text)",
1637 "Routing Information Protocol\n"
1638 "Authentication control\n"
1639 "Authentication mode\n"
1640 "Keyed message digest\n"
1641 "Clear text authentication\n")
1643 ALIAS (no_ip_rip_authentication_mode
,
1644 no_ip_rip_authentication_mode_type_authlen_cmd
,
1645 "no ip rip authentication mode (md5|text) auth-length (rfc|old-ripd)",
1648 "Routing Information Protocol\n"
1649 "Authentication control\n"
1650 "Authentication mode\n"
1651 "Keyed message digest\n"
1652 "Clear text authentication\n"
1653 "MD5 authentication data length\n"
1655 "Old ripd compatible\n")
1657 DEFUN (ip_rip_authentication_string
,
1658 ip_rip_authentication_string_cmd
,
1659 "ip rip authentication string LINE",
1661 "Routing Information Protocol\n"
1662 "Authentication control\n"
1663 "Authentication string\n"
1664 "Authentication string\n")
1666 struct interface
*ifp
;
1667 struct rip_interface
*ri
;
1669 ifp
= (struct interface
*)vty
->index
;
1672 if (strlen (argv
[0]) > 16)
1674 vty_out (vty
, "%% RIPv2 authentication string must be shorter than 16%s",
1681 vty_out (vty
, "%% key-chain configuration exists%s", VTY_NEWLINE
);
1686 free (ri
->auth_str
);
1688 ri
->auth_str
= strdup (argv
[0]);
1693 DEFUN (no_ip_rip_authentication_string
,
1694 no_ip_rip_authentication_string_cmd
,
1695 "no ip rip authentication string",
1698 "Routing Information Protocol\n"
1699 "Authentication control\n"
1700 "Authentication string\n")
1702 struct interface
*ifp
;
1703 struct rip_interface
*ri
;
1705 ifp
= (struct interface
*)vty
->index
;
1709 free (ri
->auth_str
);
1711 ri
->auth_str
= NULL
;
1716 ALIAS (no_ip_rip_authentication_string
,
1717 no_ip_rip_authentication_string2_cmd
,
1718 "no ip rip authentication string LINE",
1721 "Routing Information Protocol\n"
1722 "Authentication control\n"
1723 "Authentication string\n"
1724 "Authentication string\n")
1726 DEFUN (ip_rip_authentication_key_chain
,
1727 ip_rip_authentication_key_chain_cmd
,
1728 "ip rip authentication key-chain LINE",
1730 "Routing Information Protocol\n"
1731 "Authentication control\n"
1732 "Authentication key-chain\n"
1733 "name of key-chain\n")
1735 struct interface
*ifp
;
1736 struct rip_interface
*ri
;
1738 ifp
= (struct interface
*) vty
->index
;
1743 vty_out (vty
, "%% authentication string configuration exists%s",
1749 free (ri
->key_chain
);
1751 ri
->key_chain
= strdup (argv
[0]);
1756 DEFUN (no_ip_rip_authentication_key_chain
,
1757 no_ip_rip_authentication_key_chain_cmd
,
1758 "no ip rip authentication key-chain",
1761 "Routing Information Protocol\n"
1762 "Authentication control\n"
1763 "Authentication key-chain\n")
1765 struct interface
*ifp
;
1766 struct rip_interface
*ri
;
1768 ifp
= (struct interface
*) vty
->index
;
1772 free (ri
->key_chain
);
1774 ri
->key_chain
= NULL
;
1779 ALIAS (no_ip_rip_authentication_key_chain
,
1780 no_ip_rip_authentication_key_chain2_cmd
,
1781 "no ip rip authentication key-chain LINE",
1784 "Routing Information Protocol\n"
1785 "Authentication control\n"
1786 "Authentication key-chain\n"
1787 "name of key-chain\n")
1789 /* CHANGED: ip rip split-horizon
1790 Cisco and Zebra's command is
1793 DEFUN (ip_rip_split_horizon
,
1794 ip_rip_split_horizon_cmd
,
1795 "ip rip split-horizon",
1797 "Routing Information Protocol\n"
1798 "Perform split horizon\n")
1800 struct interface
*ifp
;
1801 struct rip_interface
*ri
;
1806 ri
->split_horizon
= RIP_SPLIT_HORIZON
;
1810 DEFUN (ip_rip_split_horizon_poisoned_reverse
,
1811 ip_rip_split_horizon_poisoned_reverse_cmd
,
1812 "ip rip split-horizon poisoned-reverse",
1814 "Routing Information Protocol\n"
1815 "Perform split horizon\n"
1816 "With poisoned-reverse\n")
1818 struct interface
*ifp
;
1819 struct rip_interface
*ri
;
1824 ri
->split_horizon
= RIP_SPLIT_HORIZON_POISONED_REVERSE
;
1828 /* CHANGED: no ip rip split-horizon
1829 Cisco and Zebra's command is
1832 DEFUN (no_ip_rip_split_horizon
,
1833 no_ip_rip_split_horizon_cmd
,
1834 "no ip rip split-horizon",
1837 "Routing Information Protocol\n"
1838 "Perform split horizon\n")
1840 struct interface
*ifp
;
1841 struct rip_interface
*ri
;
1846 ri
->split_horizon
= RIP_NO_SPLIT_HORIZON
;
1850 DEFUN (no_ip_rip_split_horizon_poisoned_reverse
,
1851 no_ip_rip_split_horizon_poisoned_reverse_cmd
,
1852 "no ip rip split-horizon poisoned-reverse",
1855 "Routing Information Protocol\n"
1856 "Perform split horizon\n"
1857 "With poisoned-reverse\n")
1859 struct interface
*ifp
;
1860 struct rip_interface
*ri
;
1865 switch( ri
->split_horizon
)
1867 case RIP_SPLIT_HORIZON_POISONED_REVERSE
:
1868 ri
->split_horizon
= RIP_SPLIT_HORIZON
;
1876 DEFUN (rip_passive_interface
,
1877 rip_passive_interface_cmd
,
1878 "passive-interface (IFNAME|default)",
1879 "Suppress routing updates on an interface\n"
1881 "default for all interfaces\n")
1883 const char *ifname
= argv
[0];
1885 if (!strcmp(ifname
,"default")) {
1886 passive_default
= 1;
1887 rip_passive_nondefault_clean();
1890 if (passive_default
)
1891 return rip_passive_nondefault_unset (vty
, ifname
);
1893 return rip_passive_nondefault_set (vty
, ifname
);
1896 DEFUN (no_rip_passive_interface
,
1897 no_rip_passive_interface_cmd
,
1898 "no passive-interface (IFNAME|default)",
1900 "Suppress routing updates on an interface\n"
1902 "default for all interfaces\n")
1904 const char *ifname
= argv
[0];
1906 if (!strcmp(ifname
,"default")) {
1907 passive_default
= 0;
1908 rip_passive_nondefault_clean();
1911 if (passive_default
)
1912 return rip_passive_nondefault_set (vty
, ifname
);
1914 return rip_passive_nondefault_unset (vty
, ifname
);
1917 /* Write rip configuration of each interface. */
1919 rip_interface_config_write (struct vty
*vty
)
1921 struct listnode
*node
;
1922 struct interface
*ifp
;
1924 for (ALL_LIST_ELEMENTS_RO (iflist
, node
, ifp
))
1926 struct rip_interface
*ri
;
1930 /* Do not display the interface if there is no
1931 * configuration about it.
1934 (ri
->split_horizon
== ri
->split_horizon_default
) &&
1935 (ri
->ri_send
== RI_RIP_UNSPEC
) &&
1936 (ri
->ri_receive
== RI_RIP_UNSPEC
) &&
1937 (ri
->auth_type
!= RIP_AUTH_MD5
) &&
1938 (ri
->md5_auth_len
!= RIP_AUTH_MD5_SIZE
) &&
1943 vty_out (vty
, "interface %s%s", ifp
->name
,
1947 vty_out (vty
, " description %s%s", ifp
->desc
,
1950 /* Split horizon. */
1951 if (ri
->split_horizon
!= ri
->split_horizon_default
)
1953 switch (ri
->split_horizon
) {
1954 case RIP_SPLIT_HORIZON
:
1955 vty_out (vty
, " ip rip split-horizon%s", VTY_NEWLINE
);
1957 case RIP_SPLIT_HORIZON_POISONED_REVERSE
:
1958 vty_out (vty
, " ip rip split-horizon poisoned-reverse%s",
1961 case RIP_NO_SPLIT_HORIZON
:
1963 vty_out (vty
, " no ip rip split-horizon%s", VTY_NEWLINE
);
1968 /* RIP version setting. */
1969 if (ri
->ri_send
!= RI_RIP_UNSPEC
)
1970 vty_out (vty
, " ip rip send version %s%s",
1971 lookup (ri_version_msg
, ri
->ri_send
),
1974 if (ri
->ri_receive
!= RI_RIP_UNSPEC
)
1975 vty_out (vty
, " ip rip receive version %s%s",
1976 lookup (ri_version_msg
, ri
->ri_receive
),
1979 /* RIP authentication. */
1980 if (ri
->auth_type
== RIP_AUTH_SIMPLE_PASSWORD
)
1981 vty_out (vty
, " ip rip authentication mode text%s", VTY_NEWLINE
);
1983 if (ri
->auth_type
== RIP_AUTH_MD5
)
1985 vty_out (vty
, " ip rip authentication mode md5");
1986 if (ri
->md5_auth_len
== RIP_AUTH_MD5_COMPAT_SIZE
)
1987 vty_out (vty
, " auth-length old-ripd");
1989 vty_out (vty
, " auth-length rfc");
1990 vty_out (vty
, "%s", VTY_NEWLINE
);
1994 vty_out (vty
, " ip rip authentication string %s%s",
1995 ri
->auth_str
, VTY_NEWLINE
);
1998 vty_out (vty
, " ip rip authentication key-chain %s%s",
1999 ri
->key_chain
, VTY_NEWLINE
);
2001 vty_out (vty
, "!%s", VTY_NEWLINE
);
2007 config_write_rip_network (struct vty
*vty
, int config_mode
)
2011 struct route_node
*node
;
2013 /* Network type RIP enable interface statement. */
2014 for (node
= route_top (rip_enable_network
); node
; node
= route_next (node
))
2016 vty_out (vty
, "%s%s/%d%s",
2017 config_mode
? " network " : " ",
2018 inet_ntoa (node
->p
.u
.prefix4
),
2022 /* Interface name RIP enable statement. */
2023 for (i
= 0; i
< vector_active (rip_enable_interface
); i
++)
2024 if ((ifname
= vector_slot (rip_enable_interface
, i
)) != NULL
)
2025 vty_out (vty
, "%s%s%s",
2026 config_mode
? " network " : " ",
2030 /* RIP neighbors listing. */
2031 for (node
= route_top (rip
->neighbor
); node
; node
= route_next (node
))
2033 vty_out (vty
, "%s%s%s",
2034 config_mode
? " neighbor " : " ",
2035 inet_ntoa (node
->p
.u
.prefix4
),
2038 /* RIP passive interface listing. */
2040 if (passive_default
)
2041 vty_out (vty
, " passive-interface default%s", VTY_NEWLINE
);
2042 for (i
= 0; i
< vector_active (Vrip_passive_nondefault
); i
++)
2043 if ((ifname
= vector_slot (Vrip_passive_nondefault
, i
)) != NULL
)
2044 vty_out (vty
, " %spassive-interface %s%s",
2045 (passive_default
? "no " : ""), ifname
, VTY_NEWLINE
);
2051 static struct cmd_node interface_node
=
2058 /* Called when interface structure allocated. */
2060 rip_interface_new_hook (struct interface
*ifp
)
2062 ifp
->info
= rip_interface_new ();
2066 /* Called when interface structure deleted. */
2068 rip_interface_delete_hook (struct interface
*ifp
)
2070 XFREE (MTYPE_RIP_INTERFACE
, ifp
->info
);
2075 /* Allocate and initialize interface vector. */
2079 /* Default initial size of interface vector. */
2081 if_add_hook (IF_NEW_HOOK
, rip_interface_new_hook
);
2082 if_add_hook (IF_DELETE_HOOK
, rip_interface_delete_hook
);
2084 /* RIP network init. */
2085 rip_enable_interface
= vector_init (1);
2086 rip_enable_network
= route_table_init ();
2088 /* RIP passive interface. */
2089 Vrip_passive_nondefault
= vector_init (1);
2091 /* Install interface node. */
2092 install_node (&interface_node
, rip_interface_config_write
);
2094 /* Install commands. */
2095 install_element (CONFIG_NODE
, &interface_cmd
);
2096 install_element (CONFIG_NODE
, &no_interface_cmd
);
2097 install_default (INTERFACE_NODE
);
2098 install_element (INTERFACE_NODE
, &interface_desc_cmd
);
2099 install_element (INTERFACE_NODE
, &no_interface_desc_cmd
);
2100 install_element (RIP_NODE
, &rip_network_cmd
);
2101 install_element (RIP_NODE
, &no_rip_network_cmd
);
2102 install_element (RIP_NODE
, &rip_neighbor_cmd
);
2103 install_element (RIP_NODE
, &no_rip_neighbor_cmd
);
2105 install_element (RIP_NODE
, &rip_passive_interface_cmd
);
2106 install_element (RIP_NODE
, &no_rip_passive_interface_cmd
);
2108 install_element (INTERFACE_NODE
, &ip_rip_send_version_cmd
);
2109 install_element (INTERFACE_NODE
, &ip_rip_send_version_1_cmd
);
2110 install_element (INTERFACE_NODE
, &ip_rip_send_version_2_cmd
);
2111 install_element (INTERFACE_NODE
, &no_ip_rip_send_version_cmd
);
2112 install_element (INTERFACE_NODE
, &no_ip_rip_send_version_num_cmd
);
2114 install_element (INTERFACE_NODE
, &ip_rip_receive_version_cmd
);
2115 install_element (INTERFACE_NODE
, &ip_rip_receive_version_1_cmd
);
2116 install_element (INTERFACE_NODE
, &ip_rip_receive_version_2_cmd
);
2117 install_element (INTERFACE_NODE
, &no_ip_rip_receive_version_cmd
);
2118 install_element (INTERFACE_NODE
, &no_ip_rip_receive_version_num_cmd
);
2120 install_element (INTERFACE_NODE
, &ip_rip_authentication_mode_cmd
);
2121 install_element (INTERFACE_NODE
, &ip_rip_authentication_mode_authlen_cmd
);
2122 install_element (INTERFACE_NODE
, &no_ip_rip_authentication_mode_cmd
);
2123 install_element (INTERFACE_NODE
, &no_ip_rip_authentication_mode_type_cmd
);
2124 install_element (INTERFACE_NODE
, &no_ip_rip_authentication_mode_type_authlen_cmd
);
2126 install_element (INTERFACE_NODE
, &ip_rip_authentication_key_chain_cmd
);
2127 install_element (INTERFACE_NODE
, &no_ip_rip_authentication_key_chain_cmd
);
2128 install_element (INTERFACE_NODE
, &no_ip_rip_authentication_key_chain2_cmd
);
2130 install_element (INTERFACE_NODE
, &ip_rip_authentication_string_cmd
);
2131 install_element (INTERFACE_NODE
, &no_ip_rip_authentication_string_cmd
);
2132 install_element (INTERFACE_NODE
, &no_ip_rip_authentication_string2_cmd
);
2134 install_element (INTERFACE_NODE
, &ip_rip_split_horizon_cmd
);
2135 install_element (INTERFACE_NODE
, &ip_rip_split_horizon_poisoned_reverse_cmd
);
2136 install_element (INTERFACE_NODE
, &no_ip_rip_split_horizon_cmd
);
2137 install_element (INTERFACE_NODE
, &no_ip_rip_split_horizon_poisoned_reverse_cmd
);