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
);
243 /* Send RIP request to the neighbor. */
245 rip_request_neighbor (struct in_addr addr
)
247 struct sockaddr_in to
;
249 memset (&to
, 0, sizeof (struct sockaddr_in
));
250 to
.sin_port
= htons (RIP_PORT_DEFAULT
);
253 rip_request_send (&to
, NULL
, rip
->version_send
, NULL
);
256 /* Request routes at all interfaces. */
258 rip_request_neighbor_all (void)
260 struct route_node
*rp
;
265 if (IS_RIP_DEBUG_EVENT
)
266 zlog_debug ("request to the all neighbor");
268 /* Send request to all neighbor. */
269 for (rp
= route_top (rip
->neighbor
); rp
; rp
= route_next (rp
))
271 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 %llx metric %d mtu %d is down",
408 ifp
->name
, ifp
->ifindex
, (unsigned long long)ifp
->flags
,
409 ifp
->metric
, ifp
->mtu
);
414 /* Inteface link up message processing */
416 rip_interface_up (int command
, struct zclient
*zclient
, zebra_size_t length
)
418 struct interface
*ifp
;
420 /* zebra_interface_state_read () updates interface structure in
422 ifp
= zebra_interface_state_read (zclient
->ibuf
);
427 if (IS_RIP_DEBUG_ZEBRA
)
428 zlog_debug ("interface %s index %d flags %#llx metric %d mtu %d is up",
429 ifp
->name
, ifp
->ifindex
, (unsigned long long) ifp
->flags
,
430 ifp
->metric
, ifp
->mtu
);
432 /* Check if this interface is RIP enabled or not.*/
433 rip_enable_apply (ifp
);
435 /* Check for a passive interface */
436 rip_passive_interface_apply (ifp
);
438 /* Apply distribute list to the all interface. */
439 rip_distribute_update_interface (ifp
);
444 /* Inteface addition message from zebra. */
446 rip_interface_add (int command
, struct zclient
*zclient
, zebra_size_t length
)
448 struct interface
*ifp
;
450 ifp
= zebra_interface_add_read (zclient
->ibuf
);
452 if (IS_RIP_DEBUG_ZEBRA
)
453 zlog_debug ("interface add %s index %d flags %#llx metric %d mtu %d",
454 ifp
->name
, ifp
->ifindex
, (unsigned long long) ifp
->flags
,
455 ifp
->metric
, ifp
->mtu
);
457 /* Check if this interface is RIP enabled or not.*/
458 rip_enable_apply (ifp
);
460 /* Check for a passive interface */
461 rip_passive_interface_apply (ifp
);
463 /* Apply distribute list to the all interface. */
464 rip_distribute_update_interface (ifp
);
466 /* rip_request_neighbor_all (); */
468 /* Check interface routemap. */
469 rip_if_rmap_update_interface (ifp
);
475 rip_interface_delete (int command
, struct zclient
*zclient
,
478 struct interface
*ifp
;
483 /* zebra_interface_state_read() updates interface structure in iflist */
484 ifp
= zebra_interface_state_read(s
);
489 if (if_is_up (ifp
)) {
493 zlog_info("interface delete %s index %d flags %#llx metric %d mtu %d",
494 ifp
->name
, ifp
->ifindex
, (unsigned long long) ifp
->flags
,
495 ifp
->metric
, ifp
->mtu
);
497 /* To support pseudo interface do not free interface structure. */
498 /* if_delete(ifp); */
499 ifp
->ifindex
= IFINDEX_INTERNAL
;
505 rip_interface_clean (void)
507 struct listnode
*node
;
508 struct interface
*ifp
;
509 struct rip_interface
*ri
;
511 for (ALL_LIST_ELEMENTS_RO (iflist
, node
, ifp
))
515 ri
->enable_network
= 0;
516 ri
->enable_interface
= 0;
521 thread_cancel (ri
->t_wakeup
);
528 rip_interface_reset (void)
530 struct listnode
*node
;
531 struct interface
*ifp
;
532 struct rip_interface
*ri
;
534 for (ALL_LIST_ELEMENTS_RO (iflist
, node
, ifp
))
538 ri
->enable_network
= 0;
539 ri
->enable_interface
= 0;
542 ri
->ri_send
= RI_RIP_UNSPEC
;
543 ri
->ri_receive
= RI_RIP_UNSPEC
;
545 ri
->auth_type
= RIP_NO_AUTH
;
554 free (ri
->key_chain
);
555 ri
->key_chain
= NULL
;
558 ri
->split_horizon
= RIP_NO_SPLIT_HORIZON
;
559 ri
->split_horizon_default
= RIP_NO_SPLIT_HORIZON
;
561 ri
->list
[RIP_FILTER_IN
] = NULL
;
562 ri
->list
[RIP_FILTER_OUT
] = NULL
;
564 ri
->prefix
[RIP_FILTER_IN
] = NULL
;
565 ri
->prefix
[RIP_FILTER_OUT
] = NULL
;
569 thread_cancel (ri
->t_wakeup
);
573 ri
->recv_badpackets
= 0;
574 ri
->recv_badroutes
= 0;
575 ri
->sent_updates
= 0;
582 rip_if_down(struct interface
*ifp
)
584 struct route_node
*rp
;
585 struct rip_info
*rinfo
;
586 struct rip_interface
*ri
= NULL
;
589 for (rp
= route_top (rip
->table
); rp
; rp
= route_next (rp
))
590 if ((rinfo
= rp
->info
) != NULL
)
592 /* Routes got through this interface. */
593 if (rinfo
->ifindex
== ifp
->ifindex
&&
594 rinfo
->type
== ZEBRA_ROUTE_RIP
&&
595 rinfo
->sub_type
== RIP_ROUTE_RTE
)
597 rip_zebra_ipv4_delete ((struct prefix_ipv4
*) &rp
->p
,
601 rip_redistribute_delete (rinfo
->type
,rinfo
->sub_type
,
602 (struct prefix_ipv4
*)&rp
->p
,
607 /* All redistributed routes but static and system */
608 if ((rinfo
->ifindex
== ifp
->ifindex
) &&
609 /* (rinfo->type != ZEBRA_ROUTE_STATIC) && */
610 (rinfo
->type
!= ZEBRA_ROUTE_SYSTEM
))
611 rip_redistribute_delete (rinfo
->type
,rinfo
->sub_type
,
612 (struct prefix_ipv4
*)&rp
->p
,
622 if (IS_RIP_DEBUG_EVENT
)
623 zlog_debug ("turn off %s", ifp
->name
);
625 /* Leave from multicast group. */
626 rip_multicast_leave (ifp
, rip
->sock
);
634 /* Needed for stop RIP process. */
638 struct interface
*ifp
;
639 struct listnode
*node
, *nnode
;
641 for (ALL_LIST_ELEMENTS (iflist
, node
, nnode
, ifp
))
646 rip_apply_address_add (struct connected
*ifc
)
648 struct prefix_ipv4 address
;
654 if (! if_is_up(ifc
->ifp
))
659 memset (&address
, 0, sizeof (address
));
660 address
.family
= p
->family
;
661 address
.prefix
= p
->u
.prefix4
;
662 address
.prefixlen
= p
->prefixlen
;
663 apply_mask_ipv4(&address
);
665 /* Check if this interface is RIP enabled or not
666 or Check if this address's prefix is RIP enabled */
667 if ((rip_enable_if_lookup(ifc
->ifp
->name
) >= 0) ||
668 (rip_enable_network_lookup2(ifc
) >= 0))
669 rip_redistribute_add(ZEBRA_ROUTE_CONNECT
, RIP_ROUTE_INTERFACE
,
670 &address
, ifc
->ifp
->ifindex
, NULL
, 0, 0);
675 rip_interface_address_add (int command
, struct zclient
*zclient
,
678 struct connected
*ifc
;
681 ifc
= zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_ADD
,
689 if (p
->family
== AF_INET
)
691 if (IS_RIP_DEBUG_ZEBRA
)
692 zlog_debug ("connected address %s/%d is added",
693 inet_ntoa (p
->u
.prefix4
), p
->prefixlen
);
695 rip_enable_apply(ifc
->ifp
);
696 /* Check if this prefix needs to be redistributed */
697 rip_apply_address_add(ifc
);
700 rip_ifaddr_add (ifc
->ifp
, ifc
);
701 #endif /* HAVE_SNMP */
708 rip_apply_address_del (struct connected
*ifc
) {
709 struct prefix_ipv4 address
;
715 if (! if_is_up(ifc
->ifp
))
720 memset (&address
, 0, sizeof (address
));
721 address
.family
= p
->family
;
722 address
.prefix
= p
->u
.prefix4
;
723 address
.prefixlen
= p
->prefixlen
;
724 apply_mask_ipv4(&address
);
726 rip_redistribute_delete(ZEBRA_ROUTE_CONNECT
, RIP_ROUTE_INTERFACE
,
727 &address
, ifc
->ifp
->ifindex
);
731 rip_interface_address_delete (int command
, struct zclient
*zclient
,
734 struct connected
*ifc
;
737 ifc
= zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_DELETE
,
743 if (p
->family
== AF_INET
)
745 if (IS_RIP_DEBUG_ZEBRA
)
746 zlog_debug ("connected address %s/%d is deleted",
747 inet_ntoa (p
->u
.prefix4
), p
->prefixlen
);
750 rip_ifaddr_delete (ifc
->ifp
, ifc
);
751 #endif /* HAVE_SNMP */
753 /* Chech wether this prefix needs to be removed */
754 rip_apply_address_del(ifc
);
758 connected_free (ifc
);
765 /* Check interface is enabled by network statement. */
766 /* Check wether the interface has at least a connected prefix that
767 * is within the ripng_enable_network table. */
769 rip_enable_network_lookup_if (struct interface
*ifp
)
771 struct listnode
*node
, *nnode
;
772 struct connected
*connected
;
773 struct prefix_ipv4 address
;
775 for (ALL_LIST_ELEMENTS (ifp
->connected
, node
, nnode
, connected
))
778 struct route_node
*node
;
780 p
= connected
->address
;
782 if (p
->family
== AF_INET
)
784 address
.family
= AF_INET
;
785 address
.prefix
= p
->u
.prefix4
;
786 address
.prefixlen
= IPV4_MAX_BITLEN
;
788 node
= route_node_match (rip_enable_network
,
789 (struct prefix
*)&address
);
792 route_unlock_node (node
);
800 /* Check wether connected is within the ripng_enable_network table. */
802 rip_enable_network_lookup2 (struct connected
*connected
)
804 struct prefix_ipv4 address
;
807 p
= connected
->address
;
809 if (p
->family
== AF_INET
) {
810 struct route_node
*node
;
812 address
.family
= p
->family
;
813 address
.prefix
= p
->u
.prefix4
;
814 address
.prefixlen
= IPV4_MAX_BITLEN
;
816 /* LPM on p->family, p->u.prefix4/IPV4_MAX_BITLEN within rip_enable_network */
817 node
= route_node_match (rip_enable_network
,
818 (struct prefix
*)&address
);
821 route_unlock_node (node
);
828 /* Add RIP enable network. */
830 rip_enable_network_add (struct prefix
*p
)
832 struct route_node
*node
;
834 node
= route_node_get (rip_enable_network
, p
);
838 route_unlock_node (node
);
842 node
->info
= (char *) "enabled";
844 /* XXX: One should find a better solution than a generic one */
845 rip_enable_apply_all();
850 /* Delete RIP enable network. */
852 rip_enable_network_delete (struct prefix
*p
)
854 struct route_node
*node
;
856 node
= route_node_lookup (rip_enable_network
, p
);
861 /* Unlock info lock. */
862 route_unlock_node (node
);
864 /* Unlock lookup lock. */
865 route_unlock_node (node
);
867 /* XXX: One should find a better solution than a generic one */
868 rip_enable_apply_all ();
875 /* Check interface is enabled by ifname statement. */
877 rip_enable_if_lookup (const char *ifname
)
882 for (i
= 0; i
< vector_active (rip_enable_interface
); i
++)
883 if ((str
= vector_slot (rip_enable_interface
, i
)) != NULL
)
884 if (strcmp (str
, ifname
) == 0)
889 /* Add interface to rip_enable_if. */
891 rip_enable_if_add (const char *ifname
)
895 ret
= rip_enable_if_lookup (ifname
);
899 vector_set (rip_enable_interface
, strdup (ifname
));
901 rip_enable_apply_all(); /* TODOVJ */
906 /* Delete interface from rip_enable_if. */
908 rip_enable_if_delete (const char *ifname
)
913 index
= rip_enable_if_lookup (ifname
);
917 str
= vector_slot (rip_enable_interface
, index
);
919 vector_unset (rip_enable_interface
, index
);
921 rip_enable_apply_all(); /* TODOVJ */
926 /* Join to multicast group and send request to the interface. */
928 rip_interface_wakeup (struct thread
*t
)
930 struct interface
*ifp
;
931 struct rip_interface
*ri
;
934 ifp
= THREAD_ARG (t
);
939 /* Join to multicast group. */
940 if (rip_multicast_join (ifp
, rip
->sock
) < 0)
942 zlog_err ("multicast join failed, interface %s not running", ifp
->name
);
946 /* Set running flag. */
949 /* Send RIP request to the interface. */
950 rip_request_interface (ifp
);
956 rip_connect_set (struct interface
*ifp
, int set
)
958 struct listnode
*node
, *nnode
;
959 struct connected
*connected
;
960 struct prefix_ipv4 address
;
962 for (ALL_LIST_ELEMENTS (ifp
->connected
, node
, nnode
, connected
))
965 p
= connected
->address
;
967 if (p
->family
!= AF_INET
)
970 address
.family
= AF_INET
;
971 address
.prefix
= p
->u
.prefix4
;
972 address
.prefixlen
= p
->prefixlen
;
973 apply_mask_ipv4 (&address
);
976 /* Check once more wether this prefix is within a "network IF_OR_PREF" one */
977 if ((rip_enable_if_lookup(connected
->ifp
->name
) >= 0) ||
978 (rip_enable_network_lookup2(connected
) >= 0))
979 rip_redistribute_add (ZEBRA_ROUTE_CONNECT
, RIP_ROUTE_INTERFACE
,
980 &address
, connected
->ifp
->ifindex
,
984 rip_redistribute_delete (ZEBRA_ROUTE_CONNECT
, RIP_ROUTE_INTERFACE
,
985 &address
, connected
->ifp
->ifindex
);
986 if (rip_redistribute_check (ZEBRA_ROUTE_CONNECT
))
987 rip_redistribute_add (ZEBRA_ROUTE_CONNECT
, RIP_ROUTE_REDISTRIBUTE
,
988 &address
, connected
->ifp
->ifindex
,
994 /* Update interface status. */
996 rip_enable_apply (struct interface
*ifp
)
999 struct rip_interface
*ri
= NULL
;
1001 /* Check interface. */
1002 if (! if_is_operative (ifp
))
1007 /* Check network configuration. */
1008 ret
= rip_enable_network_lookup_if (ifp
);
1010 /* If the interface is matched. */
1012 ri
->enable_network
= 1;
1014 ri
->enable_network
= 0;
1016 /* Check interface name configuration. */
1017 ret
= rip_enable_if_lookup (ifp
->name
);
1019 ri
->enable_interface
= 1;
1021 ri
->enable_interface
= 0;
1023 /* any interface MUST have an IPv4 address */
1024 if ( ! rip_if_ipv4_address_check (ifp
) )
1026 ri
->enable_network
= 0;
1027 ri
->enable_interface
= 0;
1030 /* Update running status of the interface. */
1031 if (ri
->enable_network
|| ri
->enable_interface
)
1034 if (IS_RIP_DEBUG_EVENT
)
1035 zlog_debug ("turn on %s", ifp
->name
);
1037 /* Add interface wake up thread. */
1039 ri
->t_wakeup
= thread_add_timer (master
, rip_interface_wakeup
,
1041 rip_connect_set (ifp
, 1);
1048 /* Might as well clean up the route table as well
1049 * rip_if_down sets to 0 ri->running, and displays "turn off %s"
1053 rip_connect_set (ifp
, 0);
1058 /* Apply network configuration to all interface. */
1060 rip_enable_apply_all ()
1062 struct interface
*ifp
;
1063 struct listnode
*node
, *nnode
;
1065 /* Check each interface. */
1066 for (ALL_LIST_ELEMENTS (iflist
, node
, nnode
, ifp
))
1067 rip_enable_apply (ifp
);
1071 rip_neighbor_lookup (struct sockaddr_in
*from
)
1073 struct prefix_ipv4 p
;
1074 struct route_node
*node
;
1076 memset (&p
, 0, sizeof (struct prefix_ipv4
));
1078 p
.prefix
= from
->sin_addr
;
1079 p
.prefixlen
= IPV4_MAX_BITLEN
;
1081 node
= route_node_lookup (rip
->neighbor
, (struct prefix
*) &p
);
1084 route_unlock_node (node
);
1090 /* Add new RIP neighbor to the neighbor tree. */
1092 rip_neighbor_add (struct prefix_ipv4
*p
)
1094 struct route_node
*node
;
1096 node
= route_node_get (rip
->neighbor
, (struct prefix
*) p
);
1101 node
->info
= rip
->neighbor
;
1106 /* Delete RIP neighbor from the neighbor tree. */
1108 rip_neighbor_delete (struct prefix_ipv4
*p
)
1110 struct route_node
*node
;
1112 /* Lock for look up. */
1113 node
= route_node_lookup (rip
->neighbor
, (struct prefix
*) p
);
1119 /* Unlock lookup lock. */
1120 route_unlock_node (node
);
1122 /* Unlock real neighbor information lock. */
1123 route_unlock_node (node
);
1128 /* Clear all network and neighbor configuration. */
1130 rip_clean_network ()
1134 struct route_node
*rn
;
1136 /* rip_enable_network. */
1137 for (rn
= route_top (rip_enable_network
); rn
; rn
= route_next (rn
))
1141 route_unlock_node (rn
);
1144 /* rip_enable_interface. */
1145 for (i
= 0; i
< vector_active (rip_enable_interface
); i
++)
1146 if ((str
= vector_slot (rip_enable_interface
, i
)) != NULL
)
1149 vector_slot (rip_enable_interface
, i
) = NULL
;
1153 /* Utility function for looking up passive interface settings. */
1155 rip_passive_nondefault_lookup (const char *ifname
)
1160 for (i
= 0; i
< vector_active (Vrip_passive_nondefault
); i
++)
1161 if ((str
= vector_slot (Vrip_passive_nondefault
, i
)) != NULL
)
1162 if (strcmp (str
, ifname
) == 0)
1168 rip_passive_interface_apply (struct interface
*ifp
)
1170 struct rip_interface
*ri
;
1174 ri
->passive
= ((rip_passive_nondefault_lookup (ifp
->name
) < 0) ?
1175 passive_default
: !passive_default
);
1177 if (IS_RIP_DEBUG_ZEBRA
)
1178 zlog_debug ("interface %s: passive = %d",ifp
->name
,ri
->passive
);
1182 rip_passive_interface_apply_all (void)
1184 struct interface
*ifp
;
1185 struct listnode
*node
, *nnode
;
1187 for (ALL_LIST_ELEMENTS (iflist
, node
, nnode
, ifp
))
1188 rip_passive_interface_apply (ifp
);
1191 /* Passive interface. */
1193 rip_passive_nondefault_set (struct vty
*vty
, const char *ifname
)
1195 if (rip_passive_nondefault_lookup (ifname
) >= 0)
1198 vector_set (Vrip_passive_nondefault
, strdup (ifname
));
1200 rip_passive_interface_apply_all ();
1206 rip_passive_nondefault_unset (struct vty
*vty
, const char *ifname
)
1211 i
= rip_passive_nondefault_lookup (ifname
);
1215 str
= vector_slot (Vrip_passive_nondefault
, i
);
1217 vector_unset (Vrip_passive_nondefault
, i
);
1219 rip_passive_interface_apply_all ();
1224 /* Free all configured RIP passive-interface settings. */
1226 rip_passive_nondefault_clean (void)
1231 for (i
= 0; i
< vector_active (Vrip_passive_nondefault
); i
++)
1232 if ((str
= vector_slot (Vrip_passive_nondefault
, i
)) != NULL
)
1235 vector_slot (Vrip_passive_nondefault
, i
) = NULL
;
1237 rip_passive_interface_apply_all ();
1240 /* RIP enable network or interface configuration. */
1243 "network (A.B.C.D/M|WORD)",
1244 "Enable routing on an IP network\n"
1245 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1249 struct prefix_ipv4 p
;
1251 ret
= str2prefix_ipv4 (argv
[0], &p
);
1254 ret
= rip_enable_network_add ((struct prefix
*) &p
);
1256 ret
= rip_enable_if_add (argv
[0]);
1260 vty_out (vty
, "There is a same network configuration %s%s", argv
[0],
1268 /* RIP enable network or interface configuration. */
1269 DEFUN (no_rip_network
,
1271 "no network (A.B.C.D/M|WORD)",
1273 "Enable routing on an IP network\n"
1274 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1278 struct prefix_ipv4 p
;
1280 ret
= str2prefix_ipv4 (argv
[0], &p
);
1283 ret
= rip_enable_network_delete ((struct prefix
*) &p
);
1285 ret
= rip_enable_if_delete (argv
[0]);
1289 vty_out (vty
, "Can't find network configuration %s%s", argv
[0],
1297 /* RIP neighbor configuration set. */
1298 DEFUN (rip_neighbor
,
1301 "Specify a neighbor router\n"
1302 "Neighbor address\n")
1305 struct prefix_ipv4 p
;
1307 ret
= str2prefix_ipv4 (argv
[0], &p
);
1311 vty_out (vty
, "Please specify address by A.B.C.D%s", VTY_NEWLINE
);
1315 rip_neighbor_add (&p
);
1320 /* RIP neighbor configuration unset. */
1321 DEFUN (no_rip_neighbor
,
1322 no_rip_neighbor_cmd
,
1323 "no neighbor A.B.C.D",
1325 "Specify a neighbor router\n"
1326 "Neighbor address\n")
1329 struct prefix_ipv4 p
;
1331 ret
= str2prefix_ipv4 (argv
[0], &p
);
1335 vty_out (vty
, "Please specify address by A.B.C.D%s", VTY_NEWLINE
);
1339 rip_neighbor_delete (&p
);
1344 DEFUN (ip_rip_receive_version
,
1345 ip_rip_receive_version_cmd
,
1346 "ip rip receive version (1|2)",
1348 "Routing Information Protocol\n"
1349 "Advertisement reception\n"
1354 struct interface
*ifp
;
1355 struct rip_interface
*ri
;
1357 ifp
= (struct interface
*)vty
->index
;
1361 if (atoi (argv
[0]) == 1)
1363 ri
->ri_receive
= RI_RIP_VERSION_1
;
1366 if (atoi (argv
[0]) == 2)
1368 ri
->ri_receive
= RI_RIP_VERSION_2
;
1374 DEFUN (ip_rip_receive_version_1
,
1375 ip_rip_receive_version_1_cmd
,
1376 "ip rip receive version 1 2",
1378 "Routing Information Protocol\n"
1379 "Advertisement reception\n"
1384 struct interface
*ifp
;
1385 struct rip_interface
*ri
;
1387 ifp
= (struct interface
*)vty
->index
;
1390 /* Version 1 and 2. */
1391 ri
->ri_receive
= RI_RIP_VERSION_1_AND_2
;
1395 DEFUN (ip_rip_receive_version_2
,
1396 ip_rip_receive_version_2_cmd
,
1397 "ip rip receive version 2 1",
1399 "Routing Information Protocol\n"
1400 "Advertisement reception\n"
1405 struct interface
*ifp
;
1406 struct rip_interface
*ri
;
1408 ifp
= (struct interface
*)vty
->index
;
1411 /* Version 1 and 2. */
1412 ri
->ri_receive
= RI_RIP_VERSION_1_AND_2
;
1416 DEFUN (no_ip_rip_receive_version
,
1417 no_ip_rip_receive_version_cmd
,
1418 "no ip rip receive version",
1421 "Routing Information Protocol\n"
1422 "Advertisement reception\n"
1423 "Version control\n")
1425 struct interface
*ifp
;
1426 struct rip_interface
*ri
;
1428 ifp
= (struct interface
*)vty
->index
;
1431 ri
->ri_receive
= RI_RIP_UNSPEC
;
1435 ALIAS (no_ip_rip_receive_version
,
1436 no_ip_rip_receive_version_num_cmd
,
1437 "no ip rip receive version (1|2)",
1440 "Routing Information Protocol\n"
1441 "Advertisement reception\n"
1446 DEFUN (ip_rip_send_version
,
1447 ip_rip_send_version_cmd
,
1448 "ip rip send version (1|2)",
1450 "Routing Information Protocol\n"
1451 "Advertisement transmission\n"
1456 struct interface
*ifp
;
1457 struct rip_interface
*ri
;
1459 ifp
= (struct interface
*)vty
->index
;
1463 if (atoi (argv
[0]) == 1)
1465 ri
->ri_send
= RI_RIP_VERSION_1
;
1468 if (atoi (argv
[0]) == 2)
1470 ri
->ri_send
= RI_RIP_VERSION_2
;
1476 DEFUN (ip_rip_send_version_1
,
1477 ip_rip_send_version_1_cmd
,
1478 "ip rip send version 1 2",
1480 "Routing Information Protocol\n"
1481 "Advertisement transmission\n"
1486 struct interface
*ifp
;
1487 struct rip_interface
*ri
;
1489 ifp
= (struct interface
*)vty
->index
;
1492 /* Version 1 and 2. */
1493 ri
->ri_send
= RI_RIP_VERSION_1_AND_2
;
1497 DEFUN (ip_rip_send_version_2
,
1498 ip_rip_send_version_2_cmd
,
1499 "ip rip send version 2 1",
1501 "Routing Information Protocol\n"
1502 "Advertisement transmission\n"
1507 struct interface
*ifp
;
1508 struct rip_interface
*ri
;
1510 ifp
= (struct interface
*)vty
->index
;
1513 /* Version 1 and 2. */
1514 ri
->ri_send
= RI_RIP_VERSION_1_AND_2
;
1518 DEFUN (no_ip_rip_send_version
,
1519 no_ip_rip_send_version_cmd
,
1520 "no ip rip send version",
1523 "Routing Information Protocol\n"
1524 "Advertisement transmission\n"
1525 "Version control\n")
1527 struct interface
*ifp
;
1528 struct rip_interface
*ri
;
1530 ifp
= (struct interface
*)vty
->index
;
1533 ri
->ri_send
= RI_RIP_UNSPEC
;
1537 ALIAS (no_ip_rip_send_version
,
1538 no_ip_rip_send_version_num_cmd
,
1539 "no ip rip send version (1|2)",
1542 "Routing Information Protocol\n"
1543 "Advertisement transmission\n"
1548 DEFUN (ip_rip_authentication_mode
,
1549 ip_rip_authentication_mode_cmd
,
1550 "ip rip authentication mode (md5|text)",
1552 "Routing Information Protocol\n"
1553 "Authentication control\n"
1554 "Authentication mode\n"
1555 "Keyed message digest\n"
1556 "Clear text authentication\n")
1558 struct interface
*ifp
;
1559 struct rip_interface
*ri
;
1562 ifp
= (struct interface
*)vty
->index
;
1565 if ( (argc
< 1) || (argc
> 2) )
1567 vty_out (vty
, "incorrect argument count%s", VTY_NEWLINE
);
1571 if (strncmp ("md5", argv
[0], strlen (argv
[0])) == 0)
1572 auth_type
= RIP_AUTH_MD5
;
1573 else if (strncmp ("text", argv
[0], strlen (argv
[0])) == 0)
1574 auth_type
= RIP_AUTH_SIMPLE_PASSWORD
;
1577 vty_out (vty
, "mode should be md5 or text%s", VTY_NEWLINE
);
1583 ri
->auth_type
= auth_type
;
1587 if ( (argc
== 2) && (auth_type
!= RIP_AUTH_MD5
) )
1589 vty_out (vty
, "auth length argument only valid for md5%s", VTY_NEWLINE
);
1593 if (strncmp ("r", argv
[1], 1) == 0)
1594 ri
->md5_auth_len
= RIP_AUTH_MD5_SIZE
;
1595 else if (strncmp ("o", argv
[1], 1) == 0)
1596 ri
->md5_auth_len
= RIP_AUTH_MD5_COMPAT_SIZE
;
1600 ri
->auth_type
= auth_type
;
1605 ALIAS (ip_rip_authentication_mode
,
1606 ip_rip_authentication_mode_authlen_cmd
,
1607 "ip rip authentication mode (md5|text) auth-length (rfc|old-ripd)",
1609 "Routing Information Protocol\n"
1610 "Authentication control\n"
1611 "Authentication mode\n"
1612 "Keyed message digest\n"
1613 "Clear text authentication\n"
1614 "MD5 authentication data length\n"
1616 "Old ripd compatible\n")
1618 DEFUN (no_ip_rip_authentication_mode
,
1619 no_ip_rip_authentication_mode_cmd
,
1620 "no ip rip authentication mode",
1623 "Routing Information Protocol\n"
1624 "Authentication control\n"
1625 "Authentication mode\n")
1627 struct interface
*ifp
;
1628 struct rip_interface
*ri
;
1630 ifp
= (struct interface
*)vty
->index
;
1633 ri
->auth_type
= RIP_NO_AUTH
;
1634 ri
->md5_auth_len
= RIP_AUTH_MD5_COMPAT_SIZE
;
1639 ALIAS (no_ip_rip_authentication_mode
,
1640 no_ip_rip_authentication_mode_type_cmd
,
1641 "no ip rip authentication mode (md5|text)",
1644 "Routing Information Protocol\n"
1645 "Authentication control\n"
1646 "Authentication mode\n"
1647 "Keyed message digest\n"
1648 "Clear text authentication\n")
1650 ALIAS (no_ip_rip_authentication_mode
,
1651 no_ip_rip_authentication_mode_type_authlen_cmd
,
1652 "no ip rip authentication mode (md5|text) auth-length (rfc|old-ripd)",
1655 "Routing Information Protocol\n"
1656 "Authentication control\n"
1657 "Authentication mode\n"
1658 "Keyed message digest\n"
1659 "Clear text authentication\n"
1660 "MD5 authentication data length\n"
1662 "Old ripd compatible\n")
1664 DEFUN (ip_rip_authentication_string
,
1665 ip_rip_authentication_string_cmd
,
1666 "ip rip authentication string LINE",
1668 "Routing Information Protocol\n"
1669 "Authentication control\n"
1670 "Authentication string\n"
1671 "Authentication string\n")
1673 struct interface
*ifp
;
1674 struct rip_interface
*ri
;
1676 ifp
= (struct interface
*)vty
->index
;
1679 if (strlen (argv
[0]) > 16)
1681 vty_out (vty
, "%% RIPv2 authentication string must be shorter than 16%s",
1688 vty_out (vty
, "%% key-chain configuration exists%s", VTY_NEWLINE
);
1693 free (ri
->auth_str
);
1695 ri
->auth_str
= strdup (argv
[0]);
1700 DEFUN (no_ip_rip_authentication_string
,
1701 no_ip_rip_authentication_string_cmd
,
1702 "no ip rip authentication string",
1705 "Routing Information Protocol\n"
1706 "Authentication control\n"
1707 "Authentication string\n")
1709 struct interface
*ifp
;
1710 struct rip_interface
*ri
;
1712 ifp
= (struct interface
*)vty
->index
;
1716 free (ri
->auth_str
);
1718 ri
->auth_str
= NULL
;
1723 ALIAS (no_ip_rip_authentication_string
,
1724 no_ip_rip_authentication_string2_cmd
,
1725 "no ip rip authentication string LINE",
1728 "Routing Information Protocol\n"
1729 "Authentication control\n"
1730 "Authentication string\n"
1731 "Authentication string\n")
1733 DEFUN (ip_rip_authentication_key_chain
,
1734 ip_rip_authentication_key_chain_cmd
,
1735 "ip rip authentication key-chain LINE",
1737 "Routing Information Protocol\n"
1738 "Authentication control\n"
1739 "Authentication key-chain\n"
1740 "name of key-chain\n")
1742 struct interface
*ifp
;
1743 struct rip_interface
*ri
;
1745 ifp
= (struct interface
*) vty
->index
;
1750 vty_out (vty
, "%% authentication string configuration exists%s",
1756 free (ri
->key_chain
);
1758 ri
->key_chain
= strdup (argv
[0]);
1763 DEFUN (no_ip_rip_authentication_key_chain
,
1764 no_ip_rip_authentication_key_chain_cmd
,
1765 "no ip rip authentication key-chain",
1768 "Routing Information Protocol\n"
1769 "Authentication control\n"
1770 "Authentication key-chain\n")
1772 struct interface
*ifp
;
1773 struct rip_interface
*ri
;
1775 ifp
= (struct interface
*) vty
->index
;
1779 free (ri
->key_chain
);
1781 ri
->key_chain
= NULL
;
1786 ALIAS (no_ip_rip_authentication_key_chain
,
1787 no_ip_rip_authentication_key_chain2_cmd
,
1788 "no ip rip authentication key-chain LINE",
1791 "Routing Information Protocol\n"
1792 "Authentication control\n"
1793 "Authentication key-chain\n"
1794 "name of key-chain\n")
1796 /* CHANGED: ip rip split-horizon
1797 Cisco and Zebra's command is
1800 DEFUN (ip_rip_split_horizon
,
1801 ip_rip_split_horizon_cmd
,
1802 "ip rip split-horizon",
1804 "Routing Information Protocol\n"
1805 "Perform split horizon\n")
1807 struct interface
*ifp
;
1808 struct rip_interface
*ri
;
1813 ri
->split_horizon
= RIP_SPLIT_HORIZON
;
1817 DEFUN (ip_rip_split_horizon_poisoned_reverse
,
1818 ip_rip_split_horizon_poisoned_reverse_cmd
,
1819 "ip rip split-horizon poisoned-reverse",
1821 "Routing Information Protocol\n"
1822 "Perform split horizon\n"
1823 "With poisoned-reverse\n")
1825 struct interface
*ifp
;
1826 struct rip_interface
*ri
;
1831 ri
->split_horizon
= RIP_SPLIT_HORIZON_POISONED_REVERSE
;
1835 /* CHANGED: no ip rip split-horizon
1836 Cisco and Zebra's command is
1839 DEFUN (no_ip_rip_split_horizon
,
1840 no_ip_rip_split_horizon_cmd
,
1841 "no ip rip split-horizon",
1844 "Routing Information Protocol\n"
1845 "Perform split horizon\n")
1847 struct interface
*ifp
;
1848 struct rip_interface
*ri
;
1853 ri
->split_horizon
= RIP_NO_SPLIT_HORIZON
;
1857 DEFUN (no_ip_rip_split_horizon_poisoned_reverse
,
1858 no_ip_rip_split_horizon_poisoned_reverse_cmd
,
1859 "no ip rip split-horizon poisoned-reverse",
1862 "Routing Information Protocol\n"
1863 "Perform split horizon\n"
1864 "With poisoned-reverse\n")
1866 struct interface
*ifp
;
1867 struct rip_interface
*ri
;
1872 switch( ri
->split_horizon
)
1874 case RIP_SPLIT_HORIZON_POISONED_REVERSE
:
1875 ri
->split_horizon
= RIP_SPLIT_HORIZON
;
1883 DEFUN (rip_passive_interface
,
1884 rip_passive_interface_cmd
,
1885 "passive-interface (IFNAME|default)",
1886 "Suppress routing updates on an interface\n"
1888 "default for all interfaces\n")
1890 const char *ifname
= argv
[0];
1892 if (!strcmp(ifname
,"default")) {
1893 passive_default
= 1;
1894 rip_passive_nondefault_clean();
1897 if (passive_default
)
1898 return rip_passive_nondefault_unset (vty
, ifname
);
1900 return rip_passive_nondefault_set (vty
, ifname
);
1903 DEFUN (no_rip_passive_interface
,
1904 no_rip_passive_interface_cmd
,
1905 "no passive-interface (IFNAME|default)",
1907 "Suppress routing updates on an interface\n"
1909 "default for all interfaces\n")
1911 const char *ifname
= argv
[0];
1913 if (!strcmp(ifname
,"default")) {
1914 passive_default
= 0;
1915 rip_passive_nondefault_clean();
1918 if (passive_default
)
1919 return rip_passive_nondefault_set (vty
, ifname
);
1921 return rip_passive_nondefault_unset (vty
, ifname
);
1924 /* Write rip configuration of each interface. */
1926 rip_interface_config_write (struct vty
*vty
)
1928 struct listnode
*node
;
1929 struct interface
*ifp
;
1931 for (ALL_LIST_ELEMENTS_RO (iflist
, node
, ifp
))
1933 struct rip_interface
*ri
;
1937 /* Do not display the interface if there is no
1938 * configuration about it.
1941 (ri
->split_horizon
== ri
->split_horizon_default
) &&
1942 (ri
->ri_send
== RI_RIP_UNSPEC
) &&
1943 (ri
->ri_receive
== RI_RIP_UNSPEC
) &&
1944 (ri
->auth_type
!= RIP_AUTH_MD5
) &&
1945 (ri
->md5_auth_len
!= RIP_AUTH_MD5_SIZE
) &&
1950 vty_out (vty
, "interface %s%s", ifp
->name
,
1954 vty_out (vty
, " description %s%s", ifp
->desc
,
1957 /* Split horizon. */
1958 if (ri
->split_horizon
!= ri
->split_horizon_default
)
1960 switch (ri
->split_horizon
) {
1961 case RIP_SPLIT_HORIZON
:
1962 vty_out (vty
, " ip rip split-horizon%s", VTY_NEWLINE
);
1964 case RIP_SPLIT_HORIZON_POISONED_REVERSE
:
1965 vty_out (vty
, " ip rip split-horizon poisoned-reverse%s",
1968 case RIP_NO_SPLIT_HORIZON
:
1970 vty_out (vty
, " no ip rip split-horizon%s", VTY_NEWLINE
);
1975 /* RIP version setting. */
1976 if (ri
->ri_send
!= RI_RIP_UNSPEC
)
1977 vty_out (vty
, " ip rip send version %s%s",
1978 lookup (ri_version_msg
, ri
->ri_send
),
1981 if (ri
->ri_receive
!= RI_RIP_UNSPEC
)
1982 vty_out (vty
, " ip rip receive version %s%s",
1983 lookup (ri_version_msg
, ri
->ri_receive
),
1986 /* RIP authentication. */
1987 if (ri
->auth_type
== RIP_AUTH_SIMPLE_PASSWORD
)
1988 vty_out (vty
, " ip rip authentication mode text%s", VTY_NEWLINE
);
1990 if (ri
->auth_type
== RIP_AUTH_MD5
)
1992 vty_out (vty
, " ip rip authentication mode md5");
1993 if (ri
->md5_auth_len
== RIP_AUTH_MD5_COMPAT_SIZE
)
1994 vty_out (vty
, " auth-length old-ripd");
1996 vty_out (vty
, " auth-length rfc");
1997 vty_out (vty
, "%s", VTY_NEWLINE
);
2001 vty_out (vty
, " ip rip authentication string %s%s",
2002 ri
->auth_str
, VTY_NEWLINE
);
2005 vty_out (vty
, " ip rip authentication key-chain %s%s",
2006 ri
->key_chain
, VTY_NEWLINE
);
2008 vty_out (vty
, "!%s", VTY_NEWLINE
);
2014 config_write_rip_network (struct vty
*vty
, int config_mode
)
2018 struct route_node
*node
;
2020 /* Network type RIP enable interface statement. */
2021 for (node
= route_top (rip_enable_network
); node
; node
= route_next (node
))
2023 vty_out (vty
, "%s%s/%d%s",
2024 config_mode
? " network " : " ",
2025 inet_ntoa (node
->p
.u
.prefix4
),
2029 /* Interface name RIP enable statement. */
2030 for (i
= 0; i
< vector_active (rip_enable_interface
); i
++)
2031 if ((ifname
= vector_slot (rip_enable_interface
, i
)) != NULL
)
2032 vty_out (vty
, "%s%s%s",
2033 config_mode
? " network " : " ",
2037 /* RIP neighbors listing. */
2038 for (node
= route_top (rip
->neighbor
); node
; node
= route_next (node
))
2040 vty_out (vty
, "%s%s%s",
2041 config_mode
? " neighbor " : " ",
2042 inet_ntoa (node
->p
.u
.prefix4
),
2045 /* RIP passive interface listing. */
2047 if (passive_default
)
2048 vty_out (vty
, " passive-interface default%s", VTY_NEWLINE
);
2049 for (i
= 0; i
< vector_active (Vrip_passive_nondefault
); i
++)
2050 if ((ifname
= vector_slot (Vrip_passive_nondefault
, i
)) != NULL
)
2051 vty_out (vty
, " %spassive-interface %s%s",
2052 (passive_default
? "no " : ""), ifname
, VTY_NEWLINE
);
2058 static struct cmd_node interface_node
=
2065 /* Called when interface structure allocated. */
2067 rip_interface_new_hook (struct interface
*ifp
)
2069 ifp
->info
= rip_interface_new ();
2073 /* Called when interface structure deleted. */
2075 rip_interface_delete_hook (struct interface
*ifp
)
2077 XFREE (MTYPE_RIP_INTERFACE
, ifp
->info
);
2082 /* Allocate and initialize interface vector. */
2086 /* Default initial size of interface vector. */
2088 if_add_hook (IF_NEW_HOOK
, rip_interface_new_hook
);
2089 if_add_hook (IF_DELETE_HOOK
, rip_interface_delete_hook
);
2091 /* RIP network init. */
2092 rip_enable_interface
= vector_init (1);
2093 rip_enable_network
= route_table_init ();
2095 /* RIP passive interface. */
2096 Vrip_passive_nondefault
= vector_init (1);
2098 /* Install interface node. */
2099 install_node (&interface_node
, rip_interface_config_write
);
2101 /* Install commands. */
2102 install_element (CONFIG_NODE
, &interface_cmd
);
2103 install_element (CONFIG_NODE
, &no_interface_cmd
);
2104 install_default (INTERFACE_NODE
);
2105 install_element (INTERFACE_NODE
, &interface_desc_cmd
);
2106 install_element (INTERFACE_NODE
, &no_interface_desc_cmd
);
2107 install_element (RIP_NODE
, &rip_network_cmd
);
2108 install_element (RIP_NODE
, &no_rip_network_cmd
);
2109 install_element (RIP_NODE
, &rip_neighbor_cmd
);
2110 install_element (RIP_NODE
, &no_rip_neighbor_cmd
);
2112 install_element (RIP_NODE
, &rip_passive_interface_cmd
);
2113 install_element (RIP_NODE
, &no_rip_passive_interface_cmd
);
2115 install_element (INTERFACE_NODE
, &ip_rip_send_version_cmd
);
2116 install_element (INTERFACE_NODE
, &ip_rip_send_version_1_cmd
);
2117 install_element (INTERFACE_NODE
, &ip_rip_send_version_2_cmd
);
2118 install_element (INTERFACE_NODE
, &no_ip_rip_send_version_cmd
);
2119 install_element (INTERFACE_NODE
, &no_ip_rip_send_version_num_cmd
);
2121 install_element (INTERFACE_NODE
, &ip_rip_receive_version_cmd
);
2122 install_element (INTERFACE_NODE
, &ip_rip_receive_version_1_cmd
);
2123 install_element (INTERFACE_NODE
, &ip_rip_receive_version_2_cmd
);
2124 install_element (INTERFACE_NODE
, &no_ip_rip_receive_version_cmd
);
2125 install_element (INTERFACE_NODE
, &no_ip_rip_receive_version_num_cmd
);
2127 install_element (INTERFACE_NODE
, &ip_rip_authentication_mode_cmd
);
2128 install_element (INTERFACE_NODE
, &ip_rip_authentication_mode_authlen_cmd
);
2129 install_element (INTERFACE_NODE
, &no_ip_rip_authentication_mode_cmd
);
2130 install_element (INTERFACE_NODE
, &no_ip_rip_authentication_mode_type_cmd
);
2131 install_element (INTERFACE_NODE
, &no_ip_rip_authentication_mode_type_authlen_cmd
);
2133 install_element (INTERFACE_NODE
, &ip_rip_authentication_key_chain_cmd
);
2134 install_element (INTERFACE_NODE
, &no_ip_rip_authentication_key_chain_cmd
);
2135 install_element (INTERFACE_NODE
, &no_ip_rip_authentication_key_chain2_cmd
);
2137 install_element (INTERFACE_NODE
, &ip_rip_authentication_string_cmd
);
2138 install_element (INTERFACE_NODE
, &no_ip_rip_authentication_string_cmd
);
2139 install_element (INTERFACE_NODE
, &no_ip_rip_authentication_string2_cmd
);
2141 install_element (INTERFACE_NODE
, &ip_rip_split_horizon_cmd
);
2142 install_element (INTERFACE_NODE
, &ip_rip_split_horizon_poisoned_reverse_cmd
);
2143 install_element (INTERFACE_NODE
, &no_ip_rip_split_horizon_cmd
);
2144 install_element (INTERFACE_NODE
, &no_ip_rip_split_horizon_poisoned_reverse_cmd
);