void WirelessFrame::setInterfaceInfo() { QString cur_iface = ui->interfaceComboBox->currentText(); int cur_chan_idx = ui->channelComboBox->currentIndex(); int cur_type_idx = ui->channelTypeComboBox->currentIndex(); int cur_fcs_idx = ui->fcsComboBox->currentIndex(); if (cur_iface.isEmpty() || cur_chan_idx < 0 || cur_type_idx < 0) return; #if defined(HAVE_LIBNL) && defined(HAVE_NL80211) const QString frequency = ui->channelComboBox->itemData(cur_chan_idx).toString(); int chan_type = ui->channelTypeComboBox->itemData(cur_type_idx).toInt(); const gchar *chan_type_s = ws80211_chan_type_to_str(chan_type); gchar *data, *primary_msg, *secondary_msg; int ret; if (frequency.isEmpty() || chan_type < 0) return; ret = sync_interface_set_80211_chan(cur_iface.toUtf8().constData(), frequency.toUtf8().constData(), chan_type_s, &data, &primary_msg, &secondary_msg, main_window_update); g_free(data); g_free(primary_msg); g_free(secondary_msg); /* Parse the error msg */ if (ret) { QString err_str = tr("Unable to set channel or offset."); emit pushAdapterStatus(err_str); } #elif defined(HAVE_AIRPCAP) int frequency = ui->channelComboBox->itemData(cur_chan_idx).toInt(); int chan_type = ui->channelTypeComboBox->itemData(cur_type_idx).toInt(); if (frequency < 0 || chan_type < 0) return; if (ws80211_set_freq(cur_iface.toUtf8().constData(), frequency, chan_type) != 0) { QString err_str = tr("Unable to set channel or offset."); emit pushAdapterStatus(err_str); } #endif if (cur_fcs_idx >= 0) { if (ws80211_set_fcs_validation(cur_iface.toUtf8().constData(), (enum ws80211_fcs_validation) cur_fcs_idx) != 0) { QString err_str = tr("Unable to set FCS validation behavior."); emit pushAdapterStatus(err_str); } } getInterfaceInfo(); }
/* Invoke dumpcap to set channel */ static int tb80211_do_set_channel(char *iface, int freq, int type) { gchar *freq_s, *type_s; gchar *data, *primary_msg, *secondary_msg; int ret; freq_s = g_strdup_printf("%d", freq); type_s = ws80211_chan_type_to_str(type); ret = sync_interface_set_80211_chan(iface, freq_s, type_s, &data, &primary_msg, &secondary_msg); /* Parse the error msg */ if (ret && primary_msg) { return atoi(primary_msg); } g_free(data); g_free(primary_msg); g_free(secondary_msg); g_free(freq_s); return ret; }