Deleted Added
full compact
ieee80211_node.c (186144) ieee80211_node.c (186302)
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 186144 2008-12-15 22:50:50Z sam $");
28__FBSDID("$FreeBSD: head/sys/net80211/ieee80211_node.c 186302 2008-12-18 23:00:09Z sam $");
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>

--- 111 unchanged lines hidden (view full) ---

148 if (vap->iv_opmode == IEEE80211_M_HOSTAP) {
149 /* XXX should we allow max aid to be zero? */
150 if (vap->iv_max_aid < IEEE80211_AID_MIN) {
151 vap->iv_max_aid = IEEE80211_AID_MIN;
152 if_printf(vap->iv_ifp,
153 "WARNING: max aid too small, changed to %d\n",
154 vap->iv_max_aid);
155 }
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>

--- 111 unchanged lines hidden (view full) ---

148 if (vap->iv_opmode == IEEE80211_M_HOSTAP) {
149 /* XXX should we allow max aid to be zero? */
150 if (vap->iv_max_aid < IEEE80211_AID_MIN) {
151 vap->iv_max_aid = IEEE80211_AID_MIN;
152 if_printf(vap->iv_ifp,
153 "WARNING: max aid too small, changed to %d\n",
154 vap->iv_max_aid);
155 }
156 MALLOC(vap->iv_aid_bitmap, uint32_t *,
156 vap->iv_aid_bitmap = (uint32_t *) malloc(
157 howmany(vap->iv_max_aid, 32) * sizeof(uint32_t),
158 M_80211_NODE, M_NOWAIT | M_ZERO);
159 if (vap->iv_aid_bitmap == NULL) {
160 /* XXX no way to recover */
161 printf("%s: no memory for AID bitmap, max aid %d!\n",
162 __func__, vap->iv_max_aid);
163 vap->iv_max_aid = 0;
164 }

--- 10 unchanged lines hidden (view full) ---

175 struct ieee80211com *ic = vap->iv_ic;
176
177 ieee80211_node_table_reset(&ic->ic_sta, vap);
178 if (vap->iv_bss != NULL) {
179 ieee80211_free_node(vap->iv_bss);
180 vap->iv_bss = NULL;
181 }
182 if (vap->iv_aid_bitmap != NULL) {
157 howmany(vap->iv_max_aid, 32) * sizeof(uint32_t),
158 M_80211_NODE, M_NOWAIT | M_ZERO);
159 if (vap->iv_aid_bitmap == NULL) {
160 /* XXX no way to recover */
161 printf("%s: no memory for AID bitmap, max aid %d!\n",
162 __func__, vap->iv_max_aid);
163 vap->iv_max_aid = 0;
164 }

--- 10 unchanged lines hidden (view full) ---

175 struct ieee80211com *ic = vap->iv_ic;
176
177 ieee80211_node_table_reset(&ic->ic_sta, vap);
178 if (vap->iv_bss != NULL) {
179 ieee80211_free_node(vap->iv_bss);
180 vap->iv_bss = NULL;
181 }
182 if (vap->iv_aid_bitmap != NULL) {
183 FREE(vap->iv_aid_bitmap, M_80211_NODE);
183 free(vap->iv_aid_bitmap, M_80211_NODE);
184 vap->iv_aid_bitmap = NULL;
185 }
186}
187
188/*
189 * Port authorize/unauthorize interfaces for use by an authenticator.
190 */
191

--- 592 unchanged lines hidden (view full) ---

784 ieee80211_free_node(ni);
785}
786
787static struct ieee80211_node *
788node_alloc(struct ieee80211vap *vap, const uint8_t macaddr[IEEE80211_ADDR_LEN])
789{
790 struct ieee80211_node *ni;
791
184 vap->iv_aid_bitmap = NULL;
185 }
186}
187
188/*
189 * Port authorize/unauthorize interfaces for use by an authenticator.
190 */
191

--- 592 unchanged lines hidden (view full) ---

784 ieee80211_free_node(ni);
785}
786
787static struct ieee80211_node *
788node_alloc(struct ieee80211vap *vap, const uint8_t macaddr[IEEE80211_ADDR_LEN])
789{
790 struct ieee80211_node *ni;
791
792 MALLOC(ni, struct ieee80211_node *, sizeof(struct ieee80211_node),
792 ni = (struct ieee80211_node *) malloc(sizeof(struct ieee80211_node),
793 M_80211_NODE, M_NOWAIT | M_ZERO);
794 return ni;
795}
796
797/*
798 * Initialize an ie blob with the specified data. If previous
799 * data exists re-use the data block. As a side effect we clear
800 * all references to specific ie's; the caller is required to
801 * recalculate them.
802 */
803int
804ieee80211_ies_init(struct ieee80211_ies *ies, const uint8_t *data, int len)
805{
806 /* NB: assumes data+len are the last fields */
807 memset(ies, 0, offsetof(struct ieee80211_ies, data));
808 if (ies->data != NULL && ies->len != len) {
809 /* data size changed */
793 M_80211_NODE, M_NOWAIT | M_ZERO);
794 return ni;
795}
796
797/*
798 * Initialize an ie blob with the specified data. If previous
799 * data exists re-use the data block. As a side effect we clear
800 * all references to specific ie's; the caller is required to
801 * recalculate them.
802 */
803int
804ieee80211_ies_init(struct ieee80211_ies *ies, const uint8_t *data, int len)
805{
806 /* NB: assumes data+len are the last fields */
807 memset(ies, 0, offsetof(struct ieee80211_ies, data));
808 if (ies->data != NULL && ies->len != len) {
809 /* data size changed */
810 FREE(ies->data, M_80211_NODE_IE);
810 free(ies->data, M_80211_NODE_IE);
811 ies->data = NULL;
812 }
813 if (ies->data == NULL) {
811 ies->data = NULL;
812 }
813 if (ies->data == NULL) {
814 MALLOC(ies->data, uint8_t *, len, M_80211_NODE_IE, M_NOWAIT);
814 ies->data = (uint8_t *) malloc(len, M_80211_NODE_IE, M_NOWAIT);
815 if (ies->data == NULL) {
816 ies->len = 0;
817 /* NB: pointers have already been zero'd above */
818 return 0;
819 }
820 }
821 memcpy(ies->data, data, len);
822 ies->len = len;
823 return 1;
824}
825
826/*
827 * Reclaim storage for an ie blob.
828 */
829void
830ieee80211_ies_cleanup(struct ieee80211_ies *ies)
831{
832 if (ies->data != NULL)
815 if (ies->data == NULL) {
816 ies->len = 0;
817 /* NB: pointers have already been zero'd above */
818 return 0;
819 }
820 }
821 memcpy(ies->data, data, len);
822 ies->len = len;
823 return 1;
824}
825
826/*
827 * Reclaim storage for an ie blob.
828 */
829void
830ieee80211_ies_cleanup(struct ieee80211_ies *ies)
831{
832 if (ies->data != NULL)
833 FREE(ies->data, M_80211_NODE_IE);
833 free(ies->data, M_80211_NODE_IE);
834}
835
836/*
837 * Expand an ie blob data contents and to fillin individual
838 * ie pointers. The data blob is assumed to be well-formed;
839 * we don't do any validity checking of ie lengths.
840 */
841void

--- 65 unchanged lines hidden (view full) ---

907 /*
908 * Drain power save queue and, if needed, clear TIM.
909 */
910 if (ieee80211_node_psq_drain(ni) != 0 && vap->iv_set_tim != NULL)
911 vap->iv_set_tim(ni, 0);
912
913 ni->ni_associd = 0;
914 if (ni->ni_challenge != NULL) {
834}
835
836/*
837 * Expand an ie blob data contents and to fillin individual
838 * ie pointers. The data blob is assumed to be well-formed;
839 * we don't do any validity checking of ie lengths.
840 */
841void

--- 65 unchanged lines hidden (view full) ---

907 /*
908 * Drain power save queue and, if needed, clear TIM.
909 */
910 if (ieee80211_node_psq_drain(ni) != 0 && vap->iv_set_tim != NULL)
911 vap->iv_set_tim(ni, 0);
912
913 ni->ni_associd = 0;
914 if (ni->ni_challenge != NULL) {
915 FREE(ni->ni_challenge, M_80211_NODE);
915 free(ni->ni_challenge, M_80211_NODE);
916 ni->ni_challenge = NULL;
917 }
918 /*
919 * Preserve SSID, WPA, and WME ie's so the bss node is
920 * reusable during a re-auth/re-assoc state transition.
921 * If we remove these data they will not be recreated
922 * because they come from a probe-response or beacon frame
923 * which cannot be expected prior to the association-response.

--- 19 unchanged lines hidden (view full) ---

943node_free(struct ieee80211_node *ni)
944{
945 struct ieee80211com *ic = ni->ni_ic;
946
947 ic->ic_node_cleanup(ni);
948 ieee80211_ies_cleanup(&ni->ni_ies);
949 ieee80211_psq_cleanup(&ni->ni_psq);
950 IEEE80211_NODE_WDSQ_DESTROY(ni);
916 ni->ni_challenge = NULL;
917 }
918 /*
919 * Preserve SSID, WPA, and WME ie's so the bss node is
920 * reusable during a re-auth/re-assoc state transition.
921 * If we remove these data they will not be recreated
922 * because they come from a probe-response or beacon frame
923 * which cannot be expected prior to the association-response.

--- 19 unchanged lines hidden (view full) ---

943node_free(struct ieee80211_node *ni)
944{
945 struct ieee80211com *ic = ni->ni_ic;
946
947 ic->ic_node_cleanup(ni);
948 ieee80211_ies_cleanup(&ni->ni_ies);
949 ieee80211_psq_cleanup(&ni->ni_psq);
950 IEEE80211_NODE_WDSQ_DESTROY(ni);
951 FREE(ni, M_80211_NODE);
951 free(ni, M_80211_NODE);
952}
953
954static void
955node_age(struct ieee80211_node *ni)
956{
957 struct ieee80211vap *vap = ni->ni_vap;
958
959 IEEE80211_NODE_LOCK_ASSERT(&vap->iv_ic->ic_sta);

--- 826 unchanged lines hidden (view full) ---

1786 IEEE80211_NODE_LOCK_INIT(nt, ifp->if_xname);
1787 IEEE80211_NODE_ITERATE_LOCK_INIT(nt, ifp->if_xname);
1788 TAILQ_INIT(&nt->nt_node);
1789 nt->nt_name = name;
1790 nt->nt_scangen = 1;
1791 nt->nt_inact_init = inact;
1792 nt->nt_keyixmax = keyixmax;
1793 if (nt->nt_keyixmax > 0) {
952}
953
954static void
955node_age(struct ieee80211_node *ni)
956{
957 struct ieee80211vap *vap = ni->ni_vap;
958
959 IEEE80211_NODE_LOCK_ASSERT(&vap->iv_ic->ic_sta);

--- 826 unchanged lines hidden (view full) ---

1786 IEEE80211_NODE_LOCK_INIT(nt, ifp->if_xname);
1787 IEEE80211_NODE_ITERATE_LOCK_INIT(nt, ifp->if_xname);
1788 TAILQ_INIT(&nt->nt_node);
1789 nt->nt_name = name;
1790 nt->nt_scangen = 1;
1791 nt->nt_inact_init = inact;
1792 nt->nt_keyixmax = keyixmax;
1793 if (nt->nt_keyixmax > 0) {
1794 MALLOC(nt->nt_keyixmap, struct ieee80211_node **,
1794 nt->nt_keyixmap = (struct ieee80211_node **) malloc(
1795 keyixmax * sizeof(struct ieee80211_node *),
1796 M_80211_NODE, M_NOWAIT | M_ZERO);
1797 if (nt->nt_keyixmap == NULL)
1798 if_printf(ic->ic_ifp,
1799 "Cannot allocate key index map with %u entries\n",
1800 keyixmax);
1801 } else
1802 nt->nt_keyixmap = NULL;

--- 44 unchanged lines hidden (view full) ---

1847#ifdef DIAGNOSTIC
1848 /* XXX verify all entries are NULL */
1849 int i;
1850 for (i = 0; i < nt->nt_keyixmax; i++)
1851 if (nt->nt_keyixmap[i] != NULL)
1852 printf("%s: %s[%u] still active\n", __func__,
1853 nt->nt_name, i);
1854#endif
1795 keyixmax * sizeof(struct ieee80211_node *),
1796 M_80211_NODE, M_NOWAIT | M_ZERO);
1797 if (nt->nt_keyixmap == NULL)
1798 if_printf(ic->ic_ifp,
1799 "Cannot allocate key index map with %u entries\n",
1800 keyixmax);
1801 } else
1802 nt->nt_keyixmap = NULL;

--- 44 unchanged lines hidden (view full) ---

1847#ifdef DIAGNOSTIC
1848 /* XXX verify all entries are NULL */
1849 int i;
1850 for (i = 0; i < nt->nt_keyixmax; i++)
1851 if (nt->nt_keyixmap[i] != NULL)
1852 printf("%s: %s[%u] still active\n", __func__,
1853 nt->nt_name, i);
1854#endif
1855 FREE(nt->nt_keyixmap, M_80211_NODE);
1855 free(nt->nt_keyixmap, M_80211_NODE);
1856 nt->nt_keyixmap = NULL;
1857 }
1858 IEEE80211_NODE_ITERATE_LOCK_DESTROY(nt);
1859 IEEE80211_NODE_LOCK_DESTROY(nt);
1860}
1861
1862/*
1863 * Timeout inactive stations and do related housekeeping.

--- 707 unchanged lines hidden ---
1856 nt->nt_keyixmap = NULL;
1857 }
1858 IEEE80211_NODE_ITERATE_LOCK_DESTROY(nt);
1859 IEEE80211_NODE_LOCK_DESTROY(nt);
1860}
1861
1862/*
1863 * Timeout inactive stations and do related housekeeping.

--- 707 unchanged lines hidden ---