Devbranch network switch
This commit is contained in:
@@ -184,6 +184,7 @@ cmake_dependent_option(PCL "Generic PCL5e Printer"
|
||||
cmake_dependent_option(SIO_DETECT "Super I/O Detection Helper" ON "DEV_BRANCH" OFF)
|
||||
cmake_dependent_option(WACOM "Wacom Input Devices" ON "DEV_BRANCH" OFF)
|
||||
cmake_dependent_option(XL24 "ATI VGA Wonder XL24 (ATI-28800-6)" ON "DEV_BRANCH" OFF)
|
||||
cmake_dependent_option(NETSWITCH "Network Switch Support" ON "DEV_BRANCH" OFF)
|
||||
|
||||
# Ditto but for Qt
|
||||
if(QT)
|
||||
|
||||
@@ -34,13 +34,6 @@ list(APPEND net_sources
|
||||
net_l80225.c
|
||||
net_modem.c
|
||||
utils/getline.c
|
||||
|
||||
net_netswitch.c
|
||||
netswitch.c
|
||||
pb_common.c
|
||||
pb_encode.c
|
||||
pb_decode.c
|
||||
networkmessage.pb.c
|
||||
)
|
||||
|
||||
find_package(PkgConfig REQUIRED)
|
||||
@@ -65,6 +58,18 @@ if(WIN32)
|
||||
target_link_libraries(86Box ws2_32)
|
||||
endif()
|
||||
|
||||
if(NETSWITCH)
|
||||
add_compile_definitions(USE_NETSWITCH)
|
||||
list(APPEND net_sources
|
||||
net_netswitch.c
|
||||
netswitch.c
|
||||
pb_common.c
|
||||
pb_encode.c
|
||||
pb_decode.c
|
||||
networkmessage.pb.c
|
||||
)
|
||||
endif()
|
||||
|
||||
if (UNIX)
|
||||
find_path(HAS_VDE "libvdeplug.h" PATHS ${VDE_INCLUDE_DIR} "/usr/include /usr/local/include" "/opt/homebrew/include" )
|
||||
if(HAS_VDE)
|
||||
|
||||
@@ -503,11 +503,13 @@ network_attach(void *card_drv, uint8_t *mac, NETRXCB rx, NETSETLINKSTATE set_lin
|
||||
card->host_drv.priv = card->host_drv.init(card, mac, net_cards_conf[net_card_current].host_dev_name, net_drv_error);
|
||||
break;
|
||||
#endif
|
||||
#ifdef USE_NETSWITCH
|
||||
case NET_TYPE_NMSWITCH:
|
||||
case NET_TYPE_NRSWITCH:
|
||||
card->host_drv = net_netswitch_drv;
|
||||
card->host_drv.priv = card->host_drv.init(card, mac, &net_cards_conf[net_card_current], net_drv_error);
|
||||
break;
|
||||
#endif /* USE_NETSWITCH */
|
||||
default:
|
||||
card->host_drv.priv = NULL;
|
||||
break;
|
||||
@@ -519,11 +521,13 @@ network_attach(void *card_drv, uint8_t *mac, NETRXCB rx, NETSETLINKSTATE set_lin
|
||||
if (!card->host_drv.priv) {
|
||||
|
||||
if(net_cards_conf[net_card_current].net_type != NET_TYPE_NONE) {
|
||||
#ifdef USE_NETSWITCH
|
||||
// FIXME: Hardcoded during dev
|
||||
// FIXME: Remove when done!
|
||||
if((net_cards_conf[net_card_current].net_type == NET_TYPE_NMSWITCH) ||
|
||||
(net_cards_conf[net_card_current].net_type == NET_TYPE_NRSWITCH))
|
||||
fatal("%s", net_drv_error);
|
||||
#endif /* USE_NETSWITCH */
|
||||
|
||||
// We're here because of a failure
|
||||
swprintf(tempmsg, sizeof_w(tempmsg), L"%ls:\n\n%s\n\n%ls", plat_get_string(STRING_NET_ERROR), net_drv_error, plat_get_string(STRING_NET_ERROR_DESC));
|
||||
|
||||
@@ -252,6 +252,10 @@ if(EMU_BUILD_NUM)
|
||||
)
|
||||
endif()
|
||||
|
||||
if(NETSWITCH)
|
||||
target_compile_definitions(ui PRIVATE USE_NETSWITCH)
|
||||
endif()
|
||||
|
||||
if(RTMIDI)
|
||||
target_compile_definitions(ui PRIVATE USE_RTMIDI)
|
||||
endif()
|
||||
|
||||
@@ -139,6 +139,7 @@ SettingsNetwork::enableElements(Ui::SettingsNetwork *ui)
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef USE_NETSWITCH
|
||||
case NET_TYPE_NMSWITCH:
|
||||
// option_list_label->setText("Local Switch Options");
|
||||
option_list_label->setVisible(true);
|
||||
@@ -168,6 +169,7 @@ SettingsNetwork::enableElements(Ui::SettingsNetwork *ui)
|
||||
hostname_label->setVisible(true);
|
||||
hostname_value->setVisible(true);
|
||||
break;
|
||||
#endif /* USE_NETSWITCH */
|
||||
|
||||
case NET_TYPE_SLIRP:
|
||||
default:
|
||||
@@ -215,9 +217,11 @@ SettingsNetwork::save()
|
||||
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));
|
||||
#ifdef USE_NETSWITCH
|
||||
auto *hostname_value = findChild<QLineEdit *>(QString("hostnameSwitch%1").arg(i + 1));
|
||||
auto *promisc_value = findChild<QCheckBox *>(QString("boxPromisc%1").arg(i + 1));
|
||||
auto *switch_group_value = findChild<QSpinBox *>(QString("spinnerSwitch%1").arg(i + 1));
|
||||
#endif /* USE_NETSWITCH */
|
||||
memset(net_cards_conf[i].host_dev_name, '\0', sizeof(net_cards_conf[i].host_dev_name));
|
||||
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);
|
||||
@@ -229,6 +233,7 @@ SettingsNetwork::save()
|
||||
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));
|
||||
#endif
|
||||
#ifdef USE_NETSWITCH
|
||||
else if (net_cards_conf[i].net_type == NET_TYPE_NRSWITCH) {
|
||||
memset(net_cards_conf[i].nrs_hostname, '\0', sizeof(net_cards_conf[i].nrs_hostname));
|
||||
strncpy(net_cards_conf[i].nrs_hostname, hostname_value->text().toUtf8().constData(), sizeof(net_cards_conf[i].nrs_hostname) - 1);
|
||||
@@ -237,6 +242,7 @@ SettingsNetwork::save()
|
||||
net_cards_conf[i].promisc_mode = promisc_value->isChecked();
|
||||
net_cards_conf[i].switch_group = switch_group_value->value() - 1;
|
||||
}
|
||||
#endif /* USE_NETSWITCH */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -309,10 +315,12 @@ SettingsNetwork::onCurrentMachineChanged(int machineId)
|
||||
Models::AddEntry(model, "TAP", NET_TYPE_TAP);
|
||||
#endif
|
||||
|
||||
#ifdef USE_NETSWITCH
|
||||
Models::AddEntry(model, "Local Switch", NET_TYPE_NMSWITCH);
|
||||
#ifdef ENABLE_NET_NRSWITCH
|
||||
Models::AddEntry(model, "Remote Switch", NET_TYPE_NRSWITCH);
|
||||
#endif
|
||||
#endif /* ENABLE_NET_NRSWITCH */
|
||||
#endif /* USE_NETSWITCH */
|
||||
|
||||
model->removeRows(0, removeRows);
|
||||
cbox->setCurrentIndex(cbox->findData(net_cards_conf[i].net_type));
|
||||
@@ -348,6 +356,7 @@ SettingsNetwork::onCurrentMachineChanged(int machineId)
|
||||
auto editline = findChild<QLineEdit *>(QString("bridgeTAPNIC%1").arg(i+1));
|
||||
editline->setText(currentTapDevice);
|
||||
#endif
|
||||
#ifdef USE_NETSWITCH
|
||||
} else if (net_cards_conf[i].net_type == NET_TYPE_NMSWITCH) {
|
||||
auto *promisc_value = findChild<QCheckBox *>(QString("promiscBox%1").arg(i + 1));
|
||||
promisc_value->setCheckState(net_cards_conf[i].promisc_mode == 1 ? Qt::CheckState::Checked : Qt::CheckState::Unchecked);
|
||||
@@ -358,6 +367,7 @@ SettingsNetwork::onCurrentMachineChanged(int machineId)
|
||||
hostname_value->setText(net_cards_conf[i].nrs_hostname);
|
||||
auto *switch_group_value = findChild<QSpinBox *>(QString("switchSpinner%1").arg(i + 1));
|
||||
switch_group_value->setValue(net_cards_conf[i].switch_group + 1);
|
||||
#endif /* USE_NETSWITCH */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user