blob: c9f6cf9a8011c10d1a2488af4b035b3351c42f2f [file] [log] [blame]
developer05f3b2b2024-08-19 19:17:34 +08001From 1bc783af16926b73f98f0c1b67ab90cf39e030a1 Mon Sep 17 00:00:00 2001
2From: Michael-CY Lee <michael-cy.lee@mediatek.com>
3Date: Thu, 27 Jun 2024 08:37:52 +0800
4Subject: [PATCH 13/13] iw: add link_id for offchannel operation
5
6NL80211_CMD_REMAIN_ON_CANNEL has flag NL80211_FLAG_MLO_VALID_LINK_ID, so
7a link_id is necessary when the interface is MLD.
8
9Usage:
10iw dev <ifname> offchannel [-l link_id] <freq> <duration>
11
12Signed-off-by: Michael-CY Lee <michael-cy.lee@mediatek.com>
13---
14 offch.c | 24 ++++++++++++++++++++++--
15 1 file changed, 22 insertions(+), 2 deletions(-)
16
17diff --git a/offch.c b/offch.c
18index 19e170e..3858ccd 100644
19--- a/offch.c
20+++ b/offch.c
21@@ -14,6 +14,26 @@ static int offchannel(struct nl80211_state *state,
22 enum id_input id)
23 {
24 char *end;
25+ unsigned int link_id;
26+
27+ if (argc < 2)
28+ return 1;
29+
30+ /* link id */
31+ if (!strcmp(argv[0], "-l")) {
32+ link_id = strtol(argv[1], &end, 10);
33+ if (*end)
34+ return 1;
35+
36+ if (link_id >= IEEE80211_MLD_MAX_NUM_LINKS) {
37+ printf("link id %d exceeds max number of links\n",
38+ link_id);
39+ return 2;
40+ }
41+ NLA_PUT_U8(msg, NL80211_ATTR_MLO_LINK_ID, link_id);
42+ argv += 2;
43+ argc -= 2;
44+ }
45
46 if (argc < 2)
47 return 1;
48@@ -42,6 +62,6 @@ static int offchannel(struct nl80211_state *state,
49 return -ENOSPC;
50 }
51
52-TOPLEVEL(offchannel, "<freq> <duration>", NL80211_CMD_REMAIN_ON_CHANNEL, 0,
53- CIB_NETDEV, offchannel,
54+TOPLEVEL(offchannel, "[-l link_id] <freq> <duration>",
55+ NL80211_CMD_REMAIN_ON_CHANNEL, 0, CIB_NETDEV, offchannel,
56 "Leave operating channel and go to the given channel for a while.");
57--
582.18.0
59