goto out;
- send(sock, "ATTACH", 6, 0);
+ if (event)
+ {
+ send(sock, "ATTACH", 6, 0);
- if (nl80211_wpactl_recv(sock, buffer, sizeof(buffer)) <= 0)
- goto out;
+ if (nl80211_wpactl_recv(sock, buffer, sizeof(buffer)) <= 0)
+ goto out;
+ }
send(sock, cmd, strlen(cmd), 0);
break;
}
- if ((!event && buffer[0] != '<') || strstr(buffer, event))
+ if ((!event && buffer[0] != '<') || (event && strstr(buffer, event)))
break;
}
{
if (nls)
{
+ if (nls->nl80211)
+ genl_family_put(nls->nl80211);
+
if (nls->nl_sock)
nl_socket_free(nls->nl_sock);
int nl80211_get_hardware_id(const char *ifname, char *buf)
{
+ int rv;
+ char *res;
+
+ /* Got a radioX pseudo interface, find some interface on it or create one */
+ if (!strncmp(ifname, "radio", 5))
+ {
+ /* Reuse existing interface */
+ if ((res = nl80211_phy2ifname(ifname)) != NULL)
+ {
+ return wext_get_hardware_id(res, buf);
+ }
+
+ /* Need to spawn a temporary iface for finding IDs */
+ else if ((res = nl80211_ifadd(ifname)) != NULL)
+ {
+ rv = wext_get_hardware_id(res, buf);
+ nl80211_ifdel(res);
+ return rv;
+ }
+ }
+
return wext_get_hardware_id(ifname, buf);
}
-int nl80211_get_hardware_name(const char *ifname, char *buf)
+static const struct iwinfo_hardware_entry *
+nl80211_get_hardware_entry(const char *ifname)
{
struct iwinfo_hardware_id id;
- struct iwinfo_hardware_entry *hw;
if (nl80211_get_hardware_id(ifname, (char *)&id))
- return -1;
+ return NULL;
- hw = iwinfo_hardware(&id);
+ return iwinfo_hardware(&id);
+}
- if (hw)
- sprintf(buf, "%s %s", hw->vendor_name, hw->device_name);
- else
+int nl80211_get_hardware_name(const char *ifname, char *buf)
+{
+ const struct iwinfo_hardware_entry *hw;
+
+ if (!(hw = nl80211_get_hardware_entry(ifname)))
sprintf(buf, "Generic MAC80211");
+ else
+ sprintf(buf, "%s %s", hw->vendor_name, hw->device_name);
+
+ return 0;
+}
+
+int nl80211_get_txpower_offset(const char *ifname, int *buf)
+{
+ const struct iwinfo_hardware_entry *hw;
+
+ if (!(hw = nl80211_get_hardware_entry(ifname)))
+ return -1;
+
+ *buf = hw->txpower_offset;
+ return 0;
+}
+
+int nl80211_get_frequency_offset(const char *ifname, int *buf)
+{
+ const struct iwinfo_hardware_entry *hw;
+
+ if (!(hw = nl80211_get_hardware_entry(ifname)))
+ return -1;
+ *buf = hw->frequency_offset;
return 0;
}