Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/net80211 add ieee80211_get_rts and ieee80211_get_cts_to_...
details: https://anonhg.NetBSD.org/src/rev/f6dfed9a70e9
branches: trunk
changeset: 762494:f6dfed9a70e9
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Mon Feb 21 23:50:08 2011 +0000
description:
add ieee80211_get_rts and ieee80211_get_cts_to_self from openbsd, ok dyoung@
diffstat:
sys/net80211/ieee80211_output.c | 56 +++++++++++++++++++++++++++++++++++++++-
sys/net80211/ieee80211_proto.h | 6 +++-
2 files changed, 59 insertions(+), 3 deletions(-)
diffs (97 lines):
diff -r 6e2c348244c4 -r f6dfed9a70e9 sys/net80211/ieee80211_output.c
--- a/sys/net80211/ieee80211_output.c Mon Feb 21 23:31:00 2011 +0000
+++ b/sys/net80211/ieee80211_output.c Mon Feb 21 23:50:08 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ieee80211_output.c,v 1.49 2010/01/19 22:08:17 pooka Exp $ */
+/* $NetBSD: ieee80211_output.c,v 1.50 2011/02/21 23:50:08 jmcneill Exp $ */
/*-
* Copyright (c) 2001 Atsushi Onoe
* Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
@@ -36,7 +36,7 @@
__FBSDID("$FreeBSD: src/sys/net80211/ieee80211_output.c,v 1.34 2005/08/10 16:22:29 sam Exp $");
#endif
#ifdef __NetBSD__
-__KERNEL_RCSID(0, "$NetBSD: ieee80211_output.c,v 1.49 2010/01/19 22:08:17 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ieee80211_output.c,v 1.50 2011/02/21 23:50:08 jmcneill Exp $");
#endif
#include "opt_inet.h"
@@ -1706,6 +1706,58 @@
}
/*
+ * Build a RTS (Request To Send) control frame.
+ */
+struct mbuf *
+ieee80211_get_rts(struct ieee80211com *ic, const struct ieee80211_frame *wh,
+ uint16_t dur)
+{
+ struct ieee80211_frame_rts *rts;
+ struct mbuf *m;
+
+ MGETHDR(m, M_DONTWAIT, MT_DATA);
+ if (m == NULL)
+ 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, uint16_t dur)
+{
+ struct ieee80211_frame_cts *cts;
+ struct mbuf *m;
+
+ MGETHDR(m, M_DONTWAIT, MT_DATA);
+ if (m == NULL)
+ 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;
+}
+
+/*
* Allocate a beacon frame and fillin the appropriate bits.
*/
struct mbuf *
diff -r 6e2c348244c4 -r f6dfed9a70e9 sys/net80211/ieee80211_proto.h
--- a/sys/net80211/ieee80211_proto.h Mon Feb 21 23:31:00 2011 +0000
+++ b/sys/net80211/ieee80211_proto.h Mon Feb 21 23:50:08 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ieee80211_proto.h,v 1.17 2008/07/28 17:54:02 christos Exp $ */
+/* $NetBSD: ieee80211_proto.h,v 1.18 2011/02/21 23:50:08 jmcneill Exp $ */
/*-
* Copyright (c) 2001 Atsushi Onoe
* Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
@@ -78,6 +78,10 @@
struct ieee80211_node *);
struct mbuf *ieee80211_encap(struct ieee80211com *, struct mbuf *,
struct ieee80211_node *);
+struct mbuf *ieee80211_get_rts(struct ieee80211com *,
+ const struct ieee80211_frame *, uint16_t);
+struct mbuf *ieee80211_get_cts_to_self(struct ieee80211com *,
+ uint16_t);
void ieee80211_pwrsave(struct ieee80211com *, struct ieee80211_node *,
struct mbuf *);
Home |
Main Index |
Thread Index |
Old Index