add ieee80211_get_rts and ieee80211_get_cts_to_self from openbsd, ok dyoung@

This commit is contained in:
jmcneill 2011-02-21 23:50:08 +00:00
parent 686a05ebe4
commit bab42b3956
2 changed files with 59 additions and 3 deletions

View File

@ -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"
@ -1705,6 +1705,58 @@ bad:
#undef senderr
}
/*
* 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.
*/

View File

@ -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 @@ int ieee80211_classify(struct ieee80211com *, struct mbuf *,
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 *);