From: Ivo v. D. <iv...@gm...> - 2005-07-23 16:39:40
|
Hi, This patch adds support for the creation of RTS packets when the config fla= g=20 CFG_IEEE80211_RTS has been set. Patch is against ieee80211 1.0.3. Signed-Off-By: Ivo van Doorn <Iv...@gm...> IvD diff -U 3 -H -w -E -d -r -N -- ieee80211-1.0.3/ieee80211_module.c=20 ieee80211-1.0.3-rts/ieee80211_module.c =2D-- ieee80211-1.0.3/ieee80211_module.c 2005-07-15 01:53:35.000000000 +0200 +++ ieee80211-1.0.3-rts/ieee80211_module.c 2005-07-19 16:47:37.000000000 +0= 200 @@ -131,6 +131,7 @@ =20 /* Default fragmentation threshold is maximum payload size */ ieee->fts =3D DEFAULT_FTS; + ieee->rts =3D DEFAULT_FTS; ieee->scan_age =3D DEFAULT_MAX_SCAN_AGE; ieee->open_wep =3D 1; =20 diff -U 3 -H -w -E -d -r -N -- ieee80211-1.0.3/ieee80211_tx.c=20 ieee80211-1.0.3-rts/ieee80211_tx.c =2D-- ieee80211-1.0.3/ieee80211_tx.c 2005-07-15 01:53:35.000000000 +0200 +++ ieee80211-1.0.3-rts/ieee80211_tx.c 2005-07-19 16:47:37.000000000 +0200 @@ -244,7 +244,7 @@ struct ieee80211_device *ieee =3D netdev_priv(dev); struct ieee80211_txb *txb =3D NULL; struct ieee80211_hdr *frag_hdr; =2D int i, bytes_per_frag, nr_frags, bytes_last_frag, frag_size; + int i, bytes_per_frag, nr_frags, bytes_last_frag, frag_size, rts_required; unsigned long flags; struct net_device_stats *stats =3D &ieee->stats; int ether_type, encrypt, host_encrypt, host_encrypt_msdu; @@ -399,6 +399,10 @@ frag_size =3D bytes + IEEE80211_3ADDR_LEN; } =20 + rts_required =3D (frag_size > ieee->rts && ieee->config & CFG_IEEE80211_R= TS); + if (rts_required) + nr_frags++; + /* When we allocate the TXB we allocate enough space for the reserve * and full fragment bytes (bytes_per_frag doesn't include prefix, * postfix, header, FCS, etc.) */ @@ -414,7 +418,31 @@ else txb->payload_size =3D bytes; =20 =2D for (i =3D 0; i < nr_frags; i++) { + i =3D 0; + if (rts_required) { + skb_frag =3D txb->fragments[i]; + frag_hdr =3D (struct ieee80211_hdr *)skb_put(skb_frag, hdr_len); + + /* + * Set header frame_ctl to the RTS. + */ + header.frame_ctl =3D cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_R= TS); + memcpy(frag_hdr, &header, hdr_len); + + /* + * Restore header frame_ctl to the original data setting. + */ + header.frame_ctl =3D cpu_to_le16(fc); + + if (ieee->config & + (CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS)) + skb_put(skb_frag, 4); + + txb->rts_included =3D 1; + i =3D 1; + } + + for (; i < nr_frags; i++) { skb_frag =3D txb->fragments[i]; =20 if (host_encrypt) diff -U 3 -H -w -E -d -r -N -- ieee80211-1.0.3/net/ieee80211.h=20 ieee80211-1.0.3-rts/net/ieee80211.h =2D-- ieee80211-1.0.3/net/ieee80211.h 2005-07-15 01:53:35.000000000 +0200 +++ ieee80211-1.0.3-rts/net/ieee80211.h 2005-07-19 16:47:37.000000000 +0200 @@ -584,7 +584,8 @@ struct ieee80211_txb { u8 nr_frags; u8 encrypted; =2D u16 reserved; + u8 rts_included; + u8 reserved; u16 frag_size; u16 payload_size; struct sk_buff *fragments[0]; @@ -723,6 +724,7 @@ =20 #define CFG_IEEE80211_RESERVE_FCS (1<<0) #define CFG_IEEE80211_COMPUTE_FCS (1<<1) +#define CFG_IEEE80211_RTS (1<<2) =20 #define IEEE80211_24GHZ_MIN_FREQ 2412 #define IEEE80211_24GHZ_MAX_FREQ 2477 @@ -821,6 +823,7 @@ struct ieee80211_frag_entry frag_cache[IEEE80211_FRAG_CACHE_LEN]; unsigned int frag_next_idx; u16 fts; /* Fragmentation Threshold */ + u16 rts; /* RTS threshold */ =20 /* Association info */ u8 bssid[ETH_ALEN]; |