Search Linux Wireless

Fwd: nl80211 scanning from userspace

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I'm sorry ... I hit REPLY again to Johannes personally rather than to
the list.  I don't know what it is about this list server that makes
me do it ... maybe there's no Reply-To.

Here was my followup question:


---------- Forwarded message ----------



I have another question about netlink scanning.  Here is what I am
doing.  First, trigger a request to starts canning:

   type = genl_family_get_id(nl80211);
   cmd = NL80211_CMD_TRIGGER_SCAN;
   flags = 0;
   pid = 0;
   (void) genlmsg_put(msg, pid, seqSent, type, 0, flags, cmd, 0);
   int dev = if_nametoindex("wlan0");
   nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev);
   rc = nl_send_auto_complete(sock, msg);


Wait a little while, and I get back a valid message that indicates the
scan is complete.  I handle that here:

bool try_parse_scan_status(struct nl_msg *msg) {
   struct genlmsghdr *genMsgHeader = (struct genlmsghdr *) nlmsg_data(header);

   /* check to make sure it's the right interface.  That works so
I'll leave that code out */
   switch (genMsgHeader->cmd) {
       case NL80211_CMD_NEW_SCAN_RESULTS:
           if (debug) {
               cerr << "New scan results available" << endl;
           }
           nl_msg_dump(msg, stdout);
           trigger_fetch_scan_results();
           break;
       /* other stuff deleted */
}

OK so here's what happens.  I get the message back indicating the scan
is complete, yay!  Then I try to call my trigger_fetch_scan_results().
 What that method does is sends command NL80211_CMD_GET_SCAN on that
interface, with the flag NLM_F_DUMP.  Great!

The problem is, I get a message back whose genMsgHeader->cmd STILL
says "NL80211_CMD_NEW_SCAN_RESULTS."  The resulting packet has good
stuff in it (the ssid, etc. info I am looking for).  UNFORTUNATELY,
because of the way I wrote my code it triggers another scan, which
causes it to say "Device or resource busy" and it just loops.


So here's the question: in my NL_CB_VALID listener, how do I
distinguish the response to the NL80211_CMD_TRIGGER_SCAN (the one that
indicates scan complete) from the response to the CMD_GET_SCAN (fetch
the results) message?

--Chris
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]
  Powered by Linux