Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/net Switch to using queue access macros instead of refer...



details:   https://anonhg.NetBSD.org/src/rev/b01b21ce3451
branches:  trunk
changeset: 517038:b01b21ce3451
user:      matt <matt%NetBSD.org@localhost>
date:      Mon Nov 05 18:02:15 2001 +0000

description:
Switch to using queue access macros instead of refering to the member
fields explicitly.

diffstat:

 sys/net/if.c          |   8 ++++----
 sys/net/if_ether.h    |  10 +++++-----
 sys/net/if_spppsubr.c |  22 +++++++++-------------
 sys/net/if_stf.c      |  12 +++++-------
 sys/net/if_tun.c      |   8 +++-----
 sys/net/raw_usrreq.c  |   4 ++--
 sys/net/route.c       |   4 ++--
 sys/net/rtsock.c      |  14 +++++++-------
 8 files changed, 37 insertions(+), 45 deletions(-)

diffs (298 lines):

diff -r 2591bf7236a3 -r b01b21ce3451 sys/net/if.c
--- a/sys/net/if.c      Mon Nov 05 17:51:56 2001 +0000
+++ b/sys/net/if.c      Mon Nov 05 18:02:15 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if.c,v 1.97 2001/09/17 17:26:59 thorpej Exp $  */
+/*     $NetBSD: if.c,v 1.98 2001/11/05 18:02:15 matt Exp $     */
 
 /*-
  * Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -1493,9 +1493,9 @@
        int space = ifc->ifc_len, error = 0;
 
        ifrp = ifc->ifc_req;
-       for (ifp = ifnet.tqh_first; ifp != 0; ifp = ifp->if_list.tqe_next) {
+       TAILQ_FOREACH(ifp, &ifnet, if_list) {
                bcopy(ifp->if_xname, ifr.ifr_name, IFNAMSIZ);
-               if ((ifa = ifp->if_addrlist.tqh_first) == 0) {
+               if ((ifa = TAILQ_FIRST(&ifp->if_addrlist)) == 0) {
                        memset((caddr_t)&ifr.ifr_addr, 0, sizeof(ifr.ifr_addr));
                        if (space >= (int)sizeof (ifr)) {
                                error = copyout((caddr_t)&ifr, (caddr_t)ifrp,
@@ -1505,7 +1505,7 @@
                        }
                        space -= sizeof (ifr), ifrp++;
                } else 
-                   for (; ifa != 0; ifa = ifa->ifa_list.tqe_next) {
+                   for (; ifa != 0; ifa = TAILQ_NEXT(ifa, ifa_list)) {
                        struct sockaddr *sa = ifa->ifa_addr;
 #if defined(COMPAT_43) || defined(COMPAT_LINUX) || defined(COMPAT_SVR4)
                        if (cmd == OSIOCGIFCONF) {
diff -r 2591bf7236a3 -r b01b21ce3451 sys/net/if_ether.h
--- a/sys/net/if_ether.h        Mon Nov 05 17:51:56 2001 +0000
+++ b/sys/net/if_ether.h        Mon Nov 05 18:02:15 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_ether.h,v 1.25 2001/06/03 03:24:23 thorpej Exp $    */
+/*     $NetBSD: if_ether.h,v 1.26 2001/11/05 18:02:15 matt Exp $       */
 
 /*
  * Copyright (c) 1982, 1986, 1993
@@ -204,11 +204,11 @@
        /* struct ethercom *ec; */                                      \
        /* struct ether_multi *enm; */                                  \
 {                                                                      \
-       for ((enm) = (ec)->ec_multiaddrs.lh_first;                      \
+       for ((enm) = LIST_FIRST(&(ec)->ec_multiaddrs);                  \
            (enm) != NULL &&                                            \
            (bcmp((enm)->enm_addrlo, (addrlo), ETHER_ADDR_LEN) != 0 ||  \
             bcmp((enm)->enm_addrhi, (addrhi), ETHER_ADDR_LEN) != 0);   \
-               (enm) = (enm)->enm_list.le_next);                       \
+               (enm) = LIST_NEXT((enm), enm_list));                    \
 }
 
 /*
@@ -223,7 +223,7 @@
        /* struct ether_multi *enm; */  \
 { \
        if (((enm) = (step).e_enm) != NULL) \
-               (step).e_enm = (enm)->enm_list.le_next; \
+               (step).e_enm = LIST_NEXT((enm), enm_list); \
 }
 
 #define ETHER_FIRST_MULTI(step, ec, enm) \
@@ -231,7 +231,7 @@
        /* struct ethercom *ec; */ \
        /* struct ether_multi *enm; */ \
 { \
-       (step).e_enm = (ec)->ec_multiaddrs.lh_first; \
+       (step).e_enm = LIST_FIRST(&(ec)->ec_multiaddrs); \
        ETHER_NEXT_MULTI((step), (enm)); \
 }
 
diff -r 2591bf7236a3 -r b01b21ce3451 sys/net/if_spppsubr.c
--- a/sys/net/if_spppsubr.c     Mon Nov 05 17:51:56 2001 +0000
+++ b/sys/net/if_spppsubr.c     Mon Nov 05 18:02:15 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_spppsubr.c,v 1.27 2001/10/29 19:15:48 martin Exp $   */
+/*     $NetBSD: if_spppsubr.c,v 1.28 2001/11/05 18:02:15 matt Exp $     */
 
 /*
  * Synchronous PPP/Cisco link level subroutines.
@@ -4516,15 +4516,15 @@
         * Pick the first AF_INET address from the list,
         * aliases don't make any sense on a p2p link anyway.
         */
-       for (ifa = ifp->if_addrlist.tqh_first, si = 0;
-            ifa;
-            ifa = ifa->ifa_list.tqe_next)
+       si = 0;
+       TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) {
                if (ifa->ifa_addr->sa_family == AF_INET) {
                        si = (struct sockaddr_in *)ifa->ifa_addr;
                        sm = (struct sockaddr_in *)ifa->ifa_netmask;
                        if (si)
                                break;
                }
+       }
        if (ifa) {
                if (si && si->sin_addr.s_addr) {
                        ssrc = si->sin_addr.s_addr;
@@ -4556,9 +4556,8 @@
         * aliases don't make any sense on a p2p link anyway.
         */
 
-       for (ifa = ifp->if_addrlist.tqh_first, si = 0;
-            ifa;
-            ifa = ifa->ifa_list.tqe_next)
+       si = 0;
+       TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list)
        {
                if (ifa->ifa_addr->sa_family == AF_INET)
                {
@@ -4603,9 +4602,8 @@
         * Pick the first link-local AF_INET6 address from the list,
         * aliases don't make any sense on a p2p link anyway.
         */
-       for (ifa = ifp->if_addrlist.tqh_first, si = 0;
-            ifa;
-            ifa = ifa->ifa_list.tqe_next)
+       si = 0;
+       TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list)
                if (ifa->ifa_addr->sa_family == AF_INET6) {
                        si = (struct sockaddr_in6 *)ifa->ifa_addr;
                        sm = (struct sockaddr_in6 *)ifa->ifa_netmask;
@@ -4658,9 +4656,7 @@
         */
 
        sin6 = NULL;
-       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)
                {
diff -r 2591bf7236a3 -r b01b21ce3451 sys/net/if_stf.c
--- a/sys/net/if_stf.c  Mon Nov 05 17:51:56 2001 +0000
+++ b/sys/net/if_stf.c  Mon Nov 05 18:02:15 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_stf.c,v 1.17 2001/07/18 16:43:10 thorpej Exp $      */
+/*     $NetBSD: if_stf.c,v 1.18 2001/11/05 18:02:16 matt Exp $ */
 /*     $KAME: if_stf.c,v 1.62 2001/06/07 22:32:16 itojun Exp $ */
 
 /*
@@ -343,9 +343,7 @@
 #if defined(__bsdi__) || (defined(__FreeBSD__) && __FreeBSD__ < 3)
        for (ia = ifp->if_addrlist; ia; ia = ia->ifa_next)
 #else
-       for (ia = ifp->if_addrlist.tqh_first;
-            ia;
-            ia = ia->ifa_list.tqe_next)
+       TAILQ_FIRST(ia, &ifp->if_addrlist, ifa_list) {
 #endif
        {
                if (ia->ifa_addr == NULL)
@@ -361,9 +359,9 @@
                INADDR_TO_IA(in, ia4);
 #else
 #ifdef __OpenBSD__
-               for (ia4 = in_ifaddr.tqh_first;
+               for (ia4 = TAILQ_FIRST(&in_ifaddr);
                     ia4;
-                    ia4 = ia4->ia_list.tqe_next)
+                    ia4 = TAILQ_NEXT(ia4, ia_list))
 #elif defined(__FreeBSD__) && __FreeBSD__ >= 3
                for (ia4 = TAILQ_FIRST(&in_ifaddrhead);
                     ia4;
@@ -537,7 +535,7 @@
         * reject packets with broadcast
         */
 #if defined(__OpenBSD__) || defined(__NetBSD__)
-       for (ia4 = in_ifaddr.tqh_first; ia4; ia4 = ia4->ia_list.tqe_next)
+       TAILQ_FOREACH(ia4, &in_ifaddr, ia_list)
 #elif defined(__FreeBSD__) && __FreeBSD__ >= 3
        for (ia4 = TAILQ_FIRST(&in_ifaddrhead);
             ia4;
diff -r 2591bf7236a3 -r b01b21ce3451 sys/net/if_tun.c
--- a/sys/net/if_tun.c  Mon Nov 05 17:51:56 2001 +0000
+++ b/sys/net/if_tun.c  Mon Nov 05 18:02:15 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_tun.c,v 1.46 2001/10/31 20:08:17 atatat Exp $       */
+/*     $NetBSD: if_tun.c,v 1.47 2001/11/05 18:02:16 matt Exp $ */
 
 /*
  * Copyright (c) 1988, Julian Onions <jpo%cs.nott.ac.uk@localhost>
@@ -279,8 +279,7 @@
                if (ifp->if_flags & IFF_RUNNING) {
                        /* find internet addresses and delete routes */
                        struct ifaddr *ifa;
-                       for (ifa = ifp->if_addrlist.tqh_first; ifa != 0;
-                           ifa = ifa->ifa_list.tqe_next) {
+                       TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) {
 #ifdef INET
                                if (ifa->ifa_addr->sa_family == AF_INET) {
                                        rtinit(ifa, (int)RTM_DELETE,
@@ -313,8 +312,7 @@
        ifp->if_flags |= IFF_UP | IFF_RUNNING;
 
        tp->tun_flags &= ~(TUN_IASET|TUN_DSTADDR);
-       for (ifa = ifp->if_addrlist.tqh_first; ifa != 0;
-            ifa = ifa->ifa_list.tqe_next) {
+       TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) {
 #ifdef INET
                if (ifa->ifa_addr->sa_family == AF_INET) {
                        struct sockaddr_in *sin;
diff -r 2591bf7236a3 -r b01b21ce3451 sys/net/raw_usrreq.c
--- a/sys/net/raw_usrreq.c      Mon Nov 05 17:51:56 2001 +0000
+++ b/sys/net/raw_usrreq.c      Mon Nov 05 18:02:15 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: raw_usrreq.c,v 1.15 2000/03/30 09:45:40 augustss Exp $ */
+/*     $NetBSD: raw_usrreq.c,v 1.16 2001/11/05 18:02:16 matt Exp $     */
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -94,7 +94,7 @@
        va_end(ap);
 
        last = 0;
-       for (rp = rawcb.lh_first; rp != 0; rp = rp->rcb_list.le_next) {
+       LIST_FOREACH(rp, &rawcb, rcb_list) {
                if (rp->rcb_proto.sp_family != proto->sp_family)
                        continue;
                if (rp->rcb_proto.sp_protocol  &&
diff -r 2591bf7236a3 -r b01b21ce3451 sys/net/route.c
--- a/sys/net/route.c   Mon Nov 05 17:51:56 2001 +0000
+++ b/sys/net/route.c   Mon Nov 05 18:02:15 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: route.c,v 1.48 2001/10/16 02:42:36 itojun Exp $        */
+/*     $NetBSD: route.c,v 1.49 2001/11/05 18:02:16 matt Exp $  */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -209,7 +209,7 @@
                        info.rti_info[RTAX_GATEWAY] = rt->rt_gateway;
                        if (rt->rt_ifp != NULL) {
                                info.rti_info[RTAX_IFP] = 
-                                   rt->rt_ifp->if_addrlist.tqh_first->ifa_addr;
+                                   TAILQ_FIRST(&rt->rt_ifp->if_addrlist)->ifa_addr;
                                info.rti_info[RTAX_IFA] = rt->rt_ifa->ifa_addr;
                        }
                        rt_missmsg(RTM_ADD, &info, rt->rt_flags, 0);
diff -r 2591bf7236a3 -r b01b21ce3451 sys/net/rtsock.c
--- a/sys/net/rtsock.c  Mon Nov 05 17:51:56 2001 +0000
+++ b/sys/net/rtsock.c  Mon Nov 05 18:02:15 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rtsock.c,v 1.52 2001/10/29 07:02:32 simonb Exp $       */
+/*     $NetBSD: rtsock.c,v 1.53 2001/11/05 18:02:16 matt Exp $ */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -315,7 +315,7 @@
                        genmask = rt->rt_genmask;
                        if (rtm->rtm_addrs & (RTA_IFP | RTA_IFA)) {
                                if ((ifp = rt->rt_ifp) != NULL) {
-                                       ifpaddr = ifp->if_addrlist.tqh_first->ifa_addr;
+                                       ifpaddr = TAILQ_FIRST(&ifp->if_addrlist)->ifa_addr;
                                        ifaaddr = rt->rt_ifa->ifa_addr;
                                        if (ifp->if_flags & IFF_POINTOPOINT)
                                                brdaddr = rt->rt_ifa->ifa_dstaddr;
@@ -787,7 +787,7 @@
                        int ncmd = cmd == RTM_ADD ? RTM_NEWADDR : RTM_DELADDR;
 
                        ifaaddr = sa = ifa->ifa_addr;
-                       ifpaddr = ifp->if_addrlist.tqh_first->ifa_addr;
+                       ifpaddr = TAILQ_FIRST(&ifp->if_addrlist)->ifa_addr;
                        netmask = ifa->ifa_netmask;
                        brdaddr = ifa->ifa_dstaddr;
                        memset(&ifam, 0, sizeof(ifam));
@@ -871,7 +871,7 @@
        netmask = rt_mask(rt);
        genmask = rt->rt_genmask;
        if (rt->rt_ifp) {
-               ifpaddr = rt->rt_ifp->if_addrlist.tqh_first->ifa_addr;
+               ifpaddr = TAILQ_FIRST(&rt->rt_ifp->if_addrlist)->ifa_addr;
                ifaaddr = rt->rt_ifa->ifa_addr;
                if (rt->rt_ifp->if_flags & IFF_POINTOPOINT)
                        brdaddr = rt->rt_ifa->ifa_dstaddr;
@@ -907,10 +907,10 @@
        int     len, error = 0;
 
        memset(&info, 0, sizeof(info));
-       for (ifp = ifnet.tqh_first; ifp != 0; ifp = ifp->if_list.tqe_next) {
+       TAILQ_FOREACH(ifp, &ifnet, if_list) {
                if (w->w_arg && w->w_arg != ifp->if_index)
                        continue;
-               ifa = ifp->if_addrlist.tqh_first;
+               ifa = TAILQ_FIRST(&ifp->if_addrlist);
                ifpaddr = ifa->ifa_addr;
                switch(type) {
                case NET_RT_IFLIST:
@@ -999,7 +999,7 @@
                                panic("sysctl_iflist(2)");
                        }
                }
-               while ((ifa = ifa->ifa_list.tqe_next) != NULL) {
+               while ((ifa = TAILQ_NEXT(ifa, ifa_list)) != NULL) {
                        if (af && af != ifa->ifa_addr->sa_family)
                                continue;
                        ifaaddr = ifa->ifa_addr;



Home | Main Index | Thread Index | Old Index