18 #include <netlink-private/genl.h>
19 #include <netlink/netlink.h>
20 #include <netlink/genl/genl.h>
21 #include <netlink/utils.h>
86 int version,
int flags)
88 struct genlmsghdr hdr = {
120 struct genlmsghdr *ghdr;
122 if (!nlmsg_valid_hdr(nlh, GENL_HDRLEN))
155 struct genlmsghdr *ghdr;
158 return -NLE_MSG_TOOSHORT;
195 struct genlmsghdr *ghdr;
198 return -NLE_MSG_TOOSHORT;
227 const struct nlmsghdr *nlh;
229 nlh = (
const struct nlmsghdr *)((
const unsigned char *) gnlh - NLMSG_HDRLEN);
230 return (nlh->nlmsg_len - GENL_HDRLEN - NLMSG_HDRLEN);
349 void *
genlmsg_put(
struct nl_msg *msg, uint32_t port, uint32_t seq,
int family,
350 int hdrlen,
int flags, uint8_t cmd, uint8_t version)
352 struct nlmsghdr *nlh;
353 struct genlmsghdr hdr = {
358 nlh =
nlmsg_put(msg, port, seq, family, GENL_HDRLEN + hdrlen, flags);
363 NL_DBG(2,
"msg %p: Added generic netlink header cmd=%d version=%d\n",
388 return ((
unsigned char *) gnlh + GENL_HDRLEN);
void * genlmsg_user_hdr(const struct genlmsghdr *gnlh)
Return pointer to user header.
void * nlmsg_data(const struct nlmsghdr *nlh)
Return pointer to message payload.
Attribute validation policy.
int genl_connect(struct nl_sock *sk)
Connect a Generic Netlink socket.
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.
int genlmsg_user_datalen(const struct genlmsghdr *gnlh, const int hdrlen)
Return length of user 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.
int nl_connect(struct nl_sock *sk, int protocol)
Create file descriptor and bind socket.
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.
struct nlattr * genlmsg_attrdata(const struct genlmsghdr *gnlh, int hdrlen)
Return pointer to message attributes.
struct genlmsghdr * genlmsg_hdr(struct nlmsghdr *nlh)
Return pointer to Generic Netlink header.
int genlmsg_attrlen(const struct genlmsghdr *gnlh, int hdrlen)
Return length of message attributes.
int nla_parse(struct nlattr *tb[], int maxtype, struct nlattr *head, int len, struct nla_policy *policy)
Create attribute index based on a stream of attributes.
void * genlmsg_data(const struct genlmsghdr *gnlh)
Return pointer to message payload.
int nl_send_simple(struct nl_sock *sk, int type, int flags, void *buf, size_t size)
Construct and transmit a Netlink message.
int genlmsg_parse(struct nlmsghdr *nlh, int hdrlen, struct nlattr *tb[], int maxtype, struct nla_policy *policy)
Parse Generic Netlink message including attributes.
int genlmsg_validate(struct nlmsghdr *nlh, int hdrlen, int maxtype, struct nla_policy *policy)
Validate Generic Netlink message including attributes.
int genlmsg_len(const struct genlmsghdr *gnlh)
Return length of message payload including user header.
int genlmsg_valid_hdr(struct nlmsghdr *nlh, int hdrlen)
Validate Generic Netlink message headers.
int nla_validate(const struct nlattr *head, int len, int maxtype, const struct nla_policy *policy)
Validate a stream of attributes.
void * genlmsg_user_data(const struct genlmsghdr *gnlh, const int hdrlen)
Return pointer to user data.