:: Re: [DNG] netman GIT project
Forside
Slet denne besked
Besvar denne besked
Skribent: Irrwahn
Dato:  
Til: dng
Emne: Re: [DNG] netman GIT project
On Tue, 25 Aug 2015 20:20:20 +0200 (CEST), Karl wrote:
> Irrwahn:
>> On Tue, 25 Aug 2015 19:24:17 +0200 (CEST), Karl wrote:
>>> Tilt!:
>>>> i wonder if we ever get to see such SSIDs from iwlist anyway -
>>>> how is it supposed to print SSIDs that contain the zerobyte ...
>>>
>>> iwlib.c line 989..995:
>>>       /* Is it a non-ASCII character ??? */
>>>       if(isescape || !isascii(*s) || iscntrl(*s))
>>>         {
>>>           /* Escape */
>>>           sprintf(d, "\\x%02X", *s);
>>>           d += 4;
>>>         }

>>
>> Thank you. One problem, though:
>> Not a single version of the Wireless Tools for Linux sources I
>> happened to stumble upon doing a quick internet search contains
>> this snippet, or anything remotely like it. Care to share with us,
>> where this originates?
>
> $ apt-get source wireless-tools
> $ cd wireless-tools-30~pre9
> $ ls iw*.[ch]
> iwconfig.c iwevent.c iwgetid.c iwlib.c iwlib.h iwlib-private.h iwlist.c iwmulticall.c iwpriv.c iwspy.c
> $ grep download debian/copyright
> It was downloaded from: http://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/Tools.html
> $
>
>
> http://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/Tools.html
> under "Wireless Tools latest versions":
> ///
> The main features of the latest beta is support for non-ASCII ESSIDs (such as localised ESSID), support for displaying Scanning Capabilities, slightly bigger scan buffer, fixing minor bug iwconfig parser and minor enhancement to ifrename :
>
>     Wireless Tools version 30-pre9 (beta) 
> ///

>
>> Or give a little more context, particularly
>> how isescape is set?
>
> iwlib.c line 971..981:
>       /* Escape the escape to avoid ambiguity.
>        * We do a fast path test for performance reason. Compiler will
>        * optimise all that ;-) */
>       if(*s == '\\')
>         {
>           /* Check if we would confuse it with an escape sequence */
>           if((e-s) > 4 && (s[1] == 'x')
>              && (isxdigit(s[2])) && (isxdigit(s[3])))
>             {
>               isescape = 1;
>             }


Thanks a lot, Karl! I was stupid enough to not simply apt-get the sources.
I checked, it is exactly the function that is used when printing the scan
results.

That makes escaping for file system path purposes quite easy, as everything
is already escaped, except the notorious '/'. however, that is already taken
care of in my modified version of Ed's netman.

Now, what about the consumers? I found out that wpa_supplicant can digest
printf-style escaping, provided the quoted string is prefixed with 'P':

  # ssid: SSID (mandatory); network name in one of the optional formats:
  #    - an ASCII string with double quotation
  #    - a hex string (two characters per octet of SSID)
  #    - a printf-escaped ASCII string P"<escaped string>"


I was not able to find information on how ifup passes on the information
from the wpa-ssid field. Assuming it is just handed down as is, the only
change in netman would be to prefix the SSID with 'P'.

--
Irrwahn