Lines 2156-2187
ieee80211_node_timeout(void *arg)
Link Here
|
2156 |
ieee80211_node_timeout, ic); |
2156 |
ieee80211_node_timeout, ic); |
2157 |
} |
2157 |
} |
2158 |
|
2158 |
|
|
|
2159 |
/* |
2160 |
* May directly be called and do customized iterate functions. |
2161 |
* Only requirement is to decrement each node's ref count. |
2162 |
*/ |
2159 |
void |
2163 |
void |
2160 |
ieee80211_iterate_nodes(struct ieee80211_node_table *nt, |
2164 |
ieee80211_iterate_nt(struct ieee80211_node_table *nt, |
2161 |
ieee80211_iter_func *f, void *arg) |
2165 |
struct ieee80211_node **ni_arr, uint16_t max_aid) |
2162 |
{ |
2166 |
{ |
2163 |
struct ieee80211_node *ni; |
2167 |
struct ieee80211_node *ni; |
2164 |
u_int gen; |
2168 |
u_int gen; |
|
|
2169 |
int i = 0; |
2165 |
|
2170 |
|
2166 |
IEEE80211_NODE_ITERATE_LOCK(nt); |
2171 |
IEEE80211_NODE_ITERATE_LOCK(nt); |
|
|
2172 |
IEEE80211_NODE_LOCK(nt); |
2173 |
|
2167 |
gen = ++nt->nt_scangen; |
2174 |
gen = ++nt->nt_scangen; |
|
|
2175 |
|
2168 |
restart: |
2176 |
restart: |
2169 |
IEEE80211_NODE_LOCK(nt); |
|
|
2170 |
TAILQ_FOREACH(ni, &nt->nt_node, ni_list) { |
2177 |
TAILQ_FOREACH(ni, &nt->nt_node, ni_list) { |
2171 |
if (ni->ni_scangen != gen) { |
2178 |
if (ni->ni_scangen == gen) |
2172 |
ni->ni_scangen = gen; |
2179 |
continue; |
2173 |
(void) ieee80211_ref_node(ni); |
2180 |
|
2174 |
IEEE80211_NODE_UNLOCK(nt); |
2181 |
if (i >= max_aid) { |
2175 |
(*f)(arg, ni); |
2182 |
if_printf(nt->nt_ic->ic_ifp, |
2176 |
ieee80211_free_node(ni); |
2183 |
"Node array overflow: max=%u", max_aid); |
2177 |
goto restart; |
2184 |
break; |
2178 |
} |
2185 |
} |
|
|
2186 |
|
2187 |
ni->ni_scangen = gen; |
2188 |
(*(ni_arr + i++)) = ieee80211_ref_node(ni); |
2189 |
goto restart; |
2179 |
} |
2190 |
} |
2180 |
IEEE80211_NODE_UNLOCK(nt); |
|
|
2181 |
|
2191 |
|
|
|
2192 |
IEEE80211_NODE_UNLOCK(nt); |
2182 |
IEEE80211_NODE_ITERATE_UNLOCK(nt); |
2193 |
IEEE80211_NODE_ITERATE_UNLOCK(nt); |
2183 |
} |
2194 |
} |
2184 |
|
2195 |
|
|
|
2196 |
/* |
2197 |
* Just a wrapper, so we don't have to change every ieee80211_iterate_nodes() |
2198 |
* reference in the source. |
2199 |
*/ |
2200 |
void |
2201 |
ieee80211_iterate_nodes(struct ieee80211_node_table *nt, |
2202 |
ieee80211_iter_func *f, void *arg) |
2203 |
{ |
2204 |
struct ieee80211_node **ni_arr; |
2205 |
struct ieee80211_node *ni; |
2206 |
unsigned long size; |
2207 |
int i; |
2208 |
uint16_t max_aid; |
2209 |
|
2210 |
max_aid = TAILQ_FIRST(&nt->nt_ic->ic_vaps)->iv_max_aid; |
2211 |
size = max_aid * sizeof(*ni_arr); |
2212 |
ni_arr = (struct ieee80211_node **)malloc(size, M_80211_NODE, |
2213 |
M_NOWAIT | M_ZERO); |
2214 |
if (ni_arr == NULL) |
2215 |
return; |
2216 |
|
2217 |
ieee80211_iterate_nt(nt, ni_arr, max_aid); |
2218 |
|
2219 |
for (i = 0; i < max_aid; i++) { |
2220 |
ni = *(ni_arr + i); |
2221 |
if (ni == NULL) /* end of the list */ |
2222 |
break; |
2223 |
|
2224 |
(*f)(arg, ni); |
2225 |
/* ieee80211_free_node() locks by itself */ |
2226 |
ieee80211_free_node(ni); |
2227 |
} |
2228 |
|
2229 |
free(ni_arr, M_80211_NODE); |
2230 |
} |
2231 |
|
2185 |
void |
2232 |
void |
2186 |
ieee80211_dump_node(struct ieee80211_node_table *nt, struct ieee80211_node *ni) |
2233 |
ieee80211_dump_node(struct ieee80211_node_table *nt, struct ieee80211_node *ni) |
2187 |
{ |
2234 |
{ |