summaryrefslogtreecommitdiff
path: root/isisd/isis_tlv.c
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/isis_tlv.c
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/isis_tlv.c')
-rw-r--r--isisd/isis_tlv.c38
1 files changed, 15 insertions, 23 deletions
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);