From b392b0d97f3ea048478059873ed6dec8afd9634b Mon Sep 17 00:00:00 2001 From: /dev/humancontroller Date: Sun, 8 Feb 2015 13:55:15 +0100 Subject: implement part 1 of the multi-protocol functionality: protocols this contains support for connecting via, and serving simultaneously via, any of the three protocols: latest, GPP and 1.1 alternate-1 means protocol 70 (GPP), alternate-2 means protocol 69 (1.1) relevant cvars: - net_alternateProtocols - net_alt{1|2}port[6] - sv_alt{1|2}master{1|...|5} - sv_clAltProto{0|..|63} --- src/qcommon/net_chan.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'src/qcommon/net_chan.c') diff --git a/src/qcommon/net_chan.c b/src/qcommon/net_chan.c index 58a45b50..422f64fc 100644 --- a/src/qcommon/net_chan.c +++ b/src/qcommon/net_chan.c @@ -84,7 +84,7 @@ Netchan_Setup called to open a channel to a remote system ============== */ -void Netchan_Setup(netsrc_t sock, netchan_t *chan, netadr_t adr, int qport, int challenge) +void Netchan_Setup(int alternateProtocol, netsrc_t sock, netchan_t *chan, netadr_t adr, int qport, int challenge) { Com_Memset (chan, 0, sizeof(*chan)); @@ -94,6 +94,7 @@ void Netchan_Setup(netsrc_t sock, netchan_t *chan, netadr_t adr, int qport, int chan->incomingSequence = 0; chan->outgoingSequence = 1; chan->challenge = challenge; + chan->alternateProtocol = alternateProtocol; } /* @@ -120,7 +121,8 @@ void Netchan_TransmitNextFragment( netchan_t *chan ) { MSG_WriteShort( &send, qport->integer ); } - MSG_WriteLong(&send, NETCHAN_GENCHECKSUM(chan->challenge, chan->outgoingSequence)); + if ( chan->alternateProtocol == 0 ) + MSG_WriteLong(&send, NETCHAN_GENCHECKSUM(chan->challenge, chan->outgoingSequence)); // copy the reliable message to the packet first fragmentLength = FRAGMENT_SIZE; @@ -198,7 +200,8 @@ void Netchan_Transmit( netchan_t *chan, int length, const byte *data ) { if(chan->sock == NS_CLIENT) MSG_WriteShort(&send, qport->integer); - MSG_WriteLong(&send, NETCHAN_GENCHECKSUM(chan->challenge, chan->outgoingSequence)); + if ( chan->alternateProtocol == 0 ) + MSG_WriteLong(&send, NETCHAN_GENCHECKSUM(chan->challenge, chan->outgoingSequence)); chan->outgoingSequence++; @@ -258,11 +261,14 @@ qboolean Netchan_Process( netchan_t *chan, msg_t *msg ) { MSG_ReadShort( msg ); } - checksum = MSG_ReadLong(msg); + if ( chan->alternateProtocol == 0 ) + { + checksum = MSG_ReadLong(msg); - // UDP spoofing protection - if(NETCHAN_GENCHECKSUM(chan->challenge, sequence) != checksum) - return qfalse; + // UDP spoofing protection + if(NETCHAN_GENCHECKSUM(chan->challenge, sequence) != checksum) + return qfalse; + } // read the fragment information if ( fragmented ) { @@ -656,6 +662,8 @@ int NET_StringToAdr( const char *s, netadr_t *a, netadrtype_t family ) search = base; } + a->alternateProtocol = 0; + if(!Sys_StringToAdr(search, a, family)) { a->type = NA_BAD; -- cgit