struct nl_cb *cb;
int err = -ENOMEM;
+ if (!msg)
+ return -ENOMEM;
+
cb = nl_cb_clone(global->nl_cb);
if (!cb)
goto out;
int ret;
struct nl80211_bss_info_arg arg;
+ msg = nl80211_drv_msg(drv, NLM_F_DUMP, NL80211_CMD_GET_SCAN);
os_memset(&arg, 0, sizeof(arg));
- msg = nlmsg_alloc();
- if (!msg)
- return drv->assoc_freq;
-
- if (!nl80211_cmd(drv, msg, NLM_F_DUMP, NL80211_CMD_GET_SCAN) ||
- nla_put_u32(msg, NL80211_ATTR_IFINDEX, drv->ifindex)) {
- nlmsg_free(msg);
- return drv->assoc_freq;
- }
-
arg.drv = drv;
ret = send_and_recv_msgs(drv, msg, bss_info_handler, &arg);
if (ret == 0) {
sig->current_signal = -9999;
sig->current_txrate = 0;
- msg = nlmsg_alloc();
- if (!msg)
- return -ENOMEM;
-
- if (!nl80211_cmd(drv, msg, 0, NL80211_CMD_GET_STATION) ||
- nla_put_u32(msg, NL80211_ATTR_IFINDEX, drv->ifindex) ||
+ if (!(msg = nl80211_drv_msg(drv, 0, NL80211_CMD_GET_STATION)) ||
nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, drv->bssid)) {
nlmsg_free(msg);
return -ENOBUFS;
sig_change->current_noise = 9999;
sig_change->frequency = drv->assoc_freq;
- msg = nlmsg_alloc();
- if (!msg)
- return -ENOMEM;
-
- if (!nl80211_cmd(drv, msg, NLM_F_DUMP, NL80211_CMD_GET_SURVEY) ||
- nla_put_u32(msg, NL80211_ATTR_IFINDEX, drv->ifindex)) {
- nlmsg_free(msg);
- return -ENOBUFS;
- }
-
+ msg = nl80211_drv_msg(drv, NLM_F_DUMP, NL80211_CMD_GET_SURVEY);
return send_and_recv_msgs(drv, msg, get_link_noise, sig_change);
}
{
struct nl_msg *msg;
- msg = nlmsg_alloc();
- if (!msg)
- return -ENOMEM;
-
- if (!nl80211_cmd(drv, msg, NLM_F_DUMP, NL80211_CMD_GET_SURVEY) ||
- nla_put_u32(msg, NL80211_ATTR_IFINDEX, drv->ifindex)) {
- nlmsg_free(msg);
- return -ENOBUFS;
- }
-
+ msg = nl80211_drv_msg(drv, NLM_F_DUMP, NL80211_CMD_GET_SURVEY);
return send_and_recv_msgs(drv, msg, get_noise_for_scan_results,
scan_res);
}
{
struct nl_msg *msg;
- msg = nlmsg_alloc();
- if (!msg)
- return -ENOMEM;
-
wpa_printf(MSG_DEBUG, "nl80211: Remove beacon (ifindex=%d)",
drv->ifindex);
- if (!nl80211_cmd(drv, msg, 0, NL80211_CMD_DEL_BEACON) ||
- nla_put_u32(msg, NL80211_ATTR_IFINDEX, drv->ifindex)) {
- nlmsg_free(msg);
- return -ENOBUFS;
- }
-
+ msg = nl80211_drv_msg(drv, 0, NL80211_CMD_DEL_BEACON);
return send_and_recv_msgs(drv, msg, NULL, NULL);
}
{
struct i802_bss *bss = priv;
struct wpa_driver_nl80211_data *drv = bss->drv;
- int ret = 0;
+ int ret;
struct nl_msg *msg;
#ifdef ANDROID
return android_pno_stop(bss);
#endif /* ANDROID */
- msg = nlmsg_alloc();
- if (!msg)
- return -1;
-
- if (!nl80211_cmd(drv, msg, 0, NL80211_CMD_STOP_SCHED_SCAN) ||
- nla_put_u32(msg, NL80211_ATTR_IFINDEX, drv->ifindex)) {
- nlmsg_free(msg);
- return 0;
- }
-
+ msg = nl80211_drv_msg(drv, 0, NL80211_CMD_STOP_SCHED_SCAN);
ret = send_and_recv_msgs(drv, msg, NULL, NULL);
if (ret) {
wpa_printf(MSG_DEBUG,
if (!drv->key_mgmt_set_key_vendor_cmd_avail)
return 0;
- msg = nlmsg_alloc();
- if (!msg)
- return -1;
-
- if (!nl80211_cmd(drv, msg, 0, NL80211_CMD_VENDOR) ||
- nla_put_u32(msg, NL80211_ATTR_IFINDEX, drv->ifindex) ||
+ if (!(msg = nl80211_drv_msg(drv, 0, NL80211_CMD_VENDOR)) ||
nla_put_u32(msg, NL80211_ATTR_VENDOR_ID, OUI_QCA) ||
nla_put_u32(msg, NL80211_ATTR_VENDOR_SUBCMD,
QCA_NL80211_VENDOR_SUBCMD_KEY_MGMT_SET_KEY) ||
int ret;
struct nl_msg *msg;
- msg = nlmsg_alloc();
- if (!msg)
- return -1;
-
- if (!nl80211_cmd(drv, msg, 0, cmd) ||
- nla_put_u32(msg, NL80211_ATTR_IFINDEX, drv->ifindex) ||
+ if (!(msg = nl80211_drv_msg(drv, 0, cmd)) ||
nla_put_u16(msg, NL80211_ATTR_REASON_CODE, reason_code) ||
(addr && nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, addr)) ||
(local_state_change &&
return -1;
retry:
- msg = nlmsg_alloc();
- if (!msg)
- return -1;
-
wpa_printf(MSG_DEBUG, "nl80211: Authenticate (ifindex=%d)",
drv->ifindex);
- nl80211_cmd(drv, msg, 0, NL80211_CMD_AUTHENTICATE);
+ msg = nl80211_drv_msg(drv, 0, NL80211_CMD_AUTHENTICATE);
+ if (!msg)
+ goto fail;
for (i = 0; i < 4; i++) {
if (!params->wep_key[i])
if (params->wep_tx_keyidx != i)
continue;
if (nl_add_key(msg, WPA_ALG_WEP, i, 1, NULL, 0,
- params->wep_key[i], params->wep_key_len[i])) {
- nlmsg_free(msg);
- return -1;
- }
+ params->wep_key[i], params->wep_key_len[i]))
+ goto fail;
}
- if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, drv->ifindex))
- goto fail;
if (params->bssid) {
wpa_printf(MSG_DEBUG, " * bssid=" MACSTR,
MAC2STR(params->bssid));
if (params->num_mac_acl > drv->capa.max_acl_mac_addrs)
return -ENOTSUP;
- msg = nlmsg_alloc();
- if (!msg)
- return -ENOMEM;
-
wpa_printf(MSG_DEBUG, "nl80211: Set %s ACL (num_mac_acl=%u)",
params->acl_policy ? "Accept" : "Deny", params->num_mac_acl);
- if (!nl80211_cmd(drv, msg, 0, NL80211_CMD_SET_MAC_ACL) ||
- nla_put_u32(msg, NL80211_ATTR_IFINDEX, drv->ifindex) ||
+ if (!(msg = nl80211_drv_msg(drv, 0, NL80211_CMD_SET_MAC_ACL)) ||
nla_put_u32(msg, NL80211_ATTR_ACL_POLICY, params->acl_policy ?
NL80211_ACL_POLICY_DENY_UNLESS_LISTED :
NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED) ||
"nl80211: Set freq %d (ht_enabled=%d, vht_enabled=%d, bandwidth=%d MHz, cf1=%d MHz, cf2=%d MHz)",
freq->freq, freq->ht_enabled, freq->vht_enabled,
freq->bandwidth, freq->center_freq1, freq->center_freq2);
- msg = nlmsg_alloc();
- if (!msg)
- return -1;
- if (!nl80211_cmd(drv, msg, 0, set_chan ? NL80211_CMD_SET_CHANNEL :
- NL80211_CMD_SET_WIPHY) ||
- nla_put_u32(msg, NL80211_ATTR_IFINDEX, drv->ifindex) ||
- nl80211_put_freq_params(msg, freq) < 0) {
+ msg = nl80211_drv_msg(drv, 0, set_chan ? NL80211_CMD_SET_CHANNEL :
+ NL80211_CMD_SET_WIPHY);
+ if (!msg || nl80211_put_freq_params(msg, freq) < 0) {
nlmsg_free(msg);
return -1;
}
static int nl80211_leave_ibss(struct wpa_driver_nl80211_data *drv)
{
struct nl_msg *msg;
- int ret = -1;
-
- msg = nlmsg_alloc();
- if (!msg)
- return -1;
-
- if (!nl80211_cmd(drv, msg, 0, NL80211_CMD_LEAVE_IBSS) ||
- nla_put_u32(msg, NL80211_ATTR_IFINDEX, drv->ifindex))
- goto fail;
+ int ret;
+ msg = nl80211_drv_msg(drv, 0, NL80211_CMD_LEAVE_IBSS);
ret = send_and_recv_msgs(drv, msg, NULL, NULL);
- msg = NULL;
if (ret) {
wpa_printf(MSG_DEBUG, "nl80211: Leave IBSS failed: ret=%d "
"(%s)", ret, strerror(-ret));
- goto fail;
+ } else {
+ wpa_printf(MSG_DEBUG,
+ "nl80211: Leave IBSS request sent successfully");
}
- ret = 0;
- wpa_printf(MSG_DEBUG, "nl80211: Leave IBSS request sent successfully");
-
-fail:
if (wpa_driver_nl80211_set_mode(drv->first_bss,
NL80211_IFTYPE_STATION)) {
wpa_printf(MSG_INFO, "nl80211: Failed to set interface into "
"station mode");
}
- nlmsg_free(msg);
return ret;
}
}
retry:
- msg = nlmsg_alloc();
- if (!msg)
- return -1;
-
- if (!nl80211_cmd(drv, msg, 0, NL80211_CMD_JOIN_IBSS) ||
- nla_put_u32(msg, NL80211_ATTR_IFINDEX, drv->ifindex) ||
+ if (!(msg = nl80211_drv_msg(drv, 0, NL80211_CMD_JOIN_IBSS)) ||
params->ssid == NULL || params->ssid_len > sizeof(drv->ssid))
goto fail;
struct wpa_driver_associate_params *params,
struct nl_msg *msg)
{
- if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, drv->ifindex))
- return -1;
-
if (params->bssid) {
wpa_printf(MSG_DEBUG, " * bssid=" MACSTR,
MAC2STR(params->bssid));
return ret;
}
- msg = nlmsg_alloc();
+ wpa_printf(MSG_DEBUG, "nl80211: Connect (ifindex=%d)", drv->ifindex);
+ msg = nl80211_drv_msg(drv, 0, NL80211_CMD_CONNECT);
if (!msg)
return -1;
- wpa_printf(MSG_DEBUG, "nl80211: Connect (ifindex=%d)", drv->ifindex);
- nl80211_cmd(drv, msg, 0, NL80211_CMD_CONNECT);
-
ret = nl80211_connect_common(drv, params, msg);
if (ret)
goto fail;
nl80211_mark_disconnected(drv);
- msg = nlmsg_alloc();
- if (!msg)
- return -1;
-
wpa_printf(MSG_DEBUG, "nl80211: Associate (ifindex=%d)",
drv->ifindex);
- if (!nl80211_cmd(drv, msg, 0, NL80211_CMD_ASSOCIATE))
- goto fail;
+ msg = nl80211_drv_msg(drv, 0, NL80211_CMD_ASSOCIATE);
+ if (!msg)
+ return -1;
ret = nl80211_connect_common(drv, params, msg);
if (ret)
int ret;
u32 val;
- msg = nlmsg_alloc();
- if (!msg)
- return -ENOMEM;
-
if (rts >= 2347)
val = (u32) -1;
else
val = rts;
- if (!nl80211_cmd(drv, msg, 0, NL80211_CMD_SET_WIPHY) ||
- nla_put_u32(msg, NL80211_ATTR_IFINDEX, drv->ifindex) ||
+ if (!(msg = nl80211_drv_msg(drv, 0, NL80211_CMD_SET_WIPHY)) ||
nla_put_u32(msg, NL80211_ATTR_WIPHY_RTS_THRESHOLD, val)) {
nlmsg_free(msg);
return -ENOBUFS;
int ret;
u32 val;
- msg = nlmsg_alloc();
- if (!msg)
- return -ENOMEM;
-
if (frag >= 2346)
val = (u32) -1;
else
val = frag;
- if (!nl80211_cmd(drv, msg, 0, NL80211_CMD_SET_WIPHY) ||
- nla_put_u32(msg, NL80211_ATTR_IFINDEX, drv->ifindex) ||
+ if (!(msg = nl80211_drv_msg(drv, 0, NL80211_CMD_SET_WIPHY)) ||
nla_put_u32(msg, NL80211_ATTR_WIPHY_FRAG_THRESHOLD, val)) {
nlmsg_free(msg);
return -ENOBUFS;
{
struct nl_msg *msg;
- msg = nlmsg_alloc();
- if (!msg)
- return -ENOMEM;
-
- if (!nl80211_cmd(drv, msg, 0, NL80211_CMD_GET_INTERFACE) ||
- nla_put_u32(msg, NL80211_ATTR_IFINDEX, drv->ifindex)) {
- nlmsg_free(msg);
- return -ENOBUFS;
- }
-
+ msg = nl80211_drv_msg(drv, 0, NL80211_CMD_GET_INTERFACE);
return send_and_recv_msgs(drv, msg, get_channel_width, sig);
}
struct i802_bss *bss = priv;
struct wpa_driver_nl80211_data *drv = bss->drv;
struct nl_msg *msg;
- int err = -ENOBUFS;
+ int err;
union wpa_event_data data;
struct survey_results *survey_results;
dl_list_init(&survey_results->survey_list);
- msg = nlmsg_alloc();
+ msg = nl80211_drv_msg(drv, NLM_F_DUMP, NL80211_CMD_GET_SURVEY);
if (!msg)
return -ENOBUFS;
- if (!nl80211_cmd(drv, msg, NLM_F_DUMP, NL80211_CMD_GET_SURVEY) ||
- nla_put_u32(msg, NL80211_ATTR_IFINDEX, drv->ifindex)) {
- nlmsg_free(msg);
- return -ENOBUFS;
- }
-
if (freq)
data.survey_results.freq_filter = freq;
return -1;
}
- msg = nlmsg_alloc();
- if (!msg)
- return -1;
-
- if (!nl80211_cmd(bss->drv, msg, 0, NL80211_CMD_RADAR_DETECT) ||
- nla_put_u32(msg, NL80211_ATTR_IFINDEX, drv->ifindex) ||
+ if (!(msg = nl80211_drv_msg(drv, 0, NL80211_CMD_RADAR_DETECT)) ||
nl80211_put_freq_params(msg, freq) < 0) {
nlmsg_free(msg);
return -1;
if (!dst)
return -EINVAL;
- msg = nlmsg_alloc();
- if (!msg)
- return -ENOMEM;
-
- if (!nl80211_cmd(drv, msg, 0, NL80211_CMD_TDLS_MGMT) ||
- nla_put_u32(msg, NL80211_ATTR_IFINDEX, drv->ifindex) ||
+ if (!(msg = nl80211_drv_msg(drv, 0, NL80211_CMD_TDLS_MGMT)) ||
nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, dst) ||
nla_put_u8(msg, NL80211_ATTR_TDLS_ACTION, action_code) ||
nla_put_u8(msg, NL80211_ATTR_TDLS_DIALOG_TOKEN, dialog_token) ||
return -EINVAL;
}
- msg = nlmsg_alloc();
- if (!msg)
- return -ENOMEM;
-
- if (!nl80211_cmd(drv, msg, 0, NL80211_CMD_TDLS_OPER) ||
+ if (!(msg = nl80211_drv_msg(drv, 0, NL80211_CMD_TDLS_OPER)) ||
nla_put_u8(msg, NL80211_ATTR_TDLS_OPERATION, nl80211_oper) ||
- nla_put_u32(msg, NL80211_ATTR_IFINDEX, drv->ifindex) ||
nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, peer)) {
nlmsg_free(msg);
return -ENOBUFS;
struct wpa_driver_nl80211_data *drv = bss->drv;
u16 mdid = WPA_GET_LE16(md);
- msg = nlmsg_alloc();
- if (!msg)
- return -ENOMEM;
-
wpa_printf(MSG_DEBUG, "nl80211: Updating FT IEs");
- if (!nl80211_cmd(drv, msg, 0, NL80211_CMD_UPDATE_FT_IES) ||
- nla_put_u32(msg, NL80211_ATTR_IFINDEX, drv->ifindex) ||
+ if (!(msg = nl80211_drv_msg(drv, 0, NL80211_CMD_UPDATE_FT_IES)) ||
nla_put(msg, NL80211_ATTR_IE, ies_len, ies) ||
nla_put_u16(msg, NL80211_ATTR_MDID, mdid)) {
nlmsg_free(msg);
struct nl_msg *msg;
int ret;
- msg = nlmsg_alloc();
- if (!msg)
- return -ENOMEM;
-
wpa_hexdump(MSG_DEBUG, "nl80211: Setting QoS Map",
qos_map_set, qos_map_set_len);
- if (!nl80211_cmd(drv, msg, 0, NL80211_CMD_SET_QOS_MAP) ||
- nla_put_u32(msg, NL80211_ATTR_IFINDEX, drv->ifindex) ||
+ if (!(msg = nl80211_drv_msg(drv, 0, NL80211_CMD_SET_QOS_MAP)) ||
nla_put(msg, NL80211_ATTR_QOS_MAP, qos_map_set_len, qos_map_set)) {
nlmsg_free(msg);
return -ENOBUFS;
struct nlattr *wowlan_triggers;
int ret;
- msg = nlmsg_alloc();
- if (!msg)
- return -ENOMEM;
-
wpa_printf(MSG_DEBUG, "nl80211: Setting wowlan");
- if (!nl80211_cmd(drv, msg, 0, NL80211_CMD_SET_WOWLAN) ||
- nla_put_u32(msg, NL80211_ATTR_IFINDEX, drv->ifindex) ||
+ if (!(msg = nl80211_drv_msg(drv, 0, NL80211_CMD_SET_WOWLAN)) ||
!(wowlan_triggers = nla_nest_start(msg,
NL80211_ATTR_WOWLAN_TRIGGERS)) ||
(triggers->any &&
return -1;
}
- msg = nlmsg_alloc();
- if (!msg)
- return -ENOMEM;
-
- if (!nl80211_cmd(drv, msg, 0, NL80211_CMD_VENDOR) ||
- nla_put_u32(msg, NL80211_ATTR_IFINDEX, drv->ifindex) ||
+ if (!(msg = nl80211_drv_msg(drv, 0, NL80211_CMD_VENDOR)) ||
nla_put_u32(msg, NL80211_ATTR_VENDOR_ID, OUI_QCA) ||
nla_put_u32(msg, NL80211_ATTR_VENDOR_SUBCMD,
QCA_NL80211_VENDOR_SUBCMD_ROAMING) ||
struct nlattr *container;
int ret = 0;
- msg = nlmsg_alloc();
- if (!msg)
- return -1;
-
wpa_printf(MSG_DEBUG, "nl80211: mesh join (ifindex=%d)", drv->ifindex);
- if (!nl80211_cmd(drv, msg, 0, NL80211_CMD_JOIN_MESH) ||
- nla_put_u32(msg, NL80211_ATTR_IFINDEX, drv->ifindex))
+ msg = nl80211_drv_msg(drv, 0, NL80211_CMD_JOIN_MESH);
+ if (!msg)
goto fail;
if (params->freq) {
wpa_printf(MSG_DEBUG, " * freq=%d", params->freq);
struct i802_bss *bss = priv;
struct wpa_driver_nl80211_data *drv = bss->drv;
struct nl_msg *msg;
- int ret = 0;
-
- msg = nlmsg_alloc();
- if (!msg)
- return -1;
+ int ret;
wpa_printf(MSG_DEBUG, "nl80211: mesh leave (ifindex=%d)", drv->ifindex);
- if (!nl80211_cmd(drv, msg, 0, NL80211_CMD_LEAVE_MESH) ||
- nla_put_u32(msg, NL80211_ATTR_IFINDEX, drv->ifindex))
- goto fail;
-
+ msg = nl80211_drv_msg(drv, 0, NL80211_CMD_LEAVE_MESH);
ret = send_and_recv_msgs(drv, msg, NULL, NULL);
- msg = NULL;
if (ret) {
wpa_printf(MSG_DEBUG, "nl80211: mesh leave failed: ret=%d (%s)",
ret, strerror(-ret));
"nl80211: mesh leave request send successfully");
}
-fail:
- nlmsg_free(msg);
if (wpa_driver_nl80211_set_mode(drv->first_bss,
NL80211_IFTYPE_STATION)) {
wpa_printf(MSG_INFO,
if (mode < 0)
return -1;
- msg = nlmsg_alloc();
- if (!msg)
- return -1;
-
- if (!nl80211_cmd(drv, msg, 0, NL80211_CMD_VENDOR) ||
- nla_put_u32(msg, NL80211_ATTR_IFINDEX, drv->ifindex) ||
+ if (!(msg = nl80211_drv_msg(drv, 0, NL80211_CMD_VENDOR)) ||
nla_put_u32(msg, NL80211_ATTR_VENDOR_ID, OUI_QCA) ||
nla_put_u32(msg, NL80211_ATTR_VENDOR_SUBCMD,
QCA_NL80211_VENDOR_SUBCMD_DO_ACS) ||