Linux Wireless Programming (1)

来源:互联网 发布:渡口网络破产 编辑:程序博客网 时间:2024/06/05 18:12

Linux Wireless Programming

在 Linux 的 user space 中如何进行 wireless programming 呢?

(1) 最早的一套API由HP公司员工Jean Tourrilhes于1997年开发,全称为Linux Wireless Extensions。一般缩写为wex或wext。这套API使得用户空间的程序能通过ioctl函数来控制无线网卡驱动。

(2) 由于利用ioctl开展编程的方式不太符合Linux驱动开发的要求,所以后来Linux又提供了cfg80211和nl80211两套编程接口用于替代wext。其中,cfg80211用于驱动开发,而nl80211 API供用户空间进程使用以操作那些利用cfg80211 API开发的无线网卡驱动。

Part 1: 关于 Linux Wireless Extensions

(1) Wireless Extensions for Linux
http://www.labs.hpe.com/personal/Jean_Tourrilhes/Linux/Linux.Wireless.Extensions.html

(2) Linux Wireless Wiki
https://wireless.wiki.kernel.org/en/developers/documentation/wireless-extensions

In this section, some questions about WE are answered, e.g.,
Is WE being further developed ?
Why we are abandoning WE ?
What is Wireless-Extensions’ replacement ?
Do we still use WE ?

(3) Some other important information
Wireless Tools for Linux (including WE for Wireless Extensions and WT for Wireless Tools)
http://www.labs.hpe.com/personal/Jean_Tourrilhes/Linux/Tools.html

Part 2: 关于cfg80211和nl80211

(1) cfg80211
https://wireless.wiki.kernel.org/en/developers/documentation/cfg80211

cfg80211 is the Linux 802.11 configuration API. cfg80211 replaces Wireless-Extensions. nl80211 is used to configure a cfg80211 device and is used for kernel ←→ userspace communication. Wireless extensions is now in maintenance mode, no new features will be added to it, we’ll only fix bugs for it. cfg80211 is now feature-par complete with wireless-extensions, it actually has a lot more features that are simply not available and will never be available through wireless extensions.

cfg80211 in Linux Wireless
http://linuxwireless.org/en/developers/Documentation/cfg80211/

(2) nl80211
https://wireless.wiki.kernel.org/en/developers/documentation/nl80211

nl80211 is the new 802.11 netlink interface public header. Together with cfg80211 it is intended to replace Wireless-Extensions. nl80211 and cfg80211 are still under development.

Current users of nl80211:
iw
crda
hostapd
wpa_supplicant (with -Dnl80211)

补充: wpa_supplicant
wpa_supplicant Linux documentation page
https://wireless.wiki.kernel.org/en/users/documentation/wpa_supplicant

Supplicant Home Page
Linux WPA/WPA2/IEEE 802.1X Supplicant
http://w1.fi/wpa_supplicant

Developers’ documentation for wpa_supplicant and hostapd
http://w1.fi/wpa_supplicant/devel
这里写图片描述

这里写图片描述

nl for netlink in short
man 7 netlink 可以看到:
netlink - communication between kernel and user space (AF_NETLINK)
Netlink is used to transfer information between kernel and user-space processes.

nl80211 的基础 libnl
Netlink Protocol Library Suite (libnl)
https://www.infradead.org/~tgr/libnl

Libraries
The interfaces are split into several small libraries to not force applications to link against a single, bloated library.

libnl
Core library implementing the fundamentals required to use the netlink protocol such as socket handling, message construction and parsing, and sending and receiving of data. This library is kept small and minimalistic. Other libraries of the suite depend on this library.
libnl-route
API to the configuration interfaces of the NETLINK_ROUTE family including network interfaces, routes, addresses, neighbours, and traffic control.
libnl-genl
API to the generic netlink protocol, an extended version of the netlink protocol.
libnl-nf
API to netlink based netfilter configuration and monitoring interfaces (conntrack, log, queue)
这里写图片描述

因此,通过 sudo apt-cache search libnl 会得到:
libnl-3-200 - library for dealing with netlink sockets
libnl-3-200-dbg - debug symbols for libnl3
libnl-3-dev - development library and headers for libnl-3
libnl-cli-3-200 - library for dealing with netlink sockets - cli helpers
libnl-cli-3-dev - development library and headers for libnl-cli-3
libnl-genl-3-200 - library for dealing with netlink sockets - generic netlink
libnl-genl-3-dev - development library and headers for libnl-genl-3
libnl-nf-3-200 - library for dealing with netlink sockets - netfilter interface
libnl-nf-3-dev - development library and headers for libnl-nf-3
libnl-route-3-200 - library for dealing with netlink sockets - route interface
libnl-route-3-dev - development library and headers for libnl-route-3
libnl-dev - development library and headers for libnl
libnl-doc - API documentation for libnl
libnl-utils - Utilities for dealing with netlink sockets
libnl1 - library for dealing with netlink sockets
libnlopt-dev - nonlinear optimization library – development package
libnlopt-guile0 - nonlinear optimization library – Guile bindings
libnlopt0 - nonlinear optimization library
ntrack-module-libnl-0 - libnl based ntrack module

众多分开的 shared libraries

1 0