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"},
61 extern struct zebra_privs_t ripd_privs
;
63 /* RIP enabled network vector. */
64 vector rip_enable_interface
;
66 /* RIP enabled interface table. */
67 struct route_table
*rip_enable_network
;
69 /* Vector to store passive-interface name. */
70 static int passive_default
; /* are we in passive-interface default mode? */
71 vector Vrip_passive_nondefault
;
73 /* Join to the RIP version 2 multicast group. */
75 ipv4_multicast_join (int sock
,
82 ret
= setsockopt_multicast_ipv4 (sock
,
89 zlog (NULL
, LOG_INFO
, "can't setsockopt IP_ADD_MEMBERSHIP %s",
90 safe_strerror (errno
));
95 /* Leave from the RIP version 2 multicast group. */
97 ipv4_multicast_leave (int sock
,
100 unsigned int ifindex
)
104 ret
= setsockopt_multicast_ipv4 (sock
,
111 zlog (NULL
, LOG_INFO
, "can't setsockopt IP_DROP_MEMBERSHIP");
116 /* Allocate new RIP's interface configuration. */
117 static struct rip_interface
*
118 rip_interface_new (void)
120 struct rip_interface
*ri
;
122 ri
= XMALLOC (MTYPE_RIP_INTERFACE
, sizeof (struct rip_interface
));
123 memset (ri
, 0, sizeof (struct rip_interface
));
125 /* Default authentication type is simple password for Cisco
127 ri
->auth_type
= RIP_NO_AUTH
;
128 ri
->md5_auth_len
= RIP_AUTH_MD5_COMPAT_SIZE
;
130 /* Set default split-horizon behavior. If the interface is Frame
131 Relay or SMDS is enabled, the default value for split-horizon is
132 off. But currently Zebra does detect Frame Relay or SMDS
133 interface. So all interface is set to split horizon. */
134 ri
->split_horizon_default
= RIP_SPLIT_HORIZON
;
135 ri
->split_horizon
= ri
->split_horizon_default
;
141 rip_interface_multicast_set (int sock
, struct connected
*connected
)
145 assert (connected
!= NULL
);
147 addr
= CONNECTED_ID(connected
)->u
.prefix4
;
149 if (setsockopt_multicast_ipv4 (sock
, IP_MULTICAST_IF
, addr
, 0,
150 connected
->ifp
->ifindex
) < 0)
152 zlog_warn ("Can't setsockopt IP_MULTICAST_IF on fd %d to "
153 "source address %s for interface %s",
154 sock
, inet_ntoa(addr
),
155 connected
->ifp
->name
);
161 /* Send RIP request packet to specified interface. */
163 rip_request_interface_send (struct interface
*ifp
, u_char version
)
165 struct sockaddr_in to
;
167 /* RIPv2 support multicast. */
168 if (version
== RIPv2
&& if_is_multicast (ifp
))
171 if (IS_RIP_DEBUG_EVENT
)
172 zlog_debug ("multicast request on %s", ifp
->name
);
174 rip_request_send (NULL
, ifp
, version
, NULL
);
178 /* RIPv1 and non multicast interface. */
179 if (if_is_pointopoint (ifp
) || if_is_broadcast (ifp
))
181 struct listnode
*cnode
, *cnnode
;
182 struct connected
*connected
;
184 if (IS_RIP_DEBUG_EVENT
)
185 zlog_debug ("broadcast request to %s", ifp
->name
);
187 for (ALL_LIST_ELEMENTS (ifp
->connected
, cnode
, cnnode
, connected
))
189 if (connected
->address
->family
== AF_INET
)
191 memset (&to
, 0, sizeof (struct sockaddr_in
));
192 to
.sin_port
= htons (RIP_PORT_DEFAULT
);
193 if (connected
->destination
)
194 /* use specified broadcast or peer destination addr */
195 to
.sin_addr
= connected
->destination
->u
.prefix4
;
196 else if (connected
->address
->prefixlen
< IPV4_MAX_PREFIXLEN
)
197 /* calculate the appropriate broadcast address */
199 ipv4_broadcast_addr(connected
->address
->u
.prefix4
.s_addr
,
200 connected
->address
->prefixlen
);
202 /* do not know where to send the packet */
205 if (IS_RIP_DEBUG_EVENT
)
206 zlog_debug ("SEND request to %s", inet_ntoa (to
.sin_addr
));
208 rip_request_send (&to
, ifp
, version
, connected
);
214 /* This will be executed when interface goes up. */
216 rip_request_interface (struct interface
*ifp
)
218 struct rip_interface
*ri
;
220 /* In default ripd doesn't send RIP_REQUEST to the loopback interface. */
221 if (if_is_loopback (ifp
))
224 /* If interface is down, don't send RIP packet. */
225 if (! if_is_operative (ifp
))
228 /* Fetch RIP interface information. */
232 /* If there is no version configuration in the interface,
233 use rip's version setting. */
235 int vsend
= ((ri
->ri_send
== RI_RIP_UNSPEC
) ?
236 rip
->version_send
: ri
->ri_send
);
238 rip_request_interface_send (ifp
, RIPv1
);
240 rip_request_interface_send (ifp
, RIPv2
);
244 /* Send RIP request to the neighbor. */
246 rip_request_neighbor (struct in_addr addr
)
248 struct sockaddr_in to
;
250 memset (&to
, 0, sizeof (struct sockaddr_in
));
251 to
.sin_port
= htons (RIP_PORT_DEFAULT
);
254 rip_request_send (&to
, NULL
, rip
->version_send
, NULL
);
257 /* Request routes at all interfaces. */
259 rip_request_neighbor_all (void)
261 struct route_node
*rp
;
266 if (IS_RIP_DEBUG_EVENT
)
267 zlog_debug ("request to the all neighbor");
269 /* Send request to all neighbor. */
270 for (rp
= route_top (rip
->neighbor
); rp
; rp
= route_next (rp
))
272 rip_request_neighbor (rp
->p
.u
.prefix4
);
275 /* Multicast packet receive socket. */
277 rip_multicast_join (struct interface
*ifp
, int sock
)
279 struct listnode
*cnode
;
280 struct connected
*ifc
;
282 if (if_is_operative (ifp
) && if_is_multicast (ifp
))
284 if (IS_RIP_DEBUG_EVENT
)
285 zlog_debug ("multicast join at %s", ifp
->name
);
287 for (ALL_LIST_ELEMENTS_RO (ifp
->connected
, cnode
, ifc
))
289 struct prefix_ipv4
*p
;
290 struct in_addr group
;
292 p
= (struct prefix_ipv4
*) ifc
->address
;
294 if (p
->family
!= AF_INET
)
297 group
.s_addr
= htonl (INADDR_RIP_GROUP
);
298 if (ipv4_multicast_join (sock
, group
, p
->prefix
, ifp
->ifindex
) < 0)
307 /* Leave from multicast group. */
309 rip_multicast_leave (struct interface
*ifp
, int sock
)
311 struct listnode
*cnode
;
312 struct connected
*connected
;
314 if (if_is_up (ifp
) && if_is_multicast (ifp
))
316 if (IS_RIP_DEBUG_EVENT
)
317 zlog_debug ("multicast leave from %s", ifp
->name
);
319 for (ALL_LIST_ELEMENTS_RO (ifp
->connected
, cnode
, connected
))
321 struct prefix_ipv4
*p
;
322 struct in_addr group
;
324 p
= (struct prefix_ipv4
*) connected
->address
;
326 if (p
->family
!= AF_INET
)
329 group
.s_addr
= htonl (INADDR_RIP_GROUP
);
330 if (ipv4_multicast_leave (sock
, group
, p
->prefix
, ifp
->ifindex
) == 0)
336 /* Is there and address on interface that I could use ? */
338 rip_if_ipv4_address_check (struct interface
*ifp
)
341 struct connected
*connected
;
344 for (ALL_LIST_ELEMENTS_RO (ifp
->connected
, nn
, connected
))
348 p
= connected
->address
;
350 if (p
->family
== AF_INET
)
360 /* Does this address belongs to me ? */
362 if_check_address (struct in_addr addr
)
364 struct listnode
*node
;
365 struct interface
*ifp
;
367 for (ALL_LIST_ELEMENTS_RO (iflist
, node
, ifp
))
369 struct listnode
*cnode
;
370 struct connected
*connected
;
372 for (ALL_LIST_ELEMENTS_RO (ifp
->connected
, cnode
, connected
))
374 struct prefix_ipv4
*p
;
376 p
= (struct prefix_ipv4
*) connected
->address
;
378 if (p
->family
!= AF_INET
)
381 if (IPV4_ADDR_CMP (&p
->prefix
, &addr
) == 0)
388 /* Inteface link down message processing. */
390 rip_interface_down (int command
, struct zclient
*zclient
, zebra_size_t length
)
392 struct interface
*ifp
;
397 /* zebra_interface_state_read() updates interface structure in
399 ifp
= zebra_interface_state_read(s
);
406 if (IS_RIP_DEBUG_ZEBRA
)
407 zlog_debug ("interface %s index %d flags %ld metric %d mtu %d is down",
408 ifp
->name
, ifp
->ifindex
, ifp
->flags
, ifp
->metric
, ifp
->mtu
);
413 /* Inteface link up message processing */
415 rip_interface_up (int command
, struct zclient
*zclient
, zebra_size_t length
)
417 struct interface
*ifp
;
419 /* zebra_interface_state_read () updates interface structure in
421 ifp
= zebra_interface_state_read (zclient
->ibuf
);
426 if (IS_RIP_DEBUG_ZEBRA
)
427 zlog_debug ("interface %s index %d flags %ld metric %d mtu %d is up",
428 ifp
->name
, ifp
->ifindex
, ifp
->flags
, ifp
->metric
, ifp
->mtu
);
430 /* Check if this interface is RIP enabled or not.*/
431 rip_enable_apply (ifp
);
433 /* Check for a passive interface */
434 rip_passive_interface_apply (ifp
);
436 /* Apply distribute list to the all interface. */
437 rip_distribute_update_interface (ifp
);
442 /* Inteface addition message from zebra. */
444 rip_interface_add (int command
, struct zclient
*zclient
, zebra_size_t length
)
446 struct interface
*ifp
;
448 ifp
= zebra_interface_add_read (zclient
->ibuf
);
450 if (IS_RIP_DEBUG_ZEBRA
)
451 zlog_debug ("interface add %s index %d flags %ld metric %d mtu %d",
452 ifp
->name
, ifp
->ifindex
, ifp
->flags
, 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
,
475 struct interface
*ifp
;
480 /* zebra_interface_state_read() updates interface structure in iflist */
481 ifp
= zebra_interface_state_read(s
);
486 if (if_is_up (ifp
)) {
490 zlog_info("interface delete %s index %d flags %ld metric %d mtu %d",
491 ifp
->name
, ifp
->ifindex
, ifp
->flags
, ifp
->metric
, ifp
->mtu
);
493 /* To support pseudo interface do not free interface structure. */
494 /* if_delete(ifp); */
495 ifp
->ifindex
= IFINDEX_INTERNAL
;
501 rip_interface_clean (void)
503 struct listnode
*node
;
504 struct interface
*ifp
;
505 struct rip_interface
*ri
;
507 for (ALL_LIST_ELEMENTS_RO (iflist
, node
, ifp
))
511 ri
->enable_network
= 0;
512 ri
->enable_interface
= 0;
517 thread_cancel (ri
->t_wakeup
);
524 rip_interface_reset (void)
526 struct listnode
*node
;
527 struct interface
*ifp
;
528 struct rip_interface
*ri
;
530 for (ALL_LIST_ELEMENTS_RO (iflist
, node
, ifp
))
534 ri
->enable_network
= 0;
535 ri
->enable_interface
= 0;
538 ri
->ri_send
= RI_RIP_UNSPEC
;
539 ri
->ri_receive
= RI_RIP_UNSPEC
;
541 ri
->auth_type
= RIP_NO_AUTH
;
550 free (ri
->key_chain
);
551 ri
->key_chain
= NULL
;
554 ri
->split_horizon
= RIP_NO_SPLIT_HORIZON
;
555 ri
->split_horizon_default
= RIP_NO_SPLIT_HORIZON
;
557 ri
->list
[RIP_FILTER_IN
] = NULL
;
558 ri
->list
[RIP_FILTER_OUT
] = NULL
;
560 ri
->prefix
[RIP_FILTER_IN
] = NULL
;
561 ri
->prefix
[RIP_FILTER_OUT
] = NULL
;
565 thread_cancel (ri
->t_wakeup
);
569 ri
->recv_badpackets
= 0;
570 ri
->recv_badroutes
= 0;
571 ri
->sent_updates
= 0;
578 rip_if_down(struct interface
*ifp
)
580 struct route_node
*rp
;
581 struct rip_info
*rinfo
;
582 struct rip_interface
*ri
= NULL
;
585 for (rp
= route_top (rip
->table
); rp
; rp
= route_next (rp
))
586 if ((rinfo
= rp
->info
) != NULL
)
588 /* Routes got through this interface. */
589 if (rinfo
->ifindex
== ifp
->ifindex
&&
590 rinfo
->type
== ZEBRA_ROUTE_RIP
&&
591 rinfo
->sub_type
== RIP_ROUTE_RTE
)
593 rip_zebra_ipv4_delete ((struct prefix_ipv4
*) &rp
->p
,
597 rip_redistribute_delete (rinfo
->type
,rinfo
->sub_type
,
598 (struct prefix_ipv4
*)&rp
->p
,
603 /* All redistributed routes but static and system */
604 if ((rinfo
->ifindex
== ifp
->ifindex
) &&
605 /* (rinfo->type != ZEBRA_ROUTE_STATIC) && */
606 (rinfo
->type
!= ZEBRA_ROUTE_SYSTEM
))
607 rip_redistribute_delete (rinfo
->type
,rinfo
->sub_type
,
608 (struct prefix_ipv4
*)&rp
->p
,
618 if (IS_RIP_DEBUG_EVENT
)
619 zlog_debug ("turn off %s", ifp
->name
);
621 /* Leave from multicast group. */
622 rip_multicast_leave (ifp
, rip
->sock
);
630 /* Needed for stop RIP process. */
634 struct interface
*ifp
;
635 struct listnode
*node
, *nnode
;
637 for (ALL_LIST_ELEMENTS (iflist
, node
, nnode
, ifp
))
642 rip_apply_address_add (struct connected
*ifc
)
644 struct prefix_ipv4 address
;
650 if (! if_is_up(ifc
->ifp
))
655 memset (&address
, 0, sizeof (address
));
656 address
.family
= p
->family
;
657 address
.prefix
= p
->u
.prefix4
;
658 address
.prefixlen
= p
->prefixlen
;
659 apply_mask_ipv4(&address
);
661 /* Check if this interface is RIP enabled or not
662 or Check if this address's prefix is RIP enabled */
663 if ((rip_enable_if_lookup(ifc
->ifp
->name
) >= 0) ||
664 (rip_enable_network_lookup2(ifc
) >= 0))
665 rip_redistribute_add(ZEBRA_ROUTE_CONNECT
, RIP_ROUTE_INTERFACE
,
666 &address
, ifc
->ifp
->ifindex
, NULL
, 0, 0);
671 rip_interface_address_add (int command
, struct zclient
*zclient
,
674 struct connected
*ifc
;
677 ifc
= zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_ADD
,
685 if (p
->family
== AF_INET
)
687 if (IS_RIP_DEBUG_ZEBRA
)
688 zlog_debug ("connected address %s/%d is added",
689 inet_ntoa (p
->u
.prefix4
), p
->prefixlen
);
691 rip_enable_apply(ifc
->ifp
);
692 /* Check if this prefix needs to be redistributed */
693 rip_apply_address_add(ifc
);
696 rip_ifaddr_add (ifc
->ifp
, ifc
);
697 #endif /* HAVE_SNMP */
704 rip_apply_address_del (struct connected
*ifc
) {
705 struct prefix_ipv4 address
;
711 if (! if_is_up(ifc
->ifp
))
716 memset (&address
, 0, sizeof (address
));
717 address
.family
= p
->family
;
718 address
.prefix
= p
->u
.prefix4
;
719 address
.prefixlen
= p
->prefixlen
;
720 apply_mask_ipv4(&address
);
722 rip_redistribute_delete(ZEBRA_ROUTE_CONNECT
, RIP_ROUTE_INTERFACE
,
723 &address
, ifc
->ifp
->ifindex
);
727 rip_interface_address_delete (int command
, struct zclient
*zclient
,
730 struct connected
*ifc
;
733 ifc
= zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_DELETE
,
739 if (p
->family
== AF_INET
)
741 if (IS_RIP_DEBUG_ZEBRA
)
742 zlog_debug ("connected address %s/%d is deleted",
743 inet_ntoa (p
->u
.prefix4
), p
->prefixlen
);
746 rip_ifaddr_delete (ifc
->ifp
, ifc
);
747 #endif /* HAVE_SNMP */
749 /* Chech wether this prefix needs to be removed */
750 rip_apply_address_del(ifc
);
754 connected_free (ifc
);
761 /* Check interface is enabled by network statement. */
762 /* Check wether the interface has at least a connected prefix that
763 * is within the ripng_enable_network table. */
765 rip_enable_network_lookup_if (struct interface
*ifp
)
767 struct listnode
*node
, *nnode
;
768 struct connected
*connected
;
769 struct prefix_ipv4 address
;
771 for (ALL_LIST_ELEMENTS (ifp
->connected
, node
, nnode
, connected
))
774 struct route_node
*node
;
776 p
= connected
->address
;
778 if (p
->family
== AF_INET
)
780 address
.family
= AF_INET
;
781 address
.prefix
= p
->u
.prefix4
;
782 address
.prefixlen
= IPV4_MAX_BITLEN
;
784 node
= route_node_match (rip_enable_network
,
785 (struct prefix
*)&address
);
788 route_unlock_node (node
);
796 /* Check wether connected is within the ripng_enable_network table. */
798 rip_enable_network_lookup2 (struct connected
*connected
)
800 struct prefix_ipv4 address
;
803 p
= connected
->address
;
805 if (p
->family
== AF_INET
) {
806 struct route_node
*node
;
808 address
.family
= p
->family
;
809 address
.prefix
= p
->u
.prefix4
;
810 address
.prefixlen
= IPV4_MAX_BITLEN
;
812 /* LPM on p->family, p->u.prefix4/IPV4_MAX_BITLEN within rip_enable_network */
813 node
= route_node_match (rip_enable_network
,
814 (struct prefix
*)&address
);
817 route_unlock_node (node
);
824 /* Add RIP enable network. */
826 rip_enable_network_add (struct prefix
*p
)
828 struct route_node
*node
;
830 node
= route_node_get (rip_enable_network
, p
);
834 route_unlock_node (node
);
838 node
->info
= (char *) "enabled";
840 /* XXX: One should find a better solution than a generic one */
841 rip_enable_apply_all();
846 /* Delete RIP enable network. */
848 rip_enable_network_delete (struct prefix
*p
)
850 struct route_node
*node
;
852 node
= route_node_lookup (rip_enable_network
, p
);
857 /* Unlock info lock. */
858 route_unlock_node (node
);
860 /* Unlock lookup lock. */
861 route_unlock_node (node
);
863 /* XXX: One should find a better solution than a generic one */
864 rip_enable_apply_all ();
871 /* Check interface is enabled by ifname statement. */
873 rip_enable_if_lookup (const char *ifname
)
878 for (i
= 0; i
< vector_active (rip_enable_interface
); i
++)
879 if ((str
= vector_slot (rip_enable_interface
, i
)) != NULL
)
880 if (strcmp (str
, ifname
) == 0)
885 /* Add interface to rip_enable_if. */
887 rip_enable_if_add (const char *ifname
)
891 ret
= rip_enable_if_lookup (ifname
);
895 vector_set (rip_enable_interface
, strdup (ifname
));
897 rip_enable_apply_all(); /* TODOVJ */
902 /* Delete interface from rip_enable_if. */
904 rip_enable_if_delete (const char *ifname
)
909 index
= rip_enable_if_lookup (ifname
);
913 str
= vector_slot (rip_enable_interface
, index
);
915 vector_unset (rip_enable_interface
, index
);
917 rip_enable_apply_all(); /* TODOVJ */
922 /* Join to multicast group and send request to the interface. */
924 rip_interface_wakeup (struct thread
*t
)
926 struct interface
*ifp
;
927 struct rip_interface
*ri
;
930 ifp
= THREAD_ARG (t
);
935 /* Join to multicast group. */
936 if (rip_multicast_join (ifp
, rip
->sock
) < 0)
938 zlog_err ("multicast join failed, interface %s not running", ifp
->name
);
942 /* Set running flag. */
945 /* Send RIP request to the interface. */
946 rip_request_interface (ifp
);
951 int rip_redistribute_check (int);
954 rip_connect_set (struct interface
*ifp
, int set
)
956 struct listnode
*node
, *nnode
;
957 struct connected
*connected
;
958 struct prefix_ipv4 address
;
960 for (ALL_LIST_ELEMENTS (ifp
->connected
, node
, nnode
, connected
))
963 p
= connected
->address
;
965 if (p
->family
!= AF_INET
)
968 address
.family
= AF_INET
;
969 address
.prefix
= p
->u
.prefix4
;
970 address
.prefixlen
= p
->prefixlen
;
971 apply_mask_ipv4 (&address
);
974 /* Check once more wether this prefix is within a "network IF_OR_PREF" one */
975 if ((rip_enable_if_lookup(connected
->ifp
->name
) >= 0) ||
976 (rip_enable_network_lookup2(connected
) >= 0))
977 rip_redistribute_add (ZEBRA_ROUTE_CONNECT
, RIP_ROUTE_INTERFACE
,
978 &address
, connected
->ifp
->ifindex
,
982 rip_redistribute_delete (ZEBRA_ROUTE_CONNECT
, RIP_ROUTE_INTERFACE
,
983 &address
, connected
->ifp
->ifindex
);
984 if (rip_redistribute_check (ZEBRA_ROUTE_CONNECT
))
985 rip_redistribute_add (ZEBRA_ROUTE_CONNECT
, RIP_ROUTE_REDISTRIBUTE
,
986 &address
, connected
->ifp
->ifindex
,
992 /* Update interface status. */
994 rip_enable_apply (struct interface
*ifp
)
997 struct rip_interface
*ri
= NULL
;
999 /* Check interface. */
1000 if (! if_is_operative (ifp
))
1005 /* Check network configuration. */
1006 ret
= rip_enable_network_lookup_if (ifp
);
1008 /* If the interface is matched. */
1010 ri
->enable_network
= 1;
1012 ri
->enable_network
= 0;
1014 /* Check interface name configuration. */
1015 ret
= rip_enable_if_lookup (ifp
->name
);
1017 ri
->enable_interface
= 1;
1019 ri
->enable_interface
= 0;
1021 /* any interface MUST have an IPv4 address */
1022 if ( ! rip_if_ipv4_address_check (ifp
) )
1024 ri
->enable_network
= 0;
1025 ri
->enable_interface
= 0;
1028 /* Update running status of the interface. */
1029 if (ri
->enable_network
|| ri
->enable_interface
)
1032 if (IS_RIP_DEBUG_EVENT
)
1033 zlog_debug ("turn on %s", ifp
->name
);
1035 /* Add interface wake up thread. */
1037 ri
->t_wakeup
= thread_add_timer (master
, rip_interface_wakeup
,
1039 rip_connect_set (ifp
, 1);
1046 /* Might as well clean up the route table as well
1047 * rip_if_down sets to 0 ri->running, and displays "turn off %s"
1051 rip_connect_set (ifp
, 0);
1056 /* Apply network configuration to all interface. */
1058 rip_enable_apply_all ()
1060 struct interface
*ifp
;
1061 struct listnode
*node
, *nnode
;
1063 /* Check each interface. */
1064 for (ALL_LIST_ELEMENTS (iflist
, node
, nnode
, ifp
))
1065 rip_enable_apply (ifp
);
1069 rip_neighbor_lookup (struct sockaddr_in
*from
)
1071 struct prefix_ipv4 p
;
1072 struct route_node
*node
;
1074 memset (&p
, 0, sizeof (struct prefix_ipv4
));
1076 p
.prefix
= from
->sin_addr
;
1077 p
.prefixlen
= IPV4_MAX_BITLEN
;
1079 node
= route_node_lookup (rip
->neighbor
, (struct prefix
*) &p
);
1082 route_unlock_node (node
);
1088 /* Add new RIP neighbor to the neighbor tree. */
1090 rip_neighbor_add (struct prefix_ipv4
*p
)
1092 struct route_node
*node
;
1094 node
= route_node_get (rip
->neighbor
, (struct prefix
*) p
);
1099 node
->info
= rip
->neighbor
;
1104 /* Delete RIP neighbor from the neighbor tree. */
1106 rip_neighbor_delete (struct prefix_ipv4
*p
)
1108 struct route_node
*node
;
1110 /* Lock for look up. */
1111 node
= route_node_lookup (rip
->neighbor
, (struct prefix
*) p
);
1117 /* Unlock lookup lock. */
1118 route_unlock_node (node
);
1120 /* Unlock real neighbor information lock. */
1121 route_unlock_node (node
);
1126 /* Clear all network and neighbor configuration. */
1128 rip_clean_network ()
1132 struct route_node
*rn
;
1134 /* rip_enable_network. */
1135 for (rn
= route_top (rip_enable_network
); rn
; rn
= route_next (rn
))
1139 route_unlock_node (rn
);
1142 /* rip_enable_interface. */
1143 for (i
= 0; i
< vector_active (rip_enable_interface
); i
++)
1144 if ((str
= vector_slot (rip_enable_interface
, i
)) != NULL
)
1147 vector_slot (rip_enable_interface
, i
) = NULL
;
1151 /* Utility function for looking up passive interface settings. */
1153 rip_passive_nondefault_lookup (const char *ifname
)
1158 for (i
= 0; i
< vector_active (Vrip_passive_nondefault
); i
++)
1159 if ((str
= vector_slot (Vrip_passive_nondefault
, i
)) != NULL
)
1160 if (strcmp (str
, ifname
) == 0)
1166 rip_passive_interface_apply (struct interface
*ifp
)
1168 struct rip_interface
*ri
;
1172 ri
->passive
= ((rip_passive_nondefault_lookup (ifp
->name
) < 0) ?
1173 passive_default
: !passive_default
);
1175 if (IS_RIP_DEBUG_ZEBRA
)
1176 zlog_debug ("interface %s: passive = %d",ifp
->name
,ri
->passive
);
1180 rip_passive_interface_apply_all (void)
1182 struct interface
*ifp
;
1183 struct listnode
*node
, *nnode
;
1185 for (ALL_LIST_ELEMENTS (iflist
, node
, nnode
, ifp
))
1186 rip_passive_interface_apply (ifp
);
1189 /* Passive interface. */
1191 rip_passive_nondefault_set (struct vty
*vty
, const char *ifname
)
1193 if (rip_passive_nondefault_lookup (ifname
) >= 0)
1196 vector_set (Vrip_passive_nondefault
, strdup (ifname
));
1198 rip_passive_interface_apply_all ();
1204 rip_passive_nondefault_unset (struct vty
*vty
, const char *ifname
)
1209 i
= rip_passive_nondefault_lookup (ifname
);
1213 str
= vector_slot (Vrip_passive_nondefault
, i
);
1215 vector_unset (Vrip_passive_nondefault
, i
);
1217 rip_passive_interface_apply_all ();
1222 /* Free all configured RIP passive-interface settings. */
1224 rip_passive_nondefault_clean (void)
1229 for (i
= 0; i
< vector_active (Vrip_passive_nondefault
); i
++)
1230 if ((str
= vector_slot (Vrip_passive_nondefault
, i
)) != NULL
)
1233 vector_slot (Vrip_passive_nondefault
, i
) = NULL
;
1235 rip_passive_interface_apply_all ();
1238 /* RIP enable network or interface configuration. */
1241 "network (A.B.C.D/M|WORD)",
1242 "Enable routing on an IP network\n"
1243 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1247 struct prefix_ipv4 p
;
1249 ret
= str2prefix_ipv4 (argv
[0], &p
);
1252 ret
= rip_enable_network_add ((struct prefix
*) &p
);
1254 ret
= rip_enable_if_add (argv
[0]);
1258 vty_out (vty
, "There is a same network configuration %s%s", argv
[0],
1266 /* RIP enable network or interface configuration. */
1267 DEFUN (no_rip_network
,
1269 "no network (A.B.C.D/M|WORD)",
1271 "Enable routing on an IP network\n"
1272 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1276 struct prefix_ipv4 p
;
1278 ret
= str2prefix_ipv4 (argv
[0], &p
);
1281 ret
= rip_enable_network_delete ((struct prefix
*) &p
);
1283 ret
= rip_enable_if_delete (argv
[0]);
1287 vty_out (vty
, "Can't find network configuration %s%s", argv
[0],
1295 /* RIP neighbor configuration set. */
1296 DEFUN (rip_neighbor
,
1299 "Specify a neighbor router\n"
1300 "Neighbor address\n")
1303 struct prefix_ipv4 p
;
1305 ret
= str2prefix_ipv4 (argv
[0], &p
);
1309 vty_out (vty
, "Please specify address by A.B.C.D%s", VTY_NEWLINE
);
1313 rip_neighbor_add (&p
);
1318 /* RIP neighbor configuration unset. */
1319 DEFUN (no_rip_neighbor
,
1320 no_rip_neighbor_cmd
,
1321 "no neighbor A.B.C.D",
1323 "Specify a neighbor router\n"
1324 "Neighbor address\n")
1327 struct prefix_ipv4 p
;
1329 ret
= str2prefix_ipv4 (argv
[0], &p
);
1333 vty_out (vty
, "Please specify address by A.B.C.D%s", VTY_NEWLINE
);
1337 rip_neighbor_delete (&p
);
1342 DEFUN (ip_rip_receive_version
,
1343 ip_rip_receive_version_cmd
,
1344 "ip rip receive version (1|2)",
1346 "Routing Information Protocol\n"
1347 "Advertisement reception\n"
1352 struct interface
*ifp
;
1353 struct rip_interface
*ri
;
1355 ifp
= (struct interface
*)vty
->index
;
1359 if (atoi (argv
[0]) == 1)
1361 ri
->ri_receive
= RI_RIP_VERSION_1
;
1364 if (atoi (argv
[0]) == 2)
1366 ri
->ri_receive
= RI_RIP_VERSION_2
;
1372 DEFUN (ip_rip_receive_version_1
,
1373 ip_rip_receive_version_1_cmd
,
1374 "ip rip receive version 1 2",
1376 "Routing Information Protocol\n"
1377 "Advertisement reception\n"
1382 struct interface
*ifp
;
1383 struct rip_interface
*ri
;
1385 ifp
= (struct interface
*)vty
->index
;
1388 /* Version 1 and 2. */
1389 ri
->ri_receive
= RI_RIP_VERSION_1_AND_2
;
1393 DEFUN (ip_rip_receive_version_2
,
1394 ip_rip_receive_version_2_cmd
,
1395 "ip rip receive version 2 1",
1397 "Routing Information Protocol\n"
1398 "Advertisement reception\n"
1403 struct interface
*ifp
;
1404 struct rip_interface
*ri
;
1406 ifp
= (struct interface
*)vty
->index
;
1409 /* Version 1 and 2. */
1410 ri
->ri_receive
= RI_RIP_VERSION_1_AND_2
;
1414 DEFUN (no_ip_rip_receive_version
,
1415 no_ip_rip_receive_version_cmd
,
1416 "no ip rip receive version",
1419 "Routing Information Protocol\n"
1420 "Advertisement reception\n"
1421 "Version control\n")
1423 struct interface
*ifp
;
1424 struct rip_interface
*ri
;
1426 ifp
= (struct interface
*)vty
->index
;
1429 ri
->ri_receive
= RI_RIP_UNSPEC
;
1433 ALIAS (no_ip_rip_receive_version
,
1434 no_ip_rip_receive_version_num_cmd
,
1435 "no ip rip receive version (1|2)",
1438 "Routing Information Protocol\n"
1439 "Advertisement reception\n"
1444 DEFUN (ip_rip_send_version
,
1445 ip_rip_send_version_cmd
,
1446 "ip rip send version (1|2)",
1448 "Routing Information Protocol\n"
1449 "Advertisement transmission\n"
1454 struct interface
*ifp
;
1455 struct rip_interface
*ri
;
1457 ifp
= (struct interface
*)vty
->index
;
1461 if (atoi (argv
[0]) == 1)
1463 ri
->ri_send
= RI_RIP_VERSION_1
;
1466 if (atoi (argv
[0]) == 2)
1468 ri
->ri_send
= RI_RIP_VERSION_2
;
1474 DEFUN (ip_rip_send_version_1
,
1475 ip_rip_send_version_1_cmd
,
1476 "ip rip send version 1 2",
1478 "Routing Information Protocol\n"
1479 "Advertisement transmission\n"
1484 struct interface
*ifp
;
1485 struct rip_interface
*ri
;
1487 ifp
= (struct interface
*)vty
->index
;
1490 /* Version 1 and 2. */
1491 ri
->ri_send
= RI_RIP_VERSION_1_AND_2
;
1495 DEFUN (ip_rip_send_version_2
,
1496 ip_rip_send_version_2_cmd
,
1497 "ip rip send version 2 1",
1499 "Routing Information Protocol\n"
1500 "Advertisement transmission\n"
1505 struct interface
*ifp
;
1506 struct rip_interface
*ri
;
1508 ifp
= (struct interface
*)vty
->index
;
1511 /* Version 1 and 2. */
1512 ri
->ri_send
= RI_RIP_VERSION_1_AND_2
;
1516 DEFUN (no_ip_rip_send_version
,
1517 no_ip_rip_send_version_cmd
,
1518 "no ip rip send version",
1521 "Routing Information Protocol\n"
1522 "Advertisement transmission\n"
1523 "Version control\n")
1525 struct interface
*ifp
;
1526 struct rip_interface
*ri
;
1528 ifp
= (struct interface
*)vty
->index
;
1531 ri
->ri_send
= RI_RIP_UNSPEC
;
1535 ALIAS (no_ip_rip_send_version
,
1536 no_ip_rip_send_version_num_cmd
,
1537 "no ip rip send version (1|2)",
1540 "Routing Information Protocol\n"
1541 "Advertisement transmission\n"
1546 DEFUN (ip_rip_authentication_mode
,
1547 ip_rip_authentication_mode_cmd
,
1548 "ip rip authentication mode (md5|text)",
1550 "Routing Information Protocol\n"
1551 "Authentication control\n"
1552 "Authentication mode\n"
1553 "Keyed message digest\n"
1554 "Clear text authentication\n")
1556 struct interface
*ifp
;
1557 struct rip_interface
*ri
;
1560 ifp
= (struct interface
*)vty
->index
;
1563 if ( (argc
< 1) || (argc
> 2) )
1565 vty_out (vty
, "incorrect argument count%s", VTY_NEWLINE
);
1569 if (strncmp ("md5", argv
[0], strlen (argv
[0])) == 0)
1570 auth_type
= RIP_AUTH_MD5
;
1571 else if (strncmp ("text", argv
[0], strlen (argv
[0])) == 0)
1572 auth_type
= RIP_AUTH_SIMPLE_PASSWORD
;
1575 vty_out (vty
, "mode should be md5 or text%s", VTY_NEWLINE
);
1581 ri
->auth_type
= auth_type
;
1585 if ( (argc
== 2) && (auth_type
!= RIP_AUTH_MD5
) )
1587 vty_out (vty
, "auth length argument only valid for md5%s", VTY_NEWLINE
);
1591 if (strncmp ("r", argv
[1], 1) == 0)
1592 ri
->md5_auth_len
= RIP_AUTH_MD5_SIZE
;
1593 else if (strncmp ("o", argv
[1], 1) == 0)
1594 ri
->md5_auth_len
= RIP_AUTH_MD5_COMPAT_SIZE
;
1598 ri
->auth_type
= auth_type
;
1603 ALIAS (ip_rip_authentication_mode
,
1604 ip_rip_authentication_mode_authlen_cmd
,
1605 "ip rip authentication mode (md5|text) auth-length (rfc|old-ripd)",
1607 "Routing Information Protocol\n"
1608 "Authentication control\n"
1609 "Authentication mode\n"
1610 "Keyed message digest\n"
1611 "Clear text authentication\n"
1612 "MD5 authentication data length\n"
1614 "Old ripd compatible\n")
1616 DEFUN (no_ip_rip_authentication_mode
,
1617 no_ip_rip_authentication_mode_cmd
,
1618 "no ip rip authentication mode",
1621 "Routing Information Protocol\n"
1622 "Authentication control\n"
1623 "Authentication mode\n")
1625 struct interface
*ifp
;
1626 struct rip_interface
*ri
;
1628 ifp
= (struct interface
*)vty
->index
;
1631 ri
->auth_type
= RIP_NO_AUTH
;
1632 ri
->md5_auth_len
= RIP_AUTH_MD5_COMPAT_SIZE
;
1637 ALIAS (no_ip_rip_authentication_mode
,
1638 no_ip_rip_authentication_mode_type_cmd
,
1639 "no ip rip authentication mode (md5|text)",
1642 "Routing Information Protocol\n"
1643 "Authentication control\n"
1644 "Authentication mode\n"
1645 "Keyed message digest\n"
1646 "Clear text authentication\n")
1648 ALIAS (no_ip_rip_authentication_mode
,
1649 no_ip_rip_authentication_mode_type_authlen_cmd
,
1650 "no ip rip authentication mode (md5|text) auth-length (rfc|old-ripd)",
1653 "Routing Information Protocol\n"
1654 "Authentication control\n"
1655 "Authentication mode\n"
1656 "Keyed message digest\n"
1657 "Clear text authentication\n"
1658 "MD5 authentication data length\n"
1660 "Old ripd compatible\n")
1662 DEFUN (ip_rip_authentication_string
,
1663 ip_rip_authentication_string_cmd
,
1664 "ip rip authentication string LINE",
1666 "Routing Information Protocol\n"
1667 "Authentication control\n"
1668 "Authentication string\n"
1669 "Authentication string\n")
1671 struct interface
*ifp
;
1672 struct rip_interface
*ri
;
1674 ifp
= (struct interface
*)vty
->index
;
1677 if (strlen (argv
[0]) > 16)
1679 vty_out (vty
, "%% RIPv2 authentication string must be shorter than 16%s",
1686 vty_out (vty
, "%% key-chain configuration exists%s", VTY_NEWLINE
);
1691 free (ri
->auth_str
);
1693 ri
->auth_str
= strdup (argv
[0]);
1698 DEFUN (no_ip_rip_authentication_string
,
1699 no_ip_rip_authentication_string_cmd
,
1700 "no ip rip authentication string",
1703 "Routing Information Protocol\n"
1704 "Authentication control\n"
1705 "Authentication string\n")
1707 struct interface
*ifp
;
1708 struct rip_interface
*ri
;
1710 ifp
= (struct interface
*)vty
->index
;
1714 free (ri
->auth_str
);
1716 ri
->auth_str
= NULL
;
1721 ALIAS (no_ip_rip_authentication_string
,
1722 no_ip_rip_authentication_string2_cmd
,
1723 "no ip rip authentication string LINE",
1726 "Routing Information Protocol\n"
1727 "Authentication control\n"
1728 "Authentication string\n"
1729 "Authentication string\n")
1731 DEFUN (ip_rip_authentication_key_chain
,
1732 ip_rip_authentication_key_chain_cmd
,
1733 "ip rip authentication key-chain LINE",
1735 "Routing Information Protocol\n"
1736 "Authentication control\n"
1737 "Authentication key-chain\n"
1738 "name of key-chain\n")
1740 struct interface
*ifp
;
1741 struct rip_interface
*ri
;
1743 ifp
= (struct interface
*) vty
->index
;
1748 vty_out (vty
, "%% authentication string configuration exists%s",
1754 free (ri
->key_chain
);
1756 ri
->key_chain
= strdup (argv
[0]);
1761 DEFUN (no_ip_rip_authentication_key_chain
,
1762 no_ip_rip_authentication_key_chain_cmd
,
1763 "no ip rip authentication key-chain",
1766 "Routing Information Protocol\n"
1767 "Authentication control\n"
1768 "Authentication key-chain\n")
1770 struct interface
*ifp
;
1771 struct rip_interface
*ri
;
1773 ifp
= (struct interface
*) vty
->index
;
1777 free (ri
->key_chain
);
1779 ri
->key_chain
= NULL
;
1784 ALIAS (no_ip_rip_authentication_key_chain
,
1785 no_ip_rip_authentication_key_chain2_cmd
,
1786 "no ip rip authentication key-chain LINE",
1789 "Routing Information Protocol\n"
1790 "Authentication control\n"
1791 "Authentication key-chain\n"
1792 "name of key-chain\n")
1794 /* CHANGED: ip rip split-horizon
1795 Cisco and Zebra's command is
1798 DEFUN (ip_rip_split_horizon
,
1799 ip_rip_split_horizon_cmd
,
1800 "ip rip split-horizon",
1802 "Routing Information Protocol\n"
1803 "Perform split horizon\n")
1805 struct interface
*ifp
;
1806 struct rip_interface
*ri
;
1811 ri
->split_horizon
= RIP_SPLIT_HORIZON
;
1815 DEFUN (ip_rip_split_horizon_poisoned_reverse
,
1816 ip_rip_split_horizon_poisoned_reverse_cmd
,
1817 "ip rip split-horizon poisoned-reverse",
1819 "Routing Information Protocol\n"
1820 "Perform split horizon\n"
1821 "With poisoned-reverse\n")
1823 struct interface
*ifp
;
1824 struct rip_interface
*ri
;
1829 ri
->split_horizon
= RIP_SPLIT_HORIZON_POISONED_REVERSE
;
1833 /* CHANGED: no ip rip split-horizon
1834 Cisco and Zebra's command is
1837 DEFUN (no_ip_rip_split_horizon
,
1838 no_ip_rip_split_horizon_cmd
,
1839 "no ip rip split-horizon",
1842 "Routing Information Protocol\n"
1843 "Perform split horizon\n")
1845 struct interface
*ifp
;
1846 struct rip_interface
*ri
;
1851 ri
->split_horizon
= RIP_NO_SPLIT_HORIZON
;
1855 DEFUN (no_ip_rip_split_horizon_poisoned_reverse
,
1856 no_ip_rip_split_horizon_poisoned_reverse_cmd
,
1857 "no ip rip split-horizon poisoned-reverse",
1860 "Routing Information Protocol\n"
1861 "Perform split horizon\n"
1862 "With poisoned-reverse\n")
1864 struct interface
*ifp
;
1865 struct rip_interface
*ri
;
1870 switch( ri
->split_horizon
)
1872 case RIP_SPLIT_HORIZON_POISONED_REVERSE
:
1873 ri
->split_horizon
= RIP_SPLIT_HORIZON
;
1881 DEFUN (rip_passive_interface
,
1882 rip_passive_interface_cmd
,
1883 "passive-interface (IFNAME|default)",
1884 "Suppress routing updates on an interface\n"
1886 "default for all interfaces\n")
1888 const char *ifname
= argv
[0];
1890 if (!strcmp(ifname
,"default")) {
1891 passive_default
= 1;
1892 rip_passive_nondefault_clean();
1895 if (passive_default
)
1896 return rip_passive_nondefault_unset (vty
, ifname
);
1898 return rip_passive_nondefault_set (vty
, ifname
);
1901 DEFUN (no_rip_passive_interface
,
1902 no_rip_passive_interface_cmd
,
1903 "no passive-interface (IFNAME|default)",
1905 "Suppress routing updates on an interface\n"
1907 "default for all interfaces\n")
1909 const char *ifname
= argv
[0];
1911 if (!strcmp(ifname
,"default")) {
1912 passive_default
= 0;
1913 rip_passive_nondefault_clean();
1916 if (passive_default
)
1917 return rip_passive_nondefault_set (vty
, ifname
);
1919 return rip_passive_nondefault_unset (vty
, ifname
);
1922 /* Write rip configuration of each interface. */
1924 rip_interface_config_write (struct vty
*vty
)
1926 struct listnode
*node
;
1927 struct interface
*ifp
;
1929 for (ALL_LIST_ELEMENTS_RO (iflist
, node
, ifp
))
1931 struct rip_interface
*ri
;
1935 /* Do not display the interface if there is no
1936 * configuration about it.
1939 (ri
->split_horizon
== ri
->split_horizon_default
) &&
1940 (ri
->ri_send
== RI_RIP_UNSPEC
) &&
1941 (ri
->ri_receive
== RI_RIP_UNSPEC
) &&
1942 (ri
->auth_type
!= RIP_AUTH_MD5
) &&
1943 (ri
->md5_auth_len
!= RIP_AUTH_MD5_SIZE
) &&
1948 vty_out (vty
, "interface %s%s", ifp
->name
,
1952 vty_out (vty
, " description %s%s", ifp
->desc
,
1955 /* Split horizon. */
1956 if (ri
->split_horizon
!= ri
->split_horizon_default
)
1958 switch (ri
->split_horizon
) {
1959 case RIP_SPLIT_HORIZON
:
1960 vty_out (vty
, " ip rip split-horizon%s", VTY_NEWLINE
);
1962 case RIP_SPLIT_HORIZON_POISONED_REVERSE
:
1963 vty_out (vty
, " ip rip split-horizon poisoned-reverse%s",
1966 case RIP_NO_SPLIT_HORIZON
:
1968 vty_out (vty
, " no ip rip split-horizon%s", VTY_NEWLINE
);
1973 /* RIP version setting. */
1974 if (ri
->ri_send
!= RI_RIP_UNSPEC
)
1975 vty_out (vty
, " ip rip send version %s%s",
1976 lookup (ri_version_msg
, ri
->ri_send
),
1979 if (ri
->ri_receive
!= RI_RIP_UNSPEC
)
1980 vty_out (vty
, " ip rip receive version %s%s",
1981 lookup (ri_version_msg
, ri
->ri_receive
),
1984 /* RIP authentication. */
1985 if (ri
->auth_type
== RIP_AUTH_SIMPLE_PASSWORD
)
1986 vty_out (vty
, " ip rip authentication mode text%s", VTY_NEWLINE
);
1988 if (ri
->auth_type
== RIP_AUTH_MD5
)
1990 vty_out (vty
, " ip rip authentication mode md5");
1991 if (ri
->md5_auth_len
== RIP_AUTH_MD5_COMPAT_SIZE
)
1992 vty_out (vty
, " auth-length old-ripd");
1994 vty_out (vty
, " auth-length rfc");
1995 vty_out (vty
, "%s", VTY_NEWLINE
);
1999 vty_out (vty
, " ip rip authentication string %s%s",
2000 ri
->auth_str
, VTY_NEWLINE
);
2003 vty_out (vty
, " ip rip authentication key-chain %s%s",
2004 ri
->key_chain
, VTY_NEWLINE
);
2006 vty_out (vty
, "!%s", VTY_NEWLINE
);
2012 config_write_rip_network (struct vty
*vty
, int config_mode
)
2016 struct route_node
*node
;
2018 /* Network type RIP enable interface statement. */
2019 for (node
= route_top (rip_enable_network
); node
; node
= route_next (node
))
2021 vty_out (vty
, "%s%s/%d%s",
2022 config_mode
? " network " : " ",
2023 inet_ntoa (node
->p
.u
.prefix4
),
2027 /* Interface name RIP enable statement. */
2028 for (i
= 0; i
< vector_active (rip_enable_interface
); i
++)
2029 if ((ifname
= vector_slot (rip_enable_interface
, i
)) != NULL
)
2030 vty_out (vty
, "%s%s%s",
2031 config_mode
? " network " : " ",
2035 /* RIP neighbors listing. */
2036 for (node
= route_top (rip
->neighbor
); node
; node
= route_next (node
))
2038 vty_out (vty
, "%s%s%s",
2039 config_mode
? " neighbor " : " ",
2040 inet_ntoa (node
->p
.u
.prefix4
),
2043 /* RIP passive interface listing. */
2045 if (passive_default
)
2046 vty_out (vty
, " passive-interface default%s", VTY_NEWLINE
);
2047 for (i
= 0; i
< vector_active (Vrip_passive_nondefault
); i
++)
2048 if ((ifname
= vector_slot (Vrip_passive_nondefault
, i
)) != NULL
)
2049 vty_out (vty
, " %spassive-interface %s%s",
2050 (passive_default
? "no " : ""), ifname
, VTY_NEWLINE
);
2056 struct cmd_node interface_node
=
2063 /* Called when interface structure allocated. */
2065 rip_interface_new_hook (struct interface
*ifp
)
2067 ifp
->info
= rip_interface_new ();
2071 /* Called when interface structure deleted. */
2073 rip_interface_delete_hook (struct interface
*ifp
)
2075 XFREE (MTYPE_RIP_INTERFACE
, ifp
->info
);
2080 /* Allocate and initialize interface vector. */
2084 /* Default initial size of interface vector. */
2086 if_add_hook (IF_NEW_HOOK
, rip_interface_new_hook
);
2087 if_add_hook (IF_DELETE_HOOK
, rip_interface_delete_hook
);
2089 /* RIP network init. */
2090 rip_enable_interface
= vector_init (1);
2091 rip_enable_network
= route_table_init ();
2093 /* RIP passive interface. */
2094 Vrip_passive_nondefault
= vector_init (1);
2096 /* Install interface node. */
2097 install_node (&interface_node
, rip_interface_config_write
);
2099 /* Install commands. */
2100 install_element (CONFIG_NODE
, &interface_cmd
);
2101 install_element (CONFIG_NODE
, &no_interface_cmd
);
2102 install_default (INTERFACE_NODE
);
2103 install_element (INTERFACE_NODE
, &interface_desc_cmd
);
2104 install_element (INTERFACE_NODE
, &no_interface_desc_cmd
);
2105 install_element (RIP_NODE
, &rip_network_cmd
);
2106 install_element (RIP_NODE
, &no_rip_network_cmd
);
2107 install_element (RIP_NODE
, &rip_neighbor_cmd
);
2108 install_element (RIP_NODE
, &no_rip_neighbor_cmd
);
2110 install_element (RIP_NODE
, &rip_passive_interface_cmd
);
2111 install_element (RIP_NODE
, &no_rip_passive_interface_cmd
);
2113 install_element (INTERFACE_NODE
, &ip_rip_send_version_cmd
);
2114 install_element (INTERFACE_NODE
, &ip_rip_send_version_1_cmd
);
2115 install_element (INTERFACE_NODE
, &ip_rip_send_version_2_cmd
);
2116 install_element (INTERFACE_NODE
, &no_ip_rip_send_version_cmd
);
2117 install_element (INTERFACE_NODE
, &no_ip_rip_send_version_num_cmd
);
2119 install_element (INTERFACE_NODE
, &ip_rip_receive_version_cmd
);
2120 install_element (INTERFACE_NODE
, &ip_rip_receive_version_1_cmd
);
2121 install_element (INTERFACE_NODE
, &ip_rip_receive_version_2_cmd
);
2122 install_element (INTERFACE_NODE
, &no_ip_rip_receive_version_cmd
);
2123 install_element (INTERFACE_NODE
, &no_ip_rip_receive_version_num_cmd
);
2125 install_element (INTERFACE_NODE
, &ip_rip_authentication_mode_cmd
);
2126 install_element (INTERFACE_NODE
, &ip_rip_authentication_mode_authlen_cmd
);
2127 install_element (INTERFACE_NODE
, &no_ip_rip_authentication_mode_cmd
);
2128 install_element (INTERFACE_NODE
, &no_ip_rip_authentication_mode_type_cmd
);
2129 install_element (INTERFACE_NODE
, &no_ip_rip_authentication_mode_type_authlen_cmd
);
2131 install_element (INTERFACE_NODE
, &ip_rip_authentication_key_chain_cmd
);
2132 install_element (INTERFACE_NODE
, &no_ip_rip_authentication_key_chain_cmd
);
2133 install_element (INTERFACE_NODE
, &no_ip_rip_authentication_key_chain2_cmd
);
2135 install_element (INTERFACE_NODE
, &ip_rip_authentication_string_cmd
);
2136 install_element (INTERFACE_NODE
, &no_ip_rip_authentication_string_cmd
);
2137 install_element (INTERFACE_NODE
, &no_ip_rip_authentication_string2_cmd
);
2139 install_element (INTERFACE_NODE
, &ip_rip_split_horizon_cmd
);
2140 install_element (INTERFACE_NODE
, &ip_rip_split_horizon_poisoned_reverse_cmd
);
2141 install_element (INTERFACE_NODE
, &no_ip_rip_split_horizon_cmd
);
2142 install_element (INTERFACE_NODE
, &no_ip_rip_split_horizon_poisoned_reverse_cmd
);