+2005-04-07 Paul Jakma <paul.jakma@sun.com>
+
+ * (global): Fix up list loops to match changes in lib/linklist,
+ and some basic auditing of usage.
+ * configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES
+ * HACKING: Add notes about deprecating interfaces and commands.
+
2005-04-05 Paul Jakma <paul@dishone.st>
* HACKING: remove the 'manually patch redhat/quagga.spec' bit
-*- mode: text; -*-
-$Id: HACKING,v 1.18 2005/04/05 10:14:50 paul Exp $
+$Id: HACKING,v 1.19 2005/04/07 07:30:20 paul Exp $
GUIDELINES FOR HACKING ON QUAGGA
lib/log.h logging levels and usage guidance
[more to be added]
+If changing an exported interface, please try to deprecate the interface in
+an orderly manner. If at all possible, try to retain the old deprecated
+interface as is, or functionally equivalent. Make a note of when the
+interface was deprecated and guard the deprecated interface definitions in
+the header file, ie:
+
+/* Deprecated: 20050406 */
+#if !defined(QUAGGA_NO_DEPRECATED_INTERFACES)
+#warning "Using deprecated <libname> (interface(s)|function(s))"
+...
+#endif /* QUAGGA_NO_DEPRECATED_INTERFACES */
+
+To ensure that the core Quagga sources do not use the deprecated interfaces
+(you should update Quagga sources to use new interfaces, if applicable)
+while allowing external sources to continue to build. Deprecated interfaces
+should be excised in the next unstable cycle.
+
+If changing or removing a command definition, *ensure* that you properly
+deprecate it - use the _DEPRECATED form of the appropriate DEFUN macro. This
+is *critical*. Even if the command can no longer function, you *must* still
+implement it as a do-nothing stub. Failure to follow this causes grief for
+systems administrators. Deprecated commands should be excised in the next
+unstable cycle. A list of deprecated commands should be collated for each
+release.
+
+See also below regarding SHARED LIBRARY VERSIONING.
CHANGELOG
checkouts. Do not append to tarballs, as this has produced
non-standards-conforming tarballs in the past.
+[TODO: collation of a list of deprecated commands. Possibly can be scripted
+to extract from vtysh/vtysh_cmd.c]
+
TOOL VERSIONS
Require versions of support tools are listed in INSTALL.quagga.txt.
struct connected *connected;
struct listnode *node;
- for (node = listhead (ifp->connected); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, connected))
{
- connected = getdata (node);
-
p = (struct prefix_ipv4 *) connected->address;
if (p->family == AF_INET)
struct bgp_info *bi;
struct bgp_info *next;
struct peer *peer;
- struct listnode *nn;
+ struct listnode *node, *nnode;
int valid;
int current;
int changed;
return;
/* Maximum prefix check */
- LIST_LOOP (bgp->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
if (peer->status != Established)
continue;
struct connected *ifc;
struct prefix *p;
- for (node = listhead (iflist); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
{
- ifp = getdata (node);
-
- for (node2 = listhead (ifp->connected); node2; nextnode (node2))
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, node2, ifc))
{
- ifc = getdata (node2);
p = ifc->address;
if (p && p->family == AF_INET
struct bgp *bgp;
struct bgp_node *rn;
struct bgp_static *bgp_static;
- struct listnode *nn;
+ struct listnode *node, *nnode;
int valid;
u_int32_t metric;
struct in_addr nexthop;
if (BGP_DEBUG (events, EVENTS))
zlog_debug ("Import timer expired.");
- LIST_LOOP (bm->bgp, bgp, nn)
+ for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
{
for (afi = AFI_IP; afi < AFI_MAX; afi++)
for (safi = SAFI_UNICAST; safi < SAFI_MPLS_VPN; safi++)
bgp_collision_detect (struct peer *new, struct in_addr remote_id)
{
struct peer *peer;
- struct listnode *nn;
+ struct listnode *node, *nnode;
struct bgp *bgp;
bgp = bgp_get_default ();
OPEN message, then the local system performs the following
collision resolution procedure: */
- LIST_LOOP (bgp->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
/* Under OpenConfirm status, local peer structure already hold
remote router ID. */
struct bgp_info_pair old_and_new;
struct attr attr;
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
p = &rn->p;
if (CHECK_FLAG(rsclient->sflags, PEER_STATUS_GROUP))
{
group = rsclient->group;
- LIST_LOOP(group->peer, rsclient, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, rsclient))
{
/* Nothing to do. */
if (old_select && old_select == new_select)
struct bgp_info *new_select;
struct bgp_info *old_select;
struct bgp_info_pair old_and_new;
- struct listnode *nn;
+ struct listnode *node, *nnode;
struct peer *peer;
struct attr attr;
/* Check each BGP peer. */
- LIST_LOOP (bgp->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
bgp_process_announce_selected (peer, new_select, rn, &attr, afi, safi);
}
struct prefix_rd *prd, u_char *tag, int soft_reconfig)
{
struct peer *rsclient;
- struct listnode *nn;
+ struct listnode *node, *nnode;
struct bgp *bgp;
int ret;
bgp = peer->bgp;
/* Process the update for each RS-client. */
- LIST_LOOP(bgp->rsclient, rsclient, nn)
+ for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient))
{
if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
bgp_update_rsclient (rsclient, afi, safi, attr, peer, p, type,
struct bgp_node *rn;
struct bgp_info *ri;
struct peer *rsclient;
- struct listnode *nn;
+ struct listnode *node, *nnode;
bgp = peer->bgp;
/* Process the withdraw for each RS-client. */
- LIST_LOOP (bgp->rsclient, rsclient, nn)
+ for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient))
{
if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
bgp_withdraw_rsclient (rsclient, afi, safi, peer, p, type, sub_type, prd, tag);
struct bgp_node *rn;
struct bgp_table *table;
struct peer *rsclient;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (safi != SAFI_MPLS_VPN)
bgp_clear_route_table (peer, afi, safi, NULL, NULL);
if ((table = rn->info) != NULL)
bgp_clear_route_table (peer, afi, safi, table, NULL);
- LIST_LOOP (peer->bgp->rsclient, rsclient, nn)
+ for (ALL_LIST_ELEMENTS (peer->bgp->rsclient, node, nnode, rsclient))
{
if (CHECK_FLAG(rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
bgp_clear_route_table (peer, afi, safi, NULL, rsclient);
bgp_cleanup_routes ()
{
struct bgp *bgp;
- struct listnode *nn;
+ struct listnode *node, *nnode;
struct bgp_node *rn;
struct bgp_table *table;
struct bgp_info *ri;
- LIST_LOOP (bm->bgp, bgp, nn)
+ for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
{
table = bgp->rib[AFI_IP][SAFI_UNICAST];
struct bgp_static *bgp_static, afi_t afi, safi_t safi)
{
struct peer *rsclient;
- struct listnode *nn;
+ struct listnode *node, *nnode;
bgp_static_update_main (bgp, p, bgp_static, afi, safi);
- LIST_LOOP(bgp->rsclient, rsclient, nn)
+ for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient))
{
bgp_static_update_rsclient (rsclient, p, bgp_static, afi, safi);
}
u_int32_t metric, u_char type)
{
struct bgp *bgp;
- struct listnode *nn;
+ struct listnode *node, *nnode;
struct bgp_info *new;
struct bgp_info *bi;
struct bgp_info info;
attr.med = metric;
attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
- LIST_LOOP (bm->bgp, bgp, nn)
+ for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
{
afi = family2afi (p->family);
bgp_redistribute_delete (struct prefix *p, u_char type)
{
struct bgp *bgp;
- struct listnode *nn;
+ struct listnode *node, *nnode;
afi_t afi;
struct bgp_node *rn;
struct bgp_info *ri;
- LIST_LOOP (bm->bgp, bgp, nn)
+ for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
{
afi = family2afi (p->family);
struct bgp_info *ri;
struct prefix *p;
struct peer *peer;
- struct listnode *nn;
+ struct listnode *node, *nnode;
char buf1[INET6_ADDRSTRLEN];
char buf2[INET6_ADDRSTRLEN];
int count = 0;
vty_out (vty, ")%s", VTY_NEWLINE);
/* advertised peer */
- LIST_LOOP (bgp->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
if (bgp_adj_out_lookup (peer, p, afi, safi, rn))
{
union sockunion *su2;
struct peer_group *group;
struct peer *peer;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (type == RMAP_BGP)
{
else
{
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
if (sockunion_same (su, &peer->su))
return RMAP_MATCH;
afi_t afi;
safi_t safi;
int direct;
- struct listnode *nn, *nm;
+ struct listnode *node, *nnode;
+ struct listnode *mnode, *mnnode;
struct bgp *bgp;
struct peer *peer;
struct peer_group *group;
struct bgp_static *bgp_static;
/* For neighbor route-map updates. */
- LIST_LOOP (bm->bgp, bgp, nn)
+ for (ALL_LIST_ELEMENTS (bm->bgp, mnode, mnnode, bgp))
{
- LIST_LOOP (bgp->peer, peer, nm)
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
for (afi = AFI_IP; afi < AFI_MAX; afi++)
for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
filter->usmap.map = NULL;
}
}
- LIST_LOOP (bgp->group, group, nm)
+ for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group))
{
for (afi = AFI_IP; afi < AFI_MAX; afi++)
for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
}
/* For default-originate route-map updates. */
- LIST_LOOP (bm->bgp, bgp, nn)
+ for (ALL_LIST_ELEMENTS (bm->bgp, mnode, mnnode, bgp))
{
- LIST_LOOP (bgp->peer, peer, nm)
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
for (afi = AFI_IP; afi < AFI_MAX; afi++)
for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
}
/* For network route-map updates. */
- LIST_LOOP (bm->bgp, bgp, nn)
+ for (ALL_LIST_ELEMENTS (bm->bgp, mnode, mnnode, bgp))
{
for (afi = AFI_IP; afi < AFI_MAX; afi++)
for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
}
/* For redistribute route-map updates. */
- LIST_LOOP (bm->bgp, bgp, nn)
+ for (ALL_LIST_ELEMENTS (bm->bgp, mnode, mnnode, bgp))
{
for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
{
{
struct bgp *bgp;
struct peer *peer;
- struct listnode *nn;
+ struct listnode *node;
struct in_addr addr;
int ret;
if (! bgp)
return NULL;
- LIST_LOOP (bgp->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS_RO (bgp->peer, node, peer))
{
ret = inet_pton (AF_INET, peer->host, &addr);
if (ret > 0)
{
struct bgp *bgp;
struct peer *peer;
- struct listnode *nn;
+ struct listnode *node;
struct in_addr *p;
union sockunion su;
int ret;
if (! bgp)
return NULL;
- LIST_LOOP (bgp->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS_RO (bgp->peer, node, peer))
{
ret = inet_pton (AF_INET, peer->host, &su.sin.sin_addr);
if (ret > 0)
struct bgp *bgp;
struct peer *peer;
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
struct bgp_filter *pfilter;
struct bgp_filter *gfilter;
group = peer->group;
gfilter = &peer->filter[afi][safi];
- LIST_LOOP(group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
pfilter = &peer->filter[afi][safi];
struct bgp *bgp;
struct peer *peer;
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
bgp = vty->index;
{
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
ret = peer_af_flag_unset (peer, afi, safi, PEER_FLAG_RSERVER_CLIENT);
if (ret < 0)
{
int ret;
struct peer *peer;
- struct listnode *nn;
+ struct listnode *node, *nnode;
/* Clear all neighbors. */
if (sort == clear_all)
{
- LIST_LOOP (bgp->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
if (stype == BGP_CLEAR_SOFT_NONE)
ret = peer_clear (peer);
return -1;
}
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
if (stype == BGP_CLEAR_SOFT_NONE)
{
if (sort == clear_external)
{
- LIST_LOOP (bgp->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
if (peer_sort (peer) == BGP_PEER_IBGP)
continue;
}
as = (as_t) as_ul;
- LIST_LOOP (bgp->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
if (peer->as != as)
continue;
bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi)
{
struct peer *peer;
- struct listnode *nn;
+ struct listnode *node, *nnode;
int count = 0;
char timebuf[BGP_UPTIME_LEN];
int len;
/* Header string for each address family. */
static char header[] = "Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd";
- LIST_LOOP (bgp->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
if (peer->afc[afi][safi])
{
bgp_show_neighbor (struct vty *vty, struct bgp *bgp,
enum show_type type, union sockunion *su)
{
- struct listnode *nn;
+ struct listnode *node, *nnode;
struct peer *peer;
int find = 0;
- LIST_LOOP (bgp->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
switch (type)
{
char rmbuf[14];
const char *rmname;
struct peer *peer;
- struct listnode *nn;
+ struct listnode *node, *nnode;
int len;
int count = 0;
if (CHECK_FLAG (rsclient->sflags, PEER_STATUS_GROUP))
{
- LIST_LOOP (rsclient->group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (rsclient->group->peer, node, nnode, peer))
{
count++;
bgp_write_rsclient_summary (vty, peer, afi, safi);
afi_t afi, safi_t safi)
{
struct peer *peer;
- struct listnode *nn;
+ struct listnode *node, *nnode;
int count = 0;
/* Header string for each address family. */
static char header[] = "Neighbor V AS Export-Policy Import-Policy Up/Down State";
- LIST_LOOP (bgp->rsclient, peer, nn)
+ for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, peer))
{
if (peer->afc[afi][safi] &&
CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
bgp_router_id_update (int command, struct zclient *zclient, zebra_size_t length)
{
struct prefix router_id;
- struct listnode *nn;
+ struct listnode *node, *nnode;
struct bgp *bgp;
zebra_router_id_update_read(zclient->ibuf,&router_id);
router_id_zebra = router_id.u.prefix4;
- LIST_LOOP (bm->bgp, bgp, nn)
+ for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
{
if (!bgp->router_id_static.s_addr)
- bgp_router_id_set (bgp, &router_id.u.prefix4);
+ bgp_router_id_set (bgp, &router_id.u.prefix4);
}
return 0;
struct stream *s;
struct interface *ifp;
struct connected *c;
- struct listnode *node;
+ struct listnode *node, *nnode;
s = zclient->ibuf;
ifp = zebra_interface_state_read (s);
if (! ifp)
return 0;
- for (node = listhead (ifp->connected); node; nextnode (node))
- {
- c = getdata (node);
- bgp_connected_add (c);
- }
+ for (ALL_LIST_ELEMENTS (ifp->connected, node, nnode, c))
+ bgp_connected_add (c);
return 0;
}
struct stream *s;
struct interface *ifp;
struct connected *c;
- struct listnode *node;
+ struct listnode *node, *nnode;
s = zclient->ibuf;
ifp = zebra_interface_state_read (s);
if (! ifp)
return 0;
- for (node = listhead (ifp->connected); node; nextnode (node))
- {
- c = getdata (node);
- bgp_connected_delete (c);
- }
+ for (ALL_LIST_ELEMENTS (ifp->connected, node, nnode, c))
+ bgp_connected_delete (c);
/* Fast external-failover (Currently IPv4 only) */
{
- struct listnode *nn, *nm;
+ struct listnode *mnode;
struct bgp *bgp;
struct peer *peer;
struct interface *peer_if;
- LIST_LOOP (bm->bgp, bgp, nn)
+ for (ALL_LIST_ELEMENTS_RO (bm->bgp, mnode, bgp))
{
if (CHECK_FLAG (bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER))
continue;
- LIST_LOOP (bgp->peer, peer, nm)
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
if (peer->ttl != 1)
continue;
p.prefix = *addr;
p.prefixlen = IPV4_MAX_BITLEN;
- for (ifnode = listhead (iflist); ifnode; nextnode (ifnode))
+ for (ALL_LIST_ELEMENTS_RO (iflist, ifnode, ifp))
{
- ifp = getdata (ifnode);
-
- for (cnode = listhead (ifp->connected); cnode; nextnode (cnode))
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, cnode, connected))
{
- connected = getdata (cnode);
cp = connected->address;
if (cp->family == AF_INET)
struct connected *connected;
struct prefix *cp;
- for (ifnode = listhead (iflist); ifnode; nextnode (ifnode))
+ for (ALL_LIST_ELEMENTS_RO (iflist, ifnode, ifp))
{
- ifp = getdata (ifnode);
-
- for (cnode = listhead (ifp->connected); cnode; nextnode (cnode))
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, cnode, connected))
{
- connected = getdata (cnode);
cp = connected->address;
if (cp->family == AF_INET)
p.prefix = *addr;
p.prefixlen = IPV6_MAX_BITLEN;
- for (ifnode = listhead (iflist); ifnode; nextnode (ifnode))
+ for (ALL_LIST_ELEMENTS_RO (iflist, ifnode, ifp))
{
- ifp = getdata (ifnode);
-
- for (cnode = listhead (ifp->connected); cnode; nextnode (cnode))
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, cnode, connected))
{
- connected = getdata (cnode);
cp = connected->address;
if (cp->family == AF_INET6)
struct connected *connected;
struct prefix *cp;
- for (ifnode = listhead (iflist); ifnode; nextnode (ifnode))
+ for (ALL_LIST_ELEMENTS_RO (iflist, ifnode, ifp))
{
- ifp = getdata (ifnode);
-
- for (cnode = listhead (ifp->connected); cnode; nextnode (cnode))
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, cnode, connected))
{
- connected = getdata (cnode);
cp = connected->address;
if (cp->family == AF_INET6)
struct connected *connected;
struct prefix *cp;
- for (cnode = listhead (ifp->connected); cnode; nextnode (cnode))
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, cnode, connected))
{
- connected = getdata (cnode);
cp = connected->address;
if (cp->family == AF_INET6)
struct connected *connected;
struct prefix *cp;
- for (cnode = listhead (ifp->connected); cnode; nextnode (cnode))
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, cnode, connected))
{
- connected = getdata (cnode);
cp = connected->address;
if (cp->family == AF_INET6)
p.prefix = *addr;
p.prefixlen = IPV6_MAX_BITLEN;
- for (ifnode = listhead (iflist); ifnode; nextnode (ifnode))
+ for (ALL_LIST_ELEMENTS_RO (iflist, ifnode, ifp))
{
- ifp = getdata (ifnode);
-
- for (cnode = listhead (ifp->connected); cnode; nextnode (cnode))
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, cnode, connected))
{
struct prefix *cp;
- connected = getdata (cnode);
cp = connected->address;
if (cp->family == AF_INET6)
bgp_router_id_set (struct bgp *bgp, struct in_addr *id)
{
struct peer *peer;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (bgp_config_check (bgp, BGP_CONFIG_ROUTER_ID)
&& IPV4_ADDR_SAME (&bgp->router_id, id))
bgp_config_set (bgp, BGP_CONFIG_ROUTER_ID);
/* Set all peer's local identifier with this value. */
- LIST_LOOP (bgp->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
IPV4_ADDR_COPY (&peer->local_id, id);
bgp_cluster_id_set (struct bgp *bgp, struct in_addr *cluster_id)
{
struct peer *peer;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (bgp_config_check (bgp, BGP_CONFIG_CLUSTER_ID)
&& IPV4_ADDR_SAME (&bgp->cluster_id, cluster_id))
bgp_config_set (bgp, BGP_CONFIG_CLUSTER_ID);
/* Clear all IBGP peer. */
- LIST_LOOP (bgp->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
if (peer_sort (peer) != BGP_PEER_IBGP)
continue;
bgp_cluster_id_unset (struct bgp *bgp)
{
struct peer *peer;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (! bgp_config_check (bgp, BGP_CONFIG_CLUSTER_ID))
return 0;
bgp_config_unset (bgp, BGP_CONFIG_CLUSTER_ID);
/* Clear all IBGP peer. */
- LIST_LOOP (bgp->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
if (peer_sort (peer) != BGP_PEER_IBGP)
continue;
bgp_confederation_id_set (struct bgp *bgp, as_t as)
{
struct peer *peer;
- struct listnode *nn;
+ struct listnode *node, *nnode;
int already_confed;
if (as == 0)
/* If we were doing confederation already, this is just an external
AS change. Just Reset EBGP sessions, not CONFED sessions. If we
were not doing confederation before, reset all EBGP sessions. */
- LIST_LOOP (bgp->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
/* We're looking for peers who's AS is not local or part of our
confederation. */
bgp_confederation_id_unset (struct bgp *bgp)
{
struct peer *peer;
- struct listnode *nn;
+ struct listnode *node, *nnode;
bgp->confed_id = 0;
bgp_config_unset (bgp, BGP_CONFIG_CONFEDERATION);
- LIST_LOOP (bgp->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
/* We're looking for peers who's AS is not local */
if (peer_sort (peer) != BGP_PEER_IBGP)
bgp_confederation_peers_add (struct bgp *bgp, as_t as)
{
struct peer *peer;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (! bgp)
return BGP_ERR_INVALID_BGP;
if (bgp_config_check (bgp, BGP_CONFIG_CONFEDERATION))
{
- LIST_LOOP (bgp->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
if (peer->as == as)
{
int i;
int j;
struct peer *peer;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (! bgp)
return -1;
CONFED */
if (bgp_config_check (bgp, BGP_CONFIG_CONFEDERATION))
{
- LIST_LOOP (bgp->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
if (peer->as == as)
{
{
struct peer_group *group;
struct peer *peer1;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
{
group = peer->group;
- LIST_LOOP (group->peer, peer1, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer1))
{
if (peer1->af_group[afi][safi])
return BGP_ERR_PEER_GROUP_MEMBER_EXISTS;
peer_group_lookup (struct bgp *bgp, const char *name)
{
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
- LIST_LOOP (bgp->group, group, nn)
+ for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group))
{
if (strcmp (group->name, name) == 0)
return group;
{
struct peer_group *group;
struct peer *peer;
- struct listnode *nn;
+ struct listnode *node, *nnode;
group = peer_group_lookup (bgp, group_name);
if (! group)
number must be updated to same number. */
peer_as_change (group->conf, *as);
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
if (peer->as != *as)
peer_as_change (peer, *as);
{
struct bgp *bgp;
struct peer *peer;
- struct listnode *nn;
+ struct listnode *node, *nnode;
bgp = group->bgp;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
peer->group = NULL;
peer_delete (peer);
peer_group_remote_as_delete (struct peer_group *group)
{
struct peer *peer;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (! group->conf->as)
return 0;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
peer->group = NULL;
peer_delete (peer);
bgp_get_default ()
{
if (bm->bgp->head)
- return bm->bgp->head->data;
+ return (listgetdata (listhead (bm->bgp)));
return NULL;
}
bgp_lookup (as_t as, const char *name)
{
struct bgp *bgp;
- struct listnode *nn;
+ struct listnode *node, *nnode;
- LIST_LOOP (bm->bgp, bgp, nn)
+ for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
if (bgp->as == as
&& ((bgp->name == NULL && name == NULL)
|| (bgp->name && name && strcmp (bgp->name, name) == 0)))
bgp_lookup_by_name (const char *name)
{
struct bgp *bgp;
- struct listnode *nn;
+ struct listnode *node, *nnode;
- LIST_LOOP (bm->bgp, bgp, nn)
+ for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
if ((bgp->name == NULL && name == NULL)
|| (bgp->name && name && strcmp (bgp->name, name) == 0))
return bgp;
bgp_delete (struct bgp *bgp)
{
struct peer *peer;
- struct listnode *nn;
+ struct listnode *node;
struct listnode *next;
afi_t afi;
safi_t safi;
bgp->group->del = (void (*)(void *)) peer_group_delete;
list_delete (bgp->group);
- for (nn = bgp->peer->head; nn; nn = next)
- {
- peer = nn->data;
- next = nn->next;
- peer_delete (peer);
- }
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, next, peer))
+ peer_delete (peer);
bgp->rsclient->del = (void (*)(void *)) peer_delete;
list_delete (bgp->rsclient);
peer_lookup (struct bgp *bgp, union sockunion *su)
{
struct peer *peer;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (! bgp)
bgp = bgp_get_default ();
if (! bgp)
return NULL;
- LIST_LOOP (bgp->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
if (sockunion_same (&peer->su, su)
&& ! CHECK_FLAG (peer->sflags, PEER_STATUS_ACCEPT_PEER))
struct in_addr *remote_id, int *as)
{
struct peer *peer;
- struct listnode *nn;
+ struct listnode *node, *nnode;
struct bgp *bgp;
bgp = bgp_get_default ();
if (! bgp)
return NULL;
- LIST_LOOP (bgp->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
if (sockunion_same (&peer->su, su)
&& ! CHECK_FLAG (peer->sflags, PEER_STATUS_ACCEPT_PEER))
*as = 1;
}
}
- LIST_LOOP (bgp->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
if (sockunion_same (&peer->su, su)
&& ! CHECK_FLAG (peer->sflags, PEER_STATUS_ACCEPT_PEER))
int found;
int size;
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
struct peer_flag_action action;
memset (&action, 0, sizeof (struct peer_flag_action));
/* peer-group member updates. */
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
if (set && CHECK_FLAG (peer->flags, flag) == flag)
continue;
{
int found;
int size;
- struct listnode *nn;
+ struct listnode *node, *nnode;
struct peer_group *group;
struct peer_flag_action action;
{
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
if (! peer->af_group[afi][safi])
continue;
peer_ebgp_multihop_set (struct peer *peer, int ttl)
{
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (peer_sort (peer) == BGP_PEER_IBGP)
return 0;
else
{
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
if (peer_sort (peer) == BGP_PEER_IBGP)
continue;
peer_ebgp_multihop_unset (struct peer *peer)
{
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (peer_sort (peer) == BGP_PEER_IBGP)
return 0;
else
{
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
if (peer_sort (peer) == BGP_PEER_IBGP)
continue;
peer_update_source_if_set (struct peer *peer, const char *ifname)
{
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (peer->update_if)
{
/* peer-group member updates. */
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
if (peer->update_if)
{
peer_update_source_addr_set (struct peer *peer, union sockunion *su)
{
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (peer->update_source)
{
/* peer-group member updates. */
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
if (peer->update_source)
{
{
union sockunion *su;
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)
&& ! peer->update_source
/* peer-group member updates. */
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
if (! peer->update_source && ! peer->update_if)
continue;
const char *rmap)
{
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
/* Adress family must be activated. */
if (! peer->afc[afi][safi])
/* peer-group member updates. */
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
SET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE);
peer_default_originate_unset (struct peer *peer, afi_t afi, safi_t safi)
{
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
/* Adress family must be activated. */
if (! peer->afc[afi][safi])
/* peer-group member updates. */
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
UNSET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE);
peer_weight_set (struct peer *peer, u_int16_t weight)
{
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
SET_FLAG (peer->config, PEER_CONFIG_WEIGHT);
peer->weight = weight;
/* peer-group member updates. */
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
peer->weight = group->conf->weight;
}
peer_weight_unset (struct peer *peer)
{
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
/* Set default weight. */
if (peer_group_active (peer))
/* peer-group member updates. */
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
peer->weight = 0;
}
peer_timers_set (struct peer *peer, u_int32_t keepalive, u_int32_t holdtime)
{
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
/* Not for peer group memeber. */
if (peer_group_active (peer))
/* peer-group member updates. */
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
SET_FLAG (peer->config, PEER_CONFIG_TIMER);
peer->holdtime = group->conf->holdtime;
peer_timers_unset (struct peer *peer)
{
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (peer_group_active (peer))
return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER;
/* peer-group member updates. */
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
UNSET_FLAG (peer->config, PEER_CONFIG_TIMER);
peer->holdtime = 0;
peer_allowas_in_set (struct peer *peer, afi_t afi, safi_t safi, int allow_num)
{
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (allow_num < 1 || allow_num > 10)
return BGP_ERR_INVALID_VALUE;
return 0;
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
if (peer->allowas_in[afi][safi] != allow_num)
{
peer_allowas_in_unset (struct peer *peer, afi_t afi, safi_t safi)
{
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_ALLOWAS_IN))
{
return 0;
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_ALLOWAS_IN))
{
{
struct bgp *bgp = peer->bgp;
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (peer_sort (peer) != BGP_PEER_EBGP
&& peer_sort (peer) != BGP_PEER_INTERNAL)
}
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
peer->change_local_as = as;
if (no_prepend)
peer_local_as_unset (struct peer *peer)
{
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (peer_group_active (peer))
return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER;
}
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
peer->change_local_as = 0;
UNSET_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND);
{
struct bgp_filter *filter;
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (! peer->afc[afi][safi])
return BGP_ERR_PEER_INACTIVE;
return 0;
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
filter = &peer->filter[afi][safi];
struct bgp_filter *filter;
struct bgp_filter *gfilter;
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (! peer->afc[afi][safi])
return BGP_ERR_PEER_INACTIVE;
return 0;
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
filter = &peer->filter[afi][safi];
afi_t afi;
safi_t safi;
int direct;
- struct listnode *nn, *nm;
+ struct listnode *mnode, *mnnode;
+ struct listnode *node, *nnode;
struct bgp *bgp;
struct peer *peer;
struct peer_group *group;
struct bgp_filter *filter;
- LIST_LOOP (bm->bgp, bgp, nn)
+ for (ALL_LIST_ELEMENTS (bm->bgp, mnode, mnnode, bgp))
{
- LIST_LOOP (bgp->peer, peer, nm)
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
for (afi = AFI_IP; afi < AFI_MAX; afi++)
for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
}
}
}
- LIST_LOOP (bgp->group, group, nm)
+ for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group))
{
for (afi = AFI_IP; afi < AFI_MAX; afi++)
for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
{
struct bgp_filter *filter;
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (! peer->afc[afi][safi])
return BGP_ERR_PEER_INACTIVE;
return 0;
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
filter = &peer->filter[afi][safi];
struct bgp_filter *filter;
struct bgp_filter *gfilter;
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (! peer->afc[afi][safi])
return BGP_ERR_PEER_INACTIVE;
return 0;
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
filter = &peer->filter[afi][safi];
void
peer_prefix_list_update (struct prefix_list *plist)
{
- struct listnode *nn, *nm;
+ struct listnode *mnode, *mnnode;
+ struct listnode *node, *nnode;
struct bgp *bgp;
struct peer *peer;
struct peer_group *group;
safi_t safi;
int direct;
- LIST_LOOP (bm->bgp, bgp, nn)
+ for (ALL_LIST_ELEMENTS (bm->bgp, mnode, mnnode, bgp))
{
- LIST_LOOP (bgp->peer, peer, nm)
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
for (afi = AFI_IP; afi < AFI_MAX; afi++)
for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
}
}
}
- LIST_LOOP (bgp->group, group, nm)
+ for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group))
{
for (afi = AFI_IP; afi < AFI_MAX; afi++)
for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
{
struct bgp_filter *filter;
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (! peer->afc[afi][safi])
return BGP_ERR_PEER_INACTIVE;
return 0;
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
filter = &peer->filter[afi][safi];
struct bgp_filter *filter;
struct bgp_filter *gfilter;
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (! peer->afc[afi][safi])
return BGP_ERR_PEER_INACTIVE;
return 0;
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
filter = &peer->filter[afi][safi];
afi_t afi;
safi_t safi;
int direct;
- struct listnode *nn, *nm;
+ struct listnode *mnode, *mnnode;
+ struct listnode *node, *nnode;
struct bgp *bgp;
struct peer *peer;
struct peer_group *group;
struct bgp_filter *filter;
- LIST_LOOP (bm->bgp, bgp, nn)
+ for (ALL_LIST_ELEMENTS (bm->bgp, mnode, mnnode, bgp))
{
- LIST_LOOP (bgp->peer, peer, nm)
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
for (afi = AFI_IP; afi < AFI_MAX; afi++)
for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
}
}
}
- LIST_LOOP (bgp->group, group, nm)
+ for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group))
{
for (afi = AFI_IP; afi < AFI_MAX; afi++)
for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
{
struct bgp_filter *filter;
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (! peer->afc[afi][safi])
return BGP_ERR_PEER_INACTIVE;
return 0;
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
filter = &peer->filter[afi][safi];
struct bgp_filter *filter;
struct bgp_filter *gfilter;
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (! peer->afc[afi][safi])
return BGP_ERR_PEER_INACTIVE;
return 0;
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
filter = &peer->filter[afi][safi];
{
struct bgp_filter *filter;
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (! peer->afc[afi][safi])
return BGP_ERR_PEER_INACTIVE;
return 0;
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
filter = &peer->filter[afi][safi];
{
struct bgp_filter *filter;
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (! peer->afc[afi][safi])
return BGP_ERR_PEER_INACTIVE;
return 0;
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
filter = &peer->filter[afi][safi];
int warning, u_int16_t restart)
{
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (! peer->afc[afi][safi])
return BGP_ERR_PEER_INACTIVE;
return 0;
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
if (! peer->af_group[afi][safi])
continue;
peer_maximum_prefix_unset (struct peer *peer, afi_t afi, safi_t safi)
{
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (! peer->afc[afi][safi])
return BGP_ERR_PEER_INACTIVE;
return 0;
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
if (! peer->af_group[afi][safi])
continue;
int write = 0;
struct peer *peer;
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
bgp_config_write_network (vty, bgp, afi, safi, &write);
bgp_config_write_redistribute (vty, bgp, afi, safi, &write);
- LIST_LOOP (bgp->group, group, nn)
+ for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group))
{
if (group->conf->afc[afi][safi])
{
bgp_config_write_peer (vty, bgp, group->conf, afi, safi);
}
}
- LIST_LOOP (bgp->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
if (peer->afc[afi][safi])
{
struct bgp *bgp;
struct peer_group *group;
struct peer *peer;
- struct listnode *nn, *nm, *no;
+ struct listnode *node, *nnode;
+ struct listnode *mnode, *mnnode;
/* BGP Multiple instance. */
if (bgp_option_check (BGP_OPT_MULTIPLE_INSTANCE))
}
/* BGP configuration. */
- LIST_LOOP (bm->bgp, bgp, nn)
+ for (ALL_LIST_ELEMENTS (bm->bgp, mnode, mnnode, bgp))
{
if (write)
vty_out (vty, "!%s", VTY_NEWLINE);
bgp->default_holdtime, VTY_NEWLINE);
/* peer-group */
- LIST_LOOP (bgp->group, group, nm)
+ for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group))
{
bgp_config_write_peer (vty, bgp, group->conf, AFI_IP, SAFI_UNICAST);
}
/* Normal neighbor configuration. */
- LIST_LOOP (bgp->peer, peer, no)
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_ACCEPT_PEER))
bgp_config_write_peer (vty, bgp, peer, AFI_IP, SAFI_UNICAST);
{
struct bgp *bgp;
struct peer *peer;
- struct listnode *nn;
- struct listnode *mm;
+ struct listnode *node, *nnode;
+ struct listnode *mnode, *mnnode;
- LIST_LOOP (bm->bgp, bgp, nn)
- LIST_LOOP (bgp->peer, peer, mm)
+ for (ALL_LIST_ELEMENTS (bm->bgp, mnode, mnnode, bgp))
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
if (peer->status == Established)
bgp_notify_send (peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_PEER_UNCONFIG);
-
+
bgp_cleanup_routes ();
}
## Copyright (c) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro <kunihiro@zebra.org>
## Portions Copyright (c) 2003 Paul Jakma <paul@dishone.st>
##
-## $Id: configure.ac,v 1.98 2005/04/03 23:46:37 hasso Exp $
+## $Id: configure.ac,v 1.99 2005/04/07 07:30:20 paul Exp $
AC_PREREQ(2.53)
AC_INIT(Quagga, 0.99.0, [http://bugzilla.quagga.net])
AC_DEFINE_UNQUOTED(ISIS_VTYSH_PATH, "$quagga_statedir/isisd.vty",isisd vty socket)
AC_DEFINE_UNQUOTED(DAEMON_VTY_DIR, "$quagga_statedir",daemon vty directory)
+dnl -------------------------------
+dnl Quagga sources should always be
+dnl current wrt interfaces. Dont
+dnl allow deprecated interfaces to
+dnl be exposed.
+dnl -------------------------------
+AC_DEFINE(QUAGGA_NO_DEPRECATED_INTERFACES, 1, Hide deprecated interfaces)
+
dnl ---------------------------
dnl Check htonl works correctly
dnl ---------------------------
struct isis_adjacency *adj;
struct listnode *node;
- for (node = listhead (adjdb); node; nextnode (node))
- {
- adj = getdata (node);
- if (memcmp (adj->sysid, sysid, ISIS_SYS_ID_LEN) == 0)
- return adj;
- }
+ for (ALL_LIST_ELEMENTS_RO (adjdb, node, adj))
+ if (memcmp (adj->sysid, sysid, ISIS_SYS_ID_LEN) == 0)
+ return adj;
return NULL;
}
struct listnode *node;
struct isis_adjacency *adj;
- for (node = listhead (adjdb); node; nextnode (node))
- {
- adj = getdata (node);
- if (memcmp (adj->snpa, ssnpa, ETH_ALEN) == 0)
- return adj;
- }
+ for (ALL_LIST_ELEMENTS_RO (adjdb, node, adj))
+ if (memcmp (adj->snpa, ssnpa, ETH_ALEN) == 0)
+ return adj;
return NULL;
}
void
isis_delete_adj (struct isis_adjacency *adj, struct list *adjdb)
{
- struct isis_adjacency *adj2;
+ struct isis_adjacency *adj2 = NULL;
struct listnode *node;
if (adjdb)
{
- for (node = listhead (adjdb); node; nextnode (node))
- {
- adj2 = getdata (node);
- if (adj2 == adj)
- break;
- }
+ for (ALL_LIST_ELEMENTS_RO (adjdb, node, adj2))
+ if (adj2 == adj)
+ break;
+
listnode_delete (adjdb, adj);
}
{
zlog_debug ("IPv4 Addresses:");
- for (node = listhead (adj->ipv4_addrs); node; nextnode (node))
- {
- ipv4_addr = getdata (node);
- zlog_debug ("%s", inet_ntoa (*ipv4_addr));
- }
+ for (ALL_LIST_ELEMENTS_RO (adj->ipv4_addrs, node, ipv4_addr))
+ zlog_debug ("%s", inet_ntoa (*ipv4_addr));
}
#ifdef HAVE_IPV6
if (adj->ipv6_addrs && listcount (adj->ipv6_addrs) > 0)
{
zlog_debug ("IPv6 Addresses:");
- for (node = listhead (adj->ipv6_addrs); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (adj->ipv6_addrs, node, ipv6_addr))
{
- ipv6_addr = getdata (node);
inet_ntop (AF_INET6, ipv6_addr, (char *)ip6, INET6_ADDRSTRLEN);
zlog_debug ("%s", ip6);
}
if (adj->ipv4_addrs && listcount (adj->ipv4_addrs) > 0)
{
vty_out (vty, " IPv4 Addresses:%s", VTY_NEWLINE);
- for (node = listhead (adj->ipv4_addrs); node; nextnode (node))
- {
- ip_addr = getdata (node);
- vty_out (vty, " %s%s", inet_ntoa (*ip_addr), VTY_NEWLINE);
- }
+ for (ALL_LIST_ELEMENTS_RO (adj->ipv4_addrs, node, ip_addr))
+ vty_out (vty, " %s%s", inet_ntoa (*ip_addr), VTY_NEWLINE);
}
#ifdef HAVE_IPV6
if (adj->ipv6_addrs && listcount (adj->ipv6_addrs) > 0)
{
vty_out (vty, " IPv6 Addresses:%s", VTY_NEWLINE);
- for (node = listhead (adj->ipv6_addrs); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (adj->ipv4_addrs, node, ipv6_addr))
{
- ipv6_addr = getdata (node);
inet_ntop (AF_INET6, ipv6_addr, (char *)ip6, INET6_ADDRSTRLEN);
vty_out (vty, " %s%s", ip6, VTY_NEWLINE);
}
isis_adjdb_iterate (struct list *adjdb, void (*func) (struct isis_adjacency *,
void *), void *arg)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct isis_adjacency *adj;
- for (node = listhead (adjdb); node; nextnode (node))
- {
- adj = getdata (node);
- (*func) (adj, arg);
- }
+
+ for (ALL_LIST_ELEMENTS (adjdb, node, nnode, adj))
+ (*func) (adj, arg);
}
void
return;
}
- for (node = listhead (adjdb); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (adjdb, node, adj))
{
- adj = getdata (node);
if (!adj)
{
zlog_warn ("isis_adj_build_neigh_list(): NULL adj");
return;
}
- for (node = listhead (adjdb); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (adjdb, node, adj))
{
- adj = getdata (node);
-
if (!adj)
{
zlog_warn ("isis_adj_build_up_list(): NULL adj");
if (!list)
return NULL;
- for (node = listhead (list); node; nextnode (node))
- {
- circuit = getdata (node);
- if (circuit->interface == ifp)
- return circuit;
- }
-
+ for (ALL_LIST_ELEMENTS_RO (list, node, circuit))
+ if (circuit->interface == ifp)
+ return circuit;
+
return NULL;
}
if (!isis->area_list)
return NULL;
- for (node = listhead (isis->area_list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
{
- area = getdata (node);
circuit = circuit_lookup_by_ifp (ifp, area->circuit_list);
if (circuit)
return circuit;
ipv4->prefixlen = connected->address->prefixlen;
ipv4->prefix = connected->address->u.prefix4;
- for (node = listhead (circuit->ip_addrs); node; nextnode (node))
- {
- ip = getdata (node);
- if (prefix_same ((struct prefix *) ip, (struct prefix *) &ipv4))
- break;
- }
+ for (ALL_LIST_ELEMENTS_RO (circuit->ip_addrs, node, ip))
+ if (prefix_same ((struct prefix *) ip, (struct prefix *) &ipv4))
+ break;
if (ip)
{
if (IN6_IS_ADDR_LINKLOCAL (&ipv6->prefix))
{
- for (node = listhead (circuit->ipv6_link); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (circuit->ipv6_link, node, ip6))
{
- ip6 = getdata (node);
if (prefix_same ((struct prefix *) ip6, (struct prefix *) ipv6))
break;
}
}
else
{
- for (node = listhead (circuit->ipv6_non_link); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (circuit->ipv6_non_link, node, ip6))
{
- ip6 = getdata (node);
if (prefix_same ((struct prefix *) ip6, (struct prefix *) ipv6))
break;
}
void
isis_circuit_if_add (struct isis_circuit *circuit, struct interface *ifp)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct connected *conn;
circuit->interface = ifp;
zlog_warn ("isis_circuit_if_add: unsupported media");
}
- for (node = ifp->connected ? listhead (ifp->connected) : NULL; node;
- nextnode (node))
- {
- conn = getdata (node);
- isis_circuit_add_addr (circuit, conn);
- }
+ for (ALL_LIST_ELEMENTS (ifp->connected, node, nnode, conn))
+ isis_circuit_add_addr (circuit, conn);
return;
}
{
int write = 0;
- struct listnode *node;
- struct listnode *node2;
+ struct listnode *node, *nnode;
+ struct listnode *node2, *nnode2;
struct interface *ifp;
struct isis_area *area;
struct isis_circuit *c;
int i;
- LIST_LOOP (iflist, ifp, node)
+ for (ALL_LIST_ELEMENTS (iflist, node, nnode, ifp))
{
/* IF name */
vty_out (vty, "interface %s%s", ifp->name, VTY_NEWLINE);
write++;
}
/* ISIS Circuit */
- LIST_LOOP (isis->area_list, area, node2)
+ for (ALL_LIST_ELEMENTS (isis->area_list, node2, nnode2, area))
{
c = circuit_lookup_by_ifp (ifp, area->circuit_list);
if (c)
struct isis_circuit *circuit = NULL;
struct interface *ifp;
struct isis_area *area;
- struct listnode *node;
+ struct listnode *node, *nnode;
ifp = (struct interface *) vty->index;
assert (ifp);
vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
return CMD_WARNING;
}
- LIST_LOOP (area->circuit_list, circuit, node)
+ for (ALL_LIST_ELEMENTS (area->circuit_list, node, nnode, circuit))
if (circuit->interface == ifp)
break;
if (!circuit)
isis_dr_elect (struct isis_circuit *circuit, int level)
{
struct list *adjdb;
- struct listnode *node;
+ struct listnode *node, *nnode;
struct isis_adjacency *adj, *adj_dr = NULL;
struct list *list = list_new ();
u_char own_prio;
/*
* Loop the adjacencies and find the one with the biggest priority
*/
- for (node = listhead (list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (list, node, nnode, adj))
{
- adj = getdata (node);
/* clear flag for show output */
adj->dis_record[level - 1].dis = ISIS_IS_NOT_DIS;
adj->dis_record[level - 1].last_dis_change = time (NULL);
*/
/* rotate the history log */
- for (node = listhead (list); node; nextnode (node))
- {
- adj = getdata (node);
- isis_check_dr_change (adj, level);
- }
+ for (ALL_LIST_ELEMENTS (list, node, nnode, adj))
+ isis_check_dr_change (adj, level);
/* commence */
list_delete (list);
* if yes rotate the history log
*/
- for (node = listhead (list); node; nextnode (node))
- {
- adj = getdata (node);
- isis_check_dr_change (adj, level);
- }
+ for (ALL_LIST_ELEMENTS (list, node, nnode, adj))
+ isis_check_dr_change (adj, level);
/*
* We are not DR - if we were -> resign
struct listnode *node = NULL;
struct isis_dynhn *dyn = NULL;
- for (node = listhead (dyn_cache); node; nextnode (node))
- {
- dyn = getdata (node);
- if (memcmp (dyn->id, id, ISIS_SYS_ID_LEN) == 0)
- return dyn;
- }
+ for (ALL_LIST_ELEMENTS_RO (dyn_cache, node, dyn))
+ if (memcmp (dyn->id, id, ISIS_SYS_ID_LEN) == 0)
+ return dyn;
return NULL;
}
struct isis_dynhn *dyn;
vty_out (vty, "Level System ID Dynamic Hostname%s", VTY_NEWLINE);
- for (node = listhead (dyn_cache); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (dyn_cache, node, dyn))
{
- dyn = getdata (node);
vty_out (vty, "%-7d", dyn->level);
vty_out (vty, "%-15s%-15s%s", sysid_print (dyn->id), dyn->name.name,
VTY_NEWLINE);
void
isis_event_system_type_change (struct isis_area *area, int newtype)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct isis_circuit *circuit;
if (isis->debugs & DEBUG_EVENTS)
}
area->is_type = newtype;
- for (node = listhead (area->circuit_list); node; nextnode (node))
- {
- circuit = getdata (node);
- isis_event_circuit_type_change (circuit, newtype);
- }
+ for (ALL_LIST_ELEMENTS (area->circuit_list, node, nnode, circuit))
+ isis_event_circuit_type_change (circuit, newtype);
spftree_area_init (area);
lsp_regenerate_schedule (area);
else
{
node = listhead (flags->free_idcs);
- index = (int) getdata (node);
+ index = (int) listgetdata (node);
listnode_delete (flags->free_idcs, (void *) index);
}
lsp_remove_frags (struct list *frags, dict_t * lspdb)
{
dnode_t *dnode;
- struct listnode *lnode;
+ struct listnode *lnode, *lnnode;
struct isis_lsp *lsp;
- for (lnode = listhead (frags); lnode; nextnode (lnode))
+ for (ALL_LIST_ELEMENTS (frags, lnode, lnnode, lsp))
{
- lsp = getdata (lnode);
dnode = dict_lookup (lspdb, lsp->lsp_header->lsp_id);
lsp_destroy (lsp);
dnode_destroy (dict_delete (lspdb, dnode));
lsp_seqnum_update (struct isis_lsp *lsp0)
{
struct isis_lsp *lsp;
- struct listnode *node;
+ struct listnode *node, *nnode;
lsp_inc_seqnum (lsp0, 0);
if (!lsp0->lspu.frags)
return;
- for (node = listhead (lsp0->lspu.frags); node; nextnode (node))
- {
- lsp = getdata (node);
- lsp_inc_seqnum (lsp, 0);
- }
+ for (ALL_LIST_ELEMENTS (lsp0->lspu.frags, node, nnode, lsp))
+ lsp_inc_seqnum (lsp, 0);
return;
}
struct isis_lsp *lsp = dnode_get (node);
struct area_addr *area_addr;
int i;
- struct listnode *lnode;
+ struct listnode *lnode, *lnnode;
struct is_neigh *is_neigh;
struct te_is_neigh *te_is_neigh;
struct ipv4_reachability *ipv4_reach;
/* for all area address */
if (lsp->tlv_data.area_addrs)
- {
- LIST_LOOP (lsp->tlv_data.area_addrs, area_addr, lnode)
+ for (ALL_LIST_ELEMENTS (lsp->tlv_data.area_addrs, lnode,
+ lnnode, area_addr))
{
vty_out (vty, " Area Address: %s%s",
isonet_print (area_addr->area_addr, area_addr->addr_len),
VTY_NEWLINE);
}
- }
-
+
/* for the nlpid tlv */
if (lsp->tlv_data.nlpids)
{
}
if (lsp->tlv_data.ipv4_addrs)
- {
- LIST_LOOP (lsp->tlv_data.ipv4_addrs, ipv4_addr, lnode)
+ for (ALL_LIST_ELEMENTS (lsp->tlv_data.ipv4_addrs, lnode,
+ lnnode, ipv4_addr))
{
memcpy (ipv4_address, inet_ntoa (*ipv4_addr), sizeof (ipv4_address));
vty_out (vty, " IP: %s%s", ipv4_address, VTY_NEWLINE);
}
- }
/* TE router id */
if (lsp->tlv_data.router_id)
/* for the IS neighbor tlv */
if (lsp->tlv_data.is_neighs)
- {
- LIST_LOOP (lsp->tlv_data.is_neighs, is_neigh, lnode)
+ for (ALL_LIST_ELEMENTS (lsp->tlv_data.is_neighs, lnode, lnnode, is_neigh))
{
lspid_print (is_neigh->neigh_id, LSPid, dynhost, 0);
vty_out (vty, " Metric: %d IS %s%s",
is_neigh->metrics.metric_default, LSPid, VTY_NEWLINE);
}
- }
/* for the internal reachable tlv */
if (lsp->tlv_data.ipv4_int_reachs)
- LIST_LOOP (lsp->tlv_data.ipv4_int_reachs, ipv4_reach, lnode)
+ for (ALL_LIST_ELEMENTS (lsp->tlv_data.ipv4_int_reachs, lnode,
+ lnnode, ipv4_reach))
{
memcpy (ipv4_reach_prefix, inet_ntoa (ipv4_reach->prefix),
sizeof (ipv4_reach_prefix));
/* for the external reachable tlv */
if (lsp->tlv_data.ipv4_ext_reachs)
- LIST_LOOP (lsp->tlv_data.ipv4_ext_reachs, ipv4_reach, lnode)
+ for (ALL_LIST_ELEMENTS (lsp->tlv_data.ipv4_ext_reachs, lnode,
+ lnnode, ipv4_reach))
{
memcpy (ipv4_reach_prefix, inet_ntoa (ipv4_reach->prefix),
sizeof (ipv4_reach_prefix));
ipv4_reach->metrics.metric_default, ipv4_reach_prefix,
ipv4_reach_mask, VTY_NEWLINE);
}
-
+
/* IPv6 tlv */
#ifdef HAVE_IPV6
if (lsp->tlv_data.ipv6_reachs)
- LIST_LOOP (lsp->tlv_data.ipv6_reachs, ipv6_reach, lnode)
+ for (ALL_LIST_ELEMENTS (lsp->tlv_data.ipv6_reachs, lnode,
+ lnnode, ipv6_reach))
{
memset (&in6, 0, sizeof (in6));
memcpy (in6.s6_addr, ipv6_reach->prefix,
buff, ipv6_reach->prefix_len, VTY_NEWLINE);
}
#endif
+
/* TE IS neighbor tlv */
if (lsp->tlv_data.te_is_neighs)
- LIST_LOOP (lsp->tlv_data.te_is_neighs, te_is_neigh, lnode)
+ for (ALL_LIST_ELEMENTS (lsp->tlv_data.te_is_neighs, lnode,
+ lnnode, te_is_neigh))
{
/* FIXME: metric display is wrong. */
lspid_print (te_is_neigh->neigh_id, LSPid, dynhost, 0);
/* TE IPv4 tlv */
if (lsp->tlv_data.te_ipv4_reachs)
- LIST_LOOP (lsp->tlv_data.te_ipv4_reachs, te_ipv4_reach, lnode)
+ for (ALL_LIST_ELEMENTS (lsp->tlv_data.te_ipv4_reachs, lnode,
+ lnnode, te_ipv4_reach))
{
/* FIXME: There should be better way to output this stuff. */
vty_out (vty, " Metric: %d extd-IP %s/%d%s",
lsp_build_nonpseudo (struct isis_lsp *lsp, struct isis_area *area)
{
struct is_neigh *is_neigh;
- struct listnode *node, *ipnode;
+ struct listnode *node, *nnode, *ipnode, *ipnnode;
int level = lsp->level;
struct isis_circuit *circuit;
struct prefix_ipv4 *ipv4;
/*
* Then add tlvs related to circuits
*/
- for (node = listhead (area->circuit_list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (area->circuit_list, node, nnode, circuit))
{
- circuit = getdata (node);
if (circuit->state != C_STATE_UP)
continue;
lsp->tlv_data.ipv4_int_reachs = list_new ();
lsp->tlv_data.ipv4_int_reachs->del = free_tlv;
}
- for (ipnode = listhead (circuit->ip_addrs); ipnode;
- nextnode (ipnode))
+ for (ALL_LIST_ELEMENTS (circuit->ip_addrs, ipnode, ipnnode, ipv4))
{
- ipv4 = getdata (ipnode);
ipreach =
XMALLOC (MTYPE_ISIS_TLV, sizeof (struct ipv4_reachability));
ipreach->metrics = circuit->metrics[level - 1];
lsp->tlv_data.ipv6_reachs = list_new ();
lsp->tlv_data.ipv6_reachs->del = free_tlv;
}
- for (ipnode = listhead (circuit->ipv6_non_link); ipnode;
- nextnode (ipnode))
+ for (ALL_LIST_ELEMENTS (circuit->ipv6_non_link, ipnode,
+ ipnnode, ipv6))
{
- ipv6 = getdata (ipnode);
ip6reach =
XMALLOC (MTYPE_ISIS_TLV, sizeof (struct ipv6_reachability));
memset (ip6reach, 0, sizeof (struct ipv6_reachability));
count = count / tlvsize;
for (i = 0; i < count; i++)
{
- listnode_add (*to, getdata (listhead (*from)));
- listnode_delete (*from, getdata (listhead (*from)));
+ listnode_add (*to, listgetdata (listhead (*from)));
+ listnode_delete (*from, listgetdata (listhead (*from)));
}
tlv_build_func (*to, lsp->pdu);
}
lsp_build_nonpseudo (struct isis_lsp *lsp, struct isis_area *area)
{
struct is_neigh *is_neigh;
- struct listnode *node, *ipnode;
+ struct listnode *node, *nnode, *ipnode, *ipnnode;
int level = lsp->level;
struct isis_circuit *circuit;
struct prefix_ipv4 *ipv4;
/*
* Then build lists of tlvs related to circuits
*/
- for (node = listhead (area->circuit_list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (area->circuit_list, node, nnode, circuit))
{
- circuit = getdata (node);
if (circuit->state != C_STATE_UP)
continue;
{
tlv_data.ipv4_int_reachs = list_new ();
}
- for (ipnode = listhead (circuit->ip_addrs); ipnode;
- nextnode (ipnode))
+ for (ALL_LIST_ELEMENTS (circuit->ip_addrs, ipnode, ipnnode, ipv4))
{
- ipv4 = getdata (ipnode);
ipreach =
XMALLOC (MTYPE_ISIS_TLV, sizeof (struct ipv4_reachability));
ipreach->metrics = circuit->metrics[level - 1];
{
tlv_data.ipv6_reachs = list_new ();
}
- for (ipnode = listhead (circuit->ipv6_non_link); ipnode;
- nextnode (ipnode))
+ for (ALL_LIST_ELEMENTS (circuit->ipv6_non_link, ipnode, ipnnode,
+ ipv6))
{
- ipv6 = getdata (ipnode);
ip6reach =
XMALLOC (MTYPE_ISIS_TLV, sizeof (struct ipv6_reachability));
memset (ip6reach, 0, sizeof (struct ipv6_reachability));
lsp->last_generated = time (NULL);
area->lsp_regenerate_pending[level - 1] = 0;
ISIS_FLAGS_SET_ALL (lsp->SRMflags);
- for (node = listhead (lsp->lspu.frags); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (lsp->lspu.frags, node, frag))
{
- frag = getdata (node);
frag->lsp_header->rem_lifetime = htons (isis_jitter
(area->
max_lsp_lifetime[level - 1],
struct is_neigh *is_neigh;
struct es_neigh *es_neigh;
struct list *adj_list;
- struct listnode *node;
+ struct listnode *node, *nnode;
struct isis_passwd *passwd;
assert (circuit);
adj_list = list_new ();
isis_adj_build_up_list (circuit->u.bc.adjdb[level - 1], adj_list);
- for (node = listhead (adj_list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (adj_list, node, nnode, adj))
{
- adj = getdata (node);
if (adj->circuit_t & level)
{
if ((level == 1 && adj->sys_type == ISIS_SYSTYPE_L1_IS) ||
struct isis_circuit *circuit;
struct isis_lsp *lsp;
struct list *lsp_list;
- struct listnode *lspnode, *cnode;
+ struct listnode *lspnode, *lspnnode, *cnode;
dnode_t *dnode, *dnode_next;
int level;
*/
if (listcount (lsp_list) > 0)
{
- for (cnode = listhead (area->circuit_list); cnode;
- nextnode (cnode))
+ for (ALL_LIST_ELEMENTS_RO (area->circuit_list, cnode, circuit))
{
- circuit = getdata (cnode);
- for (lspnode = listhead (lsp_list); lspnode;
- nextnode (lspnode))
+ for (ALL_LIST_ELEMENTS (lsp_list, lspnode, lspnnode, lsp))
{
- lsp = getdata (lspnode);
if (ISIS_CHECK_FLAG (lsp->SRMflags, circuit))
{
/* FIXME: if same or elder lsp is already in lsp
area_match (struct list *left, struct list *right)
{
struct area_addr *addr1, *addr2;
- struct listnode *node1, *node2;
+ struct listnode *node1, *nnode1;
+ struct listnode *node2, *nnode2;
- LIST_LOOP (left, addr1, node1)
+ for (ALL_LIST_ELEMENTS (left, node1, nnode1, addr1))
{
- LIST_LOOP (right, addr2, node2)
+ for (ALL_LIST_ELEMENTS (right, node2, nnode2, addr2))
{
if (addr1->addr_len == addr2->addr_len &&
!memcmp (addr1->area_addr, addr2->area_addr, (int) addr1->addr_len))
{
struct prefix_ipv4 *ip1;
struct in_addr *ip2;
- struct listnode *node1, *node2;
+ struct listnode *node1, *nnode1;
+ struct listnode *node2, *nnode2;
if ((left == NULL) || (right == NULL))
return 0;
- LIST_LOOP (left, ip1, node1)
+ for (ALL_LIST_ELEMENTS (left, node1, nnode1, ip1))
{
- LIST_LOOP (right, ip2, node2)
+ for (ALL_LIST_ELEMENTS (right, node2, nnode2, ip2))
{
if (ip_same_subnet (ip1, ip2))
{
static void
tlvs_to_adj_ipv4_addrs (struct tlvs *tlvs, struct isis_adjacency *adj)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct in_addr *ipv4_addr, *malloced;
if (adj->ipv4_addrs)
adj->ipv4_addrs = list_new ();
if (tlvs->ipv4_addrs)
{
- LIST_LOOP (tlvs->ipv4_addrs, ipv4_addr, node)
+ for (ALL_LIST_ELEMENTS (tlvs->ipv4_addrs, node, nnode, ipv4_addr))
{
malloced = XMALLOC (MTYPE_ISIS_TMP, sizeof (struct in_addr));
memcpy (malloced, ipv4_addr, sizeof (struct in_addr));
static void
tlvs_to_adj_ipv6_addrs (struct tlvs *tlvs, struct isis_adjacency *adj)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct in6_addr *ipv6_addr, *malloced;
if (adj->ipv6_addrs)
adj->ipv6_addrs = list_new ();
if (tlvs->ipv6_addrs)
{
- LIST_LOOP (tlvs->ipv6_addrs, ipv6_addr, node)
+ for (ALL_LIST_ELEMENTS (tlvs->ipv6_addrs, node, nnode, ipv6_addr))
{
malloced = XMALLOC (MTYPE_ISIS_TMP, sizeof (struct in6_addr));
memcpy (malloced, ipv6_addr, sizeof (struct in6_addr));
u_int32_t expected = 0, found;
struct tlvs tlvs;
u_char *snpa;
- struct listnode *node;
+ struct listnode *node, *nnode;
if ((stream_get_endp (circuit->rcv_stream) -
stream_get_getp (circuit->rcv_stream)) < ISIS_LANHELLO_HDRLEN)
{
if (adj->adj_state != ISIS_ADJ_UP)
{
- LIST_LOOP (tlvs.lan_neighs, snpa, node)
+ for (ALL_LIST_ELEMENTS (tlvs.lan_neighs, node, nnode, snpa))
if (!memcmp (snpa, circuit->u.bc.snpa, ETH_ALEN))
{
isis_adj_state_change (adj, ISIS_ADJ_UP,
uint32_t found = 0, expected = 0;
struct isis_lsp *lsp;
struct lsp_entry *entry;
- struct listnode *node, *node2;
+ struct listnode *node, *nnode;
+ struct listnode *node2, *nnode2;
struct tlvs tlvs;
struct list *lsp_list = NULL;
struct isis_passwd *passwd;
typechar, snpa_print (ssnpa), circuit->interface->name);
if (tlvs.lsp_entries)
{
- LIST_LOOP (tlvs.lsp_entries, entry, node)
+ for (ALL_LIST_ELEMENTS (tlvs.lsp_entries, node, nnode, entry))
{
zlog_debug ("ISIS-Snp (%s): %cSNP entry %s, seq 0x%08x,"
" cksum 0x%04x, lifetime %us",
/* 7.3.15.2 b) Actions on LSP_ENTRIES reported */
if (tlvs.lsp_entries)
{
- LIST_LOOP (tlvs.lsp_entries, entry, node)
+ for (ALL_LIST_ELEMENTS (tlvs.lsp_entries, node, nnode, entry))
{
lsp = lsp_search (entry->lsp_id, circuit->area->lspdb[level - 1]);
own_lsp = !memcmp (entry->lsp_id, isis->sysid, ISIS_SYS_ID_LEN);
/* Fixme: Find a better solution */
if (tlvs.lsp_entries)
{
- LIST_LOOP (tlvs.lsp_entries, entry, node)
+ for (ALL_LIST_ELEMENTS (tlvs.lsp_entries, node, nnode, entry))
{
- LIST_LOOP (lsp_list, lsp, node2)
+ for (ALL_LIST_ELEMENTS (lsp_list, node2, nnode2, lsp))
{
if (lsp_id_cmp (lsp->lsp_header->lsp_id, entry->lsp_id) == 0)
{
}
}
/* on remaining LSPs we set SRM (neighbor knew not of) */
- LIST_LOOP (lsp_list, lsp, node2)
+ for (ALL_LIST_ELEMENTS (lsp_list, node2, nnode2, lsp))
{
ISIS_SET_FLAG (lsp->SRMflags, circuit);
}
u_char start[ISIS_SYS_ID_LEN + 2];
u_char stop[ISIS_SYS_ID_LEN + 2];
struct list *list = NULL;
- struct listnode *node;
+ struct listnode *node, *nnode;
struct isis_lsp *lsp;
memset (start, 0x00, ISIS_SYS_ID_LEN + 2);
if (isis->debugs & DEBUG_SNP_PACKETS)
{
zlog_debug ("ISIS-Snp (%s): Sent L%d CSNP on %s, length %ld",
- circuit->area->area_tag, level, circuit->interface->name,
- STREAM_SIZE (circuit->snd_stream));
- LIST_LOOP (list, lsp, node)
+ circuit->area->area_tag, level, circuit->interface->name,
+ STREAM_SIZE (circuit->snd_stream));
+ for (ALL_LIST_ELEMENTS (list, node, nnode, lsp))
{
zlog_debug ("ISIS-Snp (%s): CSNP entry %s, seq 0x%08x,"
" cksum 0x%04x, lifetime %us",
int retval = 0;
struct isis_lsp *lsp;
struct isis_passwd *passwd;
- struct listnode *node;
+ struct listnode *node, *nnode;
if (level == 1)
fill_fixed_hdr_andstream (&fixed_hdr, L1_PARTIAL_SEQ_NUM,
if (isis->debugs & DEBUG_SNP_PACKETS)
{
- LIST_LOOP (lsps, lsp, node)
+ for (ALL_LIST_ELEMENTS (lsps, node, nnode, lsp))
{
zlog_debug ("ISIS-Snp (%s): PSNP entry %s, seq 0x%08x,"
" cksum 0x%04x, lifetime %us",
int retval = ISIS_OK;
struct isis_lsp *lsp;
struct list *list = NULL;
- struct listnode *node;
+ struct listnode *node, *nnode;
if ((circuit->circ_type == CIRCUIT_T_BROADCAST &&
!circuit->u.bc.is_dr[level - 1]) ||
* sending succeeded, we can clear SSN flags of this circuit
* for the LSPs in list
*/
- for (node = listhead (list); node; nextnode (node))
- {
- lsp = getdata (node);
- ISIS_CLEAR_FLAG (lsp->SSNflags, circuit);
- }
+ for (ALL_LIST_ELEMENTS (list, node, nnode, lsp))
+ ISIS_CLEAR_FLAG (lsp->SSNflags, circuit);
}
}
list_delete (list);
if (circuit->state == C_STATE_UP)
{
- node = listhead (circuit->lsp_queue);
- assert (node);
-
- lsp = getdata (node);
+ lsp = listgetdata ((node = listhead (circuit->lsp_queue)));
/*
* Do not send if levels do not match
struct listnode *node;
struct isis_nexthop *nexthop;
- for (node = listhead (isis->nexthops); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (isis->nexthops, node, nexthop))
{
- nexthop = getdata (node);
if (nexthop->ifindex != ifindex)
continue;
if (ip && memcmp (&nexthop->ip, ip, sizeof (struct in_addr)) != 0)
struct listnode *node;
struct isis_nexthop *nh;
- for (node = listhead (nexthops); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (nexthops, node, nh))
{
- nh = getdata (node);
if (!(memcmp (ip, &nh->ip, sizeof (struct in_addr))) &&
ifindex == nh->ifindex)
return 1;
{
struct listnode *node;
- for (node = listhead (nhs); node; nextnode (node))
- nexthop_print (getdata (node));
+ for (ALL_LIST_ELEMENTS_RO (nhs, node, nh))
+ nexthop_print (nh);
}
#endif /* 0 */
struct listnode *node;
struct isis_nexthop6 *nexthop6;
- for (node = listhead (isis->nexthops6); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (isis->nexthops6, node, nexthop6))
{
- nexthop6 = getdata (node);
if (nexthop6->ifindex != ifindex)
continue;
if (ip6 && memcmp (&nexthop6->ip6, ip6, sizeof (struct in6_addr)) != 0)
struct listnode *node;
struct isis_nexthop6 *nh6;
- for (node = listhead (nexthops6); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (nexthops6, node, nh6))
{
- nh6 = getdata (node);
if (!(memcmp (ip6, &nh6->ip6, sizeof (struct in6_addr))) &&
ifindex == nh6->ifindex)
return 1;
{
struct listnode *node;
- for (node = listhead (nhs6); node; nextnode (node))
- nexthop6_print (getdata (node));
+ for (ALL_LIST_ELEMENTS_RO (nhs6, node, nh6))
+ nexthop6_print (nh6);
}
#endif /* EXTREME_DEBUG */
#endif /* HAVE_IPV6 */
adjinfo2nexthop (struct list *nexthops, struct isis_adjacency *adj)
{
struct isis_nexthop *nh;
- struct listnode *node;
+ struct listnode *node, *nnode;
struct in_addr *ipv4_addr;
if (adj->ipv4_addrs == NULL)
return;
- for (node = listhead (adj->ipv4_addrs); node; nextnode (node))
+
+ for (ALL_LIST_ELEMENTS (adj->ipv4_addrs, node, nnode, ipv4_addr))
{
- ipv4_addr = getdata (node);
if (!nexthoplookup (nexthops, ipv4_addr,
adj->circuit->interface->ifindex))
{
static void
adjinfo2nexthop6 (struct list *nexthops6, struct isis_adjacency *adj)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct in6_addr *ipv6_addr;
struct isis_nexthop6 *nh6;
if (!adj->ipv6_addrs)
return;
- for (node = listhead (adj->ipv6_addrs); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (adj->ipv6_addrs, node, nnode, ipv6_addr))
{
- ipv6_addr = getdata (node);
if (!nexthop6lookup (nexthops6, ipv6_addr,
adj->circuit->interface->ifindex))
{
{
struct isis_route_info *rinfo;
struct isis_adjacency *adj;
- struct listnode *node;
+ struct listnode *node, *nnode;
rinfo = XMALLOC (MTYPE_ISIS_ROUTE_INFO, sizeof (struct isis_route_info));
if (!rinfo)
if (family == AF_INET)
{
rinfo->nexthops = list_new ();
- for (node = listhead (adjacencies); node; nextnode (node))
- {
- adj = getdata (node);
- adjinfo2nexthop (rinfo->nexthops, adj);
- }
+ for (ALL_LIST_ELEMENTS (adjacencies, node, nnode, adj))
+ adjinfo2nexthop (rinfo->nexthops, adj);
}
#ifdef HAVE_IPV6
if (family == AF_INET6)
{
rinfo->nexthops6 = list_new ();
- for (node = listhead (adjacencies); node; nextnode (node))
- {
- adj = getdata (node);
- adjinfo2nexthop6 (rinfo->nexthops6, adj);
- }
+ for (ALL_LIST_ELEMENTS (adjacencies, node, nnode, adj))
+ adjinfo2nexthop6 (rinfo->nexthops6, adj);
}
#endif /* HAVE_IPV6 */
isis_route_info_same (struct isis_route_info *new,
struct isis_route_info *old, u_char family)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct isis_nexthop *nexthop;
#ifdef HAVE_IPV6
struct isis_nexthop6 *nexthop6;
if (family == AF_INET)
{
- for (node = listhead (new->nexthops); node; nextnode (node))
- {
- nexthop = (struct isis_nexthop *) getdata (node);
- if (nexthoplookup (old->nexthops, &nexthop->ip, nexthop->ifindex) ==
- 0)
- return 0;
- }
-
- for (node = listhead (old->nexthops); node; nextnode (node))
- {
- nexthop = (struct isis_nexthop *) getdata (node);
- if (nexthoplookup (new->nexthops, &nexthop->ip, nexthop->ifindex) ==
- 0)
- return 0;
- }
+ for (ALL_LIST_ELEMENTS (new->nexthops, node, nnode, nexthop))
+ if (nexthoplookup (old->nexthops, &nexthop->ip, nexthop->ifindex)
+ == 0)
+ return 0;
+
+ for (ALL_LIST_ELEMENTS (old->nexthops, node, nnode, nexthop))
+ if (nexthoplookup (new->nexthops, &nexthop->ip, nexthop->ifindex)
+ == 0)
+ return 0;
}
#ifdef HAVE_IPV6
else if (family == AF_INET6)
{
- for (node = listhead (new->nexthops6); node; nextnode (node))
- {
- nexthop6 = (struct isis_nexthop6 *) getdata (node);
- if (nexthop6lookup (old->nexthops6, &nexthop6->ip6,
- nexthop6->ifindex) == 0)
- return 0;
- }
-
- for (node = listhead (old->nexthops6); node; nextnode (node))
- {
- nexthop6 = (struct isis_nexthop6 *) getdata (node);
- if (nexthop6lookup (new->nexthops6, &nexthop6->ip6,
- nexthop6->ifindex) == 0)
- return 0;
- }
+ for (ALL_LIST_ELEMENTS (new->nexthops6, node, nnode, nexthop6))
+ if (nexthop6lookup (old->nexthops6, &nexthop6->ip6,
+ nexthop6->ifindex) == 0)
+ return 0;
+
+ for (ALL_LIST_ELEMENTS (old->nexthops6, node, nnode, nexthop6))
+ if (nexthop6lookup (new->nexthops6, &nexthop6->ip6,
+ nexthop6->ifindex) == 0)
+ return 0;
}
#endif /* HAVE_IPV6 */
static void
isis_nexthops_merge (struct list *new, struct list *old)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct isis_nexthop *nexthop;
- for (node = listhead (new); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (new, node, nnode, nexthop))
{
- nexthop = (struct isis_nexthop *) getdata (node);
if (nexthoplookup (old, &nexthop->ip, nexthop->ifindex))
continue;
listnode_add (old, nexthop);
static void
isis_nexthops6_merge (struct list *new, struct list *old)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct isis_nexthop6 *nexthop6;
- for (node = listhead (new); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (new, node, nnode, nexthop6))
{
- nexthop6 = (struct isis_nexthop6 *) getdata (node);
if (nexthop6lookup (old, &nexthop6->ip6, nexthop6->ifindex))
continue;
listnode_add (old, nexthop6);
struct listnode *node, *node2;
zlog_debug ("Union adjlist!");
- for (node = listhead (source); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (source, node, adj))
{
- adj = getdata (node);
-
/* lookup adjacency in the source list */
- for (node2 = listhead (target); node2; nextnode (node2))
- {
- adj2 = getdata (node2);
- if (adj == adj2)
+ for (ALL_LIST_ELEMENTS_RO (target, node2, adj2))
+ if (adj == adj2)
break;
- }
-
+
if (!node2)
listnode_add (target, adj);
}
static void
remove_excess_adjs (struct list *adjs)
{
- struct listnode *node, *excess = NULL;
+ struct listnode *node, *nnode, *excess = NULL;
struct isis_adjacency *adj, *candidate = NULL;
int comp;
- for (node = listhead (adjs); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (adjs, node, nnode, adj))
{
if (excess == NULL)
excess = node;
- candidate = getdata (excess);
- adj = getdata (node);
+ candidate = listgetdata (excess);
+
if (candidate->sys_type < adj->sys_type)
{
excess = node;
struct isis_vertex *vertex;
struct prefix *p1, *p2;
- for (node = listhead (list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (list, node, vertex))
{
- vertex = getdata (node);
if (vertex->type != vtype)
continue;
switch (vtype)
listnode_add (spftree->tents, vertex);
return vertex;
}
- for (node = listhead (spftree->tents); node; nextnode (node))
+
+ /* XXX: This cant use the standard ALL_LIST_ELEMENT macro */
+ for (node = listhead (spftree->tents); node; node = listnextnode (node))
{
- v = getdata (node);
+ v = listgetdata (node);
if (v->d_N > vertex->d_N)
{
list_add_node_prev (spftree->tents, node, vertex);
{
break;
}
- nextnode (node);
- (node) ? (v = getdata (node)) : (v = NULL);
+ /* XXX: this seems dubious, node is the loop iterator */
+ node = listnextnode (node);
+ (node) ? (v = listgetdata (node)) : (v = NULL);
}
list_add_node_prev (spftree->tents, node, vertex);
break;
{
if (lsp->tlv_data.is_neighs)
{
- for (node = listhead (lsp->tlv_data.is_neighs); node;
- nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (lsp->tlv_data.is_neighs, node, is_neigh))
{
- is_neigh = getdata (node);
/* C.2.6 a) */
/* Two way connectivity */
if (!memcmp (is_neigh->neigh_id, isis->sysid, ISIS_SYS_ID_LEN))
if (family == AF_INET && lsp->tlv_data.ipv4_int_reachs)
{
prefix.family = AF_INET;
- for (node = listhead (lsp->tlv_data.ipv4_int_reachs); node;
- nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (lsp->tlv_data.ipv4_int_reachs,
+ node, ipreach))
{
- ipreach = getdata (node);
dist = cost + ipreach->metrics.metric_default;
vtype = VTYPE_IPREACH_INTERNAL;
prefix.u.prefix4 = ipreach->prefix;
if (family == AF_INET && lsp->tlv_data.ipv4_ext_reachs)
{
prefix.family = AF_INET;
- for (node = listhead (lsp->tlv_data.ipv4_ext_reachs); node;
- nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (lsp->tlv_data.ipv4_ext_reachs,
+ node, ipreach))
{
- ipreach = getdata (node);
dist = cost + ipreach->metrics.metric_default;
vtype = VTYPE_IPREACH_EXTERNAL;
prefix.u.prefix4 = ipreach->prefix;
if (family == AF_INET6 && lsp->tlv_data.ipv6_reachs)
{
prefix.family = AF_INET6;
- for (node = listhead (lsp->tlv_data.ipv6_reachs); node;
- nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (lsp->tlv_data.ipv6_reachs,
+ node, ip6reach))
{
- ip6reach = getdata (node);
dist = cost + ip6reach->metric;
vtype = (ip6reach->control_info & CTRL_INFO_DISTRIBUTION) ?
VTYPE_IP6REACH_EXTERNAL : VTYPE_IP6REACH_INTERNAL;
if (fragnode == NULL)
fragnode = listhead (lsp->lspu.frags);
else
- nextnode (fragnode);
+ fragnode = listnextnode (fragnode);
if (fragnode)
{
- lsp = getdata (fragnode);
+ lsp = listgetdata (fragnode);
goto lspfragloop;
}
struct isis_lsp *lsp, uint16_t cost,
uint16_t depth, int family)
{
- struct listnode *node, *fragnode = NULL;
+ struct listnode *node, *nnode, *fragnode = NULL;
struct is_neigh *is_neigh;
enum vertextype vtype;
return ISIS_WARNING;
}
- for (node = (lsp->tlv_data.is_neighs ?
- listhead (lsp->tlv_data.is_neighs) : NULL);
- node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (lsp->tlv_data.is_neighs, node, nnode, is_neigh))
{
- is_neigh = getdata (node);
vtype = LSP_PSEUDO_ID (is_neigh->neigh_id) ? VTYPE_PSEUDO_IS
: VTYPE_NONPSEUDO_IS;
/* Two way connectivity */
if (fragnode == NULL)
fragnode = listhead (lsp->lspu.frags);
else
- nextnode (fragnode);
+ fragnode = listnextnode (fragnode);
if (fragnode)
{
- lsp = getdata (fragnode);
+ lsp = listgetdata (fragnode);
goto pseudofragloop;
}
{
struct isis_vertex *vertex;
struct isis_circuit *circuit;
- struct listnode *cnode, *anode, *ipnode;
+ struct listnode *cnode, *cnnode;
+ struct listnode *anode;
+ struct listnode *ipnode, *ipnnode;
struct isis_adjacency *adj;
struct isis_lsp *lsp;
struct list *adj_list;
struct prefix_ipv6 *ipv6;
#endif /* HAVE_IPV6 */
- for (cnode = listhead (area->circuit_list); cnode; nextnode (cnode))
+ for (ALL_LIST_ELEMENTS (area->circuit_list, cnode, cnnode, circuit))
{
- circuit = getdata (cnode);
if (circuit->state != C_STATE_UP)
continue;
if (!(circuit->circuit_is_type & level))
if (family == AF_INET)
{
prefix.family = AF_INET;
- for (ipnode =
- (circuit->ip_addrs ? listhead (circuit->ip_addrs) : NULL);
- ipnode; nextnode (ipnode))
+ for (ALL_LIST_ELEMENTS (circuit->ip_addrs, ipnode, ipnnode, ipv4))
{
- ipv4 = getdata (ipnode);
prefix.u.prefix4 = ipv4->prefix;
prefix.prefixlen = ipv4->prefixlen;
isis_spf_add_local (spftree, VTYPE_IPREACH_INTERNAL, &prefix,
if (family == AF_INET6)
{
prefix.family = AF_INET6;
- for (ipnode = (circuit->ipv6_non_link ? listhead
- (circuit->ipv6_non_link) : NULL); ipnode;
- nextnode (ipnode))
+ for (ALL_LIST_ELEMENTS (circuit->ipv6_non_link,
+ ipnode, ipnnode, ipv6))
{
- ipv6 = getdata (ipnode);
prefix.prefixlen = ipv6->prefixlen;
prefix.u.prefix6 = ipv6->prefix;
isis_spf_add_local (spftree, VTYPE_IP6REACH_INTERNAL,
anode = listhead (adj_list);
while (anode)
{
- adj = getdata (anode);
+ adj = listgetdata (anode);
if (!speaks (&adj->nlpids, family))
{
- nextnode (anode);
+ anode = listnextnode (anode);
continue;
}
switch (adj->sys_type)
default:
zlog_warn ("isis_spf_preload_tent unknow adj type");
}
- nextnode (anode);
+ anode = listnextnode (anode);
}
list_delete (adj_list);
/*
while (listcount (spftree->tents) > 0)
{
node = listhead (spftree->tents);
- vertex = getdata (node);
+ vertex = listgetdata (node);
/* Remove from tent list */
list_delete_node (spftree->tents, node);
if (isis_find_vertex (spftree->paths, vertex->N.id, vertex->type))
static void
isis_print_paths (struct vty *vty, struct list *paths)
{
- struct listnode *node, *anode;
+ struct listnode *node;
struct isis_vertex *vertex;
struct isis_dynhn *dyn, *nh_dyn = NULL;
struct isis_adjacency *adj;
vty_out (vty, "System Id Metric Next-Hop"
" Interface SNPA%s", VTY_NEWLINE);
- for (node = listhead (paths); node; nextnode (node))
+
+ for (ALL_LIST_ELEMENTS_RO (paths, node, vertex))
{
- vertex = getdata (node);
if (vertex->type != VTYPE_NONPSEUDO_IS)
continue;
if (memcmp (vertex->N.id, isis->sysid, ISIS_SYS_ID_LEN) == 0)
else
{
dyn = dynhn_find_by_id ((u_char *) vertex->N.id);
- anode = listhead (vertex->Adj_N);
- adj = getdata (anode);
+ adj = listgetdata (listhead (vertex->Adj_N));
if (adj)
{
nh_dyn = dynhn_find_by_id (adj->sysid);
if (!isis->area_list || isis->area_list->count == 0)
return CMD_SUCCESS;
- for (node = listhead (isis->area_list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
{
- area = getdata (node);
-
vty_out (vty, "Area %s:%s", area->area_tag ? area->area_tag : "null",
VTY_NEWLINE);
if (!isis->area_list || isis->area_list->count == 0)
return CMD_SUCCESS;
- for (node = listhead (isis->area_list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
{
- area = getdata (node);
-
vty_out (vty, "Area %s:%s", area->area_tag ? area->area_tag : "null",
VTY_NEWLINE);
if (!isis->area_list || isis->area_list->count == 0)
return CMD_SUCCESS;
- for (node = listhead (isis->area_list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
{
- area = getdata (node);
-
vty_out (vty, "Area %s:%s", area->area_tag ? area->area_tag : "null",
VTY_NEWLINE);
u_char value[255];
u_char *pos = value;
- for (node = listhead (area_addrs); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (area_addrs, node, area_addr))
{
- area_addr = getdata (node);
if (pos - value + area_addr->addr_len > 255)
goto err;
*pos = area_addr->addr_len;
int
tlv_add_is_neighs (struct list *is_neighs, struct stream *stream)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct is_neigh *is_neigh;
u_char value[255];
u_char *pos = value;
*pos = 0; /*is_neigh->virtual; */
pos++;
- for (node = listhead (is_neighs); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (is_neighs, node, nnode, is_neigh))
{
- is_neigh = getdata (node);
if (pos - value + IS_NEIGHBOURS_LEN > 255)
{
retval = add_tlv (IS_NEIGHBOURS, pos - value, value, stream);
int
tlv_add_lan_neighs (struct list *lan_neighs, struct stream *stream)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
u_char *snpa;
u_char value[255];
u_char *pos = value;
int retval;
- for (node = listhead (lan_neighs); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (lan_neighs, node, nnode, snpa))
{
- snpa = getdata (node);
if (pos - value + ETH_ALEN > 255)
{
retval = add_tlv (LAN_NEIGHBOURS, pos - value, value, stream);
int
tlv_add_ip_addrs (struct list *ip_addrs, struct stream *stream)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct prefix_ipv4 *ipv4;
u_char value[255];
u_char *pos = value;
int retval;
- for (node = listhead (ip_addrs); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (ip_addrs, node, nnode, ipv4))
{
- ipv4 = getdata (node);
if (pos - value + IPV4_MAX_BYTELEN > 255)
{
retval = add_tlv (IPV4_ADDR, pos - value, value, stream);
int
tlv_add_lsp_entries (struct list *lsps, struct stream *stream)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct isis_lsp *lsp;
u_char value[255];
u_char *pos = value;
int retval;
- for (node = listhead (lsps); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (lsps, node, nnode, lsp))
{
- lsp = getdata (node);
if (pos - value + LSP_ENTRIES_LEN > 255)
{
retval = add_tlv (LSP_ENTRIES, pos - value, value, stream);
int
tlv_add_ipv4_reachs (struct list *ipv4_reachs, struct stream *stream)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ipv4_reachability *reach;
u_char value[255];
u_char *pos = value;
int retval;
- for (node = listhead (ipv4_reachs); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (ipv4_reachs, node, nnode, reach))
{
- reach = getdata (node);
if (pos - value + IPV4_REACH_LEN > 255)
{
retval =
int
tlv_add_ipv6_addrs (struct list *ipv6_addrs, struct stream *stream)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct prefix_ipv6 *ipv6;
u_char value[255];
u_char *pos = value;
int retval;
- for (node = listhead (ipv6_addrs); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (ipv6_addrs, node, nnode, ipv6))
{
- ipv6 = getdata (node);
if (pos - value + IPV6_MAX_BYTELEN > 255)
{
retval = add_tlv (IPV6_ADDR, pos - value, value, stream);
int
tlv_add_ipv6_reachs (struct list *ipv6_reachs, struct stream *stream)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ipv6_reachability *ip6reach;
u_char value[255];
u_char *pos = value;
int retval, prefix_octets;
- for (node = listhead (ipv6_reachs); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (ipv6_reachs, node, nnode, ip6reach))
{
- ip6reach = getdata (node);
if (pos - value + IPV6_MAX_BYTELEN + 6 > 255)
{
retval = add_tlv (IPV6_REACHABILITY, pos - value, value, stream);
stream_putc (stream, listcount (route_info->nexthops));
/* Nexthop, ifindex, distance and metric information */
- for (node = listhead (route_info->nexthops); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (route_info->nexthops, node, nexthop))
{
- nexthop = getdata (node);
/* FIXME: can it be ? */
if (nexthop->ip.s_addr != INADDR_ANY)
{
/* for each nexthop */
i = 0;
- for (node = listhead (route_info->nexthops6); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (route_info->nexthops6, node, nexthop6))
{
- nexthop6 = getdata (node);
-
if (!IN6_IS_ADDR_LINKLOCAL (&nexthop6->ip6) &&
!IN6_IS_ADDR_UNSPECIFIED (&nexthop6->ip6))
{
/* for each nexthop */
i = 0;
- for (node = listhead (route_info->nexthops6); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (route_info->nexthops6, node, nexthop6))
{
- nexthop6 = getdata (node);
-
if (!IN6_IS_ADDR_LINKLOCAL (&nexthop6->ip6) &&
!IN6_IS_ADDR_UNSPECIFIED (&nexthop6->ip6))
{
isis_area_lookup (const char *area_tag)
{
struct isis_area *area;
- struct listnode *node;
+ struct listnode *node, *nnode;
- LIST_LOOP (isis->area_list, area, node)
+ for (ALL_LIST_ELEMENTS (isis->area_list, node, nnode, area))
if ((area->area_tag == NULL && area_tag == NULL) ||
(area->area_tag && area_tag
&& strcmp (area->area_tag, area_tag) == 0))
isis_area_destroy (struct vty *vty, const char *area_tag)
{
struct isis_area *area;
- struct listnode *node;
+ struct listnode *node, *nnode;
struct isis_circuit *circuit;
area = isis_area_lookup (area_tag);
if (area->circuit_list)
{
- node = listhead (area->circuit_list);
- while (node)
- {
- circuit = getdata (node);
- nextnode (node);
- isis_circuit_del (circuit);
- }
+ for (ALL_LIST_ELEMENTS (area->circuit_list, node, nnode, circuit))
+ isis_circuit_del (circuit);
+
list_delete (area->circuit_list);
}
listnode_delete (isis->area_list, area);
struct isis_area *area;
struct area_addr *addr;
struct area_addr *addrp;
- struct listnode *node;
+ struct listnode *node, *nnode;
u_char buff[255];
area = vty->index;
}
/* now we see that we don't already have this address */
- LIST_LOOP (area->area_addrs, addrp, node)
+ for (ALL_LIST_ELEMENTS (area->area_addrs, node, nnode, addrp))
{
if ((addrp->addr_len + ISIS_SYS_ID_LEN + 1) == (addr->addr_len))
{
{
struct isis_area *area;
struct area_addr addr, *addrp = NULL;
- struct listnode *node;
+ struct listnode *node, *nnode;
u_char buff[255];
area = vty->index;
memcpy (addr.area_addr, buff, (int) addr.addr_len);
- LIST_LOOP (area->area_addrs, addrp, node)
+ for (ALL_LIST_ELEMENTS (area->area_addrs, node, nnode, addrp))
if (addrp->addr_len == addr.addr_len &&
!memcmp (addrp->area_addr, addr.area_addr, addr.addr_len))
break;
int
show_clns_neigh (struct vty *vty, char detail)
{
- struct listnode *node_area, *node_circ;
+ struct listnode *anode, *annode, *cnode, *cnnode;
struct isis_area *area;
struct isis_circuit *circuit;
struct list *db;
return CMD_SUCCESS;
}
- for (node_area = listhead (isis->area_list); node_area;
- nextnode (node_area))
+ for (ALL_LIST_ELEMENTS (isis->area_list, anode, annode, area))
{
- area = getdata (node_area);
vty_out (vty, "Area %s:%s", area->area_tag, VTY_NEWLINE);
if (detail == ISIS_UI_LEVEL_BRIEF)
vty_out (vty, " System Id Interface L State "
"Holdtime SNPA%s", VTY_NEWLINE);
- for (node_circ = listhead (area->circuit_list); node_circ;
- nextnode (node_circ))
+ for (ALL_LIST_ELEMENTS (area->circuit_list, cnode, cnnode, circuit))
{
- circuit = getdata (node_circ);
if (circuit->circ_type == CIRCUIT_T_BROADCAST)
{
for (i = 0; i < 2; i++)
"show isis database",
SHOW_STR "IS-IS information\n" "IS-IS link state database\n")
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct isis_area *area;
int level, lsp_count;
if (isis->area_list->count == 0)
return CMD_SUCCESS;
- for (node = listhead (isis->area_list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (isis->area_list, node, nnode, area))
{
- area = getdata (node);
vty_out (vty, "Area %s:%s", area->area_tag ? area->area_tag : "null",
VTY_NEWLINE);
for (level = 0; level < ISIS_LEVELS; level++)
"IS-IS information\n"
"IS-IS link state database\n")
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct isis_area *area;
int level, lsp_count;
if (isis->area_list->count == 0)
return CMD_SUCCESS;
- for (node = listhead (isis->area_list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (isis->area_list, node, nnode, area))
{
- area = getdata (node);
vty_out (vty, "Area %s:%s", area->area_tag ? area->area_tag : "null",
VTY_NEWLINE);
for (level = 0; level < ISIS_LEVELS; level++)
* Put the is-type back to default. Which is level-1-2 on first
* circuit for the area level-1 for the rest
*/
- if (getdata (listhead (isis->area_list)) == area)
+ if (listgetdata (listhead (isis->area_list)) == area)
type = IS_LEVEL_1_AND_2;
else
type = IS_LEVEL_1;
"CLNS neighbor adjacencies\n")
{
struct isis_area *area;
- struct listnode *node;
+ struct listnode *node, *nnode;
struct listnode *node2;
struct arc *arc;
- LIST_LOOP (isis->area_list, area, node)
+ for (ALL_LIST_ELEMENTS (isis->area_list, node, nnode, area))
{
if (area->topology)
{
if (isis != NULL)
{
struct isis_area *area;
- struct listnode *node;
- struct listnode *node2;
+ struct listnode *node, *nnode;
+ struct listnode *node2, *nnode2;
- LIST_LOOP (isis->area_list, area, node)
+ for (ALL_LIST_ELEMENTS (isis->area_list, node, nnode, area))
{
/* ISIS - Area name */
vty_out (vty, "router isis %s%s", area->area_tag, VTY_NEWLINE);
if (listcount (area->area_addrs) > 0)
{
struct area_addr *area_addr;
- LIST_LOOP (area->area_addrs, area_addr, node2)
+ for (ALL_LIST_ELEMENTS (area->area_addrs, node2, nnode2, area_addr))
{
vty_out (vty, " net %s%s",
isonet_print (area_addr->area_addr,
+2005-04-07 Paul Jakma <paul.jakma@sun.com>
+
+ * linklist.h: Add usage comments.
+ Rename getdata macro to listgetdata.
+ Rename nextnode to listnextnode and fix its odd behaviour to be
+ less dangerous.
+ Make listgetdata macro assert node is not null, NULL list entries
+ should be bug condition.
+ ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use
+ with for loop, Suggested by Jim Carlson of Sun.
+ Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the
+ "safety" of previous macro.
+ LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to
+ distinguish from the similarly named functions, and reflect their
+ effect better.
+ Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section
+ with the old defines which were modified above,
+ for backwards compatibility - guarded to prevent Quagga using it..
+ * linklist.c: fix up for linklist.h changes.
+ * *.c: fix up for new list loop macro, try audit other loop
+ usage at same time, to some degree.
+
2004-04-05 Hasso Tepper <hasso at quagga.net>
* lib/prefix.[hc]: inet6_ntoa utility function copied from
struct listnode *node;
struct interface *ifp;
- for (node = listhead (iflist); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO(iflist, node, ifp))
{
- ifp = getdata (node);
if (ifp->ifindex == index)
return ifp;
}
struct listnode *node;
struct interface *ifp;
- for (node = listhead (iflist); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
{
- ifp = getdata (node);
if (strcmp(name, ifp->name) == 0)
return ifp;
}
if_lookup_by_name_len(const char *name, size_t namelen)
{
struct listnode *node;
+ struct interface *ifp;
if (namelen > INTERFACE_NAMSIZ)
return NULL;
- for (node = listhead (iflist); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
{
- struct interface *ifp;
-
- ifp = getdata (node);
if (!memcmp(name, ifp->name, namelen) && (ifp->name[namelen] == '\0'))
return ifp;
}
struct prefix *p;
struct connected *c;
- for (node = listhead (iflist); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
{
- ifp = getdata (node);
-
- for (cnode = listhead (ifp->connected); cnode; nextnode (cnode))
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, cnode, c))
{
- c = getdata (cnode);
-
p = c->address;
if (p && p->family == AF_INET)
match = NULL;
- for (node = listhead (iflist); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
{
- ifp = getdata (node);
-
- for (cnode = listhead (ifp->connected); cnode; nextnode (cnode))
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, cnode, c))
{
- c = getdata (cnode);
-
if (c->address && (c->address->family == AF_INET))
{
if (CONNECTED_POINTOPOINT_HOST(c))
if_dump (struct interface *ifp)
{
struct listnode *node;
+ struct connected *c;
zlog_info ("Interface %s index %d metric %d mtu %d "
#ifdef HAVE_IPV6
#endif /* HAVE_IPV6 */
if_flag_dump (ifp->flags));
- for (node = listhead (ifp->connected); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, c))
;
}
if_dump_all ()
{
struct listnode *node;
+ void *p;
- for (node = listhead (iflist); node; nextnode (node))
- if_dump (getdata (node));
+ for (ALL_LIST_ELEMENTS_RO (iflist, node, p))
+ if_dump (p);
}
DEFUN (interface_desc,
struct connected *ifc;
struct prefix *p;
- for (node = listhead (iflist); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
{
- ifp = getdata (node);
-
- for (node2 = listhead (ifp->connected); node2; nextnode (node2))
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, node2, ifc))
{
- ifc = getdata (node2);
p = ifc->address;
if (p->family == AF_INET)
/* In case of same prefix come, replace it with new one. */
for (node = listhead (ifp->connected); node; node = next)
{
- ifc = getdata (node);
+ ifc = listgetdata (node);
next = node->next;
if (connected_same_prefix (ifc->address, p))
match = NULL;
- for (cnode = listhead (ifp->connected); cnode; nextnode (cnode))
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, cnode, c))
{
- c = getdata (cnode);
-
if (c->address && (c->address->family == AF_INET))
{
if (CONNECTED_POINTOPOINT_HOST(c))
struct prefix_ipv4 p;
struct route_node *rn;
struct interface *ifp;
- struct listnode *node;
if (addr)
{
struct keychain *
keychain_lookup (const char *name)
{
- struct listnode *nn;
+ struct listnode *node;
struct keychain *keychain;
if (name == NULL)
return NULL;
- LIST_LOOP (keychain_list, keychain, nn)
+ for (ALL_LIST_ELEMENTS_RO (keychain_list, node, keychain))
{
if (strcmp (keychain->name, name) == 0)
return keychain;
struct key *
key_lookup (const struct keychain *keychain, u_int32_t index)
{
- struct listnode *nn;
+ struct listnode *node;
struct key *key;
- LIST_LOOP (keychain->key, key, nn)
+ for (ALL_LIST_ELEMENTS_RO (keychain->key, node, key))
{
if (key->index == index)
return key;
struct key *
key_lookup_for_accept (const struct keychain *keychain, u_int32_t index)
{
- struct listnode *nn;
+ struct listnode *node;
struct key *key;
time_t now;
now = time (NULL);
- LIST_LOOP (keychain->key, key, nn)
+ for (ALL_LIST_ELEMENTS_RO (keychain->key, node, key))
{
if (key->index >= index)
{
struct key *
key_match_for_accept (const struct keychain *keychain, const char *auth_str)
{
- struct listnode *nn;
+ struct listnode *node;
struct key *key;
time_t now;
now = time (NULL);
- LIST_LOOP (keychain->key, key, nn)
+ for (ALL_LIST_ELEMENTS_RO (keychain->key, node, key))
{
if (key->accept.start == 0 ||
(key->accept.start <= now &&
struct key *
key_lookup_for_send (const struct keychain *keychain)
{
- struct listnode *nn;
+ struct listnode *node;
struct key *key;
time_t now;
now = time (NULL);
- LIST_LOOP (keychain->key, key, nn)
+ for (ALL_LIST_ELEMENTS_RO (keychain->key, node, key))
{
if (key->send.start == 0)
return key;
{
struct keychain *keychain;
struct key *key;
- struct listnode *nn;
- struct listnode *nm;
+ struct listnode *node;
+ struct listnode *knode;
char buf[BUFSIZ];
- LIST_LOOP (keychain_list, keychain, nn)
+ for (ALL_LIST_ELEMENTS_RO (keychain_list, node, keychain))
{
vty_out (vty, "key chain %s%s", keychain->name, VTY_NEWLINE);
- LIST_LOOP (keychain->key, key, nm)
+ for (ALL_LIST_ELEMENTS_RO (keychain->key, knode, key))
{
vty_out (vty, " key %d%s", key->index, VTY_NEWLINE);
struct listnode *node;
assert(list);
- for (node = list->head; node; nextnode (node))
- if (data == getdata (node))
+ for (node = listhead(list); node; node = listnextnode (node))
+ if (data == listgetdata (node))
return node;
return NULL;
}
{
struct listnode *n;
- for (n = listhead (m); n; nextnode (n))
+ for (n = listhead (m); n; n = listnextnode (n))
listnode_add (l, n->data);
}
#ifndef _ZEBRA_LINKLIST_H
#define _ZEBRA_LINKLIST_H
+/* listnodes must always contain data to be valid. Adding an empty node
+ * to a list is invalid
+ */
struct listnode
{
struct listnode *next;
struct listnode *prev;
+
+ /* private member, use getdata() to retrieve, do not access directly */
void *data;
};
{
struct listnode *head;
struct listnode *tail;
+
/* invariant: count is the number of listnodes in the list */
unsigned int count;
+
/*
* Returns -1 if val1 < val2, 0 if equal?, 1 if val1 > val2.
* Used as definition of sorted for listnode_add_sort
*/
int (*cmp) (void *val1, void *val2);
+
+ /* callback to free user-owned data when listnode is deleted. supplying
+ * this callback is very much encouraged!
+ */
void (*del) (void *val);
};
-#define nextnode(X) ((X) = (X)->next)
+#define listnextnode(X) ((X)->next)
#define listhead(X) ((X)->head)
#define listtail(X) ((X)->tail)
#define listcount(X) ((X)->count)
#define list_isempty(X) ((X)->head == NULL && (X)->tail == NULL)
-#define getdata(X) ((X)->data)
+#define listgetdata(X) (assert((X)->data != NULL), (X)->data)
/* Prototypes. */
-struct list *list_new();
+struct list *list_new(); /* encouraged: set list.del callback on new lists */
void list_free (struct list *);
void listnode_add (struct list *, void *);
void list_add_node_next (struct list *, struct listnode *, void *);
void list_add_list (struct list *, struct list *);
-/* List iteration macro. */
-#define LIST_LOOP(L,V,N) \
- for ((N) = (L)->head; (N); (N) = (N)->next) \
- if (((V) = (N)->data) != NULL)
+/* List iteration macro.
+ * Usage: for (ALL_LIST_ELEMENTS (...) { ... }
+ * It is safe to delete the listnode using this macro.
+ */
+#define ALL_LIST_ELEMENTS(list,node,nextnode,data) \
+ (node) = listhead(list); \
+ (node) != NULL && \
+ ((data) = listgetdata(node),(nextnode) = listnextnode(node), 1); \
+ (node) = (nextnode)
+
+/* read-only list iteration macro.
+ * Usage: as per ALL_LIST_ELEMENTS, but not safe to delete the listnode Only
+ * use this macro when it is *immediately obvious* the listnode is not
+ * deleted in the body of the loop. Does not have forward-reference overhead
+ * of previous macro.
+ */
+#define ALL_LIST_ELEMENTS_RO(list,node,data) \
+ (node) = listhead(list); \
+ (node) != NULL && ((data) = listgetdata(node), 1); \
+ (node) = listnextnode(node)
-/* List node add macro. */
-#define LISTNODE_ADD(L,N) \
+/* these *do not* cleanup list nodes and referenced data, as the functions
+ * do - these macros simply {de,at}tach a listnode from/to a list.
+ */
+
+/* List node attach macro. */
+#define LISTNODE_ATTACH(L,N) \
do { \
(N)->prev = (L)->tail; \
if ((L)->head == NULL) \
(L)->count++; \
} while (0)
-/* List node delete macro. */
-#define LISTNODE_DELETE(L,N) \
+/* List node detach macro. */
+#define LISTNODE_DETACH(L,N) \
do { \
if ((N)->prev) \
(N)->prev->next = (N)->next; \
(L)->count--; \
} while (0)
+/* Deprecated: 20050406 */
+#if !defined(QUAGGA_NO_DEPRECATED_INTERFACES)
+#warning "Using deprecated libzebra interfaces"
+#define LISTNODE_ADD(L,N) LISTNODE_ATTACH(L,N)
+#define LISTNODE_DELETE(L,N) LISTNODE_DETACH(L,N)
+#define nextnode(X) ((X) = (X)->next)
+#define getdata(X) listgetdata(X)
+#define LIST_LOOP(L,V,N) \
+ for (ALL_LIST_ELEMENTS_RO (L,N,V))
+#endif /* QUAGGA_NO_DEPRECATED_INTERFACES */
+
#endif /* _ZEBRA_LINKLIST_H */
int result;
u_char *statP = NULL;
WriteMethod *write_method = NULL;
- struct listnode *node;
+ struct listnode *node, *nnode;
/* Check */
- for (node = treelist->head; node; node = node->next)
+ for (ALL_LIST_ELEMENTS (treelist, node, nnode, subtree))
{
- subtree = node->data;
subresult = oid_compare_part (reqid, *reqid_len,
subtree->name, subtree->name_len);
size_t suffix_len;
int result;
WriteMethod *write_method=NULL;
- struct listnode *node;
+ struct listnode *node, *nnode;
/* Check */
- for (node = treelist->head; node; node = node->next)
+ for (ALL_LIST_ELEMENTS (treelist, node, nnode,subtree))
{
- subtree = node->data;
subresult = oid_compare_part (reqid, *reqid_len,
subtree->name, subtree->name_len);
size_t suffix_len;
int result;
WriteMethod *write_method=NULL;
- struct listnode *node;
+ struct listnode *node, *nnode;
/* Save incoming request. */
savelen = *reqid_len;
/* Check */
- for (node = treelist->head; node; node = node->next)
+ for (ALL_LIST_ELEMENTS (treelist, node, nnode, subtree))
{
- subtree = node->data;
subresult = oid_compare_part (reqid, *reqid_len,
subtree->name, subtree->name_len);
long priority;
long operation;
struct subtree *subtree;
- struct listnode *node;
+ struct listnode *node, *nnode;
ret = 0;
- for (node = treelist->head; node; node = node->next)
+ for (ALL_LIST_ELEMENTS (treelist, node, nnode, subtree))
{
ptr = buf;
len = BUFSIZ;
- subtree = node->data;
-
/* SMUX RReq Header. */
ptr = asn_build_header (ptr, &len, (u_char) SMUX_RREQ, 0);
+2005-04-07 Paul Jakma <paul@dishone.st>
+
+ * (global) Fix up list loops to match changes in lib/linklist,
+ and some basic auditing of usage.
+ * ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single
+ scan of the area list, rather than scanning all areas first for
+ INTER_ROUTER and then again for INTER_NETWORK. According to
+ 16.2, the scan should be area specific anyway, and further
+ ospf6d does not seem to implement 16.3 anyway.
+
2005-04-02 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
* ospf6_interface.[ch]: (ospf6_interface_lookup_by_name) Remove unused
struct ospf6_area *oa;
int area_count = 0;
- for (node = listhead (o->area_list); node; nextnode (node))
- {
- oa = OSPF6_AREA (getdata (node));
- if (IS_AREA_ENABLED (oa))
- area_count++;
- }
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, node, oa))
+ if (IS_AREA_ENABLED (oa))
+ area_count++;
if (area_count > 1)
return 1;
{
struct ospf6_area *oa;
struct ospf6_route *ro;
- struct listnode *node;
+ struct listnode *node, *nnode;
- for (node = listhead (area->ospf6->area_list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (area->ospf6->area_list, node, nnode, oa))
{
- oa = OSPF6_AREA (getdata (node));
-
/* update B bit for each area */
OSPF6_ROUTER_LSA_SCHEDULE (oa);
struct ospf6_area *oa;
struct ospf6_route *ro;
struct ospf6_lsa *old;
- struct listnode *node;
+ struct listnode *node, *nnode;
/* Withdraw all summary prefixes previously originated */
for (ro = ospf6_route_head (area->summary_prefix); ro;
}
/* Schedule Router-LSA for each area (ABR status may change) */
- for (node = listhead (area->ospf6->area_list); node; nextnode (node))
- {
- oa = OSPF6_AREA (getdata (node));
-
- /* update B bit for each area */
- OSPF6_ROUTER_LSA_SCHEDULE (oa);
- }
+ for (ALL_LIST_ELEMENTS (area->ospf6->area_list, node, nnode, oa))
+ /* update B bit for each area */
+ OSPF6_ROUTER_LSA_SCHEDULE (oa);
}
/* RFC 2328 12.4.3. Summary-LSAs */
void
ospf6_abr_originate_summary (struct ospf6_route *route)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf6_area *oa;
struct ospf6_route *range = NULL;
ospf6_abr_range_update (range);
}
- for (node = listhead (ospf6->area_list); node; nextnode (node))
- {
- oa = (struct ospf6_area *) getdata (node);
- ospf6_abr_originate_summary_to_area (route, oa);
- }
+ for (ALL_LIST_ELEMENTS (ospf6->area_list, node, nnode, oa))
+ ospf6_abr_originate_summary_to_area (route, oa);
}
/* RFC 2328 16.2. Calculating the inter-area routes */
{
struct ospf6_lsa *lsa;
struct ospf6_area *oa;
- struct listnode *node;
+ struct listnode *node, *nnode;
u_int16_t type;
- type = htons (OSPF6_LSTYPE_INTER_ROUTER);
- for (node = listhead (ospf6->area_list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (ospf6->area_list, node, nnode, oa))
{
- oa = OSPF6_AREA (getdata (node));
+ type = htons (OSPF6_LSTYPE_INTER_ROUTER);
for (lsa = ospf6_lsdb_type_router_head (type, router_id, oa->lsdb); lsa;
lsa = ospf6_lsdb_type_router_next (type, router_id, lsa))
ospf6_abr_examin_summary (lsa, oa);
- }
- type = htons (OSPF6_LSTYPE_INTER_PREFIX);
- for (node = listhead (ospf6->area_list); node; nextnode (node))
- {
- oa = OSPF6_AREA (getdata (node));
+ type = htons (OSPF6_LSTYPE_INTER_PREFIX);
for (lsa = ospf6_lsdb_type_router_head (type, router_id, oa->lsdb); lsa;
lsa = ospf6_lsdb_type_router_next (type, router_id, lsa))
ospf6_abr_examin_summary (lsa, oa);
void
ospf6_area_delete (struct ospf6_area *oa)
{
- struct listnode *n;
+ struct listnode *n, *nnode;
struct ospf6_interface *oi;
ospf6_route_table_delete (oa->range_table);
ospf6_route_table_delete (oa->summary_router);
/* ospf6 interface list */
- for (n = listhead (oa->if_list); n; nextnode (n))
+ for (ALL_LIST_ELEMENTS (oa->if_list, n, nnode, oi))
{
- oi = (struct ospf6_interface *) getdata (n);
ospf6_interface_delete (oi);
}
list_delete (oa->if_list);
struct ospf6_area *oa;
struct listnode *n;
- for (n = listhead (ospf6->area_list); n; nextnode (n))
- {
- oa = (struct ospf6_area *) getdata (n);
- if (oa->area_id == area_id)
- return oa;
- }
+ for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, n, oa))
+ if (oa->area_id == area_id)
+ return oa;
return (struct ospf6_area *) NULL;
}
void
ospf6_area_enable (struct ospf6_area *oa)
{
- struct listnode *i;
+ struct listnode *node, *nnode;
struct ospf6_interface *oi;
SET_FLAG (oa->flag, OSPF6_AREA_ENABLE);
- for (i = listhead (oa->if_list); i; nextnode (i))
- {
- oi = (struct ospf6_interface *) getdata (i);
- ospf6_interface_enable (oi);
- }
+ for (ALL_LIST_ELEMENTS (oa->if_list, node, nnode, oi))
+ ospf6_interface_enable (oi);
}
void
ospf6_area_disable (struct ospf6_area *oa)
{
- struct listnode *i;
+ struct listnode *node, *nnode;
struct ospf6_interface *oi;
UNSET_FLAG (oa->flag, OSPF6_AREA_ENABLE);
- for (i = listhead (oa->if_list); i; nextnode (i))
- {
- oi = (struct ospf6_interface *) getdata (i);
- ospf6_interface_disable (oi);
- }
+ for (ALL_LIST_ELEMENTS (oa->if_list, node, nnode, oi))
+ ospf6_interface_disable (oi);
}
\f
oa->lsdb->count, VNL);
vty_out (vty, " Interface attached to this area:");
- for (i = listhead (oa->if_list); i; nextnode (i))
- {
- oi = (struct ospf6_interface *) getdata (i);
- vty_out (vty, " %s", oi->interface->name);
- }
+ for (ALL_LIST_ELEMENTS_RO (oa->if_list, i, oi))
+ vty_out (vty, " %s", oi->interface->name);
+
vty_out (vty, "%s", VNL);
}
struct ospf6_route *range;
char buf[128];
- for (node = listhead (ospf6->area_list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa))
{
- oa = OSPF6_AREA (getdata (node));
-
for (range = ospf6_route_head (oa->range_table); range;
range = ospf6_route_next (range))
{
struct prefix prefix;
ospf6_linkstate_prefix (ospf6->router_id, htonl (0), &prefix);
- for (node = listhead (ospf6->area_list); node; nextnode (node))
+
+ for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa))
{
- oa = (struct ospf6_area *) getdata (node);
route = ospf6_route_lookup (&prefix, oa->spf_table);
if (route == NULL)
{
struct prefix prefix_id;
struct route_node *node;
char pbuf[64], ibuf[16];
- struct listnode *lnode;
+ struct listnode *lnode, *lnnode;
struct ospf6_area *oa;
if (! ospf6_zebra_is_redistribute (type))
ospf6_as_external_lsa_originate (route);
/* Router-Bit (ASBR Flag) may have to be updated */
- for (lnode = listhead (ospf6->area_list); lnode; nextnode (lnode))
- {
- oa = (struct ospf6_area *) getdata (lnode);
- OSPF6_ROUTER_LSA_SCHEDULE (oa);
- }
+ for (ALL_LIST_ELEMENTS (ospf6->area_list, lnode, lnnode, oa))
+ OSPF6_ROUTER_LSA_SCHEDULE (oa);
}
void
struct ospf6_lsa *lsa;
struct prefix prefix_id;
char pbuf[64], ibuf[16];
- struct listnode *lnode;
+ struct listnode *lnode, *lnnode;
struct ospf6_area *oa;
match = ospf6_route_lookup (prefix, ospf6->external_table);
XFREE (MTYPE_OSPF6_EXTERNAL_INFO, info);
/* Router-Bit (ASBR Flag) may have to be updated */
- for (lnode = listhead (ospf6->area_list); lnode; nextnode (lnode))
- {
- oa = (struct ospf6_area *) getdata (lnode);
- OSPF6_ROUTER_LSA_SCHEDULE (oa);
- }
+ for (ALL_LIST_ELEMENTS (ospf6->area_list, lnode, lnnode, oa))
+ OSPF6_ROUTER_LSA_SCHEDULE (oa);
}
DEFUN (ospf6_redistribute,
ospf6_flood_interface (struct ospf6_neighbor *from,
struct ospf6_lsa *lsa, struct ospf6_interface *oi)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf6_neighbor *on;
struct ospf6_lsa *req;
int retrans_added = 0;
}
/* (1) For each neighbor */
- for (node = listhead (oi->neighbor_list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
{
- on = (struct ospf6_neighbor *) getdata (node);
-
if (is_debug)
zlog_debug ("To neighbor %s", on->name);
else
{
/* reschedule retransmissions to all neighbors */
- for (node = listhead (oi->neighbor_list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
{
- on = (struct ospf6_neighbor *) getdata (node);
THREAD_OFF (on->thread_send_lsupdate);
on->thread_send_lsupdate =
thread_add_event (master, ospf6_lsupdate_send_neighbor, on, 0);
ospf6_flood_area (struct ospf6_neighbor *from,
struct ospf6_lsa *lsa, struct ospf6_area *oa)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf6_interface *oi;
- for (node = listhead (oa->if_list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (oa->if_list, node, nnode, oi))
{
- oi = OSPF6_INTERFACE (getdata (node));
-
if (OSPF6_LSA_SCOPE (lsa->header->type) == OSPF6_SCOPE_LINKLOCAL &&
oi != OSPF6_INTERFACE (lsa->lsdb->data))
continue;
ospf6_flood_process (struct ospf6_neighbor *from,
struct ospf6_lsa *lsa, struct ospf6 *process)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf6_area *oa;
- for (node = listhead (process->area_list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (process->area_list, node, nnode, oa))
{
- oa = OSPF6_AREA (getdata (node));
-
if (OSPF6_LSA_SCOPE (lsa->header->type) == OSPF6_SCOPE_AREA &&
oa != OSPF6_AREA (lsa->lsdb->data))
continue;
void
ospf6_flood_clear_interface (struct ospf6_lsa *lsa, struct ospf6_interface *oi)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf6_neighbor *on;
struct ospf6_lsa *rem;
- for (node = listhead (oi->neighbor_list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
{
- on = OSPF6_NEIGHBOR (getdata (node));
rem = ospf6_lsdb_lookup (lsa->header->type, lsa->header->id,
lsa->header->adv_router, on->retrans_list);
if (rem && ! ospf6_lsa_compare (rem, lsa))
void
ospf6_flood_clear_area (struct ospf6_lsa *lsa, struct ospf6_area *oa)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf6_interface *oi;
- for (node = listhead (oa->if_list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (oa->if_list, node, nnode, oi))
{
- oi = OSPF6_INTERFACE (getdata (node));
-
if (OSPF6_LSA_SCOPE (lsa->header->type) == OSPF6_SCOPE_LINKLOCAL &&
oi != OSPF6_INTERFACE (lsa->lsdb->data))
continue;
void
ospf6_flood_clear_process (struct ospf6_lsa *lsa, struct ospf6 *process)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf6_area *oa;
- for (node = listhead (process->area_list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (process->area_list, node, nnode, oa))
{
- oa = OSPF6_AREA (getdata (node));
-
if (OSPF6_LSA_SCOPE (lsa->header->type) == OSPF6_SCOPE_AREA &&
oa != OSPF6_AREA (lsa->lsdb->data))
continue;
return 0;
process = from->ospf6_if->area->ospf6;
- for (i = listhead (process->area_list); i; nextnode (i))
- {
- oa = OSPF6_AREA (getdata (i));
- for (j = listhead (oa->if_list); j; nextnode (j))
- {
- oi = OSPF6_INTERFACE (getdata (j));
- for (k = listhead (oi->neighbor_list); k; nextnode (k))
- {
- on = OSPF6_NEIGHBOR (getdata (k));
- if (on->state == OSPF6_NEIGHBOR_EXCHANGE ||
- on->state == OSPF6_NEIGHBOR_LOADING)
- count++;
- }
- }
- }
+
+ for (ALL_LIST_ELEMENTS_RO (process->area_list, i, oa))
+ for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
+ for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, k, on))
+ if (on->state == OSPF6_NEIGHBOR_EXCHANGE ||
+ on->state == OSPF6_NEIGHBOR_LOADING)
+ count++;
if (count == 0)
return 1;
void
ospf6_interface_delete (struct ospf6_interface *oi)
{
- struct listnode *n;
+ struct listnode *node, *nnode;
struct ospf6_neighbor *on;
- for (n = listhead (oi->neighbor_list); n; nextnode (n))
- {
- on = (struct ospf6_neighbor *) getdata (n);
+ for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
ospf6_neighbor_delete (on);
- }
+
list_delete (oi->neighbor_list);
THREAD_OFF (oi->thread_send_hello);
void
ospf6_interface_disable (struct ospf6_interface *oi)
{
- struct listnode *i;
+ struct listnode *node, *nnode;
struct ospf6_neighbor *on;
SET_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE);
- for (i = listhead (oi->neighbor_list); i; nextnode (i))
- {
- on = (struct ospf6_neighbor *) getdata (i);
+ for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
ospf6_neighbor_delete (on);
- }
+
list_delete_all_node (oi->neighbor_list);
ospf6_lsdb_remove_all (oi->lsdb);
struct in6_addr *l = (struct in6_addr *) NULL;
/* for each connected address */
- for (n = listhead (ifp->connected); n; nextnode (n))
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, n, c))
{
- c = (struct connected *) getdata (n);
-
/* if family not AF_INET6, ignore */
if (c->address->family != AF_INET6)
continue;
struct ospf6_interface *oi;
struct ospf6_route *route;
struct connected *c;
- struct listnode *i;
+ struct listnode *node, *nnode;
oi = (struct ospf6_interface *) ifp->info;
if (oi == NULL)
/* update "route to advertise" interface route table */
ospf6_route_remove_all (oi->route_connected);
- for (i = listhead (oi->interface->connected); i; nextnode (i))
- {
- c = (struct connected *) getdata (i);
+ for (ALL_LIST_ELEMENTS (oi->interface->connected, node, nnode, c))
+ {
if (c->address->family != AF_INET6)
continue;
static u_char
dr_election (struct ospf6_interface *oi)
{
- struct listnode *i;
+ struct listnode *node, *nnode;
struct ospf6_neighbor *on, *drouter, *bdrouter, myself;
struct ospf6_neighbor *best_drouter, *best_bdrouter;
u_char next_state = 0;
myself.router_id = oi->area->ospf6->router_id;
/* Electing BDR (2) */
- for (i = listhead (oi->neighbor_list); i; nextnode (i))
- {
- on = (struct ospf6_neighbor *) getdata (i);
- bdrouter = better_bdrouter (bdrouter, on);
- }
+ for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
+ bdrouter = better_bdrouter (bdrouter, on);
+
best_bdrouter = bdrouter;
bdrouter = better_bdrouter (best_bdrouter, &myself);
/* Electing DR (3) */
- for (i = listhead (oi->neighbor_list); i; nextnode (i))
- {
- on = (struct ospf6_neighbor *) getdata (i);
- drouter = better_drouter (drouter, on);
- }
+ for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
+ drouter = better_drouter (drouter, on);
+
best_drouter = drouter;
drouter = better_drouter (best_drouter, &myself);
if (drouter == NULL)
(drouter ? drouter->name : "0.0.0.0"),
(bdrouter ? bdrouter->name : "0.0.0.0"));
- for (i = listhead (oi->neighbor_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, node, on))
{
- on = (struct ospf6_neighbor *) getdata (i);
if (on->state < OSPF6_NEIGHBOR_TWOWAY)
continue;
/* Schedule AdjOK. */
interface_down (struct thread *thread)
{
struct ospf6_interface *oi;
- struct listnode *n;
+ struct listnode *node, *nnode;
struct ospf6_neighbor *on;
oi = (struct ospf6_interface *) THREAD_ARG (thread);
ospf6_interface_state_change (OSPF6_INTERFACE_DOWN, oi);
- for (n = listhead (oi->neighbor_list); n; nextnode (n))
- {
- on = (struct ospf6_neighbor *) getdata (n);
- ospf6_neighbor_delete (on);
- }
+ for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
+ ospf6_neighbor_delete (on);
+
list_delete_all_node (oi->neighbor_list);
return 0;
oi = (struct ospf6_interface *) ifp->info;
vty_out (vty, " Internet Address:%s", VNL);
- for (i = listhead (ifp->connected); i; nextnode (i))
+
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, i, c))
{
- c = (struct connected *)getdata (i);
p = c->address;
prefix2str (p, strbuf, sizeof (strbuf));
switch (p->family)
}
else
{
- for (i = listhead (iflist); i; nextnode (i))
- {
- ifp = (struct interface *) getdata (i);
- ospf6_interface_show (vty, ifp);
- }
+ for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
+ ospf6_interface_show (vty, ifp);
}
return CMD_SUCCESS;
struct ospf6_interface *oi;
struct interface *ifp;
- for (i = listhead (iflist); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
{
- ifp = (struct interface *) getdata (i);
oi = (struct ospf6_interface *) ifp->info;
if (oi == NULL)
continue;
struct ospf6_interface *oi;
struct interface *ifp;
unsigned int ifmtu, iobuflen;
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf6_neighbor *on;
ifp = (struct interface *) vty->index;
oi->ifmtu = ifmtu;
/* re-establish adjacencies */
- for (node = listhead (oi->neighbor_list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
{
- on = (struct ospf6_neighbor *) getdata (node);
THREAD_OFF (on->inactivity_timer);
thread_execute (master, inactivity_timer, on, 0);
}
struct ospf6_interface *oi;
struct interface *ifp;
unsigned int iobuflen;
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf6_neighbor *on;
ifp = (struct interface *) vty->index;
oi->ifmtu = ifp->mtu;
/* re-establish adjacencies */
- for (node = listhead (oi->neighbor_list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
{
- on = (struct ospf6_neighbor *) getdata (node);
THREAD_OFF (on->inactivity_timer);
thread_execute (master, inactivity_timer, on, 0);
}
{
struct ospf6_interface *oi;
struct interface *ifp;
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf6_neighbor *on;
ifp = (struct interface *) vty->index;
SET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE);
THREAD_OFF (oi->thread_send_hello);
- for (node = listhead (oi->neighbor_list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
{
- on = (struct ospf6_neighbor *) getdata (node);
THREAD_OFF (on->inactivity_timer);
thread_execute (master, inactivity_timer, on, 0);
}
struct ospf6_interface *oi;
struct interface *ifp;
- for (i = listhead (iflist); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
{
- ifp = (struct interface *) getdata (i);
oi = (struct ospf6_interface *) ifp->info;
if (oi == NULL)
continue;
struct ospf6_lsa *lsa;
u_int32_t link_state_id = 0;
- struct listnode *i, *j;
+ struct listnode *node, *nnode;
+ struct listnode *j;
struct ospf6_interface *oi;
struct ospf6_neighbor *on, *drouter = NULL;
struct ospf6_router_lsa *router_lsa;
lsdesc = (struct ospf6_router_lsdesc *)
((caddr_t) router_lsa + sizeof (struct ospf6_router_lsa));
- for (i = listhead (oa->if_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS (oa->if_list, node, nnode, oi))
{
- oi = (struct ospf6_interface *) getdata (i);
-
/* Interfaces in state Down or Loopback are not described */
if (oi->state == OSPF6_INTERFACE_DOWN ||
oi->state == OSPF6_INTERFACE_LOOPBACK)
/* Nor are interfaces without any full adjacencies described */
count = 0;
- for (j = listhead (oi->neighbor_list); j; nextnode (j))
- {
- on = (struct ospf6_neighbor *) getdata (j);
- if (on->state == OSPF6_NEIGHBOR_FULL)
- count++;
- }
+ for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, j, on))
+ if (on->state == OSPF6_NEIGHBOR_FULL)
+ count++;
+
if (count == 0)
continue;
/* Point-to-Point interfaces */
if (if_is_pointopoint (oi->interface))
{
- for (j = listhead (oi->neighbor_list); j; nextnode (j))
+ for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, j, on))
{
- on = (struct ospf6_neighbor *) getdata (j);
if (on->state != OSPF6_NEIGHBOR_FULL)
continue;
/* If none of neighbor is adjacent to us */
count = 0;
- for (i = listhead (oi->neighbor_list); i; nextnode (i))
- {
- on = (struct ospf6_neighbor *) getdata (i);
- if (on->state == OSPF6_NEIGHBOR_FULL)
- count++;
- }
+
+ for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, i, on))
+ if (on->state == OSPF6_NEIGHBOR_FULL)
+ count++;
+
if (count == 0)
{
if (IS_OSPF6_DEBUG_ORIGINATE (NETWORK))
lsdesc++;
/* Walk through the neighbors */
- for (i = listhead (oi->neighbor_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, i, on))
{
- on = (struct ospf6_neighbor *) getdata (i);
-
if (on->state != OSPF6_NEIGHBOR_FULL)
continue;
route_advertise = ospf6_route_table_create ();
- for (i = listhead (oa->if_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (oa->if_list, i, oi))
{
- oi = (struct ospf6_interface *) getdata (i);
-
if (oi->state == OSPF6_INTERFACE_DOWN)
{
if (IS_OSPF6_DEBUG_ORIGINATE (INTRA_PREFIX))
}
full_count = 0;
- for (j = listhead (oi->neighbor_list); j; nextnode (j))
- {
- on = (struct ospf6_neighbor *) getdata (j);
- if (on->state == OSPF6_NEIGHBOR_FULL)
- full_count++;
- }
+
+ for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, j, on))
+ if (on->state == OSPF6_NEIGHBOR_FULL)
+ full_count++;
+
if (oi->state != OSPF6_INTERFACE_LOOPBACK &&
oi->state != OSPF6_INTERFACE_POINTTOPOINT &&
full_count != 0)
}
full_count = 0;
- for (i = listhead (oi->neighbor_list); i; nextnode (i))
- {
- on = (struct ospf6_neighbor *) getdata (i);
- if (on->state == OSPF6_NEIGHBOR_FULL)
- full_count++;
- }
+ for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, i, on))
+ if (on->state == OSPF6_NEIGHBOR_FULL)
+ full_count++;
+
if (full_count == 0)
{
if (IS_OSPF6_DEBUG_ORIGINATE (INTRA_PREFIX))
struct ospf6_header *oh;
struct ospf6_hello *hello;
u_char *p;
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf6_neighbor *on;
oi = (struct ospf6_interface *) THREAD_ARG (thread);
p = (char *)((caddr_t) hello + sizeof (struct ospf6_hello));
- for (node = listhead (oi->neighbor_list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
{
- on = (struct ospf6_neighbor *) getdata (node);
-
if (on->state < OSPF6_NEIGHBOR_INIT)
continue;
struct listnode *n;
struct ospf6_neighbor *on;
- for (n = listhead (oi->neighbor_list); n; nextnode (n))
- {
- on = (struct ospf6_neighbor *) getdata (n);
- if (on->router_id == router_id)
- return on;
- }
+ for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, n, on))
+ if (on->router_id == router_id)
+ return on;
+
return (struct ospf6_neighbor *) NULL;
}
"RouterID", "State", "Duration", "DR", "BDR", "I/F",
"State", VNL);
- for (i = listhead (ospf6->area_list); i; nextnode (i))
- {
- oa = (struct ospf6_area *) getdata (i);
- for (j = listhead (oa->if_list); j; nextnode (j))
- {
- oi = (struct ospf6_interface *) getdata (j);
- for (k = listhead (oi->neighbor_list); k; nextnode (k))
- {
- on = (struct ospf6_neighbor *) getdata (k);
- (*showfunc) (vty, on);
- }
- }
- }
+ for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, i, oa))
+ for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
+ for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, k, on))
+ (*showfunc) (vty, on);
+
return CMD_SUCCESS;
}
return CMD_SUCCESS;
}
- for (i = listhead (ospf6->area_list); i; nextnode (i))
- {
- oa = (struct ospf6_area *) getdata (i);
- for (j = listhead (oa->if_list); j; nextnode (j))
- {
- oi = (struct ospf6_interface *) getdata (j);
- for (k = listhead (oi->neighbor_list); k; nextnode (k))
- {
- on = (struct ospf6_neighbor *) getdata (k);
- if (on->router_id == router_id)
- (*showfunc) (vty, on);
- }
- }
- }
+ for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, i, oa))
+ for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
+ for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, k, on))
+ (*showfunc) (vty, on);
+
return CMD_SUCCESS;
}
inet_ntoa (* (struct in_addr *) &area_id),
exact, len, *length);
- for (node = listhead (ospf6->area_list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa))
{
- oa = (struct ospf6_area *) getdata (node);
if (area == NULL)
{
if (len == 0) /* return first area entry */
}
else
{
- for (node = listhead (ospf6->area_list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa))
{
- oa = (struct ospf6_area *) getdata (node);
-
if (lsa)
continue;
if (ntohl (oa->area_id) < ntohl (area_id.s_addr))
struct ospf6_route *route;
int i, j;
struct ospf6_vertex *prev, *w;
- struct listnode *node;
+ struct listnode *node, *nnode;
if (IS_OSPF6_DEBUG_SPF (PROCESS))
zlog_debug ("SPF install %s hops %d cost %d",
prev = (struct ospf6_vertex *) route->route_option;
if (prev->hops > v->hops)
{
- LIST_LOOP (prev->child_list, w, node)
+ for (ALL_LIST_ELEMENTS (prev->child_list, node, nnode, w))
{
assert (w->parent == prev);
w->parent = v;
snprintf (p, end - p, " Area %s: %d", oa->name, oa->lsdb->count);
p = (buffer + strlen (buffer) < end ? buffer + strlen (buffer) : end);
- for (node = listhead (oa->if_list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (oa->if_list, node, oi))
{
- oi = (struct ospf6_interface *) getdata (node);
snprintf (p, end - p, " I/F %s: %d",
oi->interface->name, oi->lsdb->count);
p = (buffer + strlen (buffer) < end ? buffer + strlen (buffer) : end);
ospf6_spf_display_subtree (struct vty *vty, const char *prefix, int rest,
struct ospf6_vertex *v)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf6_vertex *c;
char *next_prefix;
int len;
snprintf (next_prefix, len, "%s%s", prefix, (rest ? "| " : " "));
restnum = listcount (v->child_list);
- LIST_LOOP (v->child_list, c, node)
+ for (ALL_LIST_ELEMENTS (v->child_list, node, nnode, c))
{
restnum--;
ospf6_spf_display_subtree (vty, next_prefix, restnum, c);
void
ospf6_delete (struct ospf6 *o)
{
- struct listnode *i;
+ struct listnode *node, *nnode;
struct ospf6_area *oa;
- for (i = listhead (o->area_list); i; nextnode (i))
- {
- oa = (struct ospf6_area *) getdata (i);
- ospf6_area_delete (oa);
- }
+ for (ALL_LIST_ELEMENTS (o->area_list, node, nnode, oa))
+ ospf6_area_delete (oa);
ospf6_lsdb_delete (o->lsdb);
ospf6_lsdb_delete (o->lsdb_self);
void
ospf6_enable (struct ospf6 *o)
{
- struct listnode *i;
+ struct listnode *node, *nnode;
struct ospf6_area *oa;
if (CHECK_FLAG (o->flag, OSPF6_DISABLED))
{
UNSET_FLAG (o->flag, OSPF6_DISABLED);
- for (i = listhead (o->area_list); i; nextnode (i))
- {
- oa = (struct ospf6_area *) getdata (i);
- ospf6_area_enable (oa);
- }
+ for (ALL_LIST_ELEMENTS (o->area_list, node, nnode, oa))
+ ospf6_area_enable (oa);
}
}
void
ospf6_disable (struct ospf6 *o)
{
- struct listnode *i;
+ struct listnode *node, *nnode;
struct ospf6_area *oa;
if (! CHECK_FLAG (o->flag, OSPF6_DISABLED))
{
SET_FLAG (o->flag, OSPF6_DISABLED);
- for (i = listhead (o->area_list); i; nextnode (i))
- {
- oa = (struct ospf6_area *) getdata (i);
- ospf6_area_disable (oa);
- }
+
+ for (ALL_LIST_ELEMENTS (o->area_list, node, nnode, oa))
+ ospf6_area_disable (oa);
ospf6_lsdb_remove_all (o->lsdb);
ospf6_route_remove_all (o->route_table);
o->maxage_remover = (struct thread *) NULL;
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
- for (j = listhead (oa->if_list); j; nextnode (j))
+ for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
{
- oi = (struct ospf6_interface *) getdata (j);
- for (k = listhead (oi->neighbor_list); k; nextnode (k))
+ for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, k, on))
{
- on = (struct ospf6_neighbor *) getdata (k);
if (on->state != OSPF6_NEIGHBOR_EXCHANGE &&
on->state != OSPF6_NEIGHBOR_LOADING)
continue;
}
}
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
- for (j = listhead (oa->if_list); j; nextnode (j))
- {
- oi = (struct ospf6_interface *) getdata (j);
- OSPF6_LSDB_MAXAGE_REMOVER (oi->lsdb);
- }
+ for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
+ OSPF6_LSDB_MAXAGE_REMOVER (oi->lsdb);
+
OSPF6_LSDB_MAXAGE_REMOVER (oa->lsdb);
}
OSPF6_LSDB_MAXAGE_REMOVER (o->lsdb);
/* Areas */
vty_out (vty, " Number of areas in this router is %u%s",
listcount (o->area_list), VNL);
- for (n = listhead (o->area_list); n; nextnode (n))
- {
- oa = (struct ospf6_area *) getdata (n);
- ospf6_area_show (vty, oa);
- }
+
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, n, oa))
+ ospf6_area_show (vty, oa);
}
/* show top level structures */
ospf6_redistribute_config_write (vty);
ospf6_area_config_write (vty);
- for (j = listhead (ospf6->area_list); j; nextnode (j))
+ for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, j, oa))
{
- oa = (struct ospf6_area *) getdata (j);
- for (k = listhead (oa->if_list); k; nextnode (k))
- {
- oi = (struct ospf6_interface *) getdata (k);
- vty_out (vty, " interface %s area %s%s",
- oi->interface->name, oa->name, VNL);
- }
+ for (ALL_LIST_ELEMENTS_RO (oa->if_list, k, oi))
+ vty_out (vty, " interface %s area %s%s",
+ oi->interface->name, oa->name, VNL);
}
vty_out (vty, "!%s", VNL);
return 0;
level = parse_show_level (argc, argv);
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
vty_out (vty, AREA_LSDB_TITLE_FORMAT, VNL, oa->name, VNL, VNL);
ospf6_lsdb_show (vty, level, NULL, NULL, NULL, oa->lsdb);
}
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
- for (j = listhead (oa->if_list); j; nextnode (j))
+ for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
{
- oi = (struct ospf6_interface *) getdata (j);
vty_out (vty, IF_LSDB_TITLE_FORMAT, VNL,
oi->interface->name, oa->name, VNL, VNL);
ospf6_lsdb_show (vty, level, NULL, NULL, NULL, oi->lsdb);
switch (OSPF6_LSA_SCOPE (type))
{
case OSPF6_SCOPE_AREA:
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
vty_out (vty, AREA_LSDB_TITLE_FORMAT, VNL, oa->name, VNL, VNL);
ospf6_lsdb_show (vty, level, &type, NULL, NULL, oa->lsdb);
}
break;
case OSPF6_SCOPE_LINKLOCAL:
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
- for (j = listhead (oa->if_list); j; nextnode (j))
+ for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
{
- oi = (struct ospf6_interface *) getdata (j);
vty_out (vty, IF_LSDB_TITLE_FORMAT, VNL,
oi->interface->name, oa->name, VNL, VNL);
ospf6_lsdb_show (vty, level, &type, NULL, NULL, oi->lsdb);
argv++;
level = parse_show_level (argc, argv);
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
vty_out (vty, AREA_LSDB_TITLE_FORMAT, VNL, oa->name, VNL, VNL);
ospf6_lsdb_show (vty, level, NULL, &id, NULL, oa->lsdb);
}
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
- for (j = listhead (oa->if_list); j; nextnode (j))
+ for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
{
- oi = (struct ospf6_interface *) getdata (j);
vty_out (vty, IF_LSDB_TITLE_FORMAT, VNL,
oi->interface->name, oa->name, VNL, VNL);
ospf6_lsdb_show (vty, level, NULL, &id, NULL, oi->lsdb);
argv++;
level = parse_show_level (argc, argv);
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
vty_out (vty, AREA_LSDB_TITLE_FORMAT, VNL, oa->name, VNL, VNL);
ospf6_lsdb_show (vty, level, NULL, NULL, &adv_router, oa->lsdb);
}
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
- for (j = listhead (oa->if_list); j; nextnode (j))
+ for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
{
- oi = (struct ospf6_interface *) getdata (j);
vty_out (vty, IF_LSDB_TITLE_FORMAT, VNL,
oi->interface->name, oa->name, VNL, VNL);
ospf6_lsdb_show (vty, level, NULL, NULL, &adv_router, oi->lsdb);
switch (OSPF6_LSA_SCOPE (type))
{
case OSPF6_SCOPE_AREA:
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
vty_out (vty, AREA_LSDB_TITLE_FORMAT, VNL, oa->name, VNL, VNL);
ospf6_lsdb_show (vty, level, &type, &id, NULL, oa->lsdb);
}
break;
case OSPF6_SCOPE_LINKLOCAL:
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
- for (j = listhead (oa->if_list); j; nextnode (j))
+ for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
{
- oi = (struct ospf6_interface *) getdata (j);
vty_out (vty, IF_LSDB_TITLE_FORMAT, VNL,
oi->interface->name, oa->name, VNL, VNL);
ospf6_lsdb_show (vty, level, &type, &id, NULL, oi->lsdb);
switch (OSPF6_LSA_SCOPE (type))
{
case OSPF6_SCOPE_AREA:
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
vty_out (vty, AREA_LSDB_TITLE_FORMAT, VNL, oa->name, VNL, VNL);
ospf6_lsdb_show (vty, level, &type, NULL, &adv_router, oa->lsdb);
}
break;
case OSPF6_SCOPE_LINKLOCAL:
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
- for (j = listhead (oa->if_list); j; nextnode (j))
+ for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
{
- oi = (struct ospf6_interface *) getdata (j);
vty_out (vty, IF_LSDB_TITLE_FORMAT, VNL,
oi->interface->name, oa->name, VNL, VNL);
ospf6_lsdb_show (vty, level, &type, NULL, &adv_router, oi->lsdb);
argv++;
level = parse_show_level (argc, argv);
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
vty_out (vty, AREA_LSDB_TITLE_FORMAT, VNL, oa->name, VNL, VNL);
ospf6_lsdb_show (vty, level, NULL, &id, &adv_router, oa->lsdb);
}
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
- for (j = listhead (oa->if_list); j; nextnode (j))
+ for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
{
- oi = (struct ospf6_interface *) getdata (j);
vty_out (vty, IF_LSDB_TITLE_FORMAT, VNL,
oi->interface->name, oa->name, VNL, VNL);
ospf6_lsdb_show (vty, level, NULL, &id, &adv_router, oi->lsdb);
argv++;
level = parse_show_level (argc, argv);
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
vty_out (vty, AREA_LSDB_TITLE_FORMAT, VNL, oa->name, VNL, VNL);
ospf6_lsdb_show (vty, level, NULL, &id, &adv_router, oa->lsdb);
}
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
- for (j = listhead (oa->if_list); j; nextnode (j))
+ for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
{
- oi = (struct ospf6_interface *) getdata (j);
vty_out (vty, IF_LSDB_TITLE_FORMAT, VNL,
oi->interface->name, oa->name, VNL, VNL);
ospf6_lsdb_show (vty, level, NULL, &id, &adv_router, oi->lsdb);
switch (OSPF6_LSA_SCOPE (type))
{
case OSPF6_SCOPE_AREA:
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
vty_out (vty, AREA_LSDB_TITLE_FORMAT, VNL, oa->name, VNL, VNL);
ospf6_lsdb_show (vty, level, &type, &id, &adv_router, oa->lsdb);
}
break;
case OSPF6_SCOPE_LINKLOCAL:
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
- for (j = listhead (oa->if_list); j; nextnode (j))
+ for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
{
- oi = (struct ospf6_interface *) getdata (j);
vty_out (vty, IF_LSDB_TITLE_FORMAT, VNL,
oi->interface->name, oa->name, VNL, VNL);
ospf6_lsdb_show (vty, level, &type, &id, &adv_router, oi->lsdb);
switch (OSPF6_LSA_SCOPE (type))
{
case OSPF6_SCOPE_AREA:
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
vty_out (vty, AREA_LSDB_TITLE_FORMAT, VNL, oa->name, VNL, VNL);
ospf6_lsdb_show (vty, level, &type, &id, &adv_router, oa->lsdb);
}
break;
case OSPF6_SCOPE_LINKLOCAL:
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
- for (j = listhead (oa->if_list); j; nextnode (j))
+ for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
{
- oi = (struct ospf6_interface *) getdata (j);
vty_out (vty, IF_LSDB_TITLE_FORMAT, VNL,
oi->interface->name, oa->name, VNL, VNL);
ospf6_lsdb_show (vty, level, &type, &id, &adv_router, oi->lsdb);
adv_router = o->router_id;
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
vty_out (vty, AREA_LSDB_TITLE_FORMAT, VNL, oa->name, VNL, VNL);
ospf6_lsdb_show (vty, level, NULL, NULL, &adv_router, oa->lsdb);
}
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
- for (j = listhead (oa->if_list); j; nextnode (j))
+ for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
{
- oi = (struct ospf6_interface *) getdata (j);
vty_out (vty, IF_LSDB_TITLE_FORMAT, VNL,
oi->interface->name, oa->name, VNL, VNL);
ospf6_lsdb_show (vty, level, NULL, NULL, &adv_router, oi->lsdb);
switch (OSPF6_LSA_SCOPE (type))
{
case OSPF6_SCOPE_AREA:
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
vty_out (vty, AREA_LSDB_TITLE_FORMAT, VNL, oa->name, VNL, VNL);
ospf6_lsdb_show (vty, level, &type, NULL, &adv_router, oa->lsdb);
}
break;
case OSPF6_SCOPE_LINKLOCAL:
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
- for (j = listhead (oa->if_list); j; nextnode (j))
+ for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
{
- oi = (struct ospf6_interface *) getdata (j);
vty_out (vty, IF_LSDB_TITLE_FORMAT, VNL,
oi->interface->name, oa->name, VNL, VNL);
ospf6_lsdb_show (vty, level, &type, NULL, &adv_router, oi->lsdb);
switch (OSPF6_LSA_SCOPE (type))
{
case OSPF6_SCOPE_AREA:
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
vty_out (vty, AREA_LSDB_TITLE_FORMAT, VNL, oa->name, VNL, VNL);
ospf6_lsdb_show (vty, level, &type, &id, &adv_router, oa->lsdb);
}
break;
case OSPF6_SCOPE_LINKLOCAL:
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
- for (j = listhead (oa->if_list); j; nextnode (j))
+ for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
{
- oi = (struct ospf6_interface *) getdata (j);
vty_out (vty, IF_LSDB_TITLE_FORMAT, VNL,
oi->interface->name, oa->name, VNL, VNL);
ospf6_lsdb_show (vty, level, &type, &id, &adv_router, oi->lsdb);
switch (OSPF6_LSA_SCOPE (type))
{
case OSPF6_SCOPE_AREA:
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
vty_out (vty, AREA_LSDB_TITLE_FORMAT, VNL, oa->name, VNL, VNL);
ospf6_lsdb_show (vty, level, &type, &id, &adv_router, oa->lsdb);
}
break;
case OSPF6_SCOPE_LINKLOCAL:
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
- for (j = listhead (oa->if_list); j; nextnode (j))
+ for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
{
- oi = (struct ospf6_interface *) getdata (j);
vty_out (vty, IF_LSDB_TITLE_FORMAT, VNL,
oi->interface->name, oa->name, VNL, VNL);
ospf6_lsdb_show (vty, level, &type, &id, &adv_router, oi->lsdb);
struct listnode *node;
struct ospf6_area *oa;
- for (node = listhead (ospf6->area_list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa))
{
- oa = OSPF6_AREA (getdata (node));
-
vty_out (vty, "%s SPF Result in Area %s%s%s",
VNL, oa->name, VNL, VNL);
ospf6_linkstate_table_show (vty, argc, argv, oa->spf_table);
sargv[sargc++] = "detail";
sargv[sargc] = NULL;
- for (node = listhead (ospf6->area_list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa))
{
- oa = OSPF6_AREA (getdata (node));
-
vty_out (vty, "%s SPF Result in Area %s%s%s",
VNL, oa->name, VNL, VNL);
ospf6_linkstate_table_show (vty, sargc, sargv, oa->spf_table);
#endif /* IPV6_DROP_MEMBERSHIP */
#endif /* ! IPV6_LEAVE_GROUP */
-/* cast macro */
+/* cast macro: XXX - these *must* die, ick ick. */
#define OSPF6_PROCESS(x) ((struct ospf6 *) (x))
#define OSPF6_AREA(x) ((struct ospf6_area *) (x))
#define OSPF6_INTERFACE(x) ((struct ospf6_interface *) (x))
ospf_area_range_match_any (struct ospf *ospf, struct prefix_ipv4 *p)
{
struct ospf_area_range *range;
+ struct ospf_area *area;
struct listnode *node;
- for (node = listhead (ospf->areas); node; nextnode (node))
- if ((range = ospf_area_range_match (node->data, p)))
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
+ if ((range = ospf_area_range_match (area, p)))
return range;
return NULL;
ospf_abr_nssa_check_status (struct ospf *ospf)
{
struct ospf_area *area;
- struct listnode *lnode;
+ struct listnode *lnode, *nnode;
- LIST_LOOP (ospf->areas, area, lnode)
+ for (ALL_LIST_ELEMENTS (ospf->areas, lnode, nnode, area))
{
if (area->external_routing != OSPF_AREA_NSSA)
ospf_check_abr_status (struct ospf *ospf)
{
struct ospf_area *area;
- struct listnode *node;
+ struct listnode *node, *nnode;
int bb_configured = 0;
int bb_act_attached = 0;
int areas_configured = 0;
if (IS_DEBUG_OSPF_EVENT)
zlog_debug ("ospf_check_abr_status(): Start");
- for (node = listhead (ospf->areas); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
{
- area = getdata (node);
-
if (listcount (area->oiflist))
{
areas_configured++;
ospf_abr_nexthops_belong_to_area (struct ospf_route *or,
struct ospf_area *area)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf_path *path;
- LIST_LOOP (or->paths, path, node)
+ for (ALL_LIST_ELEMENTS (or->paths, node, nnode, path))
{
struct ospf_interface *oi = path->oi;
or_area = ospf_area_lookup_by_area_id (ospf, or->u.std.area_id);
assert (or_area);
- for (node = listhead (ospf->areas); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
{
- area = getdata (node);
-
if (IS_DEBUG_OSPF_EVENT)
zlog_debug ("ospf_abr_announce_network(): looking at area %s",
inet_ntoa (area->area_id));
if (IS_DEBUG_OSPF_NSSA)
zlog_debug ("ospf_abr_process_nssa_translates(): Start");
- for (node = listhead (ospf->areas); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
{
- area = getdata (node);
-
if (! area->NSSATranslatorState)
continue; /* skip if not translator */
if (IS_DEBUG_OSPF_EVENT)
zlog_debug ("ospf_abr_announce_rtr(): Start");
- for (node = listhead (ospf->areas); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
{
- area = getdata (node);
-
if (IS_DEBUG_OSPF_EVENT)
zlog_debug ("ospf_abr_announce_rtr(): looking at area %s",
inet_ntoa (area->area_id));
for (rn = route_top (rt); rn; rn = route_next (rn))
{
- struct listnode *node;
+ struct listnode *node, *nnode;
char flag = 0;
struct ospf_route *best = NULL;
zlog_debug ("ospf_abr_process_router_rt(): this is a route to %s",
inet_ntoa (rn->p.u.prefix4));
- for (node = listhead (l); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (l, node, nnode, or))
{
- or = getdata (node);
- if (or == NULL)
- continue;
-
if (!ospf_area_lookup_by_area_id (ospf, or->u.std.area_id))
{
if (IS_DEBUG_OSPF_EVENT)
if (IS_DEBUG_OSPF_EVENT)
zlog_debug ("ospf_abr_unapprove_summaries(): Start");
- for (node = listhead (ospf->areas); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
{
- area = getdata (node);
if (IS_DEBUG_OSPF_EVENT)
zlog_debug ("ospf_abr_unapprove_summaries(): "
"considering area %s",
struct listnode *node;
struct route_node *rn;
struct ospf_area_range *range;
+ struct ospf_area *area;
if (IS_DEBUG_OSPF_EVENT)
zlog_debug ("ospf_abr_prepare_aggregates(): Start");
- for (node = listhead (ospf->areas); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
{
- struct ospf_area *area = getdata (node);
-
for (rn = route_top (area->ranges); rn; rn = route_next (rn))
if ((range = rn->info) != NULL)
{
if (IS_DEBUG_OSPF_EVENT)
zlog_debug ("ospf_abr_announce_aggregates(): Start");
- for (node = listhead (ospf->areas); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
{
- area = getdata (node);
-
if (IS_DEBUG_OSPF_EVENT)
zlog_debug ("ospf_abr_announce_aggregates(): looking at area %s",
inet_ntoa (area->area_id));
if (IS_DEBUG_OSPF_EVENT)
zlog_debug ("ospf_abr_announce_aggregates(): active range");
- for (n = listhead (ospf->areas); n; nextnode (n))
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, n, ar))
{
- ar = getdata (n);
if (ar == area)
continue;
if (IS_DEBUG_OSPF_NSSA)
zlog_debug ("ospf_abr_send_nssa_aggregates(): Start");
- for (node = listhead (ospf->areas); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
{
- area = getdata (node);
-
if (! area->NSSATranslatorState)
continue;
if (IS_DEBUG_OSPF_NSSA)
zlog_debug ("ospf_abr_announce_stub_defaults(): Start");
- for (node = listhead (ospf->areas); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
{
- area = getdata (node);
if (IS_DEBUG_OSPF_NSSA)
zlog_debug ("ospf_abr_announce_nssa_defaults(): looking at area %s",
inet_ntoa (area->area_id));
p.prefix.s_addr = OSPF_DEFAULT_DESTINATION;
p.prefixlen = 0;
- for (node = listhead (ospf->areas); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
{
- area = getdata (node);
if (IS_DEBUG_OSPF_EVENT)
zlog_debug ("ospf_abr_announce_stub_defaults(): looking at area %s",
inet_ntoa (area->area_id));
if (IS_DEBUG_OSPF_EVENT)
zlog_debug ("ospf_abr_remove_unapproved_summaries(): Start");
- for (node = listhead (ospf->areas); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
{
- area = getdata (node);
-
if (IS_DEBUG_OSPF_EVENT)
zlog_debug ("ospf_abr_remove_unapproved_summaries(): "
"looking at area %s", inet_ntoa (area->area_id));
void
ospf_abr_manage_discard_routes (struct ospf *ospf)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct route_node *rn;
struct ospf_area *area;
struct ospf_area_range *range;
- for (node = listhead (ospf->areas); node; nextnode (node))
- if ((area = node->data) != NULL)
- for (rn = route_top (area->ranges); rn; rn = route_next (rn))
- if ((range = rn->info) != NULL)
- if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE))
- {
- if (range->specifics)
- ospf_add_discard_route (ospf->new_table, area,
- (struct prefix_ipv4 *) &rn->p);
- else
- ospf_delete_discard_route ((struct prefix_ipv4 *) &rn->p);
- }
+ for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
+ for (rn = route_top (area->ranges); rn; rn = route_next (rn))
+ if ((range = rn->info) != NULL)
+ if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE))
+ {
+ if (range->specifics)
+ ospf_add_discard_route (ospf->new_table, area,
+ (struct prefix_ipv4 *) &rn->p);
+ else
+ ospf_delete_discard_route ((struct prefix_ipv4 *) &rn->p);
+ }
}
/* This is the function taking care about ABR NSSA, i.e. NSSA
struct ospf_interface *
ospf_apiserver_if_lookup_by_addr (struct in_addr address)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf_interface *oi;
struct ospf *ospf;
if (!(ospf = ospf_lookup ()))
return NULL;
- for (node = listhead (ospf->oiflist); node; nextnode (node))
- LIST_LOOP (ospf->oiflist, oi, node)
+ for (ALL_LIST_ELEMENTS (ospf->oiflist, node, nnode, oi))
if (oi->type != OSPF_IFTYPE_VIRTUALLINK)
if (IPV4_ADDR_SAME (&address, &oi->address->u.prefix4))
return oi;
struct ospf_interface *
ospf_apiserver_if_lookup_by_ifp (struct interface *ifp)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf_interface *oi;
struct ospf *ospf;
if (!(ospf = ospf_lookup ()));
return NULL;
- LIST_LOOP (ospf->oiflist, oi, node)
+ for (ALL_LIST_ELEMENTS (ospf->oiflist, node, nnode, oi))
if (oi->ifp == ifp)
return oi;
* Free all client instances. ospf_apiserver_free removes the node
* from the list, so we examine the head of the list anew each time.
*/
- while ( (apiserv = getdata (listhead (apiserver_list))) != NULL)
+ while ( (apiserv = listgetdata (listhead (apiserver_list))) != NULL)
ospf_apiserver_free (apiserv);
/* Free client list itself */
struct ospf_apiserver *apiserv, *found = NULL;
/* XXX: this approaches O(n**2) */
- for (n1 = listhead (apiserver_list); n1; nextnode (n1))
+ for (ALL_LIST_ELEMENTS_RO (apiserver_list, n1, apiserv))
{
- apiserv = (struct ospf_apiserver *) getdata (n1);
-
- for (n2 = listhead (apiserv->opaque_types); n2; nextnode (n2))
- {
- r = (struct registered_opaque_type *) getdata (n2);
-
- if (r->lsa_type == lsa_type && r->opaque_type == opaque_type)
- {
- found = apiserv;
- goto out;
- }
- }
+ for (ALL_LIST_ELEMENTS_RO (apiserv->opaque_types, n2, r))
+ if (r->lsa_type == lsa_type && r->opaque_type == opaque_type)
+ {
+ found = apiserv;
+ goto out;
+ }
}
out:
return found;
while ((node = listhead (apiserv->opaque_types)) != NULL)
{
-
- struct registered_opaque_type *regtype = node->data;
+ struct registered_opaque_type *regtype = listgetdata(node);
ospf_apiserver_unregister_opaque_type (apiserv, regtype->lsa_type,
regtype->opaque_type);
ospf_apiserver_unregister_opaque_type (struct ospf_apiserver *apiserv,
u_char lsa_type, u_char opaque_type)
{
- struct listnode *n1, *n1_next;
+ struct listnode *node, *nnode;
struct registered_opaque_type *regtype;
- for (n1 = listhead (apiserv->opaque_types); n1; n1 = n1_next)
+ for (ALL_LIST_ELEMENTS (apiserv->opaque_types, node, nnode, regtype))
{
- n1_next = n1->next;
-
- regtype = (struct registered_opaque_type *) getdata(n1);
-
/* Check if we really registered this opaque type */
if (regtype->lsa_type == lsa_type &&
regtype->opaque_type == opaque_type)
apiserver_is_opaque_type_registered (struct ospf_apiserver *apiserv,
u_char lsa_type, u_char opaque_type)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct registered_opaque_type *regtype;
/* XXX: how many types are there? if few, why not just a bitmap? */
- LIST_LOOP (apiserv->opaque_types, regtype, node)
+ for (ALL_LIST_ELEMENTS (apiserv->opaque_types, node, nnode, regtype))
{
/* Check if we really registered this opaque type */
if (regtype->lsa_type == lsa_type &&
void
ospf_apiserver_notify_ready_type9 (struct ospf_apiserver *apiserv)
{
- struct listnode *node;
- struct listnode *n2;
+ struct listnode *node, *nnode;
+ struct listnode *node2, *nnode2;
struct ospf *ospf;
struct ospf_interface *oi;
struct registered_opaque_type *r;
ospf = ospf_lookup ();
- LIST_LOOP (ospf->oiflist, oi, node)
+ for (ALL_LIST_ELEMENTS (ospf->oiflist, node, nnode, oi))
{
/* Check if this interface is indeed ready for type 9 */
if (!ospf_apiserver_is_ready_type9 (oi))
/* Check for registered opaque type 9 types */
/* XXX: loop-de-loop - optimise me */
- LIST_LOOP (apiserv->opaque_types, r, n2)
+ for (ALL_LIST_ELEMENTS (apiserv->opaque_types, node2, nnode2, r))
{
struct msg *msg;
void
ospf_apiserver_notify_ready_type10 (struct ospf_apiserver *apiserv)
{
- struct listnode *node;
- struct listnode *n2;
+ struct listnode *node, *nnode;
+ struct listnode *node2, *nnode2;
struct ospf *ospf;
struct ospf_area *area;
ospf = ospf_lookup ();
- LIST_LOOP (ospf->areas, area, node)
+ for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
{
struct registered_opaque_type *r;
/* Check for registered opaque type 10 types */
/* XXX: loop in loop - optimise me */
- LIST_LOOP (apiserv->opaque_types, r, n2)
+ for (ALL_LIST_ELEMENTS (apiserv->opaque_types, node2, nnode2, r))
{
struct msg *msg;
void
ospf_apiserver_notify_ready_type11 (struct ospf_apiserver *apiserv)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf *ospf;
struct registered_opaque_type *r;
goto out;
/* Check for registered opaque type 11 types */
- LIST_LOOP (apiserv->opaque_types, r, node)
+ for (ALL_LIST_ELEMENTS (apiserv->opaque_types, node, nnode, r))
{
struct msg *msg;
struct in_addr noarea_id = { 0L };
ospf_apiserver_handle_sync_lsdb (struct ospf_apiserver *apiserv,
struct msg *msg)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
u_int32_t seqnum;
int rc = 0;
struct msg_sync_lsdb *smsg;
- struct param_t
+ struct ospf_apiserver_param_t
{
struct ospf_apiserver *apiserv;
struct lsa_filter_type *filter;
- }
- param;
+ } param;
u_int16_t mask;
struct route_node *rn;
struct ospf_lsa *lsa;
mask = ntohs (smsg->filter.typemask);
/* Iterate over all areas. */
- LIST_LOOP (ospf->areas, area, node)
+ for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
{
int i;
u_int32_t *area_id = NULL;
/* Type 10 opaque LSA can be originated if there is at least one
interface belonging to the area that has an active opaque-capable
neighbor. */
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf_interface *oi;
- LIST_LOOP (area->oiflist, oi, node)
+ for (ALL_LIST_ELEMENTS (area->oiflist, node, nnode, oi))
/* Is there an active neighbor attached to this interface? */
if (ospf_apiserver_is_ready_type9 (oi))
return 1;
{
/* Type 11 opaque LSA can be originated if there is at least one interface
that has an active opaque-capable neighbor. */
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf_interface *oi;
- LIST_LOOP (ospf->oiflist, oi, node)
+ for (ALL_LIST_ELEMENTS (ospf->oiflist, node, nnode, oi))
/* Is there an active neighbor attached to this interface? */
if (ospf_apiserver_is_ready_type9 (oi))
return 1;
u_char lsa_type;
u_char opaque_type;
} param;
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf * ospf;
struct ospf_area *area;
struct ospf_lsa *lsa;
case OSPF_OPAQUE_LINK_LSA:
- LIST_LOOP (ospf->areas, area, node)
+ for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
LSDB_LOOP (OPAQUE_LINK_LSDB (area), rn, lsa)
apiserver_flush_opaque_type_callback(lsa, (void *) ¶m, 0);
break;
case OSPF_OPAQUE_AREA_LSA:
- LIST_LOOP (ospf->areas, area, node)
+ for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
LSDB_LOOP (OPAQUE_AREA_LSDB (area), rn, lsa)
apiserver_flush_opaque_type_callback(lsa, (void *) ¶m, 0);
break;
void
ospf_apiserver_clients_notify_all (struct msg *msg)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf_apiserver *apiserv;
/* Send message to all clients */
- LIST_LOOP (apiserver_list, apiserv, node)
+ for (ALL_LIST_ELEMENTS (apiserver_list, node, nnode, apiserv))
ospf_apiserver_send_msg (apiserv, msg);
}
void
ospf_apiserver_clients_notify_ready_type9 (struct ospf_interface *oi)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct msg *msg;
struct ospf_apiserver *apiserv;
return;
}
- LIST_LOOP (apiserver_list, apiserv, node)
+ for (ALL_LIST_ELEMENTS (apiserver_list, node, nnode, apiserv))
{
- struct listnode *n2;
+ struct listnode *node2, *nnode2;
struct registered_opaque_type *r;
- LIST_LOOP (apiserv->opaque_types, r, n2)
+ for (ALL_LIST_ELEMENTS (apiserv->opaque_types, node2, nnode2, r))
{
if (r->lsa_type == OSPF_OPAQUE_LINK_LSA)
{
void
ospf_apiserver_clients_notify_ready_type10 (struct ospf_area *area)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct msg *msg;
struct ospf_apiserver *apiserv;
return;
}
- LIST_LOOP (apiserver_list, apiserv, node)
+ for (ALL_LIST_ELEMENTS (apiserver_list, node, nnode, apiserv))
{
- struct listnode *n2;
+ struct listnode *node2, *nnode2;
struct registered_opaque_type *r;
- LIST_LOOP (apiserv->opaque_types, r, n2)
+ for (ALL_LIST_ELEMENTS (apiserv->opaque_types, node2, nnode2, r))
{
if (r->lsa_type == OSPF_OPAQUE_AREA_LSA)
{
void
ospf_apiserver_clients_notify_ready_type11 (struct ospf *top)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct msg *msg;
struct in_addr id_null = { 0L };
struct ospf_apiserver *apiserv;
return;
}
- LIST_LOOP (apiserver_list, apiserv, node)
+ for (ALL_LIST_ELEMENTS (apiserver_list, node, nnode, apiserv))
{
- struct listnode *n2;
+ struct listnode *node2, *nnode2;
struct registered_opaque_type *r;
- LIST_LOOP (apiserv->opaque_types, r, n2)
+ for (ALL_LIST_ELEMENTS (apiserv->opaque_types, node2, nnode2, r))
{
if (r->lsa_type == OSPF_OPAQUE_AS_LSA)
{
apiserver_clients_lsa_change_notify (u_char msgtype, struct ospf_lsa *lsa)
{
struct msg *msg;
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf_apiserver *apiserv;
/* Default area for AS-External and Opaque11 LSAs */
}
/* Now send message to all clients with a matching filter */
- LIST_LOOP (apiserver_list, apiserv, node)
+ for (ALL_LIST_ELEMENTS (apiserver_list, node, nnode, apiserv))
{
struct lsa_filter_type *filter;
u_int16_t mask;
/* First try to find intra-area non-bb paths. */
if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
- for (node = listhead ((struct list *) rn->info); node; nextnode (node))
- if ((or = getdata (node)) != NULL)
- if (or->cost < OSPF_LS_INFINITY)
- if (!OSPF_IS_AREA_ID_BACKBONE (or->u.std.area_id) &&
- or->path_type == OSPF_PATH_INTRA_AREA)
- listnode_add (chosen, or);
+ for (ALL_LIST_ELEMENTS_RO ((struct list *) rn->info, node, or))
+ if (or->cost < OSPF_LS_INFINITY)
+ if (!OSPF_IS_AREA_ID_BACKBONE (or->u.std.area_id) &&
+ or->path_type == OSPF_PATH_INTRA_AREA)
+ listnode_add (chosen, or);
/* If none is found -- look through all. */
if (listcount (chosen) == 0)
}
/* Now find the route with least cost. */
- for (node = listhead (chosen); node; nextnode (node))
- if ((or = getdata (node)) != NULL)
- if (or->cost < OSPF_LS_INFINITY)
- {
- if (best == NULL)
- best = or;
- else if (best->cost > or->cost)
- best = or;
- else if (best->cost == or->cost &&
- IPV4_ADDR_CMP (&best->u.std.area_id,
- &or->u.std.area_id) < 0)
- best = or;
- }
+ for (ALL_LIST_ELEMENTS_RO (chosen, node, or))
+ if (or->cost < OSPF_LS_INFINITY)
+ {
+ if (best == NULL)
+ best = or;
+ else if (best->cost > or->cost)
+ best = or;
+ else if (best->cost == or->cost &&
+ IPV4_ADDR_CMP (&best->u.std.area_id,
+ &or->u.std.area_id) < 0)
+ best = or;
+ }
if (chosen != rn->info)
list_delete (chosen);
route_unlock_node (rn);
- for (node = listhead ((struct list *) rn->info); node; nextnode (node))
- if ((or = getdata (node)) != NULL)
- if (IPV4_ADDR_SAME (&or->u.std.area_id, &area->area_id))
- return or;
+ for (ALL_LIST_ELEMENTS_RO ((struct list *) rn->info, node, or))
+ if (IPV4_ADDR_SAME (&or->u.std.area_id, &area->area_id))
+ return or;
}
return NULL;
struct listnode *node;
struct ospf_path *op;
- for (node = listhead (ro->paths); node; nextnode (node))
- if ((op = getdata (node)) != NULL)
- if (op->nexthop.s_addr == 0)
- op->nexthop.s_addr = nexthop.s_addr;
+ for (ALL_LIST_ELEMENTS_RO (ro->paths, node, op))
+ if (op->nexthop.s_addr == 0)
+ op->nexthop.s_addr = nexthop.s_addr;
}
int
struct listnode *ifn;
struct ospf_interface *oi;
- for (ifn = listhead (ospf->oiflist); ifn; nextnode (ifn))
- if ((oi = getdata (ifn)) != NULL)
- if (if_is_operative (oi->ifp))
- if (oi->type != OSPF_IFTYPE_VIRTUALLINK)
- if (IPV4_ADDR_SAME (&oi->address->u.prefix4, &fwd_addr))
- return 0;
+ for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, ifn, oi))
+ if (if_is_operative (oi->ifp))
+ if (oi->type != OSPF_IFTYPE_VIRTUALLINK)
+ if (IPV4_ADDR_SAME (&oi->address->u.prefix4, &fwd_addr))
+ return 0;
return 1;
}
/* Check each path. */
for (n1 = listhead (or->paths), n2 = listhead (newor->paths);
- n1 && n2; nextnode (n1), nextnode (n2))
+ n1 && n2; n1 = listnextnode (n1), n2 = listnextnode (n2))
{
- op = getdata (n1);
- newop = getdata (n2);
+ op = listgetdata (n1);
+ newop = listgetdata (n2);
if (! IPV4_ADDR_SAME (&op->nexthop, &newop->nexthop))
return 0;
/* This version simple adds to the table all NSSA areas */
if (ospf->anyNSSA)
- for (node = listhead (ospf->areas); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
{
- area = getdata (node);
if (IS_DEBUG_OSPF_NSSA)
zlog_debug ("ospf_ase_calculate_timer(): looking at area %s",
inet_ntoa (area->area_id));
struct route_node *rn;
struct ospf_lsa *lsa;
struct list *lst;
- struct listnode *node;
+ struct listnode *node, *nnode;
for (rn = route_top (rt); rn; rn = route_next (rn))
if ((lst = rn->info) != NULL)
{
- for (node = listhead (lst); node; node = nextnode (node))
- if ((lsa = getdata (node)) != NULL)
- ospf_lsa_unlock (lsa);
+ for (ALL_LIST_ELEMENTS (lst, node, nnode, lsa))
+ ospf_lsa_unlock (lsa);
list_delete (lst);
}
-
+
route_table_finish (rt);
}
assert (rn && rn->info);
lsas = rn->info;
- for (node = listhead (lsas); node; nextnode (node))
- if ((lsa = getdata (node)) != NULL)
- ospf_ase_calculate_route (ospf, lsa);
+ for (ALL_LIST_ELEMENTS_RO (lsas, node, lsa))
+ ospf_ase_calculate_route (ospf, lsa);
/* prepare temporary old routing table for compare */
tmp_old = route_table_init ();
/* Look through all interfaces, not just area, since interface
could be moved from one area to another. */
- for (node = listhead (ospf->oiflist); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
/* These are sanity check. */
- if ((oi = getdata (node)) != NULL)
- if (IPV4_ADDR_SAME (&oi->address->u.prefix4, &new->data->id))
- {
- if (oi->area != area ||
- oi->type != OSPF_IFTYPE_BROADCAST ||
- !IPV4_ADDR_SAME (&oi->address->u.prefix4, &DR (oi)))
- {
- ospf_schedule_lsa_flush_area (area, new);
- return;
- }
-
+ if (IPV4_ADDR_SAME (&oi->address->u.prefix4, &new->data->id))
+ {
+ if (oi->area != area ||
+ oi->type != OSPF_IFTYPE_BROADCAST ||
+ !IPV4_ADDR_SAME (&oi->address->u.prefix4, &DR (oi)))
+ {
+ ospf_schedule_lsa_flush_area (area, new);
+ return;
+ }
+
#ifdef HAVE_OPAQUE_LSA
- if (new->data->type == OSPF_OPAQUE_LINK_LSA)
- {
- ospf_opaque_lsa_refresh (new);
- return;
- }
+ if (new->data->type == OSPF_OPAQUE_LINK_LSA)
+ {
+ ospf_opaque_lsa_refresh (new);
+ return;
+ }
#endif /* HAVE_OPAQUE_LSA */
- ospf_lsa_unlock (oi->network_lsa_self);
- oi->network_lsa_self = ospf_lsa_lock (new);
-
- /* Schedule network-LSA origination. */
- ospf_network_lsa_timer_add (oi);
- return;
- }
+ ospf_lsa_unlock (oi->network_lsa_self);
+ oi->network_lsa_self = ospf_lsa_lock (new);
+
+ /* Schedule network-LSA origination. */
+ ospf_network_lsa_timer_add (oi);
+ return;
+ }
break;
case OSPF_SUMMARY_LSA:
case OSPF_ASBR_SUMMARY_LSA:
ospf_flood_through_area (struct ospf_area *area,
struct ospf_neighbor *inbr, struct ospf_lsa *lsa)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
+ struct ospf_interface *oi;
int lsa_ack_flag = 0;
/* All other types are specific to a single area (Area A). The
eligible interfaces are all those interfaces attaching to the
Area A. If Area A is the backbone, this includes all the virtual
links. */
- for (node = listhead (area->oiflist); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (area->oiflist, node, nnode, oi))
{
- struct ospf_interface *oi = getdata (node);
-
if (area->area_id.s_addr != OSPF_AREA_BACKBONE &&
oi->type == OSPF_IFTYPE_VIRTUALLINK)
continue;
struct ospf_lsa *lsa)
{
struct listnode *node;
+ struct ospf_area *area;
int lsa_ack_flag;
lsa_ack_flag = 0;
if (IS_DEBUG_OSPF_NSSA)
zlog_debug ("Flood/AS: NSSA TRANSLATED LSA");
- for (node = listhead (ospf->areas); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
{
int continue_flag = 0;
- struct ospf_area *area = getdata (node);
struct listnode *if_node;
+ struct ospf_interface *oi;
switch (area->external_routing)
{
/* send to every interface in this area */
- for (if_node = listhead (area->oiflist); if_node; nextnode (if_node))
+ for (ALL_LIST_ELEMENTS_RO (area->oiflist, if_node, oi))
{
- struct ospf_interface *oi = getdata (if_node);
-
/* Skip virtual links */
if (oi->type != OSPF_IFTYPE_VIRTUALLINK)
if (ospf_flood_through_interface (oi, inbr, lsa)) /* lsa */
ospf_ls_retransmit_delete_nbr_area (struct ospf_area *area,
struct ospf_lsa *lsa)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
+ struct ospf_interface *oi;
- for (node = listhead (area->oiflist); node; nextnode (node))
- ospf_ls_retransmit_delete_nbr_if (getdata (node), lsa);
+ for (ALL_LIST_ELEMENTS (area->oiflist, node, nnode, oi))
+ ospf_ls_retransmit_delete_nbr_if (oi, lsa);
}
void
ospf_ls_retransmit_delete_nbr_as (struct ospf *ospf, struct ospf_lsa *lsa)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
+ struct ospf_interface *oi;
- for (node = listhead (ospf->oiflist); node; nextnode (node))
- ospf_ls_retransmit_delete_nbr_if (getdata (node), lsa);
+ for (ALL_LIST_ELEMENTS (ospf->oiflist, node, nnode, oi))
+ ospf_ls_retransmit_delete_nbr_if (oi, lsa);
}
\f
route_unlock_node (rn);
- for (node = listhead ((struct list *) rn->info); node; nextnode (node))
- if ((or = getdata (node)) != NULL)
- if (IPV4_ADDR_SAME (&or->u.std.area_id, &area->area_id) && (or->u.std.flags & ROUTER_LSA_BORDER))
- return or;
+ for (ALL_LIST_ELEMENTS_RO ((struct list *) rn->info, node, or))
+ if (IPV4_ADDR_SAME (&or->u.std.area_id, &area->area_id)
+ && (or->u.std.flags & ROUTER_LSA_BORDER))
+ return or;
return NULL;
}
OSPF_EXAMINE_SUMMARIES_ALL (area, rt, rtrs);
- for (node = listhead (ospf->areas); node; nextnode (node))
- if ((area = getdata (node)) != NULL)
- if (area != ospf->backbone)
- if (ospf_area_is_transit (area))
- OSPF_EXAMINE_TRANSIT_SUMMARIES_ALL (area, rt, rtrs);
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
+ if (area != ospf->backbone)
+ if (ospf_area_is_transit (area))
+ OSPF_EXAMINE_TRANSIT_SUMMARIES_ALL (area, rt, rtrs);
}
else
if (IS_DEBUG_OSPF_EVENT)
OSPF_EXAMINE_SUMMARIES_ALL (area, rt, rtrs);
- for (node = listhead (ospf->areas); node; nextnode (node))
- if ((area = getdata (node)) != NULL)
- if (area != ospf->backbone)
- if (ospf_area_is_transit (area))
- OSPF_EXAMINE_TRANSIT_SUMMARIES_ALL (area, rt, rtrs);
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
+ if (area != ospf->backbone)
+ if (ospf_area_is_transit (area))
+ OSPF_EXAMINE_TRANSIT_SUMMARIES_ALL (area, rt, rtrs);
}
else
{ /* No active BB connection--consider all areas */
if (IS_DEBUG_OSPF_EVENT)
zlog_debug ("ospf_ia_routing(): "
"Active BB connection not found");
- for (node = listhead (ospf->areas); node; nextnode (node))
- if ((area = getdata (node)) != NULL)
- OSPF_EXAMINE_SUMMARIES_ALL (area, rt, rtrs);
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
+ OSPF_EXAMINE_SUMMARIES_ALL (area, rt, rtrs);
}
break;
case OSPF_ABR_SHORTCUT:
OSPF_EXAMINE_SUMMARIES_ALL (area, rt, rtrs);
}
- for (node = listhead (ospf->areas); node; nextnode (node))
- if ((area = getdata (node)) != NULL)
- if (area != ospf->backbone)
- if (ospf_area_is_transit (area) ||
- ((area->shortcut_configured != OSPF_SHORTCUT_DISABLE) &&
- ((ospf->backbone == NULL) ||
- ((area->shortcut_configured == OSPF_SHORTCUT_ENABLE) &&
- area->shortcut_capability))))
- OSPF_EXAMINE_TRANSIT_SUMMARIES_ALL (area, rt, rtrs);
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
+ if (area != ospf->backbone)
+ if (ospf_area_is_transit (area) ||
+ ((area->shortcut_configured != OSPF_SHORTCUT_DISABLE) &&
+ ((ospf->backbone == NULL) ||
+ ((area->shortcut_configured == OSPF_SHORTCUT_ENABLE) &&
+ area->shortcut_capability))))
+ OSPF_EXAMINE_TRANSIT_SUMMARIES_ALL (area, rt, rtrs);
break;
default:
break;
if (IS_DEBUG_OSPF_EVENT)
zlog_debug ("ospf_ia_routing():not ABR, considering all areas");
- for (node = listhead (ospf->areas); node; nextnode (node))
- if ((area = getdata (node)) != NULL)
- OSPF_EXAMINE_SUMMARIES_ALL (area, rt, rtrs);
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
+ OSPF_EXAMINE_SUMMARIES_ALL (area, rt, rtrs);
}
}
ospf_if_cleanup (struct ospf_interface *oi)
{
struct route_node *rn;
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf_neighbor *nbr;
+ struct ospf_nbr_nbma *nbr_nbma;
+ struct ospf_lsa *lsa;
/* oi->nbrs and oi->nbr_nbma should be deletete on InterafceDown event */
/* delete all static neighbors attached to this interface */
- for (node = listhead (oi->nbr_nbma); node; )
+ for (ALL_LIST_ELEMENTS (oi->nbr_nbma, node, nnode, nbr_nbma))
{
- struct ospf_nbr_nbma *nbr_nbma = getdata (node);
- nextnode (node);
-
OSPF_POLL_TIMER_OFF (nbr_nbma->t_poll);
if (nbr_nbma->nbr)
OSPF_NSM_EVENT_EXECUTE (nbr, NSM_KillNbr);
/* Cleanup Link State Acknowlegdment list. */
- for (node = listhead (oi->ls_ack); node; nextnode (node))
- ospf_lsa_unlock (node->data);
+ for (ALL_LIST_ELEMENTS (oi->ls_ack, node, nnode, lsa))
+ ospf_lsa_unlock (lsa);
list_delete_all_node (oi->ls_ack);
oi->crypt_seqnum = 0;
struct ospf_interface *
ospf_if_is_configured (struct ospf *ospf, struct in_addr *address)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf_interface *oi;
struct prefix_ipv4 addr;
addr.prefix = *address;
addr.prefixlen = IPV4_MAX_PREFIXLEN;
- for (node = listhead (ospf->oiflist); node; nextnode (node))
- if ((oi = getdata (node)) != NULL && oi->type != OSPF_IFTYPE_VIRTUALLINK)
+ for (ALL_LIST_ELEMENTS (ospf->oiflist, node, nnode, oi))
+ if (oi->type != OSPF_IFTYPE_VIRTUALLINK)
{
if (oi->type == OSPF_IFTYPE_POINTOPOINT)
{
ospf = ospf_lookup ();
- for (node = listhead (ospf->oiflist); node; nextnode (node))
- {
- if (((oi = getdata (node)) != NULL) && (oi == oic))
+ for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
+ if (oi == oic)
return oi;
- }
+
return NULL;
}
struct listnode *node;
struct ospf_interface *oi;
- for (node = listhead (ospf->oiflist); node; nextnode (node))
- if ((oi = getdata (node)) != NULL && oi->type != OSPF_IFTYPE_VIRTUALLINK)
+ for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
+ if (oi->type != OSPF_IFTYPE_VIRTUALLINK)
{
if (ifp && oi->ifp != ifp)
continue;
struct prefix ptmp;
/* Check each Interface. */
- for (node = listhead (ospf->oiflist); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
{
- if ((oi = getdata (node)) != NULL && oi->type != OSPF_IFTYPE_VIRTUALLINK)
+ if (oi->type != OSPF_IFTYPE_VIRTUALLINK)
{
if ((oi->type == OSPF_IFTYPE_POINTOPOINT) &&
CONNECTED_DEST_HOST(oi->connected))
match = NULL;
- for (node = listhead (ospf->oiflist); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
{
- oi = getdata (node);
-
if (oi->type == OSPF_IFTYPE_VIRTUALLINK)
continue;
struct ospf_vl_data *vl_data;
struct listnode *node;
- for (node = listhead (area->ospf->vlinks); node; nextnode (node))
- if ((vl_data = getdata (node)) != NULL)
- if (vl_data->vl_peer.s_addr == vl_peer.s_addr &&
- IPV4_ADDR_SAME (&vl_data->vl_area_id, &area->area_id))
- return vl_data;
+ for (ALL_LIST_ELEMENTS_RO (area->ospf->vlinks, node, vl_data))
+ if (vl_data->vl_peer.s_addr == vl_peer.s_addr &&
+ IPV4_ADDR_SAME (&vl_data->vl_area_id, &area->area_id))
+ return vl_data;
return NULL;
}
changed = 1;
}
- for (node = listhead (v->nexthop); node; nextnode (node))
- if ((nh = getdata (node)) != NULL)
- {
- vl_data->out_oi = (struct ospf_interface *) nh->oi;
+ for (ALL_LIST_ELEMENTS_RO (v->nexthop, node, nh))
+ {
+ vl_data->out_oi = (struct ospf_interface *) nh->oi;
+
+ if (!IPV4_ADDR_SAME(&voi->address->u.prefix4,
+ &vl_data->out_oi->address->u.prefix4))
+ changed = 1;
- if (!IPV4_ADDR_SAME(&voi->address->u.prefix4,
- &vl_data->out_oi->address->u.prefix4))
- changed = 1;
-
- voi->address->u.prefix4 = vl_data->out_oi->address->u.prefix4;
- voi->address->prefixlen = vl_data->out_oi->address->prefixlen;
-
- break; /* We take the first interface. */
- }
+ voi->address->u.prefix4 = vl_data->out_oi->address->u.prefix4;
+ voi->address->prefixlen = vl_data->out_oi->address->prefixlen;
+
+ break; /* We take the first interface. */
+ }
rl = (struct router_lsa *)v->lsa;
zlog_debug ("ospf_vl_up_check(): Area is %s", inet_ntoa (area->area_id));
}
- for (node = listhead (ospf->vlinks); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data))
{
- if ((vl_data = getdata (node)) == NULL)
- continue;
-
if (IS_DEBUG_OSPF_EVENT)
{
zlog_debug ("ospf_vl_up_check(): considering VL, name: %s",
struct listnode *node;
struct ospf_vl_data *vl_data;
- for (node = listhead (ospf->vlinks); node; nextnode (node))
- if ((vl_data = getdata (node)) != NULL)
- UNSET_FLAG (vl_data->flags, OSPF_VL_FLAG_APPROVED);
+ for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data))
+ UNSET_FLAG (vl_data->flags, OSPF_VL_FLAG_APPROVED);
}
void
ospf_vl_shut_unapproved (struct ospf *ospf)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf_vl_data *vl_data;
- for (node = listhead (ospf->vlinks); node; nextnode (node))
- if ((vl_data = getdata (node)) != NULL)
- if (!CHECK_FLAG (vl_data->flags, OSPF_VL_FLAG_APPROVED))
- ospf_vl_shutdown (vl_data);
+ for (ALL_LIST_ELEMENTS (ospf->vlinks, node, nnode, vl_data))
+ if (!CHECK_FLAG (vl_data->flags, OSPF_VL_FLAG_APPROVED))
+ ospf_vl_shutdown (vl_data);
}
int
struct ospf_vl_data *vl_data;
int c = 0;
- for (node = listhead (area->ospf->vlinks); node; nextnode (node))
- if ((vl_data = getdata (node)) != NULL)
- if (IPV4_ADDR_SAME (&vl_data->vl_area_id, &area->area_id))
- c++;
+ for (ALL_LIST_ELEMENTS_RO (area->ospf->vlinks, node, vl_data))
+ if (IPV4_ADDR_SAME (&vl_data->vl_area_id, &area->area_id))
+ c++;
return c;
}
struct listnode *node;
struct crypt_key *ck;
- for (node = listhead (auth_crypt); node; nextnode (node))
- {
- ck = getdata (node);
- if (ck->key_id == key_id)
- return ck;
- }
+ for (ALL_LIST_ELEMENTS_RO (auth_crypt, node, ck))
+ if (ck->key_id == key_id)
+ return ck;
return NULL;
}
int
ospf_crypt_key_delete (struct list *auth_crypt, u_char key_id)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct crypt_key *ck;
- for (node = listhead (auth_crypt); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (auth_crypt, node, nnode, ck))
{
- ck = getdata (node);
if (ck->key_id == key_id)
{
listnode_delete (auth_crypt, ck);
/* Choose highest router priority.
In case of tie, choose highest Router ID. */
- for (node = listhead (routers); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (routers, node, nbr))
{
- nbr = getdata (node);
-
if (max == NULL)
max = nbr;
else
dr_list = list_new ();
/* Add neighbors to the list. */
- for (node = listhead (el_list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (el_list, node, nbr))
{
- nbr = getdata (node);
-
/* neighbor declared to be DR. */
if (NBR_IS_DR (nbr))
listnode_add (dr_list, nbr);
no_dr_list = list_new ();
/* Add neighbors to the list. */
- for (node = listhead (el_list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (el_list, node, nbr))
{
- nbr = getdata (node);
-
/* neighbor declared to be DR. */
if (NBR_IS_DR (nbr))
continue;
router_lsa_link_set (struct stream *s, struct ospf_area *area)
{
struct listnode *node;
+ struct ospf_interface *oi;
int links = 0;
- for (node = listhead (area->oiflist); node; node = nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (area->oiflist, node, oi))
{
- struct ospf_interface *oi = node->data;
struct interface *ifp = oi->ifp;
/* Check interface is up, OSPF is enable. */
ospf_router_lsa_update_timer (struct thread *thread)
{
struct ospf *ospf = THREAD_ARG (thread);
- struct listnode *node;
+ struct listnode *node, *nnode;
+ struct ospf_area *area;
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
zlog_debug ("Timer[router-LSA Update]: (timer expire)");
ospf->t_router_lsa_update = NULL;
- for (node = listhead (ospf->areas); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
{
- struct ospf_area *area = getdata (node);
struct ospf_lsa *lsa = area->router_lsa_self;
struct router_lsa *rl;
const char *area_str;
{
struct in_addr fwd;
struct prefix nh;
- struct listnode *n1;
+ struct listnode *node;
+ struct ospf_interface *oi;
fwd.s_addr = 0;
nh.u.prefix4 = nexthop;
nh.prefixlen = IPV4_MAX_BITLEN;
- for (n1 = listhead (ospf->oiflist); n1; nextnode (n1))
- {
- struct ospf_interface *oi = getdata (n1);
-
- if (if_is_operative (oi->ifp))
- if (oi->address->family == AF_INET)
- if (prefix_match (oi->address, &nh))
- return nexthop;
- }
+ for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
+ if (if_is_operative (oi->ifp))
+ if (oi->address->family == AF_INET)
+ if (prefix_match (oi->address, &nh))
+ return nexthop;
return fwd;
}
{
struct in_addr fwd;
struct in_addr best_default;
- struct listnode *n1;
+ struct listnode *node;
+ struct ospf_interface *oi;
fwd.s_addr = 0;
best_default.s_addr = 0;
- for (n1 = listhead (area->ospf->oiflist); n1; nextnode (n1))
+ for (ALL_LIST_ELEMENTS_RO (area->ospf->oiflist, node, oi))
{
- struct ospf_interface *oi = getdata (n1);
-
if (if_is_operative (oi->ifp))
if (oi->area->external_routing == OSPF_AREA_NSSA)
if (oi->address && oi->address->family == AF_INET)
{
struct ospf_lsa *new;
struct as_external_lsa *extlsa;
- struct listnode *node;
+ struct ospf_area *area;
+ struct listnode *node, *nnode;
/* LSA may be a Type-5 originated via translation of a Type-7 LSA
* which originated from an NSSA area. In which case it should not be
Later, ABR_TASK and P-bit will scan Type-7 LSDB and translate to
Type-5's to non-NSSA Areas. (it will also attempt a re-install) */
- for (node = listhead (ospf->areas); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
{
- struct ospf_area *area = getdata (node);
-
/* Don't install Type-7 LSA's into nonNSSA area */
if (area->external_routing != OSPF_AREA_NSSA)
continue;
/* find the type-7 from which supplied type-5 was translated,
* ie find first type-7 with same LSA Id.
*/
- struct listnode *ln;
+ struct listnode *ln, *lnn;
struct route_node *rn;
struct ospf_lsa *lsa;
struct ospf_area *area;
- LIST_LOOP (ospf->areas, area, ln)
+ for (ALL_LIST_ELEMENTS (ospf->areas, ln, lnn, area))
{
if (area->external_routing != OSPF_AREA_NSSA
&& !type7)
void
ospf_nssa_lsa_flush (struct ospf *ospf, struct prefix_ipv4 *p)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf_lsa *lsa;
struct ospf_area *area;
- for (node = listhead (ospf->areas); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
{
- if (((area = getdata (node)) != NULL)
- && (area->external_routing == OSPF_AREA_NSSA))
+ if (area->external_routing == OSPF_AREA_NSSA)
{
if (!(lsa = ospf_lsa_lookup (area, OSPF_AS_NSSA_LSA, p->prefix,
ospf->router_id)))
int
ospf_check_nbr_status (struct ospf *ospf)
{
- struct listnode *node;
-
- for (node = listhead (ospf->oiflist); node; node = nextnode (node))
+ struct listnode *node, *nnode;
+ struct ospf_interface *oi;
+
+ for (ALL_LIST_ELEMENTS (ospf->oiflist, node, nnode, oi))
{
- struct ospf_interface *oi = getdata (node);
struct route_node *rn;
struct ospf_neighbor *nbr;
ospf_maxage_lsa_remover (struct thread *thread)
{
struct ospf *ospf = THREAD_ARG (thread);
- struct listnode *node;
- struct listnode *next;
+ struct ospf_lsa *lsa;
+ struct listnode *node, *nnode;
int reschedule = 0;
ospf->t_maxage = NULL;
reschedule = !ospf_check_nbr_status (ospf);
if (!reschedule)
- for (node = listhead (ospf->maxage_lsa); node; node = next)
+ for (ALL_LIST_ELEMENTS (ospf->maxage_lsa, node, nnode, lsa))
{
- struct ospf_lsa *lsa = getdata (node);
- next = node->next;
-
if (lsa->retransmit_counter > 0)
{
reschedule = 1;
ospf_lsa_maxage_exist (struct ospf *ospf, struct ospf_lsa *new)
{
struct listnode *node;
-
- for (node = listhead (ospf->maxage_lsa); node; nextnode (node))
- if (((struct ospf_lsa *) node->data) == new)
+ struct ospf_lsa *lsa;
+
+ for (ALL_LIST_ELEMENTS_RO (ospf->maxage_lsa, node, lsa))
+ if (lsa == new)
return 1;
return 0;
struct ospf *ospf = THREAD_ARG (thread);
struct route_node *rn;
struct ospf_lsa *lsa;
- struct listnode *node;
+ struct ospf_area *area;
+ struct listnode *node, *nnode;
ospf->t_maxage_walker = NULL;
- for (node = listhead (ospf->areas); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
{
- struct ospf_area *area = node->data;
-
LSDB_LOOP (ROUTER_LSDB (area), rn, lsa)
ospf_lsa_maxage_walker_remover (ospf, lsa);
LSDB_LOOP (NETWORK_LSDB (area), rn, lsa)
void
ospf_flush_self_originated_lsas_now (struct ospf *ospf)
{
- struct listnode *n1, *n2;
+ struct listnode *node, *nnode;
+ struct listnode *node2, *nnode2;
struct ospf_area *area;
struct ospf_interface *oi;
struct ospf_lsa *lsa;
struct route_node *rn;
int need_to_flush_ase = 0;
- for (n1 = listhead (ospf->areas); n1; nextnode (n1))
+ for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
{
- if ((area = getdata (n1)) == NULL)
- continue;
-
if ((lsa = area->router_lsa_self) != NULL)
{
if (IS_DEBUG_OSPF_EVENT)
OSPF_TIMER_OFF (area->t_router_lsa_self);
}
- for (n2 = listhead (area->oiflist); n2; nextnode (n2))
+ for (ALL_LIST_ELEMENTS (area->oiflist, node2, nnode2, oi))
{
- if ((oi = getdata (n2)) == NULL)
- continue;
-
if ((lsa = oi->network_lsa_self) != NULL
- && oi->state == ISM_DR
- && oi->full_nbrs > 0)
+ && oi->state == ISM_DR
+ && oi->full_nbrs > 0)
{
if (IS_DEBUG_OSPF_EVENT)
zlog_debug ("LSA[Type%d:%s]: Schedule self-originated LSA to FLUSH", lsa->data->type, inet_ntoa (lsa->data->id));
ospf_lsa_is_self_originated (struct ospf *ospf, struct ospf_lsa *lsa)
{
struct listnode *node;
+ struct ospf_interface *oi;
/* This LSA is already checked. */
if (CHECK_FLAG (lsa->flags, OSPF_LSA_SELF_CHECKED))
/* LSA is network-LSA. Compare Link ID with all interfaces. */
else if (lsa->data->type == OSPF_NETWORK_LSA)
- for (node = listhead (ospf->oiflist); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
{
- struct ospf_interface *oi = getdata (node);
-
/* Ignore virtual link. */
if (oi->type != OSPF_IFTYPE_VIRTUALLINK)
if (oi->address->family == AF_INET)
ospf_lsa_refresh_walker (struct thread *t)
{
struct list *refresh_list;
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf *ospf = THREAD_ARG (t);
+ struct ospf_lsa *lsa;
int i;
struct list *lsa_to_refresh = list_new ();
if (refresh_list)
{
- for (node = listhead (refresh_list); node;)
+ for (ALL_LIST_ELEMENTS (refresh_list, node, nnode, lsa))
{
- struct listnode *next;
- struct ospf_lsa *lsa = getdata (node);
- next = node->next;
-
if (IS_DEBUG_OSPF (lsa, LSA_REFRESH))
zlog_debug ("LSA[Refresh:%s]: ospf_lsa_refresh_walker(): "
"refresh lsa %p (slot %d)",
ospf_lsa_unlock (lsa);
lsa->refresh_list = -1;
listnode_add (lsa_to_refresh, lsa);
- node = next;
}
list_free (refresh_list);
}
ospf, ospf->lsa_refresh_interval);
ospf->lsa_refresher_started = time (NULL);
- for (node = listhead (lsa_to_refresh); node; nextnode (node))
- ospf_lsa_refresh (ospf, getdata (node));
+ for (ALL_LIST_ELEMENTS (lsa_to_refresh, node, nnode, lsa))
+ ospf_lsa_refresh (ospf, lsa);
list_delete (lsa_to_refresh);
ospf_flush_self_originated_lsas_now (top);
/* Revert all neighbor status to ExStart. */
- for (node = listhead (top->oiflist); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (top->oiflist, node, oi))
{
- if ((oi = getdata (node)) == NULL || (nbrs = oi->nbrs) == NULL)
+ if ((nbrs = oi->nbrs) == NULL)
continue;
for (rn = route_top (nbrs); rn; rn = route_next (rn))
struct ospf_nbr_nbma *nbr_nbma;
struct listnode *node;
- for (node = listhead (oi->nbr_nbma); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, node, nbr_nbma))
{
- nbr_nbma = getdata (node);
- assert (nbr_nbma);
-
if (IPV4_ADDR_SAME(&nbr_nbma->addr, &nbr->src))
{
nbr_nbma->nbr = nbr;
}
else
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf_opaque_functab *functab;
- LIST_LOOP (funclist, functab, node)
+ for (ALL_LIST_ELEMENTS (funclist, node, nnode, functab))
if (functab->opaque_type == opaque_type)
{
zlog_warn ("ospf_register_opaque_functab: Duplicated entry?:"
ospf_delete_opaque_functab (u_char lsa_type, u_char opaque_type)
{
struct list *funclist;
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf_opaque_functab *functab;
if ((funclist = ospf_get_opaque_funclist (lsa_type)) != NULL)
- for (node = listhead (funclist); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (funclist, node, nnode, functab))
{
- if ((functab = getdata (node)) != NULL
- && functab->opaque_type == opaque_type)
+ if (functab->opaque_type == opaque_type)
{
/* Cleanup internal control information, if it still remains. */
if (functab->oipt != NULL)
u_char key = GET_OPAQUE_TYPE (ntohl (lsa->data->id.s_addr));
if ((funclist = ospf_get_opaque_funclist (lsa->data->type)) != NULL)
- LIST_LOOP (funclist, functab, node)
+ for (ALL_LIST_ELEMENTS_RO (funclist, node, functab))
if (functab->opaque_type == key)
return functab;
struct opaque_info_per_type *oipt = (struct opaque_info_per_type *) val;
struct opaque_info_per_id *oipi;
struct ospf_lsa *lsa;
- struct listnode *node;
+ struct listnode *node, *nnode;
/* Control information per opaque-id may still exist. */
- for (node = listhead (oipt->id_list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (oipt->id_list, node, nnode, oipi))
{
- if ((oipi = getdata (node)) == NULL)
- continue;
if ((lsa = oipi->lsa) == NULL)
continue;
if (IS_LSA_MAXAGE (lsa))
struct ospf_area *area;
struct ospf_interface *oi;
struct list *listtop = NULL;
- struct listnode *node;
+ struct listnode *node, *nnode;
struct opaque_info_per_type *oipt = NULL;
u_char key = GET_OPAQUE_TYPE (ntohl (lsa->data->id.s_addr));
}
if (listtop != NULL)
- LIST_LOOP (listtop, oipt, node)
+ for (ALL_LIST_ELEMENTS (listtop, node, nnode, oipt))
if (oipt->opaque_type == key)
return oipt;
lookup_opaque_info_by_id (struct opaque_info_per_type *oipt,
struct ospf_lsa *lsa)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct opaque_info_per_id *oipi;
u_int32_t key = GET_OPAQUE_ID (ntohl (lsa->data->id.s_addr));
- LIST_LOOP (oipt->id_list, oipi, node)
+ for (ALL_LIST_ELEMENTS (oipt->id_list, node, nnode, oipi))
if (oipi->opaque_id == key)
return oipi;
static int
opaque_lsa_new_if_callback (struct list *funclist, struct interface *ifp)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf_opaque_functab *functab;
int rc = -1;
- LIST_LOOP (funclist, functab, node)
+ for (ALL_LIST_ELEMENTS (funclist, node, nnode, functab))
if (functab->new_if_hook != NULL)
if ((* functab->new_if_hook)(ifp) != 0)
goto out;
static int
opaque_lsa_del_if_callback (struct list *funclist, struct interface *ifp)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf_opaque_functab *functab;
int rc = -1;
- LIST_LOOP (funclist, functab, node)
+ for (ALL_LIST_ELEMENTS (funclist, node, nnode, functab))
if (functab->del_if_hook != NULL)
if ((* functab->del_if_hook)(ifp) != 0)
goto out;
opaque_lsa_ism_change_callback (struct list *funclist,
struct ospf_interface *oi, int old_status)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf_opaque_functab *functab;
- LIST_LOOP (funclist, functab, node)
+ for (ALL_LIST_ELEMENTS (funclist, node, nnode, functab))
if (functab->ism_change_hook != NULL)
(* functab->ism_change_hook)(oi, old_status);
opaque_lsa_nsm_change_callback (struct list *funclist,
struct ospf_neighbor *nbr, int old_status)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf_opaque_functab *functab;
- LIST_LOOP (funclist, functab, node)
+ for (ALL_LIST_ELEMENTS (funclist, node, nnode, functab))
if (functab->nsm_change_hook != NULL)
(* functab->nsm_change_hook)(nbr, old_status);
return;
opaque_lsa_config_write_router_callback (struct list *funclist,
struct vty *vty)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf_opaque_functab *functab;
- LIST_LOOP (funclist, functab, node)
+ for (ALL_LIST_ELEMENTS (funclist, node, nnode, functab))
if (functab->config_write_router != NULL)
(* functab->config_write_router)(vty);
return;
opaque_lsa_config_write_if_callback (struct list *funclist,
struct vty *vty, struct interface *ifp)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf_opaque_functab *functab;
- LIST_LOOP (funclist, functab, node)
+ for (ALL_LIST_ELEMENTS (funclist, node, nnode, functab))
if (functab->config_write_if != NULL)
(* functab->config_write_if)(vty, ifp);
return;
static void
opaque_lsa_config_write_debug_callback (struct list *funclist, struct vty *vty)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf_opaque_functab *functab;
- LIST_LOOP (funclist, functab, node)
+ for (ALL_LIST_ELEMENTS (funclist, node, nnode, functab))
if (functab->config_write_debug != NULL)
(* functab->config_write_debug)(vty);
return;
static int
opaque_lsa_originate_callback (struct list *funclist, void *lsa_type_dependent)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf_opaque_functab *functab;
int rc = -1;
- LIST_LOOP (funclist, functab, node)
+ for (ALL_LIST_ELEMENTS (funclist, node, nnode, functab))
if (functab->lsa_originator != NULL)
if ((* functab->lsa_originator)(lsa_type_dependent) != 0)
goto out;
static int
new_lsa_callback (struct list *funclist, struct ospf_lsa *lsa)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf_opaque_functab *functab;
int rc = -1;
/* This function handles ALL types of LSAs, not only opaque ones. */
- LIST_LOOP (funclist, functab, node)
+ for (ALL_LIST_ELEMENTS (funclist, node, nnode, functab))
if (functab->new_lsa_hook != NULL)
if ((* functab->new_lsa_hook)(lsa) != 0)
goto out;
static int
del_lsa_callback (struct list *funclist, struct ospf_lsa *lsa)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf_opaque_functab *functab;
int rc = -1;
/* This function handles ALL types of LSAs, not only opaque ones. */
- LIST_LOOP (funclist, functab, node)
+ for (ALL_LIST_ELEMENTS (funclist, node, nnode, functab))
if (functab->del_lsa_hook != NULL)
if ((* functab->del_lsa_hook)(lsa) != 0)
goto out;
{
struct ospf *top;
struct ospf_area *area;
- struct listnode *node;
+ struct listnode *node, *nnode;
struct opaque_info_per_type *oipt;
int delay = 0;
if (! list_isempty (ospf_opaque_type9_funclist)
&& ! list_isempty (oi->opaque_lsa_self))
{
- for (node = listhead (oi->opaque_lsa_self); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (oi->opaque_lsa_self, node, nnode, oipt))
{
/*
* removed the test for
* because opaque cababilities ON -> OFF -> ON result in list_isempty (oipt->id_list)
* not being empty.
*/
- if ((oipt = getdata (node)) == NULL /* Something wrong? */
- || oipt->t_opaque_lsa_self != NULL /* Waiting for a thread call. */
- || oipt->status == PROC_SUSPEND) /* Cannot originate now. */
+ if (oipt->t_opaque_lsa_self != NULL /* Waiting for a thread call. */
+ || oipt->status == PROC_SUSPEND) /* Cannot originate now. */
continue;
ospf_opaque_lsa_reoriginate_schedule ((void *) oi,
if (! list_isempty (ospf_opaque_type10_funclist)
&& ! list_isempty (area->opaque_lsa_self))
{
- for (node = listhead (area->opaque_lsa_self); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (area->opaque_lsa_self, node, nnode, oipt))
{
/*
* removed the test for
* because opaque cababilities ON -> OFF -> ON result in list_isempty (oipt->id_list)
* not being empty.
*/
- if ((oipt = getdata (node)) == NULL /* Something wrong? */
- || oipt->t_opaque_lsa_self != NULL /* Waiting for a thread call. */
- || oipt->status == PROC_SUSPEND) /* Cannot originate now. */
+ if (oipt->t_opaque_lsa_self != NULL /* Waiting for a thread call. */
+ || oipt->status == PROC_SUSPEND) /* Cannot originate now. */
continue;
ospf_opaque_lsa_reoriginate_schedule ((void *) area,
if (! list_isempty (ospf_opaque_type11_funclist)
&& ! list_isempty (top->opaque_lsa_self))
{
- for (node = listhead (top->opaque_lsa_self); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (top->opaque_lsa_self, node, nnode, oipt))
{
/*
* removed the test for
* because opaque cababilities ON -> OFF -> ON result in list_isempty (oipt->id_list)
* not being empty.
*/
- if ((oipt = getdata (node)) == NULL /* Something wrong? */
- || oipt->t_opaque_lsa_self != NULL /* Waiting for a thread call. */
- || oipt->status == PROC_SUSPEND) /* Cannot originate now. */
+ if (oipt->t_opaque_lsa_self != NULL /* Waiting for a thread call. */
+ || oipt->status == PROC_SUSPEND) /* Cannot originate now. */
continue;
ospf_opaque_lsa_reoriginate_schedule ((void *) top,
static void
ospf_opaque_lsa_reoriginate_resume (struct list *listtop, void *arg)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct opaque_info_per_type *oipt;
struct ospf_opaque_functab *functab;
* Pickup oipt entries those which in SUSPEND status, and give
* them a chance to start re-origination now.
*/
- LIST_LOOP (listtop, oipt, node)
+ for (ALL_LIST_ELEMENTS (listtop, node, nnode, oipt))
{
if (oipt->status != PROC_SUSPEND)
continue;
{
struct opaque_info_per_type *oipt;
struct ospf_opaque_functab *functab;
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf *top;
struct ospf_area *area;
struct ospf_interface *oi;
/* There must be at least one "opaque-capable, full-state" neighbor. */
n = 0;
- LIST_LOOP (area->oiflist, oi, node)
+ for (ALL_LIST_ELEMENTS (area->oiflist, node, nnode, oi))
{
if ((n = ospf_nbr_count_opaque_capable (oi)) > 0)
break;
struct ospf *top;
struct ospf_area *area;
struct ospf_interface *oi;
- struct listnode *node1, *node2;
+ struct listnode *node1, *nnode1;
+ struct listnode *node2, *nnode2;
struct ospf_lsa *lsa;
if ((top = oi_to_top (nbr->oi)) == NULL)
* Obviously, the latter would trigger miserable situations that repeat
* installation and removal of unwanted LSAs indefinitely.
*/
- for (node1 = listhead (lsas); node1; nextnode (node1))
+ for (ALL_LIST_ELEMENTS (lsas, node1, nnode1, lsa))
{
- if ((lsa = getdata (node1)) == NULL)
- continue;
-
/* Filter out unwanted LSAs. */
if (! IS_OPAQUE_LSA (lsa->data->type))
continue;
break;
case OSPF_OPAQUE_AREA_LSA:
area = nbr->oi->area;
- for (node2 = listhead (area->oiflist); node2; nextnode (node2))
- {
- if ((oi = getdata (node2)) == NULL)
- continue;
- ospf_opaque_exclude_lsa_from_lsreq (oi->nbrs, nbr, lsa);
- }
+ for (ALL_LIST_ELEMENTS (area->oiflist, node2, nnode2, oi))
+ ospf_opaque_exclude_lsa_from_lsreq (oi->nbrs, nbr, lsa);
break;
case OSPF_OPAQUE_AS_LSA:
- for (node2 = listhead (top->oiflist); node2; nextnode (node2))
- {
- if ((oi = getdata (node2)) == NULL)
- continue;
- ospf_opaque_exclude_lsa_from_lsreq (oi->nbrs, nbr, lsa);
- }
+ for (ALL_LIST_ELEMENTS (top->oiflist, node2, nnode2, oi))
+ ospf_opaque_exclude_lsa_from_lsreq (oi->nbrs, nbr, lsa);
break;
default:
break;
before = IS_OPAQUE_LSA_ORIGINATION_BLOCKED (top->opaque);
- for (node = listhead (lsas); node; node = next)
+ for (ALL_LIST_ELEMENTS (lsas, node, next, lsa))
{
- next = node->next;
-
- if ((lsa = getdata (node)) == NULL)
- continue;
-
listnode_delete (lsas, lsa);
/*
ospf_opaque_ls_ack_received (struct ospf_neighbor *nbr, struct list *acks)
{
struct ospf *top;
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf_lsa *lsa;
char type9_lsa_rcv = 0, type10_lsa_rcv = 0, type11_lsa_rcv = 0;
if ((top = oi_to_top (nbr->oi)) == NULL)
goto out;
- LIST_LOOP (acks, lsa, node)
+ for (ALL_LIST_ELEMENTS (acks, node, nnode, lsa))
{
switch (lsa->data->type)
{
/* Ok, let's start origination of Opaque-LSAs. */
delay = OSPF_MIN_LS_INTERVAL;
- LIST_LOOP (top->oiflist, oi, node)
+ for (ALL_LIST_ELEMENTS (top->oiflist, node, nnode, oi))
{
if (! ospf_if_is_enable (oi)
|| ospf_nbr_count_opaque_capable (oi) == 0)
struct ospf_interface *oi;
unsigned long n = 0;
- for (node = listhead (area->oiflist); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (area->oiflist, node, oi))
{
- if ((oi = getdata (node)) == NULL)
- continue;
-
if (area->area_id.s_addr != OSPF_AREA_BACKBONE
- && oi->type == OSPF_IFTYPE_VIRTUALLINK)
+ && oi->type == OSPF_IFTYPE_VIRTUALLINK)
continue;
n = ospf_opaque_nrxmt_self (oi->nbrs, OSPF_OPAQUE_AREA_LSA);
struct ospf_interface *oi;
unsigned long n = 0;
- for (node = listhead (top->oiflist); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (top->oiflist, node, oi))
{
- if ((oi = getdata (node)) == NULL)
- continue;
-
switch (oi->type)
{
case OSPF_IFTYPE_VIRTUALLINK:
auth_key = (char *) "";
else
{
- ck = getdata (OSPF_IF_PARAM (oi, auth_crypt)->tail);
+ ck = listgetdata (listtail(OSPF_IF_PARAM (oi, auth_crypt)));
auth_key = (char *) ck->auth_key;
}
node = listhead (ospf->oi_write_q);
assert (node);
- oi = getdata (node);
+ oi = listgetdata (node);
assert (oi);
#ifdef WANT_OSPF_WRITE_FRAGMENT
void
ospf_upd_list_clean (struct list *lsas)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf_lsa *lsa;
- for (node = listhead (lsas); node; nextnode (node))
- if ((lsa = getdata (node)) != NULL)
- ospf_lsa_discard (lsa);
+ for (ALL_LIST_ELEMENTS (lsas, node, nnode, lsa))
+ ospf_lsa_discard (lsa);
list_delete (lsas);
}
#ifdef HAVE_OPAQUE_LSA
struct list *mylsa_acks, *mylsa_upds;
#endif /* HAVE_OPAQUE_LSA */
- struct listnode *node, *next;
+ struct listnode *node, *nnode;
struct ospf_lsa *lsa = NULL;
/* unsigned long ls_req_found = 0; */
continue; }
/* Process each LSA received in the one packet. */
- for (node = listhead (lsas); node; node = next)
+ for (ALL_LIST_ELEMENTS (lsas, node, nnode, lsa))
{
struct ospf_lsa *ls_ret, *current;
int ret = 1;
- next = node->next;
-
- lsa = getdata (node);
-
if (IS_DEBUG_OSPF_NSSA)
{
char buf1[INET_ADDRSTRLEN];
if(lsa->data->type == OSPF_NETWORK_LSA)
{
- struct listnode *oi_node;
+ struct listnode *oinode, *oinnode;
+ struct ospf_interface *out_if;
int Flag = 0;
- for(oi_node = listhead(oi->ospf->oiflist); oi_node; oi_node = nextnode(oi_node))
+ for (ALL_LIST_ELEMENTS (oi->ospf->oiflist, oinode, oinnode, out_if))
{
- struct ospf_interface *out_if = getdata(oi_node);
if(out_if == NULL)
break;
iph->ip_dst)) == NULL)
return NULL;
- for (node = listhead (ospf->vlinks); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data))
{
- if ((vl_data = getdata (node)) == NULL)
- continue;
-
vl_area = ospf_area_lookup_by_area_id (ospf, vl_data->vl_area_id);
if (!vl_area)
continue;
ret = 0;
break;
case OSPF_AUTH_CRYPTOGRAPHIC:
- if ((ck = getdata (OSPF_IF_PARAM (oi,auth_crypt)->tail)) == NULL)
+ if ((ck = listgetdata (listtail(OSPF_IF_PARAM (oi,auth_crypt)))) == NULL)
{
ret = 0;
break;
}
else
{
- ck = getdata (OSPF_IF_PARAM (oi, auth_crypt)->tail);
+ ck = listgetdata (listtail(OSPF_IF_PARAM (oi, auth_crypt)));
ospfh->u.crypt.zero = 0;
ospfh->u.crypt.key_id = ck->key_id;
ospfh->u.crypt.auth_data_len = OSPF_AUTH_MD5_SIZE;
if (IS_DEBUG_OSPF_EVENT)
zlog_debug ("ospf_make_ls_upd: List Iteration");
- lsa = getdata (node);
- assert (lsa);
+ lsa = listgetdata (node);
+
assert (lsa->data);
/* Will it fit? */
rm_list = list_new ();
- for (node = listhead (ack); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ack, node, lsa))
{
- lsa = getdata (node);
+ lsa = listgetdata (node);
assert (lsa);
if (length + delta > ospf_packet_max (oi))
}
/* Remove LSA from LS-Ack list. */
- for (node = listhead (rm_list); node; nextnode (node))
+ /* XXX: this loop should be removed and the list move done in previous
+ * loop
+ */
+ for (ALL_LIST_ELEMENTS_RO (rm_list, node, lsa))
{
- lsa = (struct ospf_lsa *) getdata (node);
-
listnode_delete (ack, lsa);
ospf_lsa_unlock (lsa);
}
size_t size;
static char warned = 0;
- ln = listhead (update);
- lsa = getdata (ln);
- assert (lsa);
+ lsa = listgetdata((ln = listhead (update)));
assert (lsa->data);
if ((OSPF_LS_UPD_MIN_SIZE + ntohs (lsa->data->length))
ospf_ls_upd_send (struct ospf_neighbor *nbr, struct list *update, int flag)
{
struct ospf_interface *oi;
+ struct ospf_lsa *lsa;
struct prefix_ipv4 p;
struct route_node *rn;
- struct listnode *n;
+ struct listnode *node;
oi = nbr->oi;
if (rn->info == NULL)
rn->info = list_new ();
- for (n = listhead (update); n; nextnode (n))
- listnode_add (rn->info, ospf_lsa_lock (getdata (n)));
+ for (ALL_LIST_ELEMENTS_RO (update, node, lsa))
+ {
+ ospf_lsa_lock (lsa);
+ listnode_add (rn->info, lsa);
+ }
if (oi->t_ls_upd_event == NULL)
oi->t_ls_upd_event =
/* Check each path. */
for (n1 = listhead (or->paths), n2 = listhead (newor->paths);
- n1 && n2; nextnode (n1), nextnode (n2))
+ n1 && n2; n1 = listnextnode (n1), n2 = listnextnode (n2))
{
- op = getdata (n1);
- newop = getdata (n2);
+ op = listgetdata (n1);
+ newop = listgetdata (n2);
if (! IPV4_ADDR_SAME (&op->nexthop, &newop->nexthop))
return 0;
struct prefix_ipv4 p;
struct ospf_path *path;
struct vertex_nexthop *nexthop;
- struct listnode *nnode;
+ struct listnode *node, *nnode;
p.family = AF_INET;
p.prefix = v->id;
{
or->type = OSPF_DESTINATION_NETWORK;
- LIST_LOOP (v->nexthop, nexthop, nnode)
+ for (ALL_LIST_ELEMENTS (v->nexthop, node, nnode, nexthop))
{
- nexthop = getdata (nnode);
path = ospf_path_new ();
path->nexthop = nexthop->router;
listnode_add (or->paths, path);
BUFSIZ),
ospf_path_type_str[or->path_type],
or->cost);
- for (pnode = listhead (or->paths); pnode; nextnode (pnode))
- {
- path = getdata (pnode);
- zlog_debug (" -> %s", inet_ntoa (path->nexthop));
- }
+ for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path))
+ zlog_debug (" -> %s", inet_ntoa (path->nexthop));
}
else
zlog_debug ("R %s\t%s\t%s\t%d",
ospf_terminate ()
{
struct ospf *ospf;
- struct listnode *node;
+ struct listnode *node, *nnode;
- LIST_LOOP (om->ospf, ospf, node)
+ for (ALL_LIST_ELEMENTS (om->ospf, node, nnode, ospf))
{
if (ospf->new_table)
ospf_route_delete (ospf->new_table);
ospf_path_exist (struct list *plist, struct in_addr nexthop,
struct ospf_interface *oi)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf_path *path;
- for (node = listhead (plist); node; nextnode (node))
- {
- path = node->data;
+ for (ALL_LIST_ELEMENTS (plist, node, nnode, path))
+ if (IPV4_ADDR_SAME (&path->nexthop, &nexthop) && path->oi == oi)
+ return 1;
- if (IPV4_ADDR_SAME (&path->nexthop, &nexthop) && path->oi == oi)
- return 1;
- }
return 0;
}
ospf_route_copy_nexthops_from_vertex (struct ospf_route *to,
struct vertex *v)
{
- struct listnode *nnode;
+ struct listnode *node;
struct ospf_path *path;
struct vertex_nexthop *nexthop;
assert (to->paths);
- for (nnode = listhead (v->nexthop); nnode; nextnode (nnode))
+ for (ALL_LIST_ELEMENTS_RO (v->nexthop, node, nexthop))
{
- nexthop = getdata (nnode);
-
if (nexthop->oi != NULL)
{
if (! ospf_path_exist (to->paths, nexthop->router, nexthop->oi))
ospf_path_lookup (struct list *plist, struct ospf_path *path)
{
struct listnode *node;
+ struct ospf_path *op;
- for (node = listhead (plist); node; nextnode (node))
- {
- struct ospf_path *op = node->data;
-
- if (IPV4_ADDR_SAME (&op->nexthop, &path->nexthop) &&
- IPV4_ADDR_SAME (&op->adv_router, &path->adv_router))
- return op;
- }
+ for (ALL_LIST_ELEMENTS_RO (plist, node, op))
+ if (IPV4_ADDR_SAME (&op->nexthop, &path->nexthop) &&
+ IPV4_ADDR_SAME (&op->adv_router, &path->adv_router))
+ return op;
return NULL;
}
void
ospf_route_copy_nexthops (struct ospf_route *to, struct list *from)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
+ struct ospf_path *path;
assert (to->paths);
- for (node = listhead (from); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (from, node, nnode, path))
/* The same routes are just discarded. */
- if (!ospf_path_lookup (to->paths, node->data))
- listnode_add (to->paths, ospf_path_dup (node->data));
+ if (!ospf_path_lookup (to->paths, path))
+ listnode_add (to->paths, ospf_path_dup (path));
}
void
{
struct route_node *rn, *next;
struct ospf_route *or;
- struct listnode *node, *nnext;
+ struct listnode *node, *nnode;
struct list *paths;
if (IS_DEBUG_OSPF_EVENT)
if ((paths = rn->info) == NULL)
continue;
- for (node = listhead (paths); node; node = nnext)
+ for (ALL_LIST_ELEMENTS (paths, node, nnode, or))
{
- nnext = node->next;
-
- or = getdata (node);
-
if (listcount (or->paths) == 0)
{
if (IS_DEBUG_OSPF_EVENT)
if (ospf == NULL)
return 0;
- for (node = listhead (ospf->oiflist); node; nextnode (node))
- {
- oi = getdata (node);
+ for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
+ if (oi && oi->address)
+ return 1;
- if (oi && oi->address)
- return 1;
- }
return 0;
}
node = listhead (ospf->areas);
if (node)
{
- area = getdata (node);
+ area = listgetdata (node);
*area_id = area->area_id;
return area;
}
return NULL;
}
- for (node = listhead (ospf->areas); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
{
- area = getdata (node);
-
if (ntohl (area->area_id.s_addr) > ntohl (area_id->s_addr))
{
*area_id = area->area_id;
if (ospf == NULL)
return NULL;
- for (node = listhead (ospf->areas); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
{
- area = getdata (node);
-
if (area->external_routing == OSPF_AREA_STUB)
{
if (first)
void
ospf_snmp_if_delete (struct interface *ifp)
{
- struct listnode *nn;
+ struct listnode *node, *nnode;
struct ospf_snmp_if *osif;
- LIST_LOOP (ospf_snmp_iflist, osif, nn)
+ for (ALL_LIST_ELEMENTS (ospf_snmp_iflist, node, nnode, osif))
{
if (osif->ifp == ifp)
{
- list_delete_node (ospf_snmp_iflist, nn);
+ list_delete_node (ospf_snmp_iflist, node);
ospf_snmp_if_free (osif);
return;
}
void
ospf_snmp_if_update (struct interface *ifp)
{
- struct listnode *nn;
+ struct listnode *node;
struct listnode *pn;
struct connected *ifc;
struct prefix *p;
ifindex = 0;
/* Lookup first IPv4 address entry. */
- LIST_LOOP (ifp->connected, ifc, nn)
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, ifc))
{
if (CONNECTED_POINTOPOINT_HOST(ifc))
p = ifc->destination;
/* Add interface to the list. */
pn = NULL;
- LIST_LOOP (ospf_snmp_iflist, osif, nn)
+ for (ALL_LIST_ELEMENTS_RO (ospf_snmp_iflist, node, osif))
{
if (addr)
{
if (osif->addr.s_addr != 0 || osif->ifindex > ifindex)
break;
}
- pn = nn;
+ pn = node;
}
osif = ospf_snmp_if_new ();
struct interface *
ospf_snmp_if_lookup (struct in_addr *ifaddr, unsigned int *ifindex)
{
- struct listnode *nn;
+ struct listnode *node;
struct ospf_snmp_if *osif;
- LIST_LOOP (ospf_snmp_iflist, osif, nn)
+ for (ALL_LIST_ELEMENTS_RO (ospf_snmp_iflist, node, osif))
{
if (ifaddr->s_addr)
{
nn = listhead (ospf_snmp_iflist);
if (nn)
{
- osif = getdata (nn);
+ osif = listgetdata (nn);
*ifaddr = osif->addr;
*ifindex = osif->ifindex;
return osif->ifp;
return NULL;
}
- LIST_LOOP (ospf_snmp_iflist, osif, nn)
+ for (ALL_LIST_ELEMENTS_RO (ospf_snmp_iflist, nn, osif))
{
if (ifaddr->s_addr)
{
ospf_snmp_nbr_lookup (struct ospf *ospf, struct in_addr *nbr_addr,
unsigned int *ifindex)
{
- struct listnode *nn;
+ struct listnode *node, *nnode;
struct ospf_interface *oi;
struct ospf_neighbor *nbr;
struct route_node *rn;
- LIST_LOOP (ospf->oiflist, oi, nn)
+ for (ALL_LIST_ELEMENTS (ospf->oiflist, node, nnode, oi))
{
for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
if ((nbr = rn->info) != NULL
struct ospf *ospf = ospf;
ospf = ospf_lookup ();
- LIST_LOOP (ospf->oiflist, oi, nn)
+
+ for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, nn, oi))
{
for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
if ((nbr = rn->info) != NULL
void
ospf_vertex_free (struct vertex *v)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
+ struct vertex_nexthop *nh;
list_delete (v->child);
if (listcount (v->nexthop) > 0)
- for (node = listhead (v->nexthop); node; nextnode (node))
- vertex_nexthop_free (node->data);
+ for (ALL_LIST_ELEMENTS (v->nexthop, node, nnode, nh))
+ vertex_nexthop_free (nh);
list_delete (v->nexthop);
if (print_nexthops)
{
- struct listnode *nnode;
- for (nnode = listhead (v->nexthop); nnode; nextnode (nnode))
+ struct listnode *node;
+ struct vertex_nexthop *nexthop;
+
+ for (ALL_LIST_ELEMENTS_RO (v->nexthop, node, nexthop))
{
char buf1[BUFSIZ];
char buf2[BUFSIZ];
- struct vertex_nexthop *nexthop;
- nexthop = getdata (nnode);
if (nexthop)
{
zlog_debug (" nexthop %s interface %s parent %s",
if (print_children)
{
struct listnode *cnode;
- for (cnode = listhead (v->child); cnode; nextnode (cnode))
- {
- struct vertex *cv = getdata (cnode);
- if (cv)
- ospf_vertex_dump(" child:", cv, 0, 0);
- }
+ struct vertex *cv;
+
+ for (ALL_LIST_ELEMENTS_RO (v->child, cnode, cv))
+ ospf_vertex_dump(" child:", cv, 0, 0);
}
}
struct vertex_nexthop *nh;
struct listnode *node;
- for (node = listhead (v->nexthop); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (v->nexthop, node, nh))
{
- nh = (struct vertex_nexthop *) getdata (node);
-
/* No need to add two links from the same parent. */
if (listnode_lookup (nh->parent->child, v) == NULL)
listnode_add (nh->parent->child, v);
int match;
match = 0;
- for (node = listhead (nexthop); node; nextnode (node))
- {
- nh = node->data;
+ for (ALL_LIST_ELEMENTS_RO (nexthop, node, nh))
+ {
/* Compare the two entries. */
/* XXX
* Comparing the parent preserves the shortest path tree
void
ospf_nexthop_merge (struct list *a, struct list *b)
{
- struct listnode *n;
+ struct listnode *node, *nnode;
+ struct vertex_nexthop *nh;
- for (n = listhead (b); n; nextnode (n))
- {
- ospf_nexthop_add_unique (n->data, a);
- }
+ for (ALL_LIST_ELEMENTS (b, node, nnode, nh))
+ ospf_nexthop_add_unique (nh, a);
}
#define ROUTER_LSA_MIN_SIZE 12
*/
if (nexthops->head != NULL)
{
- hop = getdata (nexthops->head);
+ hop = listgetdata (nexthops->head);
/* weed out hops with higher cost than the newhop */
if (hop->oi->output_cost > newhop->oi->output_cost)
{
/* delete the existing nexthops */
- for (ln = nexthops->head; ln; ln = nn)
+ for (ALL_LIST_ELEMENTS (nexthops, ln, nn, hop))
{
- nn = ln->next;
- hop = getdata (ln);
-
listnode_delete (nexthops, hop);
vertex_nexthop_free (hop);
}
ospf_nexthop_calculation (struct ospf_area *area,
struct vertex *v, struct vertex *w)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct vertex_nexthop *nh, *x;
struct ospf_interface *oi = NULL;
struct router_lsa_link *l = NULL;
if (IS_DEBUG_OSPF_EVENT)
{
char buf1[BUFSIZ];
+ char buf2[BUFSIZ];
+
zlog_debug("ospf_nexthop_calculation(): considering link "
"type %d link_id %s link_data %s",
l->m[0].type,
inet_ntop (AF_INET, &l->link_id, buf1, BUFSIZ),
- inet_ntop (AF_INET, &l->link_data, buf1, BUFSIZ));
+ inet_ntop (AF_INET, &l->link_data, buf2, BUFSIZ));
}
if (l->m[0].type == LSA_LINK_TYPE_POINTOPOINT)
else if (v->type == OSPF_VERTEX_NETWORK)
{
/* See if any of V's parents are the root. */
- for (node = listhead (v->nexthop); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (v->nexthop, node, nnode, x))
{
- x = (struct vertex_nexthop *) getdata (node);
if (x->parent == area->spf) /* connects to root? */
{
/* 16.1.1 para 5. ...the parent vertex is a network that
* destination simply inherits the set of next hops from the
* parent.
*/
- for (node = listhead (v->nexthop); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (v->nexthop, node, nnode, nh))
{
- nh = vertex_nexthop_dup (node->data);
nh->parent = v;
ospf_nexthop_add_unique (nh, w->nexthop);
}
ip_masklen (lsa->mask));
}
- for (nnode = listhead (v->nexthop); nnode; nextnode (nnode))
- {
- nexthop = getdata (nnode);
- if (IS_DEBUG_OSPF_EVENT)
- zlog_debug (" nexthop %s", inet_ntoa (nexthop->router));
- }
+ if (IS_DEBUG_OSPF_EVENT)
+ for (ALL_LIST_ELEMENTS_RO (v->nexthop, nnode, nexthop))
+ zlog_debug (" nexthop %s", inet_ntoa (nexthop->router));
i++;
- for (cnode = listhead (v->child); cnode; nextnode (cnode))
- {
- v = getdata (cnode);
- ospf_spf_dump (v, i);
- }
+ for (ALL_LIST_ELEMENTS_RO (v->child, cnode, v))
+ ospf_spf_dump (v, i);
}
/* Second stage of SPF calculation. */
ospf_spf_process_stubs (struct ospf_area *area, struct vertex *v,
struct route_table *rt)
{
- struct listnode *cnode;
+ struct listnode *cnode, *cnnode;
struct vertex *child;
if (IS_DEBUG_OSPF_EVENT)
ospf_vertex_dump("ospf_process_stubs(): after examining links: ", v, 1, 1);
- for (cnode = listhead (v->child); cnode; nextnode (cnode))
+ for (ALL_LIST_ELEMENTS (v->child, cnode, cnnode, child))
{
- child = getdata (cnode);
-
if (CHECK_FLAG (child->flags, OSPF_VERTEX_PROCESSED))
continue;
{
struct route_node *rn;
struct list *or_list;
- struct listnode *node;
+ struct ospf_route *or;
+ struct listnode *node, *nnode;
if (IS_DEBUG_OSPF_EVENT)
zlog_debug ("Route: Router Routing Table free");
for (rn = route_top (rtrs); rn; rn = route_next (rn))
if ((or_list = rn->info) != NULL)
{
- for (node = listhead (or_list); node; nextnode (node))
- ospf_route_free (node->data);
+ for (ALL_LIST_ELEMENTS (or_list, node, nnode, or))
+ ospf_route_free (or);
list_delete (or_list);
for (rn = route_top (rtrs); rn; rn = route_next (rn))
if ((or_list = rn->info) != NULL)
- for (ln = listhead (or_list); ln; nextnode (ln))
+ for (ALL_LIST_ELEMENTS_RO (or_list, ln, or))
{
- or = getdata (ln);
-
switch (or->path_type)
{
case OSPF_PATH_INTRA_AREA:
break;
}
- for (pnode = listhead (or->paths); pnode; nextnode (pnode))
+ for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path))
{
- path = getdata (pnode);
if (path->nexthop.s_addr == 0)
{
if (IS_DEBUG_OSPF_EVENT)
{
struct ospf *ospf = THREAD_ARG (thread);
struct route_table *new_table, *new_rtrs;
- struct listnode *node;
+ struct ospf_area *area;
+ struct listnode *node, *nnode;
if (IS_DEBUG_OSPF_EVENT)
zlog_debug ("SPF: Timer (SPF calculation expire)");
ospf_vl_unapprove (ospf);
/* Calculate SPF for each area. */
- for (node = listhead (ospf->areas); node; node = nextnode (node))
- ospf_spf_calculate (node->data, new_table, new_rtrs);
+ for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
+ ospf_spf_calculate (area, new_table, new_rtrs);
ospf_vl_shut_unapproved (ospf);
static struct mpls_te_link *
lookup_linkparams_by_ifp (struct interface *ifp)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct mpls_te_link *lp;
- LIST_LOOP (OspfMplsTE.iflist, lp, node)
+ for (ALL_LIST_ELEMENTS (OspfMplsTE.iflist, node, nnode, lp))
if (lp->ifp == ifp)
return lp;
struct mpls_te_link *lp;
unsigned int key = GET_OPAQUE_ID (ntohl (lsa->data->id.s_addr));
- LIST_LOOP (OspfMplsTE.iflist, lp, node)
+ for (ALL_LIST_ELEMENTS_RO (OspfMplsTE.iflist, node, lp))
if (lp->instance == key)
return lp;
void (*func)(struct mpls_te_link *lp, enum sched_opcode),
enum sched_opcode sched_opcode)
{
- struct listnode *node, *node2;
+ struct listnode *node, *nnode;
+ struct listnode *node2;
struct mpls_te_link *lp;
struct ospf_area *area;
- LIST_LOOP (OspfMplsTE.iflist, lp, node)
+ for (ALL_LIST_ELEMENTS (OspfMplsTE.iflist, node, nnode, lp))
{
if ((area = lp->area) == NULL)
continue;
if (func != NULL)
(* func)(lp, sched_opcode);
- for (node2 = nextnode (node); node2; nextnode (node2))
- if ((lp = getdata (node2)) != NULL)
+ for (node2 = listnextnode (node); node2; node2 = listnextnode (node2))
+ if ((lp = listgetdata (node2)) != NULL)
if (lp->area != NULL)
if (IPV4_ADDR_SAME (&lp->area->area_id, &area->area_id))
lp->flags |= LPFLG_LOOKUP_DONE;
}
- LIST_LOOP (OspfMplsTE.iflist, lp, node)
+ for (ALL_LIST_ELEMENTS_RO (OspfMplsTE.iflist, node, lp))
if (lp->area != NULL)
lp->flags &= ~LPFLG_LOOKUP_DONE;
ospf_mpls_te_lsa_originate (void *arg)
{
struct ospf_area *area = (struct ospf_area *) arg;
- struct listnode *node;
+ struct listnode *node, *nnode;
struct mpls_te_link *lp;
int rc = -1;
goto out;
}
- for (node = listhead (OspfMplsTE.iflist); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (OspfMplsTE.iflist, node, nnode, lp))
{
- if ((lp = getdata (node)) == NULL)
- continue;
if (lp->area == NULL)
continue;
if (! IPV4_ADDR_SAME (&lp->area->area_id, &area->area_id))
"Configure MPLS-TE parameters\n"
"Enable the MPLS-TE functionality\n")
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct mpls_te_link *lp;
if (OspfMplsTE.status == enabled)
* 1) MPLS-TE was disabled at startup time, but now become enabled.
* 2) MPLS-TE was once enabled then disabled, and now enabled again.
*/
- for (node = listhead (OspfMplsTE.iflist); node; nextnode (node))
- if ((lp = getdata (node)) != NULL)
- initialize_linkparams (lp);
+ for (ALL_LIST_ELEMENTS (OspfMplsTE.iflist, node, nnode, lp))
+ initialize_linkparams (lp);
ospf_mpls_te_foreach_area (ospf_mpls_te_lsa_schedule, REORIGINATE_PER_AREA);
"Configure MPLS-TE parameters\n"
"Disable the MPLS-TE functionality\n")
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct mpls_te_link *lp;
if (OspfMplsTE.status == disabled)
OspfMplsTE.status = disabled;
- for (node = listhead (OspfMplsTE.iflist); node; nextnode (node))
- if ((lp = getdata (node)) != NULL)
- if (lp->area != NULL)
- if (lp->flags & LPFLG_LSA_ENGAGED)
- ospf_mpls_te_lsa_schedule (lp, FLUSH_THIS_LSA);
+ for (ALL_LIST_ELEMENTS (OspfMplsTE.iflist, node, nnode, lp))
+ if (lp->area != NULL)
+ if (lp->flags & LPFLG_LSA_ENGAGED)
+ ospf_mpls_te_lsa_schedule (lp, FLUSH_THIS_LSA);
return CMD_SUCCESS;
}
if (ntohs (ra->header.type) == 0
|| ntohl (ra->value.s_addr) != ntohl (value.s_addr))
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct mpls_te_link *lp;
int need_to_reoriginate = 0;
if (OspfMplsTE.status == disabled)
goto out;
- LIST_LOOP (OspfMplsTE.iflist, lp, node)
+ for (ALL_LIST_ELEMENTS (OspfMplsTE.iflist, node, nnode, lp))
{
if (lp->area == NULL)
continue;
break;
}
}
- for (node = listhead (OspfMplsTE.iflist); node; nextnode (node))
- LIST_LOOP (OspfMplsTE.iflist, lp, node)
+
+ for (ALL_LIST_ELEMENTS (OspfMplsTE.iflist, node, nnode, lp))
{
if (lp->area == NULL)
continue;
"Interface name\n")
{
struct interface *ifp;
- struct listnode *node;
+ struct listnode *node, *nnode;
/* Show All Interfaces. */
if (argc == 0)
{
- LIST_LOOP (iflist, ifp, node)
- show_mpls_te_link_sub (vty, ifp);
+ for (ALL_LIST_ELEMENTS (iflist, node, nnode, ifp))
+ show_mpls_te_link_sub (vty, ifp);
}
/* Interface name is specified. */
else
struct ospf *ospf = vty->index;
u_int32_t refbw;
struct listnode *node;
+ struct interface *ifp;
refbw = strtol (argv[0], NULL, 10);
if (refbw < 1 || refbw > 4294967)
vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE);
vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE);
- for (node = listhead (om->iflist); node; nextnode (node))
- ospf_if_recalculate_output_cost (getdata (node));
+ for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
+ ospf_if_recalculate_output_cost (ifp);
return CMD_SUCCESS;
}
"Use reference bandwidth method to assign OSPF cost\n")
{
struct ospf *ospf = vty->index;
- struct listnode *node;
+ struct listnode *node, *nnode;
+ struct interface *ifp;
if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH)
return CMD_SUCCESS;
vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE);
vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE);
- for (node = listhead (om->iflist); node; nextnode (node))
- ospf_if_recalculate_output_cost (getdata (node));
+ for (ALL_LIST_ELEMENTS (om->iflist, node, nnode, ifp))
+ ospf_if_recalculate_output_cost (ifp);
return CMD_SUCCESS;
}
IP_STR
"OSPF information\n")
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf_area * area;
struct ospf *ospf;
listcount (ospf->areas), VTY_NEWLINE, VTY_NEWLINE);
/* Show each area status. */
- for (node = listhead (ospf->areas); node; nextnode (node))
- if ((area = getdata (node)) != NULL)
- show_ip_ospf_area (vty, area);
+ for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
+ show_ip_ospf_area (vty, area);
return CMD_SUCCESS;
}
/* Show All Interfaces. */
if (argc == 0)
- for (node = listhead (iflist); node; nextnode (node))
- show_ip_ospf_interface_sub (vty, ospf, node->data);
+ for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
+ show_ip_ospf_interface_sub (vty, ospf, ifp);
/* Interface name is specified. */
else
{
"Neighbor list\n")
{
struct ospf *ospf;
+ struct ospf_interface *oi;
struct listnode *node;
ospf = ospf_lookup ();
"Time Address Interface RXmtL "
"RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE);
- for (node = listhead (ospf->oiflist); node; nextnode (node))
- show_ip_ospf_neighbor_sub (vty, getdata (node));
+ for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
+ show_ip_ospf_neighbor_sub (vty, oi);
return CMD_SUCCESS;
}
{
struct ospf *ospf = vty->index;
struct listnode *node;
+ struct ospf_interface *oi;
if (ospf == NULL)
{
"Time Address Interface RXmtL "
"RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE);
- for (node = listhead (ospf->oiflist); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
{
- struct ospf_interface *oi = getdata (node);
struct listnode *nbr_node;
+ struct ospf_nbr_nbma *nbr_nbma;
show_ip_ospf_neighbor_sub (vty, oi);
/* print Down neighbor status */
- for (nbr_node = listhead (oi->nbr_nbma); nbr_node; nextnode (nbr_node))
+ for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nbr_node, nbr_nbma))
{
- struct ospf_nbr_nbma *nbr_nbma;
-
- nbr_nbma = getdata (nbr_node);
-
if (nbr_nbma->nbr == NULL
|| nbr_nbma->nbr->state == NSM_Down)
{
struct ospf *ospf;
struct listnode *node;
struct ospf_neighbor *nbr;
+ struct ospf_interface *oi;
struct in_addr router_id;
int ret;
return CMD_SUCCESS;
}
- for (node = listhead (ospf->oiflist); node; nextnode (node))
- {
- struct ospf_interface *oi = getdata (node);
-
- if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id)))
- {
- show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
- return CMD_SUCCESS;
- }
- }
+ for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
+ if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id)))
+ {
+ show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
+ return CMD_SUCCESS;
+ }
/* Nothing to show. */
return CMD_SUCCESS;
"detail of all neighbors\n")
{
struct ospf *ospf;
+ struct ospf_interface *oi;
struct listnode *node;
ospf = ospf_lookup ();
return CMD_SUCCESS;
}
- for (node = listhead (ospf->oiflist); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
{
- struct ospf_interface *oi = getdata (node);
struct route_node *rn;
struct ospf_neighbor *nbr;
{
struct ospf *ospf;
struct listnode *node;
+ struct ospf_interface *oi;
ospf = ospf_lookup ();
if (ospf == NULL)
return CMD_SUCCESS;
}
- for (node = listhead (ospf->oiflist); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
{
- struct ospf_interface *oi = getdata (node);
struct route_node *rn;
struct ospf_neighbor *nbr;
+ struct ospf_nbr_nbma *nbr_nbma;
for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
if ((nbr = rn->info))
{
struct listnode *nd;
- for (nd = listhead (oi->nbr_nbma); nd; nextnode (nd))
- {
- struct ospf_nbr_nbma *nbr_nbma = getdata (nd);
- if (nbr_nbma->nbr == NULL
- || nbr_nbma->nbr->state == NSM_Down)
- show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma);
- }
+ for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nd, nbr_nbma))
+ if (nbr_nbma->nbr == NULL
+ || nbr_nbma->nbr->state == NSM_Down)
+ show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma);
}
}
struct in_addr *id, struct in_addr *adv_router)
{
struct listnode *node;
-
+ struct ospf_area *area;
+
switch (type)
{
case OSPF_AS_EXTERNAL_LSA:
show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router);
break;
default:
- for (node = listhead (ospf->areas); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
{
- struct ospf_area *area = node->data;
vty_out (vty, "%s %s (Area %s)%s%s",
VTY_NEWLINE, show_database_desc[type],
ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
struct in_addr *adv_router)
{
struct listnode *node;
+ struct ospf_area *area;
switch (type)
{
adv_router);
break;
default:
- for (node = listhead (ospf->areas); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
{
- struct ospf_area *area = node->data;
vty_out (vty, "%s %s (Area %s)%s%s",
VTY_NEWLINE, show_database_desc[type],
ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
{
struct ospf_lsa *lsa;
struct route_node *rn;
+ struct ospf_area *area;
struct listnode *node;
int type;
- for (node = listhead (ospf->areas); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
{
- struct ospf_area *area = node->data;
for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
{
switch (type)
vty_out (vty, "%s MaxAge Link States:%s%s",
VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
- for (node = listhead (ospf->maxage_lsa); node; nextnode (node))
- if ((lsa = node->data) != NULL)
- {
- vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE);
- vty_out (vty, "Link State ID: %s%s",
- inet_ntoa (lsa->data->id), VTY_NEWLINE);
- vty_out (vty, "Advertising Router: %s%s",
- inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
- vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE);
- vty_out (vty, "%s", VTY_NEWLINE);
- }
+ for (ALL_LIST_ELEMENTS_RO (ospf->maxage_lsa, node, lsa))
+ {
+ vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE);
+ vty_out (vty, "Link State ID: %s%s",
+ inet_ntoa (lsa->data->id), VTY_NEWLINE);
+ vty_out (vty, "Advertising Router: %s%s",
+ inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
+ vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE);
+ vty_out (vty, "%s", VTY_NEWLINE);
+ }
}
#define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
{
struct route_node *rn;
struct ospf_route *or;
- struct listnode *pnode;
+ struct listnode *pnode, *pnnode;
struct ospf_path *path;
vty_out (vty, "============ OSPF network routing table ============%s",
}
if (or->type == OSPF_DESTINATION_NETWORK)
- LIST_LOOP (or->paths, path, pnode)
+ for (ALL_LIST_ELEMENTS (or->paths, pnode, pnnode, path))
{
if (path->oi != NULL)
{
{
struct route_node *rn;
struct ospf_route *or;
- struct listnode *pn, *nn;
+ struct listnode *pnode;
+ struct listnode *node;
struct ospf_path *path;
vty_out (vty, "============ OSPF router routing table =============%s",
vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4));
- for (nn = listhead ((struct list *) rn->info); nn; nextnode (nn))
- if ((or = getdata (nn)) != NULL)
- {
- if (flag++)
- vty_out (vty, "%24s", "");
-
- /* Show path. */
- vty_out (vty, "%s [%d] area: %s",
- (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "),
- or->cost, inet_ntoa (or->u.std.area_id));
- /* Show flags. */
- vty_out (vty, "%s%s%s",
- (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""),
- (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""),
- VTY_NEWLINE);
-
- LIST_LOOP (or->paths, path, pn)
- {
- if (path->nexthop.s_addr == 0)
- vty_out (vty, "%24s directly attached to %s%s",
- "", path->oi->ifp->name, VTY_NEWLINE);
- else
- vty_out (vty, "%24s via %s, %s%s", "",
- inet_ntoa (path->nexthop), path->oi->ifp->name,
- VTY_NEWLINE);
- }
- }
+ for (ALL_LIST_ELEMENTS_RO ((struct list *)rn->info, node, or))
+ {
+ if (flag++)
+ vty_out (vty, "%24s", "");
+
+ /* Show path. */
+ vty_out (vty, "%s [%d] area: %s",
+ (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "),
+ or->cost, inet_ntoa (or->u.std.area_id));
+ /* Show flags. */
+ vty_out (vty, "%s%s%s",
+ (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""),
+ (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""),
+ VTY_NEWLINE);
+
+ for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path))
+ {
+ if (path->nexthop.s_addr == 0)
+ vty_out (vty, "%24s directly attached to %s%s",
+ "", path->oi->ifp->name, VTY_NEWLINE);
+ else
+ vty_out (vty, "%24s via %s, %s%s", "",
+ inet_ntoa (path->nexthop), path->oi->ifp->name,
+ VTY_NEWLINE);
+ }
+ }
}
vty_out (vty, "%s", VTY_NEWLINE);
}
{
struct route_node *rn;
struct ospf_route *er;
- struct listnode *pnode;
+ struct listnode *pnode, *pnnode;
struct ospf_path *path;
vty_out (vty, "============ OSPF external routing table ===========%s",
break;
}
- LIST_LOOP (er->paths, path, pnode)
+ for (ALL_LIST_ELEMENTS (er->paths, pnode, pnnode, path))
{
if (path->oi != NULL)
{
struct route_node *rn = NULL;
struct ospf_if_params *params;
- for (n1 = listhead (iflist); n1; nextnode (n1))
+ for (ALL_LIST_ELEMENTS_RO (iflist, n1, ifp))
{
- ifp = getdata (n1);
-
if (memcmp (ifp->name, "VLINK", 5) == 0)
continue;
}
/* Cryptographic Authentication Key print. */
- for (n2 = listhead (params->auth_crypt); n2; nextnode (n2))
+ for (ALL_LIST_ELEMENTS_RO (params->auth_crypt, n2, ck))
{
- ck = getdata (n2);
vty_out (vty, " ip ospf message-digest-key %d md5 %s",
ck->key_id, ck->auth_key);
if (params != IF_DEF_PARAMS (ifp))
config_write_ospf_area (struct vty *vty, struct ospf *ospf)
{
struct listnode *node;
+ struct ospf_area *area;
u_char buf[INET_ADDRSTRLEN];
/* Area configuration print. */
- for (node = listhead (ospf->areas); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
{
- struct ospf_area *area = getdata (node);
struct route_node *rn1;
area_id2str ((char *) buf, INET_ADDRSTRLEN, area);
config_write_virtual_link (struct vty *vty, struct ospf *ospf)
{
struct listnode *node;
+ struct ospf_vl_data *vl_data;
u_char buf[INET_ADDRSTRLEN];
/* Virtual-Link print */
- for (node = listhead (ospf->vlinks); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data))
{
struct listnode *n2;
struct crypt_key *ck;
- struct ospf_vl_data *vl_data = getdata (node);
struct ospf_interface *oi;
if (vl_data != NULL)
IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple,
VTY_NEWLINE);
/* md5 keys */
- for (n2 = listhead (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt); n2; nextnode (n2))
- {
- ck = getdata (n2);
- vty_out (vty, " area %s virtual-link %s message-digest-key %d md5 %s%s",
- buf,
- inet_ntoa (vl_data->vl_peer),
- ck->key_id, ck->auth_key, VTY_NEWLINE);
- }
+ for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt,
+ n2, ck))
+ vty_out (vty, " area %s virtual-link %s"
+ " message-digest-key %d md5 %s%s",
+ buf,
+ inet_ntoa (vl_data->vl_peer),
+ ck->key_id, ck->auth_key, VTY_NEWLINE);
}
}
ospf_config_write (struct vty *vty)
{
struct ospf *ospf;
+ struct interface *ifp;
+ struct ospf_interface *oi;
struct listnode *node;
int write = 0;
config_write_ospf_redistribute (vty, ospf);
/* passive-interface print. */
- for (node = listhead (om->iflist); node; nextnode (node))
- {
- struct interface *ifp = getdata (node);
-
- if (!ifp)
- continue;
- if (IF_DEF_PARAMS (ifp)->passive_interface == OSPF_IF_PASSIVE)
- vty_out (vty, " passive-interface %s%s",
- ifp->name, VTY_NEWLINE);
- }
-
- for (node = listhead (ospf->oiflist); node; nextnode (node))
- {
- struct ospf_interface *oi = getdata (node);
-
- if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface) &&
- oi->params->passive_interface == OSPF_IF_PASSIVE)
- vty_out (vty, " passive-interface %s %s%s",
- oi->ifp->name,
- inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE);
- }
-
+ for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
+ if (IF_DEF_PARAMS (ifp)->passive_interface == OSPF_IF_PASSIVE)
+ vty_out (vty, " passive-interface %s%s",
+ ifp->name, VTY_NEWLINE);
+
+ for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
+ if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface) &&
+ oi->params->passive_interface == OSPF_IF_PASSIVE)
+ vty_out (vty, " passive-interface %s %s%s",
+ oi->ifp->name,
+ inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE);
/* Network area print. */
config_write_network_area (vty, ospf);
stream_putc (s, or->paths->count);
/* Nexthop, ifindex, distance and metric information. */
- for (node = listhead (or->paths); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (or->paths, node, path))
{
- path = getdata (node);
-
if (path->nexthop.s_addr != INADDR_ANY)
{
stream_putc (s, ZEBRA_NEXTHOP_IPV4);
struct zapi_ipv4 api;
struct ospf_path *path;
struct in_addr *nexthop;
- struct listnode *node;
+ struct listnode *node, *nnode;
if (zclient->redist[ZEBRA_ROUTE_OSPF])
{
api.ifindex_num = 0;
api.nexthop_num = 0;
- for (node = listhead (or->paths); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (or->paths, node, nnode, path))
{
- path = getdata (node);
-
if (path->nexthop.s_addr != INADDR_ANY)
{
SET_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP);
}
/* Update Area access-list. */
- for (node = listhead (ospf->areas); node; nextnode (node))
- if ((area = getdata (node)) != NULL)
- {
- if (EXPORT_NAME (area))
- {
- EXPORT_LIST (area) = NULL;
- abr_inv++;
- }
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
+ {
+ if (EXPORT_NAME (area))
+ {
+ EXPORT_LIST (area) = NULL;
+ abr_inv++;
+ }
- if (IMPORT_NAME (area))
- {
- IMPORT_LIST (area) = NULL;
- abr_inv++;
- }
- }
+ if (IMPORT_NAME (area))
+ {
+ IMPORT_LIST (area) = NULL;
+ abr_inv++;
+ }
+ }
/* Schedule ABR tasks -- this will be changed -- takada. */
if (IS_OSPF_ABR (ospf) && abr_inv)
}
/* Update area filter-lists. */
- for (node = listhead (ospf->areas); node; nextnode (node))
- if ((area = getdata (node)) != NULL)
- {
- /* Update filter-list in. */
- if (PREFIX_NAME_IN (area))
- if (strcmp (PREFIX_NAME_IN (area), plist->name) == 0)
- {
- PREFIX_LIST_IN (area) =
- prefix_list_lookup (AFI_IP, PREFIX_NAME_IN (area));
- abr_inv++;
- }
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
+ {
+ /* Update filter-list in. */
+ if (PREFIX_NAME_IN (area))
+ if (strcmp (PREFIX_NAME_IN (area), plist->name) == 0)
+ {
+ PREFIX_LIST_IN (area) =
+ prefix_list_lookup (AFI_IP, PREFIX_NAME_IN (area));
+ abr_inv++;
+ }
- /* Update filter-list out. */
- if (PREFIX_NAME_OUT (area))
- if (strcmp (PREFIX_NAME_OUT (area), plist->name) == 0)
- {
- PREFIX_LIST_IN (area) =
- prefix_list_lookup (AFI_IP, PREFIX_NAME_OUT (area));
- abr_inv++;
- }
- }
+ /* Update filter-list out. */
+ if (PREFIX_NAME_OUT (area))
+ if (strcmp (PREFIX_NAME_OUT (area), plist->name) == 0)
+ {
+ PREFIX_LIST_IN (area) =
+ prefix_list_lookup (AFI_IP, PREFIX_NAME_OUT (area));
+ abr_inv++;
+ }
+ }
/* Schedule ABR task. */
if (IS_OSPF_ABR (ospf) && abr_inv)
ospf_router_id_update (struct ospf *ospf)
{
struct in_addr router_id, router_id_old;
+ struct ospf_interface *oi;
struct listnode *node;
if (IS_DEBUG_OSPF_EVENT)
if (!IPV4_ADDR_SAME (&router_id_old, &router_id))
{
- for (node = listhead (ospf->oiflist); node; nextnode (node))
- {
- struct ospf_interface *oi = getdata (node);
-
- /* Update self-neighbor's router_id. */
- oi->nbr_self->router_id = router_id;
- }
+ for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
+ /* Update self-neighbor's router_id. */
+ oi->nbr_self->router_id = router_id;
/* If AS-external-LSA is queued, then flush those LSAs. */
if (router_id_old.s_addr == 0 && ospf->external_origin)
if (listcount (om->ospf) == 0)
return NULL;
- return getdata (listhead (om->ospf));
+ return listgetdata (listhead (om->ospf));
}
void
struct route_node *rn;
struct ospf_nbr_nbma *nbr_nbma;
struct ospf_lsa *lsa;
- struct listnode *node;
+ struct ospf_interface *oi;
+ struct ospf_area *area;
+ struct ospf_vl_data *vl_data;
+ struct listnode *node, *nnode;
int i;
#ifdef HAVE_OPAQUE_LSA
for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
ospf_redistribute_unset (ospf, i);
- for (node = listhead (ospf->areas); node;)
- {
- struct ospf_area *area = getdata (node);
- nextnode (node);
-
- ospf_remove_vls_through_area (ospf, area);
- }
+ for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
+ ospf_remove_vls_through_area (ospf, area);
- for (node = listhead (ospf->vlinks); node; )
- {
- struct ospf_vl_data *vl_data = node->data;
- nextnode (node);
-
- ospf_vl_delete (ospf, vl_data);
- }
+ for (ALL_LIST_ELEMENTS (ospf->vlinks, node, nnode, vl_data))
+ ospf_vl_delete (ospf, vl_data);
list_delete (ospf->vlinks);
/* Reset interface. */
- for (node = listhead (ospf->oiflist); node;)
- {
- struct ospf_interface *oi = getdata (node);
- nextnode (node);
-
- if (oi)
- ospf_if_free (oi);
- }
+ for (ALL_LIST_ELEMENTS (ospf->oiflist, node, nnode, oi))
+ ospf_if_free (oi);
/* Clear static neighbors */
for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn))
}
}
- for (node = listhead (ospf->areas); node;)
+ for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
{
- struct ospf_area *area = getdata (node);
- nextnode (node);
-
listnode_delete (ospf->areas, area);
ospf_area_free (area);
}
ospf_lsdb_delete_all (ospf->lsdb);
ospf_lsdb_free (ospf->lsdb);
- for (node = listhead (ospf->maxage_lsa); node; nextnode (node))
- ospf_lsa_unlock (getdata (node));
+ for (ALL_LIST_ELEMENTS (ospf->maxage_lsa, node, nnode, lsa))
+ ospf_lsa_unlock (lsa);
list_delete (ospf->maxage_lsa);
struct ospf_area *area;
struct listnode *node;
- for (node = listhead (ospf->areas); node; nextnode (node))
- {
- area = getdata (node);
-
- if (IPV4_ADDR_SAME (&area->area_id, &area_id))
- return area;
- }
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
+ if (IPV4_ADDR_SAME (&area->area_id, &area_id))
+ return area;
return NULL;
}
ospf_network_run (struct ospf *ospf, struct prefix *p, struct ospf_area *area)
{
struct interface *ifp;
+ struct connected *co;
struct listnode *node;
/* Schedule Router ID Update. */
}
/* Get target interface. */
- for (node = listhead (om->iflist); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
{
- struct listnode *cn;
+ struct listnode *cnode;
- if ((ifp = getdata (node)) == NULL)
- continue;
-
if (memcmp (ifp->name, "VLINK", 5) == 0)
continue;
/* if interface prefix is match specified prefix,
then create socket and join multicast group. */
- for (cn = listhead (ifp->connected); cn; nextnode (cn))
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, cnode, co))
{
- struct connected *co = getdata (cn);
struct prefix *addr;
if (CHECK_FLAG(co->flags,ZEBRA_IFA_SECONDARY))
&& ! ospf_if_is_configured (ospf, &(addr->u.prefix4))
&& ospf_network_match_iface(co,p))
{
- struct ospf_interface *oi;
+ struct ospf_interface *oi;
oi = ospf_if_new (ospf, ifp, co->address);
oi->connected = co;
ospf_ls_upd_queue_empty (struct ospf_interface *oi)
{
struct route_node *rn;
- struct listnode *node;
+ struct listnode *node, *nnode;
struct list *lst;
struct ospf_lsa *lsa;
rn = route_next (rn))
if ((lst = (struct list *) rn->info))
{
- for (node = listhead (lst); node; nextnode (node))
- if ((lsa = getdata (node)))
- ospf_lsa_unlock (lsa);
+ for (ALL_LIST_ELEMENTS (lst, node, nnode, lsa))
+ ospf_lsa_unlock (lsa);
list_free (lst);
rn->info = NULL;
}
ospf_if_update (struct ospf *ospf)
{
struct route_node *rn;
- struct listnode *node;
- struct listnode *next;
+ struct listnode *node, *nnode;
struct ospf_network *network;
struct ospf_area *area;
+ struct ospf_interface *oi;
if (ospf != NULL)
{
}
/* Find interfaces that not configured already. */
- for (node = listhead (ospf->oiflist); node; node = next)
+ for (ALL_LIST_ELEMENTS (ospf->oiflist, node, nnode, oi))
{
int found = 0;
- struct ospf_interface *oi = getdata (node);
struct connected *co = oi->connected;
- next = nextnode (node);
-
if (oi->type == OSPF_IFTYPE_VIRTUALLINK)
continue;
void
ospf_remove_vls_through_area (struct ospf *ospf, struct ospf_area *area)
{
- struct listnode *node, *next;
+ struct listnode *node, *nnode;
struct ospf_vl_data *vl_data;
- for (node = listhead (ospf->vlinks); node; node = next)
- {
- next = node->next;
- if ((vl_data = getdata (node)) != NULL)
- if (IPV4_ADDR_SAME (&vl_data->vl_area_id, &area->area_id))
- ospf_vl_delete (ospf, vl_data);
- }
+ for (ALL_LIST_ELEMENTS (ospf->vlinks, node, nnode, vl_data))
+ if (IPV4_ADDR_SAME (&vl_data->vl_area_id, &area->area_id))
+ ospf_vl_delete (ospf, vl_data);
}
\f
switch (area->external_routing)
{
case OSPF_AREA_DEFAULT:
- for (node = listhead (area->oiflist); node; nextnode (node))
- if ((oi = getdata (node)) != NULL)
- if (oi->nbr_self != NULL)
- {
- UNSET_FLAG (oi->nbr_self->options, OSPF_OPTION_NP);
- SET_FLAG (oi->nbr_self->options, OSPF_OPTION_E);
- }
+ for (ALL_LIST_ELEMENTS_RO (area->oiflist, node, oi))
+ if (oi->nbr_self != NULL)
+ {
+ UNSET_FLAG (oi->nbr_self->options, OSPF_OPTION_NP);
+ SET_FLAG (oi->nbr_self->options, OSPF_OPTION_E);
+ }
break;
case OSPF_AREA_STUB:
- for (node = listhead (area->oiflist); node; nextnode (node))
- if ((oi = getdata (node)) != NULL)
- if (oi->nbr_self != NULL)
- {
- if (IS_DEBUG_OSPF_EVENT)
- zlog_debug ("setting options on %s accordingly", IF_NAME (oi));
- UNSET_FLAG (oi->nbr_self->options, OSPF_OPTION_NP);
- UNSET_FLAG (oi->nbr_self->options, OSPF_OPTION_E);
- if (IS_DEBUG_OSPF_EVENT)
- zlog_debug ("options set on %s: %x",
- IF_NAME (oi), OPTIONS (oi));
- }
+ for (ALL_LIST_ELEMENTS_RO (area->oiflist, node, oi))
+ if (oi->nbr_self != NULL)
+ {
+ if (IS_DEBUG_OSPF_EVENT)
+ zlog_debug ("setting options on %s accordingly", IF_NAME (oi));
+ UNSET_FLAG (oi->nbr_self->options, OSPF_OPTION_NP);
+ UNSET_FLAG (oi->nbr_self->options, OSPF_OPTION_E);
+ if (IS_DEBUG_OSPF_EVENT)
+ zlog_debug ("options set on %s: %x",
+ IF_NAME (oi), OPTIONS (oi));
+ }
break;
case OSPF_AREA_NSSA:
- for (node = listhead (area->oiflist); node; nextnode (node))
- if ((oi = getdata (node)) != NULL)
- if (oi->nbr_self != NULL)
- {
- if (IS_DEBUG_OSPF_EVENT)
- zlog_debug ("setting nssa options on %s accordingly", IF_NAME (oi));
- UNSET_FLAG (oi->nbr_self->options, OSPF_OPTION_E);
- SET_FLAG (oi->nbr_self->options, OSPF_OPTION_NP);
- if (IS_DEBUG_OSPF_EVENT)
- zlog_debug ("options set on %s: %x", IF_NAME (oi), OPTIONS (oi));
- }
+ for (ALL_LIST_ELEMENTS_RO (area->oiflist, node, oi))
+ if (oi->nbr_self != NULL)
+ {
+ zlog_debug ("setting nssa options on %s accordingly", IF_NAME (oi));
+ UNSET_FLAG (oi->nbr_self->options, OSPF_OPTION_E);
+ SET_FLAG (oi->nbr_self->options, OSPF_OPTION_NP);
+ zlog_debug ("options set on %s: %x", IF_NAME (oi), OPTIONS (oi));
+ }
break;
default:
break;
struct listnode *node;
int count = 0;
- for (node = listhead (ospf->vlinks); node; nextnode (node))
- {
- vl = getdata (node);
- if (IPV4_ADDR_SAME (&vl->vl_area_id, &area->area_id))
- count++;
- }
+ for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl))
+ if (IPV4_ADDR_SAME (&vl->vl_area_id, &area->area_id))
+ count++;
return count;
}
return NULL;
#if 0
- for (node = listhead (ospf->nbr_nbma); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->nbr_nbma, node, nbr_nbma))
{
- nbr_nbma = getdata (node);
-
if (first)
{
*addr = nbr_nbma->addr;
rn = route_node_get (ospf->nbr_nbma, (struct prefix *)&p);
rn->info = nbr_nbma;
- for (node = listhead (ospf->oiflist); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
{
- oi = getdata (node);
if (oi->type == OSPF_IFTYPE_NBMA)
if (prefix_match (oi->address, (struct prefix *)&p))
{
/* RIPv1 and non multicast interface. */
if (if_is_pointopoint (ifp) || if_is_broadcast (ifp))
{
- struct listnode *cnode;
+ struct listnode *cnode, *cnnode;
+ struct connected *connected;
if (IS_RIP_DEBUG_EVENT)
zlog_debug ("broadcast request to %s", ifp->name);
- for (cnode = listhead (ifp->connected); cnode; nextnode (cnode))
+ for (ALL_LIST_ELEMENTS (ifp->connected, cnode, cnnode, connected))
{
- struct connected *connected;
-
- connected = getdata (cnode);
-
if (connected->address->family == AF_INET)
{
memset (&to, 0, sizeof (struct sockaddr_in));
rip_multicast_join (struct interface *ifp, int sock)
{
struct listnode *cnode;
+ struct connected *ifc;
if (if_is_operative (ifp) && if_is_multicast (ifp))
{
if (IS_RIP_DEBUG_EVENT)
zlog_debug ("multicast join at %s", ifp->name);
- for (cnode = listhead (ifp->connected); cnode; nextnode (cnode))
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, cnode, ifc))
{
struct prefix_ipv4 *p;
- struct connected *connected;
struct in_addr group;
- connected = getdata (cnode);
- p = (struct prefix_ipv4 *) connected->address;
+ p = (struct prefix_ipv4 *) ifc->address;
if (p->family != AF_INET)
continue;
rip_multicast_leave (struct interface *ifp, int sock)
{
struct listnode *cnode;
+ struct connected *connected;
if (if_is_up (ifp) && if_is_multicast (ifp))
{
if (IS_RIP_DEBUG_EVENT)
zlog_debug ("multicast leave from %s", ifp->name);
- for (cnode = listhead (ifp->connected); cnode; nextnode (cnode))
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, cnode, connected))
{
struct prefix_ipv4 *p;
- struct connected *connected;
struct in_addr group;
-
- connected = getdata (cnode);
+
p = (struct prefix_ipv4 *) connected->address;
-
+
if (p->family != AF_INET)
continue;
struct connected *connected;
int count = 0;
- for (nn = listhead (ifp->connected); nn; nextnode (nn))
- if ((connected = getdata (nn)) != NULL)
- {
- struct prefix *p;
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, nn, connected))
+ {
+ struct prefix *p;
- p = connected->address;
+ p = connected->address;
- if (p->family == AF_INET)
- {
- count++;
- }
- }
+ if (p->family == AF_INET)
+ count++;
+ }
return count;
}
if_check_address (struct in_addr addr)
{
struct listnode *node;
-
- for (node = listhead (iflist); node; nextnode (node))
+ struct interface *ifp;
+
+ for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
{
struct listnode *cnode;
- struct interface *ifp;
-
- ifp = getdata (node);
+ struct connected *connected;
- for (cnode = listhead (ifp->connected); cnode; nextnode (cnode))
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, cnode, connected))
{
- struct connected *connected;
struct prefix_ipv4 *p;
- connected = getdata (cnode);
p = (struct prefix_ipv4 *) connected->address;
if (p->family != AF_INET)
{
struct listnode *node;
struct connected *connected = NULL;
+ struct interface *ifp;
struct prefix_ipv4 *p;
struct prefix_ipv4 pa;
pa.prefix = addr;
pa.prefixlen = IPV4_MAX_PREFIXLEN;
- for (node = listhead (iflist); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
{
struct listnode *cnode;
- struct interface *ifp;
-
- ifp = getdata (node);
- for (cnode = listhead (ifp->connected); cnode; nextnode (cnode))
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, cnode, connected))
{
- connected = getdata (cnode);
-
if (if_is_pointopoint (ifp))
{
p = (struct prefix_ipv4 *) connected->address;
struct interface *ifp;
struct rip_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;
struct interface *ifp;
struct rip_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;
rip_if_down_all ()
{
struct interface *ifp;
- struct listnode *node;
+ struct listnode *node, *nnode;
- for (node = listhead (iflist); node; nextnode (node))
- {
- ifp = getdata (node);
- rip_if_down (ifp);
- }
+ for (ALL_LIST_ELEMENTS (iflist, node, nnode, ifp))
+ rip_if_down (ifp);
}
static void
int
rip_enable_network_lookup_if (struct interface *ifp)
{
- struct listnode *nn;
+ struct listnode *node, *nnode;
struct connected *connected;
struct prefix_ipv4 address;
- for (nn = listhead (ifp->connected); nn; nextnode (nn))
- if ((connected = getdata (nn)) != NULL)
- {
- struct prefix *p;
- struct route_node *node;
+ for (ALL_LIST_ELEMENTS (ifp->connected, node, nnode, connected))
+ {
+ struct prefix *p;
+ struct route_node *node;
- p = connected->address;
+ p = connected->address;
- if (p->family == AF_INET)
- {
- address.family = AF_INET;
- address.prefix = p->u.prefix4;
- address.prefixlen = IPV4_MAX_BITLEN;
-
- node = route_node_match (rip_enable_network,
- (struct prefix *)&address);
- if (node)
- {
- route_unlock_node (node);
- return 1;
- }
- }
- }
+ if (p->family == AF_INET)
+ {
+ address.family = AF_INET;
+ address.prefix = p->u.prefix4;
+ address.prefixlen = IPV4_MAX_BITLEN;
+
+ node = route_node_match (rip_enable_network,
+ (struct prefix *)&address);
+ if (node)
+ {
+ route_unlock_node (node);
+ return 1;
+ }
+ }
+ }
return -1;
}
void
rip_connect_set (struct interface *ifp, int set)
{
- struct listnode *nn;
+ struct listnode *node, *nnode;
struct connected *connected;
struct prefix_ipv4 address;
- for (nn = listhead (ifp->connected); nn; nextnode (nn))
- if ((connected = getdata (nn)) != NULL)
- {
- struct prefix *p;
- p = connected->address;
-
- if (p->family != AF_INET)
- continue;
-
- address.family = AF_INET;
- address.prefix = p->u.prefix4;
- address.prefixlen = p->prefixlen;
- apply_mask_ipv4 (&address);
-
- if (set) {
- /* Check once more wether this prefix is within a "network IF_OR_PREF" one */
- if ((rip_enable_if_lookup(connected->ifp->name) >= 0) ||
- (rip_enable_network_lookup2(connected) >= 0))
- rip_redistribute_add (ZEBRA_ROUTE_CONNECT, RIP_ROUTE_INTERFACE,
- &address, connected->ifp->ifindex, NULL);
- } else
- {
- rip_redistribute_delete (ZEBRA_ROUTE_CONNECT, RIP_ROUTE_INTERFACE,
- &address, connected->ifp->ifindex);
- if (rip_redistribute_check (ZEBRA_ROUTE_CONNECT))
- rip_redistribute_add (ZEBRA_ROUTE_CONNECT, RIP_ROUTE_REDISTRIBUTE,
- &address, connected->ifp->ifindex, NULL);
- }
- }
+ for (ALL_LIST_ELEMENTS (ifp->connected, node, nnode, connected))
+ {
+ struct prefix *p;
+ p = connected->address;
+
+ if (p->family != AF_INET)
+ continue;
+
+ address.family = AF_INET;
+ address.prefix = p->u.prefix4;
+ address.prefixlen = p->prefixlen;
+ apply_mask_ipv4 (&address);
+
+ if (set) {
+ /* Check once more wether this prefix is within a "network IF_OR_PREF" one */
+ if ((rip_enable_if_lookup(connected->ifp->name) >= 0) ||
+ (rip_enable_network_lookup2(connected) >= 0))
+ rip_redistribute_add (ZEBRA_ROUTE_CONNECT, RIP_ROUTE_INTERFACE,
+ &address, connected->ifp->ifindex, NULL);
+ } else
+ {
+ rip_redistribute_delete (ZEBRA_ROUTE_CONNECT, RIP_ROUTE_INTERFACE,
+ &address, connected->ifp->ifindex);
+ if (rip_redistribute_check (ZEBRA_ROUTE_CONNECT))
+ rip_redistribute_add (ZEBRA_ROUTE_CONNECT, RIP_ROUTE_REDISTRIBUTE,
+ &address, connected->ifp->ifindex, NULL);
+ }
+ }
}
/* Update interface status. */
rip_enable_apply_all ()
{
struct interface *ifp;
- struct listnode *node;
+ struct listnode *node, *nnode;
/* Check each interface. */
- for (node = listhead (iflist); node; nextnode (node))
- {
- ifp = getdata (node);
- rip_enable_apply (ifp);
- }
+ for (ALL_LIST_ELEMENTS (iflist, node, nnode, ifp))
+ rip_enable_apply (ifp);
}
int
rip_passive_interface_apply_all ()
{
struct interface *ifp;
- struct listnode *node;
+ struct listnode *node, *nnode;
- for (node = listhead (iflist); node; nextnode (node))
- {
- ifp = getdata (node);
- rip_passive_interface_apply (ifp);
- }
+ for (ALL_LIST_ELEMENTS (iflist, node, nnode, ifp))
+ rip_passive_interface_apply (ifp);
}
/* Passive interface. */
struct listnode *node;
struct interface *ifp;
- for (node = listhead (iflist); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
{
struct rip_interface *ri;
- ifp = getdata (node);
ri = ifp->info;
/* Do not display the interface if there is no
rip_offset_list_lookup (const char *ifname)
{
struct rip_offset_list *offset;
- struct listnode *nn;
+ struct listnode *node, *nnode;
- LIST_LOOP (rip_offset_list_master, offset, nn)
+ for (ALL_LIST_ELEMENTS (rip_offset_list_master, node, nnode, offset))
{
if (strcmp_safe (offset->ifname, ifname) == 0)
return offset;
int
config_write_rip_offset_list (struct vty *vty)
{
- struct listnode *nn;
+ struct listnode *node, *nnode;
struct rip_offset_list *offset;
- LIST_LOOP (rip_offset_list_master, offset, nn)
+ for (ALL_LIST_ELEMENTS (rip_offset_list_master, node, nnode, offset))
{
if (! offset->ifname)
{
rip_peer_lookup (struct in_addr *addr)
{
struct rip_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 (IPV4_ADDR_SAME (&peer->addr, addr))
return peer;
rip_peer_lookup_next (struct in_addr *addr)
{
struct rip_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 (htonl (peer->addr.s_addr) > htonl (addr->s_addr))
return peer;
rip_peer_display (struct vty *vty)
{
struct rip_peer *peer;
- struct listnode *nn;
+ struct listnode *node, *nnode;
#define RIP_UPTIME_LEN 25
char timebuf[RIP_UPTIME_LEN];
- LIST_LOOP (peer_list, peer, nn)
+ for (ALL_LIST_ELEMENTS (peer_list, node, nnode, peer))
{
vty_out (vty, " %-16s %9d %9d %9d %s%s", inet_ntoa (peer->addr),
peer->recv_badpackets, peer->recv_badroutes,
/* If nexthop address matches local configured address then it is
invalid nexthop. */
- for (node = listhead (iflist); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
{
- ifp = getdata (node);
-
- for (cnode = listhead (ifp->connected); cnode; nextnode (cnode))
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, cnode, ifc))
{
- ifc = getdata (cnode);
p = ifc->address;
if (p->family == AF_INET
void
rip_update_process (int route_type)
{
- struct listnode *node, *ifnode;
+ struct listnode *node;
+ struct listnode *ifnode, *ifnnode;
struct connected *connected;
struct interface *ifp;
struct rip_interface *ri;
struct prefix_ipv4 *p;
/* Send RIP update to each interface. */
- for (node = listhead (iflist); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
{
- ifp = getdata (node);
-
if (if_is_loopback (ifp))
continue;
}
/* send update on each connected network */
-
- LIST_LOOP(ifp->connected, connected, ifnode)
+ for (ALL_LIST_ELEMENTS (ifp->connected, ifnode, ifnnode, connected))
{
struct prefix_ipv4 *ifaddr;
int done = 0;
{
struct rte *rte;
struct rip_packet rip_packet;
- struct listnode *node;
+ struct listnode *node, *nnode;
memset (&rip_packet, 0, sizeof (rip_packet));
}
/* send request on each connected network */
- LIST_LOOP(ifp->connected, connected, node)
+ for (ALL_LIST_ELEMENTS (ifp->connected, node, nnode, connected))
{
struct prefix_ipv4 *p;
vty_out (vty, " Interface Send Recv Key-chain%s", VTY_NEWLINE);
- for (node = listhead (iflist); node; node = nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
{
- ifp = getdata (node);
ri = ifp->info;
if (ri->enable_network || ri->enable_interface)
{
int found_passive = 0;
- for (node = listhead (iflist); node; node = nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
{
- ifp = getdata (node);
ri = ifp->info;
if ((ri->enable_network || ri->enable_interface) && ri->passive)
rip_distribute_update_all (struct prefix_list *notused)
{
struct interface *ifp;
- struct listnode *node;
+ struct listnode *node, *nnode;
- for (node = listhead (iflist); node; nextnode (node))
- {
- ifp = getdata (node);
- rip_distribute_update_interface (ifp);
- }
+ for (ALL_LIST_ELEMENTS (iflist, node, nnode, ifp))
+ rip_distribute_update_interface (ifp);
}
/* ARGSUSED */
void
rip_routemap_update (const char *notused)
{
struct interface *ifp;
- struct listnode *node;
+ struct listnode *node, *nnode;
- for (node = listhead (iflist); node; nextnode (node))
- {
- ifp = getdata (node);
- rip_if_rmap_update_interface (ifp);
- }
+ for (ALL_LIST_ELEMENTS (iflist, node, nnode, ifp))
+ rip_if_rmap_update_interface (ifp);
rip_routemap_update_redistribute ();
}
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;
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;
}
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;
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;
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;
}
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;
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);
}
\f
/* Clear all network and neighbor configuration */
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. */
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
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;
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))) {
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;
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)
{
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;
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;
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, " ",
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;
}
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))
/* 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))
"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);
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)
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
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 ();
}
struct config *config;
struct config *config_loop;
struct list *master;
- struct listnode *nn;
+ struct listnode *node, *nnode;
config = config_loop = NULL;
vector_set_index (configvec, index, master);
}
- LIST_LOOP (master, config_loop, nn)
+ for (ALL_LIST_ELEMENTS (master, node, nnode, config_loop))
{
if (strcmp (config_loop->name, line) == 0)
config = config_loop;
void
config_add_line_uniq (struct list *config, const char *line)
{
- struct listnode *nn;
+ struct listnode *node, *nnode;
char *pnt;
- LIST_LOOP (config, pnt, nn)
+ for (ALL_LIST_ELEMENTS (config, node, nnode, pnt))
{
if (strcmp (pnt, line) == 0)
return;
void
vtysh_config_dump (FILE *fp)
{
- struct listnode *nn;
- struct listnode *nm;
+ struct listnode *node, *nnode;
+ struct listnode *mnode, *mnnode;
struct config *config;
struct list *master;
char *line;
unsigned int i;
- LIST_LOOP (config_top, line, nn)
+ for (ALL_LIST_ELEMENTS (config_top, node, nnode, line))
{
fprintf (fp, "%s\n", line);
fflush (fp);
for (i = 0; i < vector_active (configvec); i++)
if ((master = vector_slot (configvec, i)) != NULL)
{
- LIST_LOOP (master, config, nn)
+ for (ALL_LIST_ELEMENTS (master, node, nnode, config))
{
fprintf (fp, "%s\n", config->name);
fflush (fp);
- LIST_LOOP (config->line, line, nm)
+ for (ALL_LIST_ELEMENTS (config->line, mnode, mnnode, line))
{
fprintf (fp, "%s\n", line);
fflush (fp);
struct user *
user_lookup (const char *name)
{
- struct listnode *nn;
+ struct listnode *node, *nnode;
struct user *user;
- LIST_LOOP (userlist, user, nn)
+ for (ALL_LIST_ELEMENTS (userlist, node, nnode, user))
{
if (strcmp (user->name, name) == 0)
return user;
void
user_config_write ()
{
- struct listnode *nn;
+ struct listnode *node, *nnode;
struct user *user;
- LIST_LOOP (userlist, user, nn)
+ for (ALL_LIST_ELEMENTS (userlist, node, nnode, user))
{
if (user->nopassword)
printf (" username %s nopassword\n", user->name);
struct connected *ifc;
struct listnode *node;
- for (node = listhead (ifp->connected); node; node = nextnode (node))
- {
- ifc = getdata (node);
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, ifc))
+ if (prefix_same (ifc->address, p))
+ return ifc;
- if (prefix_same (ifc->address, p))
- return ifc;
- }
return NULL;
}
struct connected *ifc;
struct listnode *node;
- for (node = listhead (ifp->connected); node; node = nextnode (node))
- {
- ifc = getdata (node);
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, ifc))
+ if (prefix_same (ifc->address, p))
+ return ifc;
- if (prefix_same (ifc->address, p))
- return ifc;
- }
return 0;
}
static void
interface_info_ioctl ()
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct interface *ifp;
- LIST_LOOP (iflist, ifp, node)
+ for (ALL_LIST_ELEMENTS (iflist, ifp, node, nnode))
{
- ifp = getdata (node);
-
if_get_index (ifp);
#ifdef SIOCGIFHWADDR
if_get_hwaddr (ifp);
if (ifp == NULL)
return NULL;
- LIST_LOOP (ifp->connected, ifc, node)
+ for (ALL_LIST_ELEMENTS_RO(ifp->connected, ifc, node))
{
if ((ifc->address->family == AF_INET6) &&
(IN6_IS_ADDR_LINKLOCAL (&ifc->address->u.prefix6)))
/* If deleted address is primary, mark subsequent one as such and distribute. */
if (! CHECK_FLAG (ifc->flags, ZEBRA_IFA_SECONDARY))
{
- ifc = (struct connected *) addr_list->head->data;
+ ifc = listgetdata (listhead (addr_list));
zebra_interface_address_delete_update (ifp, ifc);
UNSET_FLAG (ifc->flags, ZEBRA_IFA_SECONDARY);
zebra_interface_address_add_update (ifp, ifc);
void
if_addr_wakeup (struct interface *ifp)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct connected *ifc;
struct prefix *p;
int ret;
- for (node = listhead (ifp->connected); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (ifp->connected, node, nnode, ifc))
{
- ifc = getdata (node);
p = ifc->address;
if (CHECK_FLAG (ifc->conf, ZEBRA_IFC_CONFIGURED)
last = NULL;
while ((node = (last ? last->next : listhead (ifp->connected))))
{
- ifc = getdata (node);
+ ifc = listgetdata (node);
p = ifc->address;
if (p->family == AF_INET)
}
next = node->next;
- ifc = getdata (node);
+ ifc = listgetdata (node);
p = ifc->address;
connected_down_ipv4 (ifp, ifc);
/* Install connected routes to the kernel. */
if (ifp->connected)
{
- for (node = listhead (ifp->connected); node; node = next)
+ for (ALL_LIST_ELEMENTS (ifp->connected, node, next, ifc))
{
- next = node->next;
- ifc = getdata (node);
p = ifc->address;
if (p->family == AF_INET)
/* Delete connected routes from the kernel. */
if (ifp->connected)
{
- for (node = listhead (ifp->connected); node; node = next)
+ for (ALL_LIST_ELEMENTS (ifp->connected, node, next, ifc))
{
- next = node->next;
- ifc = getdata (node);
p = ifc->address;
if (p->family == AF_INET)
if (! rn->info)
continue;
- for (node = listhead ((struct list *) rn->info); node; nextnode (node))
- {
- connected = getdata (node);
- connected_dump_vty (vty, connected);
- }
+ for (ALL_LIST_ELEMENTS_RO ((struct list *)rn->info, node, connected))
+ connected_dump_vty (vty, connected);
}
- for (node = listhead (ifp->connected); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, connected))
{
- connected = getdata (node);
if (CHECK_FLAG (connected->conf, ZEBRA_IFC_REAL) &&
(connected->address->family == AF_INET6))
connected_dump_vty (vty, connected);
}
/* All interface print. */
- for (node = listhead (iflist); node; nextnode (node))
- if_dump_vty (vty, getdata (node));
+ for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
+ if_dump_vty (vty, ifp);
return CMD_SUCCESS;
}
struct interface *ifp;
vty_out (vty, "Interface Status Protocol Description%s", VTY_NEWLINE);
- for (node = listhead (iflist); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
{
int len;
- ifp = getdata (node);
len = vty_out (vty, "%s", ifp->name);
vty_out (vty, "%*s", (16 - len), " ");
struct interface *ifp;
char buf[BUFSIZ];
- for (node = listhead (iflist); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
{
struct zebra_if *if_data;
struct listnode *addrnode;
struct connected *ifc;
struct prefix *p;
- ifp = getdata (node);
if_data = ifp->info;
vty_out (vty, "interface %s%s", ifp->name,
if (CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_LINKDETECTION))
vty_out(vty, " link-detect%s", VTY_NEWLINE);
- for (addrnode = listhead (ifp->connected); addrnode; nextnode (addrnode))
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, addrnode, ifc))
{
- ifc = getdata (addrnode);
if (CHECK_FLAG (ifc->conf, ZEBRA_IFC_CONFIGURED))
{
p = ifc->address;
struct connected *ifc;
if (ifp->connected)
- LIST_LOOP (ifp->connected, ifc, node)
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, ifc))
return ifc->address;
return NULL;
seed = 0;
if( ifp->connected)
- LIST_LOOP (ifp->connected, ifc, node)
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, ifc))
{
seed = ifc->address->u.prefix4.s_addr;
break;
vty_out (vty, " ip irdp preference %ld%s",
irdp->Preference, VTY_NEWLINE);
- LIST_LOOP (irdp->AdvPrefList, adv, node)
+ for (ALL_LIST_ELEMENTS_RO (irdp->AdvPrefList, node, adv))
vty_out (vty, " ip irdp address %s preference %d%s",
inet_2a(adv->ip.s_addr, b1),
adv->pref,
pref = atoi(argv[1]);
- LIST_LOOP (irdp->AdvPrefList, adv, node)
+ for (ALL_LIST_ELEMENTS_RO (irdp->AdvPrefList, node, adv))
if(adv->ip.s_addr == ip.s_addr)
return CMD_SUCCESS;
pref = atoi(argv[1]);
- for (node = listhead (irdp->AdvPrefList); node; node = nnode)
+ for (ALL_LIST_ELEMENTS (irdp->AdvPrefList, node, nnode, adv))
{
- nnode = node->next;
- adv = getdata (node);
-
if(adv->ip.s_addr == ip.s_addr )
{
listnode_delete(irdp->AdvPrefList, adv);
if( irdp->AdvPrefList == NULL )
return irdp->Preference;
- LIST_LOOP (irdp->AdvPrefList, adv, node)
+ for (ALL_LIST_ELEMENTS_RO (irdp->AdvPrefList, node, adv))
if( p->u.prefix4.s_addr == adv->ip.s_addr )
return adv->pref;
struct zebra_if *zi=ifp->info;
struct irdp_interface *irdp=&zi->irdp;
struct prefix *p;
- struct listnode *node;
+ struct listnode *node, *nnode;
struct connected *ifc;
irdp->flags &= ~IF_SOLICIT;
if(ifp->connected)
- LIST_LOOP (ifp->connected, ifc, node)
+ for (ALL_LIST_ELEMENTS (ifp->connected, node, nnode, ifc))
{
p = ifc->address;
irdp_advertisement(ifp, p);
{
struct zebra_if *zi=ifp->info;
struct irdp_interface *irdp=&zi->irdp;
- struct listnode *node;
+ struct listnode *node, *nnode;
int i;
struct connected *ifc;
struct prefix *p;
irdp->t_advertise = NULL;
if(ifp->connected)
- LIST_LOOP (ifp->connected, ifc, node)
+ for (ALL_LIST_ELEMENTS (ifp->connected, node, nnode, ifc))
{
p = ifc->address;
void irdp_finish()
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct interface *ifp;
struct zebra_if *zi;
struct irdp_interface *irdp;
zlog_info("IRDP: Received shutdown notification.");
- for (node = listhead (iflist); node; node = nextnode (node))
+ for (ALL_LIST_ELEMENTS (iflist, node, nnode, ifp))
{
- ifp = getdata(node);
zi = ifp->info;
if (!zi)
void
redistribute_add (struct prefix *p, struct rib *rib)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct zserv *client;
- for (node = listhead (zebrad.client_list); node; nextnode (node))
- if ((client = getdata (node)) != NULL)
- {
- if (is_default (p))
- {
- if (client->redist_default || client->redist[rib->type])
- {
- if (p->family == AF_INET)
- zsend_route_multipath (ZEBRA_IPV4_ROUTE_ADD, client, p, rib);
+ for (ALL_LIST_ELEMENTS (zebrad.client_list, node, nnode, client))
+ {
+ if (is_default (p))
+ {
+ if (client->redist_default || client->redist[rib->type])
+ {
+ if (p->family == AF_INET)
+ zsend_route_multipath (ZEBRA_IPV4_ROUTE_ADD, client, p, rib);
#ifdef HAVE_IPV6
- if (p->family == AF_INET6)
- zsend_route_multipath (ZEBRA_IPV6_ROUTE_ADD, client, p, rib);
+ if (p->family == AF_INET6)
+ zsend_route_multipath (ZEBRA_IPV6_ROUTE_ADD, client, p, rib);
#endif /* HAVE_IPV6 */
- }
- }
- else if (client->redist[rib->type])
- {
- if (p->family == AF_INET)
- zsend_route_multipath (ZEBRA_IPV4_ROUTE_ADD, client, p, rib);
+ }
+ }
+ else if (client->redist[rib->type])
+ {
+ if (p->family == AF_INET)
+ zsend_route_multipath (ZEBRA_IPV4_ROUTE_ADD, client, p, rib);
#ifdef HAVE_IPV6
- if (p->family == AF_INET6)
- zsend_route_multipath (ZEBRA_IPV6_ROUTE_ADD, client, p, rib);
+ if (p->family == AF_INET6)
+ zsend_route_multipath (ZEBRA_IPV6_ROUTE_ADD, client, p, rib);
#endif /* HAVE_IPV6 */
- }
- }
+ }
+ }
}
void
redistribute_delete (struct prefix *p, struct rib *rib)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct zserv *client;
/* Add DISTANCE_INFINITY check. */
if (rib->distance == DISTANCE_INFINITY)
return;
- for (node = listhead (zebrad.client_list); node; nextnode (node))
- if ((client = getdata (node)) != NULL)
- {
- if (is_default (p))
- {
- if (client->redist_default || client->redist[rib->type])
- {
- if (p->family == AF_INET)
- zsend_route_multipath (ZEBRA_IPV4_ROUTE_DELETE, client, p, rib);
+ for (ALL_LIST_ELEMENTS (zebrad.client_list, node, nnode, client))
+ {
+ if (is_default (p))
+ {
+ if (client->redist_default || client->redist[rib->type])
+ {
+ if (p->family == AF_INET)
+ zsend_route_multipath (ZEBRA_IPV4_ROUTE_DELETE, client, p,
+ rib);
#ifdef HAVE_IPV6
- if (p->family == AF_INET6)
- zsend_route_multipath (ZEBRA_IPV6_ROUTE_DELETE, client, p, rib);
-#endif /* HAVE_IPV6 */
- }
- }
- else if (client->redist[rib->type])
- {
- if (p->family == AF_INET)
- zsend_route_multipath (ZEBRA_IPV4_ROUTE_DELETE, client, p, rib);
+ if (p->family == AF_INET6)
+ zsend_route_multipath (ZEBRA_IPV6_ROUTE_DELETE, client, p,
+ rib);
+#endif /* HAVE_IPV6 */
+ }
+ }
+ else if (client->redist[rib->type])
+ {
+ if (p->family == AF_INET)
+ zsend_route_multipath (ZEBRA_IPV4_ROUTE_DELETE, client, p, rib);
#ifdef HAVE_IPV6
- if (p->family == AF_INET6)
- zsend_route_multipath (ZEBRA_IPV6_ROUTE_DELETE, client, p, rib);
-#endif /* HAVE_IPV6 */
- }
- }
+ if (p->family == AF_INET6)
+ zsend_route_multipath (ZEBRA_IPV6_ROUTE_DELETE, client, p, rib);
+#endif /* HAVE_IPV6 */
+ }
+ }
}
void
void
zebra_interface_up_update (struct interface *ifp)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct zserv *client;
if (IS_ZEBRA_DEBUG_EVENT)
zlog_debug ("MESSAGE: ZEBRA_INTERFACE_UP %s", ifp->name);
- for (node = listhead (zebrad.client_list); node; nextnode (node))
- if ((client = getdata (node)) != NULL)
- zsend_interface_update (ZEBRA_INTERFACE_UP, client, ifp);
+ for (ALL_LIST_ELEMENTS (zebrad.client_list, node, nnode, client))
+ zsend_interface_update (ZEBRA_INTERFACE_UP, client, ifp);
}
/* Interface down information. */
void
zebra_interface_down_update (struct interface *ifp)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct zserv *client;
if (IS_ZEBRA_DEBUG_EVENT)
zlog_debug ("MESSAGE: ZEBRA_INTERFACE_DOWN %s", ifp->name);
- for (node = listhead (zebrad.client_list); node; nextnode (node))
- if ((client = getdata (node)) != NULL)
- zsend_interface_update (ZEBRA_INTERFACE_DOWN, client, ifp);
+ for (ALL_LIST_ELEMENTS (zebrad.client_list, node, nnode, client))
+ zsend_interface_update (ZEBRA_INTERFACE_DOWN, client, ifp);
}
/* Interface information update. */
void
zebra_interface_add_update (struct interface *ifp)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct zserv *client;
if (IS_ZEBRA_DEBUG_EVENT)
zlog_debug ("MESSAGE: ZEBRA_INTERFACE_ADD %s", ifp->name);
- for (node = listhead (zebrad.client_list); node; nextnode (node))
- if ((client = getdata (node)) != NULL)
- if (client->ifinfo)
- zsend_interface_add (client, ifp);
+ for (ALL_LIST_ELEMENTS (zebrad.client_list, node, nnode, client))
+ if (client->ifinfo)
+ zsend_interface_add (client, ifp);
}
/*
void
zebra_interface_delete_update (struct interface *ifp)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct zserv *client;
if (IS_ZEBRA_DEBUG_EVENT)
zlog_debug ("MESSAGE: ZEBRA_INTERFACE_DELETE %s", ifp->name);
- for (node = listhead (zebrad.client_list); node; nextnode (node))
- if ((client = getdata (node)) != NULL)
- if (client->ifinfo)
- zsend_interface_delete (client, ifp);
+ for (ALL_LIST_ELEMENTS (zebrad.client_list, node, nnode, client))
+ if (client->ifinfo)
+ zsend_interface_delete (client, ifp);
}
#endif /* defined(RTM_IFANNOUNCE) || defined(HAVE_NETLINK) */
zebra_interface_address_add_update (struct interface *ifp,
struct connected *ifc)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct zserv *client;
struct prefix *p;
char buf[BUFSIZ];
router_id_add_address(ifc);
- for (node = listhead (zebrad.client_list); node; nextnode (node))
- if ((client = getdata (node)) != NULL)
- if (client->ifinfo && CHECK_FLAG (ifc->conf, ZEBRA_IFC_REAL))
- zsend_interface_address (ZEBRA_INTERFACE_ADDRESS_ADD, client, ifp, ifc);
+ for (ALL_LIST_ELEMENTS (zebrad.client_list, node, nnode, client))
+ if (client->ifinfo && CHECK_FLAG (ifc->conf, ZEBRA_IFC_REAL))
+ zsend_interface_address (ZEBRA_INTERFACE_ADDRESS_ADD, client, ifp, ifc);
}
/* Interface address deletion. */
zebra_interface_address_delete_update (struct interface *ifp,
struct connected *ifc)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct zserv *client;
struct prefix *p;
char buf[BUFSIZ];
router_id_del_address(ifc);
- for (node = listhead (zebrad.client_list); node; nextnode (node))
- if ((client = getdata (node)) != NULL)
- if (client->ifinfo && CHECK_FLAG (ifc->conf, ZEBRA_IFC_REAL))
- zsend_interface_address (ZEBRA_INTERFACE_ADDRESS_DELETE, client, ifp, ifc);
+ for (ALL_LIST_ELEMENTS (zebrad.client_list, node, nnode, client))
+ if (client->ifinfo && CHECK_FLAG (ifc->conf, ZEBRA_IFC_REAL))
+ zsend_interface_address (ZEBRA_INTERFACE_ADDRESS_DELETE, client, ifp, ifc);
}
struct listnode *node;
struct connected *c;
- for (node = l->head; node; node = node->next)
- {
- c = (struct connected *) getdata (node);
- if (prefix_same (ifc->address, c->address))
- return c;
- }
+ for (ALL_LIST_ELEMENTS_RO (l, node, c))
+ if (prefix_same (ifc->address, c->address))
+ return c;
+
return NULL;
}
else if (!list_isempty (&rid_lo_sorted_list))
{
node = listtail (&rid_lo_sorted_list);
- c = getdata (node);
+ c = listgetdata (node);
p->u.prefix4.s_addr = c->address->u.prefix4.s_addr;
}
else if (!list_isempty (&rid_all_sorted_list))
{
node = listtail (&rid_all_sorted_list);
- c = getdata (node);
+ c = listgetdata (node);
p->u.prefix4.s_addr = c->address->u.prefix4.s_addr;
}
}
rid_user_assigned.u.prefix4.s_addr = p->u.prefix4.s_addr;
router_id_get (&p2);
- for (node = listhead (zebrad.client_list); node; nextnode (node))
- if ((client = getdata (node)) != NULL)
- zsend_router_id_update (client, &p2);
+
+ for (ALL_LIST_ELEMENTS_RO (zebrad.client_list, node, client))
+ zsend_router_id_update (client, &p2);
}
void
if (prefix_same (&before, &after))
return;
- for (node = listhead (zebrad.client_list); node; nextnode (node))
- if ((client = getdata (node)) != NULL)
- zsend_router_id_update (client, &after);
+ for (ALL_LIST_ELEMENTS_RO (zebrad.client_list, node, client))
+ zsend_router_id_update (client, &after);
}
void
if (prefix_same (&before, &after))
return;
- for (node = listhead (zebrad.client_list); node; nextnode (node))
- if ((client = getdata (node)) != NULL)
- zsend_router_id_update (client, &after);
+ for (ALL_LIST_ELEMENTS_RO (zebrad.client_list, node, client))
+ zsend_router_id_update (client, &after);
}
void
int ret;
int len = 0;
struct zebra_if *zif;
+ struct rtadv_prefix *rprefix;
u_char all_nodes_addr[] = {0xff,0x02,0,0,0,0,0,0,0,0,0,0,0,0,0,1};
struct listnode *node;
}
/* Fill in prefix. */
- for (node = listhead (zif->rtadv.AdvPrefixList); node; node = nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (zif->rtadv.AdvPrefixList, node, rprefix))
{
struct nd_opt_prefix_info *pinfo;
- struct rtadv_prefix *rprefix;
-
- rprefix = getdata (node);
pinfo = (struct nd_opt_prefix_info *) (buf + len);
int
rtadv_timer (struct thread *thread)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct interface *ifp;
struct zebra_if *zif;
int period;
rtadv_event (RTADV_TIMER_MSEC, 10 /* 10 ms */);
}
- for (node = listhead (iflist); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (iflist, node, nnode, ifp))
{
- ifp = getdata (node);
-
if (if_is_loopback (ifp))
continue;
struct listnode *node;
struct rtadv_prefix *rprefix;
- for (node = listhead (rplist); node; node = nextnode (node))
- {
- rprefix = getdata (node);
- if (prefix_same (&rprefix->prefix, p))
- return rprefix;
- }
+ for (ALL_LIST_ELEMENTS_RO (rplist, node, rprefix))
+ if (prefix_same (&rprefix->prefix, p))
+ return rprefix;
return NULL;
}
if (zif->rtadv.AdvOtherConfigFlag)
vty_out (vty, " ipv6 nd other-config-flag%s", VTY_NEWLINE);
- for (node = listhead(zif->rtadv.AdvPrefixList); node; node = nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (zif->rtadv.AdvPrefixList, node, rprefix))
{
- rprefix = getdata (node);
vty_out (vty, " ipv6 nd prefix %s/%d",
inet_ntop (AF_INET6, &rprefix->prefix.u.prefix6,
(char *) buf, INET6_ADDRSTRLEN),
static int
zread_interface_add (struct zserv *client, u_short length)
{
- struct listnode *ifnode;
- struct listnode *cnode;
+ struct listnode *ifnode, *ifnnode;
+ struct listnode *cnode, *cnnode;
struct interface *ifp;
struct connected *c;
/* Interface information is needed. */
client->ifinfo = 1;
- for (ifnode = listhead (iflist); ifnode; ifnode = nextnode (ifnode))
+ for (ALL_LIST_ELEMENTS (iflist, ifnode, ifnnode, ifp))
{
- ifp = getdata (ifnode);
-
/* Skip pseudo interface. */
if (! CHECK_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE))
continue;
if (zsend_interface_add (client, ifp) < 0)
return -1;
- for (cnode = listhead (ifp->connected); cnode; nextnode (cnode))
+ for (ALL_LIST_ELEMENTS (ifp->connected, cnode, cnnode, c))
{
- c = getdata (cnode);
if (CHECK_FLAG (c->conf, ZEBRA_IFC_REAL) &&
(zsend_interface_address (ZEBRA_INTERFACE_ADDRESS_ADD, client,
ifp, c) < 0))
struct listnode *node;
struct zserv *client;
- for (node = listhead (zebrad.client_list); node; nextnode (node))
- {
- client = getdata (node);
- vty_out (vty, "Client fd %d%s", client->sock, VTY_NEWLINE);
- }
+ for (ALL_LIST_ELEMENTS_RO (zebrad.client_list, node, client))
+ vty_out (vty, "Client fd %d%s", client->sock, VTY_NEWLINE);
+
return CMD_SUCCESS;
}