-3

I'm trying to find a proper way how to reuse existing implementations of wifi tools(iw) in own code(c\c++). I need to get information about available AccessPoints in range(signal strength, mac addr., etc). I found couple example codes(WEXT and others) that uses ioctl approach, but it makes passive scans(and i get new information only once in two minutes in my network)[UPDATE1: Thanks to @fluter, i know that WEXT can do active scanning, too.]. I found that iw makes an active scan and that is what i need. So my question:

Is there a way to use iw code in my own app without parsing its source code in chunks, or, maybe, there is an Wireless API for such purpose?

(UPDATE1: with basic code examples to start with.)

Similar question

UPDATE2: I have reviewed my task and found that AP information is not enough for me, i need to capture clients data, too. That leads me to wifi packet sniffing and the best tool i have found to do that is Horst. So, i'm trying to reuse its code in my app, now.

Community
  • 1
  • 1
diabolusss
  • 29
  • 1
  • 6
  • If iw does what you need why not just invoke it? – Wei Shen Apr 21 '16 at 15:44
  • do you mean to call it from my code? I don't know if it's a good idea, but i am ready to hear arguments for it. And if there is an option to accomplish my task in a clean way i prefer to search for that. – diabolusss Apr 21 '16 at 16:04
  • yes. Could you elaborate a bit more on the desired result? For instance what kind of data structure to store it, or just plain text to be parsed later etc. – Wei Shen Apr 21 '16 at 22:47
  • basic data that i need is mac, essid, signal_strength and noise, channel, last_seen. i suppose to temporary store it in a structure(code) for processing purposes, like it does in WEXT and any other program. Maybe, i'll be storing this data with processed one in a file, but it's not the main goal. – diabolusss Apr 22 '16 at 08:36

2 Answers2

2

You might wish to start with cfg80211.

cfg80211 replaces Wireless-Extensions and it is suggested that :

All new Linux wireless drivers should be written targeting either cfg80211 for fullmac devices or mac80211 for softmac devices.

Also, it is written:

Instead of writing wext ioctls you now write cfg80211 operation callbacks and fill in the wiphy struct to indicate to cfg80211 its device capabilities.

To start with active scanning start here

sjsam
  • 21,411
  • 5
  • 55
  • 102
0

You can use the wext api provided by kernel, basically, call ioctl with SIOCSIWSCAN, and get the scanned result with SIOCGIWSCAN. You can set to scan all by using flag IW_SCAN_ALL_ESSID, and choose scan type with flag IW_SCAN_TYPE_ACTIVE or IW_SCAN_TYPE_PASSIVE.

fluter
  • 13,238
  • 8
  • 62
  • 100