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.
This commit is contained in:
paul 2004-09-24 08:01:38 +00:00
parent 52dc7ee65f
commit 87d6f87aec
8 changed files with 353 additions and 376 deletions

View File

@ -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> 2004-09-23 Hasso Tepper <hasso at quagga.net>
* *.[c|h]: list -> struct list *, listnode -> struct listnode *. * *.[c|h]: list -> struct list *, listnode -> struct listnode *.

View File

@ -73,7 +73,7 @@
* daemon supports multiple applications concurrently. */ * daemon supports multiple applications concurrently. */
/* List of all active connections. */ /* List of all active connections. */
list apiserver_list; struct list *apiserver_list;
/* ----------------------------------------------------------- /* -----------------------------------------------------------
* Functions to lookup interfaces * Functions to lookup interfaces
@ -83,7 +83,7 @@ list apiserver_list;
struct ospf_interface * struct ospf_interface *
ospf_apiserver_if_lookup_by_addr (struct in_addr address) ospf_apiserver_if_lookup_by_addr (struct in_addr address)
{ {
listnode node; struct listnode *node;
struct ospf_interface *oi; struct ospf_interface *oi;
struct ospf *ospf; struct ospf *ospf;
@ -91,34 +91,28 @@ ospf_apiserver_if_lookup_by_addr (struct in_addr address)
return NULL; return NULL;
for (node = listhead (ospf->oiflist); node; nextnode (node)) for (node = listhead (ospf->oiflist); node; nextnode (node))
{ LIST_LOOP (ospf->oiflist, oi, node)
if ((oi = getdata (node)) != NULL if (oi->type != OSPF_IFTYPE_VIRTUALLINK)
&& oi->type != OSPF_IFTYPE_VIRTUALLINK)
{
if (IPV4_ADDR_SAME (&address, &oi->address->u.prefix4)) if (IPV4_ADDR_SAME (&address, &oi->address->u.prefix4))
return oi; return oi;
}
}
return NULL; return NULL;
} }
struct ospf_interface * struct ospf_interface *
ospf_apiserver_if_lookup_by_ifp (struct interface *ifp) ospf_apiserver_if_lookup_by_ifp (struct interface *ifp)
{ {
listnode node; struct listnode *node;
struct ospf_interface *oi; struct ospf_interface *oi;
struct ospf *ospf; struct ospf *ospf;
if (!(ospf = ospf_lookup ())); if (!(ospf = ospf_lookup ()));
return NULL; return NULL;
for (node = listhead (ospf->oiflist); node; nextnode (node)) LIST_LOOP (ospf->oiflist, oi, node)
{ if (oi->ifp == ifp)
if ((oi = getdata (node)) && oi->ifp == ifp)
{
return oi; return oi;
}
}
return NULL; return NULL;
} }
@ -186,19 +180,16 @@ out:
void void
ospf_apiserver_term (void) ospf_apiserver_term (void)
{ {
listnode node; struct listnode *node;
struct ospf_apiserver *apiserv;
/* Unregister wildcard [0/0] type */ /* Unregister wildcard [0/0] type */
ospf_delete_opaque_functab (0 /* all LSAs */, ospf_delete_opaque_functab (0 /* all LSAs */,
0 /* all opaque types */); 0 /* all opaque types */);
/* Free all client instances */ /* Free all client instances */
for (node = listhead (apiserver_list); node; nextnode (node)) LIST_LOOP (apiserver_list, apiserv, node)
{
struct ospf_apiserver *apiserv =
(struct ospf_apiserver *) getdata (node);
ospf_apiserver_free (apiserv); ospf_apiserver_free (apiserv);
}
/* Free client list itself */ /* Free client list itself */
list_delete (apiserver_list); list_delete (apiserver_list);
@ -210,10 +201,11 @@ ospf_apiserver_term (void)
static struct ospf_apiserver * static struct ospf_apiserver *
lookup_apiserver (u_char lsa_type, u_char opaque_type) lookup_apiserver (u_char lsa_type, u_char opaque_type)
{ {
listnode n1, n2; struct listnode *n1, *n2;
struct registered_opaque_type *r; struct registered_opaque_type *r;
struct ospf_apiserver *apiserv, *found = NULL; struct ospf_apiserver *apiserv, *found = NULL;
/* XXX: this approaches O(n**2) */
for (n1 = listhead (apiserver_list); n1; nextnode (n1)) for (n1 = listhead (apiserver_list); n1; nextnode (n1))
{ {
apiserv = (struct ospf_apiserver *) getdata (n1); apiserv = (struct ospf_apiserver *) getdata (n1);
@ -351,7 +343,7 @@ ospf_apiserver_event (enum event event, int fd,
void void
ospf_apiserver_free (struct ospf_apiserver *apiserv) ospf_apiserver_free (struct ospf_apiserver *apiserv)
{ {
listnode node; struct listnode *node;
/* Cancel read and write threads. */ /* Cancel read and write threads. */
if (apiserv->t_sync_read) if (apiserv->t_sync_read)
@ -958,7 +950,10 @@ ospf_apiserver_register_opaque_type (struct ospf_apiserver *apiserv,
listnode_add (apiserv->opaque_types, regtype); listnode_add (apiserv->opaque_types, regtype);
if (IS_DEBUG_OSPF_EVENT) 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; return 0;
} }
@ -967,10 +962,12 @@ int
ospf_apiserver_unregister_opaque_type (struct ospf_apiserver *apiserv, ospf_apiserver_unregister_opaque_type (struct ospf_apiserver *apiserv,
u_char lsa_type, u_char opaque_type) 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; struct registered_opaque_type *regtype = node->data;
/* Check if we really registered this opaque type */ /* Check if we really registered this opaque type */
@ -988,7 +985,10 @@ ospf_apiserver_unregister_opaque_type (struct ospf_apiserver *apiserv,
listnode_delete (apiserv->opaque_types, regtype); listnode_delete (apiserv->opaque_types, regtype);
if (IS_DEBUG_OSPF_EVENT) 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; return 0;
} }
@ -1005,12 +1005,12 @@ int
apiserver_is_opaque_type_registered (struct ospf_apiserver *apiserv, apiserver_is_opaque_type_registered (struct ospf_apiserver *apiserv,
u_char lsa_type, u_char opaque_type) 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 */ /* Check if we really registered this opaque type */
if (regtype->lsa_type == lsa_type && if (regtype->lsa_type == lsa_type &&
regtype->opaque_type == opaque_type) regtype->opaque_type == opaque_type)
@ -1067,25 +1067,24 @@ out:
void void
ospf_apiserver_notify_ready_type9 (struct ospf_apiserver *apiserv) ospf_apiserver_notify_ready_type9 (struct ospf_apiserver *apiserv)
{ {
listnode node; struct listnode *node;
listnode n2; struct listnode *n2;
struct ospf *ospf; struct ospf *ospf;
struct ospf_interface *oi;
struct registered_opaque_type *r;
ospf = ospf_lookup (); 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 */ /* Check if this interface is indeed ready for type 9 */
if (!ospf_apiserver_is_ready_type9 (oi)) if (!ospf_apiserver_is_ready_type9 (oi))
continue; continue;
/* Check for registered opaque type 9 types */ /* 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; struct msg *msg;
if (r->lsa_type == OSPF_OPAQUE_LINK_LSA) if (r->lsa_type == OSPF_OPAQUE_LINK_LSA)
@ -1119,15 +1118,16 @@ out:
void void
ospf_apiserver_notify_ready_type10 (struct ospf_apiserver *apiserv) ospf_apiserver_notify_ready_type10 (struct ospf_apiserver *apiserv)
{ {
listnode node; struct listnode *node;
listnode n2; struct listnode *n2;
struct ospf *ospf; struct ospf *ospf;
struct ospf_area *area;
ospf = ospf_lookup (); 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)) if (!ospf_apiserver_is_ready_type10 (area))
{ {
@ -1135,10 +1135,9 @@ ospf_apiserver_notify_ready_type10 (struct ospf_apiserver *apiserv)
} }
/* Check for registered opaque type 10 types */ /* 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; struct msg *msg;
if (r->lsa_type == OSPF_OPAQUE_AREA_LSA) if (r->lsa_type == OSPF_OPAQUE_AREA_LSA)
@ -1170,8 +1169,9 @@ out:
void void
ospf_apiserver_notify_ready_type11 (struct ospf_apiserver *apiserv) ospf_apiserver_notify_ready_type11 (struct ospf_apiserver *apiserv)
{ {
listnode n2; struct listnode *node;
struct ospf *ospf; struct ospf *ospf;
struct registered_opaque_type *r;
ospf = ospf_lookup (); ospf = ospf_lookup ();
@ -1180,10 +1180,8 @@ ospf_apiserver_notify_ready_type11 (struct ospf_apiserver *apiserv)
goto out;; goto out;;
/* Check for registered opaque type 11 types */ /* 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 msg *msg;
struct in_addr noarea_id = { 0L }; struct in_addr noarea_id = { 0L };
@ -1349,7 +1347,7 @@ int
ospf_apiserver_handle_sync_lsdb (struct ospf_apiserver *apiserv, ospf_apiserver_handle_sync_lsdb (struct ospf_apiserver *apiserv,
struct msg *msg) struct msg *msg)
{ {
listnode node; struct listnode *node;
u_int32_t seqnum; u_int32_t seqnum;
int rc = 0; int rc = 0;
struct msg_sync_lsdb *smsg; struct msg_sync_lsdb *smsg;
@ -1363,6 +1361,7 @@ ospf_apiserver_handle_sync_lsdb (struct ospf_apiserver *apiserv,
struct route_node *rn; struct route_node *rn;
struct ospf_lsa *lsa; struct ospf_lsa *lsa;
struct ospf *ospf; struct ospf *ospf;
struct ospf_area *area;
ospf = ospf_lookup (); ospf = ospf_lookup ();
@ -1379,11 +1378,11 @@ ospf_apiserver_handle_sync_lsdb (struct ospf_apiserver *apiserv,
mask = ntohs (smsg->filter.typemask); mask = ntohs (smsg->filter.typemask);
/* Iterate over all areas. */ /* 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; int i;
u_int32_t *area_id = NULL; u_int32_t *area_id = NULL;
/* Compare area_id with area_ids in sync request. */ /* Compare area_id with area_ids in sync request. */
if ((i = smsg->filter.num_areas) > 0) if ((i = smsg->filter.num_areas) > 0)
{ {
@ -1562,18 +1561,14 @@ ospf_apiserver_is_ready_type10 (struct ospf_area *area)
/* Type 10 opaque LSA can be originated if there is at least one /* Type 10 opaque LSA can be originated if there is at least one
interface belonging to the area that has an active opaque-capable interface belonging to the area that has an active opaque-capable
neighbor. */ 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? */ /* Is there an active neighbor attached to this interface? */
if (ospf_apiserver_is_ready_type9 (oi)) if (ospf_apiserver_is_ready_type9 (oi))
{
return 1; return 1;
}
}
/* No active neighbor in area */ /* No active neighbor in area */
return 0; return 0;
} }
@ -1583,16 +1578,14 @@ ospf_apiserver_is_ready_type11 (struct ospf *ospf)
{ {
/* Type 11 opaque LSA can be originated if there is at least one interface /* Type 11 opaque LSA can be originated if there is at least one interface
that has an active opaque-capable neighbor. */ 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? */ /* Is there an active neighbor attached to this interface? */
if (ospf_apiserver_is_ready_type9 (oi)) if (ospf_apiserver_is_ready_type9 (oi))
return 1; return 1;
}
/* No active neighbor at all */ /* No active neighbor at all */
return 0; return 0;
} }
@ -2054,10 +2047,10 @@ ospf_apiserver_flush_opaque_lsa (struct ospf_apiserver *apiserv,
struct ospf_apiserver *apiserv; struct ospf_apiserver *apiserv;
u_char lsa_type; u_char lsa_type;
u_char opaque_type; u_char opaque_type;
} } param;
param; struct listnode *node;
listnode node;
struct ospf * ospf; struct ospf * ospf;
struct ospf_area *area;
ospf = ospf_lookup(); ospf = ospf_lookup();
assert(ospf); assert(ospf);
@ -2067,45 +2060,20 @@ ospf_apiserver_flush_opaque_lsa (struct ospf_apiserver *apiserv,
param.lsa_type = lsa_type; param.lsa_type = lsa_type;
param.opaque_type = opaque_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 *) &param, 0,
apiserver_flush_opaque_type_callback);
foreach_lsa (OPAQUE_AREA_LSDB (area), (void *) &param, 0,
apiserver_flush_opaque_type_callback);
}
/* For AS-external opaque LSAs */
if (ospf->lsdb)
{
foreach_lsa (OPAQUE_AS_LSDB (ospf_top), (void *) &param, 0,
apiserver_flush_opaque_type_callback);
}
#else /* ORIGINAL_CODING */
switch (lsa_type) switch (lsa_type)
{ {
struct route_node *rn; struct route_node *rn;
struct ospf_lsa *lsa; struct ospf_lsa *lsa;
case OSPF_OPAQUE_LINK_LSA: case OSPF_OPAQUE_LINK_LSA:
for (node = listhead (ospf->areas); node; nextnode (node)) LIST_LOOP (ospf->areas, area, node)
{
struct ospf_area *area = node->data;
LSDB_LOOP (OPAQUE_LINK_LSDB (area), rn, lsa) LSDB_LOOP (OPAQUE_LINK_LSDB (area), rn, lsa)
apiserver_flush_opaque_type_callback(lsa, (void *) &param, 0); apiserver_flush_opaque_type_callback(lsa, (void *) &param, 0);
}
break; break;
case OSPF_OPAQUE_AREA_LSA: case OSPF_OPAQUE_AREA_LSA:
for (node = listhead (ospf->areas); node; nextnode (node)) LIST_LOOP (ospf->areas, area, node)
{
struct ospf_area *area = node->data;
LSDB_LOOP (OPAQUE_AREA_LSDB (area), rn, lsa) LSDB_LOOP (OPAQUE_AREA_LSDB (area), rn, lsa)
apiserver_flush_opaque_type_callback(lsa, (void *) &param, 0); apiserver_flush_opaque_type_callback(lsa, (void *) &param, 0);
}
break; break;
case OSPF_OPAQUE_AS_LSA: case OSPF_OPAQUE_AS_LSA:
LSDB_LOOP (OPAQUE_LINK_LSDB (ospf), rn, lsa) LSDB_LOOP (OPAQUE_LINK_LSDB (ospf), rn, lsa)
@ -2115,7 +2083,6 @@ ospf_apiserver_flush_opaque_lsa (struct ospf_apiserver *apiserv,
break; break;
} }
return; return;
#endif /* ORIGINAL_CODING */
} }
@ -2234,13 +2201,9 @@ ospf_apiserver_show_info (struct vty *vty, struct ospf_lsa *lsa)
olsa = (struct opaque_lsa *) lsa->data; olsa = (struct opaque_lsa *) lsa->data;
if (VALID_OPAQUE_INFO_LEN (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 else
{
opaquelen = 0; opaquelen = 0;
}
/* Output information about opaque LSAs */ /* Output information about opaque LSAs */
if (vty != NULL) if (vty != NULL)
@ -2288,16 +2251,12 @@ ospf_apiserver_show_info (struct vty *vty, struct ospf_lsa *lsa)
void void
ospf_apiserver_clients_notify_all (struct msg *msg) ospf_apiserver_clients_notify_all (struct msg *msg)
{ {
listnode node; struct listnode *node;
struct ospf_apiserver *apiserv;
/* Send message to all clients */ /* Send message to all clients */
for (node = listhead (apiserver_list); node; nextnode (node)) LIST_LOOP (apiserver_list, apiserv, node)
{
struct ospf_apiserver *apiserv =
(struct ospf_apiserver *) getdata (node);
ospf_apiserver_send_msg (apiserv, msg); ospf_apiserver_send_msg (apiserv, msg);
}
} }
/* An interface is now ready to accept opaque LSAs. Notify all /* An interface is now ready to accept opaque LSAs. Notify all
@ -2305,8 +2264,9 @@ ospf_apiserver_clients_notify_all (struct msg *msg)
void void
ospf_apiserver_clients_notify_ready_type9 (struct ospf_interface *oi) ospf_apiserver_clients_notify_ready_type9 (struct ospf_interface *oi)
{ {
listnode node; struct listnode *node;
struct msg *msg; struct msg *msg;
struct ospf_apiserver *apiserv;
assert (oi); assert (oi);
if (!oi->address) if (!oi->address)
@ -2321,16 +2281,13 @@ ospf_apiserver_clients_notify_ready_type9 (struct ospf_interface *oi)
return; return;
} }
for (node = listhead (apiserver_list); node; nextnode (node)) LIST_LOOP (apiserver_list, apiserv, node)
{ {
struct ospf_apiserver *apiserv = struct listnode *n2;
(struct ospf_apiserver *) getdata (node); struct registered_opaque_type *r;
listnode n2;
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) if (r->lsa_type == OSPF_OPAQUE_LINK_LSA)
{ {
msg = new_msg_ready_notify (0, OSPF_OPAQUE_LINK_LSA, msg = new_msg_ready_notify (0, OSPF_OPAQUE_LINK_LSA,
@ -2360,8 +2317,9 @@ out:
void void
ospf_apiserver_clients_notify_ready_type10 (struct ospf_area *area) ospf_apiserver_clients_notify_ready_type10 (struct ospf_area *area)
{ {
listnode node; struct listnode *node;
struct msg *msg; struct msg *msg;
struct ospf_apiserver *apiserv;
assert (area); assert (area);
@ -2371,16 +2329,13 @@ ospf_apiserver_clients_notify_ready_type10 (struct ospf_area *area)
return; return;
} }
for (node = listhead (apiserver_list); node; nextnode (node)) LIST_LOOP (apiserver_list, apiserv, node)
{ {
struct ospf_apiserver *apiserv = struct listnode *n2;
(struct ospf_apiserver *) getdata (node); struct registered_opaque_type *r;
listnode n2;
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) if (r->lsa_type == OSPF_OPAQUE_AREA_LSA)
{ {
msg = new_msg_ready_notify (0, OSPF_OPAQUE_AREA_LSA, msg = new_msg_ready_notify (0, OSPF_OPAQUE_AREA_LSA,
@ -2410,9 +2365,10 @@ out:
void void
ospf_apiserver_clients_notify_ready_type11 (struct ospf *top) ospf_apiserver_clients_notify_ready_type11 (struct ospf *top)
{ {
listnode node; struct listnode *node;
struct msg *msg; struct msg *msg;
struct in_addr id_null = { 0L }; struct in_addr id_null = { 0L };
struct ospf_apiserver *apiserv;
assert (top); assert (top);
@ -2422,16 +2378,13 @@ ospf_apiserver_clients_notify_ready_type11 (struct ospf *top)
return; return;
} }
for (node = listhead (apiserver_list); node; nextnode (node)) LIST_LOOP (apiserver_list, apiserv, node)
{ {
struct ospf_apiserver *apiserv = struct listnode *n2;
(struct ospf_apiserver *) getdata (node); struct registered_opaque_type *r;
listnode n2;
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) if (r->lsa_type == OSPF_OPAQUE_AS_LSA)
{ {
msg = new_msg_ready_notify (0, OSPF_OPAQUE_AS_LSA, msg = new_msg_ready_notify (0, OSPF_OPAQUE_AS_LSA,
@ -2544,7 +2497,8 @@ void
apiserver_clients_lsa_change_notify (u_char msgtype, struct ospf_lsa *lsa) apiserver_clients_lsa_change_notify (u_char msgtype, struct ospf_lsa *lsa)
{ {
struct msg *msg; struct msg *msg;
listnode node; struct listnode *node;
struct ospf_apiserver *apiserv;
/* Default area for AS-External and Opaque11 LSAs */ /* Default area for AS-External and Opaque11 LSAs */
struct in_addr area_id = { 0L }; struct in_addr area_id = { 0L };
@ -2574,9 +2528,8 @@ apiserver_clients_lsa_change_notify (u_char msgtype, struct ospf_lsa *lsa)
} }
/* Now send message to all clients with a matching filter */ /* 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; struct lsa_filter_type *filter;
u_int16_t mask; u_int16_t mask;
u_int32_t *area; u_int32_t *area;

View File

@ -50,7 +50,7 @@ struct ospf_apiserver
a single connection with the OSPF daemon, multiple a single connection with the OSPF daemon, multiple
<lsa,opaque_type> pairs can be registered. However, each <lsa,opaque_type> pairs can be registered. However, each
combination can only be registered once by all applications. */ 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. */ /* Temporary storage for LSA instances to be refreshed. */
struct ospf_lsdb reserve; struct ospf_lsdb reserve;

View File

@ -146,7 +146,7 @@ struct ospf_interface
/* self-originated LSAs. */ /* self-originated LSAs. */
struct ospf_lsa *network_lsa_self; /* network-LSA. */ struct ospf_lsa *network_lsa_self; /* network-LSA. */
#ifdef HAVE_OPAQUE_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 */ #endif /* HAVE_OPAQUE_LSA */
struct route_table *ls_upd_queue; struct route_table *ls_upd_queue;

View File

@ -253,10 +253,11 @@ struct ospf_opaque_functab
int (* del_lsa_hook)(struct ospf_lsa *lsa); int (* del_lsa_hook)(struct ospf_lsa *lsa);
}; };
static list ospf_opaque_wildcard_funclist; /* Handle LSA-9/10/11 altogether. */ /* Handle LSA-9/10/11 altogether. */
static list ospf_opaque_type9_funclist; static struct list *ospf_opaque_wildcard_funclist;
static list ospf_opaque_type10_funclist; static struct list *ospf_opaque_type9_funclist;
static list ospf_opaque_type11_funclist; static struct list *ospf_opaque_type10_funclist;
static struct list *ospf_opaque_type11_funclist;
static void static void
ospf_opaque_del_functab (void *val) ospf_opaque_del_functab (void *val)
@ -268,7 +269,7 @@ ospf_opaque_del_functab (void *val)
static void static void
ospf_opaque_funclist_init (void) ospf_opaque_funclist_init (void)
{ {
list funclist; struct list *funclist;
funclist = ospf_opaque_wildcard_funclist = list_new (); funclist = ospf_opaque_wildcard_funclist = list_new ();
funclist->del = ospf_opaque_del_functab; funclist->del = ospf_opaque_del_functab;
@ -287,7 +288,7 @@ ospf_opaque_funclist_init (void)
static void static void
ospf_opaque_funclist_term (void) ospf_opaque_funclist_term (void)
{ {
list funclist; struct list *funclist;
funclist = ospf_opaque_wildcard_funclist; funclist = ospf_opaque_wildcard_funclist;
list_delete (funclist); list_delete (funclist);
@ -303,10 +304,10 @@ ospf_opaque_funclist_term (void)
return; return;
} }
static list static struct list *
ospf_get_opaque_funclist (u_char lsa_type) ospf_get_opaque_funclist (u_char lsa_type)
{ {
list funclist = NULL; struct list *funclist = NULL;
switch (lsa_type) switch (lsa_type)
{ {
@ -336,6 +337,7 @@ ospf_get_opaque_funclist (u_char lsa_type)
return funclist; return funclist;
} }
/* XXX: such a huge argument list can /not/ be healthy... */
int int
ospf_register_opaque_functab ( ospf_register_opaque_functab (
u_char lsa_type, u_char lsa_type,
@ -353,25 +355,28 @@ ospf_register_opaque_functab (
int (* new_lsa_hook)(struct ospf_lsa *lsa), int (* new_lsa_hook)(struct ospf_lsa *lsa),
int (* del_lsa_hook)(struct ospf_lsa *lsa)) int (* del_lsa_hook)(struct ospf_lsa *lsa))
{ {
list funclist; struct list *funclist;
struct ospf_opaque_functab *new; struct ospf_opaque_functab *new;
int rc = -1; int rc = -1;
if ((funclist = ospf_get_opaque_funclist (lsa_type)) == NULL) 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; goto out;
} }
else else
{ {
listnode node; struct listnode *node;
struct ospf_opaque_functab *functab; struct ospf_opaque_functab *functab;
for (node = listhead (funclist); node; nextnode (node)) LIST_LOOP (funclist, functab, node)
if ((functab = getdata (node)) != NULL)
if (functab->opaque_type == opaque_type) if (functab->opaque_type == opaque_type)
{ {
zlog_warn ("ospf_register_opaque_functab: Duplicated entry?: lsa_type(%u), opaque_type(%u)", lsa_type, opaque_type); zlog_warn ("ospf_register_opaque_functab: Duplicated entry?:"
" lsa_type(%u), opaque_type(%u)",
lsa_type, opaque_type);
goto out; goto out;
} }
} }
@ -379,7 +384,8 @@ ospf_register_opaque_functab (
if ((new = XCALLOC (MTYPE_OSPF_OPAQUE_FUNCTAB, if ((new = XCALLOC (MTYPE_OSPF_OPAQUE_FUNCTAB,
sizeof (struct ospf_opaque_functab))) == NULL) 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; goto out;
} }
@ -408,8 +414,8 @@ out:
void void
ospf_delete_opaque_functab (u_char lsa_type, u_char opaque_type) ospf_delete_opaque_functab (u_char lsa_type, u_char opaque_type)
{ {
list funclist; struct list *funclist;
listnode node; struct listnode *node;
struct ospf_opaque_functab *functab; struct ospf_opaque_functab *functab;
if ((funclist = ospf_get_opaque_funclist (lsa_type)) != NULL) if ((funclist = ospf_get_opaque_funclist (lsa_type)) != NULL)
@ -430,24 +436,23 @@ ospf_delete_opaque_functab (u_char lsa_type, u_char opaque_type)
funclist->head = funclist->tail = NULL; funclist->head = funclist->tail = NULL;
XFREE (MTYPE_OSPF_OPAQUE_FUNCTAB, functab); XFREE (MTYPE_OSPF_OPAQUE_FUNCTAB, functab);
goto out; break;
} }
} }
out:
return; return;
} }
static struct ospf_opaque_functab * static struct ospf_opaque_functab *
ospf_opaque_functab_lookup (struct ospf_lsa *lsa) ospf_opaque_functab_lookup (struct ospf_lsa *lsa)
{ {
list funclist; struct list *funclist;
listnode node; struct listnode *node;
struct ospf_opaque_functab *functab; struct ospf_opaque_functab *functab;
u_char key = GET_OPAQUE_TYPE (ntohl (lsa->data->id.s_addr)); u_char key = GET_OPAQUE_TYPE (ntohl (lsa->data->id.s_addr));
if ((funclist = ospf_get_opaque_funclist (lsa->data->type)) != NULL) if ((funclist = ospf_get_opaque_funclist (lsa->data->type)) != NULL)
for (node = listhead (funclist); node; nextnode (node)) LIST_LOOP (funclist, functab, node)
if ((functab = getdata (node)) != NULL)
if (functab->opaque_type == key) if (functab->opaque_type == key)
return functab; return functab;
@ -494,7 +499,7 @@ struct opaque_info_per_type
struct ospf_opaque_functab *functab; struct ospf_opaque_functab *functab;
/* List of Opaque-LSA control informations per opaque-id. */ /* List of Opaque-LSA control informations per opaque-id. */
list id_list; struct list *id_list;
}; };
/* Opaque-LSA control information per opaque-id. */ /* Opaque-LSA control information per opaque-id. */
@ -580,7 +585,7 @@ free_opaque_info_per_type (void *val)
struct opaque_info_per_type *oipt = (struct opaque_info_per_type *) val; struct opaque_info_per_type *oipt = (struct opaque_info_per_type *) val;
struct opaque_info_per_id *oipi; struct opaque_info_per_id *oipi;
struct ospf_lsa *lsa; struct ospf_lsa *lsa;
listnode node; struct listnode *node;
/* Control information per opaque-id may still exist. */ /* Control information per opaque-id may still exist. */
for (node = listhead (oipt->id_list); node; nextnode (node)) for (node = listhead (oipt->id_list); node; nextnode (node))
@ -632,8 +637,8 @@ lookup_opaque_info_by_type (struct ospf_lsa *lsa)
struct ospf *top; struct ospf *top;
struct ospf_area *area; struct ospf_area *area;
struct ospf_interface *oi; struct ospf_interface *oi;
list listtop = NULL; struct list *listtop = NULL;
listnode node; struct listnode *node;
struct opaque_info_per_type *oipt = NULL; struct opaque_info_per_type *oipt = NULL;
u_char key = GET_OPAQUE_TYPE (ntohl (lsa->data->id.s_addr)); u_char key = GET_OPAQUE_TYPE (ntohl (lsa->data->id.s_addr));
@ -666,8 +671,7 @@ lookup_opaque_info_by_type (struct ospf_lsa *lsa)
} }
if (listtop != NULL) if (listtop != NULL)
for (node = listhead (listtop); node; nextnode (node)) LIST_LOOP (listtop, oipt, node)
if ((oipt = getdata (node)) != NULL)
if (oipt->opaque_type == key) if (oipt->opaque_type == key)
return oipt; return oipt;
@ -713,12 +717,11 @@ static struct opaque_info_per_id *
lookup_opaque_info_by_id (struct opaque_info_per_type *oipt, lookup_opaque_info_by_id (struct opaque_info_per_type *oipt,
struct ospf_lsa *lsa) struct ospf_lsa *lsa)
{ {
listnode node; struct listnode *node;
struct opaque_info_per_id *oipi; struct opaque_info_per_id *oipi;
u_int32_t key = GET_OPAQUE_ID (ntohl (lsa->data->id.s_addr)); u_int32_t key = GET_OPAQUE_ID (ntohl (lsa->data->id.s_addr));
for (node = listhead (oipt->id_list); node; nextnode (node)) LIST_LOOP (oipt->id_list, oipi, node)
if ((oipi = getdata (node)) != NULL)
if (oipi->opaque_id == key) if (oipi->opaque_id == key)
return oipi; return oipi;
@ -819,14 +822,13 @@ ospf_opaque_register_vty (void)
*------------------------------------------------------------------------*/ *------------------------------------------------------------------------*/
static int 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; struct ospf_opaque_functab *functab;
int rc = -1; int rc = -1;
for (node = listhead (funclist); node; nextnode (node)) LIST_LOOP (funclist, functab, node)
if ((functab = getdata (node)) != NULL)
if (functab->new_if_hook != NULL) if (functab->new_if_hook != NULL)
if ((* functab->new_if_hook)(ifp) != 0) if ((* functab->new_if_hook)(ifp) != 0)
goto out; goto out;
@ -836,14 +838,13 @@ out:
} }
static int 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; struct ospf_opaque_functab *functab;
int rc = -1; int rc = -1;
for (node = listhead (funclist); node; nextnode (node)) LIST_LOOP (funclist, functab, node)
if ((functab = getdata (node)) != NULL)
if (functab->del_if_hook != NULL) if (functab->del_if_hook != NULL)
if ((* functab->del_if_hook)(ifp) != 0) if ((* functab->del_if_hook)(ifp) != 0)
goto out; goto out;
@ -853,82 +854,78 @@ out:
} }
static void static void
opaque_lsa_ism_change_callback (list funclist, opaque_lsa_ism_change_callback (struct list *funclist,
struct ospf_interface *oi, int old_status) struct ospf_interface *oi, int old_status)
{ {
listnode node; struct listnode *node;
struct ospf_opaque_functab *functab; struct ospf_opaque_functab *functab;
for (node = listhead (funclist); node; nextnode (node)) LIST_LOOP (funclist, functab, node)
if ((functab = getdata (node)) != NULL)
if (functab->ism_change_hook != NULL) if (functab->ism_change_hook != NULL)
(* functab->ism_change_hook)(oi, old_status); (* functab->ism_change_hook)(oi, old_status);
return; return;
} }
static void static void
opaque_lsa_nsm_change_callback (list funclist, opaque_lsa_nsm_change_callback (struct list *funclist,
struct ospf_neighbor *nbr, int old_status) struct ospf_neighbor *nbr, int old_status)
{ {
listnode node; struct listnode *node;
struct ospf_opaque_functab *functab; struct ospf_opaque_functab *functab;
for (node = listhead (funclist); node; nextnode (node)) LIST_LOOP (funclist, functab, node)
if ((functab = getdata (node)) != NULL)
if (functab->nsm_change_hook != NULL) if (functab->nsm_change_hook != NULL)
(* functab->nsm_change_hook)(nbr, old_status); (* functab->nsm_change_hook)(nbr, old_status);
return; return;
} }
static void 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; struct ospf_opaque_functab *functab;
for (node = listhead (funclist); node; nextnode (node)) LIST_LOOP (funclist, functab, node)
if ((functab = getdata (node)) != NULL)
if (functab->config_write_router != NULL) if (functab->config_write_router != NULL)
(* functab->config_write_router)(vty); (* functab->config_write_router)(vty);
return; return;
} }
static void 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) struct vty *vty, struct interface *ifp)
{ {
listnode node; struct listnode *node;
struct ospf_opaque_functab *functab; struct ospf_opaque_functab *functab;
for (node = listhead (funclist); node; nextnode (node)) LIST_LOOP (funclist, functab, node)
if ((functab = getdata (node)) != NULL)
if (functab->config_write_if != NULL) if (functab->config_write_if != NULL)
(* functab->config_write_if)(vty, ifp); (* functab->config_write_if)(vty, ifp);
return; return;
} }
static void 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; struct ospf_opaque_functab *functab;
for (node = listhead (funclist); node; nextnode (node)) LIST_LOOP (funclist, functab, node)
if ((functab = getdata (node)) != NULL)
if (functab->config_write_debug != NULL) if (functab->config_write_debug != NULL)
(* functab->config_write_debug)(vty); (* functab->config_write_debug)(vty);
return; return;
} }
static int 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; struct ospf_opaque_functab *functab;
int rc = -1; int rc = -1;
for (node = listhead (funclist); node; nextnode (node)) LIST_LOOP (funclist, functab, node)
if ((functab = getdata (node)) != NULL)
if (functab->lsa_originator != NULL) if (functab->lsa_originator != NULL)
if ((* functab->lsa_originator)(lsa_type_dependent) != 0) if ((* functab->lsa_originator)(lsa_type_dependent) != 0)
goto out; goto out;
@ -938,15 +935,14 @@ out:
} }
static int 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; struct ospf_opaque_functab *functab;
int rc = -1; int rc = -1;
/* This function handles ALL types of LSAs, not only opaque ones. */ /* This function handles ALL types of LSAs, not only opaque ones. */
for (node = listhead (funclist); node; nextnode (node)) LIST_LOOP (funclist, functab, node)
if ((functab = getdata (node)) != NULL)
if (functab->new_lsa_hook != NULL) if (functab->new_lsa_hook != NULL)
if ((* functab->new_lsa_hook)(lsa) != 0) if ((* functab->new_lsa_hook)(lsa) != 0)
goto out; goto out;
@ -956,15 +952,14 @@ out:
} }
static int 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; struct ospf_opaque_functab *functab;
int rc = -1; int rc = -1;
/* This function handles ALL types of LSAs, not only opaque ones. */ /* This function handles ALL types of LSAs, not only opaque ones. */
for (node = listhead (funclist); node; nextnode (node)) LIST_LOOP (funclist, functab, node)
if ((functab = getdata (node)) != NULL)
if (functab->del_lsa_hook != NULL) if (functab->del_lsa_hook != NULL)
if ((* functab->del_lsa_hook)(lsa) != 0) if ((* functab->del_lsa_hook)(lsa) != 0)
goto out; goto out;
@ -980,7 +975,7 @@ out:
int int
ospf_opaque_new_if (struct interface *ifp) ospf_opaque_new_if (struct interface *ifp)
{ {
list funclist; struct list *funclist;
int rc = -1; int rc = -1;
funclist = ospf_opaque_wildcard_funclist; funclist = ospf_opaque_wildcard_funclist;
@ -1007,7 +1002,7 @@ out:
int int
ospf_opaque_del_if (struct interface *ifp) ospf_opaque_del_if (struct interface *ifp)
{ {
list funclist; struct list *funclist;
int rc = -1; int rc = -1;
funclist = ospf_opaque_wildcard_funclist; funclist = ospf_opaque_wildcard_funclist;
@ -1034,7 +1029,7 @@ out:
void void
ospf_opaque_ism_change (struct ospf_interface *oi, int old_status) ospf_opaque_ism_change (struct ospf_interface *oi, int old_status)
{ {
list funclist; struct list *funclist;
funclist = ospf_opaque_wildcard_funclist; funclist = ospf_opaque_wildcard_funclist;
opaque_lsa_ism_change_callback (funclist, oi, old_status); opaque_lsa_ism_change_callback (funclist, oi, old_status);
@ -1055,7 +1050,7 @@ void
ospf_opaque_nsm_change (struct ospf_neighbor *nbr, int old_state) ospf_opaque_nsm_change (struct ospf_neighbor *nbr, int old_state)
{ {
struct ospf *top; struct ospf *top;
list funclist; struct list *funclist;
if ((top = oi_to_top (nbr->oi)) == NULL) if ((top = oi_to_top (nbr->oi)) == NULL)
goto out; goto out;
@ -1107,7 +1102,7 @@ out:
void void
ospf_opaque_config_write_router (struct vty *vty, struct ospf *ospf) ospf_opaque_config_write_router (struct vty *vty, struct ospf *ospf)
{ {
list funclist; struct list *funclist;
if (CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE)) if (CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE))
vty_out (vty, " capability opaque%s", VTY_NEWLINE); vty_out (vty, " capability opaque%s", VTY_NEWLINE);
@ -1130,7 +1125,7 @@ ospf_opaque_config_write_router (struct vty *vty, struct ospf *ospf)
void void
ospf_opaque_config_write_if (struct vty *vty, struct interface *ifp) ospf_opaque_config_write_if (struct vty *vty, struct interface *ifp)
{ {
list funclist; struct list *funclist;
funclist = ospf_opaque_wildcard_funclist; funclist = ospf_opaque_wildcard_funclist;
opaque_lsa_config_write_if_callback (funclist, vty, ifp); opaque_lsa_config_write_if_callback (funclist, vty, ifp);
@ -1150,7 +1145,7 @@ ospf_opaque_config_write_if (struct vty *vty, struct interface *ifp)
void void
ospf_opaque_config_write_debug (struct vty *vty) ospf_opaque_config_write_debug (struct vty *vty)
{ {
list funclist; struct list *funclist;
funclist = ospf_opaque_wildcard_funclist; funclist = ospf_opaque_wildcard_funclist;
opaque_lsa_config_write_debug_callback (funclist, vty); opaque_lsa_config_write_debug_callback (funclist, vty);
@ -1220,7 +1215,7 @@ ospf_opaque_lsa_dump (struct stream *s, u_int16_t length)
static int static int
ospf_opaque_lsa_install_hook (struct ospf_lsa *lsa) ospf_opaque_lsa_install_hook (struct ospf_lsa *lsa)
{ {
list funclist; struct list *funclist;
int rc = -1; int rc = -1;
/* /*
@ -1251,7 +1246,7 @@ out:
static int static int
ospf_opaque_lsa_delete_hook (struct ospf_lsa *lsa) ospf_opaque_lsa_delete_hook (struct ospf_lsa *lsa)
{ {
list funclist; struct list *funclist;
int rc = -1; int rc = -1;
/* /*
@ -1286,14 +1281,14 @@ out:
static int ospf_opaque_type9_lsa_originate (struct thread *t); static int ospf_opaque_type9_lsa_originate (struct thread *t);
static int ospf_opaque_type10_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 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 void
ospf_opaque_lsa_originate_schedule (struct ospf_interface *oi, int *delay0) ospf_opaque_lsa_originate_schedule (struct ospf_interface *oi, int *delay0)
{ {
struct ospf *top; struct ospf *top;
struct ospf_area *area; struct ospf_area *area;
listnode node; struct listnode *node;
struct opaque_info_per_type *oipt; struct opaque_info_per_type *oipt;
int delay = 0; int delay = 0;
@ -1504,9 +1499,9 @@ ospf_opaque_type11_lsa_originate (struct thread *t)
} }
static void 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 opaque_info_per_type *oipt;
struct ospf_opaque_functab *functab; struct ospf_opaque_functab *functab;
@ -1517,10 +1512,9 @@ ospf_opaque_lsa_reoriginate_resume (list listtop, void *arg)
* Pickup oipt entries those which in SUSPEND status, and give * Pickup oipt entries those which in SUSPEND status, and give
* them a chance to start re-origination now. * 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 if (oipt->status != PROC_SUSPEND)
|| oipt->status != PROC_SUSPEND)
continue; continue;
oipt->status = PROC_NORMAL; oipt->status = PROC_NORMAL;
@ -1672,7 +1666,7 @@ ospf_opaque_lsa_reoriginate_schedule (void *lsa_type_dependent,
struct ospf_lsa *lsa; struct ospf_lsa *lsa;
struct opaque_info_per_type *oipt; struct opaque_info_per_type *oipt;
int (* func)(struct thread *t) = NULL; int (*func) (struct thread * t) = NULL;
int delay; int delay;
switch (lsa_type) switch (lsa_type)
@ -1680,19 +1674,23 @@ ospf_opaque_lsa_reoriginate_schedule (void *lsa_type_dependent,
case OSPF_OPAQUE_LINK_LSA: case OSPF_OPAQUE_LINK_LSA:
if ((oi = (struct ospf_interface *) lsa_type_dependent) == NULL) if ((oi = (struct ospf_interface *) lsa_type_dependent) == NULL)
{ {
zlog_warn ("ospf_opaque_lsa_reoriginate_schedule: Type-9 Opaque-LSA: Invalid parameter?"); zlog_warn ("ospf_opaque_lsa_reoriginate_schedule:"
" Type-9 Opaque-LSA: Invalid parameter?");
goto out; goto out;
} }
if ((top = oi_to_top (oi)) == NULL) 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; goto out;
} }
if (! list_isempty (ospf_opaque_type9_funclist) if (!list_isempty (ospf_opaque_type9_funclist)
&& list_isempty (oi->opaque_lsa_self) && list_isempty (oi->opaque_lsa_self)
&& oi->t_opaque_lsa_self != NULL) && 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; goto out;
} }
func = ospf_opaque_type9_lsa_reoriginate_timer; func = ospf_opaque_type9_lsa_reoriginate_timer;
@ -1700,19 +1698,23 @@ ospf_opaque_lsa_reoriginate_schedule (void *lsa_type_dependent,
case OSPF_OPAQUE_AREA_LSA: case OSPF_OPAQUE_AREA_LSA:
if ((area = (struct ospf_area *) lsa_type_dependent) == NULL) 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; goto out;
} }
if ((top = area->ospf) == NULL) 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; goto out;
} }
if (! list_isempty (ospf_opaque_type10_funclist) if (!list_isempty (ospf_opaque_type10_funclist)
&& list_isempty (area->opaque_lsa_self) && list_isempty (area->opaque_lsa_self)
&& area->t_opaque_lsa_self != NULL) && 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; goto out;
} }
func = ospf_opaque_type10_lsa_reoriginate_timer; func = ospf_opaque_type10_lsa_reoriginate_timer;
@ -1720,14 +1722,16 @@ ospf_opaque_lsa_reoriginate_schedule (void *lsa_type_dependent,
case OSPF_OPAQUE_AS_LSA: case OSPF_OPAQUE_AS_LSA:
if ((top = (struct ospf *) lsa_type_dependent) == NULL) if ((top = (struct ospf *) lsa_type_dependent) == NULL)
{ {
zlog_warn ("ospf_opaque_lsa_reoriginate_schedule: Type-11 Opaque-LSA: Invalid parameter?"); zlog_warn ("ospf_opaque_lsa_reoriginate_schedule:"
" Type-11 Opaque-LSA: Invalid parameter?");
goto out; goto out;
} }
if (! list_isempty (ospf_opaque_type11_funclist) if (!list_isempty (ospf_opaque_type11_funclist)
&& list_isempty (top->opaque_lsa_self) && list_isempty (top->opaque_lsa_self)
&& top->t_opaque_lsa_self != NULL) && 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; goto out;
} }
@ -1738,12 +1742,14 @@ ospf_opaque_lsa_reoriginate_schedule (void *lsa_type_dependent,
func = ospf_opaque_type11_lsa_reoriginate_timer; func = ospf_opaque_type11_lsa_reoriginate_timer;
break; break;
default: 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; goto out;
} }
/* It may not a right time to schedule reorigination now. */ /* 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) if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_opaque_lsa_reoriginate_schedule: Not operational."); zlog_info ("ospf_opaque_lsa_reoriginate_schedule: Not operational.");
@ -1764,12 +1770,18 @@ ospf_opaque_lsa_reoriginate_schedule (void *lsa_type_dependent,
struct ospf_opaque_functab *functab; struct ospf_opaque_functab *functab;
if ((functab = ospf_opaque_functab_lookup (lsa)) == NULL) 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; goto out;
} }
if ((oipt = register_opaque_info_per_type (functab, lsa)) == NULL) 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; goto out;
} }
} }
@ -1777,7 +1789,9 @@ ospf_opaque_lsa_reoriginate_schedule (void *lsa_type_dependent,
if (oipt->t_opaque_lsa_self != NULL) if (oipt->t_opaque_lsa_self != NULL)
{ {
if (IS_DEBUG_OSPF_EVENT) 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; goto out;
} }
@ -1791,7 +1805,10 @@ ospf_opaque_lsa_reoriginate_schedule (void *lsa_type_dependent,
delay = OSPF_MIN_LS_INTERVAL; /* XXX */ delay = OSPF_MIN_LS_INTERVAL; /* XXX */
if (IS_DEBUG_OSPF_EVENT) 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); OSPF_OPAQUE_TIMER_ON (oipt->t_opaque_lsa_self, func, oipt, delay);
@ -1869,7 +1886,7 @@ ospf_opaque_type10_lsa_reoriginate_timer (struct thread *t)
{ {
struct opaque_info_per_type *oipt; struct opaque_info_per_type *oipt;
struct ospf_opaque_functab *functab; struct ospf_opaque_functab *functab;
listnode node; struct listnode *node;
struct ospf *top; struct ospf *top;
struct ospf_area *area; struct ospf_area *area;
struct ospf_interface *oi; struct ospf_interface *oi;
@ -1894,10 +1911,8 @@ ospf_opaque_type10_lsa_reoriginate_timer (struct thread *t)
/* There must be at least one "opaque-capable, full-state" neighbor. */ /* There must be at least one "opaque-capable, full-state" neighbor. */
n = 0; 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) if ((n = ospf_nbr_count_opaque_capable (oi)) > 0)
break; break;
} }
@ -1905,7 +1920,9 @@ ospf_opaque_type10_lsa_reoriginate_timer (struct thread *t)
if (n == 0 || ! CHECK_FLAG (top->config, OSPF_OPAQUE_CAPABLE)) if (n == 0 || ! CHECK_FLAG (top->config, OSPF_OPAQUE_CAPABLE))
{ {
if (IS_DEBUG_OSPF_EVENT) 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; oipt->status = PROC_SUSPEND;
rc = 0; rc = 0;
@ -1913,7 +1930,9 @@ ospf_opaque_type10_lsa_reoriginate_timer (struct thread *t)
} }
if (IS_DEBUG_OSPF_EVENT) 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); rc = (* functab->lsa_originator)(area);
out: out:
@ -1934,7 +1953,8 @@ ospf_opaque_type11_lsa_reoriginate_timer (struct thread *t)
if ((functab = oipt->functab) == 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; goto out;
} }
@ -2116,12 +2136,12 @@ static void ospf_opaque_type11_lsa_rxmt_nbr_check (struct ospf *top);
static unsigned long ospf_opaque_nrxmt_self (struct route_table *nbrs, int lsa_type); static unsigned long ospf_opaque_nrxmt_self (struct route_table *nbrs, int lsa_type);
void 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 *top;
struct ospf_area *area; struct ospf_area *area;
struct ospf_interface *oi; struct ospf_interface *oi;
listnode node1, node2; struct listnode *node1, *node2;
struct ospf_lsa *lsa; struct ospf_lsa *lsa;
if ((top = oi_to_top (nbr->oi)) == NULL) if ((top = oi_to_top (nbr->oi)) == NULL)
@ -2228,10 +2248,11 @@ ospf_opaque_exclude_lsa_from_lsreq (struct route_table *nbrs,
} }
void 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; struct ospf *top;
listnode node, next; struct listnode *node, *next;
struct ospf_lsa *lsa; struct ospf_lsa *lsa;
u_char before; u_char before;
@ -2287,21 +2308,18 @@ out:
} }
void 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; struct ospf *top;
listnode node; struct listnode *node;
struct ospf_lsa *lsa; struct ospf_lsa *lsa;
char type9_lsa_rcv = 0, type10_lsa_rcv = 0, type11_lsa_rcv = 0; char type9_lsa_rcv = 0, type10_lsa_rcv = 0, type11_lsa_rcv = 0;
if ((top = oi_to_top (nbr->oi)) == NULL) if ((top = oi_to_top (nbr->oi)) == NULL)
goto out; goto out;
for (node = listhead (acks); node; nextnode (node)) LIST_LOOP (acks, lsa, node)
{ {
if ((lsa = getdata (node)) == NULL)
continue;
switch (lsa->data->type) switch (lsa->data->type)
{ {
case OSPF_OPAQUE_LINK_LSA: case OSPF_OPAQUE_LINK_LSA:
@ -2350,11 +2368,9 @@ ospf_opaque_ls_ack_received (struct ospf_neighbor *nbr, list acks)
/* Ok, let's start origination of Opaque-LSAs. */ /* Ok, let's start origination of Opaque-LSAs. */
delay = OSPF_MIN_LS_INTERVAL; 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) if (! ospf_if_is_enable (oi)
|| ospf_nbr_count_opaque_capable (oi) == 0) || ospf_nbr_count_opaque_capable (oi) == 0)
continue; continue;
@ -2386,7 +2402,7 @@ ospf_opaque_type9_lsa_rxmt_nbr_check (struct ospf_interface *oi)
static void static void
ospf_opaque_type10_lsa_rxmt_nbr_check (struct ospf_area *area) ospf_opaque_type10_lsa_rxmt_nbr_check (struct ospf_area *area)
{ {
listnode node; struct listnode *node;
struct ospf_interface *oi; struct ospf_interface *oi;
unsigned long n = 0; unsigned long n = 0;
@ -2418,7 +2434,7 @@ ospf_opaque_type10_lsa_rxmt_nbr_check (struct ospf_area *area)
static void static void
ospf_opaque_type11_lsa_rxmt_nbr_check (struct ospf *top) ospf_opaque_type11_lsa_rxmt_nbr_check (struct ospf *top)
{ {
listnode node; struct listnode *node;
struct ospf_interface *oi; struct ospf_interface *oi;
unsigned long n = 0; unsigned long n = 0;

View File

@ -144,9 +144,12 @@ extern void ospf_opaque_lsa_reoriginate_schedule (void *lsa_type_dependent, u_ch
extern void ospf_opaque_lsa_refresh_schedule (struct ospf_lsa *lsa); 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_lsa_flush_schedule (struct ospf_lsa *lsa);
extern void ospf_opaque_adjust_lsreq (struct ospf_neighbor *nbr, list lsas); extern void ospf_opaque_adjust_lsreq (struct ospf_neighbor *nbr,
extern void ospf_opaque_self_originated_lsa_received (struct ospf_neighbor *nbr, list lsas); struct list *lsas);
extern void ospf_opaque_ls_ack_received (struct ospf_neighbor *nbr, list acks); 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 htonf (float *src, float *dst);
extern void ntohf (float *src, float *dst); extern void ntohf (float *src, float *dst);

View File

@ -1917,7 +1917,7 @@ ospf_ls_ack (struct ip *iph, struct ospf_header *ospfh,
{ {
struct ospf_neighbor *nbr; struct ospf_neighbor *nbr;
#ifdef HAVE_OPAQUE_LSA #ifdef HAVE_OPAQUE_LSA
list opaque_acks; struct list *opaque_acks;
#endif /* HAVE_OPAQUE_LSA */ #endif /* HAVE_OPAQUE_LSA */
/* increment statistics. */ /* increment statistics. */

View File

@ -67,7 +67,7 @@ struct ospf_mpls_te
enum { disabled, enabled } status; enum { disabled, enabled } status;
/* List elements are zebra-interfaces (ifp), not ospf-interfaces (oi). */ /* List elements are zebra-interfaces (ifp), not ospf-interfaces (oi). */
list iflist; struct list *iflist;
/* Store Router-TLV in network byte order. */ /* Store Router-TLV in network byte order. */
struct te_tlv_router_addr router_addr; struct te_tlv_router_addr router_addr;
@ -252,11 +252,10 @@ out:
static struct mpls_te_link * static struct mpls_te_link *
lookup_linkparams_by_ifp (struct interface *ifp) lookup_linkparams_by_ifp (struct interface *ifp)
{ {
listnode node; struct listnode *node;
struct mpls_te_link *lp; struct mpls_te_link *lp;
for (node = listhead (OspfMplsTE.iflist); node; nextnode (node)) LIST_LOOP (OspfMplsTE.iflist, lp, node)
if ((lp = getdata (node)) != NULL)
if (lp->ifp == ifp) if (lp->ifp == ifp)
return lp; return lp;
@ -266,12 +265,11 @@ lookup_linkparams_by_ifp (struct interface *ifp)
static struct mpls_te_link * static struct mpls_te_link *
lookup_linkparams_by_instance (struct ospf_lsa *lsa) lookup_linkparams_by_instance (struct ospf_lsa *lsa)
{ {
listnode node; struct listnode *node;
struct mpls_te_link *lp; struct mpls_te_link *lp;
int key = GET_OPAQUE_ID (ntohl (lsa->data->id.s_addr)); int key = GET_OPAQUE_ID (ntohl (lsa->data->id.s_addr));
for (node = listhead (OspfMplsTE.iflist); node; nextnode (node)) LIST_LOOP (OspfMplsTE.iflist, lp, node)
if ((lp = getdata (node)) != NULL)
if (lp->instance == key) if (lp->instance == key)
return lp; return lp;
@ -284,14 +282,12 @@ ospf_mpls_te_foreach_area (
void (*func)(struct mpls_te_link *lp, enum sched_opcode), void (*func)(struct mpls_te_link *lp, enum sched_opcode),
enum sched_opcode sched_opcode) enum sched_opcode sched_opcode)
{ {
listnode node, node2; struct listnode *node, *node2;
struct mpls_te_link *lp; struct mpls_te_link *lp;
struct ospf_area *area; 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) if ((area = lp->area) == NULL)
continue; continue;
if (lp->flags & LPFLG_LOOKUP_DONE) if (lp->flags & LPFLG_LOOKUP_DONE)
@ -307,8 +303,7 @@ ospf_mpls_te_foreach_area (
lp->flags |= LPFLG_LOOKUP_DONE; lp->flags |= LPFLG_LOOKUP_DONE;
} }
for (node = listhead (OspfMplsTE.iflist); node; nextnode (node)) LIST_LOOP (OspfMplsTE.iflist, lp, node)
if ((lp = getdata (node)) != NULL)
if (lp->area != NULL) if (lp->area != NULL)
lp->flags &= ~LPFLG_LOOKUP_DONE; lp->flags &= ~LPFLG_LOOKUP_DONE;
@ -597,7 +592,7 @@ ospf_mpls_te_del_if (struct interface *ifp)
if ((lp = lookup_linkparams_by_ifp (ifp)) != NULL) if ((lp = lookup_linkparams_by_ifp (ifp)) != NULL)
{ {
list iflist = OspfMplsTE.iflist; struct list *iflist = OspfMplsTE.iflist;
/* Dequeue listnode entry from the list. */ /* Dequeue listnode entry from the list. */
listnode_delete (iflist, lp); listnode_delete (iflist, lp);
@ -970,7 +965,7 @@ static int
ospf_mpls_te_lsa_originate (void *arg) ospf_mpls_te_lsa_originate (void *arg)
{ {
struct ospf_area *area = (struct ospf_area *) arg; struct ospf_area *area = (struct ospf_area *) arg;
listnode node; struct listnode *node;
struct mpls_te_link *lp; struct mpls_te_link *lp;
int rc = -1; int rc = -1;
@ -1476,7 +1471,7 @@ DEFUN (mpls_te,
"Configure MPLS-TE parameters\n" "Configure MPLS-TE parameters\n"
"Enable the MPLS-TE functionality\n") "Enable the MPLS-TE functionality\n")
{ {
listnode node; struct listnode *node;
struct mpls_te_link *lp; struct mpls_te_link *lp;
if (OspfMplsTE.status == enabled) if (OspfMplsTE.status == enabled)
@ -1515,7 +1510,7 @@ DEFUN (no_mpls_te,
"Configure MPLS-TE parameters\n" "Configure MPLS-TE parameters\n"
"Disable the MPLS-TE functionality\n") "Disable the MPLS-TE functionality\n")
{ {
listnode node; struct listnode *node;
struct mpls_te_link *lp; struct mpls_te_link *lp;
if (OspfMplsTE.status == disabled) if (OspfMplsTE.status == disabled)
@ -1554,7 +1549,7 @@ DEFUN (mpls_te_router_addr,
if (ntohs (ra->header.type) == 0 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; struct mpls_te_link *lp;
int need_to_reoriginate = 0; int need_to_reoriginate = 0;
@ -1563,10 +1558,8 @@ DEFUN (mpls_te_router_addr,
if (OspfMplsTE.status == disabled) if (OspfMplsTE.status == disabled)
goto out; 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) if (lp->area == NULL)
continue; continue;
@ -1577,9 +1570,8 @@ DEFUN (mpls_te_router_addr,
} }
} }
for (node = listhead (OspfMplsTE.iflist); node; nextnode (node)) for (node = listhead (OspfMplsTE.iflist); node; nextnode (node))
LIST_LOOP (OspfMplsTE.iflist, lp, node)
{ {
if ((lp = getdata (node)) == NULL)
continue;
if (lp->area == NULL) if (lp->area == NULL)
continue; continue;
@ -1876,12 +1868,12 @@ DEFUN (show_mpls_te_link,
"Interface name\n") "Interface name\n")
{ {
struct interface *ifp; struct interface *ifp;
listnode node; struct listnode *node;
/* Show All Interfaces. */ /* Show All Interfaces. */
if (argc == 0) if (argc == 0)
for (node = listhead (iflist); node; nextnode (node)) LIST_LOOP (iflist, ifp, node)
show_mpls_te_link_sub (vty, node->data); show_mpls_te_link_sub (vty, ifp);
/* Interface name is specified. */ /* Interface name is specified. */
else else
{ {