summaryrefslogtreecommitdiff
path: root/sys/net80211/ieee80211_output.c
diff options
context:
space:
mode:
authorDamien Bergamini <damien@cvs.openbsd.org>2006-11-03 19:02:09 +0000
committerDamien Bergamini <damien@cvs.openbsd.org>2006-11-03 19:02:09 +0000
commit05ae39297525fdf87aa8234c6f43d2e5a016f565 (patch)
tree9c61f911b80104c48336421f91750fb72022debe /sys/net80211/ieee80211_output.c
parent7bf603f47a27a8de5f7b6c045fa3fba86b3265ab (diff)
Add two new functions:
- ieee80211_get_rts - ieee80211_get_cts_to_self that can be use by drivers for chipsets that don't offer hardware assisted RTS/CTS protection (like ral/ural/rum). "no objections here" jsg@
Diffstat (limited to 'sys/net80211/ieee80211_output.c')
-rw-r--r--sys/net80211/ieee80211_output.c56
1 files changed, 55 insertions, 1 deletions
diff --git a/sys/net80211/ieee80211_output.c b/sys/net80211/ieee80211_output.c
index a90f55453fc..2965b623364 100644
--- a/sys/net80211/ieee80211_output.c
+++ b/sys/net80211/ieee80211_output.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ieee80211_output.c,v 1.21 2006/06/27 20:55:51 reyk Exp $ */
+/* $OpenBSD: ieee80211_output.c,v 1.22 2006/11/03 19:02:08 damien Exp $ */
/* $NetBSD: ieee80211_output.c,v 1.13 2004/05/31 11:02:55 dyoung Exp $ */
/*-
@@ -929,6 +929,60 @@ bad:
#undef senderr
}
+/*
+ * Build a RTS (Request To Send) control frame.
+ */
+struct mbuf *
+ieee80211_get_rts(struct ieee80211com *ic, const struct ieee80211_frame *wh,
+ u_int16_t dur)
+{
+ struct ieee80211_frame_rts *rts;
+ struct mbuf *m;
+
+ MGETHDR(m, M_DONTWAIT, MT_DATA);
+ if (m == NULL) {
+ ic->ic_stats.is_tx_nombuf++;
+ return NULL;
+ }
+ m->m_pkthdr.len = m->m_len = sizeof (struct ieee80211_frame_rts);
+
+ rts = mtod(m, struct ieee80211_frame_rts *);
+ rts->i_fc[0] = IEEE80211_FC0_VERSION_0 | IEEE80211_FC0_TYPE_CTL |
+ IEEE80211_FC0_SUBTYPE_RTS;
+ rts->i_fc[1] = IEEE80211_FC1_DIR_NODS;
+ *(uint16_t *)rts->i_dur = htole16(dur);
+ IEEE80211_ADDR_COPY(rts->i_ra, wh->i_addr1);
+ IEEE80211_ADDR_COPY(rts->i_ta, wh->i_addr2);
+
+ return m;
+}
+
+/*
+ * Build a CTS-to-self (Clear To Send) control frame.
+ */
+struct mbuf *
+ieee80211_get_cts_to_self(struct ieee80211com *ic, u_int16_t dur)
+{
+ struct ieee80211_frame_cts *cts;
+ struct mbuf *m;
+
+ MGETHDR(m, M_DONTWAIT, MT_DATA);
+ if (m == NULL) {
+ ic->ic_stats.is_tx_nombuf++;
+ return NULL;
+ }
+ m->m_pkthdr.len = m->m_len = sizeof (struct ieee80211_frame_cts);
+
+ cts = mtod(m, struct ieee80211_frame_cts *);
+ cts->i_fc[0] = IEEE80211_FC0_VERSION_0 | IEEE80211_FC0_TYPE_CTL |
+ IEEE80211_FC0_SUBTYPE_CTS;
+ cts->i_fc[1] = IEEE80211_FC1_DIR_NODS;
+ *(uint16_t *)cts->i_dur = htole16(dur);
+ IEEE80211_ADDR_COPY(cts->i_ra, ic->ic_myaddr);
+
+ return m;
+}
+
struct mbuf *
ieee80211_beacon_alloc(struct ieee80211com *ic, struct ieee80211_node *ni)
{