19 #include <netlink-private/genl.h> 20 #include <netlink/netlink.h> 21 #include <netlink/genl/genl.h> 22 #include <netlink/utils.h> 87 int version,
int flags)
89 struct genlmsghdr hdr = {
121 struct genlmsghdr *ghdr;
123 if (!nlmsg_valid_hdr(nlh, GENL_HDRLEN))
156 struct genlmsghdr *ghdr;
159 return -NLE_MSG_TOOSHORT;
196 struct genlmsghdr *ghdr;
199 return -NLE_MSG_TOOSHORT;
228 const struct nlmsghdr *nlh;
230 nlh = (
const struct nlmsghdr *)((
const unsigned char *) gnlh - NLMSG_HDRLEN);
231 return (nlh->nlmsg_len - GENL_HDRLEN - NLMSG_HDRLEN);
350 void *
genlmsg_put(
struct nl_msg *msg, uint32_t port, uint32_t seq,
int family,
351 int hdrlen,
int flags, uint8_t cmd, uint8_t version)
353 struct nlmsghdr *nlh;
354 struct genlmsghdr hdr = {
359 nlh =
nlmsg_put(msg, port, seq, family, GENL_HDRLEN + hdrlen, flags);
364 NL_DBG(2,
"msg %p: Added generic netlink header cmd=%d version=%d\n",
367 return (
char *)
nlmsg_data(nlh) + GENL_HDRLEN;
389 return ((
unsigned char *) gnlh + GENL_HDRLEN);
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.
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.
int genlmsg_parse(struct nlmsghdr *nlh, int hdrlen, struct nlattr *tb[], int maxtype, const struct nla_policy *policy)
Parse Generic Netlink message including attributes.
Attribute validation policy.
int genl_connect(struct nl_sock *sk)
Connect a Generic Netlink socket.
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.
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.
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_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.