1 Index: madwifi-ng-r2525-20070630/ath/if_ath.c
2 ===================================================================
3 --- madwifi-ng-r2525-20070630.orig/ath/if_ath.c 2007-07-03 23:02:29.917913500 +0200
4 +++ madwifi-ng-r2525-20070630/ath/if_ath.c 2007-07-03 23:02:30.957978500 +0200
6 * and use the next two bits as the index of the VAP.
8 #define ATH_SET_VAP_BSSID_MASK(bssid_mask) ((bssid_mask)[0] &= ~(((ATH_BCBUF-1)<<2)|0x02))
9 -#define ATH_GET_VAP_ID(bssid) ((bssid)[0] >> 2)
10 #define ATH_SET_VAP_BSSID(bssid, id) \
13 @@ -1055,9 +1054,12 @@
16 case IEEE80211_M_IBSS:
17 - if (sc->sc_nvaps != 0) /* only one */
20 + if (sc->sc_nvaps == 0) /* only one */
23 + ic_opmode = IEEE80211_M_HOSTAP;
27 case IEEE80211_M_AHDEMO:
28 case IEEE80211_M_MONITOR:
33 - if (sc->sc_nvaps >= ATH_BCBUF) {
34 + if (sc->sc_nvaps + sc->sc_nibssvaps >= ATH_BCBUF) {
35 printk(KERN_WARNING "too many virtual APs (already got %d)\n", sc->sc_nvaps);
39 if (opmode == IEEE80211_M_MONITOR)
40 dev->type = ARPHRD_IEEE80211_RADIOTAP;
43 if ((flags & IEEE80211_CLONE_BSSID) &&
44 opmode != IEEE80211_M_WDS && sc->sc_hasbmask) {
45 struct ieee80211vap *v;
46 @@ -1137,18 +1140,22 @@
48 /* do a full search to mark all the allocated VAPs */
50 - TAILQ_FOREACH(v, &ic->ic_vaps, iv_next)
51 - id_mask |= (1 << ATH_GET_VAP_ID(v->iv_myaddr));
52 + TAILQ_FOREACH(v, &ic->ic_vaps, iv_next) {
53 + struct ath_vap *a = (struct ath_vap *) v->iv_dev->priv;
54 + if (a->av_bslot >= 0)
55 + id_mask |= (1 << a->av_bslot);
58 - for (id = 1; id < ATH_BCBUF; id++) {
59 + /* IBSS mode has local always set, so don't hand out beacon slot 0 to an IBSS vap */
60 + for (id = (opmode == IEEE80211_M_IBSS ? 1 : 0); id < ATH_BCBUF; id++) {
61 /* get the first available slot */
62 if ((id_mask & (1 << id)) == 0) {
63 ATH_SET_VAP_BSSID(vap->iv_myaddr, id);
70 STAILQ_INIT(&avp->av_mcastq.axq_q);
71 ATH_TXQ_LOCK_INIT(&avp->av_mcastq);
72 if (opmode == IEEE80211_M_HOSTAP || opmode == IEEE80211_M_IBSS) {
73 @@ -1158,33 +1165,14 @@
75 avp->av_bcbuf = STAILQ_FIRST(&sc->sc_bbuf);
76 STAILQ_REMOVE_HEAD(&sc->sc_bbuf, bf_list);
77 - if (opmode == IEEE80211_M_HOSTAP || !sc->sc_hasveol) {
78 + if ((opmode == IEEE80211_M_IBSS) || (opmode == IEEE80211_M_HOSTAP) || !sc->sc_hasveol) {
81 - * Assign the VAP to a beacon xmit slot. As
82 - * above, this cannot fail to find one.
85 - for (slot = 0; slot < ATH_BCBUF; slot++)
86 - if (sc->sc_bslot[slot] == NULL) {
88 - * XXX hack, space out slots to better
91 - if (slot + 1 < ATH_BCBUF &&
92 - sc->sc_bslot[slot+1] == NULL) {
93 - avp->av_bslot = slot + 1;
96 - avp->av_bslot = slot;
97 - /* NB: keep looking for a double slot */
99 KASSERT(sc->sc_bslot[avp->av_bslot] == NULL,
100 ("beacon slot %u not empty?", avp->av_bslot));
101 sc->sc_bslot[avp->av_bslot] = vap;
104 - if ((opmode == IEEE80211_M_HOSTAP) && (sc->sc_hastsfadd)) {
105 + if ((sc->sc_opmode == IEEE80211_M_HOSTAP) && (sc->sc_hastsfadd)) {
107 * Multiple VAPs are to transmit beacons and we
108 * have h/w support for TSF adjusting; enable use
109 @@ -1294,7 +1282,9 @@
110 sc->sc_stagbeacons = 0;
113 - if (vap->iv_opmode == IEEE80211_M_STA) {
114 + if (vap->iv_opmode == IEEE80211_M_IBSS) {
115 + sc->sc_nibssvaps--;
116 + } else if (vap->iv_opmode == IEEE80211_M_STA) {
118 sc->sc_nostabeacons = 0;
119 } else if (vap->iv_opmode == IEEE80211_M_MONITOR)
120 @@ -3390,7 +3380,7 @@
121 sc->sc_opmode == HAL_M_IBSS || /* NB: AHDEMO too */
122 (sc->sc_nostabeacons) || sc->sc_scanning)
123 rfilt |= HAL_RX_FILTER_BEACON;
124 - if (sc->sc_nmonvaps > 0)
125 + if ((sc->sc_nmonvaps > 0) || ((sc->sc_nvaps > 0) && (sc->sc_nibssvaps > 0)))
126 rfilt |= (HAL_RX_FILTER_CONTROL | HAL_RX_FILTER_BEACON |
127 HAL_RX_FILTER_PROBEREQ | HAL_RX_FILTER_PROM);
129 @@ -5837,12 +5827,20 @@
130 type = ieee80211_input(ni, skb, rs->rs_rssi, rs_tsf);
131 ieee80211_unref_node(&ni);
133 + const struct ieee80211_frame_min *wh = (const struct ieee80211_frame_min *) skb->data;
135 * No key index or no entry, do a lookup and
136 * add the node to the mapping table if possible.
138 - ni = ieee80211_find_rxnode(ic,
139 - (const struct ieee80211_frame_min *) skb->data);
140 + if (((wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK) == IEEE80211_FC0_SUBTYPE_PROBE_REQ) &&
141 + (sc->sc_nibssvaps > 0))
142 + /* if this is a probe request, send it to all vaps
143 + * when looking up nodes, hostap will be preferred over ibss,
144 + * because ibss will catch all nodes */
147 + ni = ieee80211_find_rxnode(ic, (const struct ieee80211_frame_min *) skb->data);
150 struct ath_node *an = ATH_NODE(ni);
151 ieee80211_keyix_t keyix;
152 Index: madwifi-ng-r2525-20070630/ath/if_athvar.h
153 ===================================================================
154 --- madwifi-ng-r2525-20070630.orig/ath/if_athvar.h 2007-07-03 23:02:29.917913500 +0200
155 +++ madwifi-ng-r2525-20070630/ath/if_athvar.h 2007-07-03 23:02:30.957978500 +0200
157 #define ATH_RXBUF 40 /* number of RX buffers */
158 #define ATH_TXBUF 200 /* number of TX buffers */
160 -#define ATH_BCBUF 4 /* number of beacon buffers */
161 +#define ATH_BCBUF 8 /* number of beacon buffers */
163 /* free buffer threshold to restart net dev */
164 #define ATH_TXBUF_FREE_THRESHOLD (ATH_TXBUF / 20)
166 u_int16_t sc_nvaps; /* # of active virtual APs */
167 u_int8_t sc_nstavaps; /* # of active station VAPs */
168 u_int8_t sc_nmonvaps; /* # of monitor VAPs */
169 + u_int8_t sc_nibssvaps; /* # of active ibss vaps */
170 u_int8_t sc_nbcnvaps; /* # of vaps sending beacons */
171 u_int sc_fftxqmin; /* aggregation threshold */
172 HAL_INT sc_imask; /* interrupt mask copy */
173 Index: madwifi-ng-r2525-20070630/net80211/ieee80211_beacon.c
174 ===================================================================
175 --- madwifi-ng-r2525-20070630.orig/net80211/ieee80211_beacon.c 2007-07-03 23:02:25.413632000 +0200
176 +++ madwifi-ng-r2525-20070630/net80211/ieee80211_beacon.c 2007-07-03 23:02:30.981980000 +0200
181 - if (vap->iv_opmode == IEEE80211_M_IBSS) {
182 + if (ic->ic_opmode == IEEE80211_M_IBSS) {
183 *frm++ = IEEE80211_ELEMID_IBSSPARMS;
185 *frm++ = 0; *frm++ = 0; /* TODO: ATIM window */
186 Index: madwifi-ng-r2525-20070630/net80211/ieee80211_input.c
187 ===================================================================
188 --- madwifi-ng-r2525-20070630.orig/net80211/ieee80211_input.c 2007-07-03 23:02:25.421632500 +0200
189 +++ madwifi-ng-r2525-20070630/net80211/ieee80211_input.c 2007-07-03 23:02:31.005981500 +0200
190 @@ -2980,7 +2980,13 @@
193 if (ni == vap->iv_bss) {
194 - if (vap->iv_opmode == IEEE80211_M_IBSS) {
195 + /* this probe request may have been sent to all vaps
196 + * to give each a chance of creating a node for this.
197 + * important for hostap+ibss mode */
198 + ni = ieee80211_find_rxnode(ic, (const struct ieee80211_frame_min *) skb->data);
201 + } else if (vap->iv_opmode == IEEE80211_M_IBSS) {
203 * XXX Cannot tell if the sender is operating
204 * in ibss mode. But we need a new node to
205 @@ -2989,12 +2995,13 @@
207 ni = ieee80211_fakeup_adhoc_node(vap,
211 ni = ieee80211_dup_bss(vap, wh->i_addr2, 1);
219 IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_INPUT, wh->i_addr2,
220 Index: madwifi-ng-r2525-20070630/net80211/ieee80211_node.c
221 ===================================================================
222 --- madwifi-ng-r2525-20070630.orig/net80211/ieee80211_node.c 2007-07-03 23:02:29.073860750 +0200
223 +++ madwifi-ng-r2525-20070630/net80211/ieee80211_node.c 2007-07-03 23:02:31.037983500 +0200
224 @@ -1084,8 +1084,25 @@
225 IEEE80211_NODE_TABLE_LOCK_ASSERT(nt);
227 hash = IEEE80211_NODE_HASH(macaddr);
229 + /* look for non-ibss nodes first */
230 + LIST_FOREACH(ni, &nt->nt_hash[hash], ni_hash) {
231 + if (IEEE80211_ADDR_EQ(ni->ni_macaddr, macaddr) && ni->ni_vap->iv_opmode != IEEE80211_M_IBSS) {
232 + ieee80211_ref_node(ni); /* mark referenced */
233 +#ifdef IEEE80211_DEBUG_REFCNT
234 + IEEE80211_DPRINTF(ni->ni_vap, IEEE80211_MSG_NODE,
235 + "%s (%s:%u) %p<%s> refcnt %d\n", __func__,
237 + ni, ether_sprintf(ni->ni_macaddr),
238 + ieee80211_node_refcnt(ni));
244 + /* now look for ibss nodes */
245 LIST_FOREACH(ni, &nt->nt_hash[hash], ni_hash) {
246 - if (IEEE80211_ADDR_EQ(ni->ni_macaddr, macaddr)) {
247 + if (IEEE80211_ADDR_EQ(ni->ni_macaddr, macaddr) && ni->ni_vap->iv_opmode == IEEE80211_M_IBSS) {
248 ieee80211_ref_node(ni); /* mark referenced */
249 #ifdef IEEE80211_DEBUG_REFCNT
250 IEEE80211_DPRINTF(ni->ni_vap, IEEE80211_MSG_NODE,