diff mbox

[v5,15/25] wpa_cli: handle IFNAME correctly for global iface

Message ID 1457083241-7492-16-git-send-email-janusz.dziedzic@tieto.com
State Changes Requested
Headers show

Commit Message

Janusz.Dziedzic@tieto.com March 4, 2016, 9:20 a.m. UTC
In case we are using wpa_cli to connect global UDP
interface, before we have "UNKNOWN COMMAND\n" string
as ifname. Change this to "unknown".

Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
---
 src/common/wpa_ctrl.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Jouni Malinen March 5, 2016, 2:33 p.m. UTC | #1
On Fri, Mar 04, 2016 at 10:20:31AM +0100, Janusz Dziedzic wrote:
> In case we are using wpa_cli to connect global UDP
> interface, before we have "UNKNOWN COMMAND\n" string
> as ifname. Change this to "unknown".

Why would "unknown" be any better than "UNKNOWN COMMAND\n"? "unknown"
would be a valid name of an interface. If we want to changes "UNKNOWN
COMMAND\n" to something, that something better be something that can be
clearly identified as not being a network interface.
Janusz.Dziedzic@tieto.com March 6, 2016, 11 a.m. UTC | #2
On 5 March 2016 at 15:33, Jouni Malinen <j@w1.fi> wrote:
> On Fri, Mar 04, 2016 at 10:20:31AM +0100, Janusz Dziedzic wrote:
>> In case we are using wpa_cli to connect global UDP
>> interface, before we have "UNKNOWN COMMAND\n" string
>> as ifname. Change this to "unknown".
>
> Why would "unknown" be any better than "UNKNOWN COMMAND\n"? "unknown"
> would be a valid name of an interface. If we want to changes "UNKNOWN
> COMMAND\n" to something, that something better be something that can be
> clearly identified as not being a network interface.
>
No idea here, added this because of "cosmetic" purpose. So, maybe skip
this one or just remove "\n"?

BR
Janusz

> --
> Jouni Malinen                                            PGP id EFC895FA
Jouni Malinen March 7, 2016, 8:59 a.m. UTC | #3
On Sun, Mar 06, 2016 at 12:00:50PM +0100, Janusz Dziedzic wrote:
> On 5 March 2016 at 15:33, Jouni Malinen <j@w1.fi> wrote:
> > On Fri, Mar 04, 2016 at 10:20:31AM +0100, Janusz Dziedzic wrote:
> >> In case we are using wpa_cli to connect global UDP
> >> interface, before we have "UNKNOWN COMMAND\n" string
> >> as ifname. Change this to "unknown".
> >
> > Why would "unknown" be any better than "UNKNOWN COMMAND\n"? "unknown"
> > would be a valid name of an interface. If we want to changes "UNKNOWN
> > COMMAND\n" to something, that something better be something that can be
> > clearly identified as not being a network interface.
> >
> No idea here, added this because of "cosmetic" purpose. So, maybe skip
> this one or just remove "\n"?

Why would "\n" be removed? I don't really understand what is the point
of this change in the first place. What is this needed for?
Janusz.Dziedzic@tieto.com March 7, 2016, 4:51 p.m. UTC | #4
On 7 March 2016 at 09:59, Jouni Malinen <j@w1.fi> wrote:
> On Sun, Mar 06, 2016 at 12:00:50PM +0100, Janusz Dziedzic wrote:
>> On 5 March 2016 at 15:33, Jouni Malinen <j@w1.fi> wrote:
>> > On Fri, Mar 04, 2016 at 10:20:31AM +0100, Janusz Dziedzic wrote:
>> >> In case we are using wpa_cli to connect global UDP
>> >> interface, before we have "UNKNOWN COMMAND\n" string
>> >> as ifname. Change this to "unknown".
>> >
>> > Why would "unknown" be any better than "UNKNOWN COMMAND\n"? "unknown"
>> > would be a valid name of an interface. If we want to changes "UNKNOWN
>> > COMMAND\n" to something, that something better be something that can be
>> > clearly identified as not being a network interface.
>> >
>> No idea here, added this because of "cosmetic" purpose. So, maybe skip
>> this one or just remove "\n"?
>
> Why would "\n" be removed? I don't really understand what is the point
> of this change in the first place. What is this needed for?
>
When using wpa_cli with UDP support we have nice prompt:

hostname/wlan0>

wlan0 is a result of "IFNAME", so for global iface we see:

localhost/UNKNOWN COMMAND
>

BR
Janusz

> --
> Jouni Malinen                                            PGP id EFC895FA
diff mbox

Patch

diff --git a/src/common/wpa_ctrl.c b/src/common/wpa_ctrl.c
index 623c2a7..042914f 100644
--- a/src/common/wpa_ctrl.c
+++ b/src/common/wpa_ctrl.c
@@ -435,6 +435,8 @@  struct wpa_ctrl * wpa_ctrl_open(const char *ctrl_path)
 
 	if (wpa_ctrl_request(ctrl, "IFNAME", 6, buf, &len, NULL) == 0) {
 		buf[len] = '\0';
+		if (os_strcmp(buf, "UNKNOWN COMMAND\n") == 0)
+			os_snprintf(buf, len, "unknown");
 		ctrl->remote_ifname = os_strdup(buf);
 	}