mirror of
https://github.com/sarah-walker-pcem/pcem.git
synced 2025-07-23 03:33:02 +02:00
changes to compile again with networking enabled. (#266)
This commit is contained in:
committed by
GitHub
parent
2e87d35d00
commit
3181dadd0e
6
.github/workflows/test-debug-builds.yml
vendored
6
.github/workflows/test-debug-builds.yml
vendored
@@ -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: >-
|
||||
|
6
.github/workflows/test-release-builds.yml
vendored
6
.github/workflows/test-release-builds.yml
vendored
@@ -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: >-
|
||||
|
@@ -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: >-
|
||||
|
@@ -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()
|
||||
|
@@ -50,17 +50,17 @@ typedef unsigned long ioctlsockopt_t;
|
||||
|
||||
#include <winsock2.h> //needs to be on top otherwise, it'll pull in winsock1
|
||||
#include <windows.h>
|
||||
|
||||
#include <ws2tcpip.h>
|
||||
#include <sys/timeb.h>
|
||||
#include <iphlpapi.h>
|
||||
|
||||
#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
|
||||
|
@@ -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);
|
||||
}*/
|
||||
|
@@ -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;
|
||||
|
@@ -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 ||
|
||||
|
@@ -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
|
||||
|
@@ -24,6 +24,8 @@
|
||||
|
||||
#include "slirp/slirp.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
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;
|
||||
}
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user