ieee80211_crypto_wep.c (184210) | ieee80211_crypto_wep.c (186302) |
---|---|
1/*- 2 * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 10 unchanged lines hidden (view full) --- 19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 10 unchanged lines hidden (view full) --- 19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26#include <sys/cdefs.h> |
27__FBSDID("$FreeBSD: head/sys/net80211/ieee80211_crypto_wep.c 184210 2008-10-23 19:57:13Z des $"); | 27__FBSDID("$FreeBSD: head/sys/net80211/ieee80211_crypto_wep.c 186302 2008-12-18 23:00:09Z sam $"); |
28 29/* 30 * IEEE 802.11 WEP crypto support. 31 */ 32#include "opt_wlan.h" 33 34#include <sys/param.h> 35#include <sys/systm.h> --- 46 unchanged lines hidden (view full) --- 82/* number of references from net80211 layer */ 83static int nrefs = 0; 84 85static void * 86wep_attach(struct ieee80211vap *vap, struct ieee80211_key *k) 87{ 88 struct wep_ctx *ctx; 89 | 28 29/* 30 * IEEE 802.11 WEP crypto support. 31 */ 32#include "opt_wlan.h" 33 34#include <sys/param.h> 35#include <sys/systm.h> --- 46 unchanged lines hidden (view full) --- 82/* number of references from net80211 layer */ 83static int nrefs = 0; 84 85static void * 86wep_attach(struct ieee80211vap *vap, struct ieee80211_key *k) 87{ 88 struct wep_ctx *ctx; 89 |
90 MALLOC(ctx, struct wep_ctx *, sizeof(struct wep_ctx), | 90 ctx = (struct wep_ctx *) malloc(sizeof(struct wep_ctx), |
91 M_80211_CRYPTO, M_NOWAIT | M_ZERO); 92 if (ctx == NULL) { 93 vap->iv_stats.is_crypto_nomem++; 94 return NULL; 95 } 96 97 ctx->wc_vap = vap; 98 ctx->wc_ic = vap->iv_ic; 99 get_random_bytes(&ctx->wc_iv, sizeof(ctx->wc_iv)); 100 nrefs++; /* NB: we assume caller locking */ 101 return ctx; 102} 103 104static void 105wep_detach(struct ieee80211_key *k) 106{ 107 struct wep_ctx *ctx = k->wk_private; 108 | 91 M_80211_CRYPTO, M_NOWAIT | M_ZERO); 92 if (ctx == NULL) { 93 vap->iv_stats.is_crypto_nomem++; 94 return NULL; 95 } 96 97 ctx->wc_vap = vap; 98 ctx->wc_ic = vap->iv_ic; 99 get_random_bytes(&ctx->wc_iv, sizeof(ctx->wc_iv)); 100 nrefs++; /* NB: we assume caller locking */ 101 return ctx; 102} 103 104static void 105wep_detach(struct ieee80211_key *k) 106{ 107 struct wep_ctx *ctx = k->wk_private; 108 |
109 FREE(ctx, M_80211_CRYPTO); | 109 free(ctx, M_80211_CRYPTO); |
110 KASSERT(nrefs > 0, ("imbalanced attach/detach")); 111 nrefs--; /* NB: we assume caller locking */ 112} 113 114static int 115wep_setkey(struct ieee80211_key *k) 116{ 117 return k->wk_keylen >= 40/NBBY; --- 363 unchanged lines hidden --- | 110 KASSERT(nrefs > 0, ("imbalanced attach/detach")); 111 nrefs--; /* NB: we assume caller locking */ 112} 113 114static int 115wep_setkey(struct ieee80211_key *k) 116{ 117 return k->wk_keylen >= 40/NBBY; --- 363 unchanged lines hidden --- |