Register a new frame reception
Carlos Guimarães
asc2.cemg
Thu Mar 10 08:16:56 PST 2011
Hi,
I need to received some action frames to process in userspace. I'm
registering its receptions by sending a @NL80211_CMD_REGISTER_ACTION
message. Everything seems correct until this point. The problem is that I
can't receive anything at userspace. I defined the handler and wait for
incoming messages but nothing seems to arrive.
Next it's the code I use to register and wait for the actions frames.
int mac80211_reg_action(const char *interface) {
struct nl_sock *nl_handle = NULL;
struct nl_cache *nl_cache = NULL;
struct genl_family *nl80211 = NULL;
struct nl_msg *msg;
// Init mac80211 connection
if (mac80211_connect(interface,
(void **) &nl_handle,
(void **) &nl_cache,
(void **) &nl80211) < 0) {
return -1;
}
if ((msg = nlmsg_alloc()) == NULL) {
mac80211_disconnect(nl_handle);
return -2;
}
//
// Create message to send to mac80211
genlmsg_put(msg, 0, 0, genl_family_get_id(nl80211), 0, 0,
NL80211_CMD_REGISTER_ACTION, 0);
NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(interface));
nla_put_u8(msg, NL80211_ATTR_FRAME_MATCH, 2);
if (nl_send_auto_complete(nl_handle, msg) < 0) {
nla_put_failure:
nlmsg_free(msg);
mac80211_disconnect(nl_handle);
return errno;
}
//
// wait for incoming messages
struct nl_cb *cb;
int err;
cb = nl_cb_alloc(NL_CB_DEFAULT);
err = 1;
nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, valid_handler, NULL);
nl_cb_set(cb, NL_CB_FINISH, NL_CB_CUSTOM, error_handler, &err);
while (err > 0)
nl_recvmsgs(nl_handle, cb);
nlmsg_free(msg);
return 0;
}
What could be wrong?
Thanks,
Carlos
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.shmoo.com/pipermail/hostap/attachments/20110310/b0e65d2f/attachment.htm
More information about the Hostap
mailing list