cancel
Showing results for 
Search instead for 
Did you mean: 

Wi-Fi Bluetooth for Linux

user_2207821
New Contributor

I'm trying to use WHD to make STA. The callback function of the whd_wifi_scan() received unexpected security bit pattern in result_ptr->security.

I investigated whd_wifi_scan_events_handler function in whd_wifi_api.c and it will not clear security member in some situation.

On the other hand the whd_wifi_scan_synch function clears scan_result area with 0. But no mentions about this.

Is caller of whd_wifi_scan() must be clear scan_result area as whd_wifi_scan_synch function does, or cypress(or someone else) modifies whd_wifi_api.c?

Also before return from the callback function must clear area pointed by result_ptr must for next scan.

0 Likes
1 Solution
Zhengbao_Zhang
Moderator
Moderator

yes, thanks a lot for your debug..  we used to clear the global area before start of  every wiced_scan_result_handler  in wifi.c  .

/* Allocate new storage space for next scan result */
scan_result_ptr = MALLOC_OBJECT("scan result", wiced_scan_handler_result_t);
if (scan_result_ptr != NULL)
{
    memset( scan_result_ptr, 0, sizeof(wiced_scan_handler_result_t));

and just as you said this callback is good to clear the area.

I think you can add this callback into your code.

void internal_scan_callback(whd_scan_result_t **result_ptr,

                             void *user_data, whd_scan_status_t status)

we will continue to make the code example more completely .

View solution in original post

17 Replies
Zhengbao_Zhang
Moderator
Moderator

Hello:

  Would you please share the failed log "unexpected security type" ? I want to see if all the APs scaned have this log out, or only special AP reported this issue.

user_2207821
New Contributor

Thank you for reply,

Here is result of whd_wifi_scan(), labled "with clear" is clear result_ptr memory at before call whd_wifi_scan() and just before return from callback function. Labeled "without clear" is no memory is modified by our routine.

with clear

0: SSID= channel=1 security=unknown:ENTERPRISE/AES/(0x02000004)

1: SSID= channel=1 security=WHD_SECURITY_WPA2_AES_PSK(0x00400004)

2: SSID=AP1 channel=1 security=WHD_SECURITY_WPA2_MIXED_PSK(0x00400006)

3: SSID= channel=1 security=WHD_SECURITY_WPA2_AES_PSK(0x00400004)

4: SSID=AP2 channel=2 security=WHD_SECURITY_WPA2_MIXED_PSK(0x00400006)

5: SSID=AP3 channel=2 security=WHD_SECURITY_WEP_PSK(0x00000001)

6: SSID=AP4 channel=3 security=WHD_SECURITY_WPA3_SAE(0x01000004)

7: SSID= channel=3 security=WHD_SECURITY_WEP_PSK(0x00000001)

8: SSID=AP5 channel=3 security=WHD_SECURITY_WPA2_AES_PSK(0x00400004)

9: SSID=AP6 channel=3 security=WHD_SECURITY_WPA2_AES_PSK(0x00400004)

without clear

0: SSID=AP1 channel=1 security=unknown:WPS/WPA2/AES/TKIP/WEP/(0x14400007)

1: SSID= channel=1 security=unknown:WPS/WPA2/AES/TKIP/WEP/(0x14400007)

2: SSID=AP3 channel=2 security=WHD_SECURITY_WEP_PSK(0x00000001)

3: SSID=AP2 channel=2 security=unknown:WPA2/AES/TKIP/WEP/(0x00400007)

4: SSID=AP6 channel=3 security=unknown:WPA2/AES/TKIP/WEP/(0x00400007)

5: SSID= channel=3 security=WHD_SECURITY_WEP_PSK(0x00000001)

6: SSID=AP7 channel=3 security=unknown:WPA2/AES/WEP/(0x00400005)

7: SSID=AP6 channel=3 security=unknown:WPA2/AES/WEP/(0x00400005)

8: SSID=AP6 channel=3 security=unknown:WPA2/AES/WEP/(0x00400005)

9: SSID=AP8 channel=3 security=unknown:WPA2/AES/WEP/(0x00400005)

0 Likes
Zhengbao_Zhang
Moderator
Moderator

That is strange , many routers will not let WEP configured with AES together.

or just for me I will set router into WPA2 only, or WPA mixed, or WEB only (not suggested )

For WPA2/AES/WEP, you can let them go to WHD_SECURITY_WPA2_AES_PSK.

For WPS together, it is also a strange configure , WPS should be a independent feature usually triggered by a button on routers.

I think you can regard them as WPA2/AES .

0 Likes
user_2207821
New Contributor

I think it is not router setting problem. The whd_wifi_scan_events_handler() function does not initialize ->security variable when following condition is met(whd_wifi_api.c, line is around 1869)

    /* Check if AP is configured for RSN */

    if ( (rsnie != NULL) &&

         (rsnie->tlv_header.length >= RSN_IE_MINIMUM_LENGTH + rsnie->pairwise_suite_count * sizeof(uint32_t) ) )

    {

It look like whd_wifi_scan_events_handler() expects ->security area is set to 0.

As I mentioned the whd_wifi_scan_synch() sets ->security variable to 0 at entering scan and returning from callback function.

But wdh_wifi_scan() does not care for ->secuirty variable.

I want to know who need to handle the ->security variable to be 0. When caller of whd_wifi_scan() must be care about it, then document must be update for this point, or cypress(or someone else) update source to ->security variable to 0 as needed.

I think the strange result is result of uninitialized variable(->seurity).

0 Likes
Zhengbao_Zhang
Moderator
Moderator

Would you please tell which module you are using for the test ?  seems you are using modus for the test .

I check the code for checking rsnie info,   it has no difference , but your result of the print really has errors if AP setting isn't wrong.

0 Likes
user_2207821
New Contributor

I'm using Murata Type 1DX includes CYW4343W.

But I think module is not matter for this problem.

As I describe above, result is changed by initialize or not initialize memory.

0 Likes
Zhengbao_Zhang
Moderator
Moderator

ok, I can duplicate the unknown issue now,  I will find time to have a debug, thanks.

0 Likes
Zhengbao_Zhang
Moderator
Moderator

Hello:

in  my test only enterprise AP can't be recognized,  the reason is static void print_scan_result(cy_wcm_scan_result_t *result) in scan_task.c didn't add enterprise printing option .   and record->security is 0 always .

       printf("record security ==0x%x\n",record->security);

        for (a = 0; a < akm_suites->akm_suite_count; ++a)

        {

            uint32_t akm_suite_list_item = ntoh32(akm_suites->akm_suite_list) & 0xFF;

            if (akm_suite_list_item == (uint32_t)WHD_AKM_PSK)

            {

                record->security |= WPA2_SECURITY;

            }

            if (akm_suite_list_item == (uint32_t)WHD_AKM_SAE_SHA256)

            {

                record->security |= WPA3_SECURITY;

            }

            if (akm_suite_list_item == (uint32_t)WHD_AKM_8021X)

            {

                record->security |= ENTERPRISE_ENABLED;

            }

            if (akm_suite_list_item == (uint32_t)WHD_AKM_FT_8021X)

            {

                record->security |= FBT_ENABLED;

                record->security |= ENTERPRISE_ENABLED;

            }

            if (akm_suite_list_item == (uint32_t)WHD_AKM_FT_PSK)

            {

                record->security |= FBT_ENABLED;

            }

        }

       printf("record security after ==0x%x\n",record->security);

record security ==0x0

record security after ==0x2000000

  1  ispot                                -68      1      20:A6:11:22:33:44       UNKNOWN

  2  ispot                                -68      1      20:A6:11:22:33:44       UNKNOWN

  3  ispot                                -68      1      20:A6:11:22:33:44        UNKNOWN

and I am using psoc+4343w board with modustoolbox 2.1 for the test.

0 Likes
user_2207821
New Contributor

Please try more than 1 AP environment which have many configuration like WPA3, WPA2 or etc.

Or please change your test program like follows, set ->security area to not 0 will show unexpected result.

        memset(scan_result_ptr, 0, sizeof(whd_scan_result_t) );

        scan_result_ptr->security = 0xffffffff;

        whd_wifi_scan(.....);

0 Likes
Zhengbao_Zhang
Moderator
Moderator

yes, I am in an open environment for the test. 

and I am using the code directly from the structure

pastedImage_0.png

record security after ==0x400000

record security ==0x0

record security after ==0x400000

15   mesh2                                 -53      6      A0:65:31:11:67: 0         WPA2-MIXED-PSK

record security ==0x0

record security after ==0x400000

record security ==0x0

record security after ==0x400000

16   cisco2                                -57      6     22:50:15:56:44:F0         WPA2-AES-PSK

17   cisco2                                -57      6     22:50:15:56:44:F0         WPA2-AES-PSK

record security ==0x0

record security after ==0x400000

record security ==0x0

record security after ==0x400000

18   NETGEAR85                             -73      7      6C:B0:3E:45:1D: 2D         WPA2-AES-PSK

record security ==0x0

record security after ==0x400000

19   NETGEAR85                             -72      7      6C:B0:3E:45:1D: 2D         WPA2-AES-PSK

20   NETGEAR85                             -72      7      6C:B0:3E:45:1D: 2D         WPA2-AES-PSK

21   NETGEAR85                             -72      7      6C:B0:3E:45:1D: 2D         WPA2-AES-PSK

22   NETGEAR85                             -72      7      6C:B0:3E:45:1D: 2D         WPA2-AES-PSK

23   NETGEAR85                             -72      7      6C:B0:3E:45:1D: 2D         WPA2-AES-PSK

record security ==0x0

record security after ==0x2000000

record security ==0x0

record security after ==0x400000

record security ==0x0

record security after ==0x400000

record security ==0x0

record security after ==0x2000000

record security ==0x0

record security after ==0x400000

record security ==0x0

record security after ==0x2000000

24   leikeT                                -50     11       8:33:79:45:6D:BA                OPEN

25   leikeT                                -50     11       8:33:79:45:6D:BA                 OPEN

26   leikeT                                -50     11       8:33:79:45:6D:BA                 OPEN

27   leikeT                                -50     11       8:33:79:45:6D:BA                OPEN

28   leikeT                                -50     11       8:33:79:45:6D:BA                OPEN

29   leikeT                                -50     11      8:33:79:45:6D:BA                 OPEN

30   leikeT                                -50     11       8:33:79:45:6D:BA                 OPEN

0 Likes
user_2207821
New Contributor

I'm referencing at https://github.com/cypresssemiconductorco/amazon-freertos.

And source is https://github.com/cypresssemiconductorco/amazon-freertos/tree/master/vendors/cypress/whd/src.

But I could not find scan_task.c you mentioned.

It seems cy_wcm_start_scan() is not part of WHD. So is the whd_wifi_scan() used in scan_task.c?

0 Likes
Zhengbao_Zhang
Moderator
Moderator

Using Wi-Fi Connection Manager from AnyCloud

I am using anycloud release for a test with psoc6+4343w , and it is using WHD also.

details are in the link above.

0 Likes
user_2207821
New Contributor

I think you are using AnyCloud library. So you use whd_wifi_scan() via cy_wcm_start_scan() right?

I searched source of cy_wcm_start_scan() but couldn't find out it.

Please tell me the source code URL of cy_wcm_start_scan().

If the source code is NOT opened. Please use whd_wifi_scan() directly to reproduce my question situation.

0 Likes
Zhengbao_Zhang
Moderator
Moderator

Hello:

I think it is open for customers, my steps are:

1. modustoolbox2.1 ,  New --> ModusToolBox Application

pastedImage_1.png

2.  choose the application to download:

3. you will see Anycloud_wifi_scan project in the left project window.

  the code will be downloaded in your workspace, that is an open source.

0 Likes
user_2207821
New Contributor

I setup Anycloud-wifi-scan project and see source code of cy_wcm_start_scan().

The cy_wcm_start_scan() calls whd_wifi_scan() with scan_result which is assigned on global scope area.

And callback function internal_scan_callback() clears result_ptr area before return to caller.

It is same as whd_wifi_scan_synch() does.

Again I want to know should  user of whd_wifi_scan() be care about clearing with 0 to result_ptr area?

If so please add this to document of whd_wifi_scan().

If user of whd_wifi_scan() does not have to care about result_ptr, please modify whd_wifi_scan() to work well.

0 Likes
Zhengbao_Zhang
Moderator
Moderator

yes, thanks a lot for your debug..  we used to clear the global area before start of  every wiced_scan_result_handler  in wifi.c  .

/* Allocate new storage space for next scan result */
scan_result_ptr = MALLOC_OBJECT("scan result", wiced_scan_handler_result_t);
if (scan_result_ptr != NULL)
{
    memset( scan_result_ptr, 0, sizeof(wiced_scan_handler_result_t));

and just as you said this callback is good to clear the area.

I think you can add this callback into your code.

void internal_scan_callback(whd_scan_result_t **result_ptr,

                             void *user_data, whd_scan_status_t status)

we will continue to make the code example more completely .

View solution in original post

user_2207821
New Contributor

I understand that caller of whd_wifi_scan() HAVE TO care about scan_result memory to set to 0.

I think the document of whd_wifi_scan() must be described that point.

0 Likes