Convert netinet to not use the internal <sys/queue.h> field names

but instead the access macros.  Use the FOREACH macros where appropriate.
This commit is contained in:
matt 2001-11-04 20:55:25 +00:00
parent 8fef52258f
commit da5a70805c
12 changed files with 121 additions and 139 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: fil.c,v 1.47 2001/06/02 16:17:09 thorpej Exp $ */
/* $NetBSD: fil.c,v 1.48 2001/11/04 20:55:25 matt Exp $ */
/*
* Copyright (C) 1993-2000 by Darren Reed.
@ -9,7 +9,7 @@
*/
#if !defined(lint)
#if defined(__NetBSD__)
static const char rcsid[] = "$NetBSD: fil.c,v 1.47 2001/06/02 16:17:09 thorpej Exp $";
static const char rcsid[] = "$NetBSD: fil.c,v 1.48 2001/11/04 20:55:25 matt Exp $";
#else
static const char sccsid[] = "@(#)fil.c 1.36 6/5/96 (C) 1993-2000 Darren Reed";
static const char rcsid[] = "@(#)Id: fil.c,v 2.35.2.30 2000/12/17 05:49:22 darrenr Exp";
@ -1879,7 +1879,7 @@ struct in_addr *inp;
ifa = TAILQ_FIRST(&ifp->if_addrhead);
# else
# if defined(__NetBSD__) || defined(__OpenBSD__)
ifa = ifp->if_addrlist.tqh_first;
ifa = TAILQ_FIRST(&ifp->if_addrlist);
# else
# if defined(__sgi) && defined(IFF_DRVRLOCK) /* IRIX 6 */
ifa = &((struct in_ifaddr *)ifp->in_ifaddr)->ia_ifa;
@ -1958,9 +1958,9 @@ void frsync()
# if defined(__OpenBSD__) || ((NetBSD >= 199511) && (NetBSD < 1991011)) || \
(defined(__FreeBSD_version) && (__FreeBSD_version >= 300000))
# if (NetBSD >= 199905) || defined(__OpenBSD__)
for (ifp = ifnet.tqh_first; ifp; ifp = ifp->if_list.tqe_next)
for (ifp = TAILQ_FIRST(&ifnet); ifp; ifp = TAILQ_NEXT(ifp, if_list))
# else
for (ifp = ifnet.tqh_first; ifp; ifp = ifp->if_link.tqe_next)
for (ifp = TAILQ_FIRST(&ifnet); ifp; ifp = TAILQ_NEXT(ifp, if_link))
# endif
# else
for (ifp = ifnet; ifp; ifp = ifp->if_next)

View File

@ -1,4 +1,4 @@
/* $NetBSD: in.c,v 1.69 2001/09/16 08:49:50 martin Exp $ */
/* $NetBSD: in.c,v 1.70 2001/11/04 20:55:25 matt Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@ -167,11 +167,11 @@ in_localaddr(in)
struct in_ifaddr *ia;
if (subnetsarelocal) {
for (ia = in_ifaddr.tqh_first; ia != 0; ia = ia->ia_list.tqe_next)
TAILQ_FOREACH(ia, &in_ifaddr, ia_list)
if ((in.s_addr & ia->ia_netmask) == ia->ia_net)
return (1);
} else {
for (ia = in_ifaddr.tqh_first; ia != 0; ia = ia->ia_list.tqe_next)
TAILQ_FOREACH(ia, &in_ifaddr, ia_list)
if ((in.s_addr & ia->ia_subnetmask) == ia->ia_subnet)
return (1);
}
@ -251,7 +251,7 @@ in_setmaxmtu()
struct ifnet *ifp;
unsigned long maxmtu = 0;
for (ia = in_ifaddr.tqh_first; ia != 0; ia = ia->ia_list.tqe_next) {
TAILQ_FOREACH(ia, &in_ifaddr, ia_list) {
if ((ifp = ia->ia_ifp) == 0)
continue;
if ((ifp->if_flags & (IFF_UP|IFF_LOOPBACK)) != IFF_UP)
@ -345,8 +345,9 @@ in_control(so, cmd, data, ifp, p)
case SIOCDIFADDR:
case SIOCGIFALIAS:
if (ifra->ifra_addr.sin_family == AF_INET)
for (ia = IN_IFADDR_HASH(ifra->ifra_addr.sin_addr.s_addr).lh_first;
ia != 0; ia = ia->ia_hash.le_next) {
LIST_FOREACH(ia,
&IN_IFADDR_HASH(ifra->ifra_addr.sin_addr.s_addr),
ia_hash) {
if (ia->ia_ifp == ifp &&
in_hosteq(ia->ia_addr.sin_addr,
ifra->ifra_addr.sin_addr))
@ -705,7 +706,7 @@ in_lifaddr_ioctl(so, cmd, data, ifp, p)
}
}
for (ifa = ifp->if_addrlist.tqh_first; ifa; ifa = ifa->ifa_list.tqe_next) {
TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) {
if (ifa->ifa_addr->sa_family != AF_INET6)
continue;
if (!cmp)
@ -902,7 +903,7 @@ in_addprefix(target, flags)
mask = target->ia_sockmask.sin_addr;
prefix.s_addr &= mask.s_addr;
for (ia = in_ifaddr.tqh_first; ia; ia = ia->ia_list.tqe_next) {
TAILQ_FOREACH(ia, &in_ifaddr, ia_list) {
/* easy one first */
if (mask.s_addr != ia->ia_sockmask.sin_addr.s_addr)
continue;
@ -955,7 +956,7 @@ in_scrubprefix(target)
mask = target->ia_sockmask.sin_addr;
prefix.s_addr &= mask.s_addr;
for (ia = in_ifaddr.tqh_first; ia; ia = ia->ia_list.tqe_next) {
TAILQ_FOREACH(ia, &in_ifaddr, ia_list) {
/* easy one first */
if (mask.s_addr != ia->ia_sockmask.sin_addr.s_addr)
continue;
@ -1014,7 +1015,7 @@ in_broadcast(in, ifp)
* with a broadcast address.
*/
#define ia (ifatoia(ifa))
for (ifa = ifp->if_addrlist.tqh_first; ifa; ifa = ifa->ifa_list.tqe_next)
TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list)
if (ifa->ifa_addr->sa_family == AF_INET &&
(in_hosteq(in, ia->ia_broadaddr.sin_addr) ||
in_hosteq(in, ia->ia_netbroadcast) ||
@ -1044,8 +1045,8 @@ in_savemkludge(oia)
IFP_TO_IA(oia->ia_ifp, ia);
if (ia) { /* there is another address */
for (inm = oia->ia_multiaddrs.lh_first; inm; inm = next){
next = inm->inm_list.le_next;
for (inm = LIST_FIRST(&oia->ia_multiaddrs); inm; inm = next){
next = LIST_NEXT(inm, inm_list);
IFAFREE(&inm->inm_ia->ia_ifa);
IFAREF(&ia->ia_ifa);
inm->inm_ia = ia;

View File

@ -1,4 +1,4 @@
/* $NetBSD: in_gif.c,v 1.23 2001/08/16 17:45:26 itojun Exp $ */
/* $NetBSD: in_gif.c,v 1.24 2001/11/04 20:55:26 matt Exp $ */
/* $KAME: in_gif.c,v 1.66 2001/07/29 04:46:09 itojun Exp $ */
/*
@ -328,8 +328,7 @@ gif_validate4(ip, sc, ifp)
return 0;
}
/* reject packets with broadcast on source */
for (ia4 = in_ifaddr.tqh_first; ia4; ia4 = ia4->ia_list.tqe_next)
{
TAILQ_FOREACH(ia4, &in_ifaddr, ia_list) {
if ((ia4->ia_ifa.ifa_ifp->if_flags & IFF_BROADCAST) == 0)
continue;
if (ip->ip_src.s_addr == ia4->ia_broadaddr.sin_addr.s_addr)

View File

@ -1,4 +1,4 @@
/* $NetBSD: in_pcb.c,v 1.71 2001/08/06 10:25:00 itojun Exp $ */
/* $NetBSD: in_pcb.c,v 1.72 2001/11/04 20:55:26 matt Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@ -224,7 +224,7 @@ in_pcbbind(v, nam, p)
int error;
#endif
if (in_ifaddr.tqh_first == 0)
if (TAILQ_FIRST(&in_ifaddr) == 0)
return (EADDRNOTAVAIL);
if (inp->inp_lport || !in_nullhost(inp->inp_laddr))
return (EINVAL);
@ -359,7 +359,7 @@ in_pcbconnect(v, nam)
return (EAFNOSUPPORT);
if (sin->sin_port == 0)
return (EADDRNOTAVAIL);
if (in_ifaddr.tqh_first != 0) {
if (TAILQ_FIRST(&in_ifaddr) != 0) {
/*
* If the destination address is INADDR_ANY,
* use any local address (likely loopback).
@ -368,15 +368,18 @@ in_pcbconnect(v, nam)
* which supports broadcast. (loopback does not)
*/
if (in_nullhost(sin->sin_addr))
sin->sin_addr = in_ifaddr.tqh_first->ia_addr.sin_addr;
else if (sin->sin_addr.s_addr == INADDR_BROADCAST)
for (ia = in_ifaddr.tqh_first; ia != NULL;
ia = ia->ia_list.tqe_next)
if (ia->ia_ifp->if_flags & IFF_BROADCAST) {
sin->sin_addr = ia->ia_broadaddr.sin_addr;
break;
if (in_nullhost(sin->sin_addr)) {
sin->sin_addr =
TAILQ_FIRST(&in_ifaddr)->ia_addr.sin_addr;
} else if (sin->sin_addr.s_addr == INADDR_BROADCAST) {
TAILQ_FOREACH(ia, &in_ifaddr, ia_list) {
if (ia->ia_ifp->if_flags & IFF_BROADCAST) {
sin->sin_addr =
ia->ia_broadaddr.sin_addr;
break;
}
}
}
}
/*
* If we haven't bound which network number to use as ours,
@ -434,8 +437,7 @@ in_pcbconnect(v, nam)
sin->sin_port = fport;
if (ia == 0) {
/* Find 1st non-loopback AF_INET address */
for (ia = in_ifaddr.tqh_first ; ia != NULL;
ia = ia->ia_list.tqe_next) {
TAILQ_FOREACH(ia, &in_ifaddr, ia_list) {
if ((ia->ia_ifp->if_flags &
IFF_LOOPBACK) == 0)
break;
@ -605,8 +607,8 @@ in_pcbnotify(table, faddr, fport_arg, laddr, lport_arg, errno, notify)
nmatch = 0;
head = INPCBHASH_CONNECT(table, faddr, fport, laddr, lport);
for (inp = head->lh_first; inp != NULL; inp = ninp) {
ninp = inp->inp_hash.le_next;
for (inp = LIST_FIRST(head); inp != NULL; inp = ninp) {
ninp = LIST_NEXT(inp, inp_hash);
if (in_hosteq(inp->inp_faddr, faddr) &&
inp->inp_fport == fport &&
inp->inp_lport == lport &&
@ -630,10 +632,10 @@ in_pcbnotifyall(table, faddr, errno, notify)
if (in_nullhost(faddr) || notify == 0)
return;
for (inp = table->inpt_queue.cqh_first;
inp != (struct inpcb *)&table->inpt_queue;
for (inp = CIRCLEQ_FIRST(&table->inpt_queue);
inp != (void *)&table->inpt_queue;
inp = ninp) {
ninp = inp->inp_queue.cqe_next;
ninp = CIRCLEQ_NEXT(inp, inp_queue);
if (in_hosteq(inp->inp_faddr, faddr))
(*notify)(inp, errno);
}
@ -648,10 +650,10 @@ in_pcbpurgeif0(table, ifp)
struct ip_moptions *imo;
int i, gap;
for (inp = table->inpt_queue.cqh_first;
inp != (struct inpcb *)&table->inpt_queue;
for (inp = CIRCLEQ_FIRST(&table->inpt_queue);
inp != (void *)&table->inpt_queue;
inp = ninp) {
ninp = inp->inp_queue.cqe_next;
ninp = CIRCLEQ_NEXT(inp, inp_queue);
imo = inp->inp_moptions;
if (imo != NULL) {
/*
@ -686,10 +688,10 @@ in_pcbpurgeif(table, ifp)
{
struct inpcb *inp, *ninp;
for (inp = table->inpt_queue.cqh_first;
inp != (struct inpcb *)&table->inpt_queue;
for (inp = CIRCLEQ_FIRST(&table->inpt_queue);
inp != (void *)&table->inpt_queue;
inp = ninp) {
ninp = inp->inp_queue.cqe_next;
ninp = CIRCLEQ_NEXT(inp, inp_queue);
if (inp->inp_route.ro_rt != NULL &&
inp->inp_route.ro_rt->rt_ifp == ifp)
in_rtchange(inp, 0);
@ -761,9 +763,7 @@ in_pcblookup_port(table, laddr, lport_arg, lookup_wildcard)
int matchwild = 3, wildcard;
u_int16_t lport = lport_arg;
for (inp = table->inpt_queue.cqh_first;
inp != (struct inpcb *)&table->inpt_queue;
inp = inp->inp_queue.cqe_next) {
CIRCLEQ_FOREACH(inp, &table->inpt_queue, inp_queue) {
if (inp->inp_lport != lport)
continue;
wildcard = 0;
@ -807,7 +807,7 @@ in_pcblookup_connect(table, faddr, fport_arg, laddr, lport_arg)
u_int16_t fport = fport_arg, lport = lport_arg;
head = INPCBHASH_CONNECT(table, faddr, fport, laddr, lport);
for (inp = head->lh_first; inp != NULL; inp = inp->inp_hash.le_next) {
LIST_FOREACH(inp, head, inp_hash) {
if (in_hosteq(inp->inp_faddr, faddr) &&
inp->inp_fport == fport &&
inp->inp_lport == lport &&
@ -825,7 +825,7 @@ in_pcblookup_connect(table, faddr, fport_arg, laddr, lport_arg)
out:
/* Move this PCB to the head of hash chain. */
if (inp != head->lh_first) {
if (inp != LIST_FIRST(head)) {
LIST_REMOVE(inp, inp_hash);
LIST_INSERT_HEAD(head, inp, inp_hash);
}
@ -843,13 +843,13 @@ in_pcblookup_bind(table, laddr, lport_arg)
u_int16_t lport = lport_arg;
head = INPCBHASH_BIND(table, laddr, lport);
for (inp = head->lh_first; inp != NULL; inp = inp->inp_hash.le_next) {
LIST_FOREACH(inp, head, inp_hash) {
if (inp->inp_lport == lport &&
in_hosteq(inp->inp_laddr, laddr))
goto out;
}
head = INPCBHASH_BIND(table, zeroin_addr, lport);
for (inp = head->lh_first; inp != NULL; inp = inp->inp_hash.le_next) {
LIST_FOREACH(inp, head, inp_hash) {
if (inp->inp_lport == lport &&
in_hosteq(inp->inp_laddr, zeroin_addr))
goto out;
@ -864,7 +864,7 @@ in_pcblookup_bind(table, laddr, lport_arg)
out:
/* Move this PCB to the head of hash chain. */
if (inp != head->lh_first) {
if (inp != LIST_FIRST(head)) {
LIST_REMOVE(inp, inp_hash);
LIST_INSERT_HEAD(head, inp, inp_hash);
}
@ -965,9 +965,7 @@ in_selectsrc(sin, ro, soopts, mopts, errorp)
sin->sin_port = fport;
if (ia == 0) {
/* Find 1st non-loopback AF_INET address */
for (ia = in_ifaddr.tqh_first;
ia != NULL;
ia = ia->ia_list.tqe_next) {
TAILQ_FOREACH(ia, &in_ifaddr, ia_list) {
if (!(ia->ia_ifp->if_flags & IFF_LOOPBACK))
break;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: in_var.h,v 1.42 2001/11/04 13:42:27 matt Exp $ */
/* $NetBSD: in_var.h,v 1.43 2001/11/04 20:55:27 matt Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -154,9 +154,7 @@ extern const int inetctlerrmap[];
/* struct in_addr addr; */ \
/* struct in_ifaddr *ia; */ \
{ \
for (ia = IN_IFADDR_HASH((addr).s_addr).lh_first; \
ia != NULL; \
ia = ia->ia_hash.le_next) { \
LIST_FOREACH(ia, &IN_IFADDR_HASH((addr).s_addr), ia_hash) { \
if (in_hosteq(ia->ia_addr.sin_addr, (addr)) && \
(ia->ia_ifp->if_flags & IFF_UP) != 0) \
break; \
@ -175,7 +173,7 @@ extern const int inetctlerrmap[];
struct in_addr addr; \
addr = ia->ia_addr.sin_addr; \
do { \
ia = ia->ia_hash.le_next; \
ia = LIST_NEXT(ia, ia_hash); \
} while ((ia != NULL) && !in_hosteq(ia->ia_addr.sin_addr, addr)); \
}
@ -203,10 +201,10 @@ extern const int inetctlerrmap[];
{ \
struct ifaddr *ifa; \
\
for (ifa = (ifp)->if_addrlist.tqh_first; \
ifa != NULL && ifa->ifa_addr->sa_family != AF_INET; \
ifa = ifa->ifa_list.tqe_next) \
continue; \
TAILQ_FOREACH(ifa, &(ifp)->if_addrlist, ifa_list) { \
if (ifa->ifa_addr->sa_family == AF_INET) \
break; \
} \
(ia) = ifatoia(ifa); \
}
#endif
@ -263,9 +261,9 @@ struct in_multistep {
if (ia == NULL) \
(inm) = NULL; \
else \
for ((inm) = ia->ia_multiaddrs.lh_first; \
for ((inm) = LIST_FIRST(&ia->ia_multiaddrs); \
(inm) != NULL && !in_hosteq((inm)->inm_addr, (addr)); \
(inm) = inm->inm_list.le_next) \
(inm) = LIST_NEXT((inm), inm_list)) \
continue; \
}
@ -281,13 +279,13 @@ struct in_multistep {
/* struct in_multi *inm; */ \
{ \
if (((inm) = (step).i_inm) != NULL) \
(step).i_inm = (inm)->inm_list.le_next; \
(step).i_inm = LIST_NEXT((inm), inm_list); \
else \
while ((step).i_ia != NULL) { \
(inm) = (step).i_ia->ia_multiaddrs.lh_first; \
(step).i_ia = (step).i_ia->ia_list.tqe_next; \
(inm) = LIST_FIRST(&(step).i_ia->ia_multiaddrs); \
(step).i_ia = TAILQ_NEXT((step).i_ia, ia_list); \
if ((inm) != NULL) { \
(step).i_inm = (inm)->inm_list.le_next; \
(step).i_inm = LIST_NEXT((inm), inm_list); \
break; \
} \
} \
@ -297,7 +295,7 @@ struct in_multistep {
/* struct in_multistep step; */ \
/* struct in_multi *inm; */ \
{ \
(step).i_ia = in_ifaddr.tqh_first; \
(step).i_ia = TAILQ_FIRST(&in_ifaddr); \
(step).i_inm = NULL; \
IN_NEXT_MULTI((step), (inm)); \
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ip_icmp.c,v 1.64 2001/11/04 13:38:50 matt Exp $ */
/* $NetBSD: ip_icmp.c,v 1.65 2001/11/04 20:55:27 matt Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@ -668,8 +668,7 @@ icmp_reflect(m)
/* look for packet sent to broadcast address */
if (ia == NULL && (m->m_pkthdr.rcvif->if_flags & IFF_BROADCAST)) {
for (ifa = m->m_pkthdr.rcvif->if_addrlist.tqh_first;
ifa != NULL; ifa = ifa->ifa_list.tqe_next) {
TAILQ_FOREACH(ifa, &m->m_pkthdr.rcvif->if_addrlist, ifa_list) {
if (ifa->ifa_addr->sa_family != AF_INET)
continue;
if (in_hosteq(t,ifatoia(ifa)->ia_broadaddr.sin_addr)) {
@ -722,8 +721,7 @@ icmp_reflect(m)
interface. This can happen when routing is asymmetric, or
when the incoming packet was encapsulated */
if (sin == (struct sockaddr_in *)0) {
for (ifa = m->m_pkthdr.rcvif->if_addrlist.tqh_first;
ifa != NULL; ifa = ifa->ifa_list.tqe_next) {
TAILQ_FOREACH(ifa, &m->m_pkthdr.rcvif->if_addrlist, ifa_list) {
if (ifa->ifa_addr->sa_family != AF_INET)
continue;
sin = &(ifatoia(ifa)->ia_addr);
@ -738,8 +736,7 @@ icmp_reflect(m)
* interface.
*/
if (sin == (struct sockaddr_in *)0)
for (ia = in_ifaddr.tqh_first; ia != NULL;
ia = ia->ia_list.tqe_next) {
TAILQ_FOREACH(ia, &in_ifaddr, ia_list) {
if (ia->ia_ifp->if_flags & IFF_LOOPBACK)
continue;
sin = &ia->ia_addr;

View File

@ -1,4 +1,4 @@
/* $NetBSD: ip_input.c,v 1.139 2001/11/04 13:42:27 matt Exp $ */
/* $NetBSD: ip_input.c,v 1.140 2001/11/04 20:55:27 matt Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@ -410,7 +410,7 @@ ip_input(struct mbuf *m)
* If no IP addresses have been set yet but the interfaces
* are receiving, can't do anything with incoming packets yet.
*/
if (in_ifaddr.tqh_first == 0)
if (TAILQ_FIRST(&in_ifaddr) == 0)
goto bad;
ipstat.ips_total++;
if (m->m_len < sizeof (struct ip) &&
@ -573,9 +573,7 @@ ip_input(struct mbuf *m)
* as not mine.
*/
downmatch = 0;
for (ia = IN_IFADDR_HASH(ip->ip_dst.s_addr).lh_first;
ia != NULL;
ia = ia->ia_hash.le_next) {
LIST_FOREACH(ia, &IN_IFADDR_HASH(ip->ip_dst.s_addr), ia_hash) {
if (in_hosteq(ia->ia_addr.sin_addr, ip->ip_dst)) {
if ((ia->ia_ifp->if_flags & IFF_UP) != 0)
break;
@ -586,9 +584,9 @@ ip_input(struct mbuf *m)
if (ia != NULL)
goto ours;
if (m->m_pkthdr.rcvif->if_flags & IFF_BROADCAST) {
for (ifa = m->m_pkthdr.rcvif->if_addrlist.tqh_first;
ifa != NULL; ifa = ifa->ifa_list.tqe_next) {
if (ifa->ifa_addr->sa_family != AF_INET) continue;
TAILQ_FOREACH(ifa, &m->m_pkthdr.rcvif->if_addrlist, ifa_list) {
if (ifa->ifa_addr->sa_family != AF_INET)
continue;
ia = ifatoia(ifa);
if (in_hosteq(ip->ip_dst, ia->ia_broadaddr.sin_addr) ||
in_hosteq(ip->ip_dst, ia->ia_netbroadcast) ||
@ -701,7 +699,7 @@ ours:
* of this datagram.
*/
IPQ_LOCK();
for (fp = ipq.lh_first; fp != NULL; fp = fp->ipq_q.le_next)
LIST_FOREACH(fp, &ipq, ipq_q)
if (ip->ip_id == fp->ipq_id &&
in_hosteq(ip->ip_src, fp->ipq_src) &&
in_hosteq(ip->ip_dst, fp->ipq_dst) &&
@ -857,8 +855,8 @@ ip_reass(ipqe, fp)
/*
* Find a segment which begins after this one does.
*/
for (p = NULL, q = fp->ipq_fragq.lh_first; q != NULL;
p = q, q = q->ipqe_q.le_next)
for (p = NULL, q = LIST_FIRST(&fp->ipq_fragq); q != NULL;
p = q, q = LIST_NEXT(q, ipqe_q))
if (q->ipqe_ip->ip_off > ipqe->ipqe_ip->ip_off)
break;
@ -893,7 +891,7 @@ ip_reass(ipqe, fp)
m_adj(q->ipqe_m, i);
break;
}
nq = q->ipqe_q.le_next;
nq = LIST_NEXT(q, ipqe_q);
m_freem(q->ipqe_m);
LIST_REMOVE(q, ipqe_q);
pool_put(&ipqent_pool, q);
@ -910,8 +908,8 @@ insert:
LIST_INSERT_AFTER(p, ipqe, ipqe_q);
}
next = 0;
for (p = NULL, q = fp->ipq_fragq.lh_first; q != NULL;
p = q, q = q->ipqe_q.le_next) {
for (p = NULL, q = LIST_FIRST(&fp->ipq_fragq); q != NULL;
p = q, q = LIST_NEXT(q, ipqe_q)) {
if (q->ipqe_ip->ip_off != next)
return (0);
next += q->ipqe_ip->ip_len;
@ -923,7 +921,7 @@ insert:
* Reassembly is complete. Check for a bogus message size and
* concatenate fragments.
*/
q = fp->ipq_fragq.lh_first;
q = LIST_FIRST(&fp->ipq_fragq);
ip = q->ipqe_ip;
if ((next + (ip->ip_hl << 2)) > IP_MAXPACKET) {
ipstat.ips_toolong++;
@ -934,11 +932,11 @@ insert:
t = m->m_next;
m->m_next = 0;
m_cat(m, t);
nq = q->ipqe_q.le_next;
nq = LIST_NEXT(q, ipqe_q);
pool_put(&ipqent_pool, q);
for (q = nq; q != NULL; q = nq) {
t = q->ipqe_m;
nq = q->ipqe_q.le_next;
nq = LIST_NEXT(q, ipqe_q);
pool_put(&ipqent_pool, q);
m_cat(m, t);
}
@ -985,8 +983,8 @@ ip_freef(fp)
IPQ_LOCK_CHECK();
for (q = fp->ipq_fragq.lh_first; q != NULL; q = p) {
p = q->ipqe_q.le_next;
for (q = LIST_FIRST(&fp->ipq_fragq); q != NULL; q = p) {
p = LIST_NEXT(q, ipqe_q);
m_freem(q->ipqe_m);
LIST_REMOVE(q, ipqe_q);
pool_put(&ipqent_pool, q);
@ -1008,8 +1006,8 @@ ip_slowtimo()
int s = splsoftnet();
IPQ_LOCK();
for (fp = ipq.lh_first; fp != NULL; fp = nfp) {
nfp = fp->ipq_q.le_next;
for (fp = LIST_FIRST(&ipq); fp != NULL; fp = nfp) {
nfp = LIST_NEXT(fp, ipq_q);
if (--fp->ipq_ttl == 0) {
ipstat.ips_fragtimeout++;
ip_freef(fp);
@ -1023,8 +1021,8 @@ ip_slowtimo()
if (ip_maxfragpackets < 0)
;
else {
while (ip_nfragpackets > ip_maxfragpackets && ipq.lh_first)
ip_freef(ipq.lh_first);
while (ip_nfragpackets > ip_maxfragpackets && LIST_FIRST(&ipq))
ip_freef(LIST_FIRST(&ipq));
}
IPQ_UNLOCK();
#ifdef GATEWAY
@ -1047,9 +1045,9 @@ ip_drain()
if (ipq_lock_try() == 0)
return;
while (ipq.lh_first != NULL) {
while (LIST_FIRST(&ipq) != NULL) {
ipstat.ips_fragdropped++;
ip_freef(ipq.lh_first);
ip_freef(LIST_FIRST(&ipq));
}
IPQ_UNLOCK();

View File

@ -1,4 +1,4 @@
/* $NetBSD: ip_mroute.c,v 1.56 2001/07/22 13:34:11 wiz Exp $ */
/* $NetBSD: ip_mroute.c,v 1.57 2001/11/04 20:55:28 matt Exp $ */
/*
* IP multicast forwarding procedures
@ -201,8 +201,7 @@ static int pim_assert;
struct mfc *_rt; \
(rt) = 0; \
++mrtstat.mrts_mfc_lookups; \
for (_rt = mfchashtbl[MFCHASH(o, g)].lh_first; \
_rt; _rt = _rt->mfc_hash.le_next) { \
LIST_FOREACH(_rt, &mfchashtbl[MFCHASH(o, g)], mfc_hash) { \
if (in_hosteq(_rt->mfc_origin, (o)) && \
in_hosteq(_rt->mfc_mcastgrp, (g)) && \
_rt->mfc_stall == 0) { \
@ -472,8 +471,8 @@ ip_mrouter_done()
for (i = 0; i < MFCTBLSIZ; i++) {
struct mfc *rt, *nrt;
for (rt = mfchashtbl[i].lh_first; rt; rt = nrt) {
nrt = rt->mfc_hash.le_next;
for (rt = LIST_FIRST(&mfchashtbl[i]); rt; rt = nrt) {
nrt = LIST_NEXT(rt, mfc_hash);
expire_mfc(rt);
}
@ -810,7 +809,7 @@ add_mfc(m)
*/
nstl = 0;
hash = MFCHASH(mfccp->mfcc_origin, mfccp->mfcc_mcastgrp);
for (rt = mfchashtbl[hash].lh_first; rt; rt = rt->mfc_hash.le_next) {
LIST_FOREACH(rt, &mfchashtbl[hash], mfc_hash) {
if (in_hosteq(rt->mfc_origin, mfccp->mfcc_origin) &&
in_hosteq(rt->mfc_mcastgrp, mfccp->mfcc_mcastgrp) &&
rt->mfc_stall != 0) {
@ -1108,7 +1107,7 @@ ip_mforward(m, ifp)
/* is there an upcall waiting for this packet? */
hash = MFCHASH(ip->ip_src, ip->ip_dst);
for (rt = mfchashtbl[hash].lh_first; rt; rt = rt->mfc_hash.le_next) {
LIST_FOREACH(rt, &mfchashtbl[hash], mfc_hash) {
if (in_hosteq(ip->ip_src, rt->mfc_origin) &&
in_hosteq(ip->ip_dst, rt->mfc_mcastgrp) &&
rt->mfc_stall != 0)
@ -1225,8 +1224,8 @@ expire_upcalls(v)
if (nexpire[i] == 0)
continue;
for (rt = mfchashtbl[i].lh_first; rt; rt = nrt) {
nrt = rt->mfc_hash.le_next;
for (rt = LIST_FIRST(&mfchashtbl[i]); rt; rt = nrt) {
nrt = LIST_NEXT(rt, mfc_hash);
if (rt->mfc_expire == 0 ||
--rt->mfc_expire > 0)

View File

@ -1,4 +1,4 @@
/* $NetBSD: raw_ip.c,v 1.57 2001/07/25 23:28:02 itojun Exp $ */
/* $NetBSD: raw_ip.c,v 1.58 2001/11/04 20:55:28 matt Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@ -162,9 +162,7 @@ rip_input(m, va_alist)
*/
ip->ip_len -= ip->ip_hl << 2;
for (inp = rawcbtable.inpt_queue.cqh_first;
inp != (struct inpcb *)&rawcbtable.inpt_queue;
inp = inp->inp_queue.cqe_next) {
CIRCLEQ_FOREACH(inp, &rawcbtable.inpt_queue, inp_queue) {
if (inp->inp_ip.ip_p && inp->inp_ip.ip_p != proto)
continue;
if (!in_nullhost(inp->inp_laddr) &&
@ -389,7 +387,7 @@ rip_bind(inp, nam)
if (nam->m_len != sizeof(*addr))
return (EINVAL);
if (ifnet.tqh_first == 0)
if (TAILQ_FIRST(&ifnet) == 0)
return (EADDRNOTAVAIL);
if (addr->sin_family != AF_INET &&
addr->sin_family != AF_IMPLINK)
@ -410,7 +408,7 @@ rip_connect(inp, nam)
if (nam->m_len != sizeof(*addr))
return (EINVAL);
if (ifnet.tqh_first == 0)
if (TAILQ_FIRST(&ifnet) == 0)
return (EADDRNOTAVAIL);
if (addr->sin_family != AF_INET &&
addr->sin_family != AF_IMPLINK)

View File

@ -1,4 +1,4 @@
/* $NetBSD: tcp_input.c,v 1.131 2001/09/17 17:27:00 thorpej Exp $ */
/* $NetBSD: tcp_input.c,v 1.132 2001/11/04 20:55:28 matt Exp $ */
/*
%%% portions-copyright-nrl-95
@ -304,8 +304,8 @@ tcp_reass(tp, th, m, tlen)
/*
* Find a segment which begins after this one does.
*/
for (p = NULL, q = tp->segq.lh_first; q != NULL; q = nq) {
nq = q->ipqe_q.le_next;
for (p = NULL, q = LIST_FIRST(&tp->segq); q != NULL; q = nq) {
nq = LIST_NEXT(q, ipqe_q);
/*
* If the received segment is just right after this
* fragment, merge the two together and then check
@ -510,7 +510,7 @@ present:
*/
if (TCPS_HAVEESTABLISHED(tp->t_state) == 0)
return (0);
q = tp->segq.lh_first;
q = LIST_FIRST(&tp->segq);
if (q == NULL || q->ipqe_seq != tp->rcv_nxt)
return (0);
if (tp->t_state == TCPS_SYN_RECEIVED && q->ipqe_len)
@ -1348,7 +1348,7 @@ after_listen:
return;
}
} else if (th->th_ack == tp->snd_una &&
tp->segq.lh_first == NULL &&
LIST_FIRST(&tp->segq) == NULL &&
tlen <= sbspace(&so->so_rcv)) {
/*
* this is a pure, in-sequence data packet
@ -2075,7 +2075,7 @@ dodata: /* XXX */
/* NOTE: this was TCP_REASS() macro, but used only once */
TCP_REASS_LOCK(tp);
if (th->th_seq == tp->rcv_nxt &&
tp->segq.lh_first == NULL &&
LIST_FIRST(&tp->segq) == NULL &&
tp->t_state == TCPS_ESTABLISHED) {
TCP_SETUP_ACK(tp, th);
tp->rcv_nxt += tlen;

View File

@ -1,4 +1,4 @@
/* $NetBSD: tcp_subr.c,v 1.120 2001/11/04 13:42:27 matt Exp $ */
/* $NetBSD: tcp_subr.c,v 1.121 2001/11/04 20:55:29 matt Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@ -1057,7 +1057,7 @@ tcp_freeq(tp)
TCP_REASS_LOCK_CHECK(tp);
while ((qe = tp->segq.lh_first) != NULL) {
while ((qe = LIST_FIRST(&tp->segq)) != NULL) {
#ifdef TCPREASS_DEBUG
printf("tcp_freeq[%p,%d]: %u:%u(%u) 0x%02x\n",
tp, i++, qe->ipqe_seq, qe->ipqe_seq + qe->ipqe_len,
@ -1084,10 +1084,9 @@ tcp_drain()
/*
* Free the sequence queue of all TCP connections.
*/
inp = tcbtable.inpt_queue.cqh_first;
inp = CIRCLEQ_FIRST(&tcbtable.inpt_queue);
if (inp) /* XXX */
for (; inp != (struct inpcb *)&tcbtable.inpt_queue;
inp = inp->inp_queue.cqe_next) {
CIRCLEQ_FOREACH(inp, &tcbtable.inpt_queue, inp_queue) {
if ((tp = intotcpcb(inp)) != NULL) {
/*
* We may be called from a device's interrupt

View File

@ -1,4 +1,4 @@
/* $NetBSD: udp_usrreq.c,v 1.88 2001/11/02 02:37:50 itojun Exp $ */
/* $NetBSD: udp_usrreq.c,v 1.89 2001/11/04 20:55:29 matt Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@ -635,9 +635,7 @@ udp4_realinput(src, dst, m, off)
/*
* Locate pcb(s) for datagram.
*/
for (inp = udbtable.inpt_queue.cqh_first;
inp != (struct inpcb *)&udbtable.inpt_queue;
inp = inp->inp_queue.cqe_next) {
CIRCLEQ_FOREACH(inp, &udbtable.inpt_queue, inp_queue) {
if (inp->inp_lport != *dport)
continue;
if (!in_nullhost(inp->inp_laddr)) {
@ -701,12 +699,9 @@ in6_mcmatch(in6p, ia6, ifp)
if (im6o == NULL)
return 0;
for (imm = im6o->im6o_memberships.lh_first; imm != NULL;
imm = imm->i6mm_chain.le_next) {
if ((ifp == NULL ||
imm->i6mm_maddr->in6m_ifp == ifp) &&
IN6_ARE_ADDR_EQUAL(&imm->i6mm_maddr->in6m_addr,
ia6))
LIST_FOREACH(imm, &im6o->im6o_memberships, i6mm_chain) {
if ((ifp == NULL || imm->i6mm_maddr->in6m_ifp == ifp) &&
IN6_ARE_ADDR_EQUAL(&imm->i6mm_maddr->in6m_addr, ia6))
return 1;
}
return 0;