summaryrefslogtreecommitdiff
path: root/ripngd
diff options
context:
space:
mode:
Diffstat (limited to 'ripngd')
-rw-r--r--ripngd/ripng_interface.c88
-rw-r--r--ripngd/ripng_nexthop.c5
-rw-r--r--ripngd/ripng_offset.c8
-rw-r--r--ripngd/ripng_peer.c12
-rw-r--r--ripngd/ripngd.c46
5 files changed, 68 insertions, 91 deletions
diff --git a/ripngd/ripng_interface.c b/ripngd/ripng_interface.c
index 6d5d468c..d2fa3d60 100644
--- a/ripngd/ripng_interface.c
+++ b/ripngd/ripng_interface.c
@@ -144,8 +144,8 @@ ripng_if_ipv6_lladdress_check (struct interface *ifp)
struct connected *connected;
int count = 0;
- for (nn = listhead (ifp->connected); nn; nextnode (nn))
- if ((connected = getdata (nn)) != NULL) {
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, nn, connected))
+ {
struct prefix *p;
p = connected->address;
@@ -166,12 +166,10 @@ ripng_check_max_mtu ()
unsigned int mtu;
mtu = 0;
- for (node = listhead (iflist); node; nextnode (node))
- {
- ifp = getdata (node);
- if (mtu < ifp->mtu6)
- mtu = ifp->mtu6;
- }
+ for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
+ if (mtu < ifp->mtu6)
+ mtu = ifp->mtu6;
+
return mtu;
}
@@ -339,13 +337,12 @@ ripng_interface_delete (int command, struct zclient *zclient,
void
ripng_interface_clean ()
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct interface *ifp;
struct ripng_interface *ri;
- for (node = listhead (iflist); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (iflist, node, nnode, ifp))
{
- ifp = getdata (node);
ri = ifp->info;
ri->enable_network = 0;
@@ -366,9 +363,8 @@ ripng_interface_reset () {
struct interface *ifp;
struct ripng_interface *ri;
- for (node = listhead (iflist); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
{
- ifp = getdata (node);
ri = ifp->info;
ri->enable_network = 0;
@@ -535,33 +531,32 @@ struct route_table *ripng_enable_network;
int
ripng_enable_network_lookup_if (struct interface *ifp)
{
- struct listnode *listnode;
+ struct listnode *node;
struct connected *connected;
struct prefix_ipv6 address;
- for (listnode = listhead (ifp->connected); listnode; nextnode (listnode))
- if ((connected = getdata (listnode)) != NULL)
- {
- struct prefix *p;
- struct route_node *node;
-
- p = connected->address;
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, connected))
+ {
+ struct prefix *p;
+ struct route_node *node;
- if (p->family == AF_INET6)
- {
- address.family = AF_INET6;
- address.prefix = p->u.prefix6;
- address.prefixlen = IPV6_MAX_BITLEN;
+ p = connected->address;
- node = route_node_match (ripng_enable_network,
- (struct prefix *)&address);
- if (node)
- {
- route_unlock_node (node);
- return 1;
- }
- }
- }
+ if (p->family == AF_INET6)
+ {
+ address.family = AF_INET6;
+ address.prefix = p->u.prefix6;
+ address.prefixlen = IPV6_MAX_BITLEN;
+
+ node = route_node_match (ripng_enable_network,
+ (struct prefix *)&address);
+ if (node)
+ {
+ route_unlock_node (node);
+ return 1;
+ }
+ }
+ }
return -1;
}
@@ -722,12 +717,12 @@ int ripng_redistribute_check (int);
void
ripng_connect_set (struct interface *ifp, int set)
{
- struct listnode *nn;
+ struct listnode *node, *nnode;
struct connected *connected;
struct prefix_ipv6 address;
- for (nn = listhead (ifp->connected); nn; nextnode (nn))
- if ((connected = getdata (nn)) != NULL) {
+ for (ALL_LIST_ELEMENTS (ifp->connected, node, nnode, connected))
+ {
struct prefix *p;
p = connected->address;
@@ -829,11 +824,8 @@ ripng_enable_apply_all ()
struct interface *ifp;
struct listnode *node;
- for (node = listhead (iflist); node; nextnode (node))
- {
- ifp = getdata (node);
- ripng_enable_apply (ifp);
- }
+ for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
+ ripng_enable_apply (ifp);
}
/* Clear all network and neighbor configuration */
@@ -897,11 +889,8 @@ ripng_passive_interface_apply_all (void)
struct interface *ifp;
struct listnode *node;
- for (node = listhead (iflist); node; nextnode (node))
- {
- ifp = getdata (node);
- ripng_passive_interface_apply (ifp);
- }
+ for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
+ ripng_passive_interface_apply (ifp);
}
/* Passive interface. */
@@ -1171,9 +1160,8 @@ interface_config_write (struct vty *vty)
struct ripng_interface *ri;
int write = 0;
- for (node = listhead (iflist); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
{
- ifp = getdata (node);
ri = ifp->info;
/* Do not display the interface if there is no
diff --git a/ripngd/ripng_nexthop.c b/ripngd/ripng_nexthop.c
index 1c1829d4..05f190e2 100644
--- a/ripngd/ripng_nexthop.c
+++ b/ripngd/ripng_nexthop.c
@@ -117,7 +117,7 @@ ripng_rte_send(struct list *ripng_rte_list, struct interface *ifp,
struct sockaddr_in6 *to) {
struct ripng_rte_data *data;
- struct listnode * nn;
+ struct listnode *node, *nnode;
struct in6_addr last_nexthop;
struct in6_addr myself_nexthop;
@@ -154,8 +154,7 @@ ripng_rte_send(struct list *ripng_rte_list, struct interface *ifp,
sizeof (struct ripng_packet) +
sizeof (struct rte)) / sizeof (struct rte);
- LIST_LOOP(ripng_rte_list, data, nn) {
-
+ for (ALL_LIST_ELEMENTS (ripng_rte_list, node, nnode, data)) {
/* (2.1) Next hop support */
if (!IPV6_ADDR_SAME(&last_nexthop, NEXTHOP_OUT_PTR(data))) {
diff --git a/ripngd/ripng_offset.c b/ripngd/ripng_offset.c
index 46e23f0b..31d78ba8 100644
--- a/ripngd/ripng_offset.c
+++ b/ripngd/ripng_offset.c
@@ -81,9 +81,9 @@ struct ripng_offset_list *
ripng_offset_list_lookup (const char *ifname)
{
struct ripng_offset_list *offset;
- struct listnode *nn;
+ struct listnode *node, *nnode;
- LIST_LOOP (ripng_offset_list_master, offset, nn)
+ for (ALL_LIST_ELEMENTS (ripng_offset_list_master, node, nnode, offset))
{
if (strcmp_safe (offset->ifname, ifname) == 0)
return offset;
@@ -382,10 +382,10 @@ ripng_offset_clean ()
int
config_write_ripng_offset_list (struct vty *vty)
{
- struct listnode *nn;
+ struct listnode *node, *nnode;
struct ripng_offset_list *offset;
- LIST_LOOP (ripng_offset_list_master, offset, nn)
+ for (ALL_LIST_ELEMENTS (ripng_offset_list_master, node, nnode, offset))
{
if (! offset->ifname)
{
diff --git a/ripngd/ripng_peer.c b/ripngd/ripng_peer.c
index 66282614..bfbade50 100644
--- a/ripngd/ripng_peer.c
+++ b/ripngd/ripng_peer.c
@@ -59,9 +59,9 @@ struct ripng_peer *
ripng_peer_lookup (struct in6_addr *addr)
{
struct ripng_peer *peer;
- struct listnode *nn;
+ struct listnode *node, *nnode;
- LIST_LOOP (peer_list, peer, nn)
+ for (ALL_LIST_ELEMENTS (peer_list, node, nnode, peer))
{
if (IPV6_ADDR_SAME (&peer->addr, addr))
return peer;
@@ -73,9 +73,9 @@ struct ripng_peer *
ripng_peer_lookup_next (struct in6_addr *addr)
{
struct ripng_peer *peer;
- struct listnode *nn;
+ struct listnode *node, *nnode;
- LIST_LOOP (peer_list, peer, nn)
+ for (ALL_LIST_ELEMENTS (peer_list, node, nnode, peer))
{
if (addr6_cmp(&peer->addr, addr) > 0)
return peer;
@@ -191,11 +191,11 @@ void
ripng_peer_display (struct vty *vty)
{
struct ripng_peer *peer;
- struct listnode *nn;
+ struct listnode *node, *nnode;
#define RIPNG_UPTIME_LEN 25
char timebuf[RIPNG_UPTIME_LEN];
- LIST_LOOP (peer_list, peer, nn)
+ for (ALL_LIST_ELEMENTS (peer_list, node, nnode, peer))
{
vty_out (vty, " %s %s%14s %10d %10d %10d %s%s", inet6_ntoa (&peer->addr),
VTY_NEWLINE, " ",
diff --git a/ripngd/ripngd.c b/ripngd/ripngd.c
index b6b5f5ae..ec6c4d04 100644
--- a/ripngd/ripngd.c
+++ b/ripngd/ripngd.c
@@ -380,20 +380,19 @@ ripng_nexthop_rte (struct rte *rte,
int
ripng_lladdr_check (struct interface *ifp, struct in6_addr *addr)
{
- struct listnode *listnode;
+ struct listnode *node;
struct connected *connected;
struct prefix *p;
- for (listnode = listhead (ifp->connected); listnode; nextnode (listnode))
- if ((connected = getdata (listnode)) != NULL)
- {
- p = connected->address;
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, connected))
+ {
+ p = connected->address;
- if (p->family == AF_INET6 &&
- IN6_IS_ADDR_LINKLOCAL (&p->u.prefix6) &&
- IN6_ARE_ADDR_EQUAL (&p->u.prefix6, addr))
- return 1;
- }
+ if (p->family == AF_INET6 &&
+ IN6_IS_ADDR_LINKLOCAL (&p->u.prefix6) &&
+ IN6_ARE_ADDR_EQUAL (&p->u.prefix6, addr))
+ return 1;
+ }
return 0;
}
@@ -1439,9 +1438,8 @@ ripng_update (struct thread *t)
zlog_debug ("RIPng update timer expired!");
/* Supply routes to each interface. */
- for (node = listhead (iflist); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
{
- ifp = getdata (node);
ri = ifp->info;
if (if_is_loopback (ifp) || ! if_is_up (ifp))
@@ -1523,9 +1521,8 @@ ripng_triggered_update (struct thread *t)
/* Split Horizon processing is done when generating triggered
updates as well as normal updates (see section 2.6). */
- for (node = listhead (iflist); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
{
- ifp = getdata (node);
ri = ifp->info;
if (if_is_loopback (ifp) || ! if_is_up (ifp))
@@ -2137,6 +2134,7 @@ DEFUN (show_ipv6_ripng_status,
"IPv6 routing protocol process parameters and statistics\n")
{
struct listnode *node;
+ struct interface *ifp;
int ripng_network_write (struct vty *, int);
void ripng_redistribute_write (struct vty *, int);
@@ -2171,12 +2169,10 @@ DEFUN (show_ipv6_ripng_status,
vty_out (vty, " Interface Send Recv%s", VTY_NEWLINE);
- for (node = listhead (iflist); node; node = nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
{
struct ripng_interface *ri;
- struct interface *ifp;
-
- ifp = getdata (node);
+
ri = ifp->info;
if (ri->enable_network || ri->enable_interface)
@@ -2808,11 +2804,8 @@ ripng_distribute_update_all (struct prefix_list *notused)
struct interface *ifp;
struct listnode *node;
- for (node = listhead (iflist); node; nextnode (node))
- {
- ifp = getdata (node);
- ripng_distribute_update_interface (ifp);
- }
+ for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
+ ripng_distribute_update_interface (ifp);
}
void
@@ -2986,11 +2979,8 @@ ripng_routemap_update (const char *unused)
struct interface *ifp;
struct listnode *node;
- for (node = listhead (iflist); node; nextnode (node))
- {
- ifp = getdata (node);
- ripng_if_rmap_update_interface (ifp);
- }
+ for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
+ ripng_if_rmap_update_interface (ifp);
ripng_routemap_update_redistribute ();
}