* [PATCH 1/3] rfkill: update rfkill.h
@ 2021-02-06 15:34 Markus Theil
2021-02-06 15:34 ` [PATCH 2/3] rfkill.c: deal with updated struct size Markus Theil
2021-02-06 15:34 ` [PATCH 3/3] rfkill: support hard block reason in C code Markus Theil
0 siblings, 2 replies; 3+ messages in thread
From: Markus Theil @ 2021-02-06 15:34 UTC (permalink / raw)
To: johannes; +Cc: linux-wireless, Markus Theil
Signed-off-by: Markus Theil <markus.theil@tu-ilmenau.de>
---
rfkill.h | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/rfkill.h b/rfkill.h
index 058757f..03e8af8 100644
--- a/rfkill.h
+++ b/rfkill.h
@@ -59,6 +59,8 @@ enum rfkill_type {
* @RFKILL_OP_DEL: a device was removed
* @RFKILL_OP_CHANGE: a device's state changed -- userspace changes one device
* @RFKILL_OP_CHANGE_ALL: userspace changes all devices (of a type, or all)
+ * into a state, also updating the default state used for devices that
+ * are hot-plugged later.
*/
enum rfkill_operation {
RFKILL_OP_ADD = 0,
@@ -67,6 +69,16 @@ enum rfkill_operation {
RFKILL_OP_CHANGE_ALL,
};
+/**
+ * enum rfkill_hard_block_reasons - hard block reasons
+ * @RFKILL_HARD_BLOCK_SIGNAL: the hardware rfkill signal is active
+ * @RFKILL_HARD_BLOCK_NOT_OWNER: the NIC is not owned by the host
+ */
+enum rfkill_hard_block_reasons {
+ RFKILL_HARD_BLOCK_SIGNAL = 1 << 0,
+ RFKILL_HARD_BLOCK_NOT_OWNER = 1 << 1,
+};
+
/**
* struct rfkill_event - events for userspace on /dev/rfkill
* @idx: index of dev rfkill
@@ -74,6 +86,8 @@ enum rfkill_operation {
* @op: operation code
* @hard: hard state (0/1)
* @soft: soft state (0/1)
+ * @hard_block_reasons: valid if hard is set. One or several reasons from
+ * &enum rfkill_hard_block_reasons.
*
* Structure used for userspace communication on /dev/rfkill,
* used for events from the kernel and control to the kernel.
@@ -82,7 +96,9 @@ struct rfkill_event {
__u32 idx;
__u8 type;
__u8 op;
- __u8 soft, hard;
+ __u8 soft;
+ __u8 hard;
+ __u8 hard_block_reasons;
} __attribute__((packed));
/*
--
2.30.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/3] rfkill.c: deal with updated struct size
2021-02-06 15:34 [PATCH 1/3] rfkill: update rfkill.h Markus Theil
@ 2021-02-06 15:34 ` Markus Theil
2021-02-06 15:34 ` [PATCH 3/3] rfkill: support hard block reason in C code Markus Theil
1 sibling, 0 replies; 3+ messages in thread
From: Markus Theil @ 2021-02-06 15:34 UTC (permalink / raw)
To: johannes; +Cc: linux-wireless, Markus Theil
Signed-off-by: Markus Theil <markus.theil@tu-ilmenau.de>
---
rfkill.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/rfkill.c b/rfkill.c
index 8cd81fe..6b5ca2c 100644
--- a/rfkill.c
+++ b/rfkill.c
@@ -45,13 +45,14 @@ static void rfkill_event(void)
if (n == 0)
continue;
+ memset(&event, 0, sizeof(event));
len = read(fd, &event, sizeof(event));
if (len < 0) {
perror("Reading of RFKILL events failed");
break;
}
- if (len != RFKILL_EVENT_SIZE_V1) {
+ if (len < RFKILL_EVENT_SIZE_V1) {
fprintf(stderr, "Wrong size of RFKILL event\n");
continue;
}
@@ -206,6 +207,7 @@ static int rfkill_list(const char *param)
}
while (1) {
+ memset(&event, 0, sizeof(event));
len = read(fd, &event, sizeof(event));
if (len < 0) {
if (errno == EAGAIN)
@@ -214,7 +216,7 @@ static int rfkill_list(const char *param)
break;
}
- if (len != RFKILL_EVENT_SIZE_V1) {
+ if (len < RFKILL_EVENT_SIZE_V1) {
fprintf(stderr, "Wrong size of RFKILL event\n");
continue;
}
--
2.30.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 3/3] rfkill: support hard block reason in C code
2021-02-06 15:34 [PATCH 1/3] rfkill: update rfkill.h Markus Theil
2021-02-06 15:34 ` [PATCH 2/3] rfkill.c: deal with updated struct size Markus Theil
@ 2021-02-06 15:34 ` Markus Theil
1 sibling, 0 replies; 3+ messages in thread
From: Markus Theil @ 2021-02-06 15:34 UTC (permalink / raw)
To: johannes; +Cc: linux-wireless, Markus Theil
Signed-off-by: Markus Theil <markus.theil@tu-ilmenau.de>
---
rfkill.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/rfkill.c b/rfkill.c
index 6b5ca2c..253ee46 100644
--- a/rfkill.c
+++ b/rfkill.c
@@ -58,9 +58,10 @@ static void rfkill_event(void)
}
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);
}
@@ -244,6 +245,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
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-02-06 15:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-06 15:34 [PATCH 1/3] rfkill: update rfkill.h Markus Theil
2021-02-06 15:34 ` [PATCH 2/3] rfkill.c: deal with updated struct size Markus Theil
2021-02-06 15:34 ` [PATCH 3/3] rfkill: support hard block reason in C code Markus Theil
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).