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_multicast_ipv4 (sock
,
88 zlog (NULL
, LOG_INFO
, "can't setsockopt IP_ADD_MEMBERSHIP %s",
89 safe_strerror (errno
));
94 /* Leave from the RIP version 2 multicast group. */
96 ipv4_multicast_leave (int sock
,
103 ret
= setsockopt_multicast_ipv4 (sock
,
110 zlog (NULL
, LOG_INFO
, "can't setsockopt IP_DROP_MEMBERSHIP");
115 /* Allocate new RIP's interface configuration. */
116 static struct rip_interface
*
117 rip_interface_new (void)
119 struct rip_interface
*ri
;
121 ri
= XCALLOC (MTYPE_RIP_INTERFACE
, sizeof (struct rip_interface
));
123 /* Default authentication type is simple password for Cisco
125 ri
->auth_type
= RIP_NO_AUTH
;
126 ri
->md5_auth_len
= RIP_AUTH_MD5_COMPAT_SIZE
;
128 /* Set default split-horizon behavior. If the interface is Frame
129 Relay or SMDS is enabled, the default value for split-horizon is
130 off. But currently Zebra does detect Frame Relay or SMDS
131 interface. So all interface is set to split horizon. */
132 ri
->split_horizon_default
= RIP_SPLIT_HORIZON
;
133 ri
->split_horizon
= ri
->split_horizon_default
;
139 rip_interface_multicast_set (int sock
, struct connected
*connected
)
143 assert (connected
!= NULL
);
145 addr
= CONNECTED_ID(connected
)->u
.prefix4
;
147 if (setsockopt_multicast_ipv4 (sock
, IP_MULTICAST_IF
, addr
, 0,
148 connected
->ifp
->ifindex
) < 0)
150 zlog_warn ("Can't setsockopt IP_MULTICAST_IF on fd %d to "
151 "source address %s for interface %s",
152 sock
, inet_ntoa(addr
),
153 connected
->ifp
->name
);
159 /* Send RIP request packet to specified interface. */
161 rip_request_interface_send (struct interface
*ifp
, u_char version
)
163 struct sockaddr_in to
;
165 /* RIPv2 support multicast. */
166 if (version
== RIPv2
&& if_is_multicast (ifp
))
169 if (IS_RIP_DEBUG_EVENT
)
170 zlog_debug ("multicast request on %s", ifp
->name
);
172 rip_request_send (NULL
, ifp
, version
, NULL
);
176 /* RIPv1 and non multicast interface. */
177 if (if_is_pointopoint (ifp
) || if_is_broadcast (ifp
))
179 struct listnode
*cnode
, *cnnode
;
180 struct connected
*connected
;
182 if (IS_RIP_DEBUG_EVENT
)
183 zlog_debug ("broadcast request to %s", ifp
->name
);
185 for (ALL_LIST_ELEMENTS (ifp
->connected
, cnode
, cnnode
, connected
))
187 if (connected
->address
->family
== AF_INET
)
189 memset (&to
, 0, sizeof (struct sockaddr_in
));
190 to
.sin_port
= htons (RIP_PORT_DEFAULT
);
191 if (connected
->destination
)
192 /* use specified broadcast or peer destination addr */
193 to
.sin_addr
= connected
->destination
->u
.prefix4
;
194 else if (connected
->address
->prefixlen
< IPV4_MAX_PREFIXLEN
)
195 /* calculate the appropriate broadcast address */
197 ipv4_broadcast_addr(connected
->address
->u
.prefix4
.s_addr
,
198 connected
->address
->prefixlen
);
200 /* do not know where to send the packet */
203 if (IS_RIP_DEBUG_EVENT
)
204 zlog_debug ("SEND request to %s", inet_ntoa (to
.sin_addr
));
206 rip_request_send (&to
, ifp
, version
, connected
);
212 /* This will be executed when interface goes up. */
214 rip_request_interface (struct interface
*ifp
)
216 struct rip_interface
*ri
;
218 /* In default ripd doesn't send RIP_REQUEST to the loopback interface. */
219 if (if_is_loopback (ifp
))
222 /* If interface is down, don't send RIP packet. */
223 if (! if_is_operative (ifp
))
226 /* Fetch RIP interface information. */
230 /* If there is no version configuration in the interface,
231 use rip's version setting. */
233 int vsend
= ((ri
->ri_send
== RI_RIP_UNSPEC
) ?
234 rip
->version_send
: ri
->ri_send
);
236 rip_request_interface_send (ifp
, RIPv1
);
238 rip_request_interface_send (ifp
, RIPv2
);
242 /* Send RIP request to the neighbor. */
244 rip_request_neighbor (struct in_addr addr
)
246 struct sockaddr_in to
;
248 memset (&to
, 0, sizeof (struct sockaddr_in
));
249 to
.sin_port
= htons (RIP_PORT_DEFAULT
);
252 rip_request_send (&to
, NULL
, rip
->version_send
, NULL
);
255 /* Request routes at all interfaces. */
257 rip_request_neighbor_all (void)
259 struct route_node
*rp
;
264 if (IS_RIP_DEBUG_EVENT
)
265 zlog_debug ("request to the all neighbor");
267 /* Send request to all neighbor. */
268 for (rp
= route_top (rip
->neighbor
); rp
; rp
= route_next (rp
))
270 rip_request_neighbor (rp
->p
.u
.prefix4
);
273 /* Multicast packet receive socket. */
275 rip_multicast_join (struct interface
*ifp
, int sock
)
277 struct listnode
*cnode
;
278 struct connected
*ifc
;
280 if (if_is_operative (ifp
) && if_is_multicast (ifp
))
282 if (IS_RIP_DEBUG_EVENT
)
283 zlog_debug ("multicast join at %s", ifp
->name
);
285 for (ALL_LIST_ELEMENTS_RO (ifp
->connected
, cnode
, ifc
))
287 struct prefix_ipv4
*p
;
288 struct in_addr group
;
290 p
= (struct prefix_ipv4
*) ifc
->address
;
292 if (p
->family
!= AF_INET
)
295 group
.s_addr
= htonl (INADDR_RIP_GROUP
);
296 if (ipv4_multicast_join (sock
, group
, p
->prefix
, ifp
->ifindex
) < 0)
305 /* Leave from multicast group. */
307 rip_multicast_leave (struct interface
*ifp
, int sock
)
309 struct listnode
*cnode
;
310 struct connected
*connected
;
312 if (if_is_up (ifp
) && if_is_multicast (ifp
))
314 if (IS_RIP_DEBUG_EVENT
)
315 zlog_debug ("multicast leave from %s", ifp
->name
);
317 for (ALL_LIST_ELEMENTS_RO (ifp
->connected
, cnode
, connected
))
319 struct prefix_ipv4
*p
;
320 struct in_addr group
;
322 p
= (struct prefix_ipv4
*) connected
->address
;
324 if (p
->family
!= AF_INET
)
327 group
.s_addr
= htonl (INADDR_RIP_GROUP
);
328 if (ipv4_multicast_leave (sock
, group
, p
->prefix
, ifp
->ifindex
) == 0)
334 /* Is there and address on interface that I could use ? */
336 rip_if_ipv4_address_check (struct interface
*ifp
)
339 struct connected
*connected
;
342 for (ALL_LIST_ELEMENTS_RO (ifp
->connected
, nn
, connected
))
346 p
= connected
->address
;
348 if (p
->family
== AF_INET
)
358 /* Does this address belongs to me ? */
360 if_check_address (struct in_addr addr
)
362 struct listnode
*node
;
363 struct interface
*ifp
;
365 for (ALL_LIST_ELEMENTS_RO (iflist
, node
, ifp
))
367 struct listnode
*cnode
;
368 struct connected
*connected
;
370 for (ALL_LIST_ELEMENTS_RO (ifp
->connected
, cnode
, connected
))
372 struct prefix_ipv4
*p
;
374 p
= (struct prefix_ipv4
*) connected
->address
;
376 if (p
->family
!= AF_INET
)
379 if (IPV4_ADDR_CMP (&p
->prefix
, &addr
) == 0)
386 /* Inteface link down message processing. */
388 rip_interface_down (int command
, struct zclient
*zclient
, zebra_size_t length
)
390 struct interface
*ifp
;
395 /* zebra_interface_state_read() updates interface structure in
397 ifp
= zebra_interface_state_read(s
);
404 if (IS_RIP_DEBUG_ZEBRA
)
405 zlog_debug ("interface %s index %d flags %ld metric %d mtu %d is down",
406 ifp
->name
, ifp
->ifindex
, ifp
->flags
, ifp
->metric
, ifp
->mtu
);
411 /* Inteface link up message processing */
413 rip_interface_up (int command
, struct zclient
*zclient
, zebra_size_t length
)
415 struct interface
*ifp
;
417 /* zebra_interface_state_read () updates interface structure in
419 ifp
= zebra_interface_state_read (zclient
->ibuf
);
424 if (IS_RIP_DEBUG_ZEBRA
)
425 zlog_debug ("interface %s index %d flags %ld metric %d mtu %d is up",
426 ifp
->name
, ifp
->ifindex
, ifp
->flags
, 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
)
444 struct interface
*ifp
;
446 ifp
= zebra_interface_add_read (zclient
->ibuf
);
448 if (IS_RIP_DEBUG_ZEBRA
)
449 zlog_debug ("interface add %s index %d flags %ld metric %d mtu %d",
450 ifp
->name
, ifp
->ifindex
, ifp
->flags
, ifp
->metric
, ifp
->mtu
);
452 /* Check if this interface is RIP enabled or not.*/
453 rip_enable_apply (ifp
);
455 /* Check for a passive interface */
456 rip_passive_interface_apply (ifp
);
458 /* Apply distribute list to the all interface. */
459 rip_distribute_update_interface (ifp
);
461 /* rip_request_neighbor_all (); */
463 /* Check interface routemap. */
464 rip_if_rmap_update_interface (ifp
);
470 rip_interface_delete (int command
, struct zclient
*zclient
,
473 struct interface
*ifp
;
478 /* zebra_interface_state_read() updates interface structure in iflist */
479 ifp
= zebra_interface_state_read(s
);
484 if (if_is_up (ifp
)) {
488 zlog_info("interface delete %s index %d flags %ld metric %d mtu %d",
489 ifp
->name
, ifp
->ifindex
, ifp
->flags
, ifp
->metric
, ifp
->mtu
);
491 /* To support pseudo interface do not free interface structure. */
492 /* if_delete(ifp); */
493 ifp
->ifindex
= IFINDEX_INTERNAL
;
499 rip_interface_clean (void)
501 struct listnode
*node
;
502 struct interface
*ifp
;
503 struct rip_interface
*ri
;
505 for (ALL_LIST_ELEMENTS_RO (iflist
, node
, ifp
))
509 ri
->enable_network
= 0;
510 ri
->enable_interface
= 0;
515 thread_cancel (ri
->t_wakeup
);
522 rip_interface_reset (void)
524 struct listnode
*node
;
525 struct interface
*ifp
;
526 struct rip_interface
*ri
;
528 for (ALL_LIST_ELEMENTS_RO (iflist
, node
, ifp
))
532 ri
->enable_network
= 0;
533 ri
->enable_interface
= 0;
536 ri
->ri_send
= RI_RIP_UNSPEC
;
537 ri
->ri_receive
= RI_RIP_UNSPEC
;
539 ri
->auth_type
= RIP_NO_AUTH
;
548 free (ri
->key_chain
);
549 ri
->key_chain
= NULL
;
552 ri
->split_horizon
= RIP_NO_SPLIT_HORIZON
;
553 ri
->split_horizon_default
= RIP_NO_SPLIT_HORIZON
;
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
;
563 thread_cancel (ri
->t_wakeup
);
567 ri
->recv_badpackets
= 0;
568 ri
->recv_badroutes
= 0;
569 ri
->sent_updates
= 0;
576 rip_if_down(struct interface
*ifp
)
578 struct route_node
*rp
;
579 struct rip_info
*rinfo
;
580 struct rip_interface
*ri
= NULL
;
583 for (rp
= route_top (rip
->table
); rp
; rp
= route_next (rp
))
584 if ((rinfo
= rp
->info
) != NULL
)
586 /* Routes got through this interface. */
587 if (rinfo
->ifindex
== ifp
->ifindex
&&
588 rinfo
->type
== ZEBRA_ROUTE_RIP
&&
589 rinfo
->sub_type
== RIP_ROUTE_RTE
)
591 rip_zebra_ipv4_delete ((struct prefix_ipv4
*) &rp
->p
,
595 rip_redistribute_delete (rinfo
->type
,rinfo
->sub_type
,
596 (struct prefix_ipv4
*)&rp
->p
,
601 /* All redistributed routes but static and system */
602 if ((rinfo
->ifindex
== ifp
->ifindex
) &&
603 /* (rinfo->type != ZEBRA_ROUTE_STATIC) && */
604 (rinfo
->type
!= ZEBRA_ROUTE_SYSTEM
))
605 rip_redistribute_delete (rinfo
->type
,rinfo
->sub_type
,
606 (struct prefix_ipv4
*)&rp
->p
,
616 if (IS_RIP_DEBUG_EVENT
)
617 zlog_debug ("turn off %s", ifp
->name
);
619 /* Leave from multicast group. */
620 rip_multicast_leave (ifp
, rip
->sock
);
628 /* Needed for stop RIP process. */
632 struct interface
*ifp
;
633 struct listnode
*node
, *nnode
;
635 for (ALL_LIST_ELEMENTS (iflist
, node
, nnode
, ifp
))
640 rip_apply_address_add (struct connected
*ifc
)
642 struct prefix_ipv4 address
;
648 if (! if_is_up(ifc
->ifp
))
653 memset (&address
, 0, sizeof (address
));
654 address
.family
= p
->family
;
655 address
.prefix
= p
->u
.prefix4
;
656 address
.prefixlen
= p
->prefixlen
;
657 apply_mask_ipv4(&address
);
659 /* Check if this interface is RIP enabled or not
660 or Check if this address's prefix is RIP enabled */
661 if ((rip_enable_if_lookup(ifc
->ifp
->name
) >= 0) ||
662 (rip_enable_network_lookup2(ifc
) >= 0))
663 rip_redistribute_add(ZEBRA_ROUTE_CONNECT
, RIP_ROUTE_INTERFACE
,
664 &address
, ifc
->ifp
->ifindex
, NULL
, 0, 0);
669 rip_interface_address_add (int command
, struct zclient
*zclient
,
672 struct connected
*ifc
;
675 ifc
= zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_ADD
,
683 if (p
->family
== AF_INET
)
685 if (IS_RIP_DEBUG_ZEBRA
)
686 zlog_debug ("connected address %s/%d is added",
687 inet_ntoa (p
->u
.prefix4
), p
->prefixlen
);
689 rip_enable_apply(ifc
->ifp
);
690 /* Check if this prefix needs to be redistributed */
691 rip_apply_address_add(ifc
);
694 rip_ifaddr_add (ifc
->ifp
, ifc
);
695 #endif /* HAVE_SNMP */
702 rip_apply_address_del (struct connected
*ifc
) {
703 struct prefix_ipv4 address
;
709 if (! if_is_up(ifc
->ifp
))
714 memset (&address
, 0, sizeof (address
));
715 address
.family
= p
->family
;
716 address
.prefix
= p
->u
.prefix4
;
717 address
.prefixlen
= p
->prefixlen
;
718 apply_mask_ipv4(&address
);
720 rip_redistribute_delete(ZEBRA_ROUTE_CONNECT
, RIP_ROUTE_INTERFACE
,
721 &address
, ifc
->ifp
->ifindex
);
725 rip_interface_address_delete (int command
, struct zclient
*zclient
,
728 struct connected
*ifc
;
731 ifc
= zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_DELETE
,
737 if (p
->family
== AF_INET
)
739 if (IS_RIP_DEBUG_ZEBRA
)
740 zlog_debug ("connected address %s/%d is deleted",
741 inet_ntoa (p
->u
.prefix4
), p
->prefixlen
);
744 rip_ifaddr_delete (ifc
->ifp
, ifc
);
745 #endif /* HAVE_SNMP */
747 /* Chech wether this prefix needs to be removed */
748 rip_apply_address_del(ifc
);
752 connected_free (ifc
);
759 /* Check interface is enabled by network statement. */
760 /* Check wether the interface has at least a connected prefix that
761 * is within the ripng_enable_network table. */
763 rip_enable_network_lookup_if (struct interface
*ifp
)
765 struct listnode
*node
, *nnode
;
766 struct connected
*connected
;
767 struct prefix_ipv4 address
;
769 for (ALL_LIST_ELEMENTS (ifp
->connected
, node
, nnode
, connected
))
772 struct route_node
*node
;
774 p
= connected
->address
;
776 if (p
->family
== AF_INET
)
778 address
.family
= AF_INET
;
779 address
.prefix
= p
->u
.prefix4
;
780 address
.prefixlen
= IPV4_MAX_BITLEN
;
782 node
= route_node_match (rip_enable_network
,
783 (struct prefix
*)&address
);
786 route_unlock_node (node
);
794 /* Check wether connected is within the ripng_enable_network table. */
796 rip_enable_network_lookup2 (struct connected
*connected
)
798 struct prefix_ipv4 address
;
801 p
= connected
->address
;
803 if (p
->family
== AF_INET
) {
804 struct route_node
*node
;
806 address
.family
= p
->family
;
807 address
.prefix
= p
->u
.prefix4
;
808 address
.prefixlen
= IPV4_MAX_BITLEN
;
810 /* LPM on p->family, p->u.prefix4/IPV4_MAX_BITLEN within rip_enable_network */
811 node
= route_node_match (rip_enable_network
,
812 (struct prefix
*)&address
);
815 route_unlock_node (node
);
822 /* Add RIP enable network. */
824 rip_enable_network_add (struct prefix
*p
)
826 struct route_node
*node
;
828 node
= route_node_get (rip_enable_network
, p
);
832 route_unlock_node (node
);
836 node
->info
= (char *) "enabled";
838 /* XXX: One should find a better solution than a generic one */
839 rip_enable_apply_all();
844 /* Delete RIP enable network. */
846 rip_enable_network_delete (struct prefix
*p
)
848 struct route_node
*node
;
850 node
= route_node_lookup (rip_enable_network
, p
);
855 /* Unlock info lock. */
856 route_unlock_node (node
);
858 /* Unlock lookup lock. */
859 route_unlock_node (node
);
861 /* XXX: One should find a better solution than a generic one */
862 rip_enable_apply_all ();
869 /* Check interface is enabled by ifname statement. */
871 rip_enable_if_lookup (const char *ifname
)
876 for (i
= 0; i
< vector_active (rip_enable_interface
); i
++)
877 if ((str
= vector_slot (rip_enable_interface
, i
)) != NULL
)
878 if (strcmp (str
, ifname
) == 0)
883 /* Add interface to rip_enable_if. */
885 rip_enable_if_add (const char *ifname
)
889 ret
= rip_enable_if_lookup (ifname
);
893 vector_set (rip_enable_interface
, strdup (ifname
));
895 rip_enable_apply_all(); /* TODOVJ */
900 /* Delete interface from rip_enable_if. */
902 rip_enable_if_delete (const char *ifname
)
907 index
= rip_enable_if_lookup (ifname
);
911 str
= vector_slot (rip_enable_interface
, index
);
913 vector_unset (rip_enable_interface
, index
);
915 rip_enable_apply_all(); /* TODOVJ */
920 /* Join to multicast group and send request to the interface. */
922 rip_interface_wakeup (struct thread
*t
)
924 struct interface
*ifp
;
925 struct rip_interface
*ri
;
928 ifp
= THREAD_ARG (t
);
933 /* Join to multicast group. */
934 if (rip_multicast_join (ifp
, rip
->sock
) < 0)
936 zlog_err ("multicast join failed, interface %s not running", ifp
->name
);
940 /* Set running flag. */
943 /* Send RIP request to the interface. */
944 rip_request_interface (ifp
);
949 int rip_redistribute_check (int);
952 rip_connect_set (struct interface
*ifp
, int set
)
954 struct listnode
*node
, *nnode
;
955 struct connected
*connected
;
956 struct prefix_ipv4 address
;
958 for (ALL_LIST_ELEMENTS (ifp
->connected
, node
, nnode
, connected
))
961 p
= connected
->address
;
963 if (p
->family
!= AF_INET
)
966 address
.family
= AF_INET
;
967 address
.prefix
= p
->u
.prefix4
;
968 address
.prefixlen
= p
->prefixlen
;
969 apply_mask_ipv4 (&address
);
972 /* Check once more wether this prefix is within a "network IF_OR_PREF" one */
973 if ((rip_enable_if_lookup(connected
->ifp
->name
) >= 0) ||
974 (rip_enable_network_lookup2(connected
) >= 0))
975 rip_redistribute_add (ZEBRA_ROUTE_CONNECT
, RIP_ROUTE_INTERFACE
,
976 &address
, connected
->ifp
->ifindex
,
980 rip_redistribute_delete (ZEBRA_ROUTE_CONNECT
, RIP_ROUTE_INTERFACE
,
981 &address
, connected
->ifp
->ifindex
);
982 if (rip_redistribute_check (ZEBRA_ROUTE_CONNECT
))
983 rip_redistribute_add (ZEBRA_ROUTE_CONNECT
, RIP_ROUTE_REDISTRIBUTE
,
984 &address
, connected
->ifp
->ifindex
,
990 /* Update interface status. */
992 rip_enable_apply (struct interface
*ifp
)
995 struct rip_interface
*ri
= NULL
;
997 /* Check interface. */
998 if (! if_is_operative (ifp
))
1003 /* Check network configuration. */
1004 ret
= rip_enable_network_lookup_if (ifp
);
1006 /* If the interface is matched. */
1008 ri
->enable_network
= 1;
1010 ri
->enable_network
= 0;
1012 /* Check interface name configuration. */
1013 ret
= rip_enable_if_lookup (ifp
->name
);
1015 ri
->enable_interface
= 1;
1017 ri
->enable_interface
= 0;
1019 /* any interface MUST have an IPv4 address */
1020 if ( ! rip_if_ipv4_address_check (ifp
) )
1022 ri
->enable_network
= 0;
1023 ri
->enable_interface
= 0;
1026 /* Update running status of the interface. */
1027 if (ri
->enable_network
|| ri
->enable_interface
)
1030 if (IS_RIP_DEBUG_EVENT
)
1031 zlog_debug ("turn on %s", ifp
->name
);
1033 /* Add interface wake up thread. */
1035 ri
->t_wakeup
= thread_add_timer (master
, rip_interface_wakeup
,
1037 rip_connect_set (ifp
, 1);
1044 /* Might as well clean up the route table as well
1045 * rip_if_down sets to 0 ri->running, and displays "turn off %s"
1049 rip_connect_set (ifp
, 0);
1054 /* Apply network configuration to all interface. */
1056 rip_enable_apply_all ()
1058 struct interface
*ifp
;
1059 struct listnode
*node
, *nnode
;
1061 /* Check each interface. */
1062 for (ALL_LIST_ELEMENTS (iflist
, node
, nnode
, ifp
))
1063 rip_enable_apply (ifp
);
1067 rip_neighbor_lookup (struct sockaddr_in
*from
)
1069 struct prefix_ipv4 p
;
1070 struct route_node
*node
;
1072 memset (&p
, 0, sizeof (struct prefix_ipv4
));
1074 p
.prefix
= from
->sin_addr
;
1075 p
.prefixlen
= IPV4_MAX_BITLEN
;
1077 node
= route_node_lookup (rip
->neighbor
, (struct prefix
*) &p
);
1080 route_unlock_node (node
);
1086 /* Add new RIP neighbor to the neighbor tree. */
1088 rip_neighbor_add (struct prefix_ipv4
*p
)
1090 struct route_node
*node
;
1092 node
= route_node_get (rip
->neighbor
, (struct prefix
*) p
);
1097 node
->info
= rip
->neighbor
;
1102 /* Delete RIP neighbor from the neighbor tree. */
1104 rip_neighbor_delete (struct prefix_ipv4
*p
)
1106 struct route_node
*node
;
1108 /* Lock for look up. */
1109 node
= route_node_lookup (rip
->neighbor
, (struct prefix
*) p
);
1115 /* Unlock lookup lock. */
1116 route_unlock_node (node
);
1118 /* Unlock real neighbor information lock. */
1119 route_unlock_node (node
);
1124 /* Clear all network and neighbor configuration. */
1126 rip_clean_network ()
1130 struct route_node
*rn
;
1132 /* rip_enable_network. */
1133 for (rn
= route_top (rip_enable_network
); rn
; rn
= route_next (rn
))
1137 route_unlock_node (rn
);
1140 /* rip_enable_interface. */
1141 for (i
= 0; i
< vector_active (rip_enable_interface
); i
++)
1142 if ((str
= vector_slot (rip_enable_interface
, i
)) != NULL
)
1145 vector_slot (rip_enable_interface
, i
) = NULL
;
1149 /* Utility function for looking up passive interface settings. */
1151 rip_passive_nondefault_lookup (const char *ifname
)
1156 for (i
= 0; i
< vector_active (Vrip_passive_nondefault
); i
++)
1157 if ((str
= vector_slot (Vrip_passive_nondefault
, i
)) != NULL
)
1158 if (strcmp (str
, ifname
) == 0)
1164 rip_passive_interface_apply (struct interface
*ifp
)
1166 struct rip_interface
*ri
;
1170 ri
->passive
= ((rip_passive_nondefault_lookup (ifp
->name
) < 0) ?
1171 passive_default
: !passive_default
);
1173 if (IS_RIP_DEBUG_ZEBRA
)
1174 zlog_debug ("interface %s: passive = %d",ifp
->name
,ri
->passive
);
1178 rip_passive_interface_apply_all (void)
1180 struct interface
*ifp
;
1181 struct listnode
*node
, *nnode
;
1183 for (ALL_LIST_ELEMENTS (iflist
, node
, nnode
, ifp
))
1184 rip_passive_interface_apply (ifp
);
1187 /* Passive interface. */
1189 rip_passive_nondefault_set (struct vty
*vty
, const char *ifname
)
1191 if (rip_passive_nondefault_lookup (ifname
) >= 0)
1194 vector_set (Vrip_passive_nondefault
, strdup (ifname
));
1196 rip_passive_interface_apply_all ();
1202 rip_passive_nondefault_unset (struct vty
*vty
, const char *ifname
)
1207 i
= rip_passive_nondefault_lookup (ifname
);
1211 str
= vector_slot (Vrip_passive_nondefault
, i
);
1213 vector_unset (Vrip_passive_nondefault
, i
);
1215 rip_passive_interface_apply_all ();
1220 /* Free all configured RIP passive-interface settings. */
1222 rip_passive_nondefault_clean (void)
1227 for (i
= 0; i
< vector_active (Vrip_passive_nondefault
); i
++)
1228 if ((str
= vector_slot (Vrip_passive_nondefault
, i
)) != NULL
)
1231 vector_slot (Vrip_passive_nondefault
, i
) = NULL
;
1233 rip_passive_interface_apply_all ();
1236 /* RIP enable network or interface configuration. */
1239 "network (A.B.C.D/M|WORD)",
1240 "Enable routing on an IP network\n"
1241 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1245 struct prefix_ipv4 p
;
1247 ret
= str2prefix_ipv4 (argv
[0], &p
);
1250 ret
= rip_enable_network_add ((struct prefix
*) &p
);
1252 ret
= rip_enable_if_add (argv
[0]);
1256 vty_out (vty
, "There is a same network configuration %s%s", argv
[0],
1264 /* RIP enable network or interface configuration. */
1265 DEFUN (no_rip_network
,
1267 "no network (A.B.C.D/M|WORD)",
1269 "Enable routing on an IP network\n"
1270 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1274 struct prefix_ipv4 p
;
1276 ret
= str2prefix_ipv4 (argv
[0], &p
);
1279 ret
= rip_enable_network_delete ((struct prefix
*) &p
);
1281 ret
= rip_enable_if_delete (argv
[0]);
1285 vty_out (vty
, "Can't find network configuration %s%s", argv
[0],
1293 /* RIP neighbor configuration set. */
1294 DEFUN (rip_neighbor
,
1297 "Specify a neighbor router\n"
1298 "Neighbor address\n")
1301 struct prefix_ipv4 p
;
1303 ret
= str2prefix_ipv4 (argv
[0], &p
);
1307 vty_out (vty
, "Please specify address by A.B.C.D%s", VTY_NEWLINE
);
1311 rip_neighbor_add (&p
);
1316 /* RIP neighbor configuration unset. */
1317 DEFUN (no_rip_neighbor
,
1318 no_rip_neighbor_cmd
,
1319 "no neighbor A.B.C.D",
1321 "Specify a neighbor router\n"
1322 "Neighbor address\n")
1325 struct prefix_ipv4 p
;
1327 ret
= str2prefix_ipv4 (argv
[0], &p
);
1331 vty_out (vty
, "Please specify address by A.B.C.D%s", VTY_NEWLINE
);
1335 rip_neighbor_delete (&p
);
1340 DEFUN (ip_rip_receive_version
,
1341 ip_rip_receive_version_cmd
,
1342 "ip rip receive version (1|2)",
1344 "Routing Information Protocol\n"
1345 "Advertisement reception\n"
1350 struct interface
*ifp
;
1351 struct rip_interface
*ri
;
1353 ifp
= (struct interface
*)vty
->index
;
1357 if (atoi (argv
[0]) == 1)
1359 ri
->ri_receive
= RI_RIP_VERSION_1
;
1362 if (atoi (argv
[0]) == 2)
1364 ri
->ri_receive
= RI_RIP_VERSION_2
;
1370 DEFUN (ip_rip_receive_version_1
,
1371 ip_rip_receive_version_1_cmd
,
1372 "ip rip receive version 1 2",
1374 "Routing Information Protocol\n"
1375 "Advertisement reception\n"
1380 struct interface
*ifp
;
1381 struct rip_interface
*ri
;
1383 ifp
= (struct interface
*)vty
->index
;
1386 /* Version 1 and 2. */
1387 ri
->ri_receive
= RI_RIP_VERSION_1_AND_2
;
1391 DEFUN (ip_rip_receive_version_2
,
1392 ip_rip_receive_version_2_cmd
,
1393 "ip rip receive version 2 1",
1395 "Routing Information Protocol\n"
1396 "Advertisement reception\n"
1401 struct interface
*ifp
;
1402 struct rip_interface
*ri
;
1404 ifp
= (struct interface
*)vty
->index
;
1407 /* Version 1 and 2. */
1408 ri
->ri_receive
= RI_RIP_VERSION_1_AND_2
;
1412 DEFUN (no_ip_rip_receive_version
,
1413 no_ip_rip_receive_version_cmd
,
1414 "no ip rip receive version",
1417 "Routing Information Protocol\n"
1418 "Advertisement reception\n"
1419 "Version control\n")
1421 struct interface
*ifp
;
1422 struct rip_interface
*ri
;
1424 ifp
= (struct interface
*)vty
->index
;
1427 ri
->ri_receive
= RI_RIP_UNSPEC
;
1431 ALIAS (no_ip_rip_receive_version
,
1432 no_ip_rip_receive_version_num_cmd
,
1433 "no ip rip receive version (1|2)",
1436 "Routing Information Protocol\n"
1437 "Advertisement reception\n"
1442 DEFUN (ip_rip_send_version
,
1443 ip_rip_send_version_cmd
,
1444 "ip rip send version (1|2)",
1446 "Routing Information Protocol\n"
1447 "Advertisement transmission\n"
1452 struct interface
*ifp
;
1453 struct rip_interface
*ri
;
1455 ifp
= (struct interface
*)vty
->index
;
1459 if (atoi (argv
[0]) == 1)
1461 ri
->ri_send
= RI_RIP_VERSION_1
;
1464 if (atoi (argv
[0]) == 2)
1466 ri
->ri_send
= RI_RIP_VERSION_2
;
1472 DEFUN (ip_rip_send_version_1
,
1473 ip_rip_send_version_1_cmd
,
1474 "ip rip send version 1 2",
1476 "Routing Information Protocol\n"
1477 "Advertisement transmission\n"
1482 struct interface
*ifp
;
1483 struct rip_interface
*ri
;
1485 ifp
= (struct interface
*)vty
->index
;
1488 /* Version 1 and 2. */
1489 ri
->ri_send
= RI_RIP_VERSION_1_AND_2
;
1493 DEFUN (ip_rip_send_version_2
,
1494 ip_rip_send_version_2_cmd
,
1495 "ip rip send version 2 1",
1497 "Routing Information Protocol\n"
1498 "Advertisement transmission\n"
1503 struct interface
*ifp
;
1504 struct rip_interface
*ri
;
1506 ifp
= (struct interface
*)vty
->index
;
1509 /* Version 1 and 2. */
1510 ri
->ri_send
= RI_RIP_VERSION_1_AND_2
;
1514 DEFUN (no_ip_rip_send_version
,
1515 no_ip_rip_send_version_cmd
,
1516 "no ip rip send version",
1519 "Routing Information Protocol\n"
1520 "Advertisement transmission\n"
1521 "Version control\n")
1523 struct interface
*ifp
;
1524 struct rip_interface
*ri
;
1526 ifp
= (struct interface
*)vty
->index
;
1529 ri
->ri_send
= RI_RIP_UNSPEC
;
1533 ALIAS (no_ip_rip_send_version
,
1534 no_ip_rip_send_version_num_cmd
,
1535 "no ip rip send version (1|2)",
1538 "Routing Information Protocol\n"
1539 "Advertisement transmission\n"
1544 DEFUN (ip_rip_authentication_mode
,
1545 ip_rip_authentication_mode_cmd
,
1546 "ip rip authentication mode (md5|text)",
1548 "Routing Information Protocol\n"
1549 "Authentication control\n"
1550 "Authentication mode\n"
1551 "Keyed message digest\n"
1552 "Clear text authentication\n")
1554 struct interface
*ifp
;
1555 struct rip_interface
*ri
;
1558 ifp
= (struct interface
*)vty
->index
;
1561 if ( (argc
< 1) || (argc
> 2) )
1563 vty_out (vty
, "incorrect argument count%s", VTY_NEWLINE
);
1567 if (strncmp ("md5", argv
[0], strlen (argv
[0])) == 0)
1568 auth_type
= RIP_AUTH_MD5
;
1569 else if (strncmp ("text", argv
[0], strlen (argv
[0])) == 0)
1570 auth_type
= RIP_AUTH_SIMPLE_PASSWORD
;
1573 vty_out (vty
, "mode should be md5 or text%s", VTY_NEWLINE
);
1579 ri
->auth_type
= auth_type
;
1583 if ( (argc
== 2) && (auth_type
!= RIP_AUTH_MD5
) )
1585 vty_out (vty
, "auth length argument only valid for md5%s", VTY_NEWLINE
);
1589 if (strncmp ("r", argv
[1], 1) == 0)
1590 ri
->md5_auth_len
= RIP_AUTH_MD5_SIZE
;
1591 else if (strncmp ("o", argv
[1], 1) == 0)
1592 ri
->md5_auth_len
= RIP_AUTH_MD5_COMPAT_SIZE
;
1596 ri
->auth_type
= auth_type
;
1601 ALIAS (ip_rip_authentication_mode
,
1602 ip_rip_authentication_mode_authlen_cmd
,
1603 "ip rip authentication mode (md5|text) auth-length (rfc|old-ripd)",
1605 "Routing Information Protocol\n"
1606 "Authentication control\n"
1607 "Authentication mode\n"
1608 "Keyed message digest\n"
1609 "Clear text authentication\n"
1610 "MD5 authentication data length\n"
1612 "Old ripd compatible\n")
1614 DEFUN (no_ip_rip_authentication_mode
,
1615 no_ip_rip_authentication_mode_cmd
,
1616 "no ip rip authentication mode",
1619 "Routing Information Protocol\n"
1620 "Authentication control\n"
1621 "Authentication mode\n")
1623 struct interface
*ifp
;
1624 struct rip_interface
*ri
;
1626 ifp
= (struct interface
*)vty
->index
;
1629 ri
->auth_type
= RIP_NO_AUTH
;
1630 ri
->md5_auth_len
= RIP_AUTH_MD5_COMPAT_SIZE
;
1635 ALIAS (no_ip_rip_authentication_mode
,
1636 no_ip_rip_authentication_mode_type_cmd
,
1637 "no ip rip authentication mode (md5|text)",
1640 "Routing Information Protocol\n"
1641 "Authentication control\n"
1642 "Authentication mode\n"
1643 "Keyed message digest\n"
1644 "Clear text authentication\n")
1646 ALIAS (no_ip_rip_authentication_mode
,
1647 no_ip_rip_authentication_mode_type_authlen_cmd
,
1648 "no ip rip authentication mode (md5|text) auth-length (rfc|old-ripd)",
1651 "Routing Information Protocol\n"
1652 "Authentication control\n"
1653 "Authentication mode\n"
1654 "Keyed message digest\n"
1655 "Clear text authentication\n"
1656 "MD5 authentication data length\n"
1658 "Old ripd compatible\n")
1660 DEFUN (ip_rip_authentication_string
,
1661 ip_rip_authentication_string_cmd
,
1662 "ip rip authentication string LINE",
1664 "Routing Information Protocol\n"
1665 "Authentication control\n"
1666 "Authentication string\n"
1667 "Authentication string\n")
1669 struct interface
*ifp
;
1670 struct rip_interface
*ri
;
1672 ifp
= (struct interface
*)vty
->index
;
1675 if (strlen (argv
[0]) > 16)
1677 vty_out (vty
, "%% RIPv2 authentication string must be shorter than 16%s",
1684 vty_out (vty
, "%% key-chain configuration exists%s", VTY_NEWLINE
);
1689 free (ri
->auth_str
);
1691 ri
->auth_str
= strdup (argv
[0]);
1696 DEFUN (no_ip_rip_authentication_string
,
1697 no_ip_rip_authentication_string_cmd
,
1698 "no ip rip authentication string",
1701 "Routing Information Protocol\n"
1702 "Authentication control\n"
1703 "Authentication string\n")
1705 struct interface
*ifp
;
1706 struct rip_interface
*ri
;
1708 ifp
= (struct interface
*)vty
->index
;
1712 free (ri
->auth_str
);
1714 ri
->auth_str
= NULL
;
1719 ALIAS (no_ip_rip_authentication_string
,
1720 no_ip_rip_authentication_string2_cmd
,
1721 "no ip rip authentication string LINE",
1724 "Routing Information Protocol\n"
1725 "Authentication control\n"
1726 "Authentication string\n"
1727 "Authentication string\n")
1729 DEFUN (ip_rip_authentication_key_chain
,
1730 ip_rip_authentication_key_chain_cmd
,
1731 "ip rip authentication key-chain LINE",
1733 "Routing Information Protocol\n"
1734 "Authentication control\n"
1735 "Authentication key-chain\n"
1736 "name of key-chain\n")
1738 struct interface
*ifp
;
1739 struct rip_interface
*ri
;
1741 ifp
= (struct interface
*) vty
->index
;
1746 vty_out (vty
, "%% authentication string configuration exists%s",
1752 free (ri
->key_chain
);
1754 ri
->key_chain
= strdup (argv
[0]);
1759 DEFUN (no_ip_rip_authentication_key_chain
,
1760 no_ip_rip_authentication_key_chain_cmd
,
1761 "no ip rip authentication key-chain",
1764 "Routing Information Protocol\n"
1765 "Authentication control\n"
1766 "Authentication key-chain\n")
1768 struct interface
*ifp
;
1769 struct rip_interface
*ri
;
1771 ifp
= (struct interface
*) vty
->index
;
1775 free (ri
->key_chain
);
1777 ri
->key_chain
= NULL
;
1782 ALIAS (no_ip_rip_authentication_key_chain
,
1783 no_ip_rip_authentication_key_chain2_cmd
,
1784 "no ip rip authentication key-chain LINE",
1787 "Routing Information Protocol\n"
1788 "Authentication control\n"
1789 "Authentication key-chain\n"
1790 "name of key-chain\n")
1792 /* CHANGED: ip rip split-horizon
1793 Cisco and Zebra's command is
1796 DEFUN (ip_rip_split_horizon
,
1797 ip_rip_split_horizon_cmd
,
1798 "ip rip split-horizon",
1800 "Routing Information Protocol\n"
1801 "Perform split horizon\n")
1803 struct interface
*ifp
;
1804 struct rip_interface
*ri
;
1809 ri
->split_horizon
= RIP_SPLIT_HORIZON
;
1813 DEFUN (ip_rip_split_horizon_poisoned_reverse
,
1814 ip_rip_split_horizon_poisoned_reverse_cmd
,
1815 "ip rip split-horizon poisoned-reverse",
1817 "Routing Information Protocol\n"
1818 "Perform split horizon\n"
1819 "With poisoned-reverse\n")
1821 struct interface
*ifp
;
1822 struct rip_interface
*ri
;
1827 ri
->split_horizon
= RIP_SPLIT_HORIZON_POISONED_REVERSE
;
1831 /* CHANGED: no ip rip split-horizon
1832 Cisco and Zebra's command is
1835 DEFUN (no_ip_rip_split_horizon
,
1836 no_ip_rip_split_horizon_cmd
,
1837 "no ip rip split-horizon",
1840 "Routing Information Protocol\n"
1841 "Perform split horizon\n")
1843 struct interface
*ifp
;
1844 struct rip_interface
*ri
;
1849 ri
->split_horizon
= RIP_NO_SPLIT_HORIZON
;
1853 DEFUN (no_ip_rip_split_horizon_poisoned_reverse
,
1854 no_ip_rip_split_horizon_poisoned_reverse_cmd
,
1855 "no ip rip split-horizon poisoned-reverse",
1858 "Routing Information Protocol\n"
1859 "Perform split horizon\n"
1860 "With poisoned-reverse\n")
1862 struct interface
*ifp
;
1863 struct rip_interface
*ri
;
1868 switch( ri
->split_horizon
)
1870 case RIP_SPLIT_HORIZON_POISONED_REVERSE
:
1871 ri
->split_horizon
= RIP_SPLIT_HORIZON
;
1879 DEFUN (rip_passive_interface
,
1880 rip_passive_interface_cmd
,
1881 "passive-interface (IFNAME|default)",
1882 "Suppress routing updates on an interface\n"
1884 "default for all interfaces\n")
1886 const char *ifname
= argv
[0];
1888 if (!strcmp(ifname
,"default")) {
1889 passive_default
= 1;
1890 rip_passive_nondefault_clean();
1893 if (passive_default
)
1894 return rip_passive_nondefault_unset (vty
, ifname
);
1896 return rip_passive_nondefault_set (vty
, ifname
);
1899 DEFUN (no_rip_passive_interface
,
1900 no_rip_passive_interface_cmd
,
1901 "no passive-interface (IFNAME|default)",
1903 "Suppress routing updates on an interface\n"
1905 "default for all interfaces\n")
1907 const char *ifname
= argv
[0];
1909 if (!strcmp(ifname
,"default")) {
1910 passive_default
= 0;
1911 rip_passive_nondefault_clean();
1914 if (passive_default
)
1915 return rip_passive_nondefault_set (vty
, ifname
);
1917 return rip_passive_nondefault_unset (vty
, ifname
);
1920 /* Write rip configuration of each interface. */
1922 rip_interface_config_write (struct vty
*vty
)
1924 struct listnode
*node
;
1925 struct interface
*ifp
;
1927 for (ALL_LIST_ELEMENTS_RO (iflist
, node
, ifp
))
1929 struct rip_interface
*ri
;
1933 /* Do not display the interface if there is no
1934 * configuration about it.
1937 (ri
->split_horizon
== ri
->split_horizon_default
) &&
1938 (ri
->ri_send
== RI_RIP_UNSPEC
) &&
1939 (ri
->ri_receive
== RI_RIP_UNSPEC
) &&
1940 (ri
->auth_type
!= RIP_AUTH_MD5
) &&
1941 (ri
->md5_auth_len
!= RIP_AUTH_MD5_SIZE
) &&
1946 vty_out (vty
, "interface %s%s", ifp
->name
,
1950 vty_out (vty
, " description %s%s", ifp
->desc
,
1953 /* Split horizon. */
1954 if (ri
->split_horizon
!= ri
->split_horizon_default
)
1956 switch (ri
->split_horizon
) {
1957 case RIP_SPLIT_HORIZON
:
1958 vty_out (vty
, " ip rip split-horizon%s", VTY_NEWLINE
);
1960 case RIP_SPLIT_HORIZON_POISONED_REVERSE
:
1961 vty_out (vty
, " ip rip split-horizon poisoned-reverse%s",
1964 case RIP_NO_SPLIT_HORIZON
:
1966 vty_out (vty
, " no ip rip split-horizon%s", VTY_NEWLINE
);
1971 /* RIP version setting. */
1972 if (ri
->ri_send
!= RI_RIP_UNSPEC
)
1973 vty_out (vty
, " ip rip send version %s%s",
1974 lookup (ri_version_msg
, ri
->ri_send
),
1977 if (ri
->ri_receive
!= RI_RIP_UNSPEC
)
1978 vty_out (vty
, " ip rip receive version %s%s",
1979 lookup (ri_version_msg
, ri
->ri_receive
),
1982 /* RIP authentication. */
1983 if (ri
->auth_type
== RIP_AUTH_SIMPLE_PASSWORD
)
1984 vty_out (vty
, " ip rip authentication mode text%s", VTY_NEWLINE
);
1986 if (ri
->auth_type
== RIP_AUTH_MD5
)
1988 vty_out (vty
, " ip rip authentication mode md5");
1989 if (ri
->md5_auth_len
== RIP_AUTH_MD5_COMPAT_SIZE
)
1990 vty_out (vty
, " auth-length old-ripd");
1992 vty_out (vty
, " auth-length rfc");
1993 vty_out (vty
, "%s", VTY_NEWLINE
);
1997 vty_out (vty
, " ip rip authentication string %s%s",
1998 ri
->auth_str
, VTY_NEWLINE
);
2001 vty_out (vty
, " ip rip authentication key-chain %s%s",
2002 ri
->key_chain
, VTY_NEWLINE
);
2004 vty_out (vty
, "!%s", VTY_NEWLINE
);
2010 config_write_rip_network (struct vty
*vty
, int config_mode
)
2014 struct route_node
*node
;
2016 /* Network type RIP enable interface statement. */
2017 for (node
= route_top (rip_enable_network
); node
; node
= route_next (node
))
2019 vty_out (vty
, "%s%s/%d%s",
2020 config_mode
? " network " : " ",
2021 inet_ntoa (node
->p
.u
.prefix4
),
2025 /* Interface name RIP enable statement. */
2026 for (i
= 0; i
< vector_active (rip_enable_interface
); i
++)
2027 if ((ifname
= vector_slot (rip_enable_interface
, i
)) != NULL
)
2028 vty_out (vty
, "%s%s%s",
2029 config_mode
? " network " : " ",
2033 /* RIP neighbors listing. */
2034 for (node
= route_top (rip
->neighbor
); node
; node
= route_next (node
))
2036 vty_out (vty
, "%s%s%s",
2037 config_mode
? " neighbor " : " ",
2038 inet_ntoa (node
->p
.u
.prefix4
),
2041 /* RIP passive interface listing. */
2043 if (passive_default
)
2044 vty_out (vty
, " passive-interface default%s", VTY_NEWLINE
);
2045 for (i
= 0; i
< vector_active (Vrip_passive_nondefault
); i
++)
2046 if ((ifname
= vector_slot (Vrip_passive_nondefault
, i
)) != NULL
)
2047 vty_out (vty
, " %spassive-interface %s%s",
2048 (passive_default
? "no " : ""), ifname
, VTY_NEWLINE
);
2054 static struct cmd_node interface_node
=
2061 /* Called when interface structure allocated. */
2063 rip_interface_new_hook (struct interface
*ifp
)
2065 ifp
->info
= rip_interface_new ();
2069 /* Called when interface structure deleted. */
2071 rip_interface_delete_hook (struct interface
*ifp
)
2073 XFREE (MTYPE_RIP_INTERFACE
, ifp
->info
);
2078 /* Allocate and initialize interface vector. */
2082 /* Default initial size of interface vector. */
2084 if_add_hook (IF_NEW_HOOK
, rip_interface_new_hook
);
2085 if_add_hook (IF_DELETE_HOOK
, rip_interface_delete_hook
);
2087 /* RIP network init. */
2088 rip_enable_interface
= vector_init (1);
2089 rip_enable_network
= route_table_init ();
2091 /* RIP passive interface. */
2092 Vrip_passive_nondefault
= vector_init (1);
2094 /* Install interface node. */
2095 install_node (&interface_node
, rip_interface_config_write
);
2097 /* Install commands. */
2098 install_element (CONFIG_NODE
, &interface_cmd
);
2099 install_element (CONFIG_NODE
, &no_interface_cmd
);
2100 install_default (INTERFACE_NODE
);
2101 install_element (INTERFACE_NODE
, &interface_desc_cmd
);
2102 install_element (INTERFACE_NODE
, &no_interface_desc_cmd
);
2103 install_element (RIP_NODE
, &rip_network_cmd
);
2104 install_element (RIP_NODE
, &no_rip_network_cmd
);
2105 install_element (RIP_NODE
, &rip_neighbor_cmd
);
2106 install_element (RIP_NODE
, &no_rip_neighbor_cmd
);
2108 install_element (RIP_NODE
, &rip_passive_interface_cmd
);
2109 install_element (RIP_NODE
, &no_rip_passive_interface_cmd
);
2111 install_element (INTERFACE_NODE
, &ip_rip_send_version_cmd
);
2112 install_element (INTERFACE_NODE
, &ip_rip_send_version_1_cmd
);
2113 install_element (INTERFACE_NODE
, &ip_rip_send_version_2_cmd
);
2114 install_element (INTERFACE_NODE
, &no_ip_rip_send_version_cmd
);
2115 install_element (INTERFACE_NODE
, &no_ip_rip_send_version_num_cmd
);
2117 install_element (INTERFACE_NODE
, &ip_rip_receive_version_cmd
);
2118 install_element (INTERFACE_NODE
, &ip_rip_receive_version_1_cmd
);
2119 install_element (INTERFACE_NODE
, &ip_rip_receive_version_2_cmd
);
2120 install_element (INTERFACE_NODE
, &no_ip_rip_receive_version_cmd
);
2121 install_element (INTERFACE_NODE
, &no_ip_rip_receive_version_num_cmd
);
2123 install_element (INTERFACE_NODE
, &ip_rip_authentication_mode_cmd
);
2124 install_element (INTERFACE_NODE
, &ip_rip_authentication_mode_authlen_cmd
);
2125 install_element (INTERFACE_NODE
, &no_ip_rip_authentication_mode_cmd
);
2126 install_element (INTERFACE_NODE
, &no_ip_rip_authentication_mode_type_cmd
);
2127 install_element (INTERFACE_NODE
, &no_ip_rip_authentication_mode_type_authlen_cmd
);
2129 install_element (INTERFACE_NODE
, &ip_rip_authentication_key_chain_cmd
);
2130 install_element (INTERFACE_NODE
, &no_ip_rip_authentication_key_chain_cmd
);
2131 install_element (INTERFACE_NODE
, &no_ip_rip_authentication_key_chain2_cmd
);
2133 install_element (INTERFACE_NODE
, &ip_rip_authentication_string_cmd
);
2134 install_element (INTERFACE_NODE
, &no_ip_rip_authentication_string_cmd
);
2135 install_element (INTERFACE_NODE
, &no_ip_rip_authentication_string2_cmd
);
2137 install_element (INTERFACE_NODE
, &ip_rip_split_horizon_cmd
);
2138 install_element (INTERFACE_NODE
, &ip_rip_split_horizon_poisoned_reverse_cmd
);
2139 install_element (INTERFACE_NODE
, &no_ip_rip_split_horizon_cmd
);
2140 install_element (INTERFACE_NODE
, &no_ip_rip_split_horizon_poisoned_reverse_cmd
);