Replace XMALLOC + memset with XCALLOC. Fix some indentation issues.
The only really significant change is simplified isis_delete_adj
function in isis_adjacency.c.
+2005-09-28 Hasso Tepper <hasso at quagga.net>
+
+ * *.c: Massive cleanup of lists loops. Stop abusing ALL_LIST_ELEMENTS.
+ Replace XMALLOC + memset with XCALLOC. Fix some indentation issues.
+ The only really significant change is simplified isis_delete_adj
+ function in isis_adjacency.c.
+
2005-09-28 Hasso Tepper <hasso at quagga.net>
* isis_dynh.c, isisd.h: Implement dynamic hostname cache cleanup.
return NULL;
}
-
struct isis_adjacency *
isis_adj_lookup_snpa (u_char * ssnpa, struct list *adjdb)
{
return NULL;
}
-/*
- * When we recieve a NULL list, we will know its p2p
- */
void
isis_delete_adj (struct isis_adjacency *adj, struct list *adjdb)
{
- struct isis_adjacency *adj2 = NULL;
- struct listnode *node;
-
+ if (!adj)
+ return;
+ /* When we recieve a NULL list, we will know its p2p. */
if (adjdb)
- {
- for (ALL_LIST_ELEMENTS_RO (adjdb, node, adj2))
- if (adj2 == adj)
- break;
-
- listnode_delete (adjdb, adj);
- }
+ listnode_delete (adjdb, adj);
if (adj->ipv4_addrs)
list_delete (adj->ipv4_addrs);
if (adj->ipv6_addrs)
list_delete (adj->ipv6_addrs);
#endif
- if (adj)
- {
- XFREE (MTYPE_ISIS_ADJACENCY, adj);
- }
- else
- {
- zlog_warn ("tried to delete a non-existent adjacency");
- }
-
+
+ XFREE (MTYPE_ISIS_ADJACENCY, adj);
return;
}
struct isis_circuit *circuit;
int i;
- circuit = XMALLOC (MTYPE_ISIS_CIRCUIT, sizeof (struct isis_circuit));
+ circuit = XCALLOC (MTYPE_ISIS_CIRCUIT, sizeof (struct isis_circuit));
if (circuit)
{
- memset (circuit, 0, sizeof (struct isis_circuit));
/* set default metrics for circuit */
for (i = 0; i < 2; i++)
{
{
int write = 0;
- struct listnode *node, *nnode;
- struct listnode *node2, *nnode2;
+ struct listnode *node, *node2;
struct interface *ifp;
struct isis_area *area;
struct isis_circuit *c;
int i;
- for (ALL_LIST_ELEMENTS (iflist, node, nnode, ifp))
+ for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
{
/* IF name */
vty_out (vty, "interface %s%s", ifp->name, VTY_NEWLINE);
write++;
}
/* ISIS Circuit */
- for (ALL_LIST_ELEMENTS (isis->area_list, node2, nnode2, area))
+ for (ALL_LIST_ELEMENTS_RO (isis->area_list, node2, 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, *nnode;
+ struct listnode *node;
ifp = (struct interface *) vty->index;
assert (ifp);
vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
return CMD_WARNING;
}
- for (ALL_LIST_ELEMENTS (area->circuit_list, node, nnode, circuit))
+ for (ALL_LIST_ELEMENTS_RO (area->circuit_list, node, circuit))
if (circuit->interface == ifp)
break;
if (!circuit)
isis_dr_elect (struct isis_circuit *circuit, int level)
{
struct list *adjdb;
- struct listnode *node, *nnode;
+ struct listnode *node;
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 (ALL_LIST_ELEMENTS (list, node, nnode, adj))
+ for (ALL_LIST_ELEMENTS_RO (list, node, adj))
{
/* clear flag for show output */
adj->dis_record[level - 1].dis = ISIS_IS_NOT_DIS;
*/
/* rotate the history log */
- for (ALL_LIST_ELEMENTS (list, node, nnode, adj))
+ for (ALL_LIST_ELEMENTS_RO (list, node, adj))
isis_check_dr_change (adj, level);
/* commence */
* if yes rotate the history log
*/
- for (ALL_LIST_ELEMENTS (list, node, nnode, adj))
+ for (ALL_LIST_ELEMENTS_RO (list, node, adj))
isis_check_dr_change (adj, level);
/*
void
isis_event_system_type_change (struct isis_area *area, int newtype)
{
- struct listnode *node, *nnode;
+ struct listnode *node;
struct isis_circuit *circuit;
if (isis->debugs & DEBUG_EVENTS)
}
area->is_type = newtype;
- for (ALL_LIST_ELEMENTS (area->circuit_list, node, nnode, circuit))
+ for (ALL_LIST_ELEMENTS_RO (area->circuit_list, node, circuit))
isis_event_circuit_type_change (circuit, newtype);
spftree_area_init (area);
lsp_seqnum_update (struct isis_lsp *lsp0)
{
struct isis_lsp *lsp;
- struct listnode *node, *nnode;
+ struct listnode *node;
lsp_inc_seqnum (lsp0, 0);
if (!lsp0->lspu.frags)
return;
- for (ALL_LIST_ELEMENTS (lsp0->lspu.frags, node, nnode, lsp))
+ for (ALL_LIST_ELEMENTS_RO (lsp0->lspu.frags, node, lsp))
lsp_inc_seqnum (lsp, 0);
return;
struct isis_lsp *lsp = dnode_get (node);
struct area_addr *area_addr;
int i;
- struct listnode *lnode, *lnnode;
+ struct listnode *lnode;
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)
- for (ALL_LIST_ELEMENTS (lsp->tlv_data.area_addrs, lnode,
- lnnode, area_addr))
+ for (ALL_LIST_ELEMENTS_RO (lsp->tlv_data.area_addrs, lnode, area_addr))
{
vty_out (vty, " Area Address: %s%s",
isonet_print (area_addr->area_addr, area_addr->addr_len),
}
if (lsp->tlv_data.ipv4_addrs)
- for (ALL_LIST_ELEMENTS (lsp->tlv_data.ipv4_addrs, lnode,
- lnnode, ipv4_addr))
+ for (ALL_LIST_ELEMENTS_RO (lsp->tlv_data.ipv4_addrs, lnode, ipv4_addr))
{
memcpy (ipv4_address, inet_ntoa (*ipv4_addr), sizeof (ipv4_address));
vty_out (vty, " IP: %s%s", ipv4_address, VTY_NEWLINE);
/* for the IS neighbor tlv */
if (lsp->tlv_data.is_neighs)
- for (ALL_LIST_ELEMENTS (lsp->tlv_data.is_neighs, lnode, lnnode, is_neigh))
+ for (ALL_LIST_ELEMENTS_RO (lsp->tlv_data.is_neighs, lnode, is_neigh))
{
lspid_print (is_neigh->neigh_id, LSPid, dynhost, 0);
vty_out (vty, " Metric: %-10d IS %s%s",
/* for the internal reachable tlv */
if (lsp->tlv_data.ipv4_int_reachs)
- for (ALL_LIST_ELEMENTS (lsp->tlv_data.ipv4_int_reachs, lnode,
- lnnode, ipv4_reach))
+ for (ALL_LIST_ELEMENTS_RO (lsp->tlv_data.ipv4_int_reachs, lnode,
+ 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)
- for (ALL_LIST_ELEMENTS (lsp->tlv_data.ipv4_ext_reachs, lnode,
- lnnode, ipv4_reach))
+ for (ALL_LIST_ELEMENTS_RO (lsp->tlv_data.ipv4_ext_reachs, lnode,
+ ipv4_reach))
{
memcpy (ipv4_reach_prefix, inet_ntoa (ipv4_reach->prefix),
sizeof (ipv4_reach_prefix));
/* IPv6 tlv */
#ifdef HAVE_IPV6
if (lsp->tlv_data.ipv6_reachs)
- for (ALL_LIST_ELEMENTS (lsp->tlv_data.ipv6_reachs, lnode,
- lnnode, ipv6_reach))
+ for (ALL_LIST_ELEMENTS_RO (lsp->tlv_data.ipv6_reachs, lnode, ipv6_reach))
{
memset (&in6, 0, sizeof (in6));
memcpy (in6.s6_addr, ipv6_reach->prefix,
/* TE IS neighbor tlv */
if (lsp->tlv_data.te_is_neighs)
- for (ALL_LIST_ELEMENTS (lsp->tlv_data.te_is_neighs, lnode,
- lnnode, te_is_neigh))
+ for (ALL_LIST_ELEMENTS_RO (lsp->tlv_data.te_is_neighs, lnode, te_is_neigh))
{
uint32_t metric;
memcpy (&metric, te_is_neigh->te_metric, 3);
/* TE IPv4 tlv */
if (lsp->tlv_data.te_ipv4_reachs)
- for (ALL_LIST_ELEMENTS (lsp->tlv_data.te_ipv4_reachs, lnode,
- lnnode, te_ipv4_reach))
+ for (ALL_LIST_ELEMENTS_RO (lsp->tlv_data.te_ipv4_reachs, lnode,
+ te_ipv4_reach))
{
/* FIXME: There should be better way to output this stuff. */
vty_out (vty, " Metric: %-10d IP-Extended %s/%d%s",
{
struct is_neigh *is_neigh;
struct te_is_neigh *te_is_neigh;
- struct listnode *node, *nnode, *ipnode, *ipnnode;
+ struct listnode *node, *ipnode;
int level = lsp->level;
struct isis_circuit *circuit;
struct prefix_ipv4 *ipv4;
tlv_data.is_neighs = list_new ();
tlv_data.is_neighs->del = free_tlv;
}
- is_neigh = XMALLOC (MTYPE_ISIS_TLV, sizeof (struct is_neigh));
- memset (is_neigh, 0, sizeof (struct is_neigh));
+ is_neigh = XCALLOC (MTYPE_ISIS_TLV, sizeof (struct is_neigh));
memcpy (&is_neigh->neigh_id, area->topology_baseis, ISIS_SYS_ID_LEN);
is_neigh->neigh_id[ISIS_SYS_ID_LEN - 1] = (1 & 0xFF);
/*
* Then build lists of tlvs related to circuits
*/
- for (ALL_LIST_ELEMENTS (area->circuit_list, node, nnode, circuit))
+ for (ALL_LIST_ELEMENTS_RO (area->circuit_list, node, circuit))
{
if (circuit->state != C_STATE_UP)
continue;
tlv_data.ipv4_int_reachs = list_new ();
tlv_data.ipv4_int_reachs->del = free_tlv;
}
- for (ALL_LIST_ELEMENTS (circuit->ip_addrs, ipnode, ipnnode, ipv4))
+ for (ALL_LIST_ELEMENTS_RO (circuit->ip_addrs, ipnode, ipv4))
{
ipreach =
XMALLOC (MTYPE_ISIS_TLV, sizeof (struct ipv4_reachability));
tlv_data.te_ipv4_reachs = list_new ();
tlv_data.te_ipv4_reachs->del = free_tlv;
}
- for (ALL_LIST_ELEMENTS (circuit->ip_addrs, ipnode, ipnnode, ipv4))
+ for (ALL_LIST_ELEMENTS_RO (circuit->ip_addrs, ipnode, ipv4))
{
/* FIXME All this assumes that we have no sub TLVs. */
te_ipreach = XCALLOC (MTYPE_ISIS_TLV,
tlv_data.ipv6_reachs = list_new ();
tlv_data.ipv6_reachs->del = free_tlv;
}
- for (ALL_LIST_ELEMENTS (circuit->ipv6_non_link, ipnode, ipnnode,
- ipv6))
+ for (ALL_LIST_ELEMENTS_RO (circuit->ipv6_non_link, ipnode, ipv6))
{
ip6reach =
XCALLOC (MTYPE_ISIS_TLV, sizeof (struct ipv6_reachability));
struct te_is_neigh *te_is_neigh;
struct es_neigh *es_neigh;
struct list *adj_list;
- struct listnode *node, *nnode;
+ struct listnode *node;
struct isis_passwd *passwd;
assert (circuit);
adj_list = list_new ();
isis_adj_build_up_list (circuit->u.bc.adjdb[level - 1], adj_list);
- for (ALL_LIST_ELEMENTS (adj_list, node, nnode, adj))
+ for (ALL_LIST_ELEMENTS_RO (adj_list, node, adj))
{
if (adj->circuit_t & level)
{
struct isis_circuit *circuit;
struct isis_lsp *lsp;
struct list *lsp_list;
- struct listnode *lspnode, *lspnnode, *cnode;
+ struct listnode *lspnode, *cnode;
dnode_t *dnode, *dnode_next;
int level;
{
for (ALL_LIST_ELEMENTS_RO (area->circuit_list, cnode, circuit))
{
- for (ALL_LIST_ELEMENTS (lsp_list, lspnode, lspnnode, lsp))
+ for (ALL_LIST_ELEMENTS_RO (lsp_list, lspnode, lsp))
{
if (ISIS_CHECK_FLAG (lsp->SRMflags, circuit))
{
build_topology_lsp_data (struct isis_lsp *lsp, struct isis_area *area,
int lsp_top_num)
{
- struct listnode *node, *nnode;
+ struct listnode *node;
struct arc *arc;
struct is_neigh *is_neigh;
struct te_is_neigh *te_is_neigh;
/* Add reachability for this IS for simulated 1. */
if (lsp_top_num == 1)
{
- is_neigh = XMALLOC (MTYPE_ISIS_TLV, sizeof (struct is_neigh));
- memset (is_neigh, 0, sizeof (struct is_neigh));
+ is_neigh = XCALLOC (MTYPE_ISIS_TLV, sizeof (struct is_neigh));
memcpy (&is_neigh->neigh_id, isis->sysid, ISIS_SYS_ID_LEN);
LSP_PSEUDO_ID (is_neigh->neigh_id) = 0x00;
}
/* Add IS reachabilities. */
- for (ALL_LIST_ELEMENTS (area->topology, node, nnode, arc))
+ for (ALL_LIST_ELEMENTS_RO (area->topology, node, arc))
{
int to_lsp = 0;
area_match (struct list *left, struct list *right)
{
struct area_addr *addr1, *addr2;
- struct listnode *node1, *nnode1;
- struct listnode *node2, *nnode2;
+ struct listnode *node1, *node2;
- for (ALL_LIST_ELEMENTS (left, node1, nnode1, addr1))
+ for (ALL_LIST_ELEMENTS_RO (left, node1, addr1))
{
- for (ALL_LIST_ELEMENTS (right, node2, nnode2, addr2))
+ for (ALL_LIST_ELEMENTS_RO (right, node2, 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, *nnode1;
- struct listnode *node2, *nnode2;
+ struct listnode *node1, *node2;
if ((left == NULL) || (right == NULL))
return 0;
- for (ALL_LIST_ELEMENTS (left, node1, nnode1, ip1))
+ for (ALL_LIST_ELEMENTS_RO (left, node1, ip1))
{
- for (ALL_LIST_ELEMENTS (right, node2, nnode2, ip2))
+ for (ALL_LIST_ELEMENTS_RO (right, node2, ip2))
{
if (ip_same_subnet (ip1, ip2))
{
static void
tlvs_to_adj_ipv4_addrs (struct tlvs *tlvs, struct isis_adjacency *adj)
{
- struct listnode *node, *nnode;
+ struct listnode *node;
struct in_addr *ipv4_addr, *malloced;
if (adj->ipv4_addrs)
adj->ipv4_addrs = list_new ();
if (tlvs->ipv4_addrs)
{
- for (ALL_LIST_ELEMENTS (tlvs->ipv4_addrs, node, nnode, ipv4_addr))
+ for (ALL_LIST_ELEMENTS_RO (tlvs->ipv4_addrs, node, 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, *nnode;
+ struct listnode *node;
struct in6_addr *ipv6_addr, *malloced;
if (adj->ipv6_addrs)
adj->ipv6_addrs = list_new ();
if (tlvs->ipv6_addrs)
{
- for (ALL_LIST_ELEMENTS (tlvs->ipv6_addrs, node, nnode, ipv6_addr))
+ for (ALL_LIST_ELEMENTS_RO (tlvs->ipv6_addrs, node, 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, *nnode;
+ struct listnode *node;
if ((stream_get_endp (circuit->rcv_stream) -
stream_get_getp (circuit->rcv_stream)) < ISIS_LANHELLO_HDRLEN)
{
if (adj->adj_state != ISIS_ADJ_UP)
{
- for (ALL_LIST_ELEMENTS (tlvs.lan_neighs, node, nnode, snpa))
+ for (ALL_LIST_ELEMENTS_RO (tlvs.lan_neighs, node, snpa))
if (!memcmp (snpa, circuit->u.bc.snpa, ETH_ALEN))
{
isis_adj_state_change (adj, ISIS_ADJ_UP,
typechar, snpa_print (ssnpa), circuit->interface->name);
if (tlvs.lsp_entries)
{
- for (ALL_LIST_ELEMENTS (tlvs.lsp_entries, node, nnode, entry))
+ for (ALL_LIST_ELEMENTS_RO (tlvs.lsp_entries, node, 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)
{
- for (ALL_LIST_ELEMENTS (tlvs.lsp_entries, node, nnode, entry))
+ for (ALL_LIST_ELEMENTS_RO (tlvs.lsp_entries, node, entry))
{
lsp = lsp_search (entry->lsp_id, circuit->area->lspdb[level - 1]);
own_lsp = !memcmp (entry->lsp_id, isis->sysid, ISIS_SYS_ID_LEN);
}
}
/* on remaining LSPs we set SRM (neighbor knew not of) */
- for (ALL_LIST_ELEMENTS (lsp_list, node2, nnode2, lsp))
+ for (ALL_LIST_ELEMENTS_RO (lsp_list, node, 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, *nnode;
+ struct listnode *node;
struct isis_lsp *lsp;
memset (start, 0x00, ISIS_SYS_ID_LEN + 2);
circuit->area->area_tag, level, circuit->interface->name,
/* FIXME: use %z when we stop supporting old compilers. */
(unsigned long) STREAM_SIZE (circuit->snd_stream));
- for (ALL_LIST_ELEMENTS (list, node, nnode, lsp))
+ for (ALL_LIST_ELEMENTS_RO (list, node, 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, *nnode;
+ struct listnode *node;
if (level == 1)
fill_fixed_hdr_andstream (&fixed_hdr, L1_PARTIAL_SEQ_NUM,
if (isis->debugs & DEBUG_SNP_PACKETS)
{
- for (ALL_LIST_ELEMENTS (lsps, node, nnode, lsp))
+ for (ALL_LIST_ELEMENTS_RO (lsps, node, 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, *nnode;
+ struct listnode *node;
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 (ALL_LIST_ELEMENTS (list, node, nnode, lsp))
+ for (ALL_LIST_ELEMENTS_RO (list, node, lsp))
ISIS_CLEAR_FLAG (lsp->SSNflags, circuit);
}
}
return nexthop;
}
- nexthop = XMALLOC (MTYPE_ISIS_NEXTHOP, sizeof (struct isis_nexthop));
+ nexthop = XCALLOC (MTYPE_ISIS_NEXTHOP, sizeof (struct isis_nexthop));
if (!nexthop)
{
zlog_err ("ISIS-Rte: isis_nexthop_create: out of memory!");
}
- memset (nexthop, 0, sizeof (struct isis_nexthop));
nexthop->ifindex = ifindex;
memcpy (&nexthop->ip, ip, sizeof (struct in_addr));
listnode_add (isis->nexthops, nexthop);
struct isis_nexthop6 *nexthop6;
- nexthop6 = XMALLOC (MTYPE_ISIS_NEXTHOP6, sizeof (struct isis_nexthop6));
+ nexthop6 = XCALLOC (MTYPE_ISIS_NEXTHOP6, sizeof (struct isis_nexthop6));
if (!nexthop6)
{
zlog_err ("ISIS-Rte: isis_nexthop_create6: out of memory!");
}
- memset (nexthop6, 0, sizeof (struct isis_nexthop6));
nexthop6->ifindex = ifindex;
memcpy (&nexthop6->ip6, ip6, sizeof (struct in6_addr));
nexthop6->lock++;
adjinfo2nexthop (struct list *nexthops, struct isis_adjacency *adj)
{
struct isis_nexthop *nh;
- struct listnode *node, *nnode;
+ struct listnode *node;
struct in_addr *ipv4_addr;
if (adj->ipv4_addrs == NULL)
return;
- for (ALL_LIST_ELEMENTS (adj->ipv4_addrs, node, nnode, ipv4_addr))
+ for (ALL_LIST_ELEMENTS_RO (adj->ipv4_addrs, node, ipv4_addr))
{
if (!nexthoplookup (nexthops, ipv4_addr,
adj->circuit->interface->ifindex))
static void
adjinfo2nexthop6 (struct list *nexthops6, struct isis_adjacency *adj)
{
- struct listnode *node, *nnode;
+ struct listnode *node;
struct in6_addr *ipv6_addr;
struct isis_nexthop6 *nh6;
if (!adj->ipv6_addrs)
return;
- for (ALL_LIST_ELEMENTS (adj->ipv6_addrs, node, nnode, ipv6_addr))
+ for (ALL_LIST_ELEMENTS_RO (adj->ipv6_addrs, node, ipv6_addr))
{
if (!nexthop6lookup (nexthops6, ipv6_addr,
adj->circuit->interface->ifindex))
{
struct isis_route_info *rinfo;
struct isis_adjacency *adj;
- struct listnode *node, *nnode;
+ struct listnode *node;
- rinfo = XMALLOC (MTYPE_ISIS_ROUTE_INFO, sizeof (struct isis_route_info));
+ rinfo = XCALLOC (MTYPE_ISIS_ROUTE_INFO, sizeof (struct isis_route_info));
if (!rinfo)
{
zlog_err ("ISIS-Rte: isis_route_info_new: out of memory!");
return NULL;
}
- memset (rinfo, 0, sizeof (struct isis_route_info));
if (family == AF_INET)
{
rinfo->nexthops = list_new ();
- for (ALL_LIST_ELEMENTS (adjacencies, node, nnode, adj))
+ for (ALL_LIST_ELEMENTS_RO (adjacencies, node, adj))
adjinfo2nexthop (rinfo->nexthops, adj);
}
#ifdef HAVE_IPV6
if (family == AF_INET6)
{
rinfo->nexthops6 = list_new ();
- for (ALL_LIST_ELEMENTS (adjacencies, node, nnode, adj))
+ for (ALL_LIST_ELEMENTS_RO (adjacencies, node, adj))
adjinfo2nexthop6 (rinfo->nexthops6, adj);
}
isis_route_info_same (struct isis_route_info *new,
struct isis_route_info *old, u_char family)
{
- struct listnode *node, *nnode;
+ struct listnode *node;
struct isis_nexthop *nexthop;
#ifdef HAVE_IPV6
struct isis_nexthop6 *nexthop6;
if (family == AF_INET)
{
- for (ALL_LIST_ELEMENTS (new->nexthops, node, nnode, nexthop))
+ for (ALL_LIST_ELEMENTS_RO (new->nexthops, node, nexthop))
if (nexthoplookup (old->nexthops, &nexthop->ip, nexthop->ifindex)
== 0)
return 0;
- for (ALL_LIST_ELEMENTS (old->nexthops, node, nnode, nexthop))
+ for (ALL_LIST_ELEMENTS_RO (old->nexthops, node, nexthop))
if (nexthoplookup (new->nexthops, &nexthop->ip, nexthop->ifindex)
== 0)
return 0;
#ifdef HAVE_IPV6
else if (family == AF_INET6)
{
- for (ALL_LIST_ELEMENTS (new->nexthops6, node, nnode, nexthop6))
+ for (ALL_LIST_ELEMENTS_RO (new->nexthops6, node, nexthop6))
if (nexthop6lookup (old->nexthops6, &nexthop6->ip6,
nexthop6->ifindex) == 0)
return 0;
- for (ALL_LIST_ELEMENTS (old->nexthops6, node, nnode, nexthop6))
+ for (ALL_LIST_ELEMENTS_RO (old->nexthops6, node, nexthop6))
if (nexthop6lookup (new->nexthops6, &nexthop6->ip6,
nexthop6->ifindex) == 0)
return 0;
static void
isis_nexthops_merge (struct list *new, struct list *old)
{
- struct listnode *node, *nnode;
+ struct listnode *node;
struct isis_nexthop *nexthop;
- for (ALL_LIST_ELEMENTS (new, node, nnode, nexthop))
+ for (ALL_LIST_ELEMENTS_RO (new, node, nexthop))
{
if (nexthoplookup (old, &nexthop->ip, nexthop->ifindex))
continue;
static void
isis_nexthops6_merge (struct list *new, struct list *old)
{
- struct listnode *node, *nnode;
+ struct listnode *node;
struct isis_nexthop6 *nexthop6;
- for (ALL_LIST_ELEMENTS (new, node, nnode, nexthop6))
+ for (ALL_LIST_ELEMENTS_RO (new, node, nexthop6))
{
if (nexthop6lookup (old, &nexthop6->ip6, nexthop6->ifindex))
continue;
static void
remove_excess_adjs (struct list *adjs)
{
- struct listnode *node, *nnode, *excess = NULL;
+ struct listnode *node, *excess = NULL;
struct isis_adjacency *adj, *candidate = NULL;
int comp;
- for (ALL_LIST_ELEMENTS (adjs, node, nnode, adj))
+ for (ALL_LIST_ELEMENTS_RO (adjs, node, adj))
{
if (excess == NULL)
excess = node;
{
struct isis_spftree *tree;
- tree = XMALLOC (MTYPE_ISIS_SPFTREE, sizeof (struct isis_spftree));
+ tree = XCALLOC (MTYPE_ISIS_SPFTREE, sizeof (struct isis_spftree));
if (tree == NULL)
{
zlog_err ("ISIS-Spf: isis_spftree_new Out of memory!");
return NULL;
}
- memset (tree, 0, sizeof (struct isis_spftree));
tree->tents = list_new ();
tree->paths = list_new ();
{
struct isis_vertex *vertex;
- vertex = XMALLOC (MTYPE_ISIS_VERTEX, sizeof (struct isis_vertex));
+ vertex = XCALLOC (MTYPE_ISIS_VERTEX, sizeof (struct isis_vertex));
if (vertex == NULL)
{
zlog_err ("isis_vertex_new Out of memory!");
return NULL;
}
- memset (vertex, 0, sizeof (struct isis_vertex));
vertex->type = vtype;
switch (vtype)
{
struct isis_lsp *lsp, uint16_t cost,
uint16_t depth, int family)
{
- struct listnode *node, *nnode, *fragnode = NULL;
+ struct listnode *node, *fragnode = NULL;
struct is_neigh *is_neigh;
struct te_is_neigh *te_is_neigh;
enum vertextype vtype;
}
if (lsp->tlv_data.is_neighs)
- for (ALL_LIST_ELEMENTS (lsp->tlv_data.is_neighs, node, nnode, is_neigh))
+ for (ALL_LIST_ELEMENTS_RO (lsp->tlv_data.is_neighs, node, is_neigh))
{
vtype = LSP_PSEUDO_ID (is_neigh->neigh_id) ? VTYPE_PSEUDO_IS
: VTYPE_NONPSEUDO_IS;
}
}
if (lsp->tlv_data.te_is_neighs)
- for (ALL_LIST_ELEMENTS (lsp->tlv_data.te_is_neighs, node, nnode, te_is_neigh))
+ for (ALL_LIST_ELEMENTS_RO (lsp->tlv_data.te_is_neighs, node, te_is_neigh))
{
vtype = LSP_PSEUDO_ID (te_is_neigh->neigh_id) ? VTYPE_PSEUDO_TE_IS
: VTYPE_NONPSEUDO_TE_IS;
{
struct isis_vertex *vertex;
struct isis_circuit *circuit;
- struct listnode *cnode, *cnnode;
- struct listnode *anode;
- struct listnode *ipnode, *ipnnode;
+ struct listnode *cnode, *anode, *ipnode;
struct isis_adjacency *adj;
struct isis_lsp *lsp;
struct list *adj_list;
struct prefix_ipv6 *ipv6;
#endif /* HAVE_IPV6 */
- for (ALL_LIST_ELEMENTS (area->circuit_list, cnode, cnnode, circuit))
+ for (ALL_LIST_ELEMENTS_RO (area->circuit_list, cnode, circuit))
{
if (circuit->state != C_STATE_UP)
continue;
if (family == AF_INET)
{
prefix.family = AF_INET;
- for (ALL_LIST_ELEMENTS (circuit->ip_addrs, ipnode, ipnnode, ipv4))
+ for (ALL_LIST_ELEMENTS_RO (circuit->ip_addrs, ipnode, ipv4))
{
prefix.u.prefix4 = ipv4->prefix;
prefix.prefixlen = ipv4->prefixlen;
if (family == AF_INET6)
{
prefix.family = AF_INET6;
- for (ALL_LIST_ELEMENTS (circuit->ipv6_non_link,
- ipnode, ipnnode, ipv6))
+ for (ALL_LIST_ELEMENTS_RO (circuit->ipv6_non_link, ipnode, ipv6))
{
prefix.prefixlen = ipv6->prefixlen;
prefix.u.prefix6 = ipv6->prefix;
int
tlv_add_is_neighs (struct list *is_neighs, struct stream *stream)
{
- struct listnode *node, *nnode;
+ struct listnode *node;
struct is_neigh *is_neigh;
u_char value[255];
u_char *pos = value;
*pos = 0; /*is_neigh->virtual; */
pos++;
- for (ALL_LIST_ELEMENTS (is_neighs, node, nnode, is_neigh))
+ for (ALL_LIST_ELEMENTS_RO (is_neighs, node, is_neigh))
{
if (pos - value + IS_NEIGHBOURS_LEN > 255)
{
int
tlv_add_te_is_neighs (struct list *te_is_neighs, struct stream *stream)
{
- struct listnode *node, *nnode;
+ struct listnode *node;
struct te_is_neigh *te_is_neigh;
u_char value[255];
u_char *pos = value;
int retval;
- for (ALL_LIST_ELEMENTS (te_is_neighs, node, nnode, te_is_neigh))
+ for (ALL_LIST_ELEMENTS_RO (te_is_neighs, node, te_is_neigh))
{
/* FIXME: This will be wrong if we are going to add TE sub TLVs. */
if (pos - value + IS_NEIGHBOURS_LEN > 255)
int
tlv_add_lan_neighs (struct list *lan_neighs, struct stream *stream)
{
- struct listnode *node, *nnode;
+ struct listnode *node;
u_char *snpa;
u_char value[255];
u_char *pos = value;
int retval;
- for (ALL_LIST_ELEMENTS (lan_neighs, node, nnode, snpa))
+ for (ALL_LIST_ELEMENTS_RO (lan_neighs, node, snpa))
{
if (pos - value + ETH_ALEN > 255)
{
return add_tlv (LAN_NEIGHBOURS, pos - value, value, stream);
}
-/*
- u_char value[255];
- u_char *pos = value;
-
- if (circuit->ip_router) {
- *pos = (u_char)NLPID_IP;
- pos ++;
- }
- if (circuit->ipv6_router) {
- *pos = (u_char)NLPID_IPV6;
- pos ++;
- }
-*/
-
int
tlv_add_nlpid (struct nlpids *nlpids, struct stream *stream)
{
-
return add_tlv (PROTOCOLS_SUPPORTED, nlpids->count, nlpids->nlpids, stream);
}
int
tlv_add_ip_addrs (struct list *ip_addrs, struct stream *stream)
{
- struct listnode *node, *nnode;
+ struct listnode *node;
struct prefix_ipv4 *ipv4;
u_char value[255];
u_char *pos = value;
int retval;
- for (ALL_LIST_ELEMENTS (ip_addrs, node, nnode, ipv4))
+ for (ALL_LIST_ELEMENTS_RO (ip_addrs, node, ipv4))
{
if (pos - value + IPV4_MAX_BYTELEN > 255)
{
int
tlv_add_lsp_entries (struct list *lsps, struct stream *stream)
{
- struct listnode *node, *nnode;
+ struct listnode *node;
struct isis_lsp *lsp;
u_char value[255];
u_char *pos = value;
int retval;
- for (ALL_LIST_ELEMENTS (lsps, node, nnode, lsp))
+ for (ALL_LIST_ELEMENTS_RO (lsps, node, lsp))
{
if (pos - value + LSP_ENTRIES_LEN > 255)
{
int
tlv_add_ipv4_reachs (struct list *ipv4_reachs, struct stream *stream)
{
- struct listnode *node, *nnode;
+ struct listnode *node;
struct ipv4_reachability *reach;
u_char value[255];
u_char *pos = value;
int retval;
- for (ALL_LIST_ELEMENTS (ipv4_reachs, node, nnode, reach))
+ for (ALL_LIST_ELEMENTS_RO (ipv4_reachs, node, reach))
{
if (pos - value + IPV4_REACH_LEN > 255)
{
int
tlv_add_te_ipv4_reachs (struct list *te_ipv4_reachs, struct stream *stream)
{
- struct listnode *node, *nnode;
+ struct listnode *node;
struct te_ipv4_reachability *te_reach;
u_char value[255];
u_char *pos = value;
u_char prefix_size;
int retval;
- for (ALL_LIST_ELEMENTS (te_ipv4_reachs, node, nnode, te_reach))
+ for (ALL_LIST_ELEMENTS_RO (te_ipv4_reachs, node, te_reach))
{
prefix_size = ((((te_reach->control & 0x3F) - 1) >> 3) + 1);
int
tlv_add_ipv6_addrs (struct list *ipv6_addrs, struct stream *stream)
{
- struct listnode *node, *nnode;
+ struct listnode *node;
struct prefix_ipv6 *ipv6;
u_char value[255];
u_char *pos = value;
int retval;
- for (ALL_LIST_ELEMENTS (ipv6_addrs, node, nnode, ipv6))
+ for (ALL_LIST_ELEMENTS_RO (ipv6_addrs, node, ipv6))
{
if (pos - value + IPV6_MAX_BYTELEN > 255)
{
int
tlv_add_ipv6_reachs (struct list *ipv6_reachs, struct stream *stream)
{
- struct listnode *node, *nnode;
+ struct listnode *node;
struct ipv6_reachability *ip6reach;
u_char value[255];
u_char *pos = value;
int retval, prefix_octets;
- for (ALL_LIST_ELEMENTS (ipv6_reachs, node, nnode, ip6reach))
+ for (ALL_LIST_ELEMENTS_RO (ipv6_reachs, node, ip6reach))
{
if (pos - value + IPV6_MAX_BYTELEN + 6 > 255)
{
isis_area_lookup (const char *area_tag)
{
struct isis_area *area;
- struct listnode *node, *nnode;
+ struct listnode *node;
- for (ALL_LIST_ELEMENTS (isis->area_list, node, nnode, area))
+ for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
if ((area->area_tag == NULL && area_tag == NULL) ||
(area->area_tag && area_tag
&& strcmp (area->area_tag, area_tag) == 0))
struct isis_area *area;
struct area_addr *addr;
struct area_addr *addrp;
- struct listnode *node, *nnode;
+ struct listnode *node;
u_char buff[255];
area = vty->index;
}
/* now we see that we don't already have this address */
- for (ALL_LIST_ELEMENTS (area->area_addrs, node, nnode, addrp))
- {
- if ((addrp->addr_len + ISIS_SYS_ID_LEN + 1) == (addr->addr_len))
- {
- if (!memcmp (addrp->area_addr, addr->area_addr, addr->addr_len))
- {
- XFREE (MTYPE_ISIS_AREA_ADDR, addr);
- return CMD_SUCCESS; /* silent fail */
- }
- }
- }
+ for (ALL_LIST_ELEMENTS_RO (area->area_addrs, node, addrp))
+ {
+ if ((addrp->addr_len + ISIS_SYS_ID_LEN + 1) != (addr->addr_len))
+ continue;
+ if (!memcmp (addrp->area_addr, addr->area_addr, addr->addr_len))
+ {
+ XFREE (MTYPE_ISIS_AREA_ADDR, addr);
+ return CMD_SUCCESS; /* silent fail */
+ }
+ }
}
/*
{
struct isis_area *area;
struct area_addr addr, *addrp = NULL;
- struct listnode *node, *nnode;
+ struct listnode *node;
u_char buff[255];
area = vty->index;
memcpy (addr.area_addr, buff, (int) addr.addr_len);
- for (ALL_LIST_ELEMENTS (area->area_addrs, node, nnode, addrp))
+ for (ALL_LIST_ELEMENTS_RO (area->area_addrs, node, 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 *anode, *annode, *cnode, *cnnode;
+ struct listnode *anode, *cnode;
struct isis_area *area;
struct isis_circuit *circuit;
struct list *db;
return CMD_SUCCESS;
}
- for (ALL_LIST_ELEMENTS (isis->area_list, anode, annode, area))
+ for (ALL_LIST_ELEMENTS_RO (isis->area_list, anode, area))
{
vty_out (vty, "Area %s:%s", area->area_tag, VTY_NEWLINE);
vty_out (vty, " System Id Interface L State "
"Holdtime SNPA%s", VTY_NEWLINE);
- for (ALL_LIST_ELEMENTS (area->circuit_list, cnode, cnnode, circuit))
+ for (ALL_LIST_ELEMENTS_RO (area->circuit_list, cnode, circuit))
{
if (circuit->circ_type == CIRCUIT_T_BROADCAST)
{
"show isis database",
SHOW_STR "IS-IS information\n" "IS-IS link state database\n")
{
- struct listnode *node, *nnode;
+ struct listnode *node;
struct isis_area *area;
int level, lsp_count;
if (isis->area_list->count == 0)
return CMD_SUCCESS;
- for (ALL_LIST_ELEMENTS (isis->area_list, node, nnode, area))
+ for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
{
vty_out (vty, "Area %s:%s", area->area_tag ? area->area_tag : "null",
VTY_NEWLINE);
"IS-IS information\n"
"IS-IS link state database\n")
{
- struct listnode *node, *nnode;
+ struct listnode *node;
struct isis_area *area;
int level, lsp_count;
if (isis->area_list->count == 0)
return CMD_SUCCESS;
- for (ALL_LIST_ELEMENTS (isis->area_list, node, nnode, area))
+ for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
{
vty_out (vty, "Area %s:%s", area->area_tag ? area->area_tag : "null",
VTY_NEWLINE);
if (isis != NULL)
{
struct isis_area *area;
- struct listnode *node, *nnode;
- struct listnode *node2, *nnode2;
+ struct listnode *node, *node2;
- for (ALL_LIST_ELEMENTS (isis->area_list, node, nnode, area))
+ for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, 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;
- for (ALL_LIST_ELEMENTS (area->area_addrs, node2, nnode2, area_addr))
- {
- vty_out (vty, " net %s%s",
- isonet_print (area_addr->area_addr,
- area_addr->addr_len + ISIS_SYS_ID_LEN +
- 1), VTY_NEWLINE);
- write++;
- }
+ for (ALL_LIST_ELEMENTS_RO (area->area_addrs, node2, area_addr))
+ {
+ vty_out (vty, " net %s%s",
+ isonet_print (area_addr->area_addr,
+ area_addr->addr_len + ISIS_SYS_ID_LEN +
+ 1), VTY_NEWLINE);
+ write++;
+ }
}
- /* ISIS - Dynamic hostname - Defaults to true so only display if false */
+ /* ISIS - Dynamic hostname - Defaults to true so only display if
+ * false. */
if (!area->dynhostname)
{
vty_out (vty, " no hostname dynamic%s", VTY_NEWLINE);