12#include <netlink-private/genl.h>
13#include <netlink/netlink.h>
14#include <netlink/genl/genl.h>
15#include <netlink/utils.h>
80 int version,
int flags)
82 struct genlmsghdr hdr = {
114 struct genlmsghdr *ghdr;
116 if (!nlmsg_valid_hdr(nlh, GENL_HDRLEN))
149 struct genlmsghdr *ghdr;
152 return -NLE_MSG_TOOSHORT;
189 struct genlmsghdr *ghdr;
192 return -NLE_MSG_TOOSHORT;
221 const struct nlmsghdr *nlh;
223 nlh = (
const struct nlmsghdr *)((
const unsigned char *) gnlh - NLMSG_HDRLEN);
224 return (nlh->nlmsg_len - GENL_HDRLEN - NLMSG_HDRLEN);
343void *
genlmsg_put(
struct nl_msg *msg, uint32_t port, uint32_t seq,
int family,
344 int hdrlen,
int flags, uint8_t cmd, uint8_t version)
346 struct nlmsghdr *nlh;
347 struct genlmsghdr hdr = {
352 nlh =
nlmsg_put(msg, port, seq, family, GENL_HDRLEN + hdrlen, flags);
357 NL_DBG(2,
"msg %p: Added generic netlink header cmd=%d version=%d\n",
360 return (
char *)
nlmsg_data(nlh) + GENL_HDRLEN;
382 return ((
unsigned char *) gnlh + GENL_HDRLEN);
int nla_validate(const struct nlattr *head, int len, int maxtype, const struct nla_policy *policy)
Validate a stream of attributes.
int nla_parse(struct nlattr *tb[], int maxtype, struct nlattr *head, int len, const struct nla_policy *policy)
Create attribute index based on a stream of attributes.
struct genlmsghdr * genlmsg_hdr(struct nlmsghdr *nlh)
Return pointer to Generic Netlink header.
int genlmsg_validate(struct nlmsghdr *nlh, int hdrlen, int maxtype, const struct nla_policy *policy)
Validate Generic Netlink message including attributes.
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.
struct nlattr * genlmsg_attrdata(const struct genlmsghdr *gnlh, int hdrlen)
Return pointer to message attributes.
int genlmsg_len(const struct genlmsghdr *gnlh)
Return length of message payload including user header.
int genlmsg_user_datalen(const struct genlmsghdr *gnlh, const int hdrlen)
Return length of user data.
void * genlmsg_user_hdr(const struct genlmsghdr *gnlh)
Return pointer to user header.
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.
int genlmsg_parse(struct nlmsghdr *nlh, int hdrlen, struct nlattr *tb[], int maxtype, const struct nla_policy *policy)
Parse Generic Netlink message including attributes.
void * genlmsg_user_data(const struct genlmsghdr *gnlh, const int hdrlen)
Return pointer to user data.
void * genlmsg_data(const struct genlmsghdr *gnlh)
Return pointer to message payload.
int genl_connect(struct nl_sock *sk)
Connect a Generic Netlink socket.
int genlmsg_attrlen(const struct genlmsghdr *gnlh, int hdrlen)
Return length of message attributes.
int genlmsg_valid_hdr(struct nlmsghdr *nlh, int hdrlen)
Validate Generic Netlink message headers.
void * nlmsg_data(const struct nlmsghdr *nlh)
Return pointer to message payload.
struct nlmsghdr * nlmsg_put(struct nl_msg *n, uint32_t pid, uint32_t seq, int type, int payload, int flags)
Add a netlink message header to a netlink message.
int nl_connect(struct nl_sock *sk, int protocol)
Create file descriptor and bind socket.
int nl_send_simple(struct nl_sock *sk, int type, int flags, void *buf, size_t size)
Construct and transmit a Netlink message.
Attribute validation policy.