7#include <libmnl/libmnl.h>
8#include <linux/genetlink.h>
12static int data_cb(
const struct nlmsghdr *nlh,
void *data)
14 printf(
"received event type=%d from genetlink group %d\n",
15 nlh->nlmsg_type, group);
19int main(
int argc,
char *argv[])
21 struct mnl_socket *nl;
22 char buf[MNL_SOCKET_BUFFER_SIZE];
26 printf(
"%s [group]\n", argv[0]);
29 group = atoi(argv[1]);
33 perror(
"mnl_socket_open");
38 perror(
"mnl_socket_bind");
44 perror(
"mnl_socket_setsockopt");
50 ret =
mnl_cb_run(buf, ret, 0, 0, data_cb, NULL);
int mnl_cb_run(const void *buf, size_t numbytes, unsigned int seq, unsigned int portid, mnl_cb_t cb_data, void *data)
int mnl_socket_close(struct mnl_socket *nl)
int mnl_socket_setsockopt(const struct mnl_socket *nl, int type, void *buf, socklen_t len)
struct mnl_socket * mnl_socket_open(int bus)
ssize_t mnl_socket_recvfrom(const struct mnl_socket *nl, void *buf, size_t bufsiz)
int mnl_socket_bind(struct mnl_socket *nl, unsigned int groups, pid_t pid)