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 extern struct zebra_privs_t ripd_privs
;
63 /* RIP enabled network vector. */
64 vector rip_enable_interface
;
66 /* RIP enabled interface table. */
67 struct route_table
*rip_enable_network
;
69 /* Vector to store passive-interface name. */
70 static int passive_default
; /* are we in passive-interface default mode? */
71 vector Vrip_passive_nondefault
;
73 /* Join to the RIP version 2 multicast group. */
74 static int ipv4_multicast_join(int sock
, struct in_addr group
,
75 struct in_addr ifa
, ifindex_t ifindex
)
79 ret
= setsockopt_ipv4_multicast(sock
, IP_ADD_MEMBERSHIP
, ifa
,
80 group
.s_addr
, ifindex
);
83 zlog_info("can't setsockopt IP_ADD_MEMBERSHIP %s",
84 safe_strerror(errno
));
89 /* Leave from the RIP version 2 multicast group. */
90 static int ipv4_multicast_leave(int sock
, struct in_addr group
,
91 struct in_addr ifa
, ifindex_t ifindex
)
95 ret
= setsockopt_ipv4_multicast(sock
, IP_DROP_MEMBERSHIP
, ifa
,
96 group
.s_addr
, ifindex
);
99 zlog_info("can't setsockopt IP_DROP_MEMBERSHIP");
104 static void rip_interface_reset(struct rip_interface
*);
106 /* Allocate new RIP's interface configuration. */
107 static struct rip_interface
*rip_interface_new(void)
109 struct rip_interface
*ri
;
111 ri
= XCALLOC(MTYPE_RIP_INTERFACE
, sizeof(struct rip_interface
));
113 rip_interface_reset(ri
);
118 void rip_interface_multicast_set(int sock
, struct connected
*connected
)
122 assert(connected
!= NULL
);
124 addr
= CONNECTED_ID(connected
)->u
.prefix4
;
126 if (setsockopt_ipv4_multicast_if(sock
, addr
, connected
->ifp
->ifindex
)
129 "Can't setsockopt IP_MULTICAST_IF on fd %d to "
130 "ifindex %d for interface %s",
131 sock
, connected
->ifp
->ifindex
, connected
->ifp
->name
);
137 /* Send RIP request packet to specified interface. */
138 static void rip_request_interface_send(struct interface
*ifp
, u_char version
)
140 struct sockaddr_in to
;
142 /* RIPv2 support multicast. */
143 if (version
== RIPv2
&& if_is_multicast(ifp
)) {
145 if (IS_RIP_DEBUG_EVENT
)
146 zlog_debug("multicast request on %s", ifp
->name
);
148 rip_request_send(NULL
, ifp
, version
, NULL
);
152 /* RIPv1 and non multicast interface. */
153 if (if_is_pointopoint(ifp
) || if_is_broadcast(ifp
)) {
154 struct listnode
*cnode
, *cnnode
;
155 struct connected
*connected
;
157 if (IS_RIP_DEBUG_EVENT
)
158 zlog_debug("broadcast request to %s", ifp
->name
);
160 for (ALL_LIST_ELEMENTS(ifp
->connected
, cnode
, cnnode
,
162 if (connected
->address
->family
== AF_INET
) {
163 memset(&to
, 0, sizeof(struct sockaddr_in
));
164 to
.sin_port
= htons(RIP_PORT_DEFAULT
);
165 if (connected
->destination
)
166 /* use specified broadcast or peer
167 * destination addr */
168 to
.sin_addr
= connected
->destination
->u
170 else if (connected
->address
->prefixlen
171 < IPV4_MAX_PREFIXLEN
)
172 /* calculate the appropriate broadcast
175 .s_addr
= ipv4_broadcast_addr(
176 connected
->address
->u
.prefix4
178 connected
->address
->prefixlen
);
180 /* do not know where to send the packet
184 if (IS_RIP_DEBUG_EVENT
)
185 zlog_debug("SEND request to %s",
186 inet_ntoa(to
.sin_addr
));
188 rip_request_send(&to
, ifp
, version
, connected
);
194 /* This will be executed when interface goes up. */
195 static void rip_request_interface(struct interface
*ifp
)
197 struct rip_interface
*ri
;
199 /* In default ripd doesn't send RIP_REQUEST to the loopback interface.
201 if (if_is_loopback(ifp
))
204 /* If interface is down, don't send RIP packet. */
205 if (!if_is_operative(ifp
))
208 /* Fetch RIP interface information. */
212 /* If there is no version configuration in the interface,
213 use rip's version setting. */
215 int vsend
= ((ri
->ri_send
== RI_RIP_UNSPEC
) ? rip
->version_send
218 rip_request_interface_send(ifp
, RIPv1
);
220 rip_request_interface_send(ifp
, RIPv2
);
225 /* Send RIP request to the neighbor. */
227 rip_request_neighbor (struct in_addr addr
)
229 struct sockaddr_in to
;
231 memset (&to
, 0, sizeof (struct sockaddr_in
));
232 to
.sin_port
= htons (RIP_PORT_DEFAULT
);
235 rip_request_send (&to
, NULL
, rip
->version_send
, NULL
);
238 /* Request routes at all interfaces. */
240 rip_request_neighbor_all (void)
242 struct route_node
*rp
;
247 if (IS_RIP_DEBUG_EVENT
)
248 zlog_debug ("request to the all neighbor");
250 /* Send request to all neighbor. */
251 for (rp
= route_top (rip
->neighbor
); rp
; rp
= route_next (rp
))
253 rip_request_neighbor (rp
->p
.u
.prefix4
);
257 /* Multicast packet receive socket. */
258 static int rip_multicast_join(struct interface
*ifp
, int sock
)
260 struct listnode
*cnode
;
261 struct connected
*ifc
;
263 if (if_is_operative(ifp
) && if_is_multicast(ifp
)) {
264 if (IS_RIP_DEBUG_EVENT
)
265 zlog_debug("multicast join at %s", ifp
->name
);
267 for (ALL_LIST_ELEMENTS_RO(ifp
->connected
, cnode
, ifc
)) {
268 struct prefix_ipv4
*p
;
269 struct in_addr group
;
271 p
= (struct prefix_ipv4
*)ifc
->address
;
273 if (p
->family
!= AF_INET
)
276 group
.s_addr
= htonl(INADDR_RIP_GROUP
);
277 if (ipv4_multicast_join(sock
, group
, p
->prefix
,
288 /* Leave from multicast group. */
289 static void rip_multicast_leave(struct interface
*ifp
, int sock
)
291 struct listnode
*cnode
;
292 struct connected
*connected
;
294 if (if_is_up(ifp
) && if_is_multicast(ifp
)) {
295 if (IS_RIP_DEBUG_EVENT
)
296 zlog_debug("multicast leave from %s", ifp
->name
);
298 for (ALL_LIST_ELEMENTS_RO(ifp
->connected
, cnode
, connected
)) {
299 struct prefix_ipv4
*p
;
300 struct in_addr group
;
302 p
= (struct prefix_ipv4
*)connected
->address
;
304 if (p
->family
!= AF_INET
)
307 group
.s_addr
= htonl(INADDR_RIP_GROUP
);
308 if (ipv4_multicast_leave(sock
, group
, p
->prefix
,
316 /* Is there and address on interface that I could use ? */
317 static int rip_if_ipv4_address_check(struct interface
*ifp
)
320 struct connected
*connected
;
323 for (ALL_LIST_ELEMENTS_RO(ifp
->connected
, nn
, connected
)) {
326 p
= connected
->address
;
328 if (p
->family
== AF_INET
)
336 /* Does this address belongs to me ? */
337 int if_check_address(struct in_addr addr
)
339 struct vrf
*vrf
= vrf_lookup_by_id(VRF_DEFAULT
);
340 struct interface
*ifp
;
342 FOR_ALL_INTERFACES (vrf
, ifp
) {
343 struct listnode
*cnode
;
344 struct connected
*connected
;
346 for (ALL_LIST_ELEMENTS_RO(ifp
->connected
, cnode
, connected
)) {
347 struct prefix_ipv4
*p
;
349 p
= (struct prefix_ipv4
*)connected
->address
;
351 if (p
->family
!= AF_INET
)
354 if (IPV4_ADDR_CMP(&p
->prefix
, &addr
) == 0)
361 /* Inteface link down message processing. */
362 int rip_interface_down(int command
, struct zclient
*zclient
,
363 zebra_size_t length
, vrf_id_t vrf_id
)
365 struct interface
*ifp
;
370 /* zebra_interface_state_read() updates interface structure in
372 ifp
= zebra_interface_state_read(s
, vrf_id
);
379 if (IS_RIP_DEBUG_ZEBRA
)
381 "interface %s index %d flags %llx metric %d mtu %d is down",
382 ifp
->name
, ifp
->ifindex
, (unsigned long long)ifp
->flags
,
383 ifp
->metric
, ifp
->mtu
);
388 /* Inteface link up message processing */
389 int rip_interface_up(int command
, struct zclient
*zclient
, zebra_size_t length
,
392 struct interface
*ifp
;
394 /* zebra_interface_state_read () updates interface structure in
396 ifp
= zebra_interface_state_read(zclient
->ibuf
, vrf_id
);
401 if (IS_RIP_DEBUG_ZEBRA
)
403 "interface %s index %d flags %#llx metric %d mtu %d is up",
404 ifp
->name
, ifp
->ifindex
, (unsigned long long)ifp
->flags
,
405 ifp
->metric
, ifp
->mtu
);
407 /* Check if this interface is RIP enabled or not.*/
408 rip_enable_apply(ifp
);
410 /* Check for a passive interface */
411 rip_passive_interface_apply(ifp
);
413 /* Apply distribute list to the all interface. */
414 rip_distribute_update_interface(ifp
);
419 /* Inteface addition message from zebra. */
420 int rip_interface_add(int command
, struct zclient
*zclient
, zebra_size_t length
,
423 struct interface
*ifp
;
425 ifp
= zebra_interface_add_read(zclient
->ibuf
, vrf_id
);
427 if (IS_RIP_DEBUG_ZEBRA
)
429 "interface add %s index %d flags %#llx metric %d mtu %d",
430 ifp
->name
, ifp
->ifindex
, (unsigned long long)ifp
->flags
,
431 ifp
->metric
, ifp
->mtu
);
433 /* Check if this interface is RIP enabled or not.*/
434 rip_enable_apply(ifp
);
436 /* Check for a passive interface */
437 rip_passive_interface_apply(ifp
);
439 /* Apply distribute list to the all interface. */
440 rip_distribute_update_interface(ifp
);
442 /* rip_request_neighbor_all (); */
444 /* Check interface routemap. */
445 rip_if_rmap_update_interface(ifp
);
450 int rip_interface_delete(int command
, struct zclient
*zclient
,
451 zebra_size_t length
, vrf_id_t vrf_id
)
453 struct interface
*ifp
;
458 /* zebra_interface_state_read() updates interface structure in iflist */
459 ifp
= zebra_interface_state_read(s
, vrf_id
);
468 zlog_info("interface delete %s index %d flags %#llx metric %d mtu %d",
469 ifp
->name
, ifp
->ifindex
, (unsigned long long)ifp
->flags
,
470 ifp
->metric
, ifp
->mtu
);
472 /* To support pseudo interface do not free interface structure. */
473 /* if_delete(ifp); */
474 if_set_index(ifp
, IFINDEX_INTERNAL
);
479 static void rip_interface_clean(struct rip_interface
*ri
)
481 ri
->enable_network
= 0;
482 ri
->enable_interface
= 0;
486 thread_cancel(ri
->t_wakeup
);
491 void rip_interfaces_clean(void)
493 struct vrf
*vrf
= vrf_lookup_by_id(VRF_DEFAULT
);
494 struct interface
*ifp
;
496 FOR_ALL_INTERFACES (vrf
, ifp
)
497 rip_interface_clean(ifp
->info
);
500 static void rip_interface_reset(struct rip_interface
*ri
)
502 /* Default authentication type is simple password for Cisco
504 ri
->auth_type
= RIP_NO_AUTH
;
505 ri
->md5_auth_len
= RIP_AUTH_MD5_COMPAT_SIZE
;
507 /* Set default split-horizon behavior. If the interface is Frame
508 Relay or SMDS is enabled, the default value for split-horizon is
509 off. But currently Zebra does detect Frame Relay or SMDS
510 interface. So all interface is set to split horizon. */
511 ri
->split_horizon_default
= RIP_SPLIT_HORIZON
;
512 ri
->split_horizon
= ri
->split_horizon_default
;
514 ri
->ri_send
= RI_RIP_UNSPEC
;
515 ri
->ri_receive
= RI_RIP_UNSPEC
;
517 ri
->v2_broadcast
= 0;
525 ri
->key_chain
= NULL
;
528 ri
->list
[RIP_FILTER_IN
] = NULL
;
529 ri
->list
[RIP_FILTER_OUT
] = NULL
;
531 ri
->prefix
[RIP_FILTER_IN
] = NULL
;
532 ri
->prefix
[RIP_FILTER_OUT
] = NULL
;
534 ri
->recv_badpackets
= 0;
535 ri
->recv_badroutes
= 0;
536 ri
->sent_updates
= 0;
540 rip_interface_clean(ri
);
543 void rip_interfaces_reset(void)
545 struct vrf
*vrf
= vrf_lookup_by_id(VRF_DEFAULT
);
546 struct interface
*ifp
;
548 FOR_ALL_INTERFACES (vrf
, ifp
)
549 rip_interface_reset(ifp
->info
);
552 int rip_if_down(struct interface
*ifp
)
554 struct route_node
*rp
;
555 struct rip_info
*rinfo
;
556 struct rip_interface
*ri
= NULL
;
557 struct list
*list
= NULL
;
558 struct listnode
*listnode
= NULL
, *nextnode
= NULL
;
560 for (rp
= route_top(rip
->table
); rp
; rp
= route_next(rp
))
561 if ((list
= rp
->info
) != NULL
)
562 for (ALL_LIST_ELEMENTS(list
, listnode
, nextnode
,
564 if (rinfo
->ifindex
== ifp
->ifindex
)
565 rip_ecmp_delete(rinfo
);
570 if (IS_RIP_DEBUG_EVENT
)
571 zlog_debug("turn off %s", ifp
->name
);
573 /* Leave from multicast group. */
574 rip_multicast_leave(ifp
, rip
->sock
);
583 /* Needed for stop RIP process. */
584 void rip_if_down_all()
586 struct vrf
*vrf
= vrf_lookup_by_id(VRF_DEFAULT
);
587 struct interface
*ifp
;
589 FOR_ALL_INTERFACES (vrf
, ifp
)
593 static void rip_apply_address_add(struct connected
*ifc
)
595 struct prefix_ipv4 address
;
601 if (!if_is_up(ifc
->ifp
))
606 memset(&address
, 0, sizeof(address
));
607 address
.family
= p
->family
;
608 address
.prefix
= p
->u
.prefix4
;
609 address
.prefixlen
= p
->prefixlen
;
610 apply_mask_ipv4(&address
);
612 /* Check if this interface is RIP enabled or not
613 or Check if this address's prefix is RIP enabled */
614 if ((rip_enable_if_lookup(ifc
->ifp
->name
) >= 0)
615 || (rip_enable_network_lookup2(ifc
) >= 0))
616 rip_redistribute_add(ZEBRA_ROUTE_CONNECT
, RIP_ROUTE_INTERFACE
,
617 &address
, ifc
->ifp
->ifindex
, NULL
, 0, 0,
621 int rip_interface_address_add(int command
, struct zclient
*zclient
,
622 zebra_size_t length
, vrf_id_t vrf_id
)
624 struct connected
*ifc
;
627 ifc
= zebra_interface_address_read(ZEBRA_INTERFACE_ADDRESS_ADD
,
628 zclient
->ibuf
, vrf_id
);
635 if (p
->family
== AF_INET
) {
636 if (IS_RIP_DEBUG_ZEBRA
)
637 zlog_debug("connected address %s/%d is added",
638 inet_ntoa(p
->u
.prefix4
), p
->prefixlen
);
640 rip_enable_apply(ifc
->ifp
);
641 /* Check if this prefix needs to be redistributed */
642 rip_apply_address_add(ifc
);
644 hook_call(rip_ifaddr_add
, ifc
);
650 static void rip_apply_address_del(struct connected
*ifc
)
652 struct prefix_ipv4 address
;
658 if (!if_is_up(ifc
->ifp
))
663 memset(&address
, 0, sizeof(address
));
664 address
.family
= p
->family
;
665 address
.prefix
= p
->u
.prefix4
;
666 address
.prefixlen
= p
->prefixlen
;
667 apply_mask_ipv4(&address
);
669 rip_redistribute_delete(ZEBRA_ROUTE_CONNECT
, RIP_ROUTE_INTERFACE
,
670 &address
, ifc
->ifp
->ifindex
);
673 int rip_interface_address_delete(int command
, struct zclient
*zclient
,
674 zebra_size_t length
, vrf_id_t vrf_id
)
676 struct connected
*ifc
;
679 ifc
= zebra_interface_address_read(ZEBRA_INTERFACE_ADDRESS_DELETE
,
680 zclient
->ibuf
, vrf_id
);
684 if (p
->family
== AF_INET
) {
685 if (IS_RIP_DEBUG_ZEBRA
)
686 zlog_debug("connected address %s/%d is deleted",
687 inet_ntoa(p
->u
.prefix4
),
690 hook_call(rip_ifaddr_del
, ifc
);
692 /* Chech wether this prefix needs to be removed */
693 rip_apply_address_del(ifc
);
702 /* Check interface is enabled by network statement. */
703 /* Check wether the interface has at least a connected prefix that
704 * is within the ripng_enable_network table. */
705 static int rip_enable_network_lookup_if(struct interface
*ifp
)
707 struct listnode
*node
, *nnode
;
708 struct connected
*connected
;
709 struct prefix_ipv4 address
;
711 for (ALL_LIST_ELEMENTS(ifp
->connected
, node
, nnode
, connected
)) {
713 struct route_node
*node
;
715 p
= connected
->address
;
717 if (p
->family
== AF_INET
) {
718 address
.family
= AF_INET
;
719 address
.prefix
= p
->u
.prefix4
;
720 address
.prefixlen
= IPV4_MAX_BITLEN
;
722 node
= route_node_match(rip_enable_network
,
723 (struct prefix
*)&address
);
725 route_unlock_node(node
);
733 /* Check wether connected is within the ripng_enable_network table. */
734 int rip_enable_network_lookup2(struct connected
*connected
)
736 struct prefix_ipv4 address
;
739 p
= connected
->address
;
741 if (p
->family
== AF_INET
) {
742 struct route_node
*node
;
744 address
.family
= p
->family
;
745 address
.prefix
= p
->u
.prefix4
;
746 address
.prefixlen
= IPV4_MAX_BITLEN
;
748 /* LPM on p->family, p->u.prefix4/IPV4_MAX_BITLEN within
749 * rip_enable_network */
750 node
= route_node_match(rip_enable_network
,
751 (struct prefix
*)&address
);
754 route_unlock_node(node
);
761 /* Add RIP enable network. */
762 static int rip_enable_network_add(struct prefix
*p
)
764 struct route_node
*node
;
766 node
= route_node_get(rip_enable_network
, p
);
769 route_unlock_node(node
);
772 node
->info
= (void *)1;
774 /* XXX: One should find a better solution than a generic one */
775 rip_enable_apply_all();
780 /* Delete RIP enable network. */
781 static int rip_enable_network_delete(struct prefix
*p
)
783 struct route_node
*node
;
785 node
= route_node_lookup(rip_enable_network
, p
);
789 /* Unlock info lock. */
790 route_unlock_node(node
);
792 /* Unlock lookup lock. */
793 route_unlock_node(node
);
795 /* XXX: One should find a better solution than a generic one */
796 rip_enable_apply_all();
803 /* Check interface is enabled by ifname statement. */
804 static int rip_enable_if_lookup(const char *ifname
)
809 for (i
= 0; i
< vector_active(rip_enable_interface
); i
++)
810 if ((str
= vector_slot(rip_enable_interface
, i
)) != NULL
)
811 if (strcmp(str
, ifname
) == 0)
816 /* Add interface to rip_enable_if. */
817 static int rip_enable_if_add(const char *ifname
)
821 ret
= rip_enable_if_lookup(ifname
);
825 vector_set(rip_enable_interface
, strdup(ifname
));
827 rip_enable_apply_all(); /* TODOVJ */
832 /* Delete interface from rip_enable_if. */
833 static int rip_enable_if_delete(const char *ifname
)
838 index
= rip_enable_if_lookup(ifname
);
842 str
= vector_slot(rip_enable_interface
, index
);
844 vector_unset(rip_enable_interface
, index
);
846 rip_enable_apply_all(); /* TODOVJ */
851 /* Join to multicast group and send request to the interface. */
852 static int rip_interface_wakeup(struct thread
*t
)
854 struct interface
*ifp
;
855 struct rip_interface
*ri
;
863 /* Join to multicast group. */
864 if (rip_multicast_join(ifp
, rip
->sock
) < 0) {
865 zlog_err("multicast join failed, interface %s not running",
870 /* Set running flag. */
873 /* Send RIP request to the interface. */
874 rip_request_interface(ifp
);
879 static void rip_connect_set(struct interface
*ifp
, int set
)
881 struct listnode
*node
, *nnode
;
882 struct connected
*connected
;
883 struct prefix_ipv4 address
;
885 for (ALL_LIST_ELEMENTS(ifp
->connected
, node
, nnode
, connected
)) {
887 p
= connected
->address
;
889 if (p
->family
!= AF_INET
)
892 address
.family
= AF_INET
;
893 address
.prefix
= p
->u
.prefix4
;
894 address
.prefixlen
= p
->prefixlen
;
895 apply_mask_ipv4(&address
);
898 /* Check once more wether this prefix is within a
899 * "network IF_OR_PREF" one */
900 if ((rip_enable_if_lookup(connected
->ifp
->name
) >= 0)
901 || (rip_enable_network_lookup2(connected
) >= 0))
902 rip_redistribute_add(
904 RIP_ROUTE_INTERFACE
, &address
,
905 connected
->ifp
->ifindex
, NULL
, 0, 0, 0);
907 rip_redistribute_delete(ZEBRA_ROUTE_CONNECT
,
908 RIP_ROUTE_INTERFACE
, &address
,
909 connected
->ifp
->ifindex
);
910 if (rip_redistribute_check(ZEBRA_ROUTE_CONNECT
))
911 rip_redistribute_add(
913 RIP_ROUTE_REDISTRIBUTE
, &address
,
914 connected
->ifp
->ifindex
, NULL
, 0, 0, 0);
919 /* Update interface status. */
920 void rip_enable_apply(struct interface
*ifp
)
923 struct rip_interface
*ri
= NULL
;
925 /* Check interface. */
926 if (!if_is_operative(ifp
))
931 /* Check network configuration. */
932 ret
= rip_enable_network_lookup_if(ifp
);
934 /* If the interface is matched. */
936 ri
->enable_network
= 1;
938 ri
->enable_network
= 0;
940 /* Check interface name configuration. */
941 ret
= rip_enable_if_lookup(ifp
->name
);
943 ri
->enable_interface
= 1;
945 ri
->enable_interface
= 0;
947 /* any interface MUST have an IPv4 address */
948 if (!rip_if_ipv4_address_check(ifp
)) {
949 ri
->enable_network
= 0;
950 ri
->enable_interface
= 0;
953 /* Update running status of the interface. */
954 if (ri
->enable_network
|| ri
->enable_interface
) {
956 if (IS_RIP_DEBUG_EVENT
)
957 zlog_debug("turn on %s", ifp
->name
);
959 /* Add interface wake up thread. */
960 thread_add_timer(master
, rip_interface_wakeup
, ifp
, 1,
962 rip_connect_set(ifp
, 1);
966 /* Might as well clean up the route table as well
967 * rip_if_down sets to 0 ri->running, and displays "turn
972 rip_connect_set(ifp
, 0);
977 /* Apply network configuration to all interface. */
978 void rip_enable_apply_all()
980 struct vrf
*vrf
= vrf_lookup_by_id(VRF_DEFAULT
);
981 struct interface
*ifp
;
983 /* Check each interface. */
984 FOR_ALL_INTERFACES (vrf
, ifp
)
985 rip_enable_apply(ifp
);
988 int rip_neighbor_lookup(struct sockaddr_in
*from
)
990 struct prefix_ipv4 p
;
991 struct route_node
*node
;
993 memset(&p
, 0, sizeof(struct prefix_ipv4
));
995 p
.prefix
= from
->sin_addr
;
996 p
.prefixlen
= IPV4_MAX_BITLEN
;
998 node
= route_node_lookup(rip
->neighbor
, (struct prefix
*)&p
);
1000 route_unlock_node(node
);
1006 /* Add new RIP neighbor to the neighbor tree. */
1007 static int rip_neighbor_add(struct prefix_ipv4
*p
)
1009 struct route_node
*node
;
1011 node
= route_node_get(rip
->neighbor
, (struct prefix
*)p
);
1016 node
->info
= rip
->neighbor
;
1021 /* Delete RIP neighbor from the neighbor tree. */
1022 static int rip_neighbor_delete(struct prefix_ipv4
*p
)
1024 struct route_node
*node
;
1026 /* Lock for look up. */
1027 node
= route_node_lookup(rip
->neighbor
, (struct prefix
*)p
);
1033 /* Unlock lookup lock. */
1034 route_unlock_node(node
);
1036 /* Unlock real neighbor information lock. */
1037 route_unlock_node(node
);
1042 /* Clear all network and neighbor configuration. */
1043 void rip_clean_network()
1047 struct route_node
*rn
;
1049 /* rip_enable_network. */
1050 for (rn
= route_top(rip_enable_network
); rn
; rn
= route_next(rn
))
1053 route_unlock_node(rn
);
1056 /* rip_enable_interface. */
1057 for (i
= 0; i
< vector_active(rip_enable_interface
); i
++)
1058 if ((str
= vector_slot(rip_enable_interface
, i
)) != NULL
) {
1060 vector_slot(rip_enable_interface
, i
) = NULL
;
1064 /* Utility function for looking up passive interface settings. */
1065 static int rip_passive_nondefault_lookup(const char *ifname
)
1070 for (i
= 0; i
< vector_active(Vrip_passive_nondefault
); i
++)
1071 if ((str
= vector_slot(Vrip_passive_nondefault
, i
)) != NULL
)
1072 if (strcmp(str
, ifname
) == 0)
1077 void rip_passive_interface_apply(struct interface
*ifp
)
1079 struct rip_interface
*ri
;
1083 ri
->passive
= ((rip_passive_nondefault_lookup(ifp
->name
) < 0)
1085 : !passive_default
);
1087 if (IS_RIP_DEBUG_ZEBRA
)
1088 zlog_debug("interface %s: passive = %d", ifp
->name
,
1092 static void rip_passive_interface_apply_all(void)
1094 struct vrf
*vrf
= vrf_lookup_by_id(VRF_DEFAULT
);
1095 struct interface
*ifp
;
1097 FOR_ALL_INTERFACES (vrf
, ifp
)
1098 rip_passive_interface_apply(ifp
);
1101 /* Passive interface. */
1102 static int rip_passive_nondefault_set(struct vty
*vty
, const char *ifname
)
1104 if (rip_passive_nondefault_lookup(ifname
) >= 0)
1105 return CMD_WARNING_CONFIG_FAILED
;
1107 vector_set(Vrip_passive_nondefault
, strdup(ifname
));
1109 rip_passive_interface_apply_all();
1114 static int rip_passive_nondefault_unset(struct vty
*vty
, const char *ifname
)
1119 i
= rip_passive_nondefault_lookup(ifname
);
1121 return CMD_WARNING_CONFIG_FAILED
;
1123 str
= vector_slot(Vrip_passive_nondefault
, i
);
1125 vector_unset(Vrip_passive_nondefault
, i
);
1127 rip_passive_interface_apply_all();
1132 /* Free all configured RIP passive-interface settings. */
1133 void rip_passive_nondefault_clean(void)
1138 for (i
= 0; i
< vector_active(Vrip_passive_nondefault
); i
++)
1139 if ((str
= vector_slot(Vrip_passive_nondefault
, i
)) != NULL
) {
1141 vector_slot(Vrip_passive_nondefault
, i
) = NULL
;
1143 rip_passive_interface_apply_all();
1146 /* RIP enable network or interface configuration. */
1149 "network <A.B.C.D/M|WORD>",
1150 "Enable routing on an IP network\n"
1151 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1154 int idx_ipv4_word
= 1;
1156 struct prefix_ipv4 p
;
1158 ret
= str2prefix_ipv4(argv
[idx_ipv4_word
]->arg
, &p
);
1161 ret
= rip_enable_network_add((struct prefix
*)&p
);
1163 ret
= rip_enable_if_add(argv
[idx_ipv4_word
]->arg
);
1166 vty_out(vty
, "There is a same network configuration %s\n",
1167 argv
[idx_ipv4_word
]->arg
);
1168 return CMD_WARNING_CONFIG_FAILED
;
1174 /* RIP enable network or interface configuration. */
1175 DEFUN (no_rip_network
,
1177 "no network <A.B.C.D/M|WORD>",
1179 "Enable routing on an IP network\n"
1180 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1183 int idx_ipv4_word
= 2;
1185 struct prefix_ipv4 p
;
1187 ret
= str2prefix_ipv4(argv
[idx_ipv4_word
]->arg
, &p
);
1190 ret
= rip_enable_network_delete((struct prefix
*)&p
);
1192 ret
= rip_enable_if_delete(argv
[idx_ipv4_word
]->arg
);
1195 vty_out(vty
, "Can't find network configuration %s\n",
1196 argv
[idx_ipv4_word
]->arg
);
1197 return CMD_WARNING_CONFIG_FAILED
;
1203 /* RIP neighbor configuration set. */
1204 DEFUN (rip_neighbor
,
1207 "Specify a neighbor router\n"
1208 "Neighbor address\n")
1212 struct prefix_ipv4 p
;
1214 ret
= str2prefix_ipv4(argv
[idx_ipv4
]->arg
, &p
);
1217 vty_out(vty
, "Please specify address by A.B.C.D\n");
1218 return CMD_WARNING_CONFIG_FAILED
;
1221 rip_neighbor_add(&p
);
1226 /* RIP neighbor configuration unset. */
1227 DEFUN (no_rip_neighbor
,
1228 no_rip_neighbor_cmd
,
1229 "no neighbor A.B.C.D",
1231 "Specify a neighbor router\n"
1232 "Neighbor address\n")
1236 struct prefix_ipv4 p
;
1238 ret
= str2prefix_ipv4(argv
[idx_ipv4
]->arg
, &p
);
1241 vty_out(vty
, "Please specify address by A.B.C.D\n");
1242 return CMD_WARNING_CONFIG_FAILED
;
1245 rip_neighbor_delete(&p
);
1250 DEFUN (ip_rip_receive_version
,
1251 ip_rip_receive_version_cmd
,
1252 "ip rip receive version <(1-2)|none>",
1254 "Routing Information Protocol\n"
1255 "Advertisement reception\n"
1260 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1262 struct rip_interface
*ri
;
1266 switch (argv
[idx_type
]->arg
[0]) {
1268 ri
->ri_receive
= RI_RIP_VERSION_1
;
1271 ri
->ri_receive
= RI_RIP_VERSION_2
;
1274 ri
->ri_receive
= RI_RIP_VERSION_NONE
;
1280 return CMD_WARNING_CONFIG_FAILED
;
1283 DEFUN (ip_rip_receive_version_1
,
1284 ip_rip_receive_version_1_cmd
,
1285 "ip rip receive version <1 2|2 1>",
1287 "Routing Information Protocol\n"
1288 "Advertisement reception\n"
1295 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1296 struct rip_interface
*ri
;
1300 /* Version 1 and 2. */
1301 ri
->ri_receive
= RI_RIP_VERSION_1_AND_2
;
1305 DEFUN (no_ip_rip_receive_version
,
1306 no_ip_rip_receive_version_cmd
,
1307 "no ip rip receive version [(1-2)]",
1310 "Routing Information Protocol\n"
1311 "Advertisement reception\n"
1315 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1316 struct rip_interface
*ri
;
1320 ri
->ri_receive
= RI_RIP_UNSPEC
;
1325 DEFUN (ip_rip_send_version
,
1326 ip_rip_send_version_cmd
,
1327 "ip rip send version (1-2)",
1329 "Routing Information Protocol\n"
1330 "Advertisement transmission\n"
1334 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1336 struct rip_interface
*ri
;
1341 if (atoi(argv
[idx_type
]->arg
) == 1) {
1342 ri
->ri_send
= RI_RIP_VERSION_1
;
1345 if (atoi(argv
[idx_type
]->arg
) == 2) {
1346 ri
->ri_send
= RI_RIP_VERSION_2
;
1349 return CMD_WARNING_CONFIG_FAILED
;
1352 DEFUN (ip_rip_send_version_1
,
1353 ip_rip_send_version_1_cmd
,
1354 "ip rip send version <1 2|2 1>",
1356 "Routing Information Protocol\n"
1357 "Advertisement transmission\n"
1364 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1365 struct rip_interface
*ri
;
1369 /* Version 1 and 2. */
1370 ri
->ri_send
= RI_RIP_VERSION_1_AND_2
;
1374 DEFUN (no_ip_rip_send_version
,
1375 no_ip_rip_send_version_cmd
,
1376 "no ip rip send version [(1-2)]",
1379 "Routing Information Protocol\n"
1380 "Advertisement transmission\n"
1384 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1385 struct rip_interface
*ri
;
1389 ri
->ri_send
= RI_RIP_UNSPEC
;
1394 DEFUN (ip_rip_v2_broadcast
,
1395 ip_rip_v2_broadcast_cmd
,
1396 "ip rip v2-broadcast",
1398 "Routing Information Protocol\n"
1399 "Send ip broadcast v2 update\n")
1401 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1402 struct rip_interface
*ri
;
1406 ri
->v2_broadcast
= 1;
1410 DEFUN (no_ip_rip_v2_broadcast
,
1411 no_ip_rip_v2_broadcast_cmd
,
1412 "no ip rip v2-broadcast",
1415 "Routing Information Protocol\n"
1416 "Send ip broadcast v2 update\n")
1418 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1419 struct rip_interface
*ri
;
1423 ri
->v2_broadcast
= 0;
1427 DEFUN (ip_rip_authentication_mode
,
1428 ip_rip_authentication_mode_cmd
,
1429 "ip rip authentication mode <md5|text> [auth-length <rfc|old-ripd>]",
1431 "Routing Information Protocol\n"
1432 "Authentication control\n"
1433 "Authentication mode\n"
1434 "Keyed message digest\n"
1435 "Clear text authentication\n"
1436 "MD5 authentication data length\n"
1438 "Old ripd compatible\n")
1440 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1441 char *cryptmode
= argv
[4]->text
;
1442 char *authlen
= (argc
> 5) ? argv
[6]->text
: NULL
;
1443 struct rip_interface
*ri
;
1448 if (strmatch("md5", cryptmode
))
1449 auth_type
= RIP_AUTH_MD5
;
1451 assert(strmatch("text", cryptmode
));
1452 auth_type
= RIP_AUTH_SIMPLE_PASSWORD
;
1455 ri
->auth_type
= auth_type
;
1458 if (auth_type
!= RIP_AUTH_MD5
) {
1460 "auth length argument only valid for md5\n");
1461 return CMD_WARNING_CONFIG_FAILED
;
1463 if (strmatch("rfc", authlen
))
1464 ri
->md5_auth_len
= RIP_AUTH_MD5_SIZE
;
1466 assert(strmatch("old-ripd", authlen
));
1467 ri
->md5_auth_len
= RIP_AUTH_MD5_COMPAT_SIZE
;
1474 DEFUN (no_ip_rip_authentication_mode
,
1475 no_ip_rip_authentication_mode_cmd
,
1476 "no ip rip authentication mode [<md5|text> [auth-length <rfc|old-ripd>]]",
1479 "Routing Information Protocol\n"
1480 "Authentication control\n"
1481 "Authentication mode\n"
1482 "Keyed message digest\n"
1483 "Clear text authentication\n"
1484 "MD5 authentication data length\n"
1486 "Old ripd compatible\n")
1488 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1489 struct rip_interface
*ri
;
1493 ri
->auth_type
= RIP_NO_AUTH
;
1494 ri
->md5_auth_len
= RIP_AUTH_MD5_COMPAT_SIZE
;
1499 DEFUN (ip_rip_authentication_string
,
1500 ip_rip_authentication_string_cmd
,
1501 "ip rip authentication string LINE",
1503 "Routing Information Protocol\n"
1504 "Authentication control\n"
1505 "Authentication string\n"
1506 "Authentication string\n")
1508 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1510 struct rip_interface
*ri
;
1514 if (strlen(argv
[idx_line
]->arg
) > 16) {
1516 "%% RIPv2 authentication string must be shorter than 16\n");
1517 return CMD_WARNING_CONFIG_FAILED
;
1520 if (ri
->key_chain
) {
1521 vty_out(vty
, "%% key-chain configuration exists\n");
1522 return CMD_WARNING_CONFIG_FAILED
;
1528 ri
->auth_str
= strdup(argv
[idx_line
]->arg
);
1533 DEFUN (no_ip_rip_authentication_string
,
1534 no_ip_rip_authentication_string_cmd
,
1535 "no ip rip authentication string [LINE]",
1538 "Routing Information Protocol\n"
1539 "Authentication control\n"
1540 "Authentication string\n"
1541 "Authentication string\n")
1543 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1544 struct rip_interface
*ri
;
1551 ri
->auth_str
= NULL
;
1557 DEFUN (ip_rip_authentication_key_chain
,
1558 ip_rip_authentication_key_chain_cmd
,
1559 "ip rip authentication key-chain LINE",
1561 "Routing Information Protocol\n"
1562 "Authentication control\n"
1563 "Authentication key-chain\n"
1564 "name of key-chain\n")
1566 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1568 struct rip_interface
*ri
;
1573 vty_out(vty
, "%% authentication string configuration exists\n");
1574 return CMD_WARNING_CONFIG_FAILED
;
1578 free(ri
->key_chain
);
1580 ri
->key_chain
= strdup(argv
[idx_line
]->arg
);
1585 DEFUN (no_ip_rip_authentication_key_chain
,
1586 no_ip_rip_authentication_key_chain_cmd
,
1587 "no ip rip authentication key-chain [LINE]",
1590 "Routing Information Protocol\n"
1591 "Authentication control\n"
1592 "Authentication key-chain\n"
1593 "name of key-chain\n")
1595 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1596 struct rip_interface
*ri
;
1601 free(ri
->key_chain
);
1603 ri
->key_chain
= NULL
;
1609 /* CHANGED: ip rip split-horizon
1610 Cisco and Zebra's command is
1613 DEFUN (ip_rip_split_horizon
,
1614 ip_rip_split_horizon_cmd
,
1615 "ip rip split-horizon",
1617 "Routing Information Protocol\n"
1618 "Perform split horizon\n")
1620 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1621 struct rip_interface
*ri
;
1625 ri
->split_horizon
= RIP_SPLIT_HORIZON
;
1629 DEFUN (ip_rip_split_horizon_poisoned_reverse
,
1630 ip_rip_split_horizon_poisoned_reverse_cmd
,
1631 "ip rip split-horizon poisoned-reverse",
1633 "Routing Information Protocol\n"
1634 "Perform split horizon\n"
1635 "With poisoned-reverse\n")
1637 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1638 struct rip_interface
*ri
;
1642 ri
->split_horizon
= RIP_SPLIT_HORIZON_POISONED_REVERSE
;
1646 /* CHANGED: no ip rip split-horizon
1647 Cisco and Zebra's command is
1650 DEFUN (no_ip_rip_split_horizon
,
1651 no_ip_rip_split_horizon_cmd
,
1652 "no ip rip split-horizon",
1655 "Routing Information Protocol\n"
1656 "Perform split horizon\n")
1658 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1659 struct rip_interface
*ri
;
1663 ri
->split_horizon
= RIP_NO_SPLIT_HORIZON
;
1667 DEFUN (no_ip_rip_split_horizon_poisoned_reverse
,
1668 no_ip_rip_split_horizon_poisoned_reverse_cmd
,
1669 "no ip rip split-horizon poisoned-reverse",
1672 "Routing Information Protocol\n"
1673 "Perform split horizon\n"
1674 "With poisoned-reverse\n")
1676 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1677 struct rip_interface
*ri
;
1681 switch (ri
->split_horizon
) {
1682 case RIP_SPLIT_HORIZON_POISONED_REVERSE
:
1683 ri
->split_horizon
= RIP_SPLIT_HORIZON
;
1691 DEFUN (rip_passive_interface
,
1692 rip_passive_interface_cmd
,
1693 "passive-interface <IFNAME|default>",
1694 "Suppress routing updates on an interface\n"
1696 "default for all interfaces\n")
1698 if (argv
[1]->type
== WORD_TKN
) { // user passed 'default'
1699 passive_default
= 1;
1700 rip_passive_nondefault_clean();
1703 if (passive_default
)
1704 return rip_passive_nondefault_unset(vty
, argv
[1]->arg
);
1706 return rip_passive_nondefault_set(vty
, argv
[1]->arg
);
1709 DEFUN (no_rip_passive_interface
,
1710 no_rip_passive_interface_cmd
,
1711 "no passive-interface <IFNAME|default>",
1713 "Suppress routing updates on an interface\n"
1715 "default for all interfaces\n")
1717 if (argv
[2]->type
== WORD_TKN
) {
1718 passive_default
= 0;
1719 rip_passive_nondefault_clean();
1722 if (passive_default
)
1723 return rip_passive_nondefault_set(vty
, argv
[2]->arg
);
1725 return rip_passive_nondefault_unset(vty
, argv
[2]->arg
);
1728 /* Write rip configuration of each interface. */
1729 static int rip_interface_config_write(struct vty
*vty
)
1731 struct vrf
*vrf
= vrf_lookup_by_id(VRF_DEFAULT
);
1732 struct interface
*ifp
;
1734 FOR_ALL_INTERFACES (vrf
, ifp
) {
1735 struct rip_interface
*ri
;
1739 /* Do not display the interface if there is no
1740 * configuration about it.
1743 && (ri
->split_horizon
== ri
->split_horizon_default
)
1744 && (ri
->ri_send
== RI_RIP_UNSPEC
)
1745 && (ri
->ri_receive
== RI_RIP_UNSPEC
)
1746 && (ri
->auth_type
!= RIP_AUTH_MD5
) && (!ri
->v2_broadcast
)
1747 && (ri
->md5_auth_len
!= RIP_AUTH_MD5_SIZE
)
1748 && (!ri
->auth_str
) && (!ri
->key_chain
))
1751 vty_frame(vty
, "interface %s\n", ifp
->name
);
1754 vty_out(vty
, " description %s\n", ifp
->desc
);
1756 /* Split horizon. */
1757 if (ri
->split_horizon
!= ri
->split_horizon_default
) {
1758 switch (ri
->split_horizon
) {
1759 case RIP_SPLIT_HORIZON
:
1760 vty_out(vty
, " ip rip split-horizon\n");
1762 case RIP_SPLIT_HORIZON_POISONED_REVERSE
:
1764 " ip rip split-horizon poisoned-reverse\n");
1766 case RIP_NO_SPLIT_HORIZON
:
1768 vty_out(vty
, " no ip rip split-horizon\n");
1773 /* RIP version setting. */
1774 if (ri
->ri_send
!= RI_RIP_UNSPEC
)
1775 vty_out(vty
, " ip rip send version %s\n",
1776 lookup_msg(ri_version_msg
, ri
->ri_send
, NULL
));
1778 if (ri
->ri_receive
!= RI_RIP_UNSPEC
)
1779 vty_out(vty
, " ip rip receive version %s \n",
1780 lookup_msg(ri_version_msg
, ri
->ri_receive
,
1783 if (ri
->v2_broadcast
)
1784 vty_out(vty
, " ip rip v2-broadcast\n");
1786 /* RIP authentication. */
1787 if (ri
->auth_type
== RIP_AUTH_SIMPLE_PASSWORD
)
1788 vty_out(vty
, " ip rip authentication mode text\n");
1790 if (ri
->auth_type
== RIP_AUTH_MD5
) {
1791 vty_out(vty
, " ip rip authentication mode md5");
1792 if (ri
->md5_auth_len
== RIP_AUTH_MD5_COMPAT_SIZE
)
1793 vty_out(vty
, " auth-length old-ripd");
1795 vty_out(vty
, " auth-length rfc");
1800 vty_out(vty
, " ip rip authentication string %s\n",
1804 vty_out(vty
, " ip rip authentication key-chain %s\n",
1807 vty_endframe(vty
, "!\n");
1812 int config_write_rip_network(struct vty
*vty
, int config_mode
)
1816 struct route_node
*node
;
1818 /* Network type RIP enable interface statement. */
1819 for (node
= route_top(rip_enable_network
); node
;
1820 node
= route_next(node
))
1822 vty_out(vty
, "%s%s/%d\n",
1823 config_mode
? " network " : " ",
1824 inet_ntoa(node
->p
.u
.prefix4
),
1827 /* Interface name RIP enable statement. */
1828 for (i
= 0; i
< vector_active(rip_enable_interface
); i
++)
1829 if ((ifname
= vector_slot(rip_enable_interface
, i
)) != NULL
)
1830 vty_out(vty
, "%s%s\n",
1831 config_mode
? " network " : " ", ifname
);
1833 /* RIP neighbors listing. */
1834 for (node
= route_top(rip
->neighbor
); node
; node
= route_next(node
))
1836 vty_out(vty
, "%s%s\n",
1837 config_mode
? " neighbor " : " ",
1838 inet_ntoa(node
->p
.u
.prefix4
));
1840 /* RIP passive interface listing. */
1842 if (passive_default
)
1843 vty_out(vty
, " passive-interface default\n");
1844 for (i
= 0; i
< vector_active(Vrip_passive_nondefault
); i
++)
1845 if ((ifname
= vector_slot(Vrip_passive_nondefault
, i
))
1847 vty_out(vty
, " %spassive-interface %s\n",
1848 (passive_default
? "no " : ""), ifname
);
1854 static struct cmd_node interface_node
= {
1855 INTERFACE_NODE
, "%s(config-if)# ", 1,
1858 /* Called when interface structure allocated. */
1859 static int rip_interface_new_hook(struct interface
*ifp
)
1861 ifp
->info
= rip_interface_new();
1865 /* Called when interface structure deleted. */
1866 static int rip_interface_delete_hook(struct interface
*ifp
)
1868 XFREE(MTYPE_RIP_INTERFACE
, ifp
->info
);
1873 /* Allocate and initialize interface vector. */
1874 void rip_if_init(void)
1876 /* Default initial size of interface vector. */
1877 hook_register_prio(if_add
, 0, rip_interface_new_hook
);
1878 hook_register_prio(if_del
, 0, rip_interface_delete_hook
);
1880 /* RIP network init. */
1881 rip_enable_interface
= vector_init(1);
1882 rip_enable_network
= route_table_init();
1884 /* RIP passive interface. */
1885 Vrip_passive_nondefault
= vector_init(1);
1887 /* Install interface node. */
1888 install_node(&interface_node
, rip_interface_config_write
);
1891 /* Install commands. */
1892 install_element(RIP_NODE
, &rip_network_cmd
);
1893 install_element(RIP_NODE
, &no_rip_network_cmd
);
1894 install_element(RIP_NODE
, &rip_neighbor_cmd
);
1895 install_element(RIP_NODE
, &no_rip_neighbor_cmd
);
1897 install_element(RIP_NODE
, &rip_passive_interface_cmd
);
1898 install_element(RIP_NODE
, &no_rip_passive_interface_cmd
);
1900 install_element(INTERFACE_NODE
, &ip_rip_send_version_cmd
);
1901 install_element(INTERFACE_NODE
, &ip_rip_send_version_1_cmd
);
1902 install_element(INTERFACE_NODE
, &no_ip_rip_send_version_cmd
);
1904 install_element(INTERFACE_NODE
, &ip_rip_receive_version_cmd
);
1905 install_element(INTERFACE_NODE
, &ip_rip_receive_version_1_cmd
);
1906 install_element(INTERFACE_NODE
, &no_ip_rip_receive_version_cmd
);
1908 install_element(INTERFACE_NODE
, &ip_rip_v2_broadcast_cmd
);
1909 install_element(INTERFACE_NODE
, &no_ip_rip_v2_broadcast_cmd
);
1911 install_element(INTERFACE_NODE
, &ip_rip_authentication_mode_cmd
);
1912 install_element(INTERFACE_NODE
, &no_ip_rip_authentication_mode_cmd
);
1914 install_element(INTERFACE_NODE
, &ip_rip_authentication_key_chain_cmd
);
1915 install_element(INTERFACE_NODE
,
1916 &no_ip_rip_authentication_key_chain_cmd
);
1918 install_element(INTERFACE_NODE
, &ip_rip_authentication_string_cmd
);
1919 install_element(INTERFACE_NODE
, &no_ip_rip_authentication_string_cmd
);
1921 install_element(INTERFACE_NODE
, &ip_rip_split_horizon_cmd
);
1922 install_element(INTERFACE_NODE
,
1923 &ip_rip_split_horizon_poisoned_reverse_cmd
);
1924 install_element(INTERFACE_NODE
, &no_ip_rip_split_horizon_cmd
);
1925 install_element(INTERFACE_NODE
,
1926 &no_ip_rip_split_horizon_poisoned_reverse_cmd
);