libnl 3.7.0
|
Modules | |
Controller (Resolver) | |
Resolves Generic Netlink family names to numeric identifiers. | |
Family and Command Registration | |
Registering Generic Netlink Families and Commands. | |
Generic Netlink Socket | |
int | genl_connect (struct nl_sock *sk) |
Connect a Generic Netlink socket. More... | |
Sending Data | |
int | genl_send_simple (struct nl_sock *sk, int family, int cmd, int version, int flags) |
Send a Generic Netlink message consisting only of a header. More... | |
Message Parsing | |
int | genlmsg_valid_hdr (struct nlmsghdr *nlh, int hdrlen) |
Validate Generic Netlink message headers. More... | |
int | genlmsg_validate (struct nlmsghdr *nlh, int hdrlen, int maxtype, const struct nla_policy *policy) |
Validate Generic Netlink message including attributes. More... | |
int | genlmsg_parse (struct nlmsghdr *nlh, int hdrlen, struct nlattr *tb[], int maxtype, const struct nla_policy *policy) |
Parse Generic Netlink message including attributes. More... | |
struct genlmsghdr * | genlmsg_hdr (struct nlmsghdr *nlh) |
Return pointer to Generic Netlink header. More... | |
int | genlmsg_len (const struct genlmsghdr *gnlh) |
Return length of message payload including user header. More... | |
void * | genlmsg_user_hdr (const struct genlmsghdr *gnlh) |
Return pointer to user header. More... | |
void * | genlmsg_user_data (const struct genlmsghdr *gnlh, const int hdrlen) |
Return pointer to user data. More... | |
int | genlmsg_user_datalen (const struct genlmsghdr *gnlh, const int hdrlen) |
Return length of user data. More... | |
struct nlattr * | genlmsg_attrdata (const struct genlmsghdr *gnlh, int hdrlen) |
Return pointer to message attributes. More... | |
int | genlmsg_attrlen (const struct genlmsghdr *gnlh, int hdrlen) |
Return length of message attributes. More... | |
Message Construction | |
void * | genlmsg_put (struct nl_msg *msg, uint32_t port, uint32_t seq, int family, int hdrlen, int flags, uint8_t cmd, uint8_t version) |
Add Generic Netlink headers to Netlink message. More... | |
Deprecated | |
void * | genlmsg_data (const struct genlmsghdr *gnlh) |
Return pointer to message payload. More... | |
int genl_connect | ( | struct nl_sock * | sk | ) |
Connect a Generic Netlink socket.
sk | Unconnected Netlink socket |
This function expects a struct nl_socket object previously allocated via nl_socket_alloc(). It calls nl_connect() to create the local socket file descriptor and binds the socket to the NETLINK_GENERIC
Netlink protocol.
Using this function is equivalent to:
Definition at line 39 of file genl.c.
References nl_connect().
int genl_send_simple | ( | struct nl_sock * | sk, |
int | family, | ||
int | cmd, | ||
int | version, | ||
int | flags | ||
) |
Send a Generic Netlink message consisting only of a header.
sk | Generic Netlink socket |
family | Numeric family identifier |
cmd | Numeric command identifier |
version | Interface version |
flags | Additional Netlink message flags (optional) |
This function is a shortcut for sending a Generic Netlink message without any message payload. The message will only consist of the Netlink and Generic Netlink headers. The header is constructed based on the specified parameters and passed on to nl_send_simple() to send it on the specified socket.
Definition at line 79 of file genl.c.
References nl_send_simple().
int genlmsg_valid_hdr | ( | struct nlmsghdr * | nlh, |
int | hdrlen | ||
) |
Validate Generic Netlink message headers.
nlh | Pointer to Netlink message header |
hdrlen | Length of user header |
Verifies the integrity of the Netlink and Generic Netlink headers by enforcing the following requirements:
hdrlen
bytes of payload included after the generic netlink header.Definition at line 112 of file genl.c.
References genlmsg_len(), and nlmsg_data().
Referenced by genl_handle_msg(), genlmsg_parse(), and genlmsg_validate().
int genlmsg_validate | ( | struct nlmsghdr * | nlh, |
int | hdrlen, | ||
int | maxtype, | ||
const struct nla_policy * | policy | ||
) |
Validate Generic Netlink message including attributes.
nlh | Pointer to Netlink message header |
hdrlen | Length of user header |
maxtype | Maximum attribtue id expected |
policy | Attribute validation policy |
Verifies the validity of the Netlink and Generic Netlink headers using genlmsg_valid_hdr() and calls nla_validate() on the message payload to verify the integrity of eventual attributes.
Definition at line 146 of file genl.c.
References genlmsg_attrdata(), genlmsg_attrlen(), genlmsg_valid_hdr(), nla_validate(), and nlmsg_data().
int genlmsg_parse | ( | struct nlmsghdr * | nlh, |
int | hdrlen, | ||
struct nlattr * | tb[], | ||
int | maxtype, | ||
const struct nla_policy * | policy | ||
) |
Parse Generic Netlink message including attributes.
nlh | Pointer to Netlink message header |
hdrlen | Length of user header |
tb | Array to store parsed attributes |
maxtype | Maximum attribute id expected |
policy | Attribute validation policy |
Verifies the validity of the Netlink and Generic Netlink headers using genlmsg_valid_hdr() and calls nla_parse() on the message payload to parse eventual attributes.
Definition at line 186 of file genl.c.
References genlmsg_attrdata(), genlmsg_attrlen(), genlmsg_valid_hdr(), nla_parse(), and nlmsg_data().
struct genlmsghdr * genlmsg_hdr | ( | struct nlmsghdr * | nlh | ) |
Return pointer to Generic Netlink header.
nlh | Netlink message header |
Definition at line 205 of file genl.c.
References nlmsg_data().
int genlmsg_len | ( | const struct genlmsghdr * | gnlh | ) |
Return length of message payload including user header.
gnlh | Generic Netlink message header |
Definition at line 219 of file genl.c.
Referenced by genlmsg_attrlen(), genlmsg_user_datalen(), and genlmsg_valid_hdr().
void * genlmsg_user_hdr | ( | const struct genlmsghdr * | gnlh | ) |
Return pointer to user header.
gnlh | Generic Netlink message header |
Calculates the pointer to the user header based on the pointer to the Generic Netlink message header.
Definition at line 237 of file genl.c.
References genlmsg_data().
Referenced by genlmsg_user_data().
void * genlmsg_user_data | ( | const struct genlmsghdr * | gnlh, |
const int | hdrlen | ||
) |
Return pointer to user data.
gnlh | Generic netlink message header |
hdrlen | Length of user header |
Calculates the pointer to the user data based on the pointer to the Generic Netlink message header.
Definition at line 254 of file genl.c.
References genlmsg_user_hdr().
Referenced by genlmsg_attrdata().
int genlmsg_user_datalen | ( | const struct genlmsghdr * | gnlh, |
const int | hdrlen | ||
) |
Return length of user data.
gnlh | Generic Netlink message header |
hdrlen | Length of user header |
Definition at line 268 of file genl.c.
References genlmsg_len().
struct nlattr * genlmsg_attrdata | ( | const struct genlmsghdr * | gnlh, |
int | hdrlen | ||
) |
Return pointer to message attributes.
gnlh | Generic Netlink message header |
hdrlen | Length of user header |
Definition at line 282 of file genl.c.
References genlmsg_user_data().
Referenced by genlmsg_parse(), and genlmsg_validate().
int genlmsg_attrlen | ( | const struct genlmsghdr * | gnlh, |
int | hdrlen | ||
) |
Return length of message attributes.
gnlh | Generic Netlink message header |
hdrlen | Length of user header |
Definition at line 297 of file genl.c.
References genlmsg_len().
Referenced by genlmsg_parse(), and genlmsg_validate().
void * genlmsg_put | ( | struct nl_msg * | msg, |
uint32_t | port, | ||
uint32_t | seq, | ||
int | family, | ||
int | hdrlen, | ||
int | flags, | ||
uint8_t | cmd, | ||
uint8_t | version | ||
) |
Add Generic Netlink headers to Netlink message.
msg | Netlink message object |
port | Netlink port or NL_AUTO_PORT |
seq | Sequence number of message or NL_AUTO_SEQ |
family | Numeric family identifier |
hdrlen | Length of user header |
flags | Additional Netlink message flags (optional) |
cmd | Numeric command identifier |
version | Interface version |
Calls nlmsg_put() on the specified message object to reserve space for the Netlink header, the Generic Netlink header, and a user header of specified length. Fills out the header fields with the specified parameters.
Returns Pointer to user header or NULL if an error occurred.
Definition at line 343 of file genl.c.
References nlmsg_data(), and nlmsg_put().
void * genlmsg_data | ( | const struct genlmsghdr * | gnlh | ) |
Return pointer to message payload.
gnlh | Generic Netlink message header |
Definition at line 380 of file genl.c.
Referenced by genlmsg_user_hdr().