From patchwork Wed Nov 13 17:54:06 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Luis R. Rodriguez" X-Patchwork-Id: 3179071 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 22D0AC045B for ; Wed, 13 Nov 2013 17:54:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 080412078B for ; Wed, 13 Nov 2013 17:54:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 096622077C for ; Wed, 13 Nov 2013 17:54:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758969Ab3KMRy1 (ORCPT ); Wed, 13 Nov 2013 12:54:27 -0500 Received: from mail-wi0-f172.google.com ([209.85.212.172]:58758 "EHLO mail-wi0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755997Ab3KMRy0 (ORCPT ); Wed, 13 Nov 2013 12:54:26 -0500 Received: by mail-wi0-f172.google.com with SMTP id i19so1124963wiw.17 for ; Wed, 13 Nov 2013 09:54:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=BYK3HIAr0LoygOK2aUo1tyqFGXS6oZU641/tTmmAlGs=; b=pEI31bCXknQ8Jauyq8aS+5TZSgVVg3g9pp5F671yMuHNmpI3I+A4T8QCq5SJDpvRBf 2tu2Aicur7y8nywvAoP0H0OivVOlrNQjvUW9VaIDO4wMyYNrQEFs1QkBI6ix+PKtv+NF 83G8jKwpHAeKIRBTr2iRdoCwq8AEQXWj/IUcyJEl/yqEZz1Vdje+rDnDiC2p+SAs+xWz RWhuImwXkK95PCJmhNol/GxHPEfLkd1k8br+EPlooQP+SqwoK17aMJClUUjm9wBv3fXB GBJukWuceGKZ9UQqeRbHTDVNpLsEIJi3lqkbAHvpaZEe1yb2NpLObwZrSXAnxfgvCvjf 0P/w== X-Received: by 10.194.239.40 with SMTP id vp8mr2694602wjc.45.1384365264890; Wed, 13 Nov 2013 09:54:24 -0800 (PST) Received: from mcgrof@gmail.com (thinkpad-luis.rsr.lip6.fr. [132.227.76.46]) by mx.google.com with ESMTPSA id b7sm57688208wiz.8.2013.11.13.09.54.23 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 13 Nov 2013 09:54:24 -0800 (PST) Received: by mcgrof@gmail.com (sSMTP sendmail emulation); Wed, 13 Nov 2013 18:54:22 +0100 From: "Luis R. Rodriguez" To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, "Luis R. Rodriguez" Subject: [PATCH 5/5] cfg80211: add reg_get_dfs_region() Date: Wed, 13 Nov 2013 18:54:06 +0100 Message-Id: <1384365246-24768-6-git-send-email-mcgrof@do-not-panic.com> X-Mailer: git-send-email 1.8.4.rc3 In-Reply-To: <1384365246-24768-1-git-send-email-mcgrof@do-not-panic.com> References: <1384365246-24768-1-git-send-email-mcgrof@do-not-panic.com> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham 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 This can be used outside of the regulatory context for any checks on the DFS region. The central cfg80211 dfs_region is always used and if it does not match with the wiphy a debug print is issued. Signed-off-by: Luis R. Rodriguez --- net/wireless/reg.c | 29 +++++++++++++++++++++++++++++ net/wireless/reg.h | 1 + 2 files changed, 30 insertions(+) diff --git a/net/wireless/reg.c b/net/wireless/reg.c index ec54e1a..4bfbeaa 100644 --- a/net/wireless/reg.c +++ b/net/wireless/reg.c @@ -135,6 +135,35 @@ static const char *reg_dfs_region_str(enum nl80211_dfs_regions dfs_region) return "Unknown"; } +enum nl80211_dfs_regions reg_get_dfs_region(struct wiphy *wiphy) +{ + const struct ieee80211_regdomain *regd = NULL; + const struct ieee80211_regdomain *wiphy_regd = NULL; + + ASSERT_RTNL(); + + regd = get_cfg80211_regdom(); + if (!wiphy) + goto out; + + wiphy_regd = get_wiphy_regdom(wiphy); + if (!wiphy_regd) + goto out; + + if (wiphy_regd->dfs_region == regd->dfs_region) + goto out; + + REG_DBG_PRINT("%s: device specific dfs_region " + "(%s) disagrees with cfg80211's " + "central dfs_region (%s)\n", + dev_name(&wiphy->dev), + reg_dfs_region_str(wiphy_regd->dfs_region), + reg_dfs_region_str(regd->dfs_region)); + +out: + return regd->dfs_region; +} + static void rcu_free_regdom(const struct ieee80211_regdomain *r) { if (!r) diff --git a/net/wireless/reg.h b/net/wireless/reg.h index cc4c2c0..02bd8f4 100644 --- a/net/wireless/reg.h +++ b/net/wireless/reg.h @@ -21,6 +21,7 @@ extern const struct ieee80211_regdomain __rcu *cfg80211_regdomain; bool reg_is_valid_request(const char *alpha2); bool is_world_regdom(const char *alpha2); bool reg_supported_dfs_region(enum nl80211_dfs_regions dfs_region); +enum nl80211_dfs_regions reg_get_dfs_region(struct wiphy *wiphy); int regulatory_hint_user(const char *alpha2, enum nl80211_user_reg_hint_type user_reg_hint_type);