From 3181dadd0e649bd4c460919ee882ff0672dff6d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josep=20Maria=20Antol=C3=ADn=20Segura?= Date: Mon, 23 Sep 2024 01:40:57 +0200 Subject: [PATCH] changes to compile again with networking enabled. (#266) --- .github/workflows/test-debug-builds.yml | 6 +-- .github/workflows/test-release-builds.yml | 6 +-- .../workflows/test-relwithdebinfo-builds.yml | 6 +-- CMakeLists.txt | 3 ++ includes/private/networking/slirp/slirp.h | 6 +-- src/cpu/808x.c | 49 ++++++++++--------- src/networking/slirp/cksum.c | 2 +- src/networking/slirp/slirp.c | 17 ++++--- src/networking/slirp/socket.c | 2 +- src/networking/slirp/tftp.c | 14 +++--- src/wx-ui/wx-hostconfig.c | 23 ++++++--- 11 files changed, 77 insertions(+), 57 deletions(-) diff --git a/.github/workflows/test-debug-builds.yml b/.github/workflows/test-debug-builds.yml index 2f349b3a..691bcdb2 100644 --- a/.github/workflows/test-debug-builds.yml +++ b/.github/workflows/test-debug-builds.yml @@ -14,7 +14,7 @@ jobs: include: - name: Ubuntu 64bit (gcc) os: ubuntu-latest - args: -DUSE_EXPERIMENTAL=ON -DUSE_EXPERIMENTAL_PRINTER=OFF -DUSE_EXPERIMENTAL_PGC=ON -DUSE_NETWORKING=OFF -DUSE_PCAP_NETWORKING=ON -DCMAKE_BUILD_TYPE=Debug -DPCEM_VERSION_STRING="vNext build ${GITHUB_SHA::8}" + args: -DUSE_EXPERIMENTAL=ON -DUSE_EXPERIMENTAL_PRINTER=OFF -DUSE_EXPERIMENTAL_PGC=ON -DUSE_NETWORKING=ON -DUSE_PCAP_NETWORKING=ON -DCMAKE_BUILD_TYPE=Debug -DPCEM_VERSION_STRING="vNext build ${GITHUB_SHA::8}" artifacts_name: PCem-Debug-vNext-Ubuntu-${{ github.run_number }} artifacts_path: PCem-Debug-vNext-Ubuntu-${{ github.run_number }}-${{ github.sha }}.tar.bz2 installdeps: >- @@ -27,7 +27,7 @@ jobs: - name: Windows 32bits (MSYS2) os: windows-latest compiler: MINGW32 - args: -DUSE_EXPERIMENTAL=ON -DUSE_EXPERIMENTAL_PRINTER=OFF -DUSE_EXPERIMENTAL_PGC=ON -DUSE_NETWORKING=OFF -DUSE_PCAP_NETWORKING=OFF -DCMAKE_BUILD_TYPE=Debug -DPCEM_VERSION_STRING="vNext build ${GITHUB_SHA::8}" + args: -DUSE_EXPERIMENTAL=ON -DUSE_EXPERIMENTAL_PRINTER=OFF -DUSE_EXPERIMENTAL_PGC=ON -DUSE_NETWORKING=ON -DUSE_PCAP_NETWORKING=OFF -DCMAKE_BUILD_TYPE=Debug -DPCEM_VERSION_STRING="vNext build ${GITHUB_SHA::8}" artifacts_name: PCem-Debug-vNext-Windows-MINGW32-${{ github.run_number }} artifacts_path: PCem-Debug-vNext-Windows-MINGW32-${{ github.run_number }}-${{ github.sha }}.zip installdeps: >- @@ -44,7 +44,7 @@ jobs: - name: Windows 64bits (MSYS2) os: windows-latest compiler: MINGW64 - args: -DUSE_EXPERIMENTAL=ON -DUSE_EXPERIMENTAL_PRINTER=OFF -DUSE_EXPERIMENTAL_PGC=ON -DUSE_NETWORKING=OFF -DUSE_PCAP_NETWORKING=ON -DCMAKE_BUILD_TYPE=Debug -DPCEM_VERSION_STRING="vNext build ${GITHUB_SHA::8}" + args: -DUSE_EXPERIMENTAL=ON -DUSE_EXPERIMENTAL_PRINTER=OFF -DUSE_EXPERIMENTAL_PGC=ON -DUSE_NETWORKING=ON -DUSE_PCAP_NETWORKING=ON -DCMAKE_BUILD_TYPE=Debug -DPCEM_VERSION_STRING="vNext build ${GITHUB_SHA::8}" artifacts_name: PCem-Debug-vNext-Windows-MINGW64-${{ github.run_number }} artifacts_path: PCem-Debug-vNext-Windows-MINGW64-${{ github.run_number }}-${{ github.sha }}.zip installdeps: >- diff --git a/.github/workflows/test-release-builds.yml b/.github/workflows/test-release-builds.yml index b2ba3326..7e4c72b8 100644 --- a/.github/workflows/test-release-builds.yml +++ b/.github/workflows/test-release-builds.yml @@ -14,7 +14,7 @@ jobs: include: - name: Ubuntu 64bit (gcc) os: ubuntu-latest - args: -DUSE_EXPERIMENTAL=ON -DUSE_EXPERIMENTAL_PRINTER=OFF -DUSE_EXPERIMENTAL_PGC=ON -DUSE_NETWORKING=OFF -DUSE_PCAP_NETWORKING=ON -DCMAKE_BUILD_TYPE=Release -DPCEM_VERSION_STRING="vNext build ${GITHUB_SHA::8}" + args: -DUSE_EXPERIMENTAL=ON -DUSE_EXPERIMENTAL_PRINTER=OFF -DUSE_EXPERIMENTAL_PGC=ON -DUSE_NETWORKING=ON -DUSE_PCAP_NETWORKING=ON -DCMAKE_BUILD_TYPE=Release -DPCEM_VERSION_STRING="vNext build ${GITHUB_SHA::8}" artifacts_name: PCem-vNext-Ubuntu-${{ github.run_number }} artifacts_path: PCem-vNext-Ubuntu-${{ github.run_number }}-${{ github.sha }}.tar.bz2 installdeps: >- @@ -27,7 +27,7 @@ jobs: - name: Windows 32bits (MSYS2) os: windows-latest compiler: MINGW32 - args: -DUSE_EXPERIMENTAL=ON -DUSE_EXPERIMENTAL_PRINTER=OFF -DUSE_EXPERIMENTAL_PGC=ON -DUSE_NETWORKING=OFF -DUSE_PCAP_NETWORKING=OFF -DCMAKE_BUILD_TYPE=Release -DPCEM_VERSION_STRING="vNext build ${GITHUB_SHA::8}" + args: -DUSE_EXPERIMENTAL=ON -DUSE_EXPERIMENTAL_PRINTER=OFF -DUSE_EXPERIMENTAL_PGC=ON -DUSE_NETWORKING=ON -DUSE_PCAP_NETWORKING=OFF -DCMAKE_BUILD_TYPE=Release -DPCEM_VERSION_STRING="vNext build ${GITHUB_SHA::8}" artifacts_name: PCem-vNext-Windows-MINGW32-${{ github.run_number }} artifacts_path: PCem-vNext-Windows-MINGW32-${{ github.run_number }}-${{ github.sha }}.zip installdeps: >- @@ -44,7 +44,7 @@ jobs: - name: Windows 64bits (MSYS2) os: windows-latest compiler: MINGW64 - args: -DUSE_EXPERIMENTAL=ON -DUSE_EXPERIMENTAL_PRINTER=OFF -DUSE_EXPERIMENTAL_PGC=ON -DUSE_NETWORKING=OFF -DUSE_PCAP_NETWORKING=ON -DCMAKE_BUILD_TYPE=Release -DPCEM_VERSION_STRING="vNext build ${GITHUB_SHA::8}" + args: -DUSE_EXPERIMENTAL=ON -DUSE_EXPERIMENTAL_PRINTER=OFF -DUSE_EXPERIMENTAL_PGC=ON -DUSE_NETWORKING=ON -DUSE_PCAP_NETWORKING=ON -DCMAKE_BUILD_TYPE=Release -DPCEM_VERSION_STRING="vNext build ${GITHUB_SHA::8}" artifacts_name: PCem-vNext-Windows-MINGW64-${{ github.run_number }} artifacts_path: PCem-vNext-Windows-MINGW64-${{ github.run_number }}-${{ github.sha }}.zip installdeps: >- diff --git a/.github/workflows/test-relwithdebinfo-builds.yml b/.github/workflows/test-relwithdebinfo-builds.yml index 2ce02af1..87ec346e 100644 --- a/.github/workflows/test-relwithdebinfo-builds.yml +++ b/.github/workflows/test-relwithdebinfo-builds.yml @@ -14,7 +14,7 @@ jobs: include: - name: Ubuntu 64bit (gcc) os: ubuntu-latest - args: -DUSE_EXPERIMENTAL=ON -DUSE_EXPERIMENTAL_PRINTER=OFF -DUSE_EXPERIMENTAL_PGC=ON -DUSE_NETWORKING=OFF -DUSE_PCAP_NETWORKING=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DPCEM_RELDEB_AS_RELEASE=OFF -DPCEM_VERSION_STRING="vNext build ${GITHUB_SHA::8}" + args: -DUSE_EXPERIMENTAL=ON -DUSE_EXPERIMENTAL_PRINTER=OFF -DUSE_EXPERIMENTAL_PGC=ON -DUSE_NETWORKING=ON -DUSE_PCAP_NETWORKING=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DPCEM_RELDEB_AS_RELEASE=OFF -DPCEM_VERSION_STRING="vNext build ${GITHUB_SHA::8}" artifacts_name: PCem-RelWithDebInfo-vNext-Ubuntu-${{ github.run_number }} artifacts_path: PCem-RelWithDebInfo-vNext-Ubuntu-${{ github.run_number }}-${{ github.sha }}.tar.bz2 installdeps: >- @@ -27,7 +27,7 @@ jobs: - name: Windows 32bits (MSYS2) os: windows-latest compiler: MINGW32 - args: -DUSE_EXPERIMENTAL=ON -DUSE_EXPERIMENTAL_PRINTER=OFF -DUSE_EXPERIMENTAL_PGC=ON -DUSE_NETWORKING=OFF -DUSE_PCAP_NETWORKING=OFF -DCMAKE_BUILD_TYPE=RelWithDebInfo -DPCEM_RELDEB_AS_RELEASE=OFF -DPCEM_VERSION_STRING="vNext build ${GITHUB_SHA::8}" + args: -DUSE_EXPERIMENTAL=ON -DUSE_EXPERIMENTAL_PRINTER=OFF -DUSE_EXPERIMENTAL_PGC=ON -DUSE_NETWORKING=ON -DUSE_PCAP_NETWORKING=OFF -DCMAKE_BUILD_TYPE=RelWithDebInfo -DPCEM_RELDEB_AS_RELEASE=OFF -DPCEM_VERSION_STRING="vNext build ${GITHUB_SHA::8}" artifacts_name: PCem-RelWithDebInfo-vNext-Windows-MINGW32-${{ github.run_number }} artifacts_path: PCem-RelWithDebInfo-vNext-Windows-MINGW32-${{ github.run_number }}-${{ github.sha }}.zip installdeps: >- @@ -44,7 +44,7 @@ jobs: - name: Windows 64bits (MSYS2) os: windows-latest compiler: MINGW64 - args: -DUSE_EXPERIMENTAL=ON -DUSE_EXPERIMENTAL_PRINTER=OFF -DUSE_EXPERIMENTAL_PGC=ON -DUSE_NETWORKING=OFF -DUSE_PCAP_NETWORKING=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DPCEM_RELDEB_AS_RELEASE=OFF -DPCEM_VERSION_STRING="vNext build ${GITHUB_SHA::8}" + args: -DUSE_EXPERIMENTAL=ON -DUSE_EXPERIMENTAL_PRINTER=OFF -DUSE_EXPERIMENTAL_PGC=ON -DUSE_NETWORKING=ON -DUSE_PCAP_NETWORKING=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DPCEM_RELDEB_AS_RELEASE=OFF -DPCEM_VERSION_STRING="vNext build ${GITHUB_SHA::8}" artifacts_name: PCem-RelWithDebInfo-vNext-Windows-MINGW64-${{ github.run_number }} artifacts_path: PCem-RelWithDebInfo-vNext-Windows-MINGW64-${{ github.run_number }}-${{ github.sha }}.zip installdeps: >- diff --git a/CMakeLists.txt b/CMakeLists.txt index 7cce6c1d..e73870d1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,6 +48,9 @@ option(USE_NETWORKING "Build PCem with networking support" ON) message("Networking Support: ${USE_NETWORKING}") if(USE_NETWORKING) + set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -std=gnu17") + message(" Switching C to gnu17 to allow slirp to build") + option(USE_PCAP_NETWORKING "Build PCem with PCAP support" ON) message(" PCAP Networking Support: ${USE_PCAP_NETWORKING}") endif() diff --git a/includes/private/networking/slirp/slirp.h b/includes/private/networking/slirp/slirp.h index 207c1296..2ad80e2f 100644 --- a/includes/private/networking/slirp/slirp.h +++ b/includes/private/networking/slirp/slirp.h @@ -50,17 +50,17 @@ typedef unsigned long ioctlsockopt_t; #include //needs to be on top otherwise, it'll pull in winsock1 #include - +#include #include #include #define USE_FIONBIO 1 -#define EWOULDBLOCK WSAEWOULDBLOCK +/*#define EWOULDBLOCK WSAEWOULDBLOCK #define EINPROGRESS WSAEINPROGRESS #define ENOTCONN WSAENOTCONN #define EHOSTUNREACH WSAEHOSTUNREACH #define ENETUNREACH WSAENETUNREACH -#define ECONNREFUSED WSAECONNREFUSED +#define ECONNREFUSED WSAECONNREFUSED*/ /* Basilisk II Router defines those */ #define udp_read_completion slirp_udp_read_completion diff --git a/src/cpu/808x.c b/src/cpu/808x.c index d73d9c0e..222746cc 100644 --- a/src/cpu/808x.c +++ b/src/cpu/808x.c @@ -525,6 +525,14 @@ void makeznptable() { int indump = 0; +FILE* dofopen(const char *filepath, const char* filename, const char * mode) { + int c = strlen(filepath) - 1; + char* sep = (filepath[c] == '/' || filepath[c] == '\\') ? "" : "/"; + char buf[1024]; + sprintf(buf, "%s%s%s", filepath, sep, filename); + return fopen(buf, mode); +} + void dumpregs() { int c, d = 0, e = 0; #ifndef RELEASE_BUILD @@ -532,74 +540,69 @@ void dumpregs() { if (indump) return; indump = 1; - // return; output = 0; - // return; - // savenvr(); - // return; - chdir(logs_path); - /* f=fopen("rram3.dmp","wb"); + /* f=dofopen(logs_path, "rram3.dmp","wb"); for (c=0;c<0x8000000;c++) putc(readmemb(c+0x10000000),f); fclose(f);*/ - f = fopen("ram.dmp", "wb"); + f = dofopen(logs_path, "ram.dmp", "wb"); fwrite(ram, mem_size * 1024, 1, f); fclose(f); /* pclog("Dumping rram5.dmp\n"); - f=fopen("rram5.dmp","wb"); + f=dofopen(logs_path, "rram5.dmp","wb"); for (c=0;c<0x1000000;c++) putc(readmemb(c+0x10150000),f); fclose(f);*/ pclog("Dumping rram.dmp\n"); - f = fopen("rram.dmp", "wb"); + f = dofopen(logs_path, "rram.dmp", "wb"); for (c = 0; c < 0x1000000; c++) putc(readmemb(c), f); fclose(f); - /* f=fopen("rram2.dmp","wb"); + /* f=dofopen(logs_path, "rram2.dmp","wb"); for (c=0;c<0x100000;c++) putc(readmemb(c+0xbff00000),f); fclose(f); - f = fopen("stack.dmp","wb"); + f = dofopen(logs_path, "stack.dmp","wb"); for (c = 0; c < 0x6000; c++) putc(readmemb(c+0xFFDFA000), f); fclose(f); - f = fopen("tempx.dmp","wb"); + f = dofopen(logs_path, "tempx.dmp","wb"); for (c = 0; c < 0x10000; c++) putc(readmemb(c+0xFC816000), f); fclose(f); - f = fopen("tempx2.dmp","wb"); + f = dofopen(logs_path, "tempx2.dmp","wb"); for (c = 0; c < 0x10000; c++) putc(readmemb(c+0xFDEF5000), f); fclose(f);*/ pclog("Dumping rram4.dmp\n"); - f = fopen("rram4.dmp", "wb"); + f = dofopen(logs_path, "rram4.dmp", "wb"); for (c = 0; c < 0x0050000; c++) { cpu_state.abrt = 0; putc(readmembl(c + 0x80000000), f); } fclose(f); pclog("Dumping done\n"); -/* f=fopen("rram6.dmp","wb"); +/* f=dofopen(logs_path, "rram6.dmp","wb"); for (c=0;c<0x1000000;c++) putc(readmemb(c+0xBF000000),f); fclose(f);*/ -/* f=fopen("ram6.bin","wb"); +/* f=dofopen(logs_path, "ram6.bin","wb"); fwrite(ram+0x10100,0xA000,1,f); fclose(f); - f=fopen("boot.bin","wb"); + f=dofopen(logs_path, "boot.bin","wb"); fwrite(ram+0x7C00,0x200,1,f); fclose(f); - f=fopen("ram7.bin","wb"); + f=dofopen(logs_path, "ram7.bin","wb"); fwrite(ram+0x11100,0x2000,1,f); fclose(f); - f=fopen("ram8.bin","wb"); + f=dofopen(logs_path, "ram8.bin","wb"); fwrite(ram+0x3D210,0x200,1,f); fclose(f); */ -/* f=fopen("bios.dmp","wb"); +/* f=dofopen(logs_path, "bios.dmp","wb"); fwrite(rom,0x20000,1,f); fclose(f);*/ -/* f=fopen("kernel.dmp","wb"); +/* f=dofopen(logs_path, "kernel.dmp","wb"); for (c=0;c<0x200000;c++) putc(readmemb(c+0xC0000000),f); fclose(f);*/ -/* f=fopen("rram.dmp","wb"); +/* f=dofopen(logs_path, "rram.dmp","wb"); for (c=0;c<0x1500000;c++) putc(readmemb(c),f); fclose(f); if (!times) { - f=fopen("thing.dmp","wb"); + f=dofopen(logs_path, "thing.dmp","wb"); fwrite(ram+0x11E50,0x1000,1,f); fclose(f); }*/ diff --git a/src/networking/slirp/cksum.c b/src/networking/slirp/cksum.c index 7d88c0c1..62b651b0 100644 --- a/src/networking/slirp/cksum.c +++ b/src/networking/slirp/cksum.c @@ -76,7 +76,7 @@ int cksum(struct SLIRPmbuf *m, int len) { /* * Force to even boundary. */ - if ((1 & (long)w) && (mlen > 0)) { + if ((1 & (off_t)w) && (mlen > 0)) { REDUCE; sum <<= 8; s_util.c[0] = *(u_int8_t *)w; diff --git a/src/networking/slirp/slirp.c b/src/networking/slirp/slirp.c index 118a0017..bfa2f2df 100644 --- a/src/networking/slirp/slirp.c +++ b/src/networking/slirp/slirp.c @@ -343,6 +343,7 @@ int slirp_select_fill(int *pnfds, fd_set *readfds, fd_set *writefds, fd_set *xfd void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds) { struct SLIRPsocket *so, *so_next; int ret; + char* dummy = ""; global_readfds = readfds; global_writefds = writefds; @@ -419,11 +420,9 @@ void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds) { /* Connected */ so->so_state &= ~SS_ISFCONNECTING; - // ret = send(so->s, &ret, 0, 0); - // winsock2.h:549:32: note: expected 'const char *' but argument is of type 'int *' - // WINSOCK_API_LINKAGE int PASCAL send(SOCKET,const char*,int,int); JASON - // ret = send(so->s, "a", 1, 0); WHY THE HELL WAS THIS HERE?! - ret = send(so->s, &ret, 0, 0); // This is what it should be. + // on linux: extern ssize_t send (int __fd, const void *__buf, size_t __n, int __flags) + // but on windows: int send(SOCKET s, const char * buf, int len, int flags) + ret = send(so->s, dummy, 0, 0); if (ret < 0) { /* XXXXX Must fix, zero bytes is a NOP */ if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINPROGRESS || @@ -456,7 +455,9 @@ void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds) { */ #ifdef PROBE_CONN if (so->so_state & SS_ISFCONNECTING) { - ret = recv(so->s, (char *)&ret, 0, 0); + // on linux: extern ssize_t recv (int __fd, void *__buf, size_t __n, int __flags); + // but on windows: int recv(SOCKET s, char * buf, int len,int flags) + ret = recv(so->s, dummy, 0, 0); if (ret < 0) { /* XXX */ @@ -468,7 +469,9 @@ void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds) { /* tcp_input will take care of it */ } else { - ret = send(so->s, &ret, 0, 0); + // on linux: extern ssize_t send (int __fd, const void *__buf, size_t __n, int __flags) + // but on windows: int send(SOCKET s, const char * buf, int len, int flags) + ret = send(so->s, dummy, 0, 0); if (ret < 0) { /* XXX */ if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINPROGRESS || diff --git a/src/networking/slirp/socket.c b/src/networking/slirp/socket.c index bfcc5fb8..c3b396c1 100644 --- a/src/networking/slirp/socket.c +++ b/src/networking/slirp/socket.c @@ -572,7 +572,7 @@ int flags; (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) || (listen(s, 1) < 0)) { int tmperrno = errno; /* Don't clobber the real reason we failed */ - close(s); + closesocket(s); sofree(so); /* Restore the real errno */ #ifdef _WIN32 diff --git a/src/networking/slirp/tftp.c b/src/networking/slirp/tftp.c index d94a3397..b39daac8 100644 --- a/src/networking/slirp/tftp.c +++ b/src/networking/slirp/tftp.c @@ -24,6 +24,8 @@ #include "slirp/slirp.h" +#include + struct tftp_session { int in_use; char filename[TFTP_FILENAME_MAX]; @@ -92,22 +94,22 @@ static int tftp_session_find(struct tftp_t *tp) { } static int tftp_read_data(struct tftp_session *spt, u_int16_t block_nr, u_int8_t *buf, int len) { - int fd; + FILE* file; int bytes_read = 0; - fd = open(spt->filename, O_RDONLY | O_BINARY); + file = fopen(spt->filename, "rb"); - if (fd < 0) { + if (file == NULL) { return -1; } if (len) { - lseek(fd, block_nr * 512, SEEK_SET); + fseek(file, block_nr * 512, SEEK_SET); - bytes_read = read(fd, buf, len); + bytes_read = fread(buf, len, 1, file); } - close(fd); + fclose(file); return bytes_read; } diff --git a/src/wx-ui/wx-hostconfig.c b/src/wx-ui/wx-hostconfig.c index d234d788..3f919473 100644 --- a/src/wx-ui/wx-hostconfig.c +++ b/src/wx-ui/wx-hostconfig.c @@ -18,8 +18,7 @@ #include "nethandler.h" #ifdef USE_PCAP_NETWORKING -static pcap_if_t *alldevs; -static char *dev_name[20]; +static char *dev_names[20]; #endif #define ETH_DEV_NAME_MAX 256 /* maximum device name size */ @@ -64,6 +63,7 @@ static int get_network_name(char *dev_name, char *regval) { int hostconfig_dialog_proc(void *hdlg, int message, INT_PARAM wParam, LONG_PARAM lParam) { void *h; #ifdef USE_PCAP_NETWORKING + pcap_if_t *alldevs; pcap_if_t *dev; char errbuf[PCAP_ERRBUF_SIZE]; #endif @@ -80,8 +80,11 @@ int hostconfig_dialog_proc(void *hdlg, int message, INT_PARAM wParam, LONG_PARAM int c = 0; int match = 0; + const char *pcap_version = pcap_lib_version(); + pclog("PCAP library version: %s\n", pcap_version); + + if (pcap_findalldevs(&alldevs, errbuf) == 0) { - if (pcap_findalldevs(&alldevs, errbuf) != -1) { char *pcap_device = config_get_string(CFG_GLOBAL, NULL, "pcap_device", "nothing"); h = wx_getdlgitem(hdlg, WX_ID("IDC_COMBO_NETWORK_DEVICE")); @@ -107,7 +110,7 @@ int hostconfig_dialog_proc(void *hdlg, int message, INT_PARAM wParam, LONG_PARAM match = c; } - dev_name[c++] = dev->name; + dev_names[c++] = dev->name; if (get_network_name(dev->name, desc)) wx_sendmessage(h, WX_CB_ADDSTRING, 0, (LONG_PARAM)dev->name); else { @@ -116,6 +119,12 @@ int hostconfig_dialog_proc(void *hdlg, int message, INT_PARAM wParam, LONG_PARAM } } } + } else { + errbuf[PCAP_ERRBUF_SIZE - 1] = '\0'; + error("Error in pcap_findalldevs: %s\n", errbuf); + } + if (alldevs != 0) { + pcap_freealldevs(alldevs); } if (c) { h = wx_getdlgitem(hdlg, WX_ID("IDC_COMBO_NETWORK_TYPE")); @@ -141,13 +150,13 @@ int hostconfig_dialog_proc(void *hdlg, int message, INT_PARAM wParam, LONG_PARAM #ifdef USE_PCAP_NETWORKING if (type) /*PCAP*/ { - int dev; + int idev; h = wx_getdlgitem(hdlg, WX_ID("IDC_COMBO_NETWORK_DEVICE")); - dev = wx_sendmessage(h, WX_CB_GETCURSEL, 0, 0); + idev = wx_sendmessage(h, WX_CB_GETCURSEL, 0, 0); config_set_int(CFG_GLOBAL, NULL, "net_type", NET_PCAP); - config_set_string(CFG_GLOBAL, NULL, "pcap_device", dev_name[dev]); + config_set_string(CFG_GLOBAL, NULL, "pcap_device", dev_names[idev]); } else /*SLiRP*/ { #endif