3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-12-23 22:42:37 +01:00

monitor: Add helper functions for parsing-only netlink monitor

This commit is contained in:
Marcel Holtmann 2014-08-05 22:37:31 +02:00
parent e260854da3
commit ce202ac843
2 changed files with 36 additions and 0 deletions

View File

@ -913,6 +913,38 @@ static void nlmon_message(struct nlmon *nlmon, const struct nlmsghdr *nlmsg)
}
}
struct nlmon *nlmon_create(void)
{
struct nlmon *nlmon;
nlmon = l_new(struct nlmon, 1);
nlmon->id = 27;
nlmon->req_list = l_queue_new();
return nlmon;
}
void nlmon_destroy(struct nlmon *nlmon)
{
if (!nlmon)
return;
l_queue_destroy(nlmon->req_list, nlmon_req_free);
l_free(nlmon);
}
void nlmon_print(struct nlmon *nlmon, const void *data, uint32_t size)
{
const struct nlmsghdr *nlmsg;
for (nlmsg = data; NLMSG_OK(nlmsg, size);
nlmsg = NLMSG_NEXT(nlmsg, size)) {
nlmon_message(nlmon, nlmsg);
}
}
static bool nlmon_receive(struct l_io *io, void *user_data)
{
struct nlmon *nlmon = user_data;

View File

@ -26,3 +26,7 @@ struct nlmon;
struct nlmon *nlmon_open(const char *ifname, uint16_t id);
void nlmon_close(struct nlmon *nlmon);
struct nlmon *nlmon_create(void);
void nlmon_destroy(struct nlmon *nlmon);
void nlmon_print(struct nlmon *nlmon, const void *data, uint32_t size);