monitor: Terminate program when setup of netlink monitor failed

This commit is contained in:
Marcel Holtmann 2014-08-09 12:32:29 -07:00
parent 70bc082d41
commit b5b292ee25
2 changed files with 10 additions and 2 deletions

View File

@ -81,8 +81,11 @@ static void genl_parse(uint16_t type, const void *data, uint32_t len,
if (id == GENL_ID_GENERATE) if (id == GENL_ID_GENERATE)
return; return;
if (!strcmp(name, NL80211_GENL_NAME)) if (!strcmp(name, NL80211_GENL_NAME)) {
nlmon = nlmon_open(ifname, id); nlmon = nlmon_open(ifname, id);
if (!nlmon)
l_main_quit();
}
} }
static void genl_notify(uint16_t type, const void *data, static void genl_notify(uint16_t type, const void *data,

View File

@ -1182,11 +1182,16 @@ static struct l_io *open_packet(const char *name)
struct nlmon *nlmon_open(const char *ifname, uint16_t id) struct nlmon *nlmon_open(const char *ifname, uint16_t id)
{ {
struct nlmon *nlmon; struct nlmon *nlmon;
struct l_io *io;
io = open_packet(ifname);
if (!io)
return NULL;
nlmon = l_new(struct nlmon, 1); nlmon = l_new(struct nlmon, 1);
nlmon->id = id; nlmon->id = id;
nlmon->io = open_packet(ifname); nlmon->io = io;
nlmon->req_list = l_queue_new(); nlmon->req_list = l_queue_new();
l_io_set_read_handler(nlmon->io, nlmon_receive, nlmon, NULL); l_io_set_read_handler(nlmon->io, nlmon_receive, nlmon, NULL);