network: Added new ability for drivers to provide error information upon failed init. Updated translation strings. Fixed an issue with VDE configuration settings.
This commit is contained in:
@@ -442,6 +442,9 @@ network_attach(void *card_drv, uint8_t *mac, NETRXCB rx, NETSETLINKSTATE set_lin
|
||||
card->card_num = net_card_current;
|
||||
card->byte_period = NET_PERIOD_10M;
|
||||
|
||||
char net_drv_error[NET_DRV_ERRBUF_SIZE];
|
||||
wchar_t tempmsg[NET_DRV_ERRBUF_SIZE * 2];
|
||||
|
||||
for (int i = 0; i < NET_QUEUE_COUNT; i++) {
|
||||
network_queue_init(&card->queues[i]);
|
||||
}
|
||||
@@ -449,17 +452,17 @@ network_attach(void *card_drv, uint8_t *mac, NETRXCB rx, NETSETLINKSTATE set_lin
|
||||
switch (net_cards_conf[net_card_current].net_type) {
|
||||
case NET_TYPE_SLIRP:
|
||||
card->host_drv = net_slirp_drv;
|
||||
card->host_drv.priv = card->host_drv.init(card, mac, NULL);
|
||||
card->host_drv.priv = card->host_drv.init(card, mac, NULL, net_drv_error);
|
||||
break;
|
||||
|
||||
case NET_TYPE_PCAP:
|
||||
card->host_drv = net_pcap_drv;
|
||||
card->host_drv.priv = card->host_drv.init(card, mac, net_cards_conf[net_card_current].host_dev_name);
|
||||
card->host_drv.priv = card->host_drv.init(card, mac, net_cards_conf[net_card_current].host_dev_name, net_drv_error);
|
||||
break;
|
||||
#ifdef HAS_VDE
|
||||
case NET_TYPE_VDE:
|
||||
card->host_drv = net_vde_drv;
|
||||
card->host_drv.priv = card->host_drv.init(card, mac, net_cards_conf[net_card_current].host_dev_name);
|
||||
card->host_drv.priv = card->host_drv.init(card, mac, net_cards_conf[net_card_current].host_dev_name, net_drv_error);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
@@ -474,13 +477,14 @@ network_attach(void *card_drv, uint8_t *mac, NETRXCB rx, NETSETLINKSTATE set_lin
|
||||
|
||||
if(net_cards_conf[net_card_current].net_type != NET_TYPE_NONE) {
|
||||
// We're here because of a failure
|
||||
// Placeholder to display a msgbox about falling back to null
|
||||
ui_msgbox(MBX_ERROR | MBX_ANSI, "Network driver initialization failed. Falling back to NULL driver.");
|
||||
swprintf(tempmsg, sizeof_w(tempmsg), L"%ls:<br /><br />%s<br /><br />%ls", plat_get_string(IDS_2167), net_drv_error, plat_get_string(IDS_2168));
|
||||
ui_msgbox(MBX_ERROR, tempmsg);
|
||||
net_cards_conf[net_card_current].net_type = NET_TYPE_NONE;
|
||||
}
|
||||
|
||||
// Init null driver
|
||||
card->host_drv = net_null_drv;
|
||||
card->host_drv.priv = card->host_drv.init(card, mac, NULL);
|
||||
card->host_drv.priv = card->host_drv.init(card, mac, NULL, net_drv_error);
|
||||
// Set link state to disconnected by default
|
||||
network_connect(card->card_num, 0);
|
||||
ui_sb_update_icon_state(SB_NETWORK | card->card_num, 1);
|
||||
|
||||
Reference in New Issue
Block a user