mirror of
https://github.com/openmoh/openmohaa.git
synced 2025-04-28 13:47:58 +03:00
Generate checksum with noncompat protocol
This commit is contained in:
parent
6e357459e6
commit
3c26b98b65
2 changed files with 32 additions and 8 deletions
|
@ -325,7 +325,12 @@ void Netchan_TransmitNextFragment( netchan_t *chan, netprofpacketlist_t *packetl
|
|||
// send the qport if we are a client
|
||||
if ( chan->sock == NS_CLIENT ) {
|
||||
MSG_WriteShort( &send, qport->integer );
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef LEGACY_PROTOCOL
|
||||
if (!chan->compat)
|
||||
#endif
|
||||
MSG_WriteLong(&send, NETCHAN_GENCHECKSUM(chan->challenge, chan->outgoingSequence));
|
||||
|
||||
// copy the reliable message to the packet first
|
||||
fragmentLength = FRAGMENT_SIZE;
|
||||
|
@ -402,12 +407,17 @@ void Netchan_Transmit( netchan_t *chan, size_t length, const byte *data, netprof
|
|||
MSG_InitOOB (&send, send_buf, chan->remoteAddress.type == NA_LOOPBACK ? MAX_PACKETLEN : MAX_REMOTE_PACKETLEN);
|
||||
|
||||
MSG_WriteLong( &send, chan->outgoingSequence );
|
||||
chan->outgoingSequence++;
|
||||
|
||||
// send the qport if we are a client
|
||||
if ( chan->sock == NS_CLIENT ) {
|
||||
MSG_WriteShort( &send, qport->integer );
|
||||
}
|
||||
if(chan->sock == NS_CLIENT)
|
||||
MSG_WriteShort(&send, qport->integer);
|
||||
|
||||
#ifdef LEGACY_PROTOCOL
|
||||
if(!chan->compat)
|
||||
#endif
|
||||
MSG_WriteLong(&send, NETCHAN_GENCHECKSUM(chan->challenge, chan->outgoingSequence));
|
||||
|
||||
chan->outgoingSequence++;
|
||||
|
||||
MSG_WriteData( &send, data, length );
|
||||
|
||||
|
@ -469,6 +479,17 @@ qboolean Netchan_Process( netchan_t *chan, msg_t *msg, netprofpacketlist_t *pack
|
|||
qport = MSG_ReadShort( msg );
|
||||
}
|
||||
|
||||
#ifdef LEGACY_PROTOCOL
|
||||
if(!chan->compat)
|
||||
#endif
|
||||
{
|
||||
int checksum = MSG_ReadLong(msg);
|
||||
|
||||
// UDP spoofing protection
|
||||
if(NETCHAN_GENCHECKSUM(chan->challenge, sequence) != checksum)
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
// read the fragment information
|
||||
if ( fragmented ) {
|
||||
fragmentStart = MSG_ReadLong( msg );
|
||||
|
|
|
@ -255,11 +255,14 @@ void NET_LeaveMulticast6(void);
|
|||
void NET_Sleep(int msec);
|
||||
|
||||
|
||||
#define MAX_MSGLEN 49152 // max length of a message, which may
|
||||
#define MAX_MSGLEN 49152 // max length of a message, which may
|
||||
// be fragmented into multiple packets
|
||||
|
||||
#define MAX_DOWNLOAD_WINDOW 8 // max of eight download frames
|
||||
#define MAX_DOWNLOAD_BLKSIZE 2048 // 2048 byte block chunks
|
||||
#define MAX_DOWNLOAD_WINDOW 48 // ACK window of 48 download chunks. Cannot set this higher, or clients
|
||||
// will overflow the reliable commands buffer
|
||||
#define MAX_DOWNLOAD_BLKSIZE 1024 // 896 byte block chunks
|
||||
|
||||
#define NETCHAN_GENCHECKSUM(challenge, sequence) ((challenge) ^ ((sequence) * (challenge)))
|
||||
|
||||
|
||||
/*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue