{
struct listnode *node;
+ if (rip == NULL)
+ return NULL;
+
if (list_entry == NULL)
- node = listhead(peer_list);
+ node = listhead(rip->peer_list);
else
node = listnextnode((struct listnode *)list_entry);
yang_str2ipv4(keys->key[0], &address);
- for (ALL_LIST_ELEMENTS_RO(peer_list, node, peer)) {
+ if (rip == NULL)
+ return NULL;
+
+ for (ALL_LIST_ELEMENTS_RO(rip->peer_list, node, peer)) {
if (IPV4_ADDR_SAME(&peer->addr, &address))
return node;
}
#include "ripd/ripd.h"
-/* Linked list of RIP peer. */
-struct list *peer_list;
-
static struct rip_peer *rip_peer_new(void)
{
return XCALLOC(MTYPE_RIP_PEER, sizeof(struct rip_peer));
struct rip_peer *peer;
struct listnode *node, *nnode;
- for (ALL_LIST_ELEMENTS(peer_list, node, nnode, peer)) {
+ for (ALL_LIST_ELEMENTS(rip->peer_list, node, nnode, peer)) {
if (IPV4_ADDR_SAME(&peer->addr, addr))
return peer;
}
struct rip_peer *peer;
struct listnode *node, *nnode;
- for (ALL_LIST_ELEMENTS(peer_list, node, nnode, peer)) {
+ for (ALL_LIST_ELEMENTS(rip->peer_list, node, nnode, peer)) {
if (htonl(peer->addr.s_addr) > htonl(addr->s_addr))
return peer;
}
struct rip_peer *peer;
peer = THREAD_ARG(t);
- listnode_delete(peer_list, peer);
+ listnode_delete(rip->peer_list, peer);
rip_peer_free(peer);
return 0;
} else {
peer = rip_peer_new();
peer->addr = *addr;
- listnode_add_sort(peer_list, peer);
+ listnode_add_sort(rip->peer_list, peer);
}
/* Update timeout thread. */
#define RIP_UPTIME_LEN 25
char timebuf[RIP_UPTIME_LEN];
- for (ALL_LIST_ELEMENTS(peer_list, node, nnode, peer)) {
+ for (ALL_LIST_ELEMENTS(rip->peer_list, node, nnode, peer)) {
vty_out(vty, " %-16s %9d %9d %9d %s\n",
inet_ntoa(peer->addr), peer->recv_badpackets,
peer->recv_badroutes, ZEBRA_RIP_DISTANCE_DEFAULT,
}
}
-static int rip_peer_list_cmp(struct rip_peer *p1, struct rip_peer *p2)
+int rip_peer_list_cmp(struct rip_peer *p1, struct rip_peer *p2)
{
if (p2->addr.s_addr == p1->addr.s_addr)
return 0;
return (htonl(p1->addr.s_addr) < htonl(p2->addr.s_addr)) ? -1 : 1;
}
-
-void rip_peer_init(void)
-{
- peer_list = list_new();
- peer_list->cmp = (int (*)(void *, void *))rip_peer_list_cmp;
-}
/* Initialize RIP data structures. */
rip->table = route_table_init();
rip->neighbor = route_table_init();
+ rip->peer_list = list_new();
+ rip->peer_list->cmp = (int (*)(void *, void *))rip_peer_list_cmp;
rip->enable_interface = vector_init(1);
rip->enable_network = route_table_init();
rip->passive_nondefault = vector_init(1);
/* RIP routing information base. */
struct route_table *table;
- /* RIP neighbor. */
+ /* RIP static neighbors. */
struct route_table *neighbor;
+ /* Linked list of RIP peers. */
+ struct list *peer_list;
+
/* RIP threads. */
struct thread *t_read;
extern int rip_show_network_config(struct vty *);
extern void rip_show_redistribute_config(struct vty *);
-extern void rip_peer_init(void);
extern void rip_peer_update(struct sockaddr_in *, uint8_t);
extern void rip_peer_bad_route(struct sockaddr_in *);
extern void rip_peer_bad_packet(struct sockaddr_in *);
extern void rip_peer_display(struct vty *);
extern struct rip_peer *rip_peer_lookup(struct in_addr *);
extern struct rip_peer *rip_peer_lookup_next(struct in_addr *);
+extern int rip_peer_list_cmp(struct rip_peer *p1, struct rip_peer *p2);
extern void rip_info_free(struct rip_info *);
extern struct rip_distance *rip_distance_new(void);
DECLARE_HOOK(rip_ifaddr_add, (struct connected * ifc), (ifc))
DECLARE_HOOK(rip_ifaddr_del, (struct connected * ifc), (ifc))
-extern struct list *peer_list;
extern struct route_table *rip_distance_table;
/* Northbound. */