Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

which c/c++ library can be used for handling wifi connections for linux?

Tags:

c++

c

linux

wifi

I want to implement WiFi manager program which should handle the following.

  • notification on wi-fi access point has come or gone
  • provide information of available wifi access point
  • connect/disconnect with a given wi-fi access point

Which is the recommended C/C++ WiFi library for Linux to achieve this?

like image 702
Ashish Avatar asked Dec 28 '11 21:12

Ashish


3 Answers

On Fedora (at least), the preferred way to interact with NetworkManager is via DBus.

While wireless-tools and the like will work — even direct kernel calls, if you must — there are a couple of problems:

  • You'll probably need superuser privileges
  • NetworkManager will probably have a panic attack and get into fights with you, unless you stop its service
  • The user's normal networking controls (e.g. desktop tray icons) are almost certainly configured to use NetworkManager.

You can send and receive DBus messages for all the tasks you mentioned, for WiFi as well as arbitrary other types of network interfaces. The API is published here, for version 0.8.

For newer operating systems, there are apparently changes in the API, with a migration guide.

Their wiki should be really helpful.

I know both Fedora and Ubuntu use NetworkManager by default; I believe many other systems do, as well, but don't have an exhaustive list.

Of course, if you're using an embedded system, custom distribution, or something, then your mileage may vary.

like image 113
BRPocock Avatar answered Oct 28 '22 18:10

BRPocock


That would be wireless-tools

like image 41
fge Avatar answered Oct 28 '22 17:10

fge


I would recommend using directly the NetworkManager Library.

You can use low-level D-Bus library or libnm-glib library, that makes communication easier: example add connection glib

For more info, you can take a look into the code of the command line client nmcli.

like image 3
asantacreu Avatar answered Oct 28 '22 17:10

asantacreu