[OpenWrt-Devel,2/2] iwinfo: add current hw and ht mode to info call
diff mbox series

Message ID 20191127172952.2143-2-daniel@dd-wrt.com
State Accepted
Delegated to: Hauke Mehrtens
Headers show
Series
  • iwinfo/rpcd: add current hw and ht mode to info call
Related show

Commit Message

Daniel Danzberger Nov. 27, 2019, 5:29 p.m. UTC
Signed-off-by: Daniel Danzberger <daniel@dd-wrt.com>
---
 iwinfo.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

Comments

Hauke Mehrtens Dec. 19, 2019, 10:29 a.m. UTC | #1
On 11/27/19 6:29 PM, Daniel Danzberger wrote:
> Signed-off-by: Daniel Danzberger <daniel@dd-wrt.com>
> ---
>  iwinfo.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 44 insertions(+)
> 
> diff --git a/iwinfo.c b/iwinfo.c
> index a76b72a..7f46e3e 100644
> --- a/iwinfo.c
> +++ b/iwinfo.c

This file does not exist.

Hauke
Daniel Danzberger Dec. 19, 2019, 11:49 a.m. UTC | #2
On 12/19/19 11:29 AM, Hauke Mehrtens wrote:
> On 11/27/19 6:29 PM, Daniel Danzberger wrote:
>> Signed-off-by: Daniel Danzberger <daniel@dd-wrt.com>
>> ---
>>  iwinfo.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
>>  1 file changed, 44 insertions(+)
>>
>> diff --git a/iwinfo.c b/iwinfo.c
>> index a76b72a..7f46e3e 100644
>> --- a/iwinfo.c
>> +++ b/iwinfo.c
> 
> This file does not exist.
This is the rpcd part of the patch. The file exists in the rpcd repository.

> 
> Hauke
>

Patch
diff mbox series

diff --git a/iwinfo.c b/iwinfo.c
index a76b72a..7f46e3e 100644
--- a/iwinfo.c
+++ b/iwinfo.c
@@ -290,6 +290,48 @@  rpc_iwinfo_call_hwmodes(const char *name)
 	}
 }
 
+static void rpc_iwinfo_call_hw_ht_mode()
+{
+	const char *hwmode_str;
+	const char *htmode_str;
+	int32_t htmode = 0;
+
+	if (iw->htmode(ifname, &htmode))
+		return;
+
+	switch (htmode) {
+		case IWINFO_HTMODE_HT20:
+			htmode_str = "HT20";
+			hwmode_str = "n";
+			break;
+		case IWINFO_HTMODE_HT40:
+			htmode_str = "HT40";
+			hwmode_str = "n";
+			break;
+		case IWINFO_HTMODE_VHT80:
+			htmode_str = "VHT80";
+			hwmode_str = "ac";
+			break;
+		case IWINFO_HTMODE_VHT80_80:
+			htmode_str = "VHT80+80";
+			hwmode_str = "ac";
+			break;
+		case IWINFO_HTMODE_VHT160:
+			htmode_str = "VHT160";
+			hwmode_str = "ac";
+			break;
+		case IWINFO_HTMODE_NOHT:
+			htmode_str = "20";
+			hwmode_str = "a/g";
+			break;
+		default:
+			htmode_str = hwmode_str = "unknown";
+			break;
+	}
+	blobmsg_add_string(&buf, "hwmode", hwmode_str);
+	blobmsg_add_string(&buf, "htmode", htmode_str);
+}
+
 static void
 rpc_iwinfo_call_str(const char *name, int (*func)(const char *, char *))
 {
@@ -341,6 +383,8 @@  rpc_iwinfo_info(struct ubus_context *ctx, struct ubus_object *obj,
 	rpc_iwinfo_call_htmodes("htmodes");
 	rpc_iwinfo_call_hwmodes("hwmodes");
 
+	rpc_iwinfo_call_hw_ht_mode();
+
 	c = blobmsg_open_table(&buf, "hardware");
 	rpc_iwinfo_call_hardware_id("id");
 	rpc_iwinfo_call_str("name", iw->hardware_name);