Compile wpa supplicant for x86/x86_64 with p2p support

This blog provides the steps to compile wpa_supplicant with p2p support for x86/x86_64 processors.

Clone the source code

Since we are going to compile the latest source we need to have a few prerequisites checked before proceeding.

Git — needs to be installed on the machine were we are going to compile the source. Git is used to clone the source code from the hostapd repo. Since many projects are using git to maintain there source code this should be available by default.

Check whether your WiFi card supports the p2p modes. This can be checked using the “iw phy” command. grep for interface modes in the above command’s output.

Sample output

Supported interface modes:
* IBSS
* managed
* AP
* AP/VLAN
* WDS
* monitor
* mesh point
* P2P-client
* P2P-GO

With git available we can now start to clone the latest code using the following command from the repo.

kasi@kasi-desktop:~$ git clone git://w1.fi/srv/git/hostap.git
Cloning into ‘hostap’…
remote: Counting objects: 74220, done.
remote: Compressing objects: 100% (16579/16579), done.
remote: Total 74220 (delta 60722), reused 70338 (delta 57445)
Receiving objects: 100% (74220/74220), 15.20 MiB | 1.22 MiB/s, done.
Resolving deltas: 100% (60722/60722), done.
Checking connectivity… done.
kasi@kasi-desktop:~$ cd hostap/
kasi@kasi-desktop:~/hostap$ ls
Android.mk  CONTRIBUTIONS  doc  hostapd  mac80211_hwsim  README  tests wpadebug  wpa_supplicant build_release  COPYING        eap_example  hs20     radius_example  src     wlantest  wpaspy

Setup the config and modify it

After downloading the source code, we now go ahead and edit the config file with the needed options.

By default there is already a config file in the cloned source code which we can use.

kasi@kasi-desktop:~/hostap$ cp wpa_supplicant/defconfig wpa_supplicant/.config

The above command copies the defconfig file to .config which we can edit to suit our needs.This is a very neat and simple approach as we just need work on a single file alone to do what we need.

Changes to the config file to add support for p2p:

CONFIG_DRIVER_NL80211=y
CONFIG_LIBNL32=y (This option is needed for libnl 3.2 libraries and above)
CONFIG_WPS=y
CONFIG_CTRL_IFACE=y
CONFIG_AP=y
CONFIG_P2P=y

These are the options which needs to be enabled to compile wpa_supplicant with p2p support.

And also the below are few additional options which can be added depending upon the mode supported by the WiFi card in use:

CONFIG_IEEE80211N=y
CONFIG_IEEE80211AC=y

After making the changes to the config file, save it.

Now we are ready to compile wpa_supplicant for x86/x86_64. Move inside the wpa_supplicant directory and just give make to start the compilation.

kasi@kasi-desktop:~/hostap$ cd wpa_supplicant/
kasi@kasi-desktop:~/hostap/wpa_supplicant$ make
  CC  config.c
  CC  notify.c
  CC  bss.c
  CC  eap_register.c
  CC  ../src/utils/common.c
  CC  ../src/utils/wpa_debug.c
  CC  ../src/utils/wpabuf.c

<– Cut Here to reduce the logs –>

  LD  wpa_supplicant
  CC  wpa_cli.c
  CC  ../src/common/wpa_ctrl.c
  CC  ../src/common/cli.c
  CC  ../src/utils/edit_simple.c
  LD  wpa_cli
  CC  wpa_passphrase.c
  LD  wpa_passphrase
  sed systemd/wpa_supplicant.service.in
  sed systemd/wpa_supplicant.service.arg.in
  sed systemd/wpa_supplicant-nl80211.service.arg.in
  sed systemd/wpa_supplicant-wired.service.arg.in
  sed dbus/fi.epitest.hostap.WPASupplicant.service.in
  sed dbus/fi.w1.wpa_supplicant1.service.in

Now lets check the compiled binary.

kasi@kasi-desktop:~/hostap/wpa_supplicant$ file wpa_supplicant
wpa_supplicant: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=346ab293d083587885bdba6fafd9d40f82772873, not stripped

file” command shows that the wpa_supplicant has been compiled for x86_64 machine. Now we can either export the path of this directory and use this wpa_supplicant or we can simply run this from the directory itself using ./wpa_supplicant along with the proper config file and interface.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s