* daemon supports multiple applications concurrently. */
/* List of all active connections. */
-list apiserver_list;
+struct list *apiserver_list;
/* -----------------------------------------------------------
* Functions to lookup interfaces
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;
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;
}
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);
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);
void
ospf_apiserver_free (struct ospf_apiserver *apiserv)
{
- listnode node;
+ struct listnode *node;
/* Cancel read and write threads. */
if (apiserv->t_sync_read)
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;
}
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 */
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;
}
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)
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)
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 */
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 ();
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 };
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;
struct route_node *rn;
struct ospf_lsa *lsa;
struct ospf *ospf;
+ struct ospf_area *area;
ospf = ospf_lookup ();
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)
{
/* 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;
}
{
/* 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;
}
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);
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)
break;
}
return;
-#endif /* ORIGINAL_CODING */
}
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)
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
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)
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,
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);
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,
/* Cannot allocate new message. What should we do? */
ospf_apiserver_free (apiserv);
#endif
- goto out;
+ goto out;
}
ospf_apiserver_send_msg (apiserv, msg);
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);
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,
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 };
}
/* 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;
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)
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;
static void
ospf_opaque_funclist_term (void)
{
- list funclist;
+ struct list *funclist;
funclist = ospf_opaque_wildcard_funclist;
list_delete (funclist);
return;
}
-static list
+static struct list *
ospf_get_opaque_funclist (u_char lsa_type)
{
- list funclist = NULL;
+ struct list *funclist = NULL;
switch (lsa_type)
{
return funclist;
}
+/* XXX: such a huge argument list can /not/ be healthy... */
int
ospf_register_opaque_functab (
u_char lsa_type,
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;
}
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)
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;
}
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. */
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))
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));
}
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;
}
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;
}
*------------------------------------------------------------------------*/
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;
int
ospf_opaque_new_if (struct interface *ifp)
{
- list funclist;
+ struct list *funclist;
int rc = -1;
funclist = ospf_opaque_wildcard_funclist;
int
ospf_opaque_del_if (struct interface *ifp)
{
- list funclist;
+ struct list *funclist;
int rc = -1;
funclist = ospf_opaque_wildcard_funclist;
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);
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;
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);
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);
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);
static int
ospf_opaque_lsa_install_hook (struct ospf_lsa *lsa)
{
- list funclist;
+ struct list *funclist;
int rc = -1;
/*
static int
ospf_opaque_lsa_delete_hook (struct ospf_lsa *lsa)
{
- list funclist;
+ struct list *funclist;
int rc = -1;
/*
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;
}
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;
* 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)
/* 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);
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
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)
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;
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;
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;
}
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. */
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;
}
}
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;
}
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);
{
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;
/* 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;
}
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;
}
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:
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;
}
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)
}
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;
}
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:
/* 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);
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;
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;