Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1135012pxb; Wed, 6 Apr 2022 09:31:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYdIevYzgEZZy5y+srIOitHVJVGjLdXD1i9e11JWPvqwoNn3eiK93g1XALRJQQkmbM11An X-Received: by 2002:a05:6a00:8c5:b0:4fe:134d:30d3 with SMTP id s5-20020a056a0008c500b004fe134d30d3mr9725547pfu.3.1649262676078; Wed, 06 Apr 2022 09:31:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649262676; cv=none; d=google.com; s=arc-20160816; b=HE3XLH0yEp4I0HMG4rZFyY3hkjLT5P2Abyl9F3V3ne9j9loAXNH0sqMupWj8jEX8iS xDgNEl7OQJIaogc49JsH2Z9rw+1U0jCfTmnBMOpj18rzA8hsS2eU/hJEca1sSrwJoF9L cvz+9u3WneaFA+A1tfET3HwVOlmWeI1fPFchhMmU6StoKzWgJCOqPdy/VH856Kib+wdR Q+YGpCqhoBiRt+wjmnbSG4IqibRzkJH009F+4ew0cUkuXIMC6PyF0gC+O1gT6P/bS4rk nRPX0lvlv7bnyva6LVaJvYYOG3OAiDooFG4GsuMvpdYgBi/DaaC14Ju+5/HwzMPy6zjx faNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:cc:to:from; bh=6t8SWOrABd8V1iWhJZrRLGQJAjNbEUJB+YTO/LZBm9s=; b=fhQiWvgT17tDaL7+IETN7AtFpGE4Z3zy0QOf8MAfUIo5Y/EAbq7F+zGZZUUxFzsEZr NK74tKhynfInT3yS5JC9fcyo6bEfL6m+ZVaf2AZ/OdFAr9hqI03qwjwWwszWEp6WZXjU +5Fi/UKhRHrnPHsfbSrv3/jMmko9NeQtBgj0eILGEWJbhsbD2beSrM9uOJTPGx0hL+ev EM84rmYUX1+QZtjmgnDflvbxIySw0uSdqvRFvY1hAtyJaC5rTifygtMOT5JZXzZ0fOHH bKNn+XEDofDMmr5ADAsA6wigzgXkpsIxWLCPehzEUeZtq0MlRaqMoGXkwSBSLejYFfty wh4w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id be3-20020a170902aa0300b00153b2d1650esi16055474plb.278.2022.04.06.09.31.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 09:31:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id EAE04ECC73; Wed, 6 Apr 2022 08:37:38 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236270AbiDFPjM (ORCPT + 69 others); Wed, 6 Apr 2022 11:39:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237163AbiDFPih (ORCPT ); Wed, 6 Apr 2022 11:38:37 -0400 Received: from farmhouse.coelho.fi (paleale.coelho.fi [176.9.41.70]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36AB4CA6F1 for ; Wed, 6 Apr 2022 05:53:24 -0700 (PDT) Received: from 91-156-4-241.elisa-laajakaista.fi ([91.156.4.241] helo=kveik.ger.corp.intel.com) by farmhouse.coelho.fi with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1nc4Tf-000pov-TN; Wed, 06 Apr 2022 15:09:36 +0300 From: Luca Coelho To: johannes@sipsolutions.net, kvalo@kernel.org Cc: luca@coelho.fi, gregory.greenman@intel.com, linux-wireless@vger.kernel.org Date: Wed, 6 Apr 2022 15:09:22 +0300 Message-Id: X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220406120924.979792-1-luca@coelho.fi> References: <20220406120924.979792-1-luca@coelho.fi> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 Subject: [PATCH 5/7] ieee80211: add helper functions for detecting TM/FTM frames Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Avraham Stern Signed-off-by: Avraham Stern Signed-off-by: Luca Coelho --- include/linux/ieee80211.h | 54 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h index 75d40acb60c1..313aabb2d511 100644 --- a/include/linux/ieee80211.h +++ b/include/linux/ieee80211.h @@ -1301,6 +1301,15 @@ struct ieee80211_mgmt { u8 action_code; u8 variable[]; } __packed s1g; + struct { + u8 action_code; + u8 dialog_token; + u8 follow_up; + u32 tod; + u32 toa; + u8 max_tod_error; + u8 max_toa_error; + } __packed wnm_timing_msr; } u; } __packed action; } u; @@ -3464,6 +3473,17 @@ enum ieee80211_mesh_actioncode { WLAN_MESH_ACTION_TBTT_ADJUSTMENT_RESPONSE, }; +/* Unprotected WNM action codes */ +enum ieee80211_unprotected_wnm_actioncode { + WLAN_UNPROTECTED_WNM_ACTION_TIM = 0, + WLAN_UNPROTECTED_WNM_ACTION_TIMING_MEASUREMENT_RESPONSE = 1, +}; + +/* Public action codes */ +enum ieee80211_public_actioncode { + WLAN_PUBLIC_ACTION_FTM_RESPONSE = 33, +}; + /* Security key length */ enum ieee80211_key_len { WLAN_KEY_LEN_WEP40 = 5, @@ -4252,6 +4272,40 @@ static inline bool ieee80211_action_contains_tpc(struct sk_buff *skb) return true; } +static inline bool ieee80211_is_timing_measurement(struct sk_buff *skb) +{ + struct ieee80211_mgmt *mgmt = (void *)skb->data; + + if (!ieee80211_is_action(mgmt->frame_control)) + return false; + + if (skb->len < IEEE80211_MIN_ACTION_SIZE) + return false; + + if (mgmt->u.action.category == WLAN_CATEGORY_WNM_UNPROTECTED && + mgmt->u.action.u.wnm_timing_msr.action_code == + WLAN_UNPROTECTED_WNM_ACTION_TIMING_MEASUREMENT_RESPONSE && + skb->len >= offsetofend(typeof(*mgmt), u.action.u.wnm_timing_msr)) + return true; + + return false; +} + +static inline bool ieee80211_is_ftm(struct sk_buff *skb) +{ + struct ieee80211_mgmt *mgmt = (void *)skb->data; + + if (!ieee80211_is_public_action((void *)mgmt, skb->len)) + return false; + + if (mgmt->u.action.u.ftm.action_code == + WLAN_PUBLIC_ACTION_FTM_RESPONSE && + skb->len >= offsetofend(typeof(*mgmt), u.action.u.ftm)) + return true; + + return false; +} + struct element { u8 id; u8 datalen; -- 2.35.1