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 %llx metric %d mtu %d is down",
406 ifp
->name
, ifp
->ifindex
, (unsigned long long)ifp
->flags
,
407 ifp
->metric
, ifp
->mtu
);
412 /* Inteface link up message processing */
414 rip_interface_up (int command
, struct zclient
*zclient
, zebra_size_t length
)
416 struct interface
*ifp
;
418 /* zebra_interface_state_read () updates interface structure in
420 ifp
= zebra_interface_state_read (zclient
->ibuf
);
425 if (IS_RIP_DEBUG_ZEBRA
)
426 zlog_debug ("interface %s index %d flags %lld metric %d mtu %d is up",
427 ifp
->name
, ifp
->ifindex
, ifp
->flags
, ifp
->metric
, ifp
->mtu
);
429 /* Check if this interface is RIP enabled or not.*/
430 rip_enable_apply (ifp
);
432 /* Check for a passive interface */
433 rip_passive_interface_apply (ifp
);
435 /* Apply distribute list to the all interface. */
436 rip_distribute_update_interface (ifp
);
441 /* Inteface addition message from zebra. */
443 rip_interface_add (int command
, struct zclient
*zclient
, zebra_size_t length
)
445 struct interface
*ifp
;
447 ifp
= zebra_interface_add_read (zclient
->ibuf
);
449 if (IS_RIP_DEBUG_ZEBRA
)
450 zlog_debug ("interface add %s index %d flags %lld metric %d mtu %d",
451 ifp
->name
, ifp
->ifindex
, ifp
->flags
, ifp
->metric
, ifp
->mtu
);
453 /* Check if this interface is RIP enabled or not.*/
454 rip_enable_apply (ifp
);
456 /* Check for a passive interface */
457 rip_passive_interface_apply (ifp
);
459 /* Apply distribute list to the all interface. */
460 rip_distribute_update_interface (ifp
);
462 /* rip_request_neighbor_all (); */
464 /* Check interface routemap. */
465 rip_if_rmap_update_interface (ifp
);
471 rip_interface_delete (int command
, struct zclient
*zclient
,
474 struct interface
*ifp
;
479 /* zebra_interface_state_read() updates interface structure in iflist */
480 ifp
= zebra_interface_state_read(s
);
485 if (if_is_up (ifp
)) {
489 zlog_info("interface delete %s index %d flags %lld metric %d mtu %d",
490 ifp
->name
, ifp
->ifindex
, ifp
->flags
, ifp
->metric
, ifp
->mtu
);
492 /* To support pseudo interface do not free interface structure. */
493 /* if_delete(ifp); */
494 ifp
->ifindex
= IFINDEX_INTERNAL
;
500 rip_interface_clean (void)
502 struct listnode
*node
;
503 struct interface
*ifp
;
504 struct rip_interface
*ri
;
506 for (ALL_LIST_ELEMENTS_RO (iflist
, node
, ifp
))
510 ri
->enable_network
= 0;
511 ri
->enable_interface
= 0;
516 thread_cancel (ri
->t_wakeup
);
523 rip_interface_reset (void)
525 struct listnode
*node
;
526 struct interface
*ifp
;
527 struct rip_interface
*ri
;
529 for (ALL_LIST_ELEMENTS_RO (iflist
, node
, ifp
))
533 ri
->enable_network
= 0;
534 ri
->enable_interface
= 0;
537 ri
->ri_send
= RI_RIP_UNSPEC
;
538 ri
->ri_receive
= RI_RIP_UNSPEC
;
540 ri
->auth_type
= RIP_NO_AUTH
;
549 free (ri
->key_chain
);
550 ri
->key_chain
= NULL
;
553 ri
->split_horizon
= RIP_NO_SPLIT_HORIZON
;
554 ri
->split_horizon_default
= RIP_NO_SPLIT_HORIZON
;
556 ri
->list
[RIP_FILTER_IN
] = NULL
;
557 ri
->list
[RIP_FILTER_OUT
] = NULL
;
559 ri
->prefix
[RIP_FILTER_IN
] = NULL
;
560 ri
->prefix
[RIP_FILTER_OUT
] = NULL
;
564 thread_cancel (ri
->t_wakeup
);
568 ri
->recv_badpackets
= 0;
569 ri
->recv_badroutes
= 0;
570 ri
->sent_updates
= 0;
577 rip_if_down(struct interface
*ifp
)
579 struct route_node
*rp
;
580 struct rip_info
*rinfo
;
581 struct rip_interface
*ri
= NULL
;
584 for (rp
= route_top (rip
->table
); rp
; rp
= route_next (rp
))
585 if ((rinfo
= rp
->info
) != NULL
)
587 /* Routes got through this interface. */
588 if (rinfo
->ifindex
== ifp
->ifindex
&&
589 rinfo
->type
== ZEBRA_ROUTE_RIP
&&
590 rinfo
->sub_type
== RIP_ROUTE_RTE
)
592 rip_zebra_ipv4_delete ((struct prefix_ipv4
*) &rp
->p
,
596 rip_redistribute_delete (rinfo
->type
,rinfo
->sub_type
,
597 (struct prefix_ipv4
*)&rp
->p
,
602 /* All redistributed routes but static and system */
603 if ((rinfo
->ifindex
== ifp
->ifindex
) &&
604 /* (rinfo->type != ZEBRA_ROUTE_STATIC) && */
605 (rinfo
->type
!= ZEBRA_ROUTE_SYSTEM
))
606 rip_redistribute_delete (rinfo
->type
,rinfo
->sub_type
,
607 (struct prefix_ipv4
*)&rp
->p
,
617 if (IS_RIP_DEBUG_EVENT
)
618 zlog_debug ("turn off %s", ifp
->name
);
620 /* Leave from multicast group. */
621 rip_multicast_leave (ifp
, rip
->sock
);
629 /* Needed for stop RIP process. */
633 struct interface
*ifp
;
634 struct listnode
*node
, *nnode
;
636 for (ALL_LIST_ELEMENTS (iflist
, node
, nnode
, ifp
))
641 rip_apply_address_add (struct connected
*ifc
)
643 struct prefix_ipv4 address
;
649 if (! if_is_up(ifc
->ifp
))
654 memset (&address
, 0, sizeof (address
));
655 address
.family
= p
->family
;
656 address
.prefix
= p
->u
.prefix4
;
657 address
.prefixlen
= p
->prefixlen
;
658 apply_mask_ipv4(&address
);
660 /* Check if this interface is RIP enabled or not
661 or Check if this address's prefix is RIP enabled */
662 if ((rip_enable_if_lookup(ifc
->ifp
->name
) >= 0) ||
663 (rip_enable_network_lookup2(ifc
) >= 0))
664 rip_redistribute_add(ZEBRA_ROUTE_CONNECT
, RIP_ROUTE_INTERFACE
,
665 &address
, ifc
->ifp
->ifindex
, NULL
, 0, 0);
670 rip_interface_address_add (int command
, struct zclient
*zclient
,
673 struct connected
*ifc
;
676 ifc
= zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_ADD
,
684 if (p
->family
== AF_INET
)
686 if (IS_RIP_DEBUG_ZEBRA
)
687 zlog_debug ("connected address %s/%d is added",
688 inet_ntoa (p
->u
.prefix4
), p
->prefixlen
);
690 rip_enable_apply(ifc
->ifp
);
691 /* Check if this prefix needs to be redistributed */
692 rip_apply_address_add(ifc
);
695 rip_ifaddr_add (ifc
->ifp
, ifc
);
696 #endif /* HAVE_SNMP */
703 rip_apply_address_del (struct connected
*ifc
) {
704 struct prefix_ipv4 address
;
710 if (! if_is_up(ifc
->ifp
))
715 memset (&address
, 0, sizeof (address
));
716 address
.family
= p
->family
;
717 address
.prefix
= p
->u
.prefix4
;
718 address
.prefixlen
= p
->prefixlen
;
719 apply_mask_ipv4(&address
);
721 rip_redistribute_delete(ZEBRA_ROUTE_CONNECT
, RIP_ROUTE_INTERFACE
,
722 &address
, ifc
->ifp
->ifindex
);
726 rip_interface_address_delete (int command
, struct zclient
*zclient
,
729 struct connected
*ifc
;
732 ifc
= zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_DELETE
,
738 if (p
->family
== AF_INET
)
740 if (IS_RIP_DEBUG_ZEBRA
)
741 zlog_debug ("connected address %s/%d is deleted",
742 inet_ntoa (p
->u
.prefix4
), p
->prefixlen
);
745 rip_ifaddr_delete (ifc
->ifp
, ifc
);
746 #endif /* HAVE_SNMP */
748 /* Chech wether this prefix needs to be removed */
749 rip_apply_address_del(ifc
);
753 connected_free (ifc
);
760 /* Check interface is enabled by network statement. */
761 /* Check wether the interface has at least a connected prefix that
762 * is within the ripng_enable_network table. */
764 rip_enable_network_lookup_if (struct interface
*ifp
)
766 struct listnode
*node
, *nnode
;
767 struct connected
*connected
;
768 struct prefix_ipv4 address
;
770 for (ALL_LIST_ELEMENTS (ifp
->connected
, node
, nnode
, connected
))
773 struct route_node
*node
;
775 p
= connected
->address
;
777 if (p
->family
== AF_INET
)
779 address
.family
= AF_INET
;
780 address
.prefix
= p
->u
.prefix4
;
781 address
.prefixlen
= IPV4_MAX_BITLEN
;
783 node
= route_node_match (rip_enable_network
,
784 (struct prefix
*)&address
);
787 route_unlock_node (node
);
795 /* Check wether connected is within the ripng_enable_network table. */
797 rip_enable_network_lookup2 (struct connected
*connected
)
799 struct prefix_ipv4 address
;
802 p
= connected
->address
;
804 if (p
->family
== AF_INET
) {
805 struct route_node
*node
;
807 address
.family
= p
->family
;
808 address
.prefix
= p
->u
.prefix4
;
809 address
.prefixlen
= IPV4_MAX_BITLEN
;
811 /* LPM on p->family, p->u.prefix4/IPV4_MAX_BITLEN within rip_enable_network */
812 node
= route_node_match (rip_enable_network
,
813 (struct prefix
*)&address
);
816 route_unlock_node (node
);
823 /* Add RIP enable network. */
825 rip_enable_network_add (struct prefix
*p
)
827 struct route_node
*node
;
829 node
= route_node_get (rip_enable_network
, p
);
833 route_unlock_node (node
);
837 node
->info
= (char *) "enabled";
839 /* XXX: One should find a better solution than a generic one */
840 rip_enable_apply_all();
845 /* Delete RIP enable network. */
847 rip_enable_network_delete (struct prefix
*p
)
849 struct route_node
*node
;
851 node
= route_node_lookup (rip_enable_network
, p
);
856 /* Unlock info lock. */
857 route_unlock_node (node
);
859 /* Unlock lookup lock. */
860 route_unlock_node (node
);
862 /* XXX: One should find a better solution than a generic one */
863 rip_enable_apply_all ();
870 /* Check interface is enabled by ifname statement. */
872 rip_enable_if_lookup (const char *ifname
)
877 for (i
= 0; i
< vector_active (rip_enable_interface
); i
++)
878 if ((str
= vector_slot (rip_enable_interface
, i
)) != NULL
)
879 if (strcmp (str
, ifname
) == 0)
884 /* Add interface to rip_enable_if. */
886 rip_enable_if_add (const char *ifname
)
890 ret
= rip_enable_if_lookup (ifname
);
894 vector_set (rip_enable_interface
, strdup (ifname
));
896 rip_enable_apply_all(); /* TODOVJ */
901 /* Delete interface from rip_enable_if. */
903 rip_enable_if_delete (const char *ifname
)
908 index
= rip_enable_if_lookup (ifname
);
912 str
= vector_slot (rip_enable_interface
, index
);
914 vector_unset (rip_enable_interface
, index
);
916 rip_enable_apply_all(); /* TODOVJ */
921 /* Join to multicast group and send request to the interface. */
923 rip_interface_wakeup (struct thread
*t
)
925 struct interface
*ifp
;
926 struct rip_interface
*ri
;
929 ifp
= THREAD_ARG (t
);
934 /* Join to multicast group. */
935 if (rip_multicast_join (ifp
, rip
->sock
) < 0)
937 zlog_err ("multicast join failed, interface %s not running", ifp
->name
);
941 /* Set running flag. */
944 /* Send RIP request to the interface. */
945 rip_request_interface (ifp
);
950 int rip_redistribute_check (int);
953 rip_connect_set (struct interface
*ifp
, int set
)
955 struct listnode
*node
, *nnode
;
956 struct connected
*connected
;
957 struct prefix_ipv4 address
;
959 for (ALL_LIST_ELEMENTS (ifp
->connected
, node
, nnode
, connected
))
962 p
= connected
->address
;
964 if (p
->family
!= AF_INET
)
967 address
.family
= AF_INET
;
968 address
.prefix
= p
->u
.prefix4
;
969 address
.prefixlen
= p
->prefixlen
;
970 apply_mask_ipv4 (&address
);
973 /* Check once more wether this prefix is within a "network IF_OR_PREF" one */
974 if ((rip_enable_if_lookup(connected
->ifp
->name
) >= 0) ||
975 (rip_enable_network_lookup2(connected
) >= 0))
976 rip_redistribute_add (ZEBRA_ROUTE_CONNECT
, RIP_ROUTE_INTERFACE
,
977 &address
, connected
->ifp
->ifindex
,
981 rip_redistribute_delete (ZEBRA_ROUTE_CONNECT
, RIP_ROUTE_INTERFACE
,
982 &address
, connected
->ifp
->ifindex
);
983 if (rip_redistribute_check (ZEBRA_ROUTE_CONNECT
))
984 rip_redistribute_add (ZEBRA_ROUTE_CONNECT
, RIP_ROUTE_REDISTRIBUTE
,
985 &address
, connected
->ifp
->ifindex
,
991 /* Update interface status. */
993 rip_enable_apply (struct interface
*ifp
)
996 struct rip_interface
*ri
= NULL
;
998 /* Check interface. */
999 if (! if_is_operative (ifp
))
1004 /* Check network configuration. */
1005 ret
= rip_enable_network_lookup_if (ifp
);
1007 /* If the interface is matched. */
1009 ri
->enable_network
= 1;
1011 ri
->enable_network
= 0;
1013 /* Check interface name configuration. */
1014 ret
= rip_enable_if_lookup (ifp
->name
);
1016 ri
->enable_interface
= 1;
1018 ri
->enable_interface
= 0;
1020 /* any interface MUST have an IPv4 address */
1021 if ( ! rip_if_ipv4_address_check (ifp
) )
1023 ri
->enable_network
= 0;
1024 ri
->enable_interface
= 0;
1027 /* Update running status of the interface. */
1028 if (ri
->enable_network
|| ri
->enable_interface
)
1031 if (IS_RIP_DEBUG_EVENT
)
1032 zlog_debug ("turn on %s", ifp
->name
);
1034 /* Add interface wake up thread. */
1036 ri
->t_wakeup
= thread_add_timer (master
, rip_interface_wakeup
,
1038 rip_connect_set (ifp
, 1);
1045 /* Might as well clean up the route table as well
1046 * rip_if_down sets to 0 ri->running, and displays "turn off %s"
1050 rip_connect_set (ifp
, 0);
1055 /* Apply network configuration to all interface. */
1057 rip_enable_apply_all ()
1059 struct interface
*ifp
;
1060 struct listnode
*node
, *nnode
;
1062 /* Check each interface. */
1063 for (ALL_LIST_ELEMENTS (iflist
, node
, nnode
, ifp
))
1064 rip_enable_apply (ifp
);
1068 rip_neighbor_lookup (struct sockaddr_in
*from
)
1070 struct prefix_ipv4 p
;
1071 struct route_node
*node
;
1073 memset (&p
, 0, sizeof (struct prefix_ipv4
));
1075 p
.prefix
= from
->sin_addr
;
1076 p
.prefixlen
= IPV4_MAX_BITLEN
;
1078 node
= route_node_lookup (rip
->neighbor
, (struct prefix
*) &p
);
1081 route_unlock_node (node
);
1087 /* Add new RIP neighbor to the neighbor tree. */
1089 rip_neighbor_add (struct prefix_ipv4
*p
)
1091 struct route_node
*node
;
1093 node
= route_node_get (rip
->neighbor
, (struct prefix
*) p
);
1098 node
->info
= rip
->neighbor
;
1103 /* Delete RIP neighbor from the neighbor tree. */
1105 rip_neighbor_delete (struct prefix_ipv4
*p
)
1107 struct route_node
*node
;
1109 /* Lock for look up. */
1110 node
= route_node_lookup (rip
->neighbor
, (struct prefix
*) p
);
1116 /* Unlock lookup lock. */
1117 route_unlock_node (node
);
1119 /* Unlock real neighbor information lock. */
1120 route_unlock_node (node
);
1125 /* Clear all network and neighbor configuration. */
1127 rip_clean_network ()
1131 struct route_node
*rn
;
1133 /* rip_enable_network. */
1134 for (rn
= route_top (rip_enable_network
); rn
; rn
= route_next (rn
))
1138 route_unlock_node (rn
);
1141 /* rip_enable_interface. */
1142 for (i
= 0; i
< vector_active (rip_enable_interface
); i
++)
1143 if ((str
= vector_slot (rip_enable_interface
, i
)) != NULL
)
1146 vector_slot (rip_enable_interface
, i
) = NULL
;
1150 /* Utility function for looking up passive interface settings. */
1152 rip_passive_nondefault_lookup (const char *ifname
)
1157 for (i
= 0; i
< vector_active (Vrip_passive_nondefault
); i
++)
1158 if ((str
= vector_slot (Vrip_passive_nondefault
, i
)) != NULL
)
1159 if (strcmp (str
, ifname
) == 0)
1165 rip_passive_interface_apply (struct interface
*ifp
)
1167 struct rip_interface
*ri
;
1171 ri
->passive
= ((rip_passive_nondefault_lookup (ifp
->name
) < 0) ?
1172 passive_default
: !passive_default
);
1174 if (IS_RIP_DEBUG_ZEBRA
)
1175 zlog_debug ("interface %s: passive = %d",ifp
->name
,ri
->passive
);
1179 rip_passive_interface_apply_all (void)
1181 struct interface
*ifp
;
1182 struct listnode
*node
, *nnode
;
1184 for (ALL_LIST_ELEMENTS (iflist
, node
, nnode
, ifp
))
1185 rip_passive_interface_apply (ifp
);
1188 /* Passive interface. */
1190 rip_passive_nondefault_set (struct vty
*vty
, const char *ifname
)
1192 if (rip_passive_nondefault_lookup (ifname
) >= 0)
1195 vector_set (Vrip_passive_nondefault
, strdup (ifname
));
1197 rip_passive_interface_apply_all ();
1203 rip_passive_nondefault_unset (struct vty
*vty
, const char *ifname
)
1208 i
= rip_passive_nondefault_lookup (ifname
);
1212 str
= vector_slot (Vrip_passive_nondefault
, i
);
1214 vector_unset (Vrip_passive_nondefault
, i
);
1216 rip_passive_interface_apply_all ();
1221 /* Free all configured RIP passive-interface settings. */
1223 rip_passive_nondefault_clean (void)
1228 for (i
= 0; i
< vector_active (Vrip_passive_nondefault
); i
++)
1229 if ((str
= vector_slot (Vrip_passive_nondefault
, i
)) != NULL
)
1232 vector_slot (Vrip_passive_nondefault
, i
) = NULL
;
1234 rip_passive_interface_apply_all ();
1237 /* RIP enable network or interface configuration. */
1240 "network (A.B.C.D/M|WORD)",
1241 "Enable routing on an IP network\n"
1242 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1246 struct prefix_ipv4 p
;
1248 ret
= str2prefix_ipv4 (argv
[0], &p
);
1251 ret
= rip_enable_network_add ((struct prefix
*) &p
);
1253 ret
= rip_enable_if_add (argv
[0]);
1257 vty_out (vty
, "There is a same network configuration %s%s", argv
[0],
1265 /* RIP enable network or interface configuration. */
1266 DEFUN (no_rip_network
,
1268 "no network (A.B.C.D/M|WORD)",
1270 "Enable routing on an IP network\n"
1271 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1275 struct prefix_ipv4 p
;
1277 ret
= str2prefix_ipv4 (argv
[0], &p
);
1280 ret
= rip_enable_network_delete ((struct prefix
*) &p
);
1282 ret
= rip_enable_if_delete (argv
[0]);
1286 vty_out (vty
, "Can't find network configuration %s%s", argv
[0],
1294 /* RIP neighbor configuration set. */
1295 DEFUN (rip_neighbor
,
1298 "Specify a neighbor router\n"
1299 "Neighbor address\n")
1302 struct prefix_ipv4 p
;
1304 ret
= str2prefix_ipv4 (argv
[0], &p
);
1308 vty_out (vty
, "Please specify address by A.B.C.D%s", VTY_NEWLINE
);
1312 rip_neighbor_add (&p
);
1317 /* RIP neighbor configuration unset. */
1318 DEFUN (no_rip_neighbor
,
1319 no_rip_neighbor_cmd
,
1320 "no neighbor A.B.C.D",
1322 "Specify a neighbor router\n"
1323 "Neighbor address\n")
1326 struct prefix_ipv4 p
;
1328 ret
= str2prefix_ipv4 (argv
[0], &p
);
1332 vty_out (vty
, "Please specify address by A.B.C.D%s", VTY_NEWLINE
);
1336 rip_neighbor_delete (&p
);
1341 DEFUN (ip_rip_receive_version
,
1342 ip_rip_receive_version_cmd
,
1343 "ip rip receive version (1|2)",
1345 "Routing Information Protocol\n"
1346 "Advertisement reception\n"
1351 struct interface
*ifp
;
1352 struct rip_interface
*ri
;
1354 ifp
= (struct interface
*)vty
->index
;
1358 if (atoi (argv
[0]) == 1)
1360 ri
->ri_receive
= RI_RIP_VERSION_1
;
1363 if (atoi (argv
[0]) == 2)
1365 ri
->ri_receive
= RI_RIP_VERSION_2
;
1371 DEFUN (ip_rip_receive_version_1
,
1372 ip_rip_receive_version_1_cmd
,
1373 "ip rip receive version 1 2",
1375 "Routing Information Protocol\n"
1376 "Advertisement reception\n"
1381 struct interface
*ifp
;
1382 struct rip_interface
*ri
;
1384 ifp
= (struct interface
*)vty
->index
;
1387 /* Version 1 and 2. */
1388 ri
->ri_receive
= RI_RIP_VERSION_1_AND_2
;
1392 DEFUN (ip_rip_receive_version_2
,
1393 ip_rip_receive_version_2_cmd
,
1394 "ip rip receive version 2 1",
1396 "Routing Information Protocol\n"
1397 "Advertisement reception\n"
1402 struct interface
*ifp
;
1403 struct rip_interface
*ri
;
1405 ifp
= (struct interface
*)vty
->index
;
1408 /* Version 1 and 2. */
1409 ri
->ri_receive
= RI_RIP_VERSION_1_AND_2
;
1413 DEFUN (no_ip_rip_receive_version
,
1414 no_ip_rip_receive_version_cmd
,
1415 "no ip rip receive version",
1418 "Routing Information Protocol\n"
1419 "Advertisement reception\n"
1420 "Version control\n")
1422 struct interface
*ifp
;
1423 struct rip_interface
*ri
;
1425 ifp
= (struct interface
*)vty
->index
;
1428 ri
->ri_receive
= RI_RIP_UNSPEC
;
1432 ALIAS (no_ip_rip_receive_version
,
1433 no_ip_rip_receive_version_num_cmd
,
1434 "no ip rip receive version (1|2)",
1437 "Routing Information Protocol\n"
1438 "Advertisement reception\n"
1443 DEFUN (ip_rip_send_version
,
1444 ip_rip_send_version_cmd
,
1445 "ip rip send version (1|2)",
1447 "Routing Information Protocol\n"
1448 "Advertisement transmission\n"
1453 struct interface
*ifp
;
1454 struct rip_interface
*ri
;
1456 ifp
= (struct interface
*)vty
->index
;
1460 if (atoi (argv
[0]) == 1)
1462 ri
->ri_send
= RI_RIP_VERSION_1
;
1465 if (atoi (argv
[0]) == 2)
1467 ri
->ri_send
= RI_RIP_VERSION_2
;
1473 DEFUN (ip_rip_send_version_1
,
1474 ip_rip_send_version_1_cmd
,
1475 "ip rip send version 1 2",
1477 "Routing Information Protocol\n"
1478 "Advertisement transmission\n"
1483 struct interface
*ifp
;
1484 struct rip_interface
*ri
;
1486 ifp
= (struct interface
*)vty
->index
;
1489 /* Version 1 and 2. */
1490 ri
->ri_send
= RI_RIP_VERSION_1_AND_2
;
1494 DEFUN (ip_rip_send_version_2
,
1495 ip_rip_send_version_2_cmd
,
1496 "ip rip send version 2 1",
1498 "Routing Information Protocol\n"
1499 "Advertisement transmission\n"
1504 struct interface
*ifp
;
1505 struct rip_interface
*ri
;
1507 ifp
= (struct interface
*)vty
->index
;
1510 /* Version 1 and 2. */
1511 ri
->ri_send
= RI_RIP_VERSION_1_AND_2
;
1515 DEFUN (no_ip_rip_send_version
,
1516 no_ip_rip_send_version_cmd
,
1517 "no ip rip send version",
1520 "Routing Information Protocol\n"
1521 "Advertisement transmission\n"
1522 "Version control\n")
1524 struct interface
*ifp
;
1525 struct rip_interface
*ri
;
1527 ifp
= (struct interface
*)vty
->index
;
1530 ri
->ri_send
= RI_RIP_UNSPEC
;
1534 ALIAS (no_ip_rip_send_version
,
1535 no_ip_rip_send_version_num_cmd
,
1536 "no ip rip send version (1|2)",
1539 "Routing Information Protocol\n"
1540 "Advertisement transmission\n"
1545 DEFUN (ip_rip_authentication_mode
,
1546 ip_rip_authentication_mode_cmd
,
1547 "ip rip authentication mode (md5|text)",
1549 "Routing Information Protocol\n"
1550 "Authentication control\n"
1551 "Authentication mode\n"
1552 "Keyed message digest\n"
1553 "Clear text authentication\n")
1555 struct interface
*ifp
;
1556 struct rip_interface
*ri
;
1559 ifp
= (struct interface
*)vty
->index
;
1562 if ( (argc
< 1) || (argc
> 2) )
1564 vty_out (vty
, "incorrect argument count%s", VTY_NEWLINE
);
1568 if (strncmp ("md5", argv
[0], strlen (argv
[0])) == 0)
1569 auth_type
= RIP_AUTH_MD5
;
1570 else if (strncmp ("text", argv
[0], strlen (argv
[0])) == 0)
1571 auth_type
= RIP_AUTH_SIMPLE_PASSWORD
;
1574 vty_out (vty
, "mode should be md5 or text%s", VTY_NEWLINE
);
1580 ri
->auth_type
= auth_type
;
1584 if ( (argc
== 2) && (auth_type
!= RIP_AUTH_MD5
) )
1586 vty_out (vty
, "auth length argument only valid for md5%s", VTY_NEWLINE
);
1590 if (strncmp ("r", argv
[1], 1) == 0)
1591 ri
->md5_auth_len
= RIP_AUTH_MD5_SIZE
;
1592 else if (strncmp ("o", argv
[1], 1) == 0)
1593 ri
->md5_auth_len
= RIP_AUTH_MD5_COMPAT_SIZE
;
1597 ri
->auth_type
= auth_type
;
1602 ALIAS (ip_rip_authentication_mode
,
1603 ip_rip_authentication_mode_authlen_cmd
,
1604 "ip rip authentication mode (md5|text) auth-length (rfc|old-ripd)",
1606 "Routing Information Protocol\n"
1607 "Authentication control\n"
1608 "Authentication mode\n"
1609 "Keyed message digest\n"
1610 "Clear text authentication\n"
1611 "MD5 authentication data length\n"
1613 "Old ripd compatible\n")
1615 DEFUN (no_ip_rip_authentication_mode
,
1616 no_ip_rip_authentication_mode_cmd
,
1617 "no ip rip authentication mode",
1620 "Routing Information Protocol\n"
1621 "Authentication control\n"
1622 "Authentication mode\n")
1624 struct interface
*ifp
;
1625 struct rip_interface
*ri
;
1627 ifp
= (struct interface
*)vty
->index
;
1630 ri
->auth_type
= RIP_NO_AUTH
;
1631 ri
->md5_auth_len
= RIP_AUTH_MD5_COMPAT_SIZE
;
1636 ALIAS (no_ip_rip_authentication_mode
,
1637 no_ip_rip_authentication_mode_type_cmd
,
1638 "no ip rip authentication mode (md5|text)",
1641 "Routing Information Protocol\n"
1642 "Authentication control\n"
1643 "Authentication mode\n"
1644 "Keyed message digest\n"
1645 "Clear text authentication\n")
1647 ALIAS (no_ip_rip_authentication_mode
,
1648 no_ip_rip_authentication_mode_type_authlen_cmd
,
1649 "no ip rip authentication mode (md5|text) auth-length (rfc|old-ripd)",
1652 "Routing Information Protocol\n"
1653 "Authentication control\n"
1654 "Authentication mode\n"
1655 "Keyed message digest\n"
1656 "Clear text authentication\n"
1657 "MD5 authentication data length\n"
1659 "Old ripd compatible\n")
1661 DEFUN (ip_rip_authentication_string
,
1662 ip_rip_authentication_string_cmd
,
1663 "ip rip authentication string LINE",
1665 "Routing Information Protocol\n"
1666 "Authentication control\n"
1667 "Authentication string\n"
1668 "Authentication string\n")
1670 struct interface
*ifp
;
1671 struct rip_interface
*ri
;
1673 ifp
= (struct interface
*)vty
->index
;
1676 if (strlen (argv
[0]) > 16)
1678 vty_out (vty
, "%% RIPv2 authentication string must be shorter than 16%s",
1685 vty_out (vty
, "%% key-chain configuration exists%s", VTY_NEWLINE
);
1690 free (ri
->auth_str
);
1692 ri
->auth_str
= strdup (argv
[0]);
1697 DEFUN (no_ip_rip_authentication_string
,
1698 no_ip_rip_authentication_string_cmd
,
1699 "no ip rip authentication string",
1702 "Routing Information Protocol\n"
1703 "Authentication control\n"
1704 "Authentication string\n")
1706 struct interface
*ifp
;
1707 struct rip_interface
*ri
;
1709 ifp
= (struct interface
*)vty
->index
;
1713 free (ri
->auth_str
);
1715 ri
->auth_str
= NULL
;
1720 ALIAS (no_ip_rip_authentication_string
,
1721 no_ip_rip_authentication_string2_cmd
,
1722 "no ip rip authentication string LINE",
1725 "Routing Information Protocol\n"
1726 "Authentication control\n"
1727 "Authentication string\n"
1728 "Authentication string\n")
1730 DEFUN (ip_rip_authentication_key_chain
,
1731 ip_rip_authentication_key_chain_cmd
,
1732 "ip rip authentication key-chain LINE",
1734 "Routing Information Protocol\n"
1735 "Authentication control\n"
1736 "Authentication key-chain\n"
1737 "name of key-chain\n")
1739 struct interface
*ifp
;
1740 struct rip_interface
*ri
;
1742 ifp
= (struct interface
*) vty
->index
;
1747 vty_out (vty
, "%% authentication string configuration exists%s",
1753 free (ri
->key_chain
);
1755 ri
->key_chain
= strdup (argv
[0]);
1760 DEFUN (no_ip_rip_authentication_key_chain
,
1761 no_ip_rip_authentication_key_chain_cmd
,
1762 "no ip rip authentication key-chain",
1765 "Routing Information Protocol\n"
1766 "Authentication control\n"
1767 "Authentication key-chain\n")
1769 struct interface
*ifp
;
1770 struct rip_interface
*ri
;
1772 ifp
= (struct interface
*) vty
->index
;
1776 free (ri
->key_chain
);
1778 ri
->key_chain
= NULL
;
1783 ALIAS (no_ip_rip_authentication_key_chain
,
1784 no_ip_rip_authentication_key_chain2_cmd
,
1785 "no ip rip authentication key-chain LINE",
1788 "Routing Information Protocol\n"
1789 "Authentication control\n"
1790 "Authentication key-chain\n"
1791 "name of key-chain\n")
1793 /* CHANGED: ip rip split-horizon
1794 Cisco and Zebra's command is
1797 DEFUN (ip_rip_split_horizon
,
1798 ip_rip_split_horizon_cmd
,
1799 "ip rip split-horizon",
1801 "Routing Information Protocol\n"
1802 "Perform split horizon\n")
1804 struct interface
*ifp
;
1805 struct rip_interface
*ri
;
1810 ri
->split_horizon
= RIP_SPLIT_HORIZON
;
1814 DEFUN (ip_rip_split_horizon_poisoned_reverse
,
1815 ip_rip_split_horizon_poisoned_reverse_cmd
,
1816 "ip rip split-horizon poisoned-reverse",
1818 "Routing Information Protocol\n"
1819 "Perform split horizon\n"
1820 "With poisoned-reverse\n")
1822 struct interface
*ifp
;
1823 struct rip_interface
*ri
;
1828 ri
->split_horizon
= RIP_SPLIT_HORIZON_POISONED_REVERSE
;
1832 /* CHANGED: no ip rip split-horizon
1833 Cisco and Zebra's command is
1836 DEFUN (no_ip_rip_split_horizon
,
1837 no_ip_rip_split_horizon_cmd
,
1838 "no ip rip split-horizon",
1841 "Routing Information Protocol\n"
1842 "Perform split horizon\n")
1844 struct interface
*ifp
;
1845 struct rip_interface
*ri
;
1850 ri
->split_horizon
= RIP_NO_SPLIT_HORIZON
;
1854 DEFUN (no_ip_rip_split_horizon_poisoned_reverse
,
1855 no_ip_rip_split_horizon_poisoned_reverse_cmd
,
1856 "no ip rip split-horizon poisoned-reverse",
1859 "Routing Information Protocol\n"
1860 "Perform split horizon\n"
1861 "With poisoned-reverse\n")
1863 struct interface
*ifp
;
1864 struct rip_interface
*ri
;
1869 switch( ri
->split_horizon
)
1871 case RIP_SPLIT_HORIZON_POISONED_REVERSE
:
1872 ri
->split_horizon
= RIP_SPLIT_HORIZON
;
1880 DEFUN (rip_passive_interface
,
1881 rip_passive_interface_cmd
,
1882 "passive-interface (IFNAME|default)",
1883 "Suppress routing updates on an interface\n"
1885 "default for all interfaces\n")
1887 const char *ifname
= argv
[0];
1889 if (!strcmp(ifname
,"default")) {
1890 passive_default
= 1;
1891 rip_passive_nondefault_clean();
1894 if (passive_default
)
1895 return rip_passive_nondefault_unset (vty
, ifname
);
1897 return rip_passive_nondefault_set (vty
, ifname
);
1900 DEFUN (no_rip_passive_interface
,
1901 no_rip_passive_interface_cmd
,
1902 "no passive-interface (IFNAME|default)",
1904 "Suppress routing updates on an interface\n"
1906 "default for all interfaces\n")
1908 const char *ifname
= argv
[0];
1910 if (!strcmp(ifname
,"default")) {
1911 passive_default
= 0;
1912 rip_passive_nondefault_clean();
1915 if (passive_default
)
1916 return rip_passive_nondefault_set (vty
, ifname
);
1918 return rip_passive_nondefault_unset (vty
, ifname
);
1921 /* Write rip configuration of each interface. */
1923 rip_interface_config_write (struct vty
*vty
)
1925 struct listnode
*node
;
1926 struct interface
*ifp
;
1928 for (ALL_LIST_ELEMENTS_RO (iflist
, node
, ifp
))
1930 struct rip_interface
*ri
;
1934 /* Do not display the interface if there is no
1935 * configuration about it.
1938 (ri
->split_horizon
== ri
->split_horizon_default
) &&
1939 (ri
->ri_send
== RI_RIP_UNSPEC
) &&
1940 (ri
->ri_receive
== RI_RIP_UNSPEC
) &&
1941 (ri
->auth_type
!= RIP_AUTH_MD5
) &&
1942 (ri
->md5_auth_len
!= RIP_AUTH_MD5_SIZE
) &&
1947 vty_out (vty
, "interface %s%s", ifp
->name
,
1951 vty_out (vty
, " description %s%s", ifp
->desc
,
1954 /* Split horizon. */
1955 if (ri
->split_horizon
!= ri
->split_horizon_default
)
1957 switch (ri
->split_horizon
) {
1958 case RIP_SPLIT_HORIZON
:
1959 vty_out (vty
, " ip rip split-horizon%s", VTY_NEWLINE
);
1961 case RIP_SPLIT_HORIZON_POISONED_REVERSE
:
1962 vty_out (vty
, " ip rip split-horizon poisoned-reverse%s",
1965 case RIP_NO_SPLIT_HORIZON
:
1967 vty_out (vty
, " no ip rip split-horizon%s", VTY_NEWLINE
);
1972 /* RIP version setting. */
1973 if (ri
->ri_send
!= RI_RIP_UNSPEC
)
1974 vty_out (vty
, " ip rip send version %s%s",
1975 lookup (ri_version_msg
, ri
->ri_send
),
1978 if (ri
->ri_receive
!= RI_RIP_UNSPEC
)
1979 vty_out (vty
, " ip rip receive version %s%s",
1980 lookup (ri_version_msg
, ri
->ri_receive
),
1983 /* RIP authentication. */
1984 if (ri
->auth_type
== RIP_AUTH_SIMPLE_PASSWORD
)
1985 vty_out (vty
, " ip rip authentication mode text%s", VTY_NEWLINE
);
1987 if (ri
->auth_type
== RIP_AUTH_MD5
)
1989 vty_out (vty
, " ip rip authentication mode md5");
1990 if (ri
->md5_auth_len
== RIP_AUTH_MD5_COMPAT_SIZE
)
1991 vty_out (vty
, " auth-length old-ripd");
1993 vty_out (vty
, " auth-length rfc");
1994 vty_out (vty
, "%s", VTY_NEWLINE
);
1998 vty_out (vty
, " ip rip authentication string %s%s",
1999 ri
->auth_str
, VTY_NEWLINE
);
2002 vty_out (vty
, " ip rip authentication key-chain %s%s",
2003 ri
->key_chain
, VTY_NEWLINE
);
2005 vty_out (vty
, "!%s", VTY_NEWLINE
);
2011 config_write_rip_network (struct vty
*vty
, int config_mode
)
2015 struct route_node
*node
;
2017 /* Network type RIP enable interface statement. */
2018 for (node
= route_top (rip_enable_network
); node
; node
= route_next (node
))
2020 vty_out (vty
, "%s%s/%d%s",
2021 config_mode
? " network " : " ",
2022 inet_ntoa (node
->p
.u
.prefix4
),
2026 /* Interface name RIP enable statement. */
2027 for (i
= 0; i
< vector_active (rip_enable_interface
); i
++)
2028 if ((ifname
= vector_slot (rip_enable_interface
, i
)) != NULL
)
2029 vty_out (vty
, "%s%s%s",
2030 config_mode
? " network " : " ",
2034 /* RIP neighbors listing. */
2035 for (node
= route_top (rip
->neighbor
); node
; node
= route_next (node
))
2037 vty_out (vty
, "%s%s%s",
2038 config_mode
? " neighbor " : " ",
2039 inet_ntoa (node
->p
.u
.prefix4
),
2042 /* RIP passive interface listing. */
2044 if (passive_default
)
2045 vty_out (vty
, " passive-interface default%s", VTY_NEWLINE
);
2046 for (i
= 0; i
< vector_active (Vrip_passive_nondefault
); i
++)
2047 if ((ifname
= vector_slot (Vrip_passive_nondefault
, i
)) != NULL
)
2048 vty_out (vty
, " %spassive-interface %s%s",
2049 (passive_default
? "no " : ""), ifname
, VTY_NEWLINE
);
2055 static struct cmd_node interface_node
=
2062 /* Called when interface structure allocated. */
2064 rip_interface_new_hook (struct interface
*ifp
)
2066 ifp
->info
= rip_interface_new ();
2070 /* Called when interface structure deleted. */
2072 rip_interface_delete_hook (struct interface
*ifp
)
2074 XFREE (MTYPE_RIP_INTERFACE
, ifp
->info
);
2079 /* Allocate and initialize interface vector. */
2083 /* Default initial size of interface vector. */
2085 if_add_hook (IF_NEW_HOOK
, rip_interface_new_hook
);
2086 if_add_hook (IF_DELETE_HOOK
, rip_interface_delete_hook
);
2088 /* RIP network init. */
2089 rip_enable_interface
= vector_init (1);
2090 rip_enable_network
= route_table_init ();
2092 /* RIP passive interface. */
2093 Vrip_passive_nondefault
= vector_init (1);
2095 /* Install interface node. */
2096 install_node (&interface_node
, rip_interface_config_write
);
2098 /* Install commands. */
2099 install_element (CONFIG_NODE
, &interface_cmd
);
2100 install_element (CONFIG_NODE
, &no_interface_cmd
);
2101 install_default (INTERFACE_NODE
);
2102 install_element (INTERFACE_NODE
, &interface_desc_cmd
);
2103 install_element (INTERFACE_NODE
, &no_interface_desc_cmd
);
2104 install_element (RIP_NODE
, &rip_network_cmd
);
2105 install_element (RIP_NODE
, &no_rip_network_cmd
);
2106 install_element (RIP_NODE
, &rip_neighbor_cmd
);
2107 install_element (RIP_NODE
, &no_rip_neighbor_cmd
);
2109 install_element (RIP_NODE
, &rip_passive_interface_cmd
);
2110 install_element (RIP_NODE
, &no_rip_passive_interface_cmd
);
2112 install_element (INTERFACE_NODE
, &ip_rip_send_version_cmd
);
2113 install_element (INTERFACE_NODE
, &ip_rip_send_version_1_cmd
);
2114 install_element (INTERFACE_NODE
, &ip_rip_send_version_2_cmd
);
2115 install_element (INTERFACE_NODE
, &no_ip_rip_send_version_cmd
);
2116 install_element (INTERFACE_NODE
, &no_ip_rip_send_version_num_cmd
);
2118 install_element (INTERFACE_NODE
, &ip_rip_receive_version_cmd
);
2119 install_element (INTERFACE_NODE
, &ip_rip_receive_version_1_cmd
);
2120 install_element (INTERFACE_NODE
, &ip_rip_receive_version_2_cmd
);
2121 install_element (INTERFACE_NODE
, &no_ip_rip_receive_version_cmd
);
2122 install_element (INTERFACE_NODE
, &no_ip_rip_receive_version_num_cmd
);
2124 install_element (INTERFACE_NODE
, &ip_rip_authentication_mode_cmd
);
2125 install_element (INTERFACE_NODE
, &ip_rip_authentication_mode_authlen_cmd
);
2126 install_element (INTERFACE_NODE
, &no_ip_rip_authentication_mode_cmd
);
2127 install_element (INTERFACE_NODE
, &no_ip_rip_authentication_mode_type_cmd
);
2128 install_element (INTERFACE_NODE
, &no_ip_rip_authentication_mode_type_authlen_cmd
);
2130 install_element (INTERFACE_NODE
, &ip_rip_authentication_key_chain_cmd
);
2131 install_element (INTERFACE_NODE
, &no_ip_rip_authentication_key_chain_cmd
);
2132 install_element (INTERFACE_NODE
, &no_ip_rip_authentication_key_chain2_cmd
);
2134 install_element (INTERFACE_NODE
, &ip_rip_authentication_string_cmd
);
2135 install_element (INTERFACE_NODE
, &no_ip_rip_authentication_string_cmd
);
2136 install_element (INTERFACE_NODE
, &no_ip_rip_authentication_string2_cmd
);
2138 install_element (INTERFACE_NODE
, &ip_rip_split_horizon_cmd
);
2139 install_element (INTERFACE_NODE
, &ip_rip_split_horizon_poisoned_reverse_cmd
);
2140 install_element (INTERFACE_NODE
, &no_ip_rip_split_horizon_cmd
);
2141 install_element (INTERFACE_NODE
, &no_ip_rip_split_horizon_poisoned_reverse_cmd
);