PERFORCE change 137817 for review

Sam Leffler sam at FreeBSD.org
Sun Mar 16 02:31:26 UTC 2008


http://perforce.freebsd.org/chv.cgi?CH=137817

Change 137817 by sam at sam_ebb on 2008/03/16 02:30:50

	add routines to alloc+build rts and cts frames; inspired
	by similar routines in openbsd

Affected files ...

.. //depot/projects/vap/sys/net80211/ieee80211_output.c#39 edit
.. //depot/projects/vap/sys/net80211/ieee80211_proto.h#18 edit

Differences ...

==== //depot/projects/vap/sys/net80211/ieee80211_output.c#39 (text+ko) ====

@@ -543,7 +543,7 @@
 		return EIO;		/* XXX */
 	}
 
-	MGETHDR(m, M_NOWAIT, MT_HEADER);
+	m = m_gethdr(M_NOWAIT, MT_HEADER);
 	if (m == NULL) {
 		/* XXX debug msg */
 		ieee80211_unref_node(&ni);
@@ -2246,6 +2246,59 @@
 	return ic->ic_raw_xmit(bss, m, NULL);
 }
 
+/*
+ * Allocate and build a RTS (Request To Send) control frame.
+ */
+struct mbuf *
+ieee80211_alloc_rts(struct ieee80211com *ic,
+	const uint8_t ra[IEEE80211_ADDR_LEN],
+	const uint8_t ta[IEEE80211_ADDR_LEN],
+	uint16_t dur)
+{
+	struct ieee80211_frame_rts *rts;
+	struct mbuf *m;
+
+	/* XXX honor ic_headroom */
+	m = m_gethdr(M_DONTWAIT, MT_DATA);
+	if (m != NULL) {
+		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;
+		*(u_int16_t *)rts->i_dur = htole16(dur);
+		IEEE80211_ADDR_COPY(rts->i_ra, ra);
+		IEEE80211_ADDR_COPY(rts->i_ta, ta);
+
+		m->m_pkthdr.len = m->m_len = sizeof(struct ieee80211_frame_rts);
+	}
+	return m;
+}
+
+/*
+ * Allocate and build a CTS (Clear To Send) control frame.
+ */
+struct mbuf *
+ieee80211_alloc_cts(struct ieee80211com *ic,
+	const uint8_t ra[IEEE80211_ADDR_LEN], uint16_t dur)
+{
+	struct ieee80211_frame_cts *cts;
+	struct mbuf *m;
+
+	/* XXX honor ic_headroom */
+	m = m_gethdr(M_DONTWAIT, MT_DATA);
+	if (m != NULL) {
+		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;
+		*(u_int16_t *)cts->i_dur = htole16(dur);
+		IEEE80211_ADDR_COPY(cts->i_ra, ra);
+
+		m->m_pkthdr.len = m->m_len = sizeof(struct ieee80211_frame_cts);
+	}
+	return m;
+}
+
 static void
 ieee80211_tx_mgt_timeout(void *arg)
 {

==== //depot/projects/vap/sys/net80211/ieee80211_proto.h#18 (text+ko) ====

@@ -91,6 +91,11 @@
 struct mbuf *ieee80211_alloc_proberesp(struct ieee80211_node *, int);
 int	ieee80211_send_proberesp(struct ieee80211vap *,
 		const uint8_t da[IEEE80211_ADDR_LEN], int);
+struct mbuf *ieee80211_alloc_rts(struct ieee80211com *ic,
+		const uint8_t [IEEE80211_ADDR_LEN],
+		const uint8_t [IEEE80211_ADDR_LEN], uint16_t);
+struct mbuf *ieee80211_alloc_cts(struct ieee80211com *,
+		const uint8_t [IEEE80211_ADDR_LEN], uint16_t);
 
 void	ieee80211_reset_erp(struct ieee80211com *);
 void	ieee80211_set_shortslottime(struct ieee80211com *, int onoff);


More information about the p4-projects mailing list