I want to learn about how nl80211
and cfg80211
works in detail. Function flow, how nl80211
interact with network tools like wpa_supplicant
, iw
.
Plz suggest me some useful links or books to refer.
I want to learn about how nl80211
and cfg80211
works in detail. Function flow, how nl80211
interact with network tools like wpa_supplicant
, iw
.
Plz suggest me some useful links or books to refer.
A slightly more detailed picture of how
nl80211
andcfg80211
work with other parts of the system (user space
,kernel
, andhardware
).nl80211
is the interface between user space software (iw
,wpa_supplicant
, etc.) and the kernel (cfg80211
andmac80211
kernel modules, and specific drivers).cfg80211_ops
is a set of operations that Full-MAC drivers andmac80211
module register tocfg80211
module.ieee80211_ops
is a set of operations that Soft-MAC drivers register tomac80211
module.To be able to control wireless drivers from userspace, some IPC communication processes between kernel and userspace are used.
ioctl
with vendor dependent APIs was used.In 2006, John Linville creates mac80211 and Johannes Berg creates cfg80211 and nl80211. Together it is intended to replace wireless extensions.
An important point is that nl80211/cfg80211/mac80211 no longer use ioctl, they use netlink.
So, tools like iw, hostapd or the wpa_supplicant use some netlink libraries (like libnl or libnl-tiny) and the netlink interface public header which is of course nl80211.h.
There is not so much documentations, but I advice you to read the libnl documentation and then the iw source code (because iw use libnl).
See my reply to How to learn the structure of Linux wireless drivers (mac80211)?
In
wpa_supplicant
, you can follow the code insrc/drivers/driver_nl80211.c
. This is a wpa_supplicant driver (not a kernel driver but an abstraction used inwpa_supplicant
code) which useslibnl
to communicate with the kernelcfg80211
module. Whenwpa_supplicant
issues a scan for example thenwpa_driver_nl80211_scan
gets called. It builds thenetlink
message with a command calledNL80211_CMD_TRIGGER_SCAN
and with all the parameters required for the scan.