platform_system_core/libnl_2
Jouni Malinen 831cbc9d29 libnl: Add nla_put_u8/u16/u32/u64() wrapper
Change-Id: I9c07bbff1f678b5c406dbd455c830363af093703
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
2012-08-09 14:38:47 -07:00
..
genl libnl_2: Extend genl_ctrl_resolve() to support "nl80211" name 2012-07-10 17:49:22 -07:00
.gitignore Cleanroom libnl_2 library 2011-06-28 13:28:02 -07:00
Android.mk libnl_2: compile as shared library as well 2012-06-11 14:18:45 -07:00
README libnl_2: Update README 2011-08-12 14:46:33 -07:00
attr.c libnl: Add nla_put_u8/u16/u32/u64() wrapper 2012-08-09 14:38:47 -07:00
cache.c Cleanroom libnl_2 library 2011-06-28 13:28:02 -07:00
dbg.c libnl_2: Fix nested attribute setting 2011-08-10 15:25:51 -07:00
handlers.c libnl_2: Fix memory leaks 2011-11-01 15:56:22 -07:00
msg.c libnl_2: Fix nested attribute setting 2011-08-10 15:25:51 -07:00
netlink.c libnl_2: Fix memory leaks 2011-11-01 15:56:22 -07:00
object.c Cleanroom libnl_2 library 2011-06-28 13:28:02 -07:00
socket.c libnl_2: Add nl_socket_set_cb() and nl_socket_get_cb() 2012-07-10 10:47:48 -07:00

README

Netlink Protocol Library

This library is a clean room re-implementation of libnl 2.0 and
re-licensed under Apache 2.0. It was developed primarily to support
wpa_supplicant. However, with additional development can be extended
to support other netlink applications.

Netlink Protocol Format (RFC3549)

+-----------------+-+-------------------+-+
|Netlink Message  |P| Generic Netlink   |P|
|    Header       |A|  Message Header   |A|
|(struct nlmsghdr)|D|(struct genlmsghdr)|D|
+-----------------+-+-------------------+-+-------------+
|len:4|type:2|flags:2|seq:4 pid:4|cmd:1|ver:1|reserved:2|
+--------------------------------+----------------------+
+-----------------+-+-----------------+-+-----------------+-+-----------------+-+---+
|Netlink Attribute|P|Netlink Attribute|P|Netlink Attribute|P|Netlink Attribute|P|...|
|    #0 Header    |A|   #0 Payload    |A|   #1 Header     |A|   #1 Payload    |A|   |
| (struct nlattr) |D|     (void)      |D| (struct nlattr) |D|     (void)      |D|   |
+-----------------+-+-----------------+-+-----------------+-+-----------------+-+---+
|len:2(==4+payload)|type:2|payload|pad|
+-------------------------+-------+---+

NETLINK OVERVIEW

* Each netlink message consists of a bitstream with a netlink header.
* After this header a second header *can* be used specific to the netlink
  family in use. This library was tested using the generic netlink
  protocol defined by struct genlmsghdr to support nl80211.
* After the header(s) netlink attributes can be appended to the message
  which hold can hold basic types such as unsigned integers and strings.
* Attributes can also be nested. This is accomplished by calling "nla_nest_start"
  which creates an empty attribute with nest attributes as its payload. Then to
  close the nest, "nla_nest_end" is called.
* All data structures in this implementation are byte-aligned (Currently 4 bytes).
* Acknowledgements (ACKs) are sent as NLMSG_ERROR netlink message types (0x2) and
  have an error value of 0.

KNOWN ISSUES

  GENERAL
  * Not tested for thread safety

  Android.mk
  * No dynamic library because of netlink cache not implemented and
    not tested for thread safety

  attr.c
  * nla_parse - does not use nla_policy argument

  cache.c
  * netlink cache not implemented and only supports one netlink family id
    which is stored in the nl_cache pointer instead of an actual cache

  netlink.c
  * nl_recvmsgs - does not support nl_cb_overwrite_recv()
  * nl_recv - sets/unsets asynchronous socket flag

SOURCE FILES

* Android.mk - Android makefile
* README - This file
* attr.c - Netlink attributes
* cache.c - Netlink cache
* genl/family.c - Generic netlink family id
* genl/genl.c - Generic netlink
* handlers.c - Netlink callbacks
* msg.c - Netlink messages construction
* netlink.c - Netlink socket communication
* object.c - libnl object wrapper
* socket.c - Netlink kernel socket utils

IMPORTANT HEADER FILES - NOTE: These are based on the the origin GPL libnl headers

* netlink-types.h - Contains many important structs for libnl
  to represent netlink objects
* netlink/netlink-kernel.h - Netlink kernel headers and field constants.
* netlink/msg.h - macros for iterating over netlink messages
* netlink/attr.h - netlink attribute constants, iteration macros and setters

REFERENCES

* nl80211.h
* netlink_types.h
* $LINUX_KERNEL/net/wireless/nl80211.c
* http://www.infradead.org/~tgr/libnl/doc-3.0/index.html
* http://www.netfilter.org/projects/libmnl/doxygen/index.html