summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/net80211/ieee80211.h6
-rw-r--r--sys/net80211/ieee80211_output.c46
-rw-r--r--sys/net80211/ieee80211_proto.h4
3 files changed, 35 insertions, 21 deletions
diff --git a/sys/net80211/ieee80211.h b/sys/net80211/ieee80211.h
index d8f80a7e849..c58e06aa7d7 100644
--- a/sys/net80211/ieee80211.h
+++ b/sys/net80211/ieee80211.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ieee80211.h,v 1.3 2004/12/23 11:54:08 jsg Exp $ */
+/* $OpenBSD: ieee80211.h,v 1.4 2004/12/23 12:27:25 jsg Exp $ */
/* $NetBSD: ieee80211.h,v 1.6 2004/04/30 23:51:53 dyoung Exp $ */
/*-
@@ -565,8 +565,12 @@ struct ieee80211_duration {
/* IEEE 802.11b durations for DSSS PHY in microseconds */
#define IEEE80211_DUR_DS_LONG_PREAMBLE 144
#define IEEE80211_DUR_DS_SHORT_PREAMBLE 72
+#define IEEE80211_DUR_DS_PREAMBLE_DIFFERENCE \
+ (IEEE80211_DUR_DS_LONG_PREAMBLE - IEEE80211_DUR_DS_SHORT_PREAMBLE)
#define IEEE80211_DUR_DS_FAST_PLCPHDR 24
#define IEEE80211_DUR_DS_SLOW_PLCPHDR 48
+#define IEEE80211_DUR_DS_PLCPHDR_DIFFERENCE \
+ (IEEE80211_DUR_DS_SLOW_PLCPHDR - IEEE80211_DUR_DS_FAST_PLCPHDR)
#define IEEE80211_DUR_DS_SLOW_ACK 112
#define IEEE80211_DUR_DS_FAST_ACK 56
#define IEEE80211_DUR_DS_SLOW_CTS 112
diff --git a/sys/net80211/ieee80211_output.c b/sys/net80211/ieee80211_output.c
index 0334d0aeb77..9ba36cb708c 100644
--- a/sys/net80211/ieee80211_output.c
+++ b/sys/net80211/ieee80211_output.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ieee80211_output.c,v 1.2 2004/12/23 11:54:09 jsg Exp $ */
+/* $OpenBSD: ieee80211_output.c,v 1.3 2004/12/23 12:27:25 jsg Exp $ */
/* $NetBSD: ieee80211_output.c,v 1.13 2004/05/31 11:02:55 dyoung Exp $ */
/*-
@@ -329,26 +329,27 @@ ieee80211_compute_duration1(int len, uint32_t flags, int rate,
return -1;
}
+ d->d_plcp_len = data_dur;
+
d->d_rts_dur = data_dur + 3 * (IEEE80211_DUR_DS_SIFS +
IEEE80211_DUR_DS_SHORT_PREAMBLE +
IEEE80211_DUR_DS_FAST_PLCPHDR) + cts + ack;
- d->d_data_dur = data_dur + IEEE80211_DUR_DS_SIFS +
- 2 * (IEEE80211_DUR_DS_SHORT_PREAMBLE +
- IEEE80211_DUR_DS_FAST_PLCPHDR) + ack;
- d->d_plcp_len = data_dur;
+ /* Note that this is the amount of time reserved *after*
+ * the packet is transmitted: just long enough for a SIFS
+ * and an ACK.
+ */
+ d->d_data_dur = IEEE80211_DUR_DS_SIFS +
+ IEEE80211_DUR_DS_SHORT_PREAMBLE + IEEE80211_DUR_DS_FAST_PLCPHDR +
+ ack;
if ((flags & IEEE80211_F_SHPREAMBLE) != 0)
return 0;
- d->d_rts_dur += 3 * (IEEE80211_DUR_DS_LONG_PREAMBLE -
- IEEE80211_DUR_DS_SHORT_PREAMBLE) +
- 3 * (IEEE80211_DUR_DS_SLOW_PLCPHDR -
- IEEE80211_DUR_DS_FAST_PLCPHDR);
- d->d_data_dur += 2 * (IEEE80211_DUR_DS_LONG_PREAMBLE -
- IEEE80211_DUR_DS_SHORT_PREAMBLE) +
- 2 * (IEEE80211_DUR_DS_SLOW_PLCPHDR -
- IEEE80211_DUR_DS_FAST_PLCPHDR);
+ d->d_rts_dur += 3 * IEEE80211_DUR_DS_PREAMBLE_DIFFERENCE +
+ 3 * IEEE80211_DUR_DS_PLCPHDR_DIFFERENCE;
+ d->d_data_dur += IEEE80211_DUR_DS_PREAMBLE_DIFFERENCE +
+ IEEE80211_DUR_DS_PLCPHDR_DIFFERENCE;
return 0;
}
@@ -357,7 +358,7 @@ ieee80211_compute_duration1(int len, uint32_t flags, int rate,
*
* wh: 802.11 header
*
- * paylen: payload length (no FCS, no WEP header)
+ * len: packet length
*
* rate: MSDU speed, units 500kb/s
*
@@ -377,18 +378,20 @@ ieee80211_compute_duration1(int len, uint32_t flags, int rate,
* of first/only fragment
*/
int
-ieee80211_compute_duration(struct ieee80211_frame *wh, int paylen,
+ieee80211_compute_duration(struct ieee80211_frame *wh, int len,
uint32_t flags, int fraglen, int rate, struct ieee80211_duration *d0,
- struct ieee80211_duration *dn, int *npktp)
+ struct ieee80211_duration *dn, int *npktp, int debug)
{
int rc;
- int firstlen, hdrlen, lastlen, lastlen0, npkt, overlen;
+ int firstlen, hdrlen, lastlen, lastlen0, npkt, overlen, paylen;
if ((wh->i_fc[1] & IEEE80211_FC1_DIR_MASK) == IEEE80211_FC1_DIR_DSTODS)
hdrlen = sizeof(struct ieee80211_frame_addr4);
else
hdrlen = sizeof(struct ieee80211_frame);
+ paylen = len - hdrlen;
+
if ((flags & IEEE80211_F_WEPON) != 0) {
overlen = IEEE80211_WEP_TOTLEN + IEEE80211_CRC_LEN;
#if 0 /* 802.11 lets us extend a fragment's length by the length of
@@ -424,10 +427,17 @@ ieee80211_compute_duration(struct ieee80211_frame *wh, int paylen,
else
firstlen = paylen + overlen;
+ if (debug) {
+ printf("%s: npkt %d firstlen %d lastlen0 %d lastlen %d "
+ "fraglen %d overlen %d len %d rate %d flags %08x\n",
+ __func__, npkt, firstlen, lastlen0, lastlen, fraglen,
+ overlen, len, rate, flags);
+ }
rc = ieee80211_compute_duration1(firstlen + hdrlen, flags, rate, d0);
if (rc == -1)
return rc;
- if (npkt > 1) {
+
+ if (npkt <= 1) {
*dn = *d0;
return 0;
}
diff --git a/sys/net80211/ieee80211_proto.h b/sys/net80211/ieee80211_proto.h
index 384779987c9..3ef2136ee35 100644
--- a/sys/net80211/ieee80211_proto.h
+++ b/sys/net80211/ieee80211_proto.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ieee80211_proto.h,v 1.3 2004/12/23 11:54:09 jsg Exp $ */
+/* $OpenBSD: ieee80211_proto.h,v 1.4 2004/12/23 12:27:25 jsg Exp $ */
/* $NetBSD: ieee80211_proto.h,v 1.3 2003/10/13 04:23:56 dyoung Exp $ */
/*-
@@ -82,7 +82,7 @@ extern int ieee80211_ibss_merge(struct ieee80211com *,
struct ieee80211_node *, u_int64_t);
extern int ieee80211_compute_duration(struct ieee80211_frame *, int,
uint32_t, int, int, struct ieee80211_duration *,
- struct ieee80211_duration *, int *);
+ struct ieee80211_duration *, int *, int);
extern const char *ieee80211_state_name[IEEE80211_S_MAX];
#endif /* _NET80211_IEEE80211_PROTO_H_ */