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.



No comments:

Post a Comment