Author: avos
Date: Mon Nov 14 23:51:28 2016
New Revision: 308656
URL: https://svnweb.freebsd.org/changeset/base/308656

Log:
  net80211: switch from ieee80211_iterate_nodes() to
  ieee80211_iterate_nodes_vap() where possible; this should
  make the code a bit cleaner.

Modified:
  head/sys/net80211/ieee80211_adhoc.c
  head/sys/net80211/ieee80211_hostap.c
  head/sys/net80211/ieee80211_ioctl.c
  head/sys/net80211/ieee80211_node.c
  head/sys/net80211/ieee80211_tdma.c

Modified: head/sys/net80211/ieee80211_adhoc.c
==============================================================================
--- head/sys/net80211/ieee80211_adhoc.c Mon Nov 14 22:39:33 2016        
(r308655)
+++ head/sys/net80211/ieee80211_adhoc.c Mon Nov 14 23:51:28 2016        
(r308656)
@@ -120,9 +120,9 @@ adhoc_vattach(struct ieee80211vap *vap)
 static void
 sta_leave(void *arg, struct ieee80211_node *ni)
 {
-       struct ieee80211vap *vap = arg;
+       struct ieee80211vap *vap = ni->ni_vap;
 
-       if (ni->ni_vap == vap && ni != vap->iv_bss)
+       if (ni != vap->iv_bss)
                ieee80211_node_leave(ni);
 }
 
@@ -164,7 +164,8 @@ adhoc_newstate(struct ieee80211vap *vap,
                switch (ostate) {
                case IEEE80211_S_RUN:           /* beacon miss */
                        /* purge station table; entries are stale */
-                       ieee80211_iterate_nodes(&ic->ic_sta, sta_leave, vap);
+                       ieee80211_iterate_nodes_vap(&ic->ic_sta, vap,
+                           sta_leave, NULL);
                        /* fall thru... */
                case IEEE80211_S_INIT:
                        if (vap->iv_des_chan != IEEE80211_CHAN_ANYC &&

Modified: head/sys/net80211/ieee80211_hostap.c
==============================================================================
--- head/sys/net80211/ieee80211_hostap.c        Mon Nov 14 22:39:33 2016        
(r308655)
+++ head/sys/net80211/ieee80211_hostap.c        Mon Nov 14 23:51:28 2016        
(r308656)
@@ -107,9 +107,8 @@ hostap_vattach(struct ieee80211vap *vap)
 static void
 sta_disassoc(void *arg, struct ieee80211_node *ni)
 {
-       struct ieee80211vap *vap = arg;
 
-       if (ni->ni_vap == vap && ni->ni_associd != 0) {
+       if (ni->ni_associd != 0) {
                IEEE80211_SEND_MGMT(ni, IEEE80211_FC0_SUBTYPE_DISASSOC,
                        IEEE80211_REASON_ASSOC_LEAVE);
                ieee80211_node_leave(ni);
@@ -119,9 +118,9 @@ sta_disassoc(void *arg, struct ieee80211
 static void
 sta_csa(void *arg, struct ieee80211_node *ni)
 {
-       struct ieee80211vap *vap = arg;
+       struct ieee80211vap *vap = ni->ni_vap;
 
-       if (ni->ni_vap == vap && ni->ni_associd != 0)
+       if (ni->ni_associd != 0)
                if (ni->ni_inact > vap->iv_inact_init) {
                        ni->ni_inact = vap->iv_inact_init;
                        IEEE80211_NOTE(vap, IEEE80211_MSG_INACT, ni,
@@ -132,9 +131,8 @@ sta_csa(void *arg, struct ieee80211_node
 static void
 sta_drop(void *arg, struct ieee80211_node *ni)
 {
-       struct ieee80211vap *vap = arg;
 
-       if (ni->ni_vap == vap && ni->ni_associd != 0)
+       if (ni->ni_associd != 0)
                ieee80211_node_leave(ni);
 }
 
@@ -179,7 +177,8 @@ hostap_newstate(struct ieee80211vap *vap
                        ieee80211_dfs_cac_stop(vap);
                        break;
                case IEEE80211_S_RUN:
-                       ieee80211_iterate_nodes(&ic->ic_sta, sta_disassoc, vap);
+                       ieee80211_iterate_nodes_vap(&ic->ic_sta, vap,
+                           sta_disassoc, NULL);
                        break;
                default:
                        break;
@@ -195,7 +194,8 @@ hostap_newstate(struct ieee80211vap *vap
                switch (ostate) {
                case IEEE80211_S_CSA:
                case IEEE80211_S_RUN:
-                       ieee80211_iterate_nodes(&ic->ic_sta, sta_disassoc, vap);
+                       ieee80211_iterate_nodes_vap(&ic->ic_sta, vap,
+                           sta_disassoc, NULL);
                        /*
                         * Clear overlapping BSS state; the beacon frame
                         * will be reconstructed on transition to the RUN
@@ -289,7 +289,8 @@ hostap_newstate(struct ieee80211vap *vap
                         * Shorten inactivity timer of associated stations
                         * to weed out sta's that don't follow a CSA.
                         */
-                       ieee80211_iterate_nodes(&ic->ic_sta, sta_csa, vap);
+                       ieee80211_iterate_nodes_vap(&ic->ic_sta, vap,
+                           sta_csa, NULL);
                        /*
                         * Update bss node channel to reflect where
                         * we landed after CSA.
@@ -340,7 +341,8 @@ hostap_newstate(struct ieee80211vap *vap
                         * such as capabilities and the negotiated rate
                         * set may/will be wrong).
                         */
-                       ieee80211_iterate_nodes(&ic->ic_sta, sta_drop, vap);
+                       ieee80211_iterate_nodes_vap(&ic->ic_sta, vap,
+                           sta_drop, NULL);
                }
                break;
        default:

Modified: head/sys/net80211/ieee80211_ioctl.c
==============================================================================
--- head/sys/net80211/ieee80211_ioctl.c Mon Nov 14 22:39:33 2016        
(r308655)
+++ head/sys/net80211/ieee80211_ioctl.c Mon Nov 14 23:51:28 2016        
(r308656)
@@ -347,7 +347,6 @@ ieee80211_ioctl_getscanresults(struct ie
 }
 
 struct stainforeq {
-       struct ieee80211vap *vap;
        struct ieee80211req_sta_info *si;
        size_t  space;
 };
@@ -366,8 +365,6 @@ get_sta_space(void *arg, struct ieee8021
        struct stainforeq *req = arg;
        size_t ielen;
 
-       if (req->vap != ni->ni_vap)
-               return;
        if (ni->ni_vap->iv_opmode == IEEE80211_M_HOSTAP &&
            ni->ni_associd == 0)        /* only associated stations */
                return;
@@ -383,8 +380,6 @@ get_sta_info(void *arg, struct ieee80211
        size_t ielen, len;
        uint8_t *cp;
 
-       if (req->vap != ni->ni_vap)
-               return;
        if (vap->iv_opmode == IEEE80211_M_HOSTAP &&
            ni->ni_associd == 0)        /* only associated stations */
                return;
@@ -472,10 +467,10 @@ getstainfo_common(struct ieee80211vap *v
 
        error = 0;
        req.space = 0;
-       req.vap = vap;
-       if (ni == NULL)
-               ieee80211_iterate_nodes(&ic->ic_sta, get_sta_space, &req);
-       else
+       if (ni == NULL) {
+               ieee80211_iterate_nodes_vap(&ic->ic_sta, vap, get_sta_space,
+                   &req);
+       } else
                get_sta_space(&req, ni);
        if (req.space > ireq->i_len)
                req.space = ireq->i_len;
@@ -489,9 +484,10 @@ getstainfo_common(struct ieee80211vap *v
                        goto bad;
                }
                req.si = p;
-               if (ni == NULL)
-                       ieee80211_iterate_nodes(&ic->ic_sta, get_sta_info, 
&req);
-               else
+               if (ni == NULL) {
+                       ieee80211_iterate_nodes_vap(&ic->ic_sta, vap,
+                           get_sta_info, &req);
+               } else
                        get_sta_info(&req, ni);
                ireq->i_len = space - req.space;
                error = copyout(p, (uint8_t *) ireq->i_data+off, ireq->i_len);

Modified: head/sys/net80211/ieee80211_node.c
==============================================================================
--- head/sys/net80211/ieee80211_node.c  Mon Nov 14 22:39:33 2016        
(r308655)
+++ head/sys/net80211/ieee80211_node.c  Mon Nov 14 23:51:28 2016        
(r308656)
@@ -2717,7 +2717,6 @@ done:
 }
 
 struct rssiinfo {
-       struct ieee80211vap *vap;
        int     rssi_samples;
        uint32_t rssi_total;
 };
@@ -2729,8 +2728,6 @@ get_hostap_rssi(void *arg, struct ieee80
        struct ieee80211vap *vap = ni->ni_vap;
        int8_t rssi;
 
-       if (info->vap != vap)
-               return;
        /* only associated stations */
        if (ni->ni_associd == 0)
                return;
@@ -2748,8 +2745,6 @@ get_adhoc_rssi(void *arg, struct ieee802
        struct ieee80211vap *vap = ni->ni_vap;
        int8_t rssi;
 
-       if (info->vap != vap)
-               return;
        /* only neighbors */
        /* XXX check bssid */
        if ((ni->ni_capinfo & IEEE80211_CAPINFO_IBSS) == 0)
@@ -2769,8 +2764,6 @@ get_mesh_rssi(void *arg, struct ieee8021
        struct ieee80211vap *vap = ni->ni_vap;
        int8_t rssi;
 
-       if (info->vap != vap)
-               return;
        /* only neighbors that peered successfully */
        if (ni->ni_mlstate != IEEE80211_NODE_MESH_ESTABLISHED)
                return;
@@ -2791,18 +2784,20 @@ ieee80211_getrssi(struct ieee80211vap *v
 
        info.rssi_total = 0;
        info.rssi_samples = 0;
-       info.vap = vap;
        switch (vap->iv_opmode) {
        case IEEE80211_M_IBSS:          /* average of all ibss neighbors */
        case IEEE80211_M_AHDEMO:        /* average of all neighbors */
-               ieee80211_iterate_nodes(&ic->ic_sta, get_adhoc_rssi, &info);
+               ieee80211_iterate_nodes_vap(&ic->ic_sta, vap, get_adhoc_rssi,
+                   &info);
                break;
        case IEEE80211_M_HOSTAP:        /* average of all associated stations */
-               ieee80211_iterate_nodes(&ic->ic_sta, get_hostap_rssi, &info);
+               ieee80211_iterate_nodes_vap(&ic->ic_sta, vap, get_hostap_rssi,
+                   &info);
                break;
 #ifdef IEEE80211_SUPPORT_MESH
        case IEEE80211_M_MBSS:          /* average of all mesh neighbors */
-               ieee80211_iterate_nodes(&ic->ic_sta, get_mesh_rssi, &info);
+               ieee80211_iterate_nodes_vap(&ic->ic_sta, vap, get_mesh_rssi,
+                   &info);
                break;
 #endif
        case IEEE80211_M_MONITOR:       /* XXX */

Modified: head/sys/net80211/ieee80211_tdma.c
==============================================================================
--- head/sys/net80211/ieee80211_tdma.c  Mon Nov 14 22:39:33 2016        
(r308655)
+++ head/sys/net80211/ieee80211_tdma.c  Mon Nov 14 23:51:28 2016        
(r308656)
@@ -209,9 +209,9 @@ tdma_vdetach(struct ieee80211vap *vap)
 static void
 sta_leave(void *arg, struct ieee80211_node *ni)
 {
-       struct ieee80211vap *vap = arg;
+       struct ieee80211vap *vap = ni->ni_vap;
 
-       if (ni->ni_vap == vap && ni != vap->iv_bss)
+       if (ni != vap->iv_bss)
                ieee80211_node_leave(ni);
 }
 
@@ -246,7 +246,8 @@ tdma_newstate(struct ieee80211vap *vap, 
                ieee80211_cancel_scan(vap);             /* background scan */
                if (ostate == IEEE80211_S_RUN) {
                        /* purge station table; entries are stale */
-                       ieee80211_iterate_nodes(&ic->ic_sta, sta_leave, vap);
+                       ieee80211_iterate_nodes_vap(&ic->ic_sta, vap,
+                           sta_leave, NULL);
                }
                if (vap->iv_flags_ext & IEEE80211_FEXT_SCANREQ) {
                        ieee80211_check_scan(vap,
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to