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 along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #include "sockunion.h"
38 #include "zebra/connected.h"
40 #include "ripd/ripd.h"
41 #include "ripd/rip_debug.h"
42 #include "ripd/rip_interface.h"
44 DEFINE_HOOK(rip_ifaddr_add
, (struct connected
* ifc
), (ifc
))
45 DEFINE_HOOK(rip_ifaddr_del
, (struct connected
* ifc
), (ifc
))
47 /* static prototypes */
48 static void rip_enable_apply(struct interface
*);
49 static void rip_passive_interface_apply(struct interface
*);
50 static int rip_if_down(struct interface
*ifp
);
51 static int rip_enable_if_lookup(const char *ifname
);
52 static int rip_enable_network_lookup2(struct connected
*connected
);
53 static void rip_enable_apply_all(void);
55 const struct message ri_version_msg
[] = {{RI_RIP_VERSION_1
, "1"},
56 {RI_RIP_VERSION_2
, "2"},
57 {RI_RIP_VERSION_1_AND_2
, "1 2"},
58 {RI_RIP_VERSION_NONE
, "none"},
61 /* RIP enabled network vector. */
62 vector rip_enable_interface
;
64 /* RIP enabled interface table. */
65 struct route_table
*rip_enable_network
;
67 /* Vector to store passive-interface name. */
68 static int passive_default
; /* are we in passive-interface default mode? */
69 vector Vrip_passive_nondefault
;
71 /* Join to the RIP version 2 multicast group. */
72 static int ipv4_multicast_join(int sock
, struct in_addr group
,
73 struct in_addr ifa
, ifindex_t ifindex
)
77 ret
= setsockopt_ipv4_multicast(sock
, IP_ADD_MEMBERSHIP
, ifa
,
78 group
.s_addr
, ifindex
);
81 zlog_info("can't setsockopt IP_ADD_MEMBERSHIP %s",
82 safe_strerror(errno
));
87 /* Leave from the RIP version 2 multicast group. */
88 static int ipv4_multicast_leave(int sock
, struct in_addr group
,
89 struct in_addr ifa
, ifindex_t ifindex
)
93 ret
= setsockopt_ipv4_multicast(sock
, IP_DROP_MEMBERSHIP
, ifa
,
94 group
.s_addr
, ifindex
);
97 zlog_info("can't setsockopt IP_DROP_MEMBERSHIP");
102 static void rip_interface_reset(struct rip_interface
*);
104 /* Allocate new RIP's interface configuration. */
105 static struct rip_interface
*rip_interface_new(void)
107 struct rip_interface
*ri
;
109 ri
= XCALLOC(MTYPE_RIP_INTERFACE
, sizeof(struct rip_interface
));
111 rip_interface_reset(ri
);
116 void rip_interface_multicast_set(int sock
, struct connected
*connected
)
120 assert(connected
!= NULL
);
122 addr
= CONNECTED_ID(connected
)->u
.prefix4
;
124 if (setsockopt_ipv4_multicast_if(sock
, addr
, connected
->ifp
->ifindex
)
127 "Can't setsockopt IP_MULTICAST_IF on fd %d to "
128 "ifindex %d for interface %s",
129 sock
, connected
->ifp
->ifindex
, connected
->ifp
->name
);
135 /* Send RIP request packet to specified interface. */
136 static void rip_request_interface_send(struct interface
*ifp
, u_char version
)
138 struct sockaddr_in to
;
140 /* RIPv2 support multicast. */
141 if (version
== RIPv2
&& if_is_multicast(ifp
)) {
143 if (IS_RIP_DEBUG_EVENT
)
144 zlog_debug("multicast request on %s", ifp
->name
);
146 rip_request_send(NULL
, ifp
, version
, NULL
);
150 /* RIPv1 and non multicast interface. */
151 if (if_is_pointopoint(ifp
) || if_is_broadcast(ifp
)) {
152 struct listnode
*cnode
, *cnnode
;
153 struct connected
*connected
;
155 if (IS_RIP_DEBUG_EVENT
)
156 zlog_debug("broadcast request to %s", ifp
->name
);
158 for (ALL_LIST_ELEMENTS(ifp
->connected
, cnode
, cnnode
,
160 if (connected
->address
->family
== AF_INET
) {
161 memset(&to
, 0, sizeof(struct sockaddr_in
));
162 to
.sin_port
= htons(RIP_PORT_DEFAULT
);
163 if (connected
->destination
)
164 /* use specified broadcast or peer
165 * destination addr */
166 to
.sin_addr
= connected
->destination
->u
168 else if (connected
->address
->prefixlen
169 < IPV4_MAX_PREFIXLEN
)
170 /* calculate the appropriate broadcast
173 .s_addr
= ipv4_broadcast_addr(
174 connected
->address
->u
.prefix4
176 connected
->address
->prefixlen
);
178 /* do not know where to send the packet
182 if (IS_RIP_DEBUG_EVENT
)
183 zlog_debug("SEND request to %s",
184 inet_ntoa(to
.sin_addr
));
186 rip_request_send(&to
, ifp
, version
, connected
);
192 /* This will be executed when interface goes up. */
193 static void rip_request_interface(struct interface
*ifp
)
195 struct rip_interface
*ri
;
197 /* In default ripd doesn't send RIP_REQUEST to the loopback interface.
199 if (if_is_loopback(ifp
))
202 /* If interface is down, don't send RIP packet. */
203 if (!if_is_operative(ifp
))
206 /* Fetch RIP interface information. */
210 /* If there is no version configuration in the interface,
211 use rip's version setting. */
213 int vsend
= ((ri
->ri_send
== RI_RIP_UNSPEC
) ? rip
->version_send
216 rip_request_interface_send(ifp
, RIPv1
);
218 rip_request_interface_send(ifp
, RIPv2
);
223 /* Send RIP request to the neighbor. */
225 rip_request_neighbor (struct in_addr addr
)
227 struct sockaddr_in to
;
229 memset (&to
, 0, sizeof (struct sockaddr_in
));
230 to
.sin_port
= htons (RIP_PORT_DEFAULT
);
233 rip_request_send (&to
, NULL
, rip
->version_send
, NULL
);
236 /* Request routes at all interfaces. */
238 rip_request_neighbor_all (void)
240 struct route_node
*rp
;
245 if (IS_RIP_DEBUG_EVENT
)
246 zlog_debug ("request to the all neighbor");
248 /* Send request to all neighbor. */
249 for (rp
= route_top (rip
->neighbor
); rp
; rp
= route_next (rp
))
251 rip_request_neighbor (rp
->p
.u
.prefix4
);
255 /* Multicast packet receive socket. */
256 static int rip_multicast_join(struct interface
*ifp
, int sock
)
258 struct listnode
*cnode
;
259 struct connected
*ifc
;
261 if (if_is_operative(ifp
) && if_is_multicast(ifp
)) {
262 if (IS_RIP_DEBUG_EVENT
)
263 zlog_debug("multicast join at %s", ifp
->name
);
265 for (ALL_LIST_ELEMENTS_RO(ifp
->connected
, cnode
, ifc
)) {
266 struct prefix_ipv4
*p
;
267 struct in_addr group
;
269 p
= (struct prefix_ipv4
*)ifc
->address
;
271 if (p
->family
!= AF_INET
)
274 group
.s_addr
= htonl(INADDR_RIP_GROUP
);
275 if (ipv4_multicast_join(sock
, group
, p
->prefix
,
286 /* Leave from multicast group. */
287 static void rip_multicast_leave(struct interface
*ifp
, int sock
)
289 struct listnode
*cnode
;
290 struct connected
*connected
;
292 if (if_is_up(ifp
) && if_is_multicast(ifp
)) {
293 if (IS_RIP_DEBUG_EVENT
)
294 zlog_debug("multicast leave from %s", ifp
->name
);
296 for (ALL_LIST_ELEMENTS_RO(ifp
->connected
, cnode
, connected
)) {
297 struct prefix_ipv4
*p
;
298 struct in_addr group
;
300 p
= (struct prefix_ipv4
*)connected
->address
;
302 if (p
->family
!= AF_INET
)
305 group
.s_addr
= htonl(INADDR_RIP_GROUP
);
306 if (ipv4_multicast_leave(sock
, group
, p
->prefix
,
314 /* Is there and address on interface that I could use ? */
315 static int rip_if_ipv4_address_check(struct interface
*ifp
)
318 struct connected
*connected
;
321 for (ALL_LIST_ELEMENTS_RO(ifp
->connected
, nn
, connected
)) {
324 p
= connected
->address
;
326 if (p
->family
== AF_INET
)
334 /* Does this address belongs to me ? */
335 int if_check_address(struct in_addr addr
)
337 struct vrf
*vrf
= vrf_lookup_by_id(VRF_DEFAULT
);
338 struct interface
*ifp
;
340 FOR_ALL_INTERFACES (vrf
, ifp
) {
341 struct listnode
*cnode
;
342 struct connected
*connected
;
344 for (ALL_LIST_ELEMENTS_RO(ifp
->connected
, cnode
, connected
)) {
345 struct prefix_ipv4
*p
;
347 p
= (struct prefix_ipv4
*)connected
->address
;
349 if (p
->family
!= AF_INET
)
352 if (IPV4_ADDR_CMP(&p
->prefix
, &addr
) == 0)
359 /* Inteface link down message processing. */
360 int rip_interface_down(int command
, struct zclient
*zclient
,
361 zebra_size_t length
, vrf_id_t vrf_id
)
363 struct interface
*ifp
;
368 /* zebra_interface_state_read() updates interface structure in
370 ifp
= zebra_interface_state_read(s
, vrf_id
);
377 if (IS_RIP_DEBUG_ZEBRA
)
379 "interface %s index %d flags %llx metric %d mtu %d is down",
380 ifp
->name
, ifp
->ifindex
, (unsigned long long)ifp
->flags
,
381 ifp
->metric
, ifp
->mtu
);
386 /* Inteface link up message processing */
387 int rip_interface_up(int command
, struct zclient
*zclient
, zebra_size_t length
,
390 struct interface
*ifp
;
392 /* zebra_interface_state_read () updates interface structure in
394 ifp
= zebra_interface_state_read(zclient
->ibuf
, vrf_id
);
399 if (IS_RIP_DEBUG_ZEBRA
)
401 "interface %s index %d flags %#llx metric %d mtu %d is up",
402 ifp
->name
, ifp
->ifindex
, (unsigned long long)ifp
->flags
,
403 ifp
->metric
, ifp
->mtu
);
405 /* Check if this interface is RIP enabled or not.*/
406 rip_enable_apply(ifp
);
408 /* Check for a passive interface */
409 rip_passive_interface_apply(ifp
);
411 /* Apply distribute list to the all interface. */
412 rip_distribute_update_interface(ifp
);
417 /* Inteface addition message from zebra. */
418 int rip_interface_add(int command
, struct zclient
*zclient
, zebra_size_t length
,
421 struct interface
*ifp
;
423 ifp
= zebra_interface_add_read(zclient
->ibuf
, vrf_id
);
425 if (IS_RIP_DEBUG_ZEBRA
)
427 "interface add %s index %d flags %#llx metric %d mtu %d",
428 ifp
->name
, ifp
->ifindex
, (unsigned long long)ifp
->flags
,
429 ifp
->metric
, ifp
->mtu
);
431 /* Check if this interface is RIP enabled or not.*/
432 rip_enable_apply(ifp
);
434 /* Check for a passive interface */
435 rip_passive_interface_apply(ifp
);
437 /* Apply distribute list to the all interface. */
438 rip_distribute_update_interface(ifp
);
440 /* rip_request_neighbor_all (); */
442 /* Check interface routemap. */
443 rip_if_rmap_update_interface(ifp
);
448 int rip_interface_delete(int command
, struct zclient
*zclient
,
449 zebra_size_t length
, vrf_id_t vrf_id
)
451 struct interface
*ifp
;
456 /* zebra_interface_state_read() updates interface structure in iflist */
457 ifp
= zebra_interface_state_read(s
, vrf_id
);
466 zlog_info("interface delete %s index %d flags %#llx metric %d mtu %d",
467 ifp
->name
, ifp
->ifindex
, (unsigned long long)ifp
->flags
,
468 ifp
->metric
, ifp
->mtu
);
470 /* To support pseudo interface do not free interface structure. */
471 /* if_delete(ifp); */
472 if_set_index(ifp
, IFINDEX_INTERNAL
);
477 static void rip_interface_clean(struct rip_interface
*ri
)
479 ri
->enable_network
= 0;
480 ri
->enable_interface
= 0;
484 thread_cancel(ri
->t_wakeup
);
489 void rip_interfaces_clean(void)
491 struct vrf
*vrf
= vrf_lookup_by_id(VRF_DEFAULT
);
492 struct interface
*ifp
;
494 FOR_ALL_INTERFACES (vrf
, ifp
)
495 rip_interface_clean(ifp
->info
);
498 static void rip_interface_reset(struct rip_interface
*ri
)
500 /* Default authentication type is simple password for Cisco
502 ri
->auth_type
= RIP_NO_AUTH
;
503 ri
->md5_auth_len
= RIP_AUTH_MD5_COMPAT_SIZE
;
505 /* Set default split-horizon behavior. If the interface is Frame
506 Relay or SMDS is enabled, the default value for split-horizon is
507 off. But currently Zebra does detect Frame Relay or SMDS
508 interface. So all interface is set to split horizon. */
509 ri
->split_horizon_default
= RIP_SPLIT_HORIZON
;
510 ri
->split_horizon
= ri
->split_horizon_default
;
512 ri
->ri_send
= RI_RIP_UNSPEC
;
513 ri
->ri_receive
= RI_RIP_UNSPEC
;
515 ri
->v2_broadcast
= 0;
523 ri
->key_chain
= NULL
;
526 ri
->list
[RIP_FILTER_IN
] = NULL
;
527 ri
->list
[RIP_FILTER_OUT
] = NULL
;
529 ri
->prefix
[RIP_FILTER_IN
] = NULL
;
530 ri
->prefix
[RIP_FILTER_OUT
] = NULL
;
532 ri
->recv_badpackets
= 0;
533 ri
->recv_badroutes
= 0;
534 ri
->sent_updates
= 0;
538 rip_interface_clean(ri
);
541 void rip_interfaces_reset(void)
543 struct vrf
*vrf
= vrf_lookup_by_id(VRF_DEFAULT
);
544 struct interface
*ifp
;
546 FOR_ALL_INTERFACES (vrf
, ifp
)
547 rip_interface_reset(ifp
->info
);
550 int rip_if_down(struct interface
*ifp
)
552 struct route_node
*rp
;
553 struct rip_info
*rinfo
;
554 struct rip_interface
*ri
= NULL
;
555 struct list
*list
= NULL
;
556 struct listnode
*listnode
= NULL
, *nextnode
= NULL
;
558 for (rp
= route_top(rip
->table
); rp
; rp
= route_next(rp
))
559 if ((list
= rp
->info
) != NULL
)
560 for (ALL_LIST_ELEMENTS(list
, listnode
, nextnode
,
562 if (rinfo
->nh
.ifindex
== ifp
->ifindex
)
563 rip_ecmp_delete(rinfo
);
568 if (IS_RIP_DEBUG_EVENT
)
569 zlog_debug("turn off %s", ifp
->name
);
571 /* Leave from multicast group. */
572 rip_multicast_leave(ifp
, rip
->sock
);
581 /* Needed for stop RIP process. */
582 void rip_if_down_all()
584 struct vrf
*vrf
= vrf_lookup_by_id(VRF_DEFAULT
);
585 struct interface
*ifp
;
587 FOR_ALL_INTERFACES (vrf
, ifp
)
591 static void rip_apply_address_add(struct connected
*ifc
)
593 struct prefix_ipv4 address
;
600 if (!if_is_up(ifc
->ifp
))
605 memset(&address
, 0, sizeof(address
));
606 memset(&nh
, 0, sizeof(nh
));
608 address
.family
= p
->family
;
609 address
.prefix
= p
->u
.prefix4
;
610 address
.prefixlen
= p
->prefixlen
;
611 apply_mask_ipv4(&address
);
613 nh
.ifindex
= ifc
->ifp
->ifindex
;
614 nh
.type
= NEXTHOP_TYPE_IFINDEX
;
616 /* Check if this interface is RIP enabled or not
617 or Check if this address's prefix is RIP enabled */
618 if ((rip_enable_if_lookup(ifc
->ifp
->name
) >= 0)
619 || (rip_enable_network_lookup2(ifc
) >= 0))
620 rip_redistribute_add(ZEBRA_ROUTE_CONNECT
, RIP_ROUTE_INTERFACE
,
621 &address
, &nh
, 0, 0, 0);
624 int rip_interface_address_add(int command
, struct zclient
*zclient
,
625 zebra_size_t length
, vrf_id_t vrf_id
)
627 struct connected
*ifc
;
630 ifc
= zebra_interface_address_read(ZEBRA_INTERFACE_ADDRESS_ADD
,
631 zclient
->ibuf
, vrf_id
);
638 if (p
->family
== AF_INET
) {
639 if (IS_RIP_DEBUG_ZEBRA
)
640 zlog_debug("connected address %s/%d is added",
641 inet_ntoa(p
->u
.prefix4
), p
->prefixlen
);
643 rip_enable_apply(ifc
->ifp
);
644 /* Check if this prefix needs to be redistributed */
645 rip_apply_address_add(ifc
);
647 hook_call(rip_ifaddr_add
, ifc
);
653 static void rip_apply_address_del(struct connected
*ifc
)
655 struct prefix_ipv4 address
;
661 if (!if_is_up(ifc
->ifp
))
666 memset(&address
, 0, sizeof(address
));
667 address
.family
= p
->family
;
668 address
.prefix
= p
->u
.prefix4
;
669 address
.prefixlen
= p
->prefixlen
;
670 apply_mask_ipv4(&address
);
672 rip_redistribute_delete(ZEBRA_ROUTE_CONNECT
, RIP_ROUTE_INTERFACE
,
673 &address
, ifc
->ifp
->ifindex
);
676 int rip_interface_address_delete(int command
, struct zclient
*zclient
,
677 zebra_size_t length
, vrf_id_t vrf_id
)
679 struct connected
*ifc
;
682 ifc
= zebra_interface_address_read(ZEBRA_INTERFACE_ADDRESS_DELETE
,
683 zclient
->ibuf
, vrf_id
);
687 if (p
->family
== AF_INET
) {
688 if (IS_RIP_DEBUG_ZEBRA
)
689 zlog_debug("connected address %s/%d is deleted",
690 inet_ntoa(p
->u
.prefix4
),
693 hook_call(rip_ifaddr_del
, ifc
);
695 /* Chech wether this prefix needs to be removed */
696 rip_apply_address_del(ifc
);
705 /* Check interface is enabled by network statement. */
706 /* Check wether the interface has at least a connected prefix that
707 * is within the ripng_enable_network table. */
708 static int rip_enable_network_lookup_if(struct interface
*ifp
)
710 struct listnode
*node
, *nnode
;
711 struct connected
*connected
;
712 struct prefix_ipv4 address
;
714 for (ALL_LIST_ELEMENTS(ifp
->connected
, node
, nnode
, connected
)) {
716 struct route_node
*node
;
718 p
= connected
->address
;
720 if (p
->family
== AF_INET
) {
721 address
.family
= AF_INET
;
722 address
.prefix
= p
->u
.prefix4
;
723 address
.prefixlen
= IPV4_MAX_BITLEN
;
725 node
= route_node_match(rip_enable_network
,
726 (struct prefix
*)&address
);
728 route_unlock_node(node
);
736 /* Check wether connected is within the ripng_enable_network table. */
737 int rip_enable_network_lookup2(struct connected
*connected
)
739 struct prefix_ipv4 address
;
742 p
= connected
->address
;
744 if (p
->family
== AF_INET
) {
745 struct route_node
*node
;
747 address
.family
= p
->family
;
748 address
.prefix
= p
->u
.prefix4
;
749 address
.prefixlen
= IPV4_MAX_BITLEN
;
751 /* LPM on p->family, p->u.prefix4/IPV4_MAX_BITLEN within
752 * rip_enable_network */
753 node
= route_node_match(rip_enable_network
,
754 (struct prefix
*)&address
);
757 route_unlock_node(node
);
764 /* Add RIP enable network. */
765 static int rip_enable_network_add(struct prefix
*p
)
767 struct route_node
*node
;
769 node
= route_node_get(rip_enable_network
, p
);
772 route_unlock_node(node
);
775 node
->info
= (void *)1;
777 /* XXX: One should find a better solution than a generic one */
778 rip_enable_apply_all();
783 /* Delete RIP enable network. */
784 static int rip_enable_network_delete(struct prefix
*p
)
786 struct route_node
*node
;
788 node
= route_node_lookup(rip_enable_network
, p
);
792 /* Unlock info lock. */
793 route_unlock_node(node
);
795 /* Unlock lookup lock. */
796 route_unlock_node(node
);
798 /* XXX: One should find a better solution than a generic one */
799 rip_enable_apply_all();
806 /* Check interface is enabled by ifname statement. */
807 static int rip_enable_if_lookup(const char *ifname
)
812 for (i
= 0; i
< vector_active(rip_enable_interface
); i
++)
813 if ((str
= vector_slot(rip_enable_interface
, i
)) != NULL
)
814 if (strcmp(str
, ifname
) == 0)
819 /* Add interface to rip_enable_if. */
820 static int rip_enable_if_add(const char *ifname
)
824 ret
= rip_enable_if_lookup(ifname
);
828 vector_set(rip_enable_interface
, strdup(ifname
));
830 rip_enable_apply_all(); /* TODOVJ */
835 /* Delete interface from rip_enable_if. */
836 static int rip_enable_if_delete(const char *ifname
)
841 index
= rip_enable_if_lookup(ifname
);
845 str
= vector_slot(rip_enable_interface
, index
);
847 vector_unset(rip_enable_interface
, index
);
849 rip_enable_apply_all(); /* TODOVJ */
854 /* Join to multicast group and send request to the interface. */
855 static int rip_interface_wakeup(struct thread
*t
)
857 struct interface
*ifp
;
858 struct rip_interface
*ri
;
866 /* Join to multicast group. */
867 if (rip_multicast_join(ifp
, rip
->sock
) < 0) {
868 zlog_err("multicast join failed, interface %s not running",
873 /* Set running flag. */
876 /* Send RIP request to the interface. */
877 rip_request_interface(ifp
);
882 static void rip_connect_set(struct interface
*ifp
, int set
)
884 struct listnode
*node
, *nnode
;
885 struct connected
*connected
;
886 struct prefix_ipv4 address
;
889 memset(&nh
, 0, sizeof(nh
));
891 for (ALL_LIST_ELEMENTS(ifp
->connected
, node
, nnode
, connected
)) {
893 p
= connected
->address
;
895 if (p
->family
!= AF_INET
)
898 address
.family
= AF_INET
;
899 address
.prefix
= p
->u
.prefix4
;
900 address
.prefixlen
= p
->prefixlen
;
901 apply_mask_ipv4(&address
);
903 nh
.ifindex
= connected
->ifp
->ifindex
;
904 nh
.type
= NEXTHOP_TYPE_IFINDEX
;
906 /* Check once more wether this prefix is within a
907 * "network IF_OR_PREF" one */
908 if ((rip_enable_if_lookup(connected
->ifp
->name
) >= 0)
909 || (rip_enable_network_lookup2(connected
) >= 0))
910 rip_redistribute_add(
912 RIP_ROUTE_INTERFACE
, &address
,
915 rip_redistribute_delete(ZEBRA_ROUTE_CONNECT
,
916 RIP_ROUTE_INTERFACE
, &address
,
917 connected
->ifp
->ifindex
);
918 if (rip_redistribute_check(ZEBRA_ROUTE_CONNECT
))
919 rip_redistribute_add(
921 RIP_ROUTE_REDISTRIBUTE
, &address
,
927 /* Update interface status. */
928 void rip_enable_apply(struct interface
*ifp
)
931 struct rip_interface
*ri
= NULL
;
933 /* Check interface. */
934 if (!if_is_operative(ifp
))
939 /* Check network configuration. */
940 ret
= rip_enable_network_lookup_if(ifp
);
942 /* If the interface is matched. */
944 ri
->enable_network
= 1;
946 ri
->enable_network
= 0;
948 /* Check interface name configuration. */
949 ret
= rip_enable_if_lookup(ifp
->name
);
951 ri
->enable_interface
= 1;
953 ri
->enable_interface
= 0;
955 /* any interface MUST have an IPv4 address */
956 if (!rip_if_ipv4_address_check(ifp
)) {
957 ri
->enable_network
= 0;
958 ri
->enable_interface
= 0;
961 /* Update running status of the interface. */
962 if (ri
->enable_network
|| ri
->enable_interface
) {
964 if (IS_RIP_DEBUG_EVENT
)
965 zlog_debug("turn on %s", ifp
->name
);
967 /* Add interface wake up thread. */
968 thread_add_timer(master
, rip_interface_wakeup
, ifp
, 1,
970 rip_connect_set(ifp
, 1);
974 /* Might as well clean up the route table as well
975 * rip_if_down sets to 0 ri->running, and displays "turn
980 rip_connect_set(ifp
, 0);
985 /* Apply network configuration to all interface. */
986 void rip_enable_apply_all()
988 struct vrf
*vrf
= vrf_lookup_by_id(VRF_DEFAULT
);
989 struct interface
*ifp
;
991 /* Check each interface. */
992 FOR_ALL_INTERFACES (vrf
, ifp
)
993 rip_enable_apply(ifp
);
996 int rip_neighbor_lookup(struct sockaddr_in
*from
)
998 struct prefix_ipv4 p
;
999 struct route_node
*node
;
1001 memset(&p
, 0, sizeof(struct prefix_ipv4
));
1003 p
.prefix
= from
->sin_addr
;
1004 p
.prefixlen
= IPV4_MAX_BITLEN
;
1006 node
= route_node_lookup(rip
->neighbor
, (struct prefix
*)&p
);
1008 route_unlock_node(node
);
1014 /* Add new RIP neighbor to the neighbor tree. */
1015 static int rip_neighbor_add(struct prefix_ipv4
*p
)
1017 struct route_node
*node
;
1019 node
= route_node_get(rip
->neighbor
, (struct prefix
*)p
);
1024 node
->info
= rip
->neighbor
;
1029 /* Delete RIP neighbor from the neighbor tree. */
1030 static int rip_neighbor_delete(struct prefix_ipv4
*p
)
1032 struct route_node
*node
;
1034 /* Lock for look up. */
1035 node
= route_node_lookup(rip
->neighbor
, (struct prefix
*)p
);
1041 /* Unlock lookup lock. */
1042 route_unlock_node(node
);
1044 /* Unlock real neighbor information lock. */
1045 route_unlock_node(node
);
1050 /* Clear all network and neighbor configuration. */
1051 void rip_clean_network()
1055 struct route_node
*rn
;
1057 /* rip_enable_network. */
1058 for (rn
= route_top(rip_enable_network
); rn
; rn
= route_next(rn
))
1061 route_unlock_node(rn
);
1064 /* rip_enable_interface. */
1065 for (i
= 0; i
< vector_active(rip_enable_interface
); i
++)
1066 if ((str
= vector_slot(rip_enable_interface
, i
)) != NULL
) {
1068 vector_slot(rip_enable_interface
, i
) = NULL
;
1072 /* Utility function for looking up passive interface settings. */
1073 static int rip_passive_nondefault_lookup(const char *ifname
)
1078 for (i
= 0; i
< vector_active(Vrip_passive_nondefault
); i
++)
1079 if ((str
= vector_slot(Vrip_passive_nondefault
, i
)) != NULL
)
1080 if (strcmp(str
, ifname
) == 0)
1085 void rip_passive_interface_apply(struct interface
*ifp
)
1087 struct rip_interface
*ri
;
1091 ri
->passive
= ((rip_passive_nondefault_lookup(ifp
->name
) < 0)
1093 : !passive_default
);
1095 if (IS_RIP_DEBUG_ZEBRA
)
1096 zlog_debug("interface %s: passive = %d", ifp
->name
,
1100 static void rip_passive_interface_apply_all(void)
1102 struct vrf
*vrf
= vrf_lookup_by_id(VRF_DEFAULT
);
1103 struct interface
*ifp
;
1105 FOR_ALL_INTERFACES (vrf
, ifp
)
1106 rip_passive_interface_apply(ifp
);
1109 /* Passive interface. */
1110 static int rip_passive_nondefault_set(struct vty
*vty
, const char *ifname
)
1112 if (rip_passive_nondefault_lookup(ifname
) >= 0)
1113 return CMD_WARNING_CONFIG_FAILED
;
1115 vector_set(Vrip_passive_nondefault
, strdup(ifname
));
1117 rip_passive_interface_apply_all();
1122 static int rip_passive_nondefault_unset(struct vty
*vty
, const char *ifname
)
1127 i
= rip_passive_nondefault_lookup(ifname
);
1129 return CMD_WARNING_CONFIG_FAILED
;
1131 str
= vector_slot(Vrip_passive_nondefault
, i
);
1133 vector_unset(Vrip_passive_nondefault
, i
);
1135 rip_passive_interface_apply_all();
1140 /* Free all configured RIP passive-interface settings. */
1141 void rip_passive_nondefault_clean(void)
1146 for (i
= 0; i
< vector_active(Vrip_passive_nondefault
); i
++)
1147 if ((str
= vector_slot(Vrip_passive_nondefault
, i
)) != NULL
) {
1149 vector_slot(Vrip_passive_nondefault
, i
) = NULL
;
1151 rip_passive_interface_apply_all();
1154 /* RIP enable network or interface configuration. */
1157 "network <A.B.C.D/M|WORD>",
1158 "Enable routing on an IP network\n"
1159 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1162 int idx_ipv4_word
= 1;
1164 struct prefix_ipv4 p
;
1166 ret
= str2prefix_ipv4(argv
[idx_ipv4_word
]->arg
, &p
);
1169 ret
= rip_enable_network_add((struct prefix
*)&p
);
1171 ret
= rip_enable_if_add(argv
[idx_ipv4_word
]->arg
);
1174 vty_out(vty
, "There is a same network configuration %s\n",
1175 argv
[idx_ipv4_word
]->arg
);
1176 return CMD_WARNING_CONFIG_FAILED
;
1182 /* RIP enable network or interface configuration. */
1183 DEFUN (no_rip_network
,
1185 "no network <A.B.C.D/M|WORD>",
1187 "Enable routing on an IP network\n"
1188 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1191 int idx_ipv4_word
= 2;
1193 struct prefix_ipv4 p
;
1195 ret
= str2prefix_ipv4(argv
[idx_ipv4_word
]->arg
, &p
);
1198 ret
= rip_enable_network_delete((struct prefix
*)&p
);
1200 ret
= rip_enable_if_delete(argv
[idx_ipv4_word
]->arg
);
1203 vty_out(vty
, "Can't find network configuration %s\n",
1204 argv
[idx_ipv4_word
]->arg
);
1205 return CMD_WARNING_CONFIG_FAILED
;
1211 /* RIP neighbor configuration set. */
1212 DEFUN (rip_neighbor
,
1215 "Specify a neighbor router\n"
1216 "Neighbor address\n")
1220 struct prefix_ipv4 p
;
1222 ret
= str2prefix_ipv4(argv
[idx_ipv4
]->arg
, &p
);
1225 vty_out(vty
, "Please specify address by A.B.C.D\n");
1226 return CMD_WARNING_CONFIG_FAILED
;
1229 rip_neighbor_add(&p
);
1234 /* RIP neighbor configuration unset. */
1235 DEFUN (no_rip_neighbor
,
1236 no_rip_neighbor_cmd
,
1237 "no neighbor A.B.C.D",
1239 "Specify a neighbor router\n"
1240 "Neighbor address\n")
1244 struct prefix_ipv4 p
;
1246 ret
= str2prefix_ipv4(argv
[idx_ipv4
]->arg
, &p
);
1249 vty_out(vty
, "Please specify address by A.B.C.D\n");
1250 return CMD_WARNING_CONFIG_FAILED
;
1253 rip_neighbor_delete(&p
);
1258 DEFUN (ip_rip_receive_version
,
1259 ip_rip_receive_version_cmd
,
1260 "ip rip receive version <(1-2)|none>",
1262 "Routing Information Protocol\n"
1263 "Advertisement reception\n"
1268 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1270 struct rip_interface
*ri
;
1274 switch (argv
[idx_type
]->arg
[0]) {
1276 ri
->ri_receive
= RI_RIP_VERSION_1
;
1279 ri
->ri_receive
= RI_RIP_VERSION_2
;
1282 ri
->ri_receive
= RI_RIP_VERSION_NONE
;
1288 return CMD_WARNING_CONFIG_FAILED
;
1291 DEFUN (ip_rip_receive_version_1
,
1292 ip_rip_receive_version_1_cmd
,
1293 "ip rip receive version <1 2|2 1>",
1295 "Routing Information Protocol\n"
1296 "Advertisement reception\n"
1303 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1304 struct rip_interface
*ri
;
1308 /* Version 1 and 2. */
1309 ri
->ri_receive
= RI_RIP_VERSION_1_AND_2
;
1313 DEFUN (no_ip_rip_receive_version
,
1314 no_ip_rip_receive_version_cmd
,
1315 "no ip rip receive version [(1-2)]",
1318 "Routing Information Protocol\n"
1319 "Advertisement reception\n"
1323 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1324 struct rip_interface
*ri
;
1328 ri
->ri_receive
= RI_RIP_UNSPEC
;
1333 DEFUN (ip_rip_send_version
,
1334 ip_rip_send_version_cmd
,
1335 "ip rip send version (1-2)",
1337 "Routing Information Protocol\n"
1338 "Advertisement transmission\n"
1342 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1344 struct rip_interface
*ri
;
1349 if (atoi(argv
[idx_type
]->arg
) == 1) {
1350 ri
->ri_send
= RI_RIP_VERSION_1
;
1353 if (atoi(argv
[idx_type
]->arg
) == 2) {
1354 ri
->ri_send
= RI_RIP_VERSION_2
;
1357 return CMD_WARNING_CONFIG_FAILED
;
1360 DEFUN (ip_rip_send_version_1
,
1361 ip_rip_send_version_1_cmd
,
1362 "ip rip send version <1 2|2 1>",
1364 "Routing Information Protocol\n"
1365 "Advertisement transmission\n"
1372 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1373 struct rip_interface
*ri
;
1377 /* Version 1 and 2. */
1378 ri
->ri_send
= RI_RIP_VERSION_1_AND_2
;
1382 DEFUN (no_ip_rip_send_version
,
1383 no_ip_rip_send_version_cmd
,
1384 "no ip rip send version [(1-2)]",
1387 "Routing Information Protocol\n"
1388 "Advertisement transmission\n"
1392 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1393 struct rip_interface
*ri
;
1397 ri
->ri_send
= RI_RIP_UNSPEC
;
1402 DEFUN (ip_rip_v2_broadcast
,
1403 ip_rip_v2_broadcast_cmd
,
1404 "ip rip v2-broadcast",
1406 "Routing Information Protocol\n"
1407 "Send ip broadcast v2 update\n")
1409 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1410 struct rip_interface
*ri
;
1414 ri
->v2_broadcast
= 1;
1418 DEFUN (no_ip_rip_v2_broadcast
,
1419 no_ip_rip_v2_broadcast_cmd
,
1420 "no ip rip v2-broadcast",
1423 "Routing Information Protocol\n"
1424 "Send ip broadcast v2 update\n")
1426 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1427 struct rip_interface
*ri
;
1431 ri
->v2_broadcast
= 0;
1435 DEFUN (ip_rip_authentication_mode
,
1436 ip_rip_authentication_mode_cmd
,
1437 "ip rip authentication mode <md5|text> [auth-length <rfc|old-ripd>]",
1439 "Routing Information Protocol\n"
1440 "Authentication control\n"
1441 "Authentication mode\n"
1442 "Keyed message digest\n"
1443 "Clear text authentication\n"
1444 "MD5 authentication data length\n"
1446 "Old ripd compatible\n")
1448 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1449 char *cryptmode
= argv
[4]->text
;
1450 char *authlen
= (argc
> 5) ? argv
[6]->text
: NULL
;
1451 struct rip_interface
*ri
;
1456 if (strmatch("md5", cryptmode
))
1457 auth_type
= RIP_AUTH_MD5
;
1459 assert(strmatch("text", cryptmode
));
1460 auth_type
= RIP_AUTH_SIMPLE_PASSWORD
;
1463 ri
->auth_type
= auth_type
;
1466 if (auth_type
!= RIP_AUTH_MD5
) {
1468 "auth length argument only valid for md5\n");
1469 return CMD_WARNING_CONFIG_FAILED
;
1471 if (strmatch("rfc", authlen
))
1472 ri
->md5_auth_len
= RIP_AUTH_MD5_SIZE
;
1474 assert(strmatch("old-ripd", authlen
));
1475 ri
->md5_auth_len
= RIP_AUTH_MD5_COMPAT_SIZE
;
1482 DEFUN (no_ip_rip_authentication_mode
,
1483 no_ip_rip_authentication_mode_cmd
,
1484 "no ip rip authentication mode [<md5|text> [auth-length <rfc|old-ripd>]]",
1487 "Routing Information Protocol\n"
1488 "Authentication control\n"
1489 "Authentication mode\n"
1490 "Keyed message digest\n"
1491 "Clear text authentication\n"
1492 "MD5 authentication data length\n"
1494 "Old ripd compatible\n")
1496 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1497 struct rip_interface
*ri
;
1501 ri
->auth_type
= RIP_NO_AUTH
;
1502 ri
->md5_auth_len
= RIP_AUTH_MD5_COMPAT_SIZE
;
1507 DEFUN (ip_rip_authentication_string
,
1508 ip_rip_authentication_string_cmd
,
1509 "ip rip authentication string LINE",
1511 "Routing Information Protocol\n"
1512 "Authentication control\n"
1513 "Authentication string\n"
1514 "Authentication string\n")
1516 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1518 struct rip_interface
*ri
;
1522 if (strlen(argv
[idx_line
]->arg
) > 16) {
1524 "%% RIPv2 authentication string must be shorter than 16\n");
1525 return CMD_WARNING_CONFIG_FAILED
;
1528 if (ri
->key_chain
) {
1529 vty_out(vty
, "%% key-chain configuration exists\n");
1530 return CMD_WARNING_CONFIG_FAILED
;
1536 ri
->auth_str
= strdup(argv
[idx_line
]->arg
);
1541 DEFUN (no_ip_rip_authentication_string
,
1542 no_ip_rip_authentication_string_cmd
,
1543 "no ip rip authentication string [LINE]",
1546 "Routing Information Protocol\n"
1547 "Authentication control\n"
1548 "Authentication string\n"
1549 "Authentication string\n")
1551 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1552 struct rip_interface
*ri
;
1559 ri
->auth_str
= NULL
;
1565 DEFUN (ip_rip_authentication_key_chain
,
1566 ip_rip_authentication_key_chain_cmd
,
1567 "ip rip authentication key-chain LINE",
1569 "Routing Information Protocol\n"
1570 "Authentication control\n"
1571 "Authentication key-chain\n"
1572 "name of key-chain\n")
1574 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1576 struct rip_interface
*ri
;
1581 vty_out(vty
, "%% authentication string configuration exists\n");
1582 return CMD_WARNING_CONFIG_FAILED
;
1586 free(ri
->key_chain
);
1588 ri
->key_chain
= strdup(argv
[idx_line
]->arg
);
1593 DEFUN (no_ip_rip_authentication_key_chain
,
1594 no_ip_rip_authentication_key_chain_cmd
,
1595 "no ip rip authentication key-chain [LINE]",
1598 "Routing Information Protocol\n"
1599 "Authentication control\n"
1600 "Authentication key-chain\n"
1601 "name of key-chain\n")
1603 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1604 struct rip_interface
*ri
;
1609 free(ri
->key_chain
);
1611 ri
->key_chain
= NULL
;
1617 /* CHANGED: ip rip split-horizon
1618 Cisco and Zebra's command is
1621 DEFUN (ip_rip_split_horizon
,
1622 ip_rip_split_horizon_cmd
,
1623 "ip rip split-horizon",
1625 "Routing Information Protocol\n"
1626 "Perform split horizon\n")
1628 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1629 struct rip_interface
*ri
;
1633 ri
->split_horizon
= RIP_SPLIT_HORIZON
;
1637 DEFUN (ip_rip_split_horizon_poisoned_reverse
,
1638 ip_rip_split_horizon_poisoned_reverse_cmd
,
1639 "ip rip split-horizon poisoned-reverse",
1641 "Routing Information Protocol\n"
1642 "Perform split horizon\n"
1643 "With poisoned-reverse\n")
1645 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1646 struct rip_interface
*ri
;
1650 ri
->split_horizon
= RIP_SPLIT_HORIZON_POISONED_REVERSE
;
1654 /* CHANGED: no ip rip split-horizon
1655 Cisco and Zebra's command is
1658 DEFUN (no_ip_rip_split_horizon
,
1659 no_ip_rip_split_horizon_cmd
,
1660 "no ip rip split-horizon",
1663 "Routing Information Protocol\n"
1664 "Perform split horizon\n")
1666 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1667 struct rip_interface
*ri
;
1671 ri
->split_horizon
= RIP_NO_SPLIT_HORIZON
;
1675 DEFUN (no_ip_rip_split_horizon_poisoned_reverse
,
1676 no_ip_rip_split_horizon_poisoned_reverse_cmd
,
1677 "no ip rip split-horizon poisoned-reverse",
1680 "Routing Information Protocol\n"
1681 "Perform split horizon\n"
1682 "With poisoned-reverse\n")
1684 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1685 struct rip_interface
*ri
;
1689 switch (ri
->split_horizon
) {
1690 case RIP_SPLIT_HORIZON_POISONED_REVERSE
:
1691 ri
->split_horizon
= RIP_SPLIT_HORIZON
;
1699 DEFUN (rip_passive_interface
,
1700 rip_passive_interface_cmd
,
1701 "passive-interface <IFNAME|default>",
1702 "Suppress routing updates on an interface\n"
1704 "default for all interfaces\n")
1706 if (argv
[1]->type
== WORD_TKN
) { // user passed 'default'
1707 passive_default
= 1;
1708 rip_passive_nondefault_clean();
1711 if (passive_default
)
1712 return rip_passive_nondefault_unset(vty
, argv
[1]->arg
);
1714 return rip_passive_nondefault_set(vty
, argv
[1]->arg
);
1717 DEFUN (no_rip_passive_interface
,
1718 no_rip_passive_interface_cmd
,
1719 "no passive-interface <IFNAME|default>",
1721 "Suppress routing updates on an interface\n"
1723 "default for all interfaces\n")
1725 if (argv
[2]->type
== WORD_TKN
) {
1726 passive_default
= 0;
1727 rip_passive_nondefault_clean();
1730 if (passive_default
)
1731 return rip_passive_nondefault_set(vty
, argv
[2]->arg
);
1733 return rip_passive_nondefault_unset(vty
, argv
[2]->arg
);
1736 /* Write rip configuration of each interface. */
1737 static int rip_interface_config_write(struct vty
*vty
)
1739 struct vrf
*vrf
= vrf_lookup_by_id(VRF_DEFAULT
);
1740 struct interface
*ifp
;
1742 FOR_ALL_INTERFACES (vrf
, ifp
) {
1743 struct rip_interface
*ri
;
1747 /* Do not display the interface if there is no
1748 * configuration about it.
1751 && (ri
->split_horizon
== ri
->split_horizon_default
)
1752 && (ri
->ri_send
== RI_RIP_UNSPEC
)
1753 && (ri
->ri_receive
== RI_RIP_UNSPEC
)
1754 && (ri
->auth_type
!= RIP_AUTH_MD5
) && (!ri
->v2_broadcast
)
1755 && (ri
->md5_auth_len
!= RIP_AUTH_MD5_SIZE
)
1756 && (!ri
->auth_str
) && (!ri
->key_chain
))
1759 vty_frame(vty
, "interface %s\n", ifp
->name
);
1762 vty_out(vty
, " description %s\n", ifp
->desc
);
1764 /* Split horizon. */
1765 if (ri
->split_horizon
!= ri
->split_horizon_default
) {
1766 switch (ri
->split_horizon
) {
1767 case RIP_SPLIT_HORIZON
:
1768 vty_out(vty
, " ip rip split-horizon\n");
1770 case RIP_SPLIT_HORIZON_POISONED_REVERSE
:
1772 " ip rip split-horizon poisoned-reverse\n");
1774 case RIP_NO_SPLIT_HORIZON
:
1776 vty_out(vty
, " no ip rip split-horizon\n");
1781 /* RIP version setting. */
1782 if (ri
->ri_send
!= RI_RIP_UNSPEC
)
1783 vty_out(vty
, " ip rip send version %s\n",
1784 lookup_msg(ri_version_msg
, ri
->ri_send
, NULL
));
1786 if (ri
->ri_receive
!= RI_RIP_UNSPEC
)
1787 vty_out(vty
, " ip rip receive version %s \n",
1788 lookup_msg(ri_version_msg
, ri
->ri_receive
,
1791 if (ri
->v2_broadcast
)
1792 vty_out(vty
, " ip rip v2-broadcast\n");
1794 /* RIP authentication. */
1795 if (ri
->auth_type
== RIP_AUTH_SIMPLE_PASSWORD
)
1796 vty_out(vty
, " ip rip authentication mode text\n");
1798 if (ri
->auth_type
== RIP_AUTH_MD5
) {
1799 vty_out(vty
, " ip rip authentication mode md5");
1800 if (ri
->md5_auth_len
== RIP_AUTH_MD5_COMPAT_SIZE
)
1801 vty_out(vty
, " auth-length old-ripd");
1803 vty_out(vty
, " auth-length rfc");
1808 vty_out(vty
, " ip rip authentication string %s\n",
1812 vty_out(vty
, " ip rip authentication key-chain %s\n",
1815 vty_endframe(vty
, "!\n");
1820 int config_write_rip_network(struct vty
*vty
, int config_mode
)
1824 struct route_node
*node
;
1826 /* Network type RIP enable interface statement. */
1827 for (node
= route_top(rip_enable_network
); node
;
1828 node
= route_next(node
))
1830 vty_out(vty
, "%s%s/%d\n",
1831 config_mode
? " network " : " ",
1832 inet_ntoa(node
->p
.u
.prefix4
),
1835 /* Interface name RIP enable statement. */
1836 for (i
= 0; i
< vector_active(rip_enable_interface
); i
++)
1837 if ((ifname
= vector_slot(rip_enable_interface
, i
)) != NULL
)
1838 vty_out(vty
, "%s%s\n",
1839 config_mode
? " network " : " ", ifname
);
1841 /* RIP neighbors listing. */
1842 for (node
= route_top(rip
->neighbor
); node
; node
= route_next(node
))
1844 vty_out(vty
, "%s%s\n",
1845 config_mode
? " neighbor " : " ",
1846 inet_ntoa(node
->p
.u
.prefix4
));
1848 /* RIP passive interface listing. */
1850 if (passive_default
)
1851 vty_out(vty
, " passive-interface default\n");
1852 for (i
= 0; i
< vector_active(Vrip_passive_nondefault
); i
++)
1853 if ((ifname
= vector_slot(Vrip_passive_nondefault
, i
))
1855 vty_out(vty
, " %spassive-interface %s\n",
1856 (passive_default
? "no " : ""), ifname
);
1862 static struct cmd_node interface_node
= {
1863 INTERFACE_NODE
, "%s(config-if)# ", 1,
1866 /* Called when interface structure allocated. */
1867 static int rip_interface_new_hook(struct interface
*ifp
)
1869 ifp
->info
= rip_interface_new();
1873 /* Called when interface structure deleted. */
1874 static int rip_interface_delete_hook(struct interface
*ifp
)
1876 XFREE(MTYPE_RIP_INTERFACE
, ifp
->info
);
1881 /* Allocate and initialize interface vector. */
1882 void rip_if_init(void)
1884 /* Default initial size of interface vector. */
1885 hook_register_prio(if_add
, 0, rip_interface_new_hook
);
1886 hook_register_prio(if_del
, 0, rip_interface_delete_hook
);
1888 /* RIP network init. */
1889 rip_enable_interface
= vector_init(1);
1890 rip_enable_network
= route_table_init();
1892 /* RIP passive interface. */
1893 Vrip_passive_nondefault
= vector_init(1);
1895 /* Install interface node. */
1896 install_node(&interface_node
, rip_interface_config_write
);
1899 /* Install commands. */
1900 install_element(RIP_NODE
, &rip_network_cmd
);
1901 install_element(RIP_NODE
, &no_rip_network_cmd
);
1902 install_element(RIP_NODE
, &rip_neighbor_cmd
);
1903 install_element(RIP_NODE
, &no_rip_neighbor_cmd
);
1905 install_element(RIP_NODE
, &rip_passive_interface_cmd
);
1906 install_element(RIP_NODE
, &no_rip_passive_interface_cmd
);
1908 install_element(INTERFACE_NODE
, &ip_rip_send_version_cmd
);
1909 install_element(INTERFACE_NODE
, &ip_rip_send_version_1_cmd
);
1910 install_element(INTERFACE_NODE
, &no_ip_rip_send_version_cmd
);
1912 install_element(INTERFACE_NODE
, &ip_rip_receive_version_cmd
);
1913 install_element(INTERFACE_NODE
, &ip_rip_receive_version_1_cmd
);
1914 install_element(INTERFACE_NODE
, &no_ip_rip_receive_version_cmd
);
1916 install_element(INTERFACE_NODE
, &ip_rip_v2_broadcast_cmd
);
1917 install_element(INTERFACE_NODE
, &no_ip_rip_v2_broadcast_cmd
);
1919 install_element(INTERFACE_NODE
, &ip_rip_authentication_mode_cmd
);
1920 install_element(INTERFACE_NODE
, &no_ip_rip_authentication_mode_cmd
);
1922 install_element(INTERFACE_NODE
, &ip_rip_authentication_key_chain_cmd
);
1923 install_element(INTERFACE_NODE
,
1924 &no_ip_rip_authentication_key_chain_cmd
);
1926 install_element(INTERFACE_NODE
, &ip_rip_authentication_string_cmd
);
1927 install_element(INTERFACE_NODE
, &no_ip_rip_authentication_string_cmd
);
1929 install_element(INTERFACE_NODE
, &ip_rip_split_horizon_cmd
);
1930 install_element(INTERFACE_NODE
,
1931 &ip_rip_split_horizon_poisoned_reverse_cmd
);
1932 install_element(INTERFACE_NODE
, &no_ip_rip_split_horizon_cmd
);
1933 install_element(INTERFACE_NODE
,
1934 &no_ip_rip_split_horizon_poisoned_reverse_cmd
);