network: icmp emulation (#694)

## Link to GitHub Issue or related Pull Request, if one exists
#0

## Description of change
Add `-icmphook` option under spicecfg Development/Network for emulating
keepalive ping replies in user mode, so games do not need to open
privileged raw ICMP sockets. This makes connecting to networks possible
on macOS under Whisky, and on Windows with ICMP firewalled or spice
running without Administrator privileges.

## Testing
Tested DDR and SDVX on Windows 10 and macOS Tahoe. Network check status
in test menu shows `CONNECTED` when -icmphook is enabled, and `NOT
CONNECTED` when it is disabled. Actual network functionality works as
expected (under previously impossible conditions).
This commit is contained in:
drmext
2026-05-14 07:44:14 +00:00
committed by GitHub
parent 6ec2b47345
commit 5bec3d5db7
8 changed files with 827 additions and 0 deletions
+6
View File
@@ -14,6 +14,7 @@
#include "util/fileutils.h"
#include "util/libutils.h"
#include "util/deferlog.h"
#include "hooks/icmphook_net.h"
// hooking related stuff
static decltype(GetAdaptersInfo) *GetAdaptersInfo_orig = nullptr;
@@ -189,6 +190,11 @@ static int WINAPI bind_hook(SOCKET s, const struct sockaddr *name, int namelen)
#pragma ide diagnostic ignored "OCDFAInspection"
#endif
int icmp_bind_result = 0;
if (icmphook_try_bind(s, name, namelen, &icmp_bind_result)) {
return icmp_bind_result;
}
// cast to sockaddr_in
struct sockaddr_in *in_name = (struct sockaddr_in *) name;