Changeset View
Changeset View
Standalone View
Standalone View
sys/net80211/ieee80211_node.c
| Show First 20 Lines • Show All 85 Lines • ▼ Show 20 Lines | static struct ieee80211_node *ieee80211_alloc_node( | ||||
| struct ieee80211_node_table *, struct ieee80211vap *, | struct ieee80211_node_table *, struct ieee80211vap *, | ||||
| const uint8_t macaddr[IEEE80211_ADDR_LEN], const char *, int); | const uint8_t macaddr[IEEE80211_ADDR_LEN], const char *, int); | ||||
| static struct ieee80211_node *node_alloc(struct ieee80211vap *, | static struct ieee80211_node *node_alloc(struct ieee80211vap *, | ||||
| const uint8_t [IEEE80211_ADDR_LEN]); | const uint8_t [IEEE80211_ADDR_LEN]); | ||||
| static int node_init(struct ieee80211_node *); | static int node_init(struct ieee80211_node *); | ||||
| static void node_cleanup(struct ieee80211_node *); | static void node_cleanup(struct ieee80211_node *); | ||||
| static void node_free(struct ieee80211_node *); | static void node_free(struct ieee80211_node *); | ||||
| static void node_age(struct ieee80211_node *); | static void node_age(struct ieee80211_node *); | ||||
| static int8_t node_getrssi(const struct ieee80211_node *); | static net80211_rssi_t node_getrssi(const struct ieee80211_node *); | ||||
| static void node_getsignal(const struct ieee80211_node *, int8_t *, int8_t *); | static void node_getsignal(const struct ieee80211_node *, net80211_rssi_t *, int8_t *); | ||||
| static void node_getmimoinfo(const struct ieee80211_node *, | static void node_getmimoinfo(const struct ieee80211_node *, | ||||
| struct ieee80211_mimo_info *); | struct ieee80211_mimo_info *); | ||||
| static void __ieee80211_free_node(struct ieee80211_node *); | static void __ieee80211_free_node(struct ieee80211_node *); | ||||
| static void node_reclaim(struct ieee80211_node_table *nt, | static void node_reclaim(struct ieee80211_node_table *nt, | ||||
| struct ieee80211_node *ni); | struct ieee80211_node *ni); | ||||
| static void ieee80211_node_table_init(struct ieee80211com *ic, | static void ieee80211_node_table_init(struct ieee80211com *ic, | ||||
| ▲ Show 20 Lines • Show All 1,232 Lines • ▼ Show 20 Lines | node_age(struct ieee80211_node *ni) | ||||
| /* | /* | ||||
| * Age out HT resources (e.g. frames on the | * Age out HT resources (e.g. frames on the | ||||
| * A-MPDU reorder queues). | * A-MPDU reorder queues). | ||||
| */ | */ | ||||
| if (ni->ni_associd != 0 && (ni->ni_flags & IEEE80211_NODE_HT)) | if (ni->ni_associd != 0 && (ni->ni_flags & IEEE80211_NODE_HT)) | ||||
| ieee80211_ht_node_age(ni); | ieee80211_ht_node_age(ni); | ||||
| } | } | ||||
| static int8_t | static net80211_rssi_t | ||||
| node_getrssi(const struct ieee80211_node *ni) | node_getrssi(const struct ieee80211_node *ni) | ||||
| { | { | ||||
| uint32_t avgrssi = ni->ni_avgrssi; | uint32_t avgrssi = ni->ni_avgrssi; | ||||
| int32_t rssi; | int32_t rssi; | ||||
| if (avgrssi == IEEE80211_RSSI_DUMMY_MARKER) | if (avgrssi == IEEE80211_RSSI_DUMMY_MARKER) | ||||
| return 0; | return 0; | ||||
| rssi = IEEE80211_RSSI_GET(avgrssi); | rssi = IEEE80211_RSSI_GET(avgrssi); | ||||
| return rssi < 0 ? 0 : rssi > 127 ? 127 : rssi; | return rssi < 0 ? 0 : rssi > 127 ? 127 : rssi; | ||||
| } | } | ||||
| static void | static void | ||||
| node_getsignal(const struct ieee80211_node *ni, int8_t *rssi, int8_t *noise) | node_getsignal(const struct ieee80211_node *ni, net80211_rssi_t *rssi, int8_t *noise) | ||||
| { | { | ||||
| *rssi = node_getrssi(ni); | *rssi = node_getrssi(ni); | ||||
| *noise = ni->ni_noise; | *noise = ni->ni_noise; | ||||
| } | } | ||||
| static void | static void | ||||
| node_getmimoinfo(const struct ieee80211_node *ni, | node_getmimoinfo(const struct ieee80211_node *ni, | ||||
| struct ieee80211_mimo_info *info) | struct ieee80211_mimo_info *info) | ||||
| ▲ Show 20 Lines • Show All 1,668 Lines • ▼ Show 20 Lines | struct rssiinfo { | ||||
| uint32_t rssi_total; | uint32_t rssi_total; | ||||
| }; | }; | ||||
| static void | static void | ||||
| get_hostap_rssi(void *arg, struct ieee80211_node *ni) | get_hostap_rssi(void *arg, struct ieee80211_node *ni) | ||||
| { | { | ||||
| struct rssiinfo *info = arg; | struct rssiinfo *info = arg; | ||||
| struct ieee80211vap *vap = ni->ni_vap; | struct ieee80211vap *vap = ni->ni_vap; | ||||
| int8_t rssi; | net80211_rssi_t rssi; | ||||
| /* only associated stations */ | /* only associated stations */ | ||||
| if (ni->ni_associd == 0) | if (ni->ni_associd == 0) | ||||
| return; | return; | ||||
| rssi = vap->iv_ic->ic_node_getrssi(ni); | rssi = vap->iv_ic->ic_node_getrssi(ni); | ||||
| if (rssi != 0) { | if (rssi != 0) { | ||||
| info->rssi_samples++; | info->rssi_samples++; | ||||
| info->rssi_total += rssi; | info->rssi_total += rssi; | ||||
| } | } | ||||
| } | } | ||||
| static void | static void | ||||
| get_adhoc_rssi(void *arg, struct ieee80211_node *ni) | get_adhoc_rssi(void *arg, struct ieee80211_node *ni) | ||||
| { | { | ||||
| struct rssiinfo *info = arg; | struct rssiinfo *info = arg; | ||||
| struct ieee80211vap *vap = ni->ni_vap; | struct ieee80211vap *vap = ni->ni_vap; | ||||
| int8_t rssi; | net80211_rssi_t rssi; | ||||
| /* only neighbors */ | /* only neighbors */ | ||||
| /* XXX check bssid */ | /* XXX check bssid */ | ||||
| if ((ni->ni_capinfo & IEEE80211_CAPINFO_IBSS) == 0) | if ((ni->ni_capinfo & IEEE80211_CAPINFO_IBSS) == 0) | ||||
| return; | return; | ||||
| rssi = vap->iv_ic->ic_node_getrssi(ni); | rssi = vap->iv_ic->ic_node_getrssi(ni); | ||||
| if (rssi != 0) { | if (rssi != 0) { | ||||
| info->rssi_samples++; | info->rssi_samples++; | ||||
| info->rssi_total += rssi; | info->rssi_total += rssi; | ||||
| } | } | ||||
| } | } | ||||
| #ifdef IEEE80211_SUPPORT_MESH | #ifdef IEEE80211_SUPPORT_MESH | ||||
| static void | static void | ||||
| get_mesh_rssi(void *arg, struct ieee80211_node *ni) | get_mesh_rssi(void *arg, struct ieee80211_node *ni) | ||||
| { | { | ||||
| struct rssiinfo *info = arg; | struct rssiinfo *info = arg; | ||||
| struct ieee80211vap *vap = ni->ni_vap; | struct ieee80211vap *vap = ni->ni_vap; | ||||
| int8_t rssi; | net80211_rssi_t rssi; | ||||
| /* only neighbors that peered successfully */ | /* only neighbors that peered successfully */ | ||||
| if (ni->ni_mlstate != IEEE80211_NODE_MESH_ESTABLISHED) | if (ni->ni_mlstate != IEEE80211_NODE_MESH_ESTABLISHED) | ||||
| return; | return; | ||||
| rssi = vap->iv_ic->ic_node_getrssi(ni); | rssi = vap->iv_ic->ic_node_getrssi(ni); | ||||
| if (rssi != 0) { | if (rssi != 0) { | ||||
| info->rssi_samples++; | info->rssi_samples++; | ||||
| info->rssi_total += rssi; | info->rssi_total += rssi; | ||||
| } | } | ||||
| } | } | ||||
| #endif /* IEEE80211_SUPPORT_MESH */ | #endif /* IEEE80211_SUPPORT_MESH */ | ||||
| int8_t | net80211_rssi_t | ||||
| ieee80211_getrssi(struct ieee80211vap *vap) | ieee80211_getrssi(struct ieee80211vap *vap) | ||||
| { | { | ||||
| #define NZ(x) ((x) == 0 ? 1 : (x)) | #define NZ(x) ((x) == 0 ? 1 : (x)) | ||||
| struct ieee80211com *ic = vap->iv_ic; | struct ieee80211com *ic = vap->iv_ic; | ||||
| struct rssiinfo info; | struct rssiinfo info; | ||||
| info.rssi_total = 0; | info.rssi_total = 0; | ||||
| info.rssi_samples = 0; | info.rssi_samples = 0; | ||||
| Show All 21 Lines | default: | ||||
| info.rssi_samples = 1; | info.rssi_samples = 1; | ||||
| break; | break; | ||||
| } | } | ||||
| return info.rssi_total / NZ(info.rssi_samples); | return info.rssi_total / NZ(info.rssi_samples); | ||||
| #undef NZ | #undef NZ | ||||
| } | } | ||||
| void | void | ||||
| ieee80211_getsignal(struct ieee80211vap *vap, int8_t *rssi, int8_t *noise) | ieee80211_getsignal(struct ieee80211vap *vap, net80211_rssi_t *rssi, int8_t *noise) | ||||
| { | { | ||||
| if (vap->iv_bss == NULL) /* NB: shouldn't happen */ | if (vap->iv_bss == NULL) /* NB: shouldn't happen */ | ||||
| return; | return; | ||||
| vap->iv_ic->ic_node_getsignal(vap->iv_bss, rssi, noise); | vap->iv_ic->ic_node_getsignal(vap->iv_bss, rssi, noise); | ||||
| /* for non-station mode return avg'd rssi accounting */ | /* for non-station mode return avg'd rssi accounting */ | ||||
| if (vap->iv_opmode != IEEE80211_M_STA) | if (vap->iv_opmode != IEEE80211_M_STA) | ||||
| *rssi = ieee80211_getrssi(vap); | *rssi = ieee80211_getrssi(vap); | ||||
| ▲ Show 20 Lines • Show All 228 Lines • Show Last 20 Lines | |||||