Add a cvar to control the address family.

OpenBSD doesn't allow mixed binding of ipv4 and ipv6, but being able to use
ipv6 enabled qf with ipv4 addresses would be nice...
This commit is contained in:
Bill Currie 2011-09-03 13:04:47 +09:00
parent 29a52a8cc8
commit 80b2b82092

View file

@ -117,6 +117,8 @@ static __attribute__ ((used)) const char rcsid[] =
# endif
#endif
static cvar_t *net_family;
netadr_t net_from;
netadr_t net_local_adr;
netadr_t net_loopback_adr;
@ -329,7 +331,13 @@ NET_StringToAdr (const char *s, netadr_t *a)
memset (&hints, 0, sizeof (hints));
hints.ai_socktype = SOCK_DGRAM;
hints.ai_family = PF_UNSPEC;
if (strchr (net_family->string, '6')) {
hints.ai_family = AF_INET6;
} else if (strchr (net_family->string, '4')) {
hints.ai_family = AF_INET;
} else {
hints.ai_family = AF_UNSPEC;
}
dstring_copystr (copy, s);
addrs = space = copy->str;
@ -568,6 +576,9 @@ NET_Init (int port)
if (r)
Sys_Error ("Winsock initialization failed.");
#endif /* _WIN32 */
net_family = Cvar_Get ("net_family", "unspecified", CVAR_ROM, 0,
"Set the address family to ipv4, ipv6 or"
" unspecified");
// open the single socket to be used for all communications
net_socket = UDP_OpenSocket (port);