93 #include <netlink-generic.h> 94 #include <netlink/netlink.h> 95 #include <netlink/genl/genl.h> 96 #include <netlink/utils.h> 103 int genl_connect(
struct nl_handle *handle)
129 int version,
int flags)
131 struct genlmsghdr hdr = {
147 int genlmsg_valid_hdr(
struct nlmsghdr *nlh,
int hdrlen)
149 struct genlmsghdr *ghdr;
151 if (!nlmsg_valid_hdr(nlh, GENL_HDRLEN))
161 int genlmsg_validate(
struct nlmsghdr *nlh,
int hdrlen,
int maxtype,
164 struct genlmsghdr *ghdr;
166 if (!genlmsg_valid_hdr(nlh, hdrlen))
167 return nl_errno(EINVAL);
174 int genlmsg_parse(
struct nlmsghdr *nlh,
int hdrlen,
struct nlattr *tb[],
177 struct genlmsghdr *ghdr;
179 if (!genlmsg_valid_hdr(nlh, hdrlen))
180 return nl_errno(EINVAL);
193 return ((
unsigned char *) gnlh + GENL_HDRLEN);
204 return (nlh->
nlmsg_len - GENL_HDRLEN - NLMSG_HDRLEN);
247 void *
genlmsg_put(
struct nl_msg *msg, uint32_t pid, uint32_t seq,
int family,
248 int hdrlen,
int flags, uint8_t cmd, uint8_t version)
251 struct genlmsghdr hdr = {
256 nlh =
nlmsg_put(msg, pid, seq, family, GENL_HDRLEN + hdrlen, flags);
261 NL_DBG(2,
"msg %p: Added generic netlink header cmd=%d version=%d\n",
int nla_validate(struct nlattr *head, int len, int maxtype, struct nla_policy *policy)
Validate a stream of attributes.
void * nlmsg_data(const struct nlmsghdr *nlh)
head of message payload
attribute validation policy
uint32_t nlmsg_len
Length of message including header.
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)
Get head of attribute data.
int nl_send_simple(struct nl_handle *handle, int type, int flags, void *buf, size_t size)
Send simple netlink message using nl_send_auto_complete()
int genlmsg_attrlen(const struct genlmsghdr *gnlh, int hdrlen)
Get length of attribute data.
int nla_parse(struct nlattr *tb[], int maxtype, struct nlattr *head, int len, struct nla_policy *policy)
Parse a stream of attributes into a tb buffer.
void * genlmsg_data(const struct genlmsghdr *gnlh)
Get head of message payload.
int nl_connect(struct nl_handle *handle, int protocol)
Create and connect netlink socket.
int genlmsg_len(const struct genlmsghdr *gnlh)
Get lenght of message payload.
int genl_send_simple(struct nl_handle *handle, int family, int cmd, int version, int flags)
Send trivial generic netlink message.
void * genlmsg_put(struct nl_msg *msg, uint32_t pid, uint32_t seq, int family, int hdrlen, int flags, uint8_t cmd, uint8_t version)
Add generic netlink header to netlink message.