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.
This commit is contained in:
paul 2004-09-24 08:24:42 +00:00
parent 1603c06ba3
commit 0c0f9112e1
6 changed files with 96 additions and 92 deletions

View File

@ -1,3 +1,15 @@
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> 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

@ -405,10 +405,10 @@ if_get_addr (struct interface *ifp)
static void static void
interface_info_ioctl () interface_info_ioctl ()
{ {
listnode node; struct listnode *node;
struct interface *ifp; struct interface *ifp;
for (node = listhead (iflist); node; node = nextnode (node)) LIST_LOOP (iflist, ifp, node)
{ {
ifp = getdata (node); ifp = getdata (node);

View File

@ -334,16 +334,14 @@ struct connected *
if_lookup_linklocal (struct interface *ifp) if_lookup_linklocal (struct interface *ifp)
{ {
#ifdef HAVE_IPV6 #ifdef HAVE_IPV6
listnode node; struct listnode *node;
struct connected *ifc; struct connected *ifc;
if (ifp == NULL) if (ifp == NULL)
return 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) && if ((ifc->address->family == AF_INET6) &&
(IN6_IS_ADDR_LINKLOCAL (&ifc->address->u.prefix6))) (IN6_IS_ADDR_LINKLOCAL (&ifc->address->u.prefix6)))
return ifc; return ifc;

View File

@ -76,14 +76,13 @@ char b1[16], b2[16], b3[16], b4[16]; /* For inet_2a */
struct prefix *irdp_get_prefix(struct interface *ifp) struct prefix *irdp_get_prefix(struct interface *ifp)
{ {
listnode node; struct listnode *node;
struct connected *ifc; struct connected *ifc;
if(ifp->connected) if (ifp->connected)
for (node = listhead (ifp->connected); node; nextnode (node)) { LIST_LOOP (ifp->connected, ifc, node)
ifc = getdata (node);
return ifc->address; return ifc->address;
}
return NULL; return NULL;
} }
@ -158,13 +157,13 @@ int if_drop_group (struct interface *ifp)
struct interface *get_iflist_ifp(int idx) struct interface *get_iflist_ifp(int idx)
{ {
listnode node; struct listnode *node;
struct interface *ifp; struct interface *ifp;
for (node = listhead (iflist); node; nextnode (node)) { LIST_LOOP (iflist, ifp, node)
ifp = getdata (node); if(ifp->ifindex == idx)
if(ifp->ifindex == idx) return ifp; return ifp;
}
return NULL; return NULL;
} }
@ -198,7 +197,8 @@ void irdp_if_start(struct interface *ifp, int multicast, int set_defaults)
{ {
struct zebra_if *zi= ifp->info; struct zebra_if *zi= ifp->info;
struct irdp_interface *irdp = &zi->irdp; struct irdp_interface *irdp = &zi->irdp;
listnode node; struct listnode *node;
struct connected *ifc;
u_int32_t timer, seed; u_int32_t timer, seed;
if (irdp->flags & IF_ACTIVE ) { if (irdp->flags & IF_ACTIVE ) {
@ -234,12 +234,12 @@ void irdp_if_start(struct interface *ifp, int multicast, int set_defaults)
/* The spec suggests this for randomness */ /* The spec suggests this for randomness */
seed = 0; seed = 0;
if( ifp->connected) if( ifp->connected)
for (node = listhead (ifp->connected); node; nextnode (node)) LIST_LOOP (ifp->connected, ifc, node)
{ {
struct connected *ifc = getdata (node); seed = ifc->address->u.prefix4.s_addr;
seed = ifc->address->u.prefix4.s_addr; break;
} }
srandom(seed); srandom(seed);
timer = (random () % IRDP_DEFAULT_INTERVAL) + 1; timer = (random () % IRDP_DEFAULT_INTERVAL) + 1;
@ -337,7 +337,7 @@ void irdp_config_write (struct vty *vty, struct interface *ifp)
struct zebra_if *zi=ifp->info; struct zebra_if *zi=ifp->info;
struct irdp_interface *irdp=&zi->irdp; struct irdp_interface *irdp=&zi->irdp;
struct Adv *adv; struct Adv *adv;
listnode node; struct listnode *node;
if(irdp->flags & IF_ACTIVE || irdp->flags & IF_SHUTDOWN) { if(irdp->flags & IF_ACTIVE || irdp->flags & IF_SHUTDOWN) {
@ -352,14 +352,11 @@ void irdp_config_write (struct vty *vty, struct interface *ifp)
vty_out (vty, " ip irdp preference %ld%s", vty_out (vty, " ip irdp preference %ld%s",
irdp->Preference, VTY_NEWLINE); irdp->Preference, VTY_NEWLINE);
for (node = listhead (irdp->AdvPrefList); node; nextnode (node)) { LIST_LOOP (irdp->AdvPrefList, adv, node)
adv = getdata (node); vty_out (vty, " ip irdp address %s preference %d%s",
vty_out (vty, " ip irdp address %s preference %d%s", inet_2a(adv->ip.s_addr, b1),
inet_2a(adv->ip.s_addr, b1), adv->pref,
adv->pref, VTY_NEWLINE);
VTY_NEWLINE);
}
vty_out (vty, " ip irdp holdtime %d%s", vty_out (vty, " ip irdp holdtime %d%s",
irdp->Lifetime, VTY_NEWLINE); irdp->Lifetime, VTY_NEWLINE);
@ -591,7 +588,7 @@ DEFUN (ip_irdp_address_preference,
"Set IRDP address for advertise\n" "Set IRDP address for advertise\n"
"Preference level\n") "Preference level\n")
{ {
listnode node; struct listnode *node;
struct in_addr ip; struct in_addr ip;
int pref; int pref;
int ret; int ret;
@ -613,10 +610,9 @@ DEFUN (ip_irdp_address_preference,
pref = atoi(argv[1]); pref = atoi(argv[1]);
for (node = listhead (irdp->AdvPrefList); node; nextnode (node)) { LIST_LOOP (irdp->AdvPrefList, adv, node)
adv = getdata (node); if(adv->ip.s_addr == ip.s_addr)
if(adv->ip.s_addr == ip.s_addr) return CMD_SUCCESS; return CMD_SUCCESS;
}
adv = Adv_new(); adv = Adv_new();
adv->ip = ip; adv->ip = ip;
@ -637,7 +633,7 @@ DEFUN (no_ip_irdp_address_preference,
"Select IRDP address\n" "Select IRDP address\n"
"Old preference level\n") "Old preference level\n")
{ {
listnode node; struct listnode *node;
struct in_addr ip; struct in_addr ip;
int pref; int pref;
int ret; int ret;
@ -655,21 +651,24 @@ DEFUN (no_ip_irdp_address_preference,
irdp=&zi->irdp; irdp=&zi->irdp;
ret = inet_aton(argv[0], &ip); ret = inet_aton(argv[0], &ip);
if(!ret) return CMD_WARNING; if (!ret)
return CMD_WARNING;
pref = atoi(argv[1]); pref = atoi(argv[1]);
for (node = listhead (irdp->AdvPrefList); node; nextnode (node)) { for (node = listhead (irdp->AdvPrefList); node; node = nnode)
adv = getdata (node); {
if(adv->ip.s_addr == ip.s_addr ) { nnode = node->next;
listnode_delete(irdp->AdvPrefList, adv); adv = getdata (node);
break;
} if(adv->ip.s_addr == ip.s_addr )
} {
listnode_delete(irdp->AdvPrefList, adv);
break;
}
}
return CMD_SUCCESS; return CMD_SUCCESS;
} }
DEFUN (ip_irdp_debug_messages, DEFUN (ip_irdp_debug_messages,

View File

@ -138,18 +138,18 @@ irdp_sock_init (void)
int get_pref(struct irdp_interface *irdp, struct prefix *p) int get_pref(struct irdp_interface *irdp, struct prefix *p)
{ {
listnode node; struct listnode *node;
struct Adv *adv; struct Adv *adv;
/* Use default preference or use the override pref */ /* 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)) { LIST_LOOP (irdp->AdvPrefList, adv, node)
adv = getdata (node);
if( p->u.prefix4.s_addr == adv->ip.s_addr ) if( p->u.prefix4.s_addr == adv->ip.s_addr )
return adv->pref; return adv->pref;
}
return irdp->Preference; return irdp->Preference;
} }
@ -231,21 +231,18 @@ int irdp_send_thread(struct thread *t_advert)
struct zebra_if *zi=ifp->info; struct zebra_if *zi=ifp->info;
struct irdp_interface *irdp=&zi->irdp; struct irdp_interface *irdp=&zi->irdp;
struct prefix *p; struct prefix *p;
listnode node; struct listnode *node;
struct connected *ifc; struct connected *ifc;
irdp->flags &= ~IF_SOLICIT; irdp->flags &= ~IF_SOLICIT;
if(ifp->connected) if(ifp->connected)
for (node = listhead (ifp->connected); node; nextnode (node)) { LIST_LOOP (ifp->connected, ifc, node)
ifc = getdata (node); {
p = ifc->address;
p = ifc->address; irdp_advertisement(ifp, p);
irdp->irdp_sent++;
irdp_advertisement(ifp, p); }
irdp->irdp_sent++;
}
tmp = irdp->MaxAdvertInterval-irdp->MinAdvertInterval; tmp = irdp->MaxAdvertInterval-irdp->MinAdvertInterval;
timer = (random () % tmp ) + 1; timer = (random () % tmp ) + 1;
@ -266,7 +263,7 @@ void irdp_advert_off(struct interface *ifp)
{ {
struct zebra_if *zi=ifp->info; struct zebra_if *zi=ifp->info;
struct irdp_interface *irdp=&zi->irdp; struct irdp_interface *irdp=&zi->irdp;
listnode node; struct listnode *node;
int i; int i;
struct connected *ifc; struct connected *ifc;
struct prefix *p; struct prefix *p;
@ -275,21 +272,20 @@ void irdp_advert_off(struct interface *ifp)
irdp->t_advertise = NULL; irdp->t_advertise = NULL;
if(ifp->connected) if(ifp->connected)
for (node = listhead (ifp->connected); node; nextnode (node)) { LIST_LOOP (ifp->connected, ifc, node)
ifc = getdata (node); {
p = ifc->address;
p = ifc->address; /* Output some packets with Lifetime 0
we should add a wait...
*/
/* Output some packets with Lifetime 0 for(i=0; i< IRDP_LAST_ADVERT_MESSAGES; i++)
we should add a wait... {
*/ irdp->irdp_sent++;
irdp_advertisement(ifp, p);
for(i=0; i< IRDP_LAST_ADVERT_MESSAGES; i++) { }
irdp->irdp_sent++;
irdp_advertisement(ifp, p);
} }
}
} }
@ -320,7 +316,7 @@ void process_solicit (struct interface *ifp)
void irdp_finish() void irdp_finish()
{ {
listnode node; struct listnode *node;
struct interface *ifp; struct interface *ifp;
struct zebra_if *zi; struct zebra_if *zi;
struct irdp_interface *irdp; struct irdp_interface *irdp;
@ -330,15 +326,19 @@ void irdp_finish()
for (node = listhead (iflist); node; node = nextnode (node)) for (node = listhead (iflist); node; node = nextnode (node))
{ {
ifp = getdata(node); ifp = getdata(node);
zi= ifp->info; zi = ifp->info;
if(! zi) continue;
if (!zi)
continue;
irdp = &zi->irdp; irdp = &zi->irdp;
if(!irdp) continue; if (!irdp)
continue;
if(irdp->flags & IF_ACTIVE ) { if (irdp->flags & IF_ACTIVE )
irdp->flags |= IF_SHUTDOWN; {
irdp_advert_off(ifp); irdp->flags |= IF_SHUTDOWN;
} irdp_advert_off(ifp);
}
} }
} }
@ -348,8 +348,6 @@ void irdp_init()
irdp_if_init (); irdp_if_init ();
} }
#endif /* HAVE_IRDP */ #endif /* HAVE_IRDP */

View File

@ -178,10 +178,7 @@ void parse_irdp_packet(char *p,
} }
} }
int irdp_recvmsg (int sock, int irdp_recvmsg (int sock, u_char *buf, int size, int *ifindex)
u_char *buf,
int size,
int *ifindex)
{ {
struct msghdr msg; struct msghdr msg;
struct iovec iov; struct iovec iov;
@ -214,7 +211,7 @@ int irdp_recvmsg (int sock,
return ret; return ret;
} }
ifindex = getsockopt_ifindex (AF_INET, &msg); *ifindex = getsockopt_ifindex (AF_INET, &msg);
return ret; return ret;
} }