From owner-svn-src-head@FreeBSD.ORG Mon Aug 26 09:52:06 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id B9AA0D42; Mon, 26 Aug 2013 09:52:06 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 986D52E9B; Mon, 26 Aug 2013 09:52:06 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r7Q9q6ti058124; Mon, 26 Aug 2013 09:52:06 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r7Q9q68M058120; Mon, 26 Aug 2013 09:52:06 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201308260952.r7Q9q68M058120@svn.freebsd.org> From: Adrian Chadd Date: Mon, 26 Aug 2013 09:52:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r254900 - head/sys/net80211 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Aug 2013 09:52:06 -0000 Author: adrian Date: Mon Aug 26 09:52:05 2013 New Revision: 254900 URL: http://svnweb.freebsd.org/changeset/base/254900 Log: Migrate the ff_encap1() routine out into the normal output code. This will eventually be used by the A-MSDU encapsulation code that I'm writing - the sub-frame encapsulation requirement is the same. Modified: head/sys/net80211/ieee80211_output.c head/sys/net80211/ieee80211_proto.h head/sys/net80211/ieee80211_superg.c Modified: head/sys/net80211/ieee80211_output.c ============================================================================== --- head/sys/net80211/ieee80211_output.c Mon Aug 26 09:17:21 2013 (r254899) +++ head/sys/net80211/ieee80211_output.c Mon Aug 26 09:52:05 2013 (r254900) @@ -3316,3 +3316,40 @@ ieee80211_beacon_update(struct ieee80211 return len_changed; } + +/* + * Do Ethernet-LLC encapsulation for each payload in a fast frame + * tunnel encapsulation. The frame is assumed to have an Ethernet + * header at the front that must be stripped before prepending the + * LLC followed by the Ethernet header passed in (with an Ethernet + * type that specifies the payload size). + */ +struct mbuf * +ieee80211_ff_encap1(struct ieee80211vap *vap, struct mbuf *m, + const struct ether_header *eh) +{ + struct llc *llc; + uint16_t payload; + + /* XXX optimize by combining m_adj+M_PREPEND */ + m_adj(m, sizeof(struct ether_header) - sizeof(struct llc)); + llc = mtod(m, struct llc *); + llc->llc_dsap = llc->llc_ssap = LLC_SNAP_LSAP; + llc->llc_control = LLC_UI; + llc->llc_snap.org_code[0] = 0; + llc->llc_snap.org_code[1] = 0; + llc->llc_snap.org_code[2] = 0; + llc->llc_snap.ether_type = eh->ether_type; + payload = m->m_pkthdr.len; /* NB: w/o Ethernet header */ + + M_PREPEND(m, sizeof(struct ether_header), M_NOWAIT); + if (m == NULL) { /* XXX cannot happen */ + IEEE80211_DPRINTF(vap, IEEE80211_MSG_SUPERG, + "%s: no space for ether_header\n", __func__); + vap->iv_stats.is_tx_nobuf++; + return NULL; + } + ETHER_HEADER_COPY(mtod(m, void *), eh); + mtod(m, struct ether_header *)->ether_type = htons(payload); + return m; +} Modified: head/sys/net80211/ieee80211_proto.h ============================================================================== --- head/sys/net80211/ieee80211_proto.h Mon Aug 26 09:17:21 2013 (r254899) +++ head/sys/net80211/ieee80211_proto.h Mon Aug 26 09:52:05 2013 (r254900) @@ -125,6 +125,9 @@ int ieee80211_send_probereq(struct ieee8 const uint8_t da[IEEE80211_ADDR_LEN], const uint8_t bssid[IEEE80211_ADDR_LEN], const uint8_t *ssid, size_t ssidlen); +struct mbuf * ieee80211_ff_encap1(struct ieee80211vap *, struct mbuf *, + const struct ether_header *); + /* * The formation of ProbeResponse frames requires guidance to * deal with legacy clients. When the client is identified as Modified: head/sys/net80211/ieee80211_superg.c ============================================================================== --- head/sys/net80211/ieee80211_superg.c Mon Aug 26 09:17:21 2013 (r254899) +++ head/sys/net80211/ieee80211_superg.c Mon Aug 26 09:52:05 2013 (r254900) @@ -330,43 +330,6 @@ ieee80211_ff_decap(struct ieee80211_node } /* - * Do Ethernet-LLC encapsulation for each payload in a fast frame - * tunnel encapsulation. The frame is assumed to have an Ethernet - * header at the front that must be stripped before prepending the - * LLC followed by the Ethernet header passed in (with an Ethernet - * type that specifies the payload size). - */ -static struct mbuf * -ff_encap1(struct ieee80211vap *vap, struct mbuf *m, - const struct ether_header *eh) -{ - struct llc *llc; - uint16_t payload; - - /* XXX optimize by combining m_adj+M_PREPEND */ - m_adj(m, sizeof(struct ether_header) - sizeof(struct llc)); - llc = mtod(m, struct llc *); - llc->llc_dsap = llc->llc_ssap = LLC_SNAP_LSAP; - llc->llc_control = LLC_UI; - llc->llc_snap.org_code[0] = 0; - llc->llc_snap.org_code[1] = 0; - llc->llc_snap.org_code[2] = 0; - llc->llc_snap.ether_type = eh->ether_type; - payload = m->m_pkthdr.len; /* NB: w/o Ethernet header */ - - M_PREPEND(m, sizeof(struct ether_header), M_NOWAIT); - if (m == NULL) { /* XXX cannot happen */ - IEEE80211_DPRINTF(vap, IEEE80211_MSG_SUPERG, - "%s: no space for ether_header\n", __func__); - vap->iv_stats.is_tx_nobuf++; - return NULL; - } - ETHER_HEADER_COPY(mtod(m, void *), eh); - mtod(m, struct ether_header *)->ether_type = htons(payload); - return m; -} - -/* * Fast frame encapsulation. There must be two packets * chained with m_nextpkt. We do header adjustment for * each, add the tunnel encapsulation, and then concatenate @@ -424,10 +387,10 @@ ieee80211_ff_encap(struct ieee80211vap * * Now do tunnel encapsulation. First, each * frame gets a standard encapsulation. */ - m1 = ff_encap1(vap, m1, &eh1); + m1 = ieee80211_ff_encap1(vap, m1, &eh1); if (m1 == NULL) goto bad; - m2 = ff_encap1(vap, m2, &eh2); + m2 = ieee80211_ff_encap1(vap, m2, &eh2); if (m2 == NULL) goto bad;