ieee80211_node.c (184205) | ieee80211_node.c (184210) |
---|---|
1/*- 2 * Copyright (c) 2001 Atsushi Onoe 3 * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 11 unchanged lines hidden (view full) --- 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2001 Atsushi Onoe 3 * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 11 unchanged lines hidden (view full) --- 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/sys/net80211/ieee80211_node.c 184205 2008-10-23 15:53:51Z des $"); | 28__FBSDID("$FreeBSD: head/sys/net80211/ieee80211_node.c 184210 2008-10-23 19:57:13Z des $"); |
29 30#include "opt_wlan.h" 31 32#include <sys/param.h> 33#include <sys/systm.h> 34#include <sys/mbuf.h> 35#include <sys/malloc.h> 36#include <sys/kernel.h> --- 106 unchanged lines hidden (view full) --- 143 if (vap->iv_opmode == IEEE80211_M_HOSTAP) { 144 /* XXX should we allow max aid to be zero? */ 145 if (vap->iv_max_aid < IEEE80211_AID_MIN) { 146 vap->iv_max_aid = IEEE80211_AID_MIN; 147 if_printf(vap->iv_ifp, 148 "WARNING: max aid too small, changed to %d\n", 149 vap->iv_max_aid); 150 } | 29 30#include "opt_wlan.h" 31 32#include <sys/param.h> 33#include <sys/systm.h> 34#include <sys/mbuf.h> 35#include <sys/malloc.h> 36#include <sys/kernel.h> --- 106 unchanged lines hidden (view full) --- 143 if (vap->iv_opmode == IEEE80211_M_HOSTAP) { 144 /* XXX should we allow max aid to be zero? */ 145 if (vap->iv_max_aid < IEEE80211_AID_MIN) { 146 vap->iv_max_aid = IEEE80211_AID_MIN; 147 if_printf(vap->iv_ifp, 148 "WARNING: max aid too small, changed to %d\n", 149 vap->iv_max_aid); 150 } |
151 vap->iv_aid_bitmap = malloc( howmany(vap->iv_max_aid, 32) * sizeof(uint32_t), | 151 MALLOC(vap->iv_aid_bitmap, uint32_t *, 152 howmany(vap->iv_max_aid, 32) * sizeof(uint32_t), |
152 M_80211_NODE, M_NOWAIT | M_ZERO); 153 if (vap->iv_aid_bitmap == NULL) { 154 /* XXX no way to recover */ 155 printf("%s: no memory for AID bitmap, max aid %d!\n", 156 __func__, vap->iv_max_aid); 157 vap->iv_max_aid = 0; 158 } 159 } --- 9 unchanged lines hidden (view full) --- 169 struct ieee80211com *ic = vap->iv_ic; 170 171 ieee80211_node_table_reset(&ic->ic_sta, vap); 172 if (vap->iv_bss != NULL) { 173 ieee80211_free_node(vap->iv_bss); 174 vap->iv_bss = NULL; 175 } 176 if (vap->iv_aid_bitmap != NULL) { | 153 M_80211_NODE, M_NOWAIT | M_ZERO); 154 if (vap->iv_aid_bitmap == NULL) { 155 /* XXX no way to recover */ 156 printf("%s: no memory for AID bitmap, max aid %d!\n", 157 __func__, vap->iv_max_aid); 158 vap->iv_max_aid = 0; 159 } 160 } --- 9 unchanged lines hidden (view full) --- 170 struct ieee80211com *ic = vap->iv_ic; 171 172 ieee80211_node_table_reset(&ic->ic_sta, vap); 173 if (vap->iv_bss != NULL) { 174 ieee80211_free_node(vap->iv_bss); 175 vap->iv_bss = NULL; 176 } 177 if (vap->iv_aid_bitmap != NULL) { |
177 free(vap->iv_aid_bitmap, M_80211_NODE); | 178 FREE(vap->iv_aid_bitmap, M_80211_NODE); |
178 vap->iv_aid_bitmap = NULL; 179 } 180} 181 182/* 183 * Port authorize/unauthorize interfaces for use by an authenticator. 184 */ 185 --- 577 unchanged lines hidden (view full) --- 763 ieee80211_free_node(ni); 764} 765 766static struct ieee80211_node * 767node_alloc(struct ieee80211vap *vap, const uint8_t macaddr[IEEE80211_ADDR_LEN]) 768{ 769 struct ieee80211_node *ni; 770 | 179 vap->iv_aid_bitmap = NULL; 180 } 181} 182 183/* 184 * Port authorize/unauthorize interfaces for use by an authenticator. 185 */ 186 --- 577 unchanged lines hidden (view full) --- 764 ieee80211_free_node(ni); 765} 766 767static struct ieee80211_node * 768node_alloc(struct ieee80211vap *vap, const uint8_t macaddr[IEEE80211_ADDR_LEN]) 769{ 770 struct ieee80211_node *ni; 771 |
771 ni = malloc(sizeof(struct ieee80211_node), | 772 MALLOC(ni, struct ieee80211_node *, sizeof(struct ieee80211_node), |
772 M_80211_NODE, M_NOWAIT | M_ZERO); 773 return ni; 774} 775 776/* 777 * Initialize an ie blob with the specified data. If previous 778 * data exists re-use the data block. As a side effect we clear 779 * all references to specific ie's; the caller is required to 780 * recalculate them. 781 */ 782int 783ieee80211_ies_init(struct ieee80211_ies *ies, const uint8_t *data, int len) 784{ 785 /* NB: assumes data+len are the last fields */ 786 memset(ies, 0, offsetof(struct ieee80211_ies, data)); 787 if (ies->data != NULL && ies->len != len) { 788 /* data size changed */ | 773 M_80211_NODE, M_NOWAIT | M_ZERO); 774 return ni; 775} 776 777/* 778 * Initialize an ie blob with the specified data. If previous 779 * data exists re-use the data block. As a side effect we clear 780 * all references to specific ie's; the caller is required to 781 * recalculate them. 782 */ 783int 784ieee80211_ies_init(struct ieee80211_ies *ies, const uint8_t *data, int len) 785{ 786 /* NB: assumes data+len are the last fields */ 787 memset(ies, 0, offsetof(struct ieee80211_ies, data)); 788 if (ies->data != NULL && ies->len != len) { 789 /* data size changed */ |
789 free(ies->data, M_80211_NODE_IE); | 790 FREE(ies->data, M_80211_NODE_IE); |
790 ies->data = NULL; 791 } 792 if (ies->data == NULL) { | 791 ies->data = NULL; 792 } 793 if (ies->data == NULL) { |
793 ies->data = malloc(len, M_80211_NODE_IE, M_NOWAIT); | 794 MALLOC(ies->data, uint8_t *, len, M_80211_NODE_IE, M_NOWAIT); |
794 if (ies->data == NULL) { 795 ies->len = 0; 796 /* NB: pointers have already been zero'd above */ 797 return 0; 798 } 799 } 800 memcpy(ies->data, data, len); 801 ies->len = len; 802 return 1; 803} 804 805/* 806 * Reclaim storage for an ie blob. 807 */ 808void 809ieee80211_ies_cleanup(struct ieee80211_ies *ies) 810{ 811 if (ies->data != NULL) | 795 if (ies->data == NULL) { 796 ies->len = 0; 797 /* NB: pointers have already been zero'd above */ 798 return 0; 799 } 800 } 801 memcpy(ies->data, data, len); 802 ies->len = len; 803 return 1; 804} 805 806/* 807 * Reclaim storage for an ie blob. 808 */ 809void 810ieee80211_ies_cleanup(struct ieee80211_ies *ies) 811{ 812 if (ies->data != NULL) |
812 free(ies->data, M_80211_NODE_IE); | 813 FREE(ies->data, M_80211_NODE_IE); |
813} 814 815/* 816 * Expand an ie blob data contents and to fillin individual 817 * ie pointers. The data blob is assumed to be well-formed; 818 * we don't do any validity checking of ie lengths. 819 */ 820void --- 63 unchanged lines hidden (view full) --- 884 /* 885 * Drain power save queue and, if needed, clear TIM. 886 */ 887 if (ieee80211_node_saveq_drain(ni) != 0 && vap->iv_set_tim != NULL) 888 vap->iv_set_tim(ni, 0); 889 890 ni->ni_associd = 0; 891 if (ni->ni_challenge != NULL) { | 814} 815 816/* 817 * Expand an ie blob data contents and to fillin individual 818 * ie pointers. The data blob is assumed to be well-formed; 819 * we don't do any validity checking of ie lengths. 820 */ 821void --- 63 unchanged lines hidden (view full) --- 885 /* 886 * Drain power save queue and, if needed, clear TIM. 887 */ 888 if (ieee80211_node_saveq_drain(ni) != 0 && vap->iv_set_tim != NULL) 889 vap->iv_set_tim(ni, 0); 890 891 ni->ni_associd = 0; 892 if (ni->ni_challenge != NULL) { |
892 free(ni->ni_challenge, M_80211_NODE); | 893 FREE(ni->ni_challenge, M_80211_NODE); |
893 ni->ni_challenge = NULL; 894 } 895 /* 896 * Preserve SSID, WPA, and WME ie's so the bss node is 897 * reusable during a re-auth/re-assoc state transition. 898 * If we remove these data they will not be recreated 899 * because they come from a probe-response or beacon frame 900 * which cannot be expected prior to the association-response. --- 19 unchanged lines hidden (view full) --- 920node_free(struct ieee80211_node *ni) 921{ 922 struct ieee80211com *ic = ni->ni_ic; 923 924 ic->ic_node_cleanup(ni); 925 ieee80211_ies_cleanup(&ni->ni_ies); 926 IEEE80211_NODE_SAVEQ_DESTROY(ni); 927 IEEE80211_NODE_WDSQ_DESTROY(ni); | 894 ni->ni_challenge = NULL; 895 } 896 /* 897 * Preserve SSID, WPA, and WME ie's so the bss node is 898 * reusable during a re-auth/re-assoc state transition. 899 * If we remove these data they will not be recreated 900 * because they come from a probe-response or beacon frame 901 * which cannot be expected prior to the association-response. --- 19 unchanged lines hidden (view full) --- 921node_free(struct ieee80211_node *ni) 922{ 923 struct ieee80211com *ic = ni->ni_ic; 924 925 ic->ic_node_cleanup(ni); 926 ieee80211_ies_cleanup(&ni->ni_ies); 927 IEEE80211_NODE_SAVEQ_DESTROY(ni); 928 IEEE80211_NODE_WDSQ_DESTROY(ni); |
928 free(ni, M_80211_NODE); | 929 FREE(ni, M_80211_NODE); |
929} 930 931static void 932node_age(struct ieee80211_node *ni) 933{ 934 struct ieee80211vap *vap = ni->ni_vap; 935#if 0 936 IEEE80211_NODE_LOCK_ASSERT(&ic->ic_sta); --- 835 unchanged lines hidden (view full) --- 1772 IEEE80211_NODE_LOCK_INIT(nt, ifp->if_xname); 1773 IEEE80211_NODE_ITERATE_LOCK_INIT(nt, ifp->if_xname); 1774 TAILQ_INIT(&nt->nt_node); 1775 nt->nt_name = name; 1776 nt->nt_scangen = 1; 1777 nt->nt_inact_init = inact; 1778 nt->nt_keyixmax = keyixmax; 1779 if (nt->nt_keyixmax > 0) { | 930} 931 932static void 933node_age(struct ieee80211_node *ni) 934{ 935 struct ieee80211vap *vap = ni->ni_vap; 936#if 0 937 IEEE80211_NODE_LOCK_ASSERT(&ic->ic_sta); --- 835 unchanged lines hidden (view full) --- 1773 IEEE80211_NODE_LOCK_INIT(nt, ifp->if_xname); 1774 IEEE80211_NODE_ITERATE_LOCK_INIT(nt, ifp->if_xname); 1775 TAILQ_INIT(&nt->nt_node); 1776 nt->nt_name = name; 1777 nt->nt_scangen = 1; 1778 nt->nt_inact_init = inact; 1779 nt->nt_keyixmax = keyixmax; 1780 if (nt->nt_keyixmax > 0) { |
1780 nt->nt_keyixmap = malloc( keyixmax * sizeof(struct ieee80211_node *), | 1781 MALLOC(nt->nt_keyixmap, struct ieee80211_node **, 1782 keyixmax * sizeof(struct ieee80211_node *), |
1781 M_80211_NODE, M_NOWAIT | M_ZERO); 1782 if (nt->nt_keyixmap == NULL) 1783 if_printf(ic->ic_ifp, 1784 "Cannot allocate key index map with %u entries\n", 1785 keyixmax); 1786 } else 1787 nt->nt_keyixmap = NULL; 1788} --- 43 unchanged lines hidden (view full) --- 1832#ifdef DIAGNOSTIC 1833 /* XXX verify all entries are NULL */ 1834 int i; 1835 for (i = 0; i < nt->nt_keyixmax; i++) 1836 if (nt->nt_keyixmap[i] != NULL) 1837 printf("%s: %s[%u] still active\n", __func__, 1838 nt->nt_name, i); 1839#endif | 1783 M_80211_NODE, M_NOWAIT | M_ZERO); 1784 if (nt->nt_keyixmap == NULL) 1785 if_printf(ic->ic_ifp, 1786 "Cannot allocate key index map with %u entries\n", 1787 keyixmax); 1788 } else 1789 nt->nt_keyixmap = NULL; 1790} --- 43 unchanged lines hidden (view full) --- 1834#ifdef DIAGNOSTIC 1835 /* XXX verify all entries are NULL */ 1836 int i; 1837 for (i = 0; i < nt->nt_keyixmax; i++) 1838 if (nt->nt_keyixmap[i] != NULL) 1839 printf("%s: %s[%u] still active\n", __func__, 1840 nt->nt_name, i); 1841#endif |
1840 free(nt->nt_keyixmap, M_80211_NODE); | 1842 FREE(nt->nt_keyixmap, M_80211_NODE); |
1841 nt->nt_keyixmap = NULL; 1842 } 1843 IEEE80211_NODE_ITERATE_LOCK_DESTROY(nt); 1844 IEEE80211_NODE_LOCK_DESTROY(nt); 1845} 1846 1847/* 1848 * Timeout inactive stations and do related housekeeping. --- 702 unchanged lines hidden --- | 1843 nt->nt_keyixmap = NULL; 1844 } 1845 IEEE80211_NODE_ITERATE_LOCK_DESTROY(nt); 1846 IEEE80211_NODE_LOCK_DESTROY(nt); 1847} 1848 1849/* 1850 * Timeout inactive stations and do related housekeeping. --- 702 unchanged lines hidden --- |