On 20 November 2017 at 18:46, Grégoire Gentil <gregoire@xxxxxxxxxx> wrote: > My question is summarized here: > > https://stackoverflow.com/questions/47398018/hostapd-how-to-know-the-frequency-of-ap-mode > > > "On Linux, I'm using hostapd in AP mode. In other words, the system is the > hotspot. > > I would like to know what is the frequency of the Wi-Fi via c code (or a > bash script that I could translate to c code). > > The following code which queries the kernel, only works in normal mode. It > fails in AP mode. > > ioctl(net_sock, SIOCGIWFREQ, &wrq); > > In bash, I have tried: > > iwconfig > iw dev > > but it doesn't report the frequency of the Wi-Fi. Same problem: it only > reports in normal mode when the system associates to a router but nothing in > AP mode. > > How can I query hostapd to know the frequency hostapd is using or is > configured to use?" Use nl80211, send NL80211_CMD_GET_INTERFACE request and check for the NL80211_ATTR_WIPHY_FREQ. This will work as long as your Linux wireless driver implements get_channel cfg80211 callback. In Linux source it's handled by: NL80211_CMD_GET_INTERFACE nl80211_get_interface / nl80211_dump_interface nl80211_send_iface rdev_get_channel nl80211_send_chandef When using "iw" tool, just try iw dev wlan0 info (replace "wlan0" if needed) _______________________________________________ Hostap mailing list Hostap@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/hostap