summaryrefslogtreecommitdiff
path: root/isisd
diff options
context:
space:
mode:
authorpaul <paul>2005-04-07 07:30:20 +0000
committerpaul <paul>2005-04-07 07:30:20 +0000
commit1eb8ef2584833f18fb674e127d59cb5a7f771482 (patch)
treef5b09d4781de9a9b08839fefb6530e64d2d2ec31 /isisd
parent5920990fecba7e2430af3cfaa8bcbaed40d0ba1a (diff)
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. * lib/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.. * lib/linklist.c: fix up for linklist.h changes. * ospf6d/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.
Diffstat (limited to 'isisd')
-rw-r--r--isisd/isis_adjacency.c67
-rw-r--r--isisd/isis_circuit.c51
-rw-r--r--isisd/isis_dr.c19
-rw-r--r--isisd/isis_dynhn.c12
-rw-r--r--isisd/isis_events.c9
-rw-r--r--isisd/isis_flags.c2
-rw-r--r--isisd/isis_lsp.c100
-rw-r--r--isisd/isis_pdu.c65
-rw-r--r--isisd/isis_route.c107
-rw-r--r--isisd/isis_spf.c116
-rw-r--r--isisd/isis_tlv.c38
-rw-r--r--isisd/isis_zebra.c11
-rw-r--r--isisd/isisd.c58
13 files changed, 259 insertions, 396 deletions
diff --git a/isisd/isis_adjacency.c b/isisd/isis_adjacency.c
index 87609f64..0a48c070 100644
--- a/isisd/isis_adjacency.c
+++ b/isisd/isis_adjacency.c
@@ -103,12 +103,9 @@ isis_adj_lookup (u_char * sysid, struct list *adjdb)
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;
}
@@ -120,12 +117,9 @@ isis_adj_lookup_snpa (u_char * ssnpa, struct list *adjdb)
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;
}
@@ -136,17 +130,15 @@ isis_adj_lookup_snpa (u_char * ssnpa, struct list *adjdb)
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);
}
@@ -249,20 +241,16 @@ isis_adj_print (struct isis_adjacency *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);
}
@@ -400,19 +388,15 @@ isis_adj_print_vty2 (struct isis_adjacency *adj, struct vty *vty, char detail)
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);
}
@@ -463,13 +447,11 @@ void
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
@@ -484,9 +466,8 @@ isis_adj_build_neigh_list (struct list *adjdb, struct list *list)
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");
@@ -512,10 +493,8 @@ isis_adj_build_up_list (struct list *adjdb, struct list *list)
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");
diff --git a/isisd/isis_circuit.c b/isisd/isis_circuit.c
index 1a98a633..b99fa5da 100644
--- a/isisd/isis_circuit.c
+++ b/isisd/isis_circuit.c
@@ -150,13 +150,10 @@ circuit_lookup_by_ifp (struct interface *ifp, struct list *list)
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;
}
@@ -170,9 +167,8 @@ circuit_scan_by_ifp (struct interface *ifp)
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;
@@ -295,12 +291,9 @@ isis_circuit_del_addr (struct isis_circuit *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)
{
@@ -324,9 +317,8 @@ isis_circuit_del_addr (struct isis_circuit *circuit,
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;
}
@@ -338,9 +330,8 @@ isis_circuit_del_addr (struct isis_circuit *circuit,
}
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;
}
@@ -368,7 +359,7 @@ isis_circuit_del_addr (struct isis_circuit *circuit,
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;
@@ -416,12 +407,8 @@ isis_circuit_if_add (struct isis_circuit *circuit, struct 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;
}
@@ -631,14 +618,14 @@ isis_interface_config_write (struct vty *vty)
{
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);
@@ -650,7 +637,7 @@ isis_interface_config_write (struct vty *vty)
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)
@@ -901,7 +888,7 @@ DEFUN (no_ip_router_isis,
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);
@@ -912,7 +899,7 @@ DEFUN (no_ip_router_isis,
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)
diff --git a/isisd/isis_dr.c b/isisd/isis_dr.c
index 4eadc9c1..75713566 100644
--- a/isisd/isis_dr.c
+++ b/isisd/isis_dr.c
@@ -130,7 +130,7 @@ int
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;
@@ -152,9 +152,8 @@ isis_dr_elect (struct isis_circuit *circuit, int level)
/*
* 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);
@@ -215,11 +214,8 @@ isis_dr_elect (struct isis_circuit *circuit, int level)
*/
/* 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);
@@ -238,11 +234,8 @@ isis_dr_elect (struct isis_circuit *circuit, int level)
* 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
diff --git a/isisd/isis_dynhn.c b/isisd/isis_dynhn.c
index 41c36371..68257ddc 100644
--- a/isisd/isis_dynhn.c
+++ b/isisd/isis_dynhn.c
@@ -60,12 +60,9 @@ dynhn_find_by_id (u_char * id)
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;
}
@@ -114,9 +111,8 @@ dynhn_print_all (struct vty *vty)
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);
diff --git a/isisd/isis_events.c b/isisd/isis_events.c
index 66d694f6..d54036a5 100644
--- a/isisd/isis_events.c
+++ b/isisd/isis_events.c
@@ -88,7 +88,7 @@ isis_event_circuit_state_change (struct isis_circuit *circuit, int up)
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)
@@ -125,11 +125,8 @@ isis_event_system_type_change (struct isis_area *area, int newtype)
}
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);
diff --git a/isisd/isis_flags.c b/isisd/isis_flags.c
index 0ef048e2..9c861c94 100644
--- a/isisd/isis_flags.c
+++ b/isisd/isis_flags.c
@@ -43,7 +43,7 @@ flags_get_index (struct flags *flags)
else
{
node = listhead (flags->free_idcs);
- index = (int) getdata (node);
+ index = (int) listgetdata (node);
listnode_delete (flags->free_idcs, (void *) index);
}
diff --git a/isisd/isis_lsp.c b/isisd/isis_lsp.c
index 987a9b32..88d4886b 100644
--- a/isisd/isis_lsp.c
+++ b/isisd/isis_lsp.c
@@ -187,12 +187,11 @@ static void
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));
@@ -325,18 +324,15 @@ static void
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;
}
@@ -717,7 +713,7 @@ lsp_print_detail (dnode_t * node, struct vty *vty, char dynhost)
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;
@@ -739,15 +735,14 @@ lsp_print_detail (dnode_t * node, struct vty *vty, char dynhost)
/* 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)
{
@@ -777,13 +772,12 @@ lsp_print_detail (dnode_t * node, struct vty *vty, char dynhost)
}
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)
@@ -795,18 +789,17 @@ lsp_print_detail (dnode_t * node, struct vty *vty, char dynhost)
/* 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));
@@ -819,7 +812,8 @@ lsp_print_detail (dnode_t * node, struct vty *vty, char dynhost)
/* 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));
@@ -829,11 +823,12 @@ lsp_print_detail (dnode_t * node, struct vty *vty, char dynhost)
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,
@@ -850,9 +845,11 @@ lsp_print_detail (dnode_t * node, struct vty *vty, char dynhost)
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);
@@ -862,7 +859,8 @@ lsp_print_detail (dnode_t * node, struct vty *vty, char dynhost)
/* 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",
@@ -949,7 +947,7 @@ void
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;
@@ -1027,9 +1025,8 @@ lsp_build_nonpseudo (struct isis_lsp *lsp, struct isis_area *area)
/*
* 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;
@@ -1044,10 +1041,8 @@ lsp_build_nonpseudo (struct isis_lsp *lsp, struct isis_area *area)
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];
@@ -1068,10 +1063,9 @@ lsp_build_nonpseudo (struct isis_lsp *lsp, struct isis_area *area)
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));
@@ -1192,8 +1186,8 @@ lsp_tlv_fit (struct isis_lsp *lsp, struct list **from, struct list **to,
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);
}
@@ -1256,7 +1250,7 @@ static void
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;
@@ -1360,9 +1354,8 @@ lsp_build_nonpseudo (struct isis_lsp *lsp, struct isis_area *area)
/*
* 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;
@@ -1376,10 +1369,8 @@ lsp_build_nonpseudo (struct isis_lsp *lsp, struct isis_area *area)
{
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];
@@ -1402,10 +1393,9 @@ lsp_build_nonpseudo (struct isis_lsp *lsp, struct isis_area *area)
{
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));
@@ -1696,9 +1686,8 @@ lsp_non_pseudo_regenerate (struct isis_area *area, int level)
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],
@@ -1862,7 +1851,7 @@ lsp_build_pseudo (struct isis_lsp *lsp, struct isis_circuit *circuit,
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);
@@ -1893,9 +1882,8 @@ lsp_build_pseudo (struct isis_lsp *lsp, struct isis_circuit *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) ||
@@ -2127,7 +2115,7 @@ lsp_tick (struct thread *thread)
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;
@@ -2174,14 +2162,10 @@ lsp_tick (struct thread *thread)
*/
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
diff --git a/isisd/isis_pdu.c b/isisd/isis_pdu.c
index 6dcc75e9..9d3b18ad 100644
--- a/isisd/isis_pdu.c
+++ b/isisd/isis_pdu.c
@@ -80,11 +80,12 @@ static int
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))
@@ -139,14 +140,15 @@ ip_match (struct list *left, struct list *right)
{
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))
{
@@ -223,7 +225,7 @@ del_ip_addr (void *val)
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)
@@ -234,7 +236,7 @@ tlvs_to_adj_ipv4_addrs (struct tlvs *tlvs, struct isis_adjacency *adj)
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));
@@ -247,7 +249,7 @@ tlvs_to_adj_ipv4_addrs (struct tlvs *tlvs, struct isis_adjacency *adj)
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)
@@ -258,7 +260,7 @@ tlvs_to_adj_ipv6_addrs (struct tlvs *tlvs, struct isis_adjacency *adj)
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));
@@ -661,7 +663,7 @@ process_lan_hello (int level, struct isis_circuit *circuit, u_char * ssnpa)
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)
@@ -884,7 +886,7 @@ process_lan_hello (int level, struct isis_circuit *circuit, u_char * ssnpa)
{
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,
@@ -1267,7 +1269,8 @@ process_snp (int snp_type, int level, struct isis_circuit *circuit,
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;
@@ -1424,7 +1427,7 @@ process_snp (int snp_type, int level, struct isis_circuit *circuit,
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",
@@ -1440,7 +1443,7 @@ process_snp (int snp_type, int level, struct isis_circuit *circuit,
/* 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);
@@ -1507,9 +1510,9 @@ process_snp (int snp_type, int level, struct isis_circuit *circuit,
/* 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)
{
@@ -1520,7 +1523,7 @@ process_snp (int snp_type, int level, struct isis_circuit *circuit,
}
}
/* 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);
}
@@ -2178,7 +2181,7 @@ send_csnp (struct isis_circuit *circuit, int level)
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);
@@ -2200,9 +2203,9 @@ send_csnp (struct isis_circuit *circuit, int level)
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",
@@ -2275,7 +2278,7 @@ build_psnp (int level, struct isis_circuit *circuit, struct list *lsps)
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,
@@ -2313,7 +2316,7 @@ build_psnp (int level, struct isis_circuit *circuit, struct list *lsps)
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",
@@ -2343,7 +2346,7 @@ send_psnp (int level, struct isis_circuit *circuit)
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]) ||
@@ -2380,11 +2383,8 @@ send_psnp (int level, struct isis_circuit *circuit)
* 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);
@@ -2467,10 +2467,7 @@ send_lsp (struct thread *thread)
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
diff --git a/isisd/isis_route.c b/isisd/isis_route.c
index 3ef90380..04346d4a 100644
--- a/isisd/isis_route.c
+++ b/isisd/isis_route.c
@@ -59,9 +59,8 @@ isis_nexthop_create (struct in_addr *ip, unsigned int ifindex)
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)
@@ -106,9 +105,8 @@ nexthoplookup (struct list *nexthops, struct in_addr *ip,
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;
@@ -133,8 +131,8 @@ nexthops_print (struct list *nhs)
{
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 */
@@ -165,9 +163,8 @@ isis_nexthop6_create (struct in6_addr *ip6, unsigned int ifindex)
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)
@@ -203,9 +200,8 @@ nexthop6lookup (struct list *nexthops6, struct in6_addr *ip6,
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;
@@ -230,8 +226,8 @@ nexthops6_print (struct list *nhs6)
{
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 */
@@ -240,14 +236,14 @@ static void
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))
{
@@ -262,16 +258,15 @@ adjinfo2nexthop (struct list *nexthops, struct isis_adjacency *adj)
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))
{
@@ -289,7 +284,7 @@ isis_route_info_new (uint32_t cost, uint32_t depth, u_char family,
{
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)
@@ -302,21 +297,15 @@ isis_route_info_new (uint32_t cost, uint32_t depth, u_char family,
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 */
@@ -363,7 +352,7 @@ static int
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;
@@ -373,40 +362,28 @@ isis_route_info_same (struct isis_route_info *new,
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 */
@@ -416,12 +393,11 @@ isis_route_info_same (struct isis_route_info *new,
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);
@@ -433,12 +409,11 @@ isis_nexthops_merge (struct list *new, struct list *old)
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);
diff --git a/isisd/isis_spf.c b/isisd/isis_spf.c
index 90a9ac58..dc5765a5 100644
--- a/isisd/isis_spf.c
+++ b/isisd/isis_spf.c
@@ -67,18 +67,13 @@ union_adjlist (struct list *target, struct list *source)
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);
}
@@ -89,16 +84,16 @@ union_adjlist (struct list *target, struct list *source)
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;
@@ -360,9 +355,8 @@ isis_find_vertex (struct list *list, void *id, enum vertextype vtype)
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)
@@ -426,9 +420,11 @@ isis_spf_add2tent (struct isis_spftree *spftree, enum vertextype 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);
@@ -443,8 +439,9 @@ isis_spf_add2tent (struct isis_spftree *spftree, enum vertextype vtype,
{
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;
@@ -586,10 +583,8 @@ lspfragloop:
{
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))
@@ -604,10 +599,9 @@ lspfragloop:
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;
@@ -620,10 +614,9 @@ lspfragloop:
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;
@@ -636,10 +629,9 @@ lspfragloop:
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;
@@ -656,11 +648,11 @@ lspfragloop:
if (fragnode == NULL)
fragnode = listhead (lsp->lspu.frags);
else
- nextnode (fragnode);
+ fragnode = listnextnode (fragnode);
if (fragnode)
{
- lsp = getdata (fragnode);
+ lsp = listgetdata (fragnode);
goto lspfragloop;
}
@@ -672,7 +664,7 @@ isis_spf_process_pseudo_lsp (struct isis_spftree *spftree,
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;
@@ -685,11 +677,8 @@ pseudofragloop:
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 */
@@ -709,11 +698,11 @@ pseudofragloop:
if (fragnode == NULL)
fragnode = listhead (lsp->lspu.frags);
else
- nextnode (fragnode);
+ fragnode = listnextnode (fragnode);
if (fragnode)
{
- lsp = getdata (fragnode);
+ lsp = listgetdata (fragnode);
goto pseudofragloop;
}
@@ -726,7 +715,9 @@ isis_spf_preload_tent (struct isis_spftree *spftree,
{
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;
@@ -739,9 +730,8 @@ isis_spf_preload_tent (struct isis_spftree *spftree,
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))
@@ -758,11 +748,8 @@ isis_spf_preload_tent (struct isis_spftree *spftree,
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,
@@ -773,11 +760,9 @@ isis_spf_preload_tent (struct isis_spftree *spftree,
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,
@@ -803,10 +788,10 @@ isis_spf_preload_tent (struct isis_spftree *spftree,
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)
@@ -840,7 +825,7 @@ isis_spf_preload_tent (struct isis_spftree *spftree,
default:
zlog_warn ("isis_spf_preload_tent unknow adj type");
}
- nextnode (anode);
+ anode = listnextnode (anode);
}
list_delete (adj_list);
/*
@@ -990,7 +975,7 @@ isis_run_spf (struct isis_area *area, int level, int family)
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))
@@ -1262,7 +1247,7 @@ isis_spf_schedule6 (struct isis_area *area, int level)
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;
@@ -1272,9 +1257,9 @@ isis_print_paths (struct vty *vty, struct list *paths)
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)
@@ -1285,8 +1270,7 @@ isis_print_paths (struct vty *vty, struct list *paths)
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);
@@ -1326,10 +1310,8 @@ DEFUN (show_isis_topology,
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);
@@ -1372,10 +1354,8 @@ DEFUN (show_isis_topology_l1,
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);
@@ -1414,10 +1394,8 @@ DEFUN (show_isis_topology_l2,
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);
diff --git a/isisd/isis_tlv.c b/isisd/isis_tlv.c
index bc653632..3dae5d89 100644
--- a/isisd/isis_tlv.c
+++ b/isisd/isis_tlv.c
@@ -776,9 +776,8 @@ tlv_add_area_addrs (struct list *area_addrs, struct stream *stream)
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;
@@ -797,7 +796,7 @@ err:
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;
@@ -806,9 +805,8 @@ tlv_add_is_neighs (struct list *is_neighs, struct stream *stream)
*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);
@@ -834,15 +832,14 @@ tlv_add_is_neighs (struct list *is_neighs, struct stream *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);
@@ -901,15 +898,14 @@ tlv_add_checksum (struct checksum *checksum, struct stream *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);
@@ -934,15 +930,14 @@ tlv_add_dynamic_hostname (struct hostname *hostname, struct stream *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);
@@ -966,15 +961,14 @@ tlv_add_lsp_entries (struct list *lsps, struct stream *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 =
@@ -1005,15 +999,14 @@ tlv_add_ipv4_reachs (struct list *ipv4_reachs, struct stream *stream)
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);
@@ -1031,15 +1024,14 @@ tlv_add_ipv6_addrs (struct list *ipv6_addrs, struct stream *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);
diff --git a/isisd/isis_zebra.c b/isisd/isis_zebra.c
index 4690fe31..f45b9c13 100644
--- a/isisd/isis_zebra.c
+++ b/isisd/isis_zebra.c
@@ -280,9 +280,8 @@ isis_zebra_route_add_ipv4 (struct prefix *prefix,
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)
{
@@ -379,10 +378,8 @@ isis_zebra_route_add_ipv6 (struct prefix *prefix,
/* 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))
{
@@ -458,10 +455,8 @@ isis_zebra_route_del_ipv6 (struct prefix *prefix,
/* 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))
{
diff --git a/isisd/isisd.c b/isisd/isisd.c
index 229f1356..c2bb9064 100644
--- a/isisd/isisd.c
+++ b/isisd/isisd.c
@@ -144,9 +144,9 @@ struct isis_area *
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))
@@ -185,7 +185,7 @@ int
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);
@@ -198,13 +198,9 @@ isis_area_destroy (struct vty *vty, const char *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);
@@ -225,7 +221,7 @@ area_net_title (struct vty *vty, u_char *net_title)
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;
@@ -284,7 +280,7 @@ area_net_title (struct vty *vty, u_char *net_title)
}
/* 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))
{
@@ -318,7 +314,7 @@ area_clear_net_title (struct vty *vty, u_char *net_title)
{
struct isis_area *area;
struct area_addr addr, *addrp = NULL;
- struct listnode *node;
+ struct listnode *node, *nnode;
u_char buff[255];
area = vty->index;
@@ -338,7 +334,7 @@ area_clear_net_title (struct vty *vty, u_char *net_title)
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;
@@ -362,7 +358,7 @@ area_clear_net_title (struct vty *vty, u_char *net_title)
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;
@@ -374,20 +370,16 @@ show_clns_neigh (struct vty *vty, char detail)
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++)
@@ -902,16 +894,15 @@ DEFUN (show_database,
"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++)
@@ -941,16 +932,15 @@ DEFUN (show_database_detail,
"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++)
@@ -1222,7 +1212,7 @@ DEFUN (no_is_type,
* 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;
@@ -1603,10 +1593,10 @@ DEFUN (show_isis_generated_topology,
"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)
{
@@ -1852,10 +1842,10 @@ isis_config_write (struct vty *vty)
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);
@@ -1864,7 +1854,7 @@ isis_config_write (struct vty *vty)
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,