if (phyidx > -1)
NLA_PUT_U32(req, NL80211_ATTR_WIPHY, phyidx);
- cv.msg = req;
- cv.cb = cb;
- cv.custom_cb = 0;
+ cv.msg = req;
+ cv.cb = cb;
return &cv;
return NULL;
}
-static void nl80211_cb(struct nl80211_msg_conveyor *cv,
- int (*cb)(struct nl_msg *, void *), void *arg)
-{
- cv->custom_cb = 1;
- nl_cb_set(cv->cb, NL_CB_VALID, NL_CB_CUSTOM, cb, arg);
-}
-
-static struct nl80211_msg_conveyor * nl80211_send(struct nl80211_msg_conveyor *cv)
-{
+static struct nl80211_msg_conveyor * nl80211_send(
+ struct nl80211_msg_conveyor *cv,
+ int (*cb_func)(struct nl_msg *, void *), void *cb_arg
+) {
static struct nl80211_msg_conveyor rcv;
int err = 1;
- if (!cv->custom_cb)
+ if (cb_func)
+ nl_cb_set(cv->cb, NL_CB_VALID, NL_CB_CUSTOM, cb_func, cb_arg);
+ else
nl_cb_set(cv->cb, NL_CB_VALID, NL_CB_CUSTOM, nl80211_msg_response, &rcv);
if (nl_send_auto_complete(nls->nl_sock, cv->msg) < 0)
req = nl80211_msg(ifname, NL80211_CMD_GET_WIPHY, 0);
if (req)
{
- nl80211_cb(req, nl80211_ifname2phy_cb, phy);
- nl80211_send(req);
+ nl80211_send(req, nl80211_ifname2phy_cb, phy);
nl80211_free(req);
}
NLA_PUT_STRING(req->msg, NL80211_ATTR_IFNAME, nif);
NLA_PUT_U32(req->msg, NL80211_ATTR_IFTYPE, NL80211_IFTYPE_STATION);
- nl80211_send(req);
+ nl80211_send(req, NULL, NULL);
rv = nif;
{
NLA_PUT_STRING(req->msg, NL80211_ATTR_IFNAME, ifname);
- nl80211_send(req);
+ nl80211_send(req, NULL, NULL);
nla_put_failure:
nl80211_free(req);
if (req)
{
- nl80211_cb(req, nl80211_fill_signal_cb, r);
- nl80211_send(req);
+ nl80211_send(req, nl80211_fill_signal_cb, r);
nl80211_free(req);
}
}
{
noise = 0;
- nl80211_cb(req, nl80211_get_noise_cb, &noise);
- nl80211_send(req);
+ nl80211_send(req, nl80211_get_noise_cb, &noise);
nl80211_free(req);
if (noise)
if (req)
{
- nl80211_cb(req, nl80211_get_assoclist_cb, &arr);
- nl80211_send(req);
+ nl80211_send(req, nl80211_get_assoclist_cb, &arr);
nl80211_free(req);
}
/* initialize the value pointer with channel for callback */
dbm_max = ch_cur;
- nl80211_cb(req, nl80211_get_txpwrlist_cb, &dbm_max);
- nl80211_send(req);
+ nl80211_send(req, nl80211_get_txpwrlist_cb, &dbm_max);
nl80211_free(req);
}
req = nl80211_msg(ifname, NL80211_CMD_GET_WIPHY, 0);
if (req)
{
- nl80211_cb(req, nl80211_get_freqlist_cb, &arr);
- nl80211_send(req);
+ nl80211_send(req, nl80211_get_freqlist_cb, &arr);
nl80211_free(req);
}
req = nl80211_msg(ifname, NL80211_CMD_GET_REG, 0);
if (req)
{
- nl80211_cb(req, nl80211_get_country_cb, buf);
- nl80211_send(req);
+ nl80211_send(req, nl80211_get_country_cb, buf);
nl80211_free(req);
if (buf[0])
req = nl80211_msg(ifname, NL80211_CMD_GET_WIPHY, 0);
if (req)
{
- nl80211_cb(req, nl80211_get_hwmodelist_cb, buf);
- nl80211_send(req);
+ nl80211_send(req, nl80211_get_hwmodelist_cb, buf);
nl80211_free(req);
}