Sign in to follow this  
nightrayy

C code to get the same information like iwlist wlan scan

Recommended Posts

Welcome is there any possibility to get the same information in application in C like iwlist wlan scan in terminal ? Only what I found is : How can I get a list of available wireless networks on Linux? which does not work and show only ssid of available network. I would like to get mainly ssid and mac adresses devices available on interface WLAN.

Share this post


Link to post
Share on other sites

Another option would be to avoid duplicating the code but instead to create a pipe(), fork() your process, then in the child set stdin / stdout to use the pipe and finally exec() the iwlist program so that the parent process can read the output from the pipe and parse it.

This is essentially what happens when you use the unix "|" on the command line to pipe the output of one process to the input of another.

Share this post


Link to post
Share on other sites
I agree; those tools are written in C, so you can do whatever they do.

I don't know what your install options are. For example, if you need to be able to build and install for systems where you can't guarantee that iwlist is installed, you may want to include the equivalent code instead. Else, just use pipe/fork/exec, or even the simplistic popen() function.

Note that some functions may need root privileges, so may not be great for using in a piece of software you ship to end users.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this