mirror of
https://github.com/86Box/86Box.git
synced 2026-02-22 09:35:32 -07:00
Add GUI settings for shared secret, remove switch groups
Two birds in one commit: with the introduction of shared secrets, there is a practically-infinite amount of local switches that can be used, by merely editing the shared secret string. As such, support for old switch groups has been removed. In addition to this, the multicast address for local switch has been altered to 239.255.80.86. This ensures a hard compatibility break with the previous code and old (albeit interim) builds of 86Box would not attempt to receive packets with shared secrets.
This commit is contained in:
11
src/config.c
11
src/config.c
@@ -910,11 +910,6 @@ load_network(void)
|
||||
nc->slirp_net[0] = '\0';
|
||||
}
|
||||
|
||||
sprintf(temp, "net_%02i_switch_group", c + 1);
|
||||
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_secret", c + 1);
|
||||
p = ini_section_get_string(cat, temp, NULL);
|
||||
strncpy(nc->secret, p ? p : "", sizeof(nc->secret) - 1);
|
||||
@@ -3024,12 +3019,6 @@ save_network(void)
|
||||
ini_section_delete_var(cat, temp);
|
||||
}
|
||||
|
||||
sprintf(temp, "net_%02i_switch_group", c + 1);
|
||||
if (nc->switch_group == NET_SWITCH_GRP_MIN)
|
||||
ini_section_delete_var(cat, temp);
|
||||
else
|
||||
ini_section_set_int(cat, temp, nc->switch_group);
|
||||
|
||||
sprintf(temp, "net_%02i_secret", c + 1);
|
||||
if (nc->secret[0] == '\0')
|
||||
ini_section_delete_var(cat, temp);
|
||||
|
||||
@@ -60,8 +60,6 @@
|
||||
#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
|
||||
@@ -97,7 +95,6 @@ typedef struct netcard_conf_t {
|
||||
int net_type;
|
||||
char host_dev_name[128];
|
||||
uint32_t link_state;
|
||||
uint8_t switch_group;
|
||||
char secret[256];
|
||||
uint8_t promisc_mode;
|
||||
char slirp_net[16];
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
|
||||
#define SWITCH_PKT_BATCH NET_QUEUE_LEN
|
||||
|
||||
#define SWITCH_MULTICAST_GROUP 0xefff5656 /* 239.255.86.86 */
|
||||
#define SWITCH_MULTICAST_GROUP 0xefff5056 /* 239.255.80.86 */
|
||||
#define SWITCH_MULTICAST_PORT 8086
|
||||
|
||||
enum {
|
||||
@@ -478,8 +478,6 @@ net_switch_init(const netcard_t *card, const uint8_t *mac_addr, void *priv, char
|
||||
{
|
||||
netcard_conf_t *netcard = (netcard_conf_t *) priv;
|
||||
|
||||
netswitch_log("Network Switch: initializing with group %d...\n", netcard->switch_group);
|
||||
|
||||
net_switch_t *netswitch = calloc(1, sizeof(net_switch_t));
|
||||
memcpy(netswitch->mac_addr, mac_addr, sizeof(netswitch->mac_addr));
|
||||
netswitch->card = (netcard_t *) card;
|
||||
@@ -514,7 +512,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 - NET_SWITCH_GRP_MIN + netcard->switch_group);
|
||||
netswitch->port_out = htons(SWITCH_MULTICAST_PORT);
|
||||
struct sockaddr_in addr = {
|
||||
.sin_family = AF_INET,
|
||||
.sin_addr = { .s_addr = htonl(INADDR_ANY) },
|
||||
|
||||
@@ -49,13 +49,9 @@ SettingsNetwork::enableElements(Ui::SettingsNetwork *ui)
|
||||
auto *option_list_label = findChild<QLabel *>(QString("labelOptionList%1").arg(i + 1));
|
||||
auto *option_list_line = findChild<QWidget *>(QString("lineOptionList%1").arg(i + 1));
|
||||
|
||||
// Switch group
|
||||
auto *switch_group_label = findChild<QLabel *>(QString("labelSwitch%1").arg(i + 1));
|
||||
// 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(NET_SWITCH_GRP_MIN);
|
||||
switch_group_value->setMaximum(NET_SWITCH_GRP_MAX);
|
||||
// Shared secret
|
||||
auto *secret_label = findChild<QLabel *>(QString("labelSecret%1").arg(i + 1));
|
||||
auto *secret_value = findChild<QLineEdit *>(QString("secretSwitch%1").arg(i + 1));
|
||||
|
||||
// Promiscuous option
|
||||
auto *promisc_label = findChild<QLabel *>(QString("labelPromisc%1").arg(i + 1));
|
||||
@@ -73,10 +69,8 @@ SettingsNetwork::enableElements(Ui::SettingsNetwork *ui)
|
||||
// NEW STUFF
|
||||
// Make all options invisible by default
|
||||
|
||||
// Switch group
|
||||
switch_group_label->setVisible(false);
|
||||
switch_group_value->setVisible(false);
|
||||
// switch_group_hspacer->setVisible(false);
|
||||
secret_label->setVisible(false);
|
||||
secret_value->setVisible(false);
|
||||
|
||||
// Promiscuous options
|
||||
promisc_label->setVisible(false);
|
||||
@@ -142,10 +136,9 @@ SettingsNetwork::enableElements(Ui::SettingsNetwork *ui)
|
||||
option_list_label->setVisible(true);
|
||||
option_list_line->setVisible(true);
|
||||
|
||||
// Switch group
|
||||
switch_group_label->setVisible(true);
|
||||
switch_group_value->setVisible(true);
|
||||
// switch_group_hspacer->setVisible(false);
|
||||
// Shared secret
|
||||
secret_label->setVisible(true);
|
||||
secret_value->setVisible(true);
|
||||
|
||||
// Promiscuous options
|
||||
promisc_label->setVisible(true);
|
||||
@@ -157,10 +150,9 @@ SettingsNetwork::enableElements(Ui::SettingsNetwork *ui)
|
||||
option_list_label->setVisible(true);
|
||||
option_list_line->setVisible(true);
|
||||
|
||||
// Switch group
|
||||
switch_group_label->setVisible(true);
|
||||
switch_group_value->setVisible(true);
|
||||
// switch_group_hspacer->setVisible(false);
|
||||
// Shared secret
|
||||
secret_label->setVisible(true);
|
||||
secret_value->setVisible(true);
|
||||
|
||||
// Hostname
|
||||
hostname_label->setVisible(true);
|
||||
@@ -215,7 +207,7 @@ SettingsNetwork::save()
|
||||
cbox = findChild<QComboBox *>(QString("comboBoxIntf%1").arg(i + 1));
|
||||
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));
|
||||
auto *secret_value = findChild<QLineEdit *>(QString("secretSwitch%1").arg(i + 1));
|
||||
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);
|
||||
@@ -230,10 +222,12 @@ 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();
|
||||
memset(net_cards_conf[i].secret, '\0', sizeof(net_cards_conf[i].secret));
|
||||
strncpy(net_cards_conf[i].secret, secret_value->text().toUtf8().constData(), sizeof(net_cards_conf[i].secret) - 1);
|
||||
} 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();
|
||||
memset(net_cards_conf[i].secret, '\0', sizeof(net_cards_conf[i].secret));
|
||||
strncpy(net_cards_conf[i].secret, secret_value->text().toUtf8().constData(), sizeof(net_cards_conf[i].secret) - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -349,13 +343,13 @@ SettingsNetwork::onCurrentMachineChanged(int machineId)
|
||||
} else if (net_cards_conf[i].net_type == NET_TYPE_NLSWITCH) {
|
||||
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);
|
||||
auto *secret_value = findChild<QLineEdit *>(QString("secretSwitch%1").arg(i + 1));
|
||||
secret_value->setText(net_cards_conf[i].secret);
|
||||
} 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);
|
||||
auto *secret_value = findChild<QLineEdit *>(QString("secretSwitch%1").arg(i + 1));
|
||||
secret_value->setText(net_cards_conf[i].secret);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,38 +170,18 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="labelSwitch1">
|
||||
<widget class="QLabel" name="labelSecret1">
|
||||
<property name="text">
|
||||
<string>Switch:</string>
|
||||
<string>Shared secret:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<layout class="QHBoxLayout" name="HLayoutSwitch1">
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinnerSwitch1">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>10</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacerSwitch1">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
<widget class="QLineEdit" name="secretSwitch1">
|
||||
<property name="maxLength">
|
||||
<number>256</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<widget class="QLabel" name="labelPromisc1">
|
||||
@@ -385,38 +365,18 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="labelSwitch2">
|
||||
<widget class="QLabel" name="labelSecret2">
|
||||
<property name="text">
|
||||
<string>Switch:</string>
|
||||
<string>Shared secret:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<layout class="QHBoxLayout" name="HLayoutSwitch2">
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinnerSwitch2">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>10</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacerSwitch2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
<widget class="QLineEdit" name="secretSwitch2">
|
||||
<property name="maxLength">
|
||||
<number>256</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<widget class="QLabel" name="labelPromisc2">
|
||||
@@ -600,38 +560,18 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="labelSwitch3">
|
||||
<widget class="QLabel" name="labelSecret3">
|
||||
<property name="text">
|
||||
<string>Switch:</string>
|
||||
<string>Shared secret:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<layout class="QHBoxLayout" name="HLayoutSwitch3">
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinnerSwitch3">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>10</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacerSwitch3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
<widget class="QLineEdit" name="secretSwitch3">
|
||||
<property name="maxLength">
|
||||
<number>256</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<widget class="QLabel" name="labelPromisc3">
|
||||
@@ -815,38 +755,18 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="labelSwitch4">
|
||||
<widget class="QLabel" name="labelSecret4">
|
||||
<property name="text">
|
||||
<string>Switch:</string>
|
||||
<string>Shared secret:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<layout class="QHBoxLayout" name="HLayoutSwitch4">
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinnerSwitch4">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>10</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacerSwitch4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
<widget class="QLineEdit" name="secretSwitch4">
|
||||
<property name="maxLength">
|
||||
<number>256</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<widget class="QLabel" name="labelPromisc4">
|
||||
|
||||
Reference in New Issue
Block a user