Deleted Added
full compact
ieee80211_adhoc.c (184480) ieee80211_adhoc.c (186904)
1/*-
1/*-
2 * Copyright (c) 2007-2008 Sam Leffler, Errno Consulting
2 * Copyright (c) 2007-2009 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
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright

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

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#ifdef __FreeBSD__
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
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright

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

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#ifdef __FreeBSD__
28__FBSDID("$FreeBSD: head/sys/net80211/ieee80211_adhoc.c 184480 2008-10-30 16:22:04Z sam $");
28__FBSDID("$FreeBSD: head/sys/net80211/ieee80211_adhoc.c 186904 2009-01-08 17:12:47Z sam $");
29#endif
30
31/*
32 * IEEE 802.11 IBSS mode support.
33 */
34#include "opt_inet.h"
35#include "opt_wlan.h"
36

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

52#include <net/if_llc.h>
53#include <net/ethernet.h>
54
55#include <net/bpf.h>
56
57#include <net80211/ieee80211_var.h>
58#include <net80211/ieee80211_adhoc.h>
59#include <net80211/ieee80211_input.h>
29#endif
30
31/*
32 * IEEE 802.11 IBSS mode support.
33 */
34#include "opt_inet.h"
35#include "opt_wlan.h"
36

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

52#include <net/if_llc.h>
53#include <net/ethernet.h>
54
55#include <net/bpf.h>
56
57#include <net80211/ieee80211_var.h>
58#include <net80211/ieee80211_adhoc.h>
59#include <net80211/ieee80211_input.h>
60#ifdef IEEE80211_SUPPORT_TDMA
61#include <net80211/ieee80211_tdma.h>
62#endif
60
61#define IEEE80211_RATE2MBS(r) (((r) & IEEE80211_RATE_VAL) / 2)
62
63static void adhoc_vattach(struct ieee80211vap *);
64static int adhoc_newstate(struct ieee80211vap *, enum ieee80211_state, int);
65static int adhoc_input(struct ieee80211_node *, struct mbuf *,
66 int rssi, int noise, uint32_t rstamp);
67static void adhoc_recv_mgmt(struct ieee80211_node *, struct mbuf *,

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

91{
92 vap->iv_newstate = adhoc_newstate;
93 vap->iv_input = adhoc_input;
94 if (vap->iv_opmode == IEEE80211_M_IBSS)
95 vap->iv_recv_mgmt = adhoc_recv_mgmt;
96 else
97 vap->iv_recv_mgmt = ahdemo_recv_mgmt;
98 vap->iv_opdetach = adhoc_vdetach;
63
64#define IEEE80211_RATE2MBS(r) (((r) & IEEE80211_RATE_VAL) / 2)
65
66static void adhoc_vattach(struct ieee80211vap *);
67static int adhoc_newstate(struct ieee80211vap *, enum ieee80211_state, int);
68static int adhoc_input(struct ieee80211_node *, struct mbuf *,
69 int rssi, int noise, uint32_t rstamp);
70static void adhoc_recv_mgmt(struct ieee80211_node *, struct mbuf *,

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

94{
95 vap->iv_newstate = adhoc_newstate;
96 vap->iv_input = adhoc_input;
97 if (vap->iv_opmode == IEEE80211_M_IBSS)
98 vap->iv_recv_mgmt = adhoc_recv_mgmt;
99 else
100 vap->iv_recv_mgmt = ahdemo_recv_mgmt;
101 vap->iv_opdetach = adhoc_vdetach;
102#ifdef IEEE80211_SUPPORT_TDMA
103 /*
104 * Throw control to tdma support. Note we do this
105 * after setting up our callbacks so it can piggyback
106 * on top of us.
107 */
108 if (vap->iv_caps & IEEE80211_C_TDMA)
109 ieee80211_tdma_vattach(vap);
110#endif
99}
100
101/*
102 * IEEE80211_M_IBSS+IEEE80211_M_AHDEMO vap state machine handler.
103 */
104static int
105adhoc_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
106{

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

350 /*
351 * Data frame, cons up a node when it doesn't
352 * exist. This should probably done after an ACL check.
353 */
354 if (type == IEEE80211_FC0_TYPE_DATA &&
355 ni == vap->iv_bss &&
356 !IEEE80211_ADDR_EQ(wh->i_addr2, ni->ni_macaddr)) {
357 /*
111}
112
113/*
114 * IEEE80211_M_IBSS+IEEE80211_M_AHDEMO vap state machine handler.
115 */
116static int
117adhoc_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
118{

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

362 /*
363 * Data frame, cons up a node when it doesn't
364 * exist. This should probably done after an ACL check.
365 */
366 if (type == IEEE80211_FC0_TYPE_DATA &&
367 ni == vap->iv_bss &&
368 !IEEE80211_ADDR_EQ(wh->i_addr2, ni->ni_macaddr)) {
369 /*
370 * Beware of frames that come in too early; we
371 * can receive broadcast frames and creating sta
372 * entries will blow up because there is no bss
373 * channel yet.
374 */
375 if (vap->iv_state != IEEE80211_S_RUN) {
376 IEEE80211_DISCARD(vap, IEEE80211_MSG_INPUT,
377 wh, "data", "not in RUN state (%s)",
378 ieee80211_state_name[vap->iv_state]);
379 vap->iv_stats.is_rx_badstate++;
380 goto err;
381 }
382 /*
358 * Fake up a node for this newly
359 * discovered member of the IBSS.
360 */
361 ni = ieee80211_fakeup_adhoc_node(vap, wh->i_addr2);
362 if (ni == NULL) {
363 /* NB: stat kept for alloc failure */
364 goto err;
365 }

--- 540 unchanged lines hidden ---
383 * Fake up a node for this newly
384 * discovered member of the IBSS.
385 */
386 ni = ieee80211_fakeup_adhoc_node(vap, wh->i_addr2);
387 if (ni == NULL) {
388 /* NB: stat kept for alloc failure */
389 goto err;
390 }

--- 540 unchanged lines hidden ---