1 Index: madwifi-ng-r2420-20070602/ath/if_ath.c
2 ===================================================================
3 --- madwifi-ng-r2420-20070602.orig/ath/if_ath.c 2007-06-04 13:21:56.911324832 +0200
4 +++ madwifi-ng-r2420-20070602/ath/if_ath.c 2007-06-04 13:21:57.500235304 +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 @@ -1048,9 +1047,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 ap's (already got %d)\n", sc->sc_nvaps);
40 if (opmode == IEEE80211_M_MONITOR)
41 dev->type = ARPHRD_IEEE80211_RADIOTAP;
42 - if ((flags & IEEE80211_CLONE_BSSID) &&
43 - sc->sc_nvaps != 0 && opmode != IEEE80211_M_WDS && sc->sc_hasbmask) {
45 + if ((flags & IEEE80211_CLONE_BSSID) && sc->sc_hasbmask &&
46 + (opmode == IEEE80211_M_HOSTAP || opmode == IEEE80211_M_IBSS)) {
47 struct ieee80211vap *v;
48 unsigned int id_mask, id;
50 @@ -1129,18 +1132,22 @@
52 /* do a full search to mark all the allocated VAPs */
54 - TAILQ_FOREACH(v, &ic->ic_vaps, iv_next)
55 - id_mask |= (1 << ATH_GET_VAP_ID(v->iv_myaddr));
56 + TAILQ_FOREACH(v, &ic->ic_vaps, iv_next) {
57 + struct ath_vap *a = (struct ath_vap *) v->iv_dev->priv;
58 + if (a->av_bslot >= 0)
59 + id_mask |= (1 << a->av_bslot);
62 - for (id = 0; id < ATH_BCBUF; id++) {
63 + /* IBSS mode has local always set, so don't hand out beacon slot 0 to an IBSS vap */
64 + for (id = (opmode == IEEE80211_M_IBSS ? 1 : 0); id < ATH_BCBUF; id++) {
65 /* get the first available slot */
66 if ((id_mask & (1 << id)) == 0) {
67 ATH_SET_VAP_BSSID(vap->iv_myaddr, id);
74 STAILQ_INIT(&avp->av_mcastq.axq_q);
75 ATH_TXQ_LOCK_INIT(&avp->av_mcastq);
76 if (opmode == IEEE80211_M_HOSTAP || opmode == IEEE80211_M_IBSS) {
77 @@ -1150,33 +1157,14 @@
79 avp->av_bcbuf = STAILQ_FIRST(&sc->sc_bbuf);
80 STAILQ_REMOVE_HEAD(&sc->sc_bbuf, bf_list);
81 - if (opmode == IEEE80211_M_HOSTAP || !sc->sc_hasveol) {
82 + if ((opmode == IEEE80211_M_IBSS) || (opmode == IEEE80211_M_HOSTAP) || !sc->sc_hasveol) {
85 - * Assign the VAP to a beacon xmit slot. As
86 - * above, this cannot fail to find one.
89 - for (slot = 0; slot < ATH_BCBUF; slot++)
90 - if (sc->sc_bslot[slot] == NULL) {
92 - * XXX hack, space out slots to better
95 - if (slot + 1 < ATH_BCBUF &&
96 - sc->sc_bslot[slot+1] == NULL) {
97 - avp->av_bslot = slot + 1;
100 - avp->av_bslot = slot;
101 - /* NB: keep looking for a double slot */
103 KASSERT(sc->sc_bslot[avp->av_bslot] == NULL,
104 ("beacon slot %u not empty?", avp->av_bslot));
105 sc->sc_bslot[avp->av_bslot] = vap;
108 - if ((opmode == IEEE80211_M_HOSTAP) && (sc->sc_hastsfadd)) {
109 + if ((sc->sc_opmode == IEEE80211_M_HOSTAP) && (sc->sc_hastsfadd)) {
111 * Multiple VAPs are to transmit beacons and we
112 * have h/w support for TSF adjusting; enable use
113 @@ -1286,7 +1274,9 @@
114 sc->sc_stagbeacons = 0;
117 - if (vap->iv_opmode == IEEE80211_M_STA) {
118 + if (vap->iv_opmode == IEEE80211_M_IBSS) {
119 + sc->sc_nibssvaps--;
120 + } else if (vap->iv_opmode == IEEE80211_M_STA) {
122 sc->sc_nostabeacons = 0;
123 } else if (vap->iv_opmode == IEEE80211_M_MONITOR)
124 @@ -3362,7 +3352,7 @@
125 sc->sc_opmode == HAL_M_IBSS || /* NB: AHDEMO too */
126 (sc->sc_nostabeacons) || sc->sc_scanning)
127 rfilt |= HAL_RX_FILTER_BEACON;
128 - if (sc->sc_nmonvaps > 0)
129 + if ((sc->sc_nmonvaps > 0) || ((sc->sc_nvaps > 0) && (sc->sc_nibssvaps > 0)))
130 rfilt |= (HAL_RX_FILTER_CONTROL | HAL_RX_FILTER_BEACON |
131 HAL_RX_FILTER_PROBEREQ | HAL_RX_FILTER_PROM);
133 @@ -5809,12 +5799,20 @@
134 type = ieee80211_input(ni, skb, rs->rs_rssi, rs->rs_tstamp);
135 ieee80211_unref_node(&ni);
137 + const struct ieee80211_frame_min *wh = (const struct ieee80211_frame_min *) skb->data;
139 * No key index or no entry, do a lookup and
140 * add the node to the mapping table if possible.
142 - ni = ieee80211_find_rxnode(ic,
143 - (const struct ieee80211_frame_min *) skb->data);
144 + if (((wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK) == IEEE80211_FC0_SUBTYPE_PROBE_REQ) &&
145 + (sc->sc_nibssvaps > 0))
146 + /* if this is a probe request, send it to all vaps
147 + * when looking up nodes, hostap will be preferred over ibss,
148 + * because ibss will catch all nodes */
151 + ni = ieee80211_find_rxnode(ic, (const struct ieee80211_frame_min *) skb->data);
154 struct ath_node *an = ATH_NODE(ni);
155 ieee80211_keyix_t keyix;
156 Index: madwifi-ng-r2420-20070602/ath/if_athvar.h
157 ===================================================================
158 --- madwifi-ng-r2420-20070602.orig/ath/if_athvar.h 2007-06-04 13:21:56.911324832 +0200
159 +++ madwifi-ng-r2420-20070602/ath/if_athvar.h 2007-06-04 13:21:57.500235304 +0200
161 #define ATH_RXBUF 40 /* number of RX buffers */
162 #define ATH_TXBUF 200 /* number of TX buffers */
164 -#define ATH_BCBUF 4 /* number of beacon buffers */
165 +#define ATH_BCBUF 8 /* number of beacon buffers */
167 /* free buffer threshold to restart net dev */
168 #define ATH_TXBUF_FREE_THRESHOLD (ATH_TXBUF / 20)
170 u_int16_t sc_nvaps; /* # of active virtual ap's */
171 u_int8_t sc_nstavaps; /* # of active station vaps */
172 u_int8_t sc_nmonvaps; /* # of monitor vaps */
173 + u_int8_t sc_nibssvaps; /* # of active ibss vaps */
174 u_int8_t sc_nbcnvaps; /* # of vaps sending beacons */
175 u_int sc_fftxqmin; /* aggregation threshold */
176 HAL_INT sc_imask; /* interrupt mask copy */
177 Index: madwifi-ng-r2420-20070602/net80211/ieee80211_beacon.c
178 ===================================================================
179 --- madwifi-ng-r2420-20070602.orig/net80211/ieee80211_beacon.c 2007-06-04 13:21:53.286875832 +0200
180 +++ madwifi-ng-r2420-20070602/net80211/ieee80211_beacon.c 2007-06-04 13:21:57.501235152 +0200
185 - if (vap->iv_opmode == IEEE80211_M_IBSS) {
186 + if (ic->ic_opmode == IEEE80211_M_IBSS) {
187 *frm++ = IEEE80211_ELEMID_IBSSPARMS;
189 *frm++ = 0; *frm++ = 0; /* TODO: ATIM window */
190 Index: madwifi-ng-r2420-20070602/net80211/ieee80211_input.c
191 ===================================================================
192 --- madwifi-ng-r2420-20070602.orig/net80211/ieee80211_input.c 2007-06-04 13:21:53.292874920 +0200
193 +++ madwifi-ng-r2420-20070602/net80211/ieee80211_input.c 2007-06-04 13:21:57.502235000 +0200
194 @@ -2939,7 +2939,13 @@
197 if (ni == vap->iv_bss) {
198 - if (vap->iv_opmode == IEEE80211_M_IBSS) {
199 + /* this probe request may have been sent to all vaps
200 + * to give each a chance of creating a node for this.
201 + * important for hostap+ibss mode */
202 + ni = ieee80211_find_rxnode(ic, (const struct ieee80211_frame_min *) skb->data);
205 + } else if (vap->iv_opmode == IEEE80211_M_IBSS) {
207 * XXX Cannot tell if the sender is operating
208 * in ibss mode. But we need a new node to
209 @@ -2948,12 +2954,13 @@
211 ni = ieee80211_fakeup_adhoc_node(vap,
215 ni = ieee80211_dup_bss(vap, wh->i_addr2, 1);
223 IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_INPUT, wh->i_addr2,
224 Index: madwifi-ng-r2420-20070602/net80211/ieee80211_node.c
225 ===================================================================
226 --- madwifi-ng-r2420-20070602.orig/net80211/ieee80211_node.c 2007-06-04 13:21:55.391555872 +0200
227 +++ madwifi-ng-r2420-20070602/net80211/ieee80211_node.c 2007-06-04 13:21:57.503234848 +0200
228 @@ -1082,8 +1082,25 @@
229 IEEE80211_NODE_TABLE_LOCK_ASSERT(nt);
231 hash = IEEE80211_NODE_HASH(macaddr);
233 + /* look for non-ibss nodes first */
234 LIST_FOREACH(ni, &nt->nt_hash[hash], ni_hash) {
235 - if (IEEE80211_ADDR_EQ(ni->ni_macaddr, macaddr)) {
236 + if (IEEE80211_ADDR_EQ(ni->ni_macaddr, macaddr) && ni->ni_vap->iv_opmode != IEEE80211_M_IBSS) {
237 + ieee80211_ref_node(ni); /* mark referenced */
238 +#ifdef IEEE80211_DEBUG_REFCNT
239 + IEEE80211_DPRINTF(ni->ni_vap, IEEE80211_MSG_NODE,
240 + "%s (%s:%u) %p<%s> refcnt %d\n", __func__,
242 + ni, ether_sprintf(ni->ni_macaddr),
243 + ieee80211_node_refcnt(ni));
249 + /* now look for ibss nodes */
250 + LIST_FOREACH(ni, &nt->nt_hash[hash], ni_hash) {
251 + if (IEEE80211_ADDR_EQ(ni->ni_macaddr, macaddr) && ni->ni_vap->iv_opmode == IEEE80211_M_IBSS) {
252 ieee80211_ref_node(ni); /* mark referenced */
253 #ifdef IEEE80211_DEBUG_REFCNT
254 IEEE80211_DPRINTF(ni->ni_vap, IEEE80211_MSG_NODE,