From 9baea3e4cad8ada43fa6ccb8936d89ebee824b3a Mon Sep 17 00:00:00 2001 From: Damien Bergamini Date: Mon, 2 Jul 2007 16:46:45 +0000 Subject: initial bits for proper TIM support. --- sys/net80211/ieee80211_output.c | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) (limited to 'sys/net80211/ieee80211_output.c') diff --git a/sys/net80211/ieee80211_output.c b/sys/net80211/ieee80211_output.c index 4e3535c7c49..b3c069ad513 100644 --- a/sys/net80211/ieee80211_output.c +++ b/sys/net80211/ieee80211_output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ieee80211_output.c,v 1.31 2007/07/02 16:19:49 damien Exp $ */ +/* $OpenBSD: ieee80211_output.c,v 1.32 2007/07/02 16:46:44 damien Exp $ */ /* $NetBSD: ieee80211_output.c,v 1.13 2004/05/31 11:02:55 dyoung Exp $ */ /*- @@ -659,6 +659,43 @@ ieee80211_add_erp(u_int8_t *frm, struct ieee80211com *ic) return frm; } +/* + * Add a TIM element to a frame (see Annex L). + */ +u_int8_t * +ieee80211_add_tim(u_int8_t *frm, struct ieee80211com *ic) +{ + u_int i, offset = 0, len; + + /* find first non-zero octet in the virtual bit map */ + for (i = 0; i < ic->ic_tim_len && ic->ic_tim_bitmap[i] == 0; i++); + + /* clear the lsb as it is reserved for the broadcast indication bit */ + if (i < ic->ic_tim_len) + offset = i & ~1; + + /* find last non-zero octet in the virtual bit map */ + for (i = ic->ic_tim_len - 1; i > 0 && ic->ic_tim_bitmap[i] != 0; i--); + + len = i - offset + 1; + + *frm++ = IEEE80211_ELEMID_TIM; + *frm++ = len + 3; /* length */ + *frm++ = ic->ic_dtim_count; /* DTIM count */ + *frm++ = ic->ic_dtim_period; /* DTIM period */ + + /* Bitmap Control */ + *frm = offset; + /* set broadcast/multicast indication bit if necessary */ + if (ic->ic_dtim_count == 0 && ic->ic_tim_mcast) + *frm |= 0x01; + frm++; + + /* Partial Virtual Bitmap */ + memcpy(frm, &ic->ic_tim_bitmap[offset], len); + return frm + len; +} + /* * Add a QoS Capability element to a frame. */ -- cgit v1.2.3