* irdp_{interface,main}.c: lists typedef removal cleanup.
update some list loops to LIST_LOOP. some miscellaneous style
and indent fixups.
(no_ip_irdp_address_preference_cmd) Fix delete of referenced node
in loop.
* irdp_packet.c: (irdp_recvmsg) Fix buggy assignment of integer
to pointer.
* if_ioctl{,_solaris}.c: lists typedef removal cleanup.
update some list loops to LIST_LOOP.
+2004-09-24 Paul Jakma <paul@dishone.st>
+
+ * irdp_{interface,main}.c: lists typedef removal cleanup.
+ update some list loops to LIST_LOOP. some miscellaneous style
+ and indent fixups.
+ (no_ip_irdp_address_preference_cmd) Fix delete of referenced node
+ in loop.
+ * irdp_packet.c: (irdp_recvmsg) Fix buggy assignment of integer
+ to pointer.
+ * if_ioctl{,_solaris}.c: lists typedef removal cleanup.
+ update some list loops to LIST_LOOP.
+
2004-09-23 Hasso Tepper <hasso at quagga.net>
* *.[c|h]: list -> struct list *, listnode -> struct listnode *.
static void
interface_info_ioctl ()
{
- listnode node;
+ struct listnode *node;
struct interface *ifp;
- for (node = listhead (iflist); node; node = nextnode (node))
+ LIST_LOOP (iflist, ifp, node)
{
ifp = getdata (node);
if_lookup_linklocal (struct interface *ifp)
{
#ifdef HAVE_IPV6
- listnode node;
+ struct listnode *node;
struct connected *ifc;
if (ifp == NULL)
return NULL;
- for (node = listhead (ifp->connected); node; node = nextnode (node))
+ LIST_LOOP (ifp->connected, ifc, node)
{
- ifc = getdata (node);
-
if ((ifc->address->family == AF_INET6) &&
(IN6_IS_ADDR_LINKLOCAL (&ifc->address->u.prefix6)))
return ifc;
struct prefix *irdp_get_prefix(struct interface *ifp)
{
- listnode node;
+ struct listnode *node;
struct connected *ifc;
- if(ifp->connected)
- for (node = listhead (ifp->connected); node; nextnode (node)) {
- ifc = getdata (node);
+ if (ifp->connected)
+ LIST_LOOP (ifp->connected, ifc, node)
return ifc->address;
- }
+
return NULL;
}
struct interface *get_iflist_ifp(int idx)
{
- listnode node;
+ struct listnode *node;
struct interface *ifp;
- for (node = listhead (iflist); node; nextnode (node)) {
- ifp = getdata (node);
- if(ifp->ifindex == idx) return ifp;
- }
+ LIST_LOOP (iflist, ifp, node)
+ if(ifp->ifindex == idx)
+ return ifp;
+
return NULL;
}
{
struct zebra_if *zi= ifp->info;
struct irdp_interface *irdp = &zi->irdp;
- listnode node;
+ struct listnode *node;
+ struct connected *ifc;
u_int32_t timer, seed;
if (irdp->flags & IF_ACTIVE ) {
/* The spec suggests this for randomness */
seed = 0;
- if( ifp->connected)
- for (node = listhead (ifp->connected); node; nextnode (node))
- {
- struct connected *ifc = getdata (node);
- seed = ifc->address->u.prefix4.s_addr;
- }
+ if( ifp->connected)
+ LIST_LOOP (ifp->connected, ifc, node)
+ {
+ seed = ifc->address->u.prefix4.s_addr;
+ break;
+ }
srandom(seed);
timer = (random () % IRDP_DEFAULT_INTERVAL) + 1;
struct zebra_if *zi=ifp->info;
struct irdp_interface *irdp=&zi->irdp;
struct Adv *adv;
- listnode node;
+ struct listnode *node;
if(irdp->flags & IF_ACTIVE || irdp->flags & IF_SHUTDOWN) {
vty_out (vty, " ip irdp preference %ld%s",
irdp->Preference, VTY_NEWLINE);
- for (node = listhead (irdp->AdvPrefList); node; nextnode (node)) {
- adv = getdata (node);
- vty_out (vty, " ip irdp address %s preference %d%s",
- inet_2a(adv->ip.s_addr, b1),
- adv->pref,
- VTY_NEWLINE);
-
- }
+ LIST_LOOP (irdp->AdvPrefList, adv, node)
+ vty_out (vty, " ip irdp address %s preference %d%s",
+ inet_2a(adv->ip.s_addr, b1),
+ adv->pref,
+ VTY_NEWLINE);
vty_out (vty, " ip irdp holdtime %d%s",
irdp->Lifetime, VTY_NEWLINE);
"Set IRDP address for advertise\n"
"Preference level\n")
{
- listnode node;
+ struct listnode *node;
struct in_addr ip;
int pref;
int ret;
pref = atoi(argv[1]);
- for (node = listhead (irdp->AdvPrefList); node; nextnode (node)) {
- adv = getdata (node);
- if(adv->ip.s_addr == ip.s_addr) return CMD_SUCCESS;
- }
+ LIST_LOOP (irdp->AdvPrefList, adv, node)
+ if(adv->ip.s_addr == ip.s_addr)
+ return CMD_SUCCESS;
adv = Adv_new();
adv->ip = ip;
"Select IRDP address\n"
"Old preference level\n")
{
- listnode node;
+ struct listnode *node;
struct in_addr ip;
int pref;
int ret;
irdp=&zi->irdp;
ret = inet_aton(argv[0], &ip);
- if(!ret) return CMD_WARNING;
+ if (!ret)
+ return CMD_WARNING;
pref = atoi(argv[1]);
- for (node = listhead (irdp->AdvPrefList); node; nextnode (node)) {
- adv = getdata (node);
- if(adv->ip.s_addr == ip.s_addr ) {
- listnode_delete(irdp->AdvPrefList, adv);
- break;
- }
- }
-
+ for (node = listhead (irdp->AdvPrefList); node; node = nnode)
+ {
+ nnode = node->next;
+ adv = getdata (node);
+
+ if(adv->ip.s_addr == ip.s_addr )
+ {
+ listnode_delete(irdp->AdvPrefList, adv);
+ break;
+ }
+ }
+
return CMD_SUCCESS;
-
-
}
DEFUN (ip_irdp_debug_messages,
int get_pref(struct irdp_interface *irdp, struct prefix *p)
{
- listnode node;
+ struct listnode *node;
struct Adv *adv;
/* Use default preference or use the override pref */
- if( irdp->AdvPrefList == NULL ) return irdp->Preference;
+ if( irdp->AdvPrefList == NULL )
+ return irdp->Preference;
- for (node = listhead (irdp->AdvPrefList); node; nextnode (node)) {
- adv = getdata (node);
+ LIST_LOOP (irdp->AdvPrefList, adv, node)
if( p->u.prefix4.s_addr == adv->ip.s_addr )
return adv->pref;
- }
+
return irdp->Preference;
}
struct zebra_if *zi=ifp->info;
struct irdp_interface *irdp=&zi->irdp;
struct prefix *p;
- listnode node;
+ struct listnode *node;
struct connected *ifc;
irdp->flags &= ~IF_SOLICIT;
if(ifp->connected)
- for (node = listhead (ifp->connected); node; nextnode (node)) {
- ifc = getdata (node);
-
- p = ifc->address;
-
- irdp_advertisement(ifp, p);
- irdp->irdp_sent++;
-
- }
+ LIST_LOOP (ifp->connected, ifc, node)
+ {
+ p = ifc->address;
+ irdp_advertisement(ifp, p);
+ irdp->irdp_sent++;
+ }
tmp = irdp->MaxAdvertInterval-irdp->MinAdvertInterval;
timer = (random () % tmp ) + 1;
{
struct zebra_if *zi=ifp->info;
struct irdp_interface *irdp=&zi->irdp;
- listnode node;
+ struct listnode *node;
int i;
struct connected *ifc;
struct prefix *p;
irdp->t_advertise = NULL;
if(ifp->connected)
- for (node = listhead (ifp->connected); node; nextnode (node)) {
- ifc = getdata (node);
-
- p = ifc->address;
-
- /* Output some packets with Lifetime 0
- we should add a wait...
- */
-
- for(i=0; i< IRDP_LAST_ADVERT_MESSAGES; i++) {
-
- irdp->irdp_sent++;
- irdp_advertisement(ifp, p);
+ LIST_LOOP (ifp->connected, ifc, node)
+ {
+ p = ifc->address;
+
+ /* Output some packets with Lifetime 0
+ we should add a wait...
+ */
+
+ for(i=0; i< IRDP_LAST_ADVERT_MESSAGES; i++)
+ {
+ irdp->irdp_sent++;
+ irdp_advertisement(ifp, p);
+ }
}
- }
}
void irdp_finish()
{
- listnode node;
+ struct listnode *node;
struct interface *ifp;
struct zebra_if *zi;
struct irdp_interface *irdp;
for (node = listhead (iflist); node; node = nextnode (node))
{
ifp = getdata(node);
- zi= ifp->info;
- if(! zi) continue;
+ zi = ifp->info;
+
+ if (!zi)
+ continue;
irdp = &zi->irdp;
- if(!irdp) continue;
-
- if(irdp->flags & IF_ACTIVE ) {
- irdp->flags |= IF_SHUTDOWN;
- irdp_advert_off(ifp);
- }
+ if (!irdp)
+ continue;
+
+ if (irdp->flags & IF_ACTIVE )
+ {
+ irdp->flags |= IF_SHUTDOWN;
+ irdp_advert_off(ifp);
+ }
}
}
irdp_if_init ();
}
-
-
#endif /* HAVE_IRDP */
}
}
\f
-int irdp_recvmsg (int sock,
- u_char *buf,
- int size,
- int *ifindex)
+int irdp_recvmsg (int sock, u_char *buf, int size, int *ifindex)
{
struct msghdr msg;
struct iovec iov;
return ret;
}
- ifindex = getsockopt_ifindex (AF_INET, &msg);
+ *ifindex = getsockopt_ifindex (AF_INET, &msg);
return ret;
}