Fix some bugs relating to tap on non unix platforms

This commit is contained in:
Jasmine Iwanek
2025-07-03 15:20:53 -04:00
parent 63a9985cce
commit 5defb8d171
2 changed files with 13 additions and 4 deletions

View File

@@ -658,9 +658,9 @@ load_network(void)
nc->net_type = NET_TYPE_PCAP; nc->net_type = NET_TYPE_PCAP;
else if (!strcmp(p, "slirp") || !strcmp(p, "2")) else if (!strcmp(p, "slirp") || !strcmp(p, "2"))
nc->net_type = NET_TYPE_SLIRP; nc->net_type = NET_TYPE_SLIRP;
else if (!strcmp(p, "vde") || !strcmp(p, "2")) else if (!strcmp(p, "vde") || !strcmp(p, "3"))
nc->net_type = NET_TYPE_VDE; nc->net_type = NET_TYPE_VDE;
else if (!strcmp(p, "tap") || !strcmp(p, "3")) else if (!strcmp(p, "tap") || !strcmp(p, "4"))
nc->net_type = NET_TYPE_TAP; nc->net_type = NET_TYPE_TAP;
else else
nc->net_type = NET_TYPE_NONE; nc->net_type = NET_TYPE_NONE;
@@ -706,9 +706,9 @@ load_network(void)
nc->net_type = NET_TYPE_PCAP; nc->net_type = NET_TYPE_PCAP;
else if (!strcmp(p, "slirp") || !strcmp(p, "2")) else if (!strcmp(p, "slirp") || !strcmp(p, "2"))
nc->net_type = NET_TYPE_SLIRP; nc->net_type = NET_TYPE_SLIRP;
else if (!strcmp(p, "vde") || !strcmp(p, "2")) else if (!strcmp(p, "vde") || !strcmp(p, "3"))
nc->net_type = NET_TYPE_VDE; nc->net_type = NET_TYPE_VDE;
else if (!strcmp(p, "tap") || !strcmp(p, "3")) else if (!strcmp(p, "tap") || !strcmp(p, "4"))
nc->net_type = NET_TYPE_TAP; nc->net_type = NET_TYPE_TAP;
else else
nc->net_type = NET_TYPE_NONE; nc->net_type = NET_TYPE_NONE;

View File

@@ -94,6 +94,7 @@ SettingsNetwork::enableElements(Ui::SettingsNetwork *ui)
intf_label->setVisible(true); intf_label->setVisible(true);
break; break;
#if defined(__unix__) || defined(__APPLE__)
case NET_TYPE_TAP: case NET_TYPE_TAP:
// option_list_label->setText("TAP Options"); // option_list_label->setText("TAP Options");
option_list_label->setVisible(true); option_list_label->setVisible(true);
@@ -101,6 +102,8 @@ SettingsNetwork::enableElements(Ui::SettingsNetwork *ui)
bridge_label->setVisible(true); bridge_label->setVisible(true);
bridge_line->setVisible(true); bridge_line->setVisible(true);
break;
#endif
case NET_TYPE_SLIRP: case NET_TYPE_SLIRP:
default: default:
@@ -149,8 +152,10 @@ SettingsNetwork::save()
strncpy(net_cards_conf[i].host_dev_name, network_devs[cbox->currentData().toInt()].device, sizeof(net_cards_conf[i].host_dev_name) - 1); 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) else if (net_cards_conf[i].net_type == NET_TYPE_VDE)
strncpy(net_cards_conf[i].host_dev_name, socket_line->text().toUtf8().constData(), sizeof(net_cards_conf[i].host_dev_name)); strncpy(net_cards_conf[i].host_dev_name, socket_line->text().toUtf8().constData(), sizeof(net_cards_conf[i].host_dev_name));
#if defined(__unix__) || defined(__APPLE__)
else if (net_cards_conf[i].net_type == NET_TYPE_TAP) else if (net_cards_conf[i].net_type == NET_TYPE_TAP)
strncpy(net_cards_conf[i].host_dev_name, bridge_line->text().toUtf8().constData(), sizeof(net_cards_conf[i].host_dev_name)); strncpy(net_cards_conf[i].host_dev_name, bridge_line->text().toUtf8().constData(), sizeof(net_cards_conf[i].host_dev_name));
#endif
} }
} }
@@ -217,7 +222,9 @@ SettingsNetwork::onCurrentMachineChanged(int machineId)
if (network_devmap.has_vde) if (network_devmap.has_vde)
Models::AddEntry(model, "VDE", NET_TYPE_VDE); Models::AddEntry(model, "VDE", NET_TYPE_VDE);
#if defined(__unix__) || defined(__APPLE__)
Models::AddEntry(model, "TAP", NET_TYPE_TAP); Models::AddEntry(model, "TAP", NET_TYPE_TAP);
#endif
model->removeRows(0, removeRows); model->removeRows(0, removeRows);
cbox->setCurrentIndex(cbox->findData(net_cards_conf[i].net_type)); cbox->setCurrentIndex(cbox->findData(net_cards_conf[i].net_type));
@@ -243,10 +250,12 @@ SettingsNetwork::onCurrentMachineChanged(int machineId)
QString currentVdeSocket = net_cards_conf[i].host_dev_name; QString currentVdeSocket = net_cards_conf[i].host_dev_name;
auto editline = findChild<QLineEdit *>(QString("socketVDENIC%1").arg(i+1)); auto editline = findChild<QLineEdit *>(QString("socketVDENIC%1").arg(i+1));
editline->setText(currentVdeSocket); editline->setText(currentVdeSocket);
#if defined(__unix__) || defined(__APPLE__)
} else if (net_cards_conf[i].net_type == NET_TYPE_TAP) { } else if (net_cards_conf[i].net_type == NET_TYPE_TAP) {
QString currentTapDevice = net_cards_conf[i].host_dev_name; QString currentTapDevice = net_cards_conf[i].host_dev_name;
auto editline = findChild<QLineEdit *>(QString("bridgeTAPNIC%1").arg(i+1)); auto editline = findChild<QLineEdit *>(QString("bridgeTAPNIC%1").arg(i+1));
editline->setText(currentTapDevice); editline->setText(currentTapDevice);
#endif
} }
} }
} }