[Prism54-devel] bug in scan (firmware)

kaleda gadeanta@soften.ktu.lt
Wed, 10 Dec 2003 15:37:43 +0200


Try doing iwlist ethX scan
it's better to do it when you see many ap's (e.g. 8+)
some essid's are printed incorrectly.
I think that it's firmware bug: the first symbol allways is length of
the ssid, 'cause in radio packets ssid is always prepended with its
length, and I think that firmware not always cuts the length before
returning the ssid's from firmware.

On some ssid's its absent, on some it appears.
In my code I've implemented such workarround:
(code from prism54_translate_bss):

 char* pessid;


   /* The ESSID */
    iwe.u.data.length = strnlen(bss->ssid, 32);
    iwe.u.data.flags = 1;
    iwe.cmd = SIOCGIWESSID;

    pessid = bss.ssid;
    if (pessid[0] < ' ') {
      pessid++;
      iwe.u.data.length--;
     }

    current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe,
pessid);
	
As ssid's always (well, they can have nonprintable chars, but mostly
they are alpha-numerical) are printable chars - for me it works
correctly.

While writing this I've just one improovement came to mind:
its possible event to check:
1. if first character is nonprintable (< ' '), 
2. maybe even check its less than 33 (max length of ssid, but i think
its just enougth of 1st check) 
3. and is the length of the string (strlen(pessid) - 1, 'cause the first
byte (this length) isn't counted.

what I mean is
    // essid bug workarround
    // iwe.u.data.length was already calculated this way:
    // iwe.u.data.length = strnlen(bss->ssid, 32);
    if ((pessid[0] < ' ') && 
		(pessid[0] == (iwe.u.data.length - 1)))
    {
      pessid++;
      iwe.u.data.length--;
     }

I think such condition is enought - i think it's not possible, that:
1. first byte is nonprintable and
2. by accident it's equal to the length of the ssid


PS:
I'm not sure, if I clearly described the problem, but hope you'll get
the point ;-)


Kaleda
(aka Antanas Gadeikis)