VDE networking support
Adds VDE (https://github.com/virtualsquare/vde-2) support to 86Box. - Adds new networking type - Modifies networking configuration dialog - Adds CMake Presets to build and debug under MacOS
This commit is contained in:
@@ -37,13 +37,17 @@ SettingsNetwork::enableElements(Ui::SettingsNetwork *ui)
|
||||
auto *net_type_cbox = findChild<QComboBox *>(QString("comboBoxNet%1").arg(i + 1));
|
||||
auto *intf_cbox = findChild<QComboBox *>(QString("comboBoxIntf%1").arg(i + 1));
|
||||
auto *conf_btn = findChild<QPushButton *>(QString("pushButtonConf%1").arg(i + 1));
|
||||
auto *socket_line = findChild<QLineEdit *>(QString("socketVDENIC%1").arg(i + 1));
|
||||
|
||||
int netType = net_type_cbox->currentData().toInt();
|
||||
bool adaptersEnabled = netType == NET_TYPE_SLIRP || (netType == NET_TYPE_PCAP && intf_cbox->currentData().toInt() > 0);
|
||||
bool adaptersEnabled = netType == NET_TYPE_SLIRP
|
||||
|| NET_TYPE_VDE
|
||||
|| (netType == NET_TYPE_PCAP && intf_cbox->currentData().toInt() > 0);
|
||||
|
||||
intf_cbox->setEnabled(net_type_cbox->currentData().toInt() == NET_TYPE_PCAP);
|
||||
nic_cbox->setEnabled(adaptersEnabled);
|
||||
conf_btn->setEnabled(adaptersEnabled && network_card_has_config(nic_cbox->currentData().toInt()));
|
||||
socket_line->setEnabled(net_type_cbox->currentData().toInt() == NET_TYPE_VDE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,6 +63,7 @@ SettingsNetwork::SettingsNetwork(QWidget *parent)
|
||||
auto *nic_cbox = findChild<QComboBox *>(QString("comboBoxNIC%1").arg(i + 1));
|
||||
auto *net_type_cbox = findChild<QComboBox *>(QString("comboBoxNet%1").arg(i + 1));
|
||||
auto *intf_cbox = findChild<QComboBox *>(QString("comboBoxIntf%1").arg(i + 1));
|
||||
auto *socket_line = findChild<QLineEdit *>(QString("socketVDENIC%1").arg(i + 1));
|
||||
connect(nic_cbox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &SettingsNetwork::on_comboIndexChanged);
|
||||
connect(net_type_cbox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &SettingsNetwork::on_comboIndexChanged);
|
||||
connect(intf_cbox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &SettingsNetwork::on_comboIndexChanged);
|
||||
@@ -75,12 +80,18 @@ SettingsNetwork::save()
|
||||
{
|
||||
for (int i = 0; i < NET_CARD_MAX; ++i) {
|
||||
auto *cbox = findChild<QComboBox *>(QString("comboBoxNIC%1").arg(i + 1));
|
||||
auto *socket_line = findChild<QLineEdit *>(QString("socketVDENIC%1").arg(i + 1));
|
||||
net_cards_conf[i].device_num = cbox->currentData().toInt();
|
||||
cbox = findChild<QComboBox *>(QString("comboBoxNet%1").arg(i + 1));
|
||||
net_cards_conf[i].net_type = cbox->currentData().toInt();
|
||||
cbox = findChild<QComboBox *>(QString("comboBoxIntf%1").arg(i + 1));
|
||||
memset(net_cards_conf[i].host_dev_name, '\0', sizeof(net_cards_conf[i].host_dev_name));
|
||||
strncpy(net_cards_conf[i].host_dev_name, network_devs[cbox->currentData().toInt()].device, sizeof(net_cards_conf[i].host_dev_name) - 1);
|
||||
if (net_cards_conf[i].net_type == NET_TYPE_PCAP) {
|
||||
strncpy(net_cards_conf[i].host_dev_name, network_devs[cbox->currentData().toInt()].device, sizeof(net_cards_conf[i].host_dev_name) - 1);
|
||||
} else if (net_cards_conf[i].net_type == NET_TYPE_VDE) {
|
||||
const char *str_socket = socket_line->text().toStdString().c_str();
|
||||
strncpy(net_cards_conf[i].host_dev_name, str_socket, strlen(str_socket));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,26 +135,37 @@ SettingsNetwork::onCurrentMachineChanged(int machineId)
|
||||
removeRows = model->rowCount();
|
||||
Models::AddEntry(model, tr("None"), NET_TYPE_NONE);
|
||||
Models::AddEntry(model, "SLiRP", NET_TYPE_SLIRP);
|
||||
|
||||
if (network_ndev > 1) {
|
||||
Models::AddEntry(model, "PCap", NET_TYPE_PCAP);
|
||||
}
|
||||
if (network_devmap.has_vde) {
|
||||
Models::AddEntry(model, "VDE", NET_TYPE_VDE);
|
||||
}
|
||||
|
||||
model->removeRows(0, removeRows);
|
||||
cbox->setCurrentIndex(net_cards_conf[i].net_type);
|
||||
|
||||
selectedRow = 0;
|
||||
|
||||
QString currentPcapDevice = net_cards_conf[i].host_dev_name;
|
||||
cbox = findChild<QComboBox *>(QString("comboBoxIntf%1").arg(i + 1));
|
||||
model = cbox->model();
|
||||
removeRows = model->rowCount();
|
||||
for (int c = 0; c < network_ndev; c++) {
|
||||
Models::AddEntry(model, tr(network_devs[c].description), c);
|
||||
if (QString(network_devs[c].device) == currentPcapDevice) {
|
||||
selectedRow = c;
|
||||
if (net_cards_conf[i].net_type == NET_TYPE_PCAP) {
|
||||
QString currentPcapDevice = net_cards_conf[i].host_dev_name;
|
||||
cbox = findChild<QComboBox *>(QString("comboBoxIntf%1").arg(i + 1));
|
||||
model = cbox->model();
|
||||
removeRows = model->rowCount();
|
||||
for (int c = 0; c < network_ndev; c++) {
|
||||
Models::AddEntry(model, tr(network_devs[c].description), c);
|
||||
if (QString(network_devs[c].device) == currentPcapDevice) {
|
||||
selectedRow = c;
|
||||
}
|
||||
}
|
||||
model->removeRows(0, removeRows);
|
||||
cbox->setCurrentIndex(selectedRow);
|
||||
} else if (net_cards_conf[i].net_type == NET_TYPE_VDE) {
|
||||
QString currentVdeSocket = net_cards_conf[i].host_dev_name;
|
||||
auto editline = findChild<QLineEdit *>(QString("socketVDENIC%1").arg(i+1));
|
||||
editline->setText(currentVdeSocket);
|
||||
}
|
||||
model->removeRows(0, removeRows);
|
||||
cbox->setCurrentIndex(selectedRow);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user