BOOL CPageConfigTfe::get_tfename(int number, char **ppname, char **ppdescription) { if (tfe_enumadapter_open()) { char *pname = NULL; char *pdescription = NULL; while (number--) { if (!tfe_enumadapter(&pname, &pdescription)) break; lib_free(pname); lib_free(pdescription); } if (tfe_enumadapter(&pname, &pdescription)) { *ppname = pname; *ppdescription = pdescription; tfe_enumadapter_close(); return TRUE; } tfe_enumadapter_close(); } return FALSE; }
static BOOL TfePcapOpenAdapter(const char *interface_name) { pcap_if_t *TfePcapDevice = NULL; if (!tfe_enumadapter_open()) { return FALSE; } else { /* look if we can find the specified adapter */ char *pname; char *pdescription; BOOL found = FALSE; if (interface_name) { /* we have an interface name, try it */ TfePcapDevice = TfePcapAlldevs; while (tfe_enumadapter(&pname, &pdescription)) { if (strcmp(pname, interface_name)==0) { found = TRUE; } lib_free(pname); lib_free(pdescription); if (found) break; TfePcapDevice = TfePcapNextDev; } } if (!found) { /* just take the first adapter */ TfePcapDevice = TfePcapAlldevs; } } TfePcapFP = (*p_pcap_open_live)(TfePcapDevice->name, 1700, 1, 20, TfePcapErrbuf); if ( TfePcapFP == NULL) { if(g_fh) fprintf(g_fh, "ERROR opening adapter: '%s'", TfePcapErrbuf); tfe_enumadapter_close(); return FALSE; } if ((*p_pcap_setnonblock)(TfePcapFP, 1, TfePcapErrbuf)<0) { if(g_fh) fprintf(g_fh, "WARNING: Setting PCAP to non-blocking failed: '%s'", TfePcapErrbuf); } /* Check the link layer. We support only Ethernet for simplicity. */ if((*p_pcap_datalink)(TfePcapFP) != DLT_EN10MB) { if(g_fh) fprintf(g_fh, "ERROR: TFE works only on Ethernet networks."); tfe_enumadapter_close(); return FALSE; } tfe_enumadapter_close(); return TRUE; }
void CPageConfigTfe::init_tfe_dialog(HWND hwnd) { HWND temp_hwnd; int active_value; int tfe_enable; int xsize, ysize; char *interface_name = NULL; uilib_get_group_extent(hwnd, ms_leftgroup, &xsize, &ysize); uilib_adjust_group_width(hwnd, ms_leftgroup); uilib_move_group(hwnd, ms_rightgroup, xsize + 30); //resources_get_value("ETHERNET_ACTIVE", (void *)&tfe_enabled); get_tfe_enabled(&tfe_enable); //resources_get_value("ETHERNET_AS_RR", (void *)&tfe_as_rr_net); active_value = (tfe_enable ? 1 : 0); temp_hwnd=GetDlgItem(hwnd,IDC_TFE_SETTINGS_ENABLE); SendMessage(temp_hwnd, CB_ADDSTRING, 0, (LPARAM)"Disabled"); SendMessage(temp_hwnd, CB_ADDSTRING, 0, (LPARAM)"Uthernet"); SendMessage(temp_hwnd, CB_SETCURSEL, (WPARAM)active_value, 0); //resources_get_value("ETHERNET_INTERFACE", (void *)&interface_name); interface_name = (char *) get_tfe_interface(); if (tfe_enumadapter_open()) { int cnt = 0; char *pname; char *pdescription; temp_hwnd=GetDlgItem(hwnd,IDC_TFE_SETTINGS_INTERFACE); for (cnt = 0; tfe_enumadapter(&pname, &pdescription); cnt++) { BOOL this_entry = FALSE; if (strcmp(pname, interface_name) == 0) { this_entry = TRUE; } SetWindowText(GetDlgItem(hwnd, IDC_TFE_SETTINGS_INTERFACE_NAME), pname); SetWindowText(GetDlgItem(hwnd, IDC_TFE_SETTINGS_INTERFACE_DESC), pdescription); SendMessage(temp_hwnd, CB_ADDSTRING, 0, (LPARAM)pname); lib_free(pname); lib_free(pdescription); if (this_entry) { SendMessage(GetDlgItem(hwnd, IDC_TFE_SETTINGS_INTERFACE), CB_SETCURSEL, (WPARAM)cnt, 0); } } tfe_enumadapter_close(); } if (gray_ungray_items(hwnd)) { /* we have a problem: TFE is disabled. Give a message to the user */ // TC (18 Dec 2017) this vicekb URL is a broken link now, so I copied it to the AppleWin repo, here: // . https://github.com/AppleWin/AppleWin/blob/master/docs/VICE%20Knowledge%20Base%20-%20Article%2013-005.htm MessageBox( hwnd, "TFE support is not available on your system,\n" "there is some important part missing. Please have a\n" "look at the VICE knowledge base support page\n" "\n http://vicekb.trikaliotis.net/13-005\n\n" "for possible reasons and to activate networking with VICE.", "TFE support", MB_ICONINFORMATION|MB_OK); /* just quit the dialog before it is open */ SendMessage( hwnd, WM_COMMAND, IDCANCEL, 0); } }