mywiki:linux:generic_netlink
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| mywiki:linux:generic_netlink [2015/05/16 08:48] – [Data Structure of Generic Netlink] shaoguoh | mywiki:linux:generic_netlink [2019/09/15 18:55] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 95: | Line 95: | ||
| </ | </ | ||
| + | {{: | ||
| + | |||
| + | {{: | ||
| ====== Procedure in kernel ====== | ====== Procedure in kernel ====== | ||
| Line 223: | Line 226: | ||
| </ | </ | ||
| + | |||
| + | |||
| + | ===== Define attribute ===== | ||
| + | |||
| + | |||
| + | < | ||
| + | |||
| + | |||
| + | </ | ||
| + | |||
| + | |||
| + | Notes: Attributes And Message Payloads | ||
| + | |||
| + | Most common data structures can be represented with Netlink attributes: | ||
| + | scalar values: Most scalar values already have well-defined attribute types; | ||
| + | Arrays: Arrays can be represented by using a single nested attribute as a container with several of the same attribute type inside each representing a spot in the array. | ||
| + | |||
| + | It is also important to use unique attributes as much as possible. This helps make the most of the Netlink attribute mechanisms and provides for easy changes to the message format in the future. | ||
| + | |||
| ===== Define Message structure ===== | ===== Define Message structure ===== | ||
| Line 257: | Line 279: | ||
| </ | </ | ||
| - | |||
| - | ===== Define attribute policy ===== | ||
| - | |||
| - | |||
| - | < | ||
| - | The nla_policy Structure | ||
| - | |||
| - | Generic Netlink attribute policy is defined by the nla_policy structure, which is shown below: | ||
| - | |||
| - | struct nla_policy | ||
| - | { | ||
| - | | ||
| - | | ||
| - | }; | ||
| - | |||
| - | Fig: The nla_policy structure | ||
| - | |||
| - | The fields are used in the following manner: | ||
| - | |||
| - | u16 type | ||
| - | This specifies the type of the attribute; presently the following types are defined for general use: | ||
| - | NLA_UNSPEC | ||
| - | Undefined type | ||
| - | NLA_U8 | ||
| - | An 8-bit unsigned integer | ||
| - | NLA_U16 | ||
| - | A 16-bit unsigned integer | ||
| - | NLA_U32 | ||
| - | A 32-bit unsigned integer | ||
| - | NLA_U64 | ||
| - | A 64-bit unsigned integer | ||
| - | NLA_FLAG | ||
| - | A simple boolean flag | ||
| - | NLA_MSECS | ||
| - | A 64-bit time value in msecs | ||
| - | NLA_STRING | ||
| - | A variable length string | ||
| - | NLA_NUL_STRING | ||
| - | A variable length NULL terminated string | ||
| - | NLA_NESTED | ||
| - | A stream of attributes | ||
| - | u16 len | ||
| - | When the attribute type is one of the string types then this field should be set to the maximum length of the string, not including the terminal NULL byte. If the attribute type is unknown or NLA_UNSPEC then this field should be set to the exact length of the attribute' | ||
| - | Unless the attribute type is one of the fixed-length types above, a value of zero indicates that no validation of the attribute should be performed. | ||
| - | </ | ||
| - | |||
| - | |||
| - | Notes: Attributes And Message Payloads | ||
| - | |||
| - | Most common data structures can be represented with Netlink attributes: | ||
| - | scalar values: Most scalar values already have well-defined attribute types; | ||
| - | Arrays: Arrays can be represented by using a single nested attribute as a container with several of the same attribute type inside each representing a spot in the array. | ||
| - | |||
| - | It is also important to use unique attributes as much as possible. This helps make the most of the Netlink attribute mechanisms and provides for easy changes to the message format in the future. | ||
mywiki/linux/generic_netlink.1431737320.txt.gz · Last modified: (external edit)
