Network Switch support

Co-Authored-By: Alexander Babikov <2708460+lemondrops@users.noreply.github.com>
Co-Authored-By: cold-brewed <47337035+cold-brewed@users.noreply.github.com>
This commit is contained in:
Jasmine Iwanek
2025-06-26 20:53:17 -04:00
parent be8dc5f488
commit 2dc28d39b1
20 changed files with 6846 additions and 5 deletions

View File

@@ -681,6 +681,10 @@ load_network(void)
nc->net_type = NET_TYPE_VDE;
else if (!strcmp(p, "tap") || !strcmp(p, "4"))
nc->net_type = NET_TYPE_TAP;
else if (!strcmp(p, "nmswitch") || !strcmp(p, "5"))
nc->net_type = NET_TYPE_NMSWITCH;
else if (!strcmp(p, "nrswitch") || !strcmp(p, "6"))
nc->net_type = NET_TYPE_NRSWITCH;
else
nc->net_type = NET_TYPE_NONE;
} else
@@ -729,6 +733,10 @@ load_network(void)
nc->net_type = NET_TYPE_VDE;
else if (!strcmp(p, "tap") || !strcmp(p, "4"))
nc->net_type = NET_TYPE_TAP;
else if (!strcmp(p, "nmswitch") || !strcmp(p, "5"))
nc->net_type = NET_TYPE_NMSWITCH;
else if (!strcmp(p, "nrswitch") || !strcmp(p, "6"))
nc->net_type = NET_TYPE_NRSWITCH;
else
nc->net_type = NET_TYPE_NONE;
} else
@@ -750,6 +758,19 @@ load_network(void)
} else
strcpy(nc->host_dev_name, "none");
sprintf(temp, "net_%02i_switch_group", c + 1);
net_cards_conf[c].switch_group = ini_section_get_int(cat, temp, 0);
sprintf(temp, "net_%02i_promisc", c + 1);
net_cards_conf[c].promisc_mode = ini_section_get_int(cat, temp, 0);
sprintf(temp, "net_%02i_nrs_host", c + 1);
p = ini_section_get_string(cat, temp, NULL);
if (p != NULL)
strncpy(net_cards_conf[c].nrs_hostname, p, sizeof(net_cards_conf[c].nrs_hostname) - 1);
else
strncpy(net_cards_conf[c].nrs_hostname, "", sizeof(net_cards_conf[c].nrs_hostname) - 1);
sprintf(temp, "net_%02i_link", c + 1);
nc->link_state = ini_section_get_int(cat, temp,
(NET_LINK_10_HD | NET_LINK_10_FD |
@@ -2601,6 +2622,12 @@ save_network(void)
case NET_TYPE_TAP:
ini_section_set_string(cat, temp, "tap");
break;
case NET_TYPE_NMSWITCH:
ini_section_set_string(cat, temp, "nmswitch");
break;
case NET_TYPE_NRSWITCH:
ini_section_set_string(cat, temp, "nrswitch");
break;
default:
break;
}
@@ -2621,6 +2648,28 @@ save_network(void)
ini_section_delete_var(cat, temp);
else
ini_section_set_int(cat, temp, nc->link_state);
sprintf(temp, "net_%02i_switch_group", c + 1);
if (nc->device_num == 0)
ini_section_delete_var(cat, temp);
else
ini_section_set_int(cat, temp, net_cards_conf[c].switch_group);
sprintf(temp, "net_%02i_promisc", c + 1);
if (nc->device_num == 0)
ini_section_delete_var(cat, temp);
else
ini_section_set_int(cat, temp, net_cards_conf[c].promisc_mode);
sprintf(temp, "net_%02i_nrs_host", c + 1);
if (nc->device_num == 0)
ini_section_delete_var(cat, temp);
else {
if (nc->nrs_hostname[0] != '\0')
ini_section_set_string(cat, temp, net_cards_conf[c].nrs_hostname);
else
ini_section_delete_var(cat, temp);
}
}
ini_delete_section_if_empty(config, cat);