mirror of
https://github.com/86Box/86Box.git
synced 2026-02-23 18:08:20 -07:00
Switch: Store the actual 1-based group number on the config file, and add min/max group defines
This commit is contained in:
@@ -887,7 +887,9 @@ load_network(void)
|
||||
strcpy(nc->host_dev_name, "none");
|
||||
|
||||
sprintf(temp, "net_%02i_switch_group", c + 1);
|
||||
nc->switch_group = ini_section_get_int(cat, temp, 0);
|
||||
nc->switch_group = ini_section_get_int(cat, temp, NET_SWITCH_GRP_MIN);
|
||||
if (nc->switch_group < NET_SWITCH_GRP_MIN)
|
||||
nc->switch_group = NET_SWITCH_GRP_MIN;
|
||||
|
||||
sprintf(temp, "net_%02i_promisc", c + 1);
|
||||
nc->promisc_mode = ini_section_get_int(cat, temp, 0);
|
||||
@@ -2986,7 +2988,7 @@ save_network(void)
|
||||
ini_section_set_int(cat, temp, nc->link_state);
|
||||
|
||||
sprintf(temp, "net_%02i_switch_group", c + 1);
|
||||
if (nc->switch_group == 0)
|
||||
if (nc->switch_group == NET_SWITCH_GRP_MIN)
|
||||
ini_section_delete_var(cat, temp);
|
||||
else
|
||||
ini_section_set_int(cat, temp, nc->switch_group);
|
||||
|
||||
@@ -60,6 +60,8 @@
|
||||
#define NET_QUEUE_COUNT 4
|
||||
#define NET_CARD_MAX 4
|
||||
#define NET_HOST_INTF_MAX 64
|
||||
#define NET_SWITCH_GRP_MIN 1
|
||||
#define NET_SWITCH_GRP_MAX 10
|
||||
|
||||
#define NET_PERIOD_10M 0.8
|
||||
#define NET_PERIOD_100M 0.08
|
||||
|
||||
@@ -469,7 +469,7 @@ net_switch_init(const netcard_t *card, const uint8_t *mac_addr, void *priv, char
|
||||
val = 0;
|
||||
setsockopt(netswitch->socket_rx, IPPROTO_IP, IP_MULTICAST_LOOP, (char *) &val, sizeof(val));
|
||||
|
||||
netswitch->port_out = htons(SWITCH_MULTICAST_PORT + netcard->switch_group);
|
||||
netswitch->port_out = htons(SWITCH_MULTICAST_PORT - NET_SWITCH_GRP_MIN + netcard->switch_group);
|
||||
struct sockaddr_in addr = {
|
||||
.sin_family = AF_INET,
|
||||
.sin_addr = { .s_addr = htonl(INADDR_ANY) },
|
||||
|
||||
@@ -54,8 +54,8 @@ SettingsNetwork::enableElements(Ui::SettingsNetwork *ui)
|
||||
// auto *switch_group_hlayout = findChild<QHBoxLayout *>(QString("HLayoutSwitch%1").arg(i + 1));
|
||||
// auto *switch_group_hspacer = findChild<QWidget *>(QString("horizontalSpacerSwitch%1").arg(i + 1));
|
||||
auto *switch_group_value = findChild<QSpinBox *>(QString("spinnerSwitch%1").arg(i + 1));
|
||||
switch_group_value->setMinimum(1);
|
||||
switch_group_value->setMaximum(10);
|
||||
switch_group_value->setMinimum(NET_SWITCH_GRP_MIN);
|
||||
switch_group_value->setMaximum(NET_SWITCH_GRP_MAX);
|
||||
|
||||
// Promiscuous option
|
||||
auto *promisc_label = findChild<QLabel *>(QString("labelPromisc%1").arg(i + 1));
|
||||
@@ -230,10 +230,10 @@ SettingsNetwork::save()
|
||||
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);
|
||||
net_cards_conf[i].switch_group = switch_group_value->value() - 1;
|
||||
net_cards_conf[i].switch_group = switch_group_value->value();
|
||||
} else if (net_cards_conf[i].net_type == NET_TYPE_NLSWITCH) {
|
||||
net_cards_conf[i].promisc_mode = promisc_value->isChecked();
|
||||
net_cards_conf[i].switch_group = switch_group_value->value() - 1;
|
||||
net_cards_conf[i].switch_group = switch_group_value->value();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -350,12 +350,12 @@ SettingsNetwork::onCurrentMachineChanged(int machineId)
|
||||
auto *promisc_value = findChild<QCheckBox *>(QString("boxPromisc%1").arg(i + 1));
|
||||
promisc_value->setCheckState(net_cards_conf[i].promisc_mode == 1 ? Qt::CheckState::Checked : Qt::CheckState::Unchecked);
|
||||
auto *switch_group_value = findChild<QSpinBox *>(QString("spinnerSwitch%1").arg(i + 1));
|
||||
switch_group_value->setValue(net_cards_conf[i].switch_group + 1);
|
||||
switch_group_value->setValue(net_cards_conf[i].switch_group);
|
||||
} else if (net_cards_conf[i].net_type == NET_TYPE_NRSWITCH) {
|
||||
auto *hostname_value = findChild<QLineEdit *>(QString("hostnameSwitch%1").arg(i + 1));
|
||||
hostname_value->setText(net_cards_conf[i].nrs_hostname);
|
||||
auto *switch_group_value = findChild<QSpinBox *>(QString("spinnerSwitch%1").arg(i + 1));
|
||||
switch_group_value->setValue(net_cards_conf[i].switch_group + 1);
|
||||
switch_group_value->setValue(net_cards_conf[i].switch_group);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user