2004-09-24 Paul Jakma <paul@dishone.st>
* ospf_apiserver.{c,h}: lists typedef removal cleanup.
update some list loops to LIST_LOOP. some miscellaneous indent
fixups.
(ospf_apiserver_unregister_opaque_type) fix listnode_delete of
referenced node in loop.
* ospf_interface.h: lists typedef removal cleanup.
* ospf_opaque.{c,h}: lists typedef removal cleanup. update some list
loops to LIST_LOOP. miscellaneous style and indent fixups.
* ospf_te.{c,h}: ditto
* ospf_packet.c: lists typedef removal cleanup.
diff --git a/ospfd/ChangeLog b/ospfd/ChangeLog
index 3a0b134..e7e7b1f 100644
--- a/ospfd/ChangeLog
+++ b/ospfd/ChangeLog
@@ -1,3 +1,16 @@
+2004-09-24 Paul Jakma <paul@dishone.st>
+
+ * ospf_apiserver.{c,h}: lists typedef removal cleanup.
+ update some list loops to LIST_LOOP. some miscellaneous indent
+ fixups.
+ (ospf_apiserver_unregister_opaque_type) fix listnode_delete of
+ referenced node in loop.
+ * ospf_interface.h: lists typedef removal cleanup.
+ * ospf_opaque.{c,h}: lists typedef removal cleanup. update some list
+ loops to LIST_LOOP. miscellaneous style and indent fixups.
+ * ospf_te.{c,h}: ditto
+ * ospf_packet.c: lists typedef removal cleanup.
+
2004-09-23 Hasso Tepper <hasso at quagga.net>
* *.[c|h]: list -> struct list *, listnode -> struct listnode *.
diff --git a/ospfd/ospf_apiserver.c b/ospfd/ospf_apiserver.c
index 6ee1c00..fa2d993 100644
--- a/ospfd/ospf_apiserver.c
+++ b/ospfd/ospf_apiserver.c
@@ -73,7 +73,7 @@
* daemon supports multiple applications concurrently. */
/* List of all active connections. */
-list apiserver_list;
+struct list *apiserver_list;
/* -----------------------------------------------------------
* Functions to lookup interfaces
@@ -83,7 +83,7 @@
struct ospf_interface *
ospf_apiserver_if_lookup_by_addr (struct in_addr address)
{
- listnode node;
+ struct listnode *node;
struct ospf_interface *oi;
struct ospf *ospf;
@@ -91,34 +91,28 @@
return NULL;
for (node = listhead (ospf->oiflist); node; nextnode (node))
- {
- if ((oi = getdata (node)) != NULL
- && oi->type != OSPF_IFTYPE_VIRTUALLINK)
- {
- if (IPV4_ADDR_SAME (&address, &oi->address->u.prefix4))
- return oi;
- }
- }
+ LIST_LOOP (ospf->oiflist, oi, node)
+ if (oi->type != OSPF_IFTYPE_VIRTUALLINK)
+ if (IPV4_ADDR_SAME (&address, &oi->address->u.prefix4))
+ return oi;
+
return NULL;
}
struct ospf_interface *
ospf_apiserver_if_lookup_by_ifp (struct interface *ifp)
{
- listnode node;
+ struct listnode *node;
struct ospf_interface *oi;
struct ospf *ospf;
if (!(ospf = ospf_lookup ()));
return NULL;
- for (node = listhead (ospf->oiflist); node; nextnode (node))
- {
- if ((oi = getdata (node)) && oi->ifp == ifp)
- {
- return oi;
- }
- }
+ LIST_LOOP (ospf->oiflist, oi, node)
+ if (oi->ifp == ifp)
+ return oi;
+
return NULL;
}
@@ -186,19 +180,16 @@
void
ospf_apiserver_term (void)
{
- listnode node;
+ struct listnode *node;
+ struct ospf_apiserver *apiserv;
/* Unregister wildcard [0/0] type */
ospf_delete_opaque_functab (0 /* all LSAs */,
0 /* all opaque types */);
/* Free all client instances */
- for (node = listhead (apiserver_list); node; nextnode (node))
- {
- struct ospf_apiserver *apiserv =
- (struct ospf_apiserver *) getdata (node);
- ospf_apiserver_free (apiserv);
- }
+ LIST_LOOP (apiserver_list, apiserv, node)
+ ospf_apiserver_free (apiserv);
/* Free client list itself */
list_delete (apiserver_list);
@@ -210,10 +201,11 @@
static struct ospf_apiserver *
lookup_apiserver (u_char lsa_type, u_char opaque_type)
{
- listnode n1, n2;
+ struct listnode *n1, *n2;
struct registered_opaque_type *r;
struct ospf_apiserver *apiserv, *found = NULL;
+ /* XXX: this approaches O(n**2) */
for (n1 = listhead (apiserver_list); n1; nextnode (n1))
{
apiserv = (struct ospf_apiserver *) getdata (n1);
@@ -351,7 +343,7 @@
void
ospf_apiserver_free (struct ospf_apiserver *apiserv)
{
- listnode node;
+ struct listnode *node;
/* Cancel read and write threads. */
if (apiserv->t_sync_read)
@@ -958,7 +950,10 @@
listnode_add (apiserv->opaque_types, regtype);
if (IS_DEBUG_OSPF_EVENT)
- zlog_info ("API: Add LSA-type(%d)/Opaque-type(%d) into apiserv(%p), total#(%d)", lsa_type, opaque_type, apiserv, listcount (apiserv->opaque_types));
+ zlog_info ("API: Add LSA-type(%d)/Opaque-type(%d) into"
+ " apiserv(%p), total#(%d)",
+ lsa_type, opaque_type, apiserv,
+ listcount (apiserv->opaque_types));
return 0;
}
@@ -967,10 +962,12 @@
ospf_apiserver_unregister_opaque_type (struct ospf_apiserver *apiserv,
u_char lsa_type, u_char opaque_type)
{
- listnode node;
+ struct listnode *node, *nextnode;
- for (node = listhead (apiserv->opaque_types); node; nextnode (node))
+ for (node = listhead (apiserv->opaque_types); node; node = nextnode)
{
+ nextnode = node->next;
+
struct registered_opaque_type *regtype = node->data;
/* Check if we really registered this opaque type */
@@ -988,7 +985,10 @@
listnode_delete (apiserv->opaque_types, regtype);
if (IS_DEBUG_OSPF_EVENT)
- zlog_info ("API: Del LSA-type(%d)/Opaque-type(%d) from apiserv(%p), total#(%d)", lsa_type, opaque_type, apiserv, listcount (apiserv->opaque_types));
+ zlog_info ("API: Del LSA-type(%d)/Opaque-type(%d)"
+ " from apiserv(%p), total#(%d)",
+ lsa_type, opaque_type, apiserv,
+ listcount (apiserv->opaque_types));
return 0;
}
@@ -1005,12 +1005,12 @@
apiserver_is_opaque_type_registered (struct ospf_apiserver *apiserv,
u_char lsa_type, u_char opaque_type)
{
- listnode node;
+ struct listnode *node;
+ struct registered_opaque_type *regtype;
- for (node = listhead (apiserv->opaque_types); node; nextnode (node))
+ /* XXX: how many types are there? if few, why not just a bitmap? */
+ LIST_LOOP (apiserv->opaque_types, regtype, node)
{
- struct registered_opaque_type *regtype = node->data;
-
/* Check if we really registered this opaque type */
if (regtype->lsa_type == lsa_type &&
regtype->opaque_type == opaque_type)
@@ -1067,25 +1067,24 @@
void
ospf_apiserver_notify_ready_type9 (struct ospf_apiserver *apiserv)
{
- listnode node;
- listnode n2;
+ struct listnode *node;
+ struct listnode *n2;
struct ospf *ospf;
+ struct ospf_interface *oi;
+ struct registered_opaque_type *r;
ospf = ospf_lookup ();
- for (node = listhead (ospf->oiflist); node; nextnode (node))
+ LIST_LOOP (ospf->oiflist, oi, node)
{
- struct ospf_interface *oi = (struct ospf_interface *) getdata (node);
-
/* Check if this interface is indeed ready for type 9 */
if (!ospf_apiserver_is_ready_type9 (oi))
continue;
/* Check for registered opaque type 9 types */
- for (n2 = listhead (apiserv->opaque_types); n2; nextnode (n2))
+ /* XXX: loop-de-loop - optimise me */
+ LIST_LOOP (apiserv->opaque_types, r, n2)
{
- struct registered_opaque_type *r =
- (struct registered_opaque_type *) getdata (n2);
struct msg *msg;
if (r->lsa_type == OSPF_OPAQUE_LINK_LSA)
@@ -1119,28 +1118,28 @@
void
ospf_apiserver_notify_ready_type10 (struct ospf_apiserver *apiserv)
{
- listnode node;
- listnode n2;
+ struct listnode *node;
+ struct listnode *n2;
struct ospf *ospf;
-
+ struct ospf_area *area;
+
ospf = ospf_lookup ();
- for (node = listhead (ospf->areas); node; nextnode (node))
+ LIST_LOOP (ospf->areas, area, node)
{
- struct ospf_area *area = getdata (node);
-
+ struct registered_opaque_type *r;
+
if (!ospf_apiserver_is_ready_type10 (area))
{
continue;
}
/* Check for registered opaque type 10 types */
- for (n2 = listhead (apiserv->opaque_types); n2; nextnode (n2))
+ /* XXX: loop in loop - optimise me */
+ LIST_LOOP (apiserv->opaque_types, r, n2)
{
- struct registered_opaque_type *r =
- (struct registered_opaque_type *) getdata (n2);
struct msg *msg;
-
+
if (r->lsa_type == OSPF_OPAQUE_AREA_LSA)
{
/* Yes, this opaque type is ready */
@@ -1170,8 +1169,9 @@
void
ospf_apiserver_notify_ready_type11 (struct ospf_apiserver *apiserv)
{
- listnode n2;
+ struct listnode *node;
struct ospf *ospf;
+ struct registered_opaque_type *r;
ospf = ospf_lookup ();
@@ -1180,10 +1180,8 @@
goto out;;
/* Check for registered opaque type 11 types */
- for (n2 = listhead (apiserv->opaque_types); n2; nextnode (n2))
+ LIST_LOOP (apiserv->opaque_types, r, node)
{
- struct registered_opaque_type *r =
- (struct registered_opaque_type *) getdata (n2);
struct msg *msg;
struct in_addr noarea_id = { 0L };
@@ -1349,7 +1347,7 @@
ospf_apiserver_handle_sync_lsdb (struct ospf_apiserver *apiserv,
struct msg *msg)
{
- listnode node;
+ struct listnode *node;
u_int32_t seqnum;
int rc = 0;
struct msg_sync_lsdb *smsg;
@@ -1363,6 +1361,7 @@
struct route_node *rn;
struct ospf_lsa *lsa;
struct ospf *ospf;
+ struct ospf_area *area;
ospf = ospf_lookup ();
@@ -1379,11 +1378,11 @@
mask = ntohs (smsg->filter.typemask);
/* Iterate over all areas. */
- for (node = listhead (ospf->areas); node; nextnode (node))
+ LIST_LOOP (ospf->areas, area, node)
{
- struct ospf_area *area = node->data;
int i;
u_int32_t *area_id = NULL;
+
/* Compare area_id with area_ids in sync request. */
if ((i = smsg->filter.num_areas) > 0)
{
@@ -1562,18 +1561,14 @@
/* Type 10 opaque LSA can be originated if there is at least one
interface belonging to the area that has an active opaque-capable
neighbor. */
- listnode node;
+ struct listnode *node;
+ struct ospf_interface *oi;
- for (node = listhead (area->oiflist); node; nextnode (node))
- {
- struct ospf_interface *oi = getdata (node);
+ LIST_LOOP (area->oiflist, oi, node)
+ /* Is there an active neighbor attached to this interface? */
+ if (ospf_apiserver_is_ready_type9 (oi))
+ return 1;
- /* Is there an active neighbor attached to this interface? */
- if (ospf_apiserver_is_ready_type9 (oi))
- {
- return 1;
- }
- }
/* No active neighbor in area */
return 0;
}
@@ -1583,16 +1578,14 @@
{
/* Type 11 opaque LSA can be originated if there is at least one interface
that has an active opaque-capable neighbor. */
- listnode node;
+ struct listnode *node;
+ struct ospf_interface *oi;
- for (node = listhead (ospf->oiflist); node; nextnode (node))
- {
- struct ospf_interface *oi = getdata (node);
+ LIST_LOOP (ospf->oiflist, oi, node)
+ /* Is there an active neighbor attached to this interface? */
+ if (ospf_apiserver_is_ready_type9 (oi))
+ return 1;
- /* Is there an active neighbor attached to this interface? */
- if (ospf_apiserver_is_ready_type9 (oi))
- return 1;
- }
/* No active neighbor at all */
return 0;
}
@@ -2054,11 +2047,11 @@
struct ospf_apiserver *apiserv;
u_char lsa_type;
u_char opaque_type;
- }
- param;
- listnode node;
+ } param;
+ struct listnode *node;
struct ospf * ospf;
-
+ struct ospf_area *area;
+
ospf = ospf_lookup();
assert(ospf);
@@ -2067,45 +2060,20 @@
param.lsa_type = lsa_type;
param.opaque_type = opaque_type;
-#ifdef ORIGINAL_CODING
- /* Iterate over all areas */
- for (node = listhead (ospf_top->areas); node; nextnode (node))
- {
- struct ospf_area *area = node->data;
-
- foreach_lsa (OPAQUE_LINK_LSDB (area), (void *) ¶m, 0,
- apiserver_flush_opaque_type_callback);
- foreach_lsa (OPAQUE_AREA_LSDB (area), (void *) ¶m, 0,
- apiserver_flush_opaque_type_callback);
- }
-
- /* For AS-external opaque LSAs */
- if (ospf->lsdb)
- {
- foreach_lsa (OPAQUE_AS_LSDB (ospf_top), (void *) ¶m, 0,
- apiserver_flush_opaque_type_callback);
- }
-#else /* ORIGINAL_CODING */
switch (lsa_type)
{
struct route_node *rn;
struct ospf_lsa *lsa;
case OSPF_OPAQUE_LINK_LSA:
- for (node = listhead (ospf->areas); node; nextnode (node))
- {
- struct ospf_area *area = node->data;
- LSDB_LOOP (OPAQUE_LINK_LSDB (area), rn, lsa)
- apiserver_flush_opaque_type_callback(lsa, (void *) ¶m, 0);
- }
+ LIST_LOOP (ospf->areas, area, node)
+ LSDB_LOOP (OPAQUE_LINK_LSDB (area), rn, lsa)
+ apiserver_flush_opaque_type_callback(lsa, (void *) ¶m, 0);
break;
case OSPF_OPAQUE_AREA_LSA:
- for (node = listhead (ospf->areas); node; nextnode (node))
- {
- struct ospf_area *area = node->data;
- LSDB_LOOP (OPAQUE_AREA_LSDB (area), rn, lsa)
- apiserver_flush_opaque_type_callback(lsa, (void *) ¶m, 0);
- }
+ LIST_LOOP (ospf->areas, area, node)
+ LSDB_LOOP (OPAQUE_AREA_LSDB (area), rn, lsa)
+ apiserver_flush_opaque_type_callback(lsa, (void *) ¶m, 0);
break;
case OSPF_OPAQUE_AS_LSA:
LSDB_LOOP (OPAQUE_LINK_LSDB (ospf), rn, lsa)
@@ -2115,7 +2083,6 @@
break;
}
return;
-#endif /* ORIGINAL_CODING */
}
@@ -2234,13 +2201,9 @@
olsa = (struct opaque_lsa *) lsa->data;
if (VALID_OPAQUE_INFO_LEN (lsa->data))
- {
- opaquelen = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE;
- }
+ opaquelen = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE;
else
- {
- opaquelen = 0;
- }
+ opaquelen = 0;
/* Output information about opaque LSAs */
if (vty != NULL)
@@ -2288,16 +2251,12 @@
void
ospf_apiserver_clients_notify_all (struct msg *msg)
{
- listnode node;
+ struct listnode *node;
+ struct ospf_apiserver *apiserv;
/* Send message to all clients */
- for (node = listhead (apiserver_list); node; nextnode (node))
- {
- struct ospf_apiserver *apiserv =
- (struct ospf_apiserver *) getdata (node);
-
- ospf_apiserver_send_msg (apiserv, msg);
- }
+ LIST_LOOP (apiserver_list, apiserv, node)
+ ospf_apiserver_send_msg (apiserv, msg);
}
/* An interface is now ready to accept opaque LSAs. Notify all
@@ -2305,8 +2264,9 @@
void
ospf_apiserver_clients_notify_ready_type9 (struct ospf_interface *oi)
{
- listnode node;
+ struct listnode *node;
struct msg *msg;
+ struct ospf_apiserver *apiserv;
assert (oi);
if (!oi->address)
@@ -2321,16 +2281,13 @@
return;
}
- for (node = listhead (apiserver_list); node; nextnode (node))
+ LIST_LOOP (apiserver_list, apiserv, node)
{
- struct ospf_apiserver *apiserv =
- (struct ospf_apiserver *) getdata (node);
- listnode n2;
+ struct listnode *n2;
+ struct registered_opaque_type *r;
- for (n2 = listhead (apiserv->opaque_types); n2; nextnode (n2))
+ LIST_LOOP (apiserv->opaque_types, r, n2)
{
- struct registered_opaque_type *r =
- (struct registered_opaque_type *) getdata (n2);
if (r->lsa_type == OSPF_OPAQUE_LINK_LSA)
{
msg = new_msg_ready_notify (0, OSPF_OPAQUE_LINK_LSA,
@@ -2360,8 +2317,9 @@
void
ospf_apiserver_clients_notify_ready_type10 (struct ospf_area *area)
{
- listnode node;
+ struct listnode *node;
struct msg *msg;
+ struct ospf_apiserver *apiserv;
assert (area);
@@ -2371,16 +2329,13 @@
return;
}
- for (node = listhead (apiserver_list); node; nextnode (node))
+ LIST_LOOP (apiserver_list, apiserv, node)
{
- struct ospf_apiserver *apiserv =
- (struct ospf_apiserver *) getdata (node);
- listnode n2;
+ struct listnode *n2;
+ struct registered_opaque_type *r;
- for (n2 = listhead (apiserv->opaque_types); n2; nextnode (n2))
+ LIST_LOOP (apiserv->opaque_types, r, n2)
{
- struct registered_opaque_type *r =
- (struct registered_opaque_type *) getdata (n2);
if (r->lsa_type == OSPF_OPAQUE_AREA_LSA)
{
msg = new_msg_ready_notify (0, OSPF_OPAQUE_AREA_LSA,
@@ -2393,7 +2348,7 @@
/* Cannot allocate new message. What should we do? */
ospf_apiserver_free (apiserv);
#endif
- goto out;
+ goto out;
}
ospf_apiserver_send_msg (apiserv, msg);
@@ -2410,9 +2365,10 @@
void
ospf_apiserver_clients_notify_ready_type11 (struct ospf *top)
{
- listnode node;
+ struct listnode *node;
struct msg *msg;
struct in_addr id_null = { 0L };
+ struct ospf_apiserver *apiserv;
assert (top);
@@ -2422,16 +2378,13 @@
return;
}
- for (node = listhead (apiserver_list); node; nextnode (node))
+ LIST_LOOP (apiserver_list, apiserv, node)
{
- struct ospf_apiserver *apiserv =
- (struct ospf_apiserver *) getdata (node);
- listnode n2;
+ struct listnode *n2;
+ struct registered_opaque_type *r;
- for (n2 = listhead (apiserv->opaque_types); n2; nextnode (n2))
+ LIST_LOOP (apiserv->opaque_types, r, n2)
{
- struct registered_opaque_type *r =
- (struct registered_opaque_type *) getdata (n2);
if (r->lsa_type == OSPF_OPAQUE_AS_LSA)
{
msg = new_msg_ready_notify (0, OSPF_OPAQUE_AS_LSA,
@@ -2544,7 +2497,8 @@
apiserver_clients_lsa_change_notify (u_char msgtype, struct ospf_lsa *lsa)
{
struct msg *msg;
- listnode node;
+ struct listnode *node;
+ struct ospf_apiserver *apiserv;
/* Default area for AS-External and Opaque11 LSAs */
struct in_addr area_id = { 0L };
@@ -2574,9 +2528,8 @@
}
/* Now send message to all clients with a matching filter */
- for (node = listhead (apiserver_list); node; nextnode (node))
+ LIST_LOOP (apiserver_list, apiserv, node)
{
- struct ospf_apiserver *apiserv = (struct ospf_apiserver *) node->data;
struct lsa_filter_type *filter;
u_int16_t mask;
u_int32_t *area;
diff --git a/ospfd/ospf_apiserver.h b/ospfd/ospf_apiserver.h
index c714578..f4dc647 100644
--- a/ospfd/ospf_apiserver.h
+++ b/ospfd/ospf_apiserver.h
@@ -50,7 +50,7 @@
a single connection with the OSPF daemon, multiple
<lsa,opaque_type> pairs can be registered. However, each
combination can only be registered once by all applications. */
- list opaque_types; /* of type registered_opaque_type */
+ struct list *opaque_types; /* of type registered_opaque_type */
/* Temporary storage for LSA instances to be refreshed. */
struct ospf_lsdb reserve;
diff --git a/ospfd/ospf_interface.h b/ospfd/ospf_interface.h
index cdab122..0f3cecd 100644
--- a/ospfd/ospf_interface.h
+++ b/ospfd/ospf_interface.h
@@ -146,7 +146,7 @@
/* self-originated LSAs. */
struct ospf_lsa *network_lsa_self; /* network-LSA. */
#ifdef HAVE_OPAQUE_LSA
- list opaque_lsa_self; /* Type-9 Opaque-LSAs */
+ struct list *opaque_lsa_self; /* Type-9 Opaque-LSAs */
#endif /* HAVE_OPAQUE_LSA */
struct route_table *ls_upd_queue;
diff --git a/ospfd/ospf_opaque.c b/ospfd/ospf_opaque.c
index 73e9639..414ec74 100644
--- a/ospfd/ospf_opaque.c
+++ b/ospfd/ospf_opaque.c
@@ -253,10 +253,11 @@
int (* del_lsa_hook)(struct ospf_lsa *lsa);
};
-static list ospf_opaque_wildcard_funclist; /* Handle LSA-9/10/11 altogether. */
-static list ospf_opaque_type9_funclist;
-static list ospf_opaque_type10_funclist;
-static list ospf_opaque_type11_funclist;
+/* Handle LSA-9/10/11 altogether. */
+static struct list *ospf_opaque_wildcard_funclist;
+static struct list *ospf_opaque_type9_funclist;
+static struct list *ospf_opaque_type10_funclist;
+static struct list *ospf_opaque_type11_funclist;
static void
ospf_opaque_del_functab (void *val)
@@ -268,7 +269,7 @@
static void
ospf_opaque_funclist_init (void)
{
- list funclist;
+ struct list *funclist;
funclist = ospf_opaque_wildcard_funclist = list_new ();
funclist->del = ospf_opaque_del_functab;
@@ -287,7 +288,7 @@
static void
ospf_opaque_funclist_term (void)
{
- list funclist;
+ struct list *funclist;
funclist = ospf_opaque_wildcard_funclist;
list_delete (funclist);
@@ -303,10 +304,10 @@
return;
}
-static list
+static struct list *
ospf_get_opaque_funclist (u_char lsa_type)
{
- list funclist = NULL;
+ struct list *funclist = NULL;
switch (lsa_type)
{
@@ -336,6 +337,7 @@
return funclist;
}
+/* XXX: such a huge argument list can /not/ be healthy... */
int
ospf_register_opaque_functab (
u_char lsa_type,
@@ -353,33 +355,37 @@
int (* new_lsa_hook)(struct ospf_lsa *lsa),
int (* del_lsa_hook)(struct ospf_lsa *lsa))
{
- list funclist;
+ struct list *funclist;
struct ospf_opaque_functab *new;
int rc = -1;
if ((funclist = ospf_get_opaque_funclist (lsa_type)) == NULL)
{
- zlog_warn ("ospf_register_opaque_functab: Cannot get funclist for Type-%u LSAs?", lsa_type);
+ zlog_warn ("ospf_register_opaque_functab: Cannot get funclist"
+ " for Type-%u LSAs?",
+ lsa_type);
goto out;
}
else
{
- listnode node;
+ struct listnode *node;
struct ospf_opaque_functab *functab;
-
- for (node = listhead (funclist); node; nextnode (node))
- if ((functab = getdata (node)) != NULL)
- if (functab->opaque_type == opaque_type)
- {
- zlog_warn ("ospf_register_opaque_functab: Duplicated entry?: lsa_type(%u), opaque_type(%u)", lsa_type, opaque_type);
- goto out;
- }
+
+ LIST_LOOP (funclist, functab, node)
+ if (functab->opaque_type == opaque_type)
+ {
+ zlog_warn ("ospf_register_opaque_functab: Duplicated entry?:"
+ " lsa_type(%u), opaque_type(%u)",
+ lsa_type, opaque_type);
+ goto out;
+ }
}
if ((new = XCALLOC (MTYPE_OSPF_OPAQUE_FUNCTAB,
sizeof (struct ospf_opaque_functab))) == NULL)
{
- zlog_warn ("ospf_register_opaque_functab: XMALLOC: %s", strerror (errno));
+ zlog_warn ("ospf_register_opaque_functab: XMALLOC: %s",
+ strerror (errno));
goto out;
}
@@ -408,15 +414,15 @@
void
ospf_delete_opaque_functab (u_char lsa_type, u_char opaque_type)
{
- list funclist;
- listnode node;
+ struct list *funclist;
+ struct listnode *node;
struct ospf_opaque_functab *functab;
if ((funclist = ospf_get_opaque_funclist (lsa_type)) != NULL)
for (node = listhead (funclist); node; nextnode (node))
{
if ((functab = getdata (node)) != NULL
- && functab->opaque_type == opaque_type)
+ && functab->opaque_type == opaque_type)
{
/* Cleanup internal control information, if it still remains. */
if (functab->oipt != NULL)
@@ -430,26 +436,25 @@
funclist->head = funclist->tail = NULL;
XFREE (MTYPE_OSPF_OPAQUE_FUNCTAB, functab);
- goto out;
+ break;
}
}
-out:
+
return;
}
static struct ospf_opaque_functab *
ospf_opaque_functab_lookup (struct ospf_lsa *lsa)
{
- list funclist;
- listnode node;
+ struct list *funclist;
+ struct listnode *node;
struct ospf_opaque_functab *functab;
u_char key = GET_OPAQUE_TYPE (ntohl (lsa->data->id.s_addr));
if ((funclist = ospf_get_opaque_funclist (lsa->data->type)) != NULL)
- for (node = listhead (funclist); node; nextnode (node))
- if ((functab = getdata (node)) != NULL)
- if (functab->opaque_type == key)
- return functab;
+ LIST_LOOP (funclist, functab, node)
+ if (functab->opaque_type == key)
+ return functab;
return NULL;
}
@@ -494,7 +499,7 @@
struct ospf_opaque_functab *functab;
/* List of Opaque-LSA control informations per opaque-id. */
- list id_list;
+ struct list *id_list;
};
/* Opaque-LSA control information per opaque-id. */
@@ -580,7 +585,7 @@
struct opaque_info_per_type *oipt = (struct opaque_info_per_type *) val;
struct opaque_info_per_id *oipi;
struct ospf_lsa *lsa;
- listnode node;
+ struct listnode *node;
/* Control information per opaque-id may still exist. */
for (node = listhead (oipt->id_list); node; nextnode (node))
@@ -632,8 +637,8 @@
struct ospf *top;
struct ospf_area *area;
struct ospf_interface *oi;
- list listtop = NULL;
- listnode node;
+ struct list *listtop = NULL;
+ struct listnode *node;
struct opaque_info_per_type *oipt = NULL;
u_char key = GET_OPAQUE_TYPE (ntohl (lsa->data->id.s_addr));
@@ -666,10 +671,9 @@
}
if (listtop != NULL)
- for (node = listhead (listtop); node; nextnode (node))
- if ((oipt = getdata (node)) != NULL)
- if (oipt->opaque_type == key)
- return oipt;
+ LIST_LOOP (listtop, oipt, node)
+ if (oipt->opaque_type == key)
+ return oipt;
return NULL;
}
@@ -713,14 +717,13 @@
lookup_opaque_info_by_id (struct opaque_info_per_type *oipt,
struct ospf_lsa *lsa)
{
- listnode node;
+ struct listnode *node;
struct opaque_info_per_id *oipi;
u_int32_t key = GET_OPAQUE_ID (ntohl (lsa->data->id.s_addr));
- for (node = listhead (oipt->id_list); node; nextnode (node))
- if ((oipi = getdata (node)) != NULL)
- if (oipi->opaque_id == key)
- return oipi;
+ LIST_LOOP (oipt->id_list, oipi, node)
+ if (oipi->opaque_id == key)
+ return oipi;
return NULL;
}
@@ -819,155 +822,147 @@
*------------------------------------------------------------------------*/
static int
-opaque_lsa_new_if_callback (list funclist, struct interface *ifp)
+opaque_lsa_new_if_callback (struct list *funclist, struct interface *ifp)
{
- listnode node;
+ struct listnode *node;
struct ospf_opaque_functab *functab;
int rc = -1;
- for (node = listhead (funclist); node; nextnode (node))
- if ((functab = getdata (node)) != NULL)
- if (functab->new_if_hook != NULL)
- if ((* functab->new_if_hook)(ifp) != 0)
- goto out;
+ LIST_LOOP (funclist, functab, node)
+ if (functab->new_if_hook != NULL)
+ if ((* functab->new_if_hook)(ifp) != 0)
+ goto out;
rc = 0;
out:
return rc;
}
static int
-opaque_lsa_del_if_callback (list funclist, struct interface *ifp)
+opaque_lsa_del_if_callback (struct list *funclist, struct interface *ifp)
{
- listnode node;
+ struct listnode *node;
struct ospf_opaque_functab *functab;
int rc = -1;
- for (node = listhead (funclist); node; nextnode (node))
- if ((functab = getdata (node)) != NULL)
- if (functab->del_if_hook != NULL)
- if ((* functab->del_if_hook)(ifp) != 0)
- goto out;
+ LIST_LOOP (funclist, functab, node)
+ if (functab->del_if_hook != NULL)
+ if ((* functab->del_if_hook)(ifp) != 0)
+ goto out;
rc = 0;
out:
return rc;
}
static void
-opaque_lsa_ism_change_callback (list funclist,
+opaque_lsa_ism_change_callback (struct list *funclist,
struct ospf_interface *oi, int old_status)
{
- listnode node;
+ struct listnode *node;
struct ospf_opaque_functab *functab;
- for (node = listhead (funclist); node; nextnode (node))
- if ((functab = getdata (node)) != NULL)
- if (functab->ism_change_hook != NULL)
- (* functab->ism_change_hook)(oi, old_status);
+ LIST_LOOP (funclist, functab, node)
+ if (functab->ism_change_hook != NULL)
+ (* functab->ism_change_hook)(oi, old_status);
+
return;
}
static void
-opaque_lsa_nsm_change_callback (list funclist,
+opaque_lsa_nsm_change_callback (struct list *funclist,
struct ospf_neighbor *nbr, int old_status)
{
- listnode node;
+ struct listnode *node;
struct ospf_opaque_functab *functab;
- for (node = listhead (funclist); node; nextnode (node))
- if ((functab = getdata (node)) != NULL)
- if (functab->nsm_change_hook != NULL)
- (* functab->nsm_change_hook)(nbr, old_status);
+ LIST_LOOP (funclist, functab, node)
+ if (functab->nsm_change_hook != NULL)
+ (* functab->nsm_change_hook)(nbr, old_status);
return;
}
static void
-opaque_lsa_config_write_router_callback (list funclist, struct vty *vty)
+opaque_lsa_config_write_router_callback (struct list *funclist,
+ struct vty *vty)
{
- listnode node;
+ struct listnode *node;
struct ospf_opaque_functab *functab;
- for (node = listhead (funclist); node; nextnode (node))
- if ((functab = getdata (node)) != NULL)
- if (functab->config_write_router != NULL)
- (* functab->config_write_router)(vty);
+ LIST_LOOP (funclist, functab, node)
+ if (functab->config_write_router != NULL)
+ (* functab->config_write_router)(vty);
return;
}
static void
-opaque_lsa_config_write_if_callback (list funclist,
+opaque_lsa_config_write_if_callback (struct list *funclist,
struct vty *vty, struct interface *ifp)
{
- listnode node;
+ struct listnode *node;
struct ospf_opaque_functab *functab;
- for (node = listhead (funclist); node; nextnode (node))
- if ((functab = getdata (node)) != NULL)
- if (functab->config_write_if != NULL)
- (* functab->config_write_if)(vty, ifp);
+ LIST_LOOP (funclist, functab, node)
+ if (functab->config_write_if != NULL)
+ (* functab->config_write_if)(vty, ifp);
return;
}
static void
-opaque_lsa_config_write_debug_callback (list funclist, struct vty *vty)
+opaque_lsa_config_write_debug_callback (struct list *funclist, struct vty *vty)
{
- listnode node;
+ struct listnode *node;
struct ospf_opaque_functab *functab;
- for (node = listhead (funclist); node; nextnode (node))
- if ((functab = getdata (node)) != NULL)
- if (functab->config_write_debug != NULL)
- (* functab->config_write_debug)(vty);
+ LIST_LOOP (funclist, functab, node)
+ if (functab->config_write_debug != NULL)
+ (* functab->config_write_debug)(vty);
return;
}
static int
-opaque_lsa_originate_callback (list funclist, void *lsa_type_dependent)
+opaque_lsa_originate_callback (struct list *funclist, void *lsa_type_dependent)
{
- listnode node;
+ struct listnode *node;
struct ospf_opaque_functab *functab;
int rc = -1;
- for (node = listhead (funclist); node; nextnode (node))
- if ((functab = getdata (node)) != NULL)
- if (functab->lsa_originator != NULL)
- if ((* functab->lsa_originator)(lsa_type_dependent) != 0)
- goto out;
+ LIST_LOOP (funclist, functab, node)
+ if (functab->lsa_originator != NULL)
+ if ((* functab->lsa_originator)(lsa_type_dependent) != 0)
+ goto out;
rc = 0;
out:
return rc;
}
static int
-new_lsa_callback (list funclist, struct ospf_lsa *lsa)
+new_lsa_callback (struct list *funclist, struct ospf_lsa *lsa)
{
- listnode node;
+ struct listnode *node;
struct ospf_opaque_functab *functab;
int rc = -1;
/* This function handles ALL types of LSAs, not only opaque ones. */
- for (node = listhead (funclist); node; nextnode (node))
- if ((functab = getdata (node)) != NULL)
- if (functab->new_lsa_hook != NULL)
- if ((* functab->new_lsa_hook)(lsa) != 0)
- goto out;
+ LIST_LOOP (funclist, functab, node)
+ if (functab->new_lsa_hook != NULL)
+ if ((* functab->new_lsa_hook)(lsa) != 0)
+ goto out;
rc = 0;
out:
return rc;
}
static int
-del_lsa_callback (list funclist, struct ospf_lsa *lsa)
+del_lsa_callback (struct list *funclist, struct ospf_lsa *lsa)
{
- listnode node;
+ struct listnode *node;
struct ospf_opaque_functab *functab;
int rc = -1;
/* This function handles ALL types of LSAs, not only opaque ones. */
- for (node = listhead (funclist); node; nextnode (node))
- if ((functab = getdata (node)) != NULL)
- if (functab->del_lsa_hook != NULL)
- if ((* functab->del_lsa_hook)(lsa) != 0)
- goto out;
+ LIST_LOOP (funclist, functab, node)
+ if (functab->del_lsa_hook != NULL)
+ if ((* functab->del_lsa_hook)(lsa) != 0)
+ goto out;
rc = 0;
out:
return rc;
@@ -980,7 +975,7 @@
int
ospf_opaque_new_if (struct interface *ifp)
{
- list funclist;
+ struct list *funclist;
int rc = -1;
funclist = ospf_opaque_wildcard_funclist;
@@ -1007,7 +1002,7 @@
int
ospf_opaque_del_if (struct interface *ifp)
{
- list funclist;
+ struct list *funclist;
int rc = -1;
funclist = ospf_opaque_wildcard_funclist;
@@ -1034,7 +1029,7 @@
void
ospf_opaque_ism_change (struct ospf_interface *oi, int old_status)
{
- list funclist;
+ struct list *funclist;
funclist = ospf_opaque_wildcard_funclist;
opaque_lsa_ism_change_callback (funclist, oi, old_status);
@@ -1055,7 +1050,7 @@
ospf_opaque_nsm_change (struct ospf_neighbor *nbr, int old_state)
{
struct ospf *top;
- list funclist;
+ struct list *funclist;
if ((top = oi_to_top (nbr->oi)) == NULL)
goto out;
@@ -1107,7 +1102,7 @@
void
ospf_opaque_config_write_router (struct vty *vty, struct ospf *ospf)
{
- list funclist;
+ struct list *funclist;
if (CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE))
vty_out (vty, " capability opaque%s", VTY_NEWLINE);
@@ -1130,7 +1125,7 @@
void
ospf_opaque_config_write_if (struct vty *vty, struct interface *ifp)
{
- list funclist;
+ struct list *funclist;
funclist = ospf_opaque_wildcard_funclist;
opaque_lsa_config_write_if_callback (funclist, vty, ifp);
@@ -1150,7 +1145,7 @@
void
ospf_opaque_config_write_debug (struct vty *vty)
{
- list funclist;
+ struct list *funclist;
funclist = ospf_opaque_wildcard_funclist;
opaque_lsa_config_write_debug_callback (funclist, vty);
@@ -1220,7 +1215,7 @@
static int
ospf_opaque_lsa_install_hook (struct ospf_lsa *lsa)
{
- list funclist;
+ struct list *funclist;
int rc = -1;
/*
@@ -1251,7 +1246,7 @@
static int
ospf_opaque_lsa_delete_hook (struct ospf_lsa *lsa)
{
- list funclist;
+ struct list *funclist;
int rc = -1;
/*
@@ -1286,14 +1281,14 @@
static int ospf_opaque_type9_lsa_originate (struct thread *t);
static int ospf_opaque_type10_lsa_originate (struct thread *t);
static int ospf_opaque_type11_lsa_originate (struct thread *t);
-static void ospf_opaque_lsa_reoriginate_resume (list listtop, void *arg);
+static void ospf_opaque_lsa_reoriginate_resume (struct list *listtop, void *arg);
void
ospf_opaque_lsa_originate_schedule (struct ospf_interface *oi, int *delay0)
{
struct ospf *top;
struct ospf_area *area;
- listnode node;
+ struct listnode *node;
struct opaque_info_per_type *oipt;
int delay = 0;
@@ -1504,9 +1499,9 @@
}
static void
-ospf_opaque_lsa_reoriginate_resume (list listtop, void *arg)
+ospf_opaque_lsa_reoriginate_resume (struct list *listtop, void *arg)
{
- listnode node;
+ struct listnode *node;
struct opaque_info_per_type *oipt;
struct ospf_opaque_functab *functab;
@@ -1517,16 +1512,15 @@
* Pickup oipt entries those which in SUSPEND status, and give
* them a chance to start re-origination now.
*/
- for (node = listhead (listtop); node; nextnode (node))
+ LIST_LOOP (listtop, oipt, node)
{
- if ((oipt = getdata (node)) == NULL
- || oipt->status != PROC_SUSPEND)
+ if (oipt->status != PROC_SUSPEND)
continue;
oipt->status = PROC_NORMAL;
if ((functab = oipt->functab) == NULL
- || functab->lsa_originator == NULL)
+ || functab->lsa_originator == NULL)
continue;
if ((* functab->lsa_originator)(arg) != 0)
@@ -1561,7 +1555,7 @@
/* Replace the existing lsa with the new one. */
if ((oipt = lookup_opaque_info_by_type (lsa)) != NULL
- && (oipi = lookup_opaque_info_by_id (oipt, lsa)) != NULL)
+ && (oipi = lookup_opaque_info_by_id (oipt, lsa)) != NULL)
{
ospf_lsa_unlock (oipi->lsa);
oipi->lsa = ospf_lsa_lock (lsa);
@@ -1626,7 +1620,7 @@
ospf = ospf_lookup ();
if ((functab = ospf_opaque_functab_lookup (lsa)) == NULL
- || functab->lsa_refresher == NULL)
+ || functab->lsa_refresher == NULL)
{
/*
* Though this LSA seems to have originated on this node, the
@@ -1672,7 +1666,7 @@
struct ospf_lsa *lsa;
struct opaque_info_per_type *oipt;
- int (* func)(struct thread *t) = NULL;
+ int (*func) (struct thread * t) = NULL;
int delay;
switch (lsa_type)
@@ -1680,19 +1674,23 @@
case OSPF_OPAQUE_LINK_LSA:
if ((oi = (struct ospf_interface *) lsa_type_dependent) == NULL)
{
- zlog_warn ("ospf_opaque_lsa_reoriginate_schedule: Type-9 Opaque-LSA: Invalid parameter?");
- goto out;
+ zlog_warn ("ospf_opaque_lsa_reoriginate_schedule:"
+ " Type-9 Opaque-LSA: Invalid parameter?");
+ goto out;
}
if ((top = oi_to_top (oi)) == NULL)
{
- zlog_warn ("ospf_opaque_lsa_reoriginate_schedule: OI(%s) -> TOP?", IF_NAME (oi));
+ zlog_warn ("ospf_opaque_lsa_reoriginate_schedule: OI(%s) -> TOP?",
+ IF_NAME (oi));
goto out;
}
- if (! list_isempty (ospf_opaque_type9_funclist)
- && list_isempty (oi->opaque_lsa_self)
- && oi->t_opaque_lsa_self != NULL)
+ if (!list_isempty (ospf_opaque_type9_funclist)
+ && list_isempty (oi->opaque_lsa_self)
+ && oi->t_opaque_lsa_self != NULL)
{
- zlog_warn ("Type-9 Opaque-LSA (opaque_type=%u): Common origination for OI(%s) has already started", opaque_type, IF_NAME (oi));
+ zlog_warn ("Type-9 Opaque-LSA (opaque_type=%u):"
+ " Common origination for OI(%s) has already started",
+ opaque_type, IF_NAME (oi));
goto out;
}
func = ospf_opaque_type9_lsa_reoriginate_timer;
@@ -1700,19 +1698,23 @@
case OSPF_OPAQUE_AREA_LSA:
if ((area = (struct ospf_area *) lsa_type_dependent) == NULL)
{
- zlog_warn ("ospf_opaque_lsa_reoriginate_schedule: Type-10 Opaque-LSA: Invalid parameter?");
+ zlog_warn ("ospf_opaque_lsa_reoriginate_schedule:"
+ " Type-10 Opaque-LSA: Invalid parameter?");
goto out;
}
if ((top = area->ospf) == NULL)
{
- zlog_warn ("ospf_opaque_lsa_reoriginate_schedule: AREA(%s) -> TOP?", inet_ntoa (area->area_id));
+ zlog_warn ("ospf_opaque_lsa_reoriginate_schedule:"
+ " AREA(%s) -> TOP?", inet_ntoa (area->area_id));
goto out;
}
- if (! list_isempty (ospf_opaque_type10_funclist)
- && list_isempty (area->opaque_lsa_self)
- && area->t_opaque_lsa_self != NULL)
+ if (!list_isempty (ospf_opaque_type10_funclist)
+ && list_isempty (area->opaque_lsa_self)
+ && area->t_opaque_lsa_self != NULL)
{
- zlog_warn ("Type-10 Opaque-LSA (opaque_type=%u): Common origination for AREA(%s) has already started", opaque_type, inet_ntoa (area->area_id));
+ zlog_warn ("Type-10 Opaque-LSA (opaque_type=%u):"
+ " Common origination for AREA(%s) has already started",
+ opaque_type, inet_ntoa (area->area_id));
goto out;
}
func = ospf_opaque_type10_lsa_reoriginate_timer;
@@ -1720,14 +1722,16 @@
case OSPF_OPAQUE_AS_LSA:
if ((top = (struct ospf *) lsa_type_dependent) == NULL)
{
- zlog_warn ("ospf_opaque_lsa_reoriginate_schedule: Type-11 Opaque-LSA: Invalid parameter?");
- goto out;
+ zlog_warn ("ospf_opaque_lsa_reoriginate_schedule:"
+ " Type-11 Opaque-LSA: Invalid parameter?");
+ goto out;
}
- if (! list_isempty (ospf_opaque_type11_funclist)
- && list_isempty (top->opaque_lsa_self)
- && top->t_opaque_lsa_self != NULL)
+ if (!list_isempty (ospf_opaque_type11_funclist)
+ && list_isempty (top->opaque_lsa_self)
+ && top->t_opaque_lsa_self != NULL)
{
- zlog_warn ("Type-11 Opaque-LSA (opaque_type=%u): Common origination has already started", opaque_type);
+ zlog_warn ("Type-11 Opaque-LSA (opaque_type=%u):"
+ " Common origination has already started", opaque_type);
goto out;
}
@@ -1738,22 +1742,24 @@
func = ospf_opaque_type11_lsa_reoriginate_timer;
break;
default:
- zlog_warn ("ospf_opaque_lsa_reoriginate_schedule: Unexpected LSA-type(%u)", lsa_type);
+ zlog_warn ("ospf_opaque_lsa_reoriginate_schedule:"
+ " Unexpected LSA-type(%u)",
+ lsa_type);
goto out;
}
/* It may not a right time to schedule reorigination now. */
- if (! CHECK_FLAG (top->opaque, OPAQUE_OPERATION_READY_BIT))
+ if (!CHECK_FLAG (top->opaque, OPAQUE_OPERATION_READY_BIT))
{
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_opaque_lsa_reoriginate_schedule: Not operational.");
- goto out; /* This is not an error. */
+ goto out; /* This is not an error. */
}
if (IS_OPAQUE_LSA_ORIGINATION_BLOCKED (top->opaque))
{
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_opaque_lsa_reoriginate_schedule: Under blockade.");
- goto out; /* This is not an error, too. */
+ goto out; /* This is not an error, too. */
}
/* Generate a dummy lsa to be passed for a lookup function. */
@@ -1764,12 +1770,18 @@
struct ospf_opaque_functab *functab;
if ((functab = ospf_opaque_functab_lookup (lsa)) == NULL)
{
- zlog_warn ("ospf_opaque_lsa_reoriginate_schedule: No associated function?: lsa_type(%u), opaque_type(%u)", lsa_type, opaque_type);
+ zlog_warn ("ospf_opaque_lsa_reoriginate_schedule:"
+ " No associated function?: lsa_type(%u),"
+ " opaque_type(%u)",
+ lsa_type, opaque_type);
goto out;
}
if ((oipt = register_opaque_info_per_type (functab, lsa)) == NULL)
{
- zlog_warn ("ospf_opaque_lsa_reoriginate_schedule: Cannot get a control info?: lsa_type(%u), opaque_type(%u)", lsa_type, opaque_type);
+ zlog_warn ("ospf_opaque_lsa_reoriginate_schedule:"
+ " Cannot get a control info?: lsa_type(%u),"
+ " opaque_type(%u)",
+ lsa_type, opaque_type);
goto out;
}
}
@@ -1777,7 +1789,9 @@
if (oipt->t_opaque_lsa_self != NULL)
{
if (IS_DEBUG_OSPF_EVENT)
- zlog_info ("Type-%u Opaque-LSA has already scheduled to RE-ORIGINATE: [opaque-type=%u]", lsa_type, GET_OPAQUE_TYPE (ntohl (lsa->data->id.s_addr)));
+ zlog_info ("Type-%u Opaque-LSA has already scheduled to"
+ " RE-ORIGINATE: [opaque-type=%u]",
+ lsa_type, GET_OPAQUE_TYPE (ntohl (lsa->data->id.s_addr)));
goto out;
}
@@ -1791,7 +1805,10 @@
delay = OSPF_MIN_LS_INTERVAL; /* XXX */
if (IS_DEBUG_OSPF_EVENT)
- zlog_info ("Schedule Type-%u Opaque-LSA to RE-ORIGINATE in %d sec later: [opaque-type=%u]", lsa_type, delay, GET_OPAQUE_TYPE (ntohl (lsa->data->id.s_addr)));
+ zlog_info ("Schedule Type-%u Opaque-LSA to RE-ORIGINATE in %d"
+ " sec later: [opaque-type=%u]",
+ lsa_type, delay,
+ GET_OPAQUE_TYPE (ntohl (lsa->data->id.s_addr)));
OSPF_OPAQUE_TIMER_ON (oipt->t_opaque_lsa_self, func, oipt, delay);
@@ -1869,7 +1886,7 @@
{
struct opaque_info_per_type *oipt;
struct ospf_opaque_functab *functab;
- listnode node;
+ struct listnode *node;
struct ospf *top;
struct ospf_area *area;
struct ospf_interface *oi;
@@ -1894,10 +1911,8 @@
/* There must be at least one "opaque-capable, full-state" neighbor. */
n = 0;
- for (node = listhead (area->oiflist); node; nextnode (node))
+ LIST_LOOP (area->oiflist, oi, node)
{
- if ((oi = getdata (node)) == NULL)
- continue;
if ((n = ospf_nbr_count_opaque_capable (oi)) > 0)
break;
}
@@ -1905,7 +1920,9 @@
if (n == 0 || ! CHECK_FLAG (top->config, OSPF_OPAQUE_CAPABLE))
{
if (IS_DEBUG_OSPF_EVENT)
- zlog_info ("Suspend re-origination of Type-10 Opaque-LSAs (opaque-type=%u) for a while...", oipt->opaque_type);
+ zlog_info ("Suspend re-origination of Type-10 Opaque-LSAs"
+ " (opaque-type=%u) for a while...",
+ oipt->opaque_type);
oipt->status = PROC_SUSPEND;
rc = 0;
@@ -1913,7 +1930,9 @@
}
if (IS_DEBUG_OSPF_EVENT)
- zlog_info ("Timer[Type10-LSA]: Re-originate Opaque-LSAs (opaque-type=%u) for Area %s", oipt->opaque_type, inet_ntoa (area->area_id));
+ zlog_info ("Timer[Type10-LSA]: Re-originate Opaque-LSAs"
+ " (opaque-type=%u) for Area %s",
+ oipt->opaque_type, inet_ntoa (area->area_id));
rc = (* functab->lsa_originator)(area);
out:
@@ -1932,9 +1951,10 @@
oipt->t_opaque_lsa_self = NULL;
if ((functab = oipt->functab) == NULL
- || functab->lsa_originator == NULL)
+ || functab->lsa_originator == NULL)
{
- zlog_warn ("ospf_opaque_type11_lsa_reoriginate_timer: No associated function?");
+ zlog_warn ("ospf_opaque_type11_lsa_reoriginate_timer:"
+ " No associated function?");
goto out;
}
@@ -2116,12 +2136,12 @@
static unsigned long ospf_opaque_nrxmt_self (struct route_table *nbrs, int lsa_type);
void
-ospf_opaque_adjust_lsreq (struct ospf_neighbor *nbr, list lsas)
+ospf_opaque_adjust_lsreq (struct ospf_neighbor *nbr, struct list *lsas)
{
struct ospf *top;
struct ospf_area *area;
struct ospf_interface *oi;
- listnode node1, node2;
+ struct listnode *node1, *node2;
struct ospf_lsa *lsa;
if ((top = oi_to_top (nbr->oi)) == NULL)
@@ -2228,10 +2248,11 @@
}
void
-ospf_opaque_self_originated_lsa_received (struct ospf_neighbor *nbr, list lsas)
+ospf_opaque_self_originated_lsa_received (struct ospf_neighbor *nbr,
+ struct list *lsas)
{
struct ospf *top;
- listnode node, next;
+ struct listnode *node, *next;
struct ospf_lsa *lsa;
u_char before;
@@ -2287,21 +2308,18 @@
}
void
-ospf_opaque_ls_ack_received (struct ospf_neighbor *nbr, list acks)
+ospf_opaque_ls_ack_received (struct ospf_neighbor *nbr, struct list *acks)
{
struct ospf *top;
- listnode node;
+ struct listnode *node;
struct ospf_lsa *lsa;
char type9_lsa_rcv = 0, type10_lsa_rcv = 0, type11_lsa_rcv = 0;
if ((top = oi_to_top (nbr->oi)) == NULL)
goto out;
- for (node = listhead (acks); node; nextnode (node))
+ LIST_LOOP (acks, lsa, node)
{
- if ((lsa = getdata (node)) == NULL)
- continue;
-
switch (lsa->data->type)
{
case OSPF_OPAQUE_LINK_LSA:
@@ -2350,13 +2368,11 @@
/* Ok, let's start origination of Opaque-LSAs. */
delay = OSPF_MIN_LS_INTERVAL;
- for (node = listhead (top->oiflist); node; nextnode (node))
- {
- if ((oi = getdata (node)) == NULL)
- continue;
+ LIST_LOOP (top->oiflist, oi, node)
+ {
if (! ospf_if_is_enable (oi)
- || ospf_nbr_count_opaque_capable (oi) == 0)
+ || ospf_nbr_count_opaque_capable (oi) == 0)
continue;
ospf_opaque_lsa_originate_schedule (oi, &delay);
@@ -2386,7 +2402,7 @@
static void
ospf_opaque_type10_lsa_rxmt_nbr_check (struct ospf_area *area)
{
- listnode node;
+ struct listnode *node;
struct ospf_interface *oi;
unsigned long n = 0;
@@ -2418,7 +2434,7 @@
static void
ospf_opaque_type11_lsa_rxmt_nbr_check (struct ospf *top)
{
- listnode node;
+ struct listnode *node;
struct ospf_interface *oi;
unsigned long n = 0;
diff --git a/ospfd/ospf_opaque.h b/ospfd/ospf_opaque.h
index 9aa08e5..743f043 100644
--- a/ospfd/ospf_opaque.h
+++ b/ospfd/ospf_opaque.h
@@ -144,9 +144,12 @@
extern void ospf_opaque_lsa_refresh_schedule (struct ospf_lsa *lsa);
extern void ospf_opaque_lsa_flush_schedule (struct ospf_lsa *lsa);
-extern void ospf_opaque_adjust_lsreq (struct ospf_neighbor *nbr, list lsas);
-extern void ospf_opaque_self_originated_lsa_received (struct ospf_neighbor *nbr, list lsas);
-extern void ospf_opaque_ls_ack_received (struct ospf_neighbor *nbr, list acks);
+extern void ospf_opaque_adjust_lsreq (struct ospf_neighbor *nbr,
+ struct list *lsas);
+extern void ospf_opaque_self_originated_lsa_received (struct ospf_neighbor *nbr,
+ struct list *lsas);
+extern void ospf_opaque_ls_ack_received (struct ospf_neighbor *nbr,
+ struct list *acks);
extern void htonf (float *src, float *dst);
extern void ntohf (float *src, float *dst);
diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c
index c4ecb79..111ee09 100644
--- a/ospfd/ospf_packet.c
+++ b/ospfd/ospf_packet.c
@@ -1917,7 +1917,7 @@
{
struct ospf_neighbor *nbr;
#ifdef HAVE_OPAQUE_LSA
- list opaque_acks;
+ struct list *opaque_acks;
#endif /* HAVE_OPAQUE_LSA */
/* increment statistics. */
diff --git a/ospfd/ospf_te.c b/ospfd/ospf_te.c
index 1a9946d..1d44250 100644
--- a/ospfd/ospf_te.c
+++ b/ospfd/ospf_te.c
@@ -67,7 +67,7 @@
enum { disabled, enabled } status;
/* List elements are zebra-interfaces (ifp), not ospf-interfaces (oi). */
- list iflist;
+ struct list *iflist;
/* Store Router-TLV in network byte order. */
struct te_tlv_router_addr router_addr;
@@ -252,13 +252,12 @@
static struct mpls_te_link *
lookup_linkparams_by_ifp (struct interface *ifp)
{
- listnode node;
+ struct listnode *node;
struct mpls_te_link *lp;
- for (node = listhead (OspfMplsTE.iflist); node; nextnode (node))
- if ((lp = getdata (node)) != NULL)
- if (lp->ifp == ifp)
- return lp;
+ LIST_LOOP (OspfMplsTE.iflist, lp, node)
+ if (lp->ifp == ifp)
+ return lp;
return NULL;
}
@@ -266,14 +265,13 @@
static struct mpls_te_link *
lookup_linkparams_by_instance (struct ospf_lsa *lsa)
{
- listnode node;
+ struct listnode *node;
struct mpls_te_link *lp;
int key = GET_OPAQUE_ID (ntohl (lsa->data->id.s_addr));
- for (node = listhead (OspfMplsTE.iflist); node; nextnode (node))
- if ((lp = getdata (node)) != NULL)
- if (lp->instance == key)
- return lp;
+ LIST_LOOP (OspfMplsTE.iflist, lp, node)
+ if (lp->instance == key)
+ return lp;
zlog_warn ("lookup_linkparams_by_instance: Entry not found: key(%x)", key);
return NULL;
@@ -284,14 +282,12 @@
void (*func)(struct mpls_te_link *lp, enum sched_opcode),
enum sched_opcode sched_opcode)
{
- listnode node, node2;
+ struct listnode *node, *node2;
struct mpls_te_link *lp;
struct ospf_area *area;
- for (node = listhead (OspfMplsTE.iflist); node; nextnode (node))
+ LIST_LOOP (OspfMplsTE.iflist, lp, node)
{
- if ((lp = getdata (node)) == NULL)
- continue;
if ((area = lp->area) == NULL)
continue;
if (lp->flags & LPFLG_LOOKUP_DONE)
@@ -307,10 +303,9 @@
lp->flags |= LPFLG_LOOKUP_DONE;
}
- for (node = listhead (OspfMplsTE.iflist); node; nextnode (node))
- if ((lp = getdata (node)) != NULL)
- if (lp->area != NULL)
- lp->flags &= ~LPFLG_LOOKUP_DONE;
+ LIST_LOOP (OspfMplsTE.iflist, lp, node)
+ if (lp->area != NULL)
+ lp->flags &= ~LPFLG_LOOKUP_DONE;
return;
}
@@ -597,7 +592,7 @@
if ((lp = lookup_linkparams_by_ifp (ifp)) != NULL)
{
- list iflist = OspfMplsTE.iflist;
+ struct list *iflist = OspfMplsTE.iflist;
/* Dequeue listnode entry from the list. */
listnode_delete (iflist, lp);
@@ -970,7 +965,7 @@
ospf_mpls_te_lsa_originate (void *arg)
{
struct ospf_area *area = (struct ospf_area *) arg;
- listnode node;
+ struct listnode *node;
struct mpls_te_link *lp;
int rc = -1;
@@ -1476,7 +1471,7 @@
"Configure MPLS-TE parameters\n"
"Enable the MPLS-TE functionality\n")
{
- listnode node;
+ struct listnode *node;
struct mpls_te_link *lp;
if (OspfMplsTE.status == enabled)
@@ -1515,7 +1510,7 @@
"Configure MPLS-TE parameters\n"
"Disable the MPLS-TE functionality\n")
{
- listnode node;
+ struct listnode *node;
struct mpls_te_link *lp;
if (OspfMplsTE.status == disabled)
@@ -1552,9 +1547,9 @@
}
if (ntohs (ra->header.type) == 0
- || ntohl (ra->value.s_addr) != ntohl (value.s_addr))
+ || ntohl (ra->value.s_addr) != ntohl (value.s_addr))
{
- listnode node;
+ struct listnode *node;
struct mpls_te_link *lp;
int need_to_reoriginate = 0;
@@ -1563,10 +1558,8 @@
if (OspfMplsTE.status == disabled)
goto out;
- for (node = listhead (OspfMplsTE.iflist); node; nextnode (node))
+ LIST_LOOP (OspfMplsTE.iflist, lp, node)
{
- if ((lp = getdata (node)) == NULL)
- continue;
if (lp->area == NULL)
continue;
@@ -1577,9 +1570,8 @@
}
}
for (node = listhead (OspfMplsTE.iflist); node; nextnode (node))
+ LIST_LOOP (OspfMplsTE.iflist, lp, node)
{
- if ((lp = getdata (node)) == NULL)
- continue;
if (lp->area == NULL)
continue;
@@ -1876,12 +1868,12 @@
"Interface name\n")
{
struct interface *ifp;
- listnode node;
+ struct listnode *node;
/* Show All Interfaces. */
if (argc == 0)
- for (node = listhead (iflist); node; nextnode (node))
- show_mpls_te_link_sub (vty, node->data);
+ LIST_LOOP (iflist, ifp, node)
+ show_mpls_te_link_sub (vty, ifp);
/* Interface name is specified. */
else
{