9#include <netlink/netlink.h>
10#include <netlink/object.h>
11#include <netlink/attr.h>
30#define NL_AUTO_PID NL_AUTO_PORT
50extern void *
nlmsg_data(
const struct nlmsghdr *);
52extern void * nlmsg_tail(
const struct nlmsghdr *);
55extern struct nlattr *
nlmsg_attrdata(
const struct nlmsghdr *,
int);
59extern int nlmsg_valid_hdr(
const struct nlmsghdr *,
int);
60extern int nlmsg_ok(
const struct nlmsghdr *,
int);
61extern struct nlmsghdr *
nlmsg_next(
struct nlmsghdr *,
int *);
62extern int nlmsg_parse(
struct nlmsghdr *,
int,
struct nlattr **,
75extern int nlmsg_append(
struct nl_msg *,
void *,
size_t,
int);
78extern struct nlmsghdr *
nlmsg_put(
struct nl_msg *, uint32_t, uint32_t,
80extern struct nlmsghdr *
nlmsg_hdr(
struct nl_msg *);
85extern void nlmsg_set_proto(
struct nl_msg *,
int);
86extern int nlmsg_get_proto(
struct nl_msg *);
87extern size_t nlmsg_get_max_size(
struct nl_msg *);
88extern void nlmsg_set_src(
struct nl_msg *,
struct sockaddr_nl *);
89extern struct sockaddr_nl *nlmsg_get_src(
struct nl_msg *);
90extern void nlmsg_set_dst(
struct nl_msg *,
struct sockaddr_nl *);
91extern struct sockaddr_nl *nlmsg_get_dst(
struct nl_msg *);
92extern void nlmsg_set_creds(
struct nl_msg *,
struct ucred *);
93extern struct ucred * nlmsg_get_creds(
struct nl_msg *);
95extern char * nl_nlmsgtype2str(
int,
char *,
size_t);
96extern int nl_str2nlmsgtype(
const char *);
98extern char * nl_nlmsg_flags2str(
int,
char *,
size_t);
100extern int nl_msg_parse(
struct nl_msg *,
101 void (*cb)(
struct nl_object *,
void *),
119#define nlmsg_for_each_attr(pos, nlh, hdrlen, rem) \
120 nla_for_each_attr(pos, nlmsg_attrdata(nlh, hdrlen), \
121 nlmsg_attrlen(nlh, hdrlen), rem)
129#define nlmsg_for_each(pos, head, len) \
130 for (int rem = len, pos = head; \
131 nlmsg_ok(pos, rem); \
132 pos = nlmsg_next(pos, &rem))
134#define nlmsg_for_each_msg(pos, head, len, rem) \
135 nlmsg_for_each(pos, head, len)
int nlmsg_ok(const struct nlmsghdr *, int)
check if the netlink message fits into the remaining bytes
void nl_msg_dump(struct nl_msg *, FILE *)
Dump message in human readable format to file descriptor.
int nlmsg_total_size(int)
Calculates size of netlink message including padding based on payload length.
struct nlmsghdr * nlmsg_hdr(struct nl_msg *)
Return actual netlink message.
struct nl_msg * nlmsg_alloc_simple(int, int)
Allocate a new netlink message.
void * nlmsg_data(const struct nlmsghdr *)
Return pointer to message payload.
void nlmsg_get(struct nl_msg *)
Acquire a reference on a netlink message.
struct nlmsghdr * nlmsg_next(struct nlmsghdr *, int *)
next netlink message in message stream
int nlmsg_validate(struct nlmsghdr *, int, int, const struct nla_policy *)
nlmsg_validate - validate a netlink message including attributes
void * nlmsg_reserve(struct nl_msg *, size_t, int)
Reserve room for additional data in a netlink message.
struct nl_msg * nlmsg_convert(struct nlmsghdr *)
Convert a netlink message received from a netlink socket to a nl_msg.
void nlmsg_free(struct nl_msg *)
Release a reference from an netlink message.
int nlmsg_parse(struct nlmsghdr *nlh, int hdrlen, struct nlattr *tb[], int maxtype, const struct nla_policy *policy)
parse attributes of a netlink message
struct nl_msg * nlmsg_alloc_size(size_t)
Allocate a new netlink message with maximum payload size specified.
int nlmsg_expand(struct nl_msg *, size_t)
Expand maximum payload size of a netlink message.
struct nlattr * nlmsg_find_attr(struct nlmsghdr *, int, int)
nlmsg_find_attr - find a specific attribute in a netlink message
struct nl_msg * nlmsg_alloc(void)
Allocate a new netlink message with the default maximum payload size.
int nlmsg_datalen(const struct nlmsghdr *)
Return length of message payload.
struct nlmsghdr * nlmsg_put(struct nl_msg *, uint32_t, uint32_t, int, int, int)
Add a netlink message header to a netlink message.
int nlmsg_attrlen(const struct nlmsghdr *, int)
length of attributes data
void nlmsg_set_default_size(size_t)
Set the default maximum message payload size for allocated messages.
int nlmsg_append(struct nl_msg *, void *, size_t, int)
Append data to tail of a netlink message.
int nlmsg_padlen(int)
Size of padding that needs to be added at end of message.
struct nlattr * nlmsg_attrdata(const struct nlmsghdr *, int)
head of attributes data
int nlmsg_size(int)
Calculates size of netlink message based on payload length.
struct nl_msg * nlmsg_inherit(struct nlmsghdr *)
Allocate a new netlink message and inherit netlink message header.
Attribute validation policy.