-
Notifications
You must be signed in to change notification settings - Fork 2
SRP
SRP (likely Segment Relay Protocol) is a simple reliable protocol used for communication with Ubi services (e.g. GSNAT).
The packets are called segments and are sent over UDP.
struct stSRPSegmentHeader {
unsigned short checksum;
unsigned short signature;
unsigned short dataSize;
unsigned short flags;
short segment;
unsigned short ack;
};
unsigned int __thiscall clSegment::CalculateCheckSum(clSegment *this, __int16 startValue)
{
int len; // edx
unsigned int checkBase; // eax
int halfLen; // edx
bool bEvenLen; // zf
int buffPtr; // ecx
len = this->length;
*this->buff = startValue;
checkBase = 0;
halfLen = len >> 1;
bEvenLen = this->length % 2 == 0;
buffPtr = this->buffPtr;
if ( !bEvenLen ) // if odd, add the first byte as extra
checkBase = *buffPtr++;
if ( halfLen > 0 )
{
do
{
checkBase += *buffPtr;
buffPtr += 2;
--halfLen;
}
while ( halfLen );
}
return ~(checkBase + (checkBase >> 16) + ((checkBase + (checkBase >> 16)) >> 16));
}
The value is sent as the 2nd u16 of the SYN response's data and resent in later requests without changes.
Length of the data to read after header, in bytes.
6 least significant bits are reserved for packet type, the rest is protocol identifier which should be set to 1 (0x40) for SRP.
Flag | Value |
---|---|
FIN | 1 |
SYN | 2 |
ACK | 4 |
URG | 8 |
unknown | 16 |
unknown | 32 |
Protocol ID (SRP) | 64 |
Incremental segment identifier.
Segment identifier of the acknowledged segment.
struct stSRPWindow {
unsigned short tail;
unsigned short senderSig;
unsigned short checksumInitValue;
unsigned short windowBufSize;
};
The receiving window's size in bytes.
The sender's signature to be used by receiver.
The value used as startValue
in checksum calculation algorithm for the response.
Buffer size for the response without header (max 4kB).
SYN
with window data:
d3 7e 00 00 08 00 42 30 00 00 08 34 0a 00 01 00 b7 1a 18 02
FIN
+ URG
:
44 6a 00 00 00 00 49 30 ff ff 72 65