Showing posts with label hostapd. Show all posts
Showing posts with label hostapd. Show all posts

Tuesday, March 5, 2013

Making "history" work on wpa_cli/hostapd_cli: Especially for P2P testing

We all are accustomed to the much neglected but most often used "up arrow" so called "history button" specially in a command line environment like a Linux terminal.

 

Recently was working with wpa_cli for some testing on P2P then observed that on some systems the "history" button works but on some it doesn't, so planned to dig it down and as always best way to understand something is to go through the code.

 

If you look in to the hostap_git there are some common utils in the src/utils folder, there we can see 3 different types of "edit"'s (edit refers to editing and history of command line)

 

  • edit_simple ==> Only editing support is available, no history support.

  • edit ==> Both editing and history support is available

  • edit_readline ==> Uses the standard GNU C library readline for editing and history of commands.

 

 In the makefile the default is edit_simple.

 ifdef CONFIG_READLINE
        OBJS_c += ../src/utils/edit_readline.o
        LIBS_c += -lncurses -lreadline
 else
        ifdef CONFIG_WPA_CLI_EDIT
              OBJS_c += ../src/utils/edit.o
        else
              OBJS_c += ../src/utils/edit_simple.o
         endif 

               endif

So unless you enable the one of the above macros in the ".config" and compile the wpa_supplicant you wont be able to edit or traverse the "history".  out of the edit and readline, readline is much cleaner as it is handled in the library.

 

Same is applicable to hostapd_cli as well. Next time you see "up arrow" not working, recompile the wpa_supplicant with the any of the macro's enabled.



Thursday, January 17, 2013

Wireless LAN and Linux Together



With the advent of opensource the development time has come down hugely and the quality has improved quickly. For all those involved with WLAN/Wi-Fi and Opensource lets take a look at the wlan architecture in linux based on opensource mac80211 framework.

Block diagram explaining linux WLAN architecture. Please see below for details.


User-Space:


Configuration: wpa_supplicant and hostapd:


All the applications which interact directly with the user lie here. They can a GUI/CLI based ones for eg. network manager in ubuntu/fedora distributions are UI based ones, but the core part are the CLI based ones eg. wpa_supplicant for controlling the STA part of it and hostapd for controlling the AP part.

Both are configuration file based along with their cli versions (wpa_cli, hostapd_cli) to send commands on the fly.

They support different features like SME, MLME, Security, Wifi-Direct (P2P),  AP and STA configurations.


Tools:

We also have tools to send commands to the driver directly to set some parameters such as channel, bandwidth, some custom commands etc.

The Bridge: User and Kernel


Now how the various applications in userspace communicate to the core entities in the kernel? Well, we have different approaches but all are based on different socket interfaces.


  1. WExt ==> Generic Wireless Extensions: IOCTL Interface
  2. NL80211==> Netlink Sockets
  3. HostAP,==> Raw Packet Sockets
  4. Chipset specific:

  •               Atheros==> IOCTL Interface 
  •               Prism,IPW etc.


Kernel Space


Configuration and UMAC


For opensource world the framework in kernel for WLAN is mac80211, it separates itself in to 2 kernel modules


  • cfg80211.ko: Which handles all the configuration, user space interaction
  • mac80211.ko: Protocol: Upper MAC , driver interaction.


Most of the features and management is handled by the mac80211 module with the help of lower MAC.

Lower MAC Drivers


Lowe MAC drivers act as a bridge between the UMAC and the chipset (Firmware and HW). They do all the device initialization, registration with OS, Bug Registration, Interrupts registration etc through the services provided by the linux kernel.

A well written driver follows these conventions


  • Maintains a OS Independent Layer: Easy portability to different OSes.
  • Maintains a UMAC Independent Layer: Easpy portability to different UMAC's: Proprietary, opensource, 3rd party etc.
  • Bus Abstraction Layer: Maintains compatibility across different Physical Buses like PCI, PCIe, AHB, SDIO etc.


Chipset: Firmware and HW


The full 802.11 protocol functionality is implemented here.

The firmware which probably runs on a separate processor/micro-controller configures and controls the hardware and also interacts with the host(The driver) through a messaging interface specific to the chipset (control path)

The Data path generally involves a DMA controller in the HW which takes care of generating interrupts to the host processor and transferring packets to and from the Host to the HW queues.


References:


  1. wpa_supplicant_hostapd_devel_doc
  2. For details on these click userspace_configurations.
  3. wpa_supplicant