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

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?



Solution 1:[1]

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.

Solution 2:[2]

That would be wireless-tools

Solution 3:[3]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 BRPocock
Solution 2 fge
Solution 3 asantacreu