Hunter Oklejas
Hunter Oklejas

Reputation: 1

rtw_android.c error: implicit declaration of function ‘strnicmp’ [-Werror=implicit-function-declaration]

I am trying tin install my Alfa AWUS036ACH adapter for Kali linux 2.0

I have fixed the prior errors but now I am stuck here. This is the error I am receiving.

os_dep/linux/rtw_android.c:345:3: error: implicit declaration of function ‘strnicmp’ [-Werror=implicit-function-declaration] if(0 == strnicmp(cmdstr , android_wifi_cmd_str[cmd_num], strlen(android_wifi_cmd_str[cmd_num])) ) ^

My coding skills are not up to par and I am still learning so any help would be appreciated.

The code in specific is as follows:

int rtw_android_cmdstr_to_num(char *cmdstr)
{
    int cmd_num;
    for(cmd_num=0 ; cmd_num<ANDROID_WIFI_CMD_MAX; cmd_num++)
        if(0 == strnicmp(cmdstr , android_wifi_cmd_str[cmd_num], strlen(android_wifi_cmd_str[cmd_num])) )
        break;

return cmd_num;
}

I looked at other peoples answers to other questions and I am not sure how this code should be adjusted.

Upvotes: 0

Views: 2226

Answers (1)

Pieter D.J. Krul
Pieter D.J. Krul

Reputation: 21

A partial answer to your question:

Kali Linux 2.0, based on Debian Jessie, comes with a Linux 4.x kernel.

In recent Linux versions, the system call strnicmp has been deprecated and replaced by a wrapper, to allow later removal, in favour of strncasecmp. See also this commit log.

One way to find out if your system supports these calls, is to look for their names in the kernel symbol table, a table with names and their memory locations. This symbol table is usually represented by a file named System.map, and located in /boot/.

An example for Linux 2.6.32:

    $ grep -e strnicmp -e strncasecmp /boot/System.map-2.6.32
    ffffffff81298450 T strnicmp
    ffffffff81298540 T strncasecmp
    ffffffff8183a680 r __ksymtab_strncasecmp
    ffffffff8183a6a0 r __ksymtab_strnicmp
    ffffffff8184e0d0 r __kcrctab_strncasecmp
    ffffffff8184e0e0 r __kcrctab_strnicmp
    ffffffff81861153 r __kstrtab_strncasecmp
    ffffffff8186116a r __kstrtab_strnicmp

An example for Linux 4.4.6:

    $ grep -e strnicmp -e strncasecmp /boot/System.map-4.4.6
    ffffffff813aaee0 T strncasecmp
    ffffffff81b484a0 R __ksymtab_strncasecmp
    ffffffff81b608c8 r __kcrctab_strncasecmp
    ffffffff81b776e4 r __kstrtab_strncasecmp

To fix your problem, without regression, a clause that reflects the renaming will have to be added to the code, in this case rtw_android.c.

An example diff for Linux version 4.0.0:

    diff -urN os_dep.orig/linux/rtw_android.c os_dep/linux/rtw_android.c
    --- os_dep.orig/linux/rtw_android.c 2016-03-29 13:53:46.657398453 +0200
    +++ os_dep/linux/rtw_android.c  2016-03-29 13:26:13.871323615 +0200
    @@ -30,6 +30,10 @@
     #endif
     #endif /* defined(RTW_ENABLE_WIFI_CONTROL_FUNC) */

    +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0))
    +#define strnicmp strncasecmp
    +#endif
    +

     const char *android_wifi_cmd_str[ANDROID_WIFI_CMD_MAX] = {
        "START",

Upvotes: 2

Related Questions