aboutsummaryrefslogtreecommitdiffstats
path: root/code/client
diff options
context:
space:
mode:
authorthilo <thilo@edf5b092-35ff-0310-97b2-ce42778d08ea>2008-04-04 23:22:22 +0000
committerthilo <thilo@edf5b092-35ff-0310-97b2-ce42778d08ea>2008-04-04 23:22:22 +0000
commitf4c60f773c1bae0e356090e812d9a619c1cfda85 (patch)
tree7125468e574841a6f996e4bd4bb85602b9195f0d /code/client
parent774e6430a3655619d690e4eb47fa04a32c4c6bd3 (diff)
downloadioquake3-aero-f4c60f773c1bae0e356090e812d9a619c1cfda85.tar.gz
ioquake3-aero-f4c60f773c1bae0e356090e812d9a619c1cfda85.zip
Basic IPv6 support. Some inspiration from the patches by Lubos Dolezel and JF Tremblay at https://bugzilla.icculus.org/show_bug.cgi?id=2355.
git-svn-id: svn://svn.icculus.org/quake3/trunk@1290 edf5b092-35ff-0310-97b2-ce42778d08ea
Diffstat (limited to 'code/client')
-rw-r--r--code/client/cl_main.c133
-rw-r--r--code/client/cl_ui.c4
2 files changed, 93 insertions, 44 deletions
diff --git a/code/client/cl_main.c b/code/client/cl_main.c
index 211907e..a03b9e7 100644
--- a/code/client/cl_main.c
+++ b/code/client/cl_main.c
@@ -780,7 +780,7 @@ void CL_MapLoading( void ) {
Key_SetCatcher( 0 );
SCR_UpdateScreen();
clc.connectTime = -RETRANSMIT_TIMEOUT;
- NET_StringToAdr( cls.servername, &clc.serverAddress);
+ NET_StringToAdr( cls.servername, &clc.serverAddress, NA_UNSPEC);
// we don't need a challenge on the localhost
CL_CheckForResend();
@@ -808,7 +808,7 @@ CL_UpdateGUID
update cl_guid using QKEY_FILE and optional prefix
====================
*/
-static void CL_UpdateGUID( char *prefix, int prefix_len )
+static void CL_UpdateGUID( const char *prefix, int prefix_len )
{
fileHandle_t f;
int len;
@@ -941,7 +941,7 @@ void CL_RequestMotd( void ) {
return;
}
Com_Printf( "Resolving %s\n", UPDATE_SERVER_NAME );
- if ( !NET_StringToAdr( UPDATE_SERVER_NAME, &cls.updateServer ) ) {
+ if ( !NET_StringToAdr( UPDATE_SERVER_NAME, &cls.updateServer, NA_IP ) ) {
Com_Printf( "Couldn't resolve address\n" );
return;
}
@@ -1011,7 +1011,7 @@ void CL_RequestAuthorization( void ) {
if ( !cls.authorizeServer.port ) {
Com_Printf( "Resolving %s\n", AUTHORIZE_SERVER_NAME );
- if ( !NET_StringToAdr( AUTHORIZE_SERVER_NAME, &cls.authorizeServer ) ) {
+ if ( !NET_StringToAdr( AUTHORIZE_SERVER_NAME, &cls.authorizeServer, NA_IP ) ) {
Com_Printf( "Couldn't resolve address\n" );
return;
}
@@ -1145,12 +1145,28 @@ CL_Connect_f
*/
void CL_Connect_f( void ) {
char *server;
- char serverString[ 22 ];
+ const char *serverString;
+ int argc = Cmd_Argc();
+ netadrtype_t family = NA_UNSPEC;
- if ( Cmd_Argc() != 2 ) {
- Com_Printf( "usage: connect [server]\n");
+ if ( argc != 2 && argc != 3 ) {
+ Com_Printf( "usage: connect [-4|-6] server\n");
return;
}
+
+ if(argc == 2)
+ server = Cmd_Argv(1);
+ else
+ {
+ if(!strcmp(Cmd_Argv(1), "-4"))
+ family = NA_IP;
+ else if(!strcmp(Cmd_Argv(1), "-6"))
+ family = NA_IP6;
+ else
+ Com_Printf( "warning: only -4 or -6 as address type understood.\n");
+
+ server = Cmd_Argv(2);
+ }
Cvar_Set("ui_singlePlayerActive", "0");
@@ -1160,8 +1176,6 @@ void CL_Connect_f( void ) {
// clear any previous "server full" type messages
clc.serverMessage[0] = 0;
- server = Cmd_Argv (1);
-
if ( com_sv_running->integer && !strcmp( server, "localhost" ) ) {
// if running a local server, kill it
SV_Shutdown( "Server quit" );
@@ -1180,7 +1194,7 @@ void CL_Connect_f( void ) {
Q_strncpyz( cls.servername, server, sizeof(cls.servername) );
- if (!NET_StringToAdr( cls.servername, &clc.serverAddress) ) {
+ if (!NET_StringToAdr(cls.servername, &clc.serverAddress, family) ) {
Com_Printf ("Bad server address\n");
cls.state = CA_DISCONNECTED;
return;
@@ -1188,12 +1202,10 @@ void CL_Connect_f( void ) {
if (clc.serverAddress.port == 0) {
clc.serverAddress.port = BigShort( PORT_SERVER );
}
- Com_sprintf( serverString, sizeof( serverString ), "%i.%i.%i.%i:%i",
- clc.serverAddress.ip[0], clc.serverAddress.ip[1],
- clc.serverAddress.ip[2], clc.serverAddress.ip[3],
- BigShort( clc.serverAddress.port ) );
-
- Com_Printf( "%s resolved to %s\n", cls.servername, serverString );
+
+ serverString = NET_AdrToStringwPort(clc.serverAddress);
+
+ Com_Printf( "%s resolved to %s\n", cls.servername, serverString);
if( cl_guidServerUniq->integer )
CL_UpdateGUID( serverString, strlen( serverString ) );
@@ -1260,7 +1272,7 @@ void CL_Rcon_f( void ) {
return;
}
- NET_StringToAdr (rconAddress->string, &to);
+ NET_StringToAdr (rconAddress->string, &to, NA_UNSPEC);
if (to.port == 0) {
to.port = BigShort (PORT_SERVER);
}
@@ -1697,8 +1709,8 @@ void CL_CheckForResend( void ) {
switch ( cls.state ) {
case CA_CONNECTING:
- // requesting a challenge
- if ( !Sys_IsLANAddress( clc.serverAddress ) ) {
+ // requesting a challenge .. IPv6 users always get in as authorize server supports no ipv6.
+ if ( clc.serverAddress.type == NA_IP && !Sys_IsLANAddress( clc.serverAddress ) ) {
CL_RequestAuthorization();
}
NET_OutOfBandPrint(NS_CLIENT, clc.serverAddress, "getchallenge");
@@ -1968,7 +1980,7 @@ void CL_ConnectionlessPacket( netadr_t from, msg_t *msg ) {
// challenge from the server we are connecting to
if ( !Q_stricmp(c, "challengeResponse") ) {
if ( cls.state != CA_CONNECTING ) {
- Com_Printf( "Unwanted challenge response received. Ignored.\n" );
+ Com_DPrintf( "Unwanted challenge response received. Ignored.\n" );
} else {
// start sending challenge repsonse instead of challenge request packets
clc.challenge = atoi(Cmd_Argv(1));
@@ -3059,7 +3071,7 @@ int CL_ServerStatus( char *serverAddress, char *serverStatusString, int maxLen )
return qfalse;
}
// get the address
- if ( !NET_StringToAdr( serverAddress, &to ) ) {
+ if ( !NET_StringToAdr( serverAddress, &to, NA_UNSPEC) ) {
return qfalse;
}
serverStatus = CL_GetServerStatus( to );
@@ -3262,7 +3274,7 @@ void CL_GlobalServers_f( void ) {
// reset the list, waiting for response
// -1 is used to distinguish a "no response"
- NET_StringToAdr( cl_master->string, &to );
+ NET_StringToAdr( cl_master->string, &to, NA_IP );
if( cls.masterNum == 1 ) {
cls.nummplayerservers = -1;
@@ -3465,17 +3477,33 @@ void CL_Ping_f( void ) {
netadr_t to;
ping_t* pingptr;
char* server;
+ int argc;
+ netadrtype_t family = NA_UNSPEC;
+
+ argc = Cmd_Argc();
- if ( Cmd_Argc() != 2 ) {
- Com_Printf( "usage: ping [server]\n");
+ if ( argc != 2 && argc != 3 ) {
+ Com_Printf( "usage: ping [-4|-6] server\n");
return;
}
+
+ if(argc == 2)
+ server = Cmd_Argv(1);
+ else
+ {
+ if(!strcmp(Cmd_Argv(1), "-4"))
+ family = NA_IP;
+ else if(!strcmp(Cmd_Argv(1), "-6"))
+ family = NA_IP6;
+ else
+ Com_Printf( "warning: only -4 or -6 as address type understood.\n");
+
+ server = Cmd_Argv(2);
+ }
Com_Memset( &to, 0, sizeof(netadr_t) );
- server = Cmd_Argv(1);
-
- if ( !NET_StringToAdr( server, &to ) ) {
+ if ( !NET_StringToAdr( server, &to, family ) ) {
return;
}
@@ -3603,32 +3631,53 @@ CL_ServerStatus_f
==================
*/
void CL_ServerStatus_f(void) {
- netadr_t to;
+ netadr_t to, *toptr = NULL;
char *server;
serverStatus_t *serverStatus;
+ int argc;
+ netadrtype_t family = NA_UNSPEC;
- Com_Memset( &to, 0, sizeof(netadr_t) );
+ argc = Cmd_Argc();
- if ( Cmd_Argc() != 2 ) {
- if ( cls.state != CA_ACTIVE || clc.demoplaying ) {
+ if ( argc != 2 && argc != 3 )
+ {
+ if (cls.state != CA_ACTIVE || clc.demoplaying)
+ {
Com_Printf ("Not connected to a server.\n");
- Com_Printf( "Usage: serverstatus [server]\n");
- return;
+ Com_Printf( "usage: serverstatus [-4|-6] server\n");
+ return;
}
- server = cls.servername;
- }
- else {
- server = Cmd_Argv(1);
+
+ toptr = &clc.serverAddress;
}
+
+ if(!toptr)
+ {
+ Com_Memset( &to, 0, sizeof(netadr_t) );
+
+ if(argc == 2)
+ server = Cmd_Argv(1);
+ else
+ {
+ if(!strcmp(Cmd_Argv(1), "-4"))
+ family = NA_IP;
+ else if(!strcmp(Cmd_Argv(1), "-6"))
+ family = NA_IP6;
+ else
+ Com_Printf( "warning: only -4 or -6 as address type understood.\n");
+
+ server = Cmd_Argv(2);
+ }
- if ( !NET_StringToAdr( server, &to ) ) {
- return;
+ toptr = &to;
+ if ( !NET_StringToAdr( server, toptr, family ) )
+ return;
}
- NET_OutOfBandPrint( NS_CLIENT, to, "getstatus" );
+ NET_OutOfBandPrint( NS_CLIENT, *toptr, "getstatus" );
- serverStatus = CL_GetServerStatus( to );
- serverStatus->address = to;
+ serverStatus = CL_GetServerStatus( *toptr );
+ serverStatus->address = *toptr;
serverStatus->print = qtrue;
serverStatus->pending = qtrue;
}
diff --git a/code/client/cl_ui.c b/code/client/cl_ui.c
index dc8d66e..e3022c5 100644
--- a/code/client/cl_ui.c
+++ b/code/client/cl_ui.c
@@ -156,7 +156,7 @@ static int LAN_AddServer(int source, const char *name, const char *address) {
break;
}
if (servers && *count < max) {
- NET_StringToAdr( address, &adr );
+ NET_StringToAdr( address, &adr, NA_IP );
for ( i = 0; i < *count; i++ ) {
if (NET_CompareAdr(servers[i].adr, adr)) {
break;
@@ -203,7 +203,7 @@ static void LAN_RemoveServer(int source, const char *addr) {
}
if (servers) {
netadr_t comp;
- NET_StringToAdr( addr, &comp );
+ NET_StringToAdr( addr, &comp, NA_IP );
for (i = 0; i < *count; i++) {
if (NET_CompareAdr( comp, servers[i].adr)) {
int j = i;