You should use libnl to query interface information. Don't rely on files under /proc or scrape the output of iw
or iwconfig
, since their output format might change any time.
If you are curious about the details, check out the source code of iw. It's easy to understand (I used it myself to understand how to query nl80211 for interface info).