From patchwork Tue Jul 9 18:27:01 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Wunderlich X-Patchwork-Id: 2825418 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 33F83C0AB2 for ; Tue, 9 Jul 2013 18:27:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3FEF22011D for ; Tue, 9 Jul 2013 18:27:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D0AD72010F for ; Tue, 9 Jul 2013 18:27:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752076Ab3GIS1O (ORCPT ); Tue, 9 Jul 2013 14:27:14 -0400 Received: from nick.hrz.tu-chemnitz.de ([134.109.228.11]:49847 "EHLO nick.hrz.tu-chemnitz.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751197Ab3GIS1O (ORCPT ); Tue, 9 Jul 2013 14:27:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tu-chemnitz.de; s=dkim2010; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=SDGlo1Xm44jFf9c3aJrRey00kutr9sZM1mGX4Jx9ooQ=; b=DVdGHqhu/NZVsN0rhcDiH33uBkYEDPBxRpkYoVlNAlYz7OfvuLRapZvankgsxT2CsEyUO2IOfn2ZEBPRNqKqHjC8kIwzJSgpyvvkPWs1OBYXdRTqE8JWD8NUs9MlURyXsw0Z/ClEh7YynrE3gNhJrREL7qMuagxfK3WXxZJHn/k=; Received: from p579e7a48.dip0.t-ipconnect.de ([87.158.122.72] helo=pandem0nium) by nick.hrz.tu-chemnitz.de with esmtpsa (TLSv1:DHE-RSA-AES128-SHA:128) (Exim 4.80.1) (envelope-from ) id 1Uwcd6-0004oh-7l; Tue, 09 Jul 2013 20:27:12 +0200 Received: from dotslash by pandem0nium with local (Exim 4.80) (envelope-from ) id 1Uwcd4-00064P-WB; Tue, 09 Jul 2013 20:27:11 +0200 From: Simon Wunderlich To: Johannes Berg Cc: linux-wireless@vger.kernel.org, Mathias Kretschmer , Simon Wunderlich Subject: [PATCHv4 2/5] mac80211: add functions to duplicate a cfg80211_beacon Date: Tue, 9 Jul 2013 20:27:01 +0200 Message-Id: <1373394424-23298-3-git-send-email-siwu@hrz.tu-chemnitz.de> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1373394424-23298-1-git-send-email-siwu@hrz.tu-chemnitz.de> References: <1373394424-23298-1-git-send-email-siwu@hrz.tu-chemnitz.de> X-purgate: clean X-purgate-type: clean X-purgate-ID: 154106::1373394432-000004FE-EF99852E/0-0/0-0 X-Scan-AV: nick.hrz.tu-chemnitz.de; 2013-07-09 20:27:12; f1f7287661adc283c194ca1b24577440 X-Scan-SA: nick.hrz.tu-chemnitz.de; 2013-07-09 20:27:12; 8151927c0c15c6de4be2792f7c9ad93f X-Spam-Score: -1.0 (-) Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP For the channel switch announcement, it is required to set a new beacon after the driver arrived on the new channel. The new beacon will be set by nl80211, but is required to duplicate the beacon as the original memory within the netlink message will be gone. Signed-off-by: Simon Wunderlich Signed-off-by: Mathias Kretschmer --- Changes to PATCHv2: * allocate only one memory chunk --- net/mac80211/cfg.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index b82fff6..8e6c935 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c @@ -2775,6 +2775,62 @@ static int ieee80211_start_radar_detection(struct wiphy *wiphy, return 0; } +static struct cfg80211_beacon_data * +cfg80211_beacon_dup(struct cfg80211_beacon_data *beacon) +{ + struct cfg80211_beacon_data *new_beacon; + u8 *pos; + int len; + + len = beacon->head_len + beacon->tail_len + beacon->beacon_ies_len + + beacon->proberesp_ies_len + beacon->assocresp_ies_len + + beacon->probe_resp_len; + + new_beacon = kzalloc(sizeof(*new_beacon) + len, GFP_KERNEL); + if (!new_beacon) + return NULL; + + pos = (u8 *)(new_beacon + 1); + if (beacon->head_len) { + new_beacon->head_len = beacon->head_len; + new_beacon->head = pos; + memcpy(pos, beacon->head, beacon->head_len); + pos += beacon->head_len; + } + if (beacon->tail_len) { + new_beacon->tail_len = beacon->tail_len; + new_beacon->tail = pos; + memcpy(pos, beacon->tail, beacon->tail_len); + pos += beacon->tail_len; + } + if (beacon->beacon_ies_len) { + new_beacon->beacon_ies_len = beacon->beacon_ies_len; + new_beacon->beacon_ies = pos; + memcpy(pos, beacon->beacon_ies, beacon->beacon_ies_len); + pos += beacon->beacon_ies_len; + } + if (beacon->proberesp_ies_len) { + new_beacon->proberesp_ies_len = beacon->proberesp_ies_len; + new_beacon->proberesp_ies = pos; + memcpy(pos, beacon->proberesp_ies, beacon->proberesp_ies_len); + pos += beacon->proberesp_ies_len; + } + if (beacon->assocresp_ies_len) { + new_beacon->assocresp_ies_len = beacon->assocresp_ies_len; + new_beacon->assocresp_ies = pos; + memcpy(pos, beacon->assocresp_ies, beacon->assocresp_ies_len); + pos += beacon->assocresp_ies_len; + } + if (beacon->probe_resp_len) { + new_beacon->probe_resp_len = beacon->probe_resp_len; + beacon->probe_resp = pos; + memcpy(pos, beacon->probe_resp, beacon->probe_resp_len); + pos += beacon->probe_resp_len; + } + + return new_beacon; +} + static int ieee80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev, struct ieee80211_channel *chan, bool offchan, unsigned int wait, const u8 *buf, size_t len,