Skip to content

Commit

Permalink
Don't bail out without nl80211 (freifunk-gluon#1)
Browse files Browse the repository at this point in the history
With this change the program just prints an error message when
there is no support for nl80211 in the kernel.

To work properly it is checked wether ctx->wifistations_ctx.fd is
initialized (>= 0) before polling at this file descriptor in
function loop().
  • Loading branch information
matwei authored and neocturne committed Feb 21, 2017
1 parent beed337 commit 749e8ef
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ void loop(struct l3ctx *ctx) {
add_fd(efd, ctx->icmp6_ctx.nsfd, EPOLLIN);
add_fd(efd, ctx->arp_ctx.fd, EPOLLIN);
add_fd(efd, ctx->intercom_ctx.fd, EPOLLIN | EPOLLET);
add_fd(efd, ctx->wifistations_ctx.fd, EPOLLIN);
if (ctx->wifistations_ctx.fd >= 0) {
add_fd(efd, ctx->wifistations_ctx.fd, EPOLLIN);
}

/* Buffer where events are returned */
events = calloc(maxevents, sizeof(struct epoll_event));
Expand Down
8 changes: 7 additions & 1 deletion src/wifistations.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,13 @@ void wifistations_init(wifistations_ctx *ctx) {
int nl80211_id = genl_ctrl_resolve(ctx->nl_sock, "nl80211");
if (nl80211_id < 0) {
fprintf(stderr, "nl80211 not found.\n");
goto fail;
/* To resolve issue #29 we do not bail out, but return with an
* invalid file descriptor and without a wifi socket instead.
*/
ctx->fd = -1;
nl_socket_free(ctx->nl_sock);
ctx->nl_sock = NULL;
return;
}

/* MLME multicast group */
Expand Down

0 comments on commit 749e8ef

Please sign in to comment.