Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp849244pxb; Sat, 16 Jan 2021 09:07:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJx7gODaNwcKVCV+dhPJ5bq1+uwbFJZk+tHG7HdibOVV5mzgDOKQ0yMBbPbheE9b6SDHM6A7 X-Received: by 2002:a17:906:1a14:: with SMTP id i20mr13005458ejf.548.1610816847905; Sat, 16 Jan 2021 09:07:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610816847; cv=none; d=google.com; s=arc-20160816; b=Mw3RmLwK19rk2YhV3pclcLGzMu60llUdx9KBKvUSK5xCOcIB13AVq5Jnf+NVa2PtQa zKtGH1aemN3YtTTno7SAtwa5EJiNKHBUBTpzHZkCf6Dw241PXsFbkANn6zgUG5V/YGOD C61O8VQ8FxDEpwHYDVRhMDTUpDRtB6tRurrQ1WX6gsyFnTU1bXHvBTY1u5wzb5zBoagC yAgZsSjnj0uA2Kg+QsAi6q+Q6RMzmBuXY87Yh1VstGG8RiRmWEjoCB5n2sGTxi3khEQd m2PTVZce+VbP2jgr+oSOkWb9x9PguRi+AgncfJLQn+AiTzEU+BJoG3L41a0564HQPJU0 Eauw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=7N0/eQU7QmXw+P/Duzg48FiMWV4nS/aWZAb2fBrCO7U=; b=cwmpq6FmFHX1DfsHQ/hE8MwWXCCE2LsFPOBbycdZLAej+ZaaFbNMpnbkM2JhH5vt0R kFj+B2kTEJFmuwU454ekuoyRy73beCiH28L1/K/8YnzQIoYKsDj62R9MPFviPrB2H1cM WD4PB26JybpY2REzDrqC4sOAgP61k3+z61AXy0k0IScAPMsT9uxanj87adFRY0tcNPyi cI3kklYb+pYUXKeF9rpVuCitLnvWDmR8nMhd0il8aP0XnZM1oACXvHmoTFB5LS0WDk4s auyg53ANvvaNIP/4h81xPzCLKJZz8pqjztlat2t55JrTvJZHXTIdkJuiTrEP3n8qTMFT BAzQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m7si5946738eji.682.2021.01.16.09.06.35; Sat, 16 Jan 2021 09:07:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726906AbhAPMxk (ORCPT + 99 others); Sat, 16 Jan 2021 07:53:40 -0500 Received: from smail.rz.tu-ilmenau.de ([141.24.186.67]:36246 "EHLO smail.rz.tu-ilmenau.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726862AbhAPMxj (ORCPT ); Sat, 16 Jan 2021 07:53:39 -0500 Received: from legolas.fritz.box (unknown [84.174.243.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smail.rz.tu-ilmenau.de (Postfix) with ESMTPSA id 644EA58008F; Sat, 16 Jan 2021 13:52:04 +0100 (CET) From: Markus Theil To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Markus Theil Subject: [PATCH 4/4] rfkill: support hard block reason in C code Date: Sat, 16 Jan 2021 13:51:46 +0100 Message-Id: <20210116125146.31932-5-markus.theil@tu-ilmenau.de> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210116125146.31932-1-markus.theil@tu-ilmenau.de> References: <20210116125146.31932-1-markus.theil@tu-ilmenau.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Signed-off-by: Markus Theil --- rfkill.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/rfkill.c b/rfkill.c index 8cd81fe..7fa5c39 100644 --- a/rfkill.c +++ b/rfkill.c @@ -51,15 +51,16 @@ static void rfkill_event(void) break; } - if (len != RFKILL_EVENT_SIZE_V1) { + if (len != RFKILL_EVENT_SIZE_V1 && len != RFKILL_EVENT_SIZE_V1 + 1) { fprintf(stderr, "Wrong size of RFKILL event\n"); continue; } gettimeofday(&tv, NULL); - printf("%ld.%06u: idx %u type %u op %u soft %u hard %u\n", + printf("%ld.%06u: idx %u type %u op %u soft %u hard %u hard block reasons 0x%02x\n", (long) tv.tv_sec, (unsigned int) tv.tv_usec, - event.idx, event.type, event.op, event.soft, event.hard); + event.idx, event.type, event.op, event.soft, event.hard, + event.hard_block_reasons); fflush(stdout); } @@ -214,7 +215,7 @@ static int rfkill_list(const char *param) break; } - if (len != RFKILL_EVENT_SIZE_V1) { + if (len != RFKILL_EVENT_SIZE_V1 && len != RFKILL_EVENT_SIZE_V1 + 1) { fprintf(stderr, "Wrong size of RFKILL event\n"); continue; } @@ -242,6 +243,16 @@ static int rfkill_list(const char *param) type2string(event.type)); printf("\tSoft blocked: %s\n", event.soft ? "yes" : "no"); printf("\tHard blocked: %s\n", event.hard ? "yes" : "no"); + if (len >= RFKILL_EVENT_SIZE_V1 + 1) { + printf("\tHard block reasons: "); + if (event.hard_block_reasons == 0) + printf("[NONE]"); + if (event.hard_block_reasons & RFKILL_HARD_BLOCK_NOT_OWNER) + printf("[NOT_OWNER]"); + if (event.hard_block_reasons & RFKILL_HARD_BLOCK_SIGNAL) + printf("[SIGNAL]"); + printf("\n"); + } } close(fd); -- 2.30.0