fixes for ping time measurement under Windows, implemented security checks for protocol

This commit is contained in:
Volker Fischer 2008-08-11 17:21:09 +00:00
parent 4d980a8a54
commit 55aaafd90f
6 changed files with 173 additions and 71 deletions

View file

@ -762,7 +762,7 @@ EPutDataStat CChannel::PutData ( const CVector<unsigned char>& vecbyData,
if ( IsConnected() ) if ( IsConnected() )
{ {
// parse the message assuming this is a protocol message // parse the message assuming this is a protocol message
if ( Protocol.ParseMessage ( vecbyData, iNumBytes ) ) if ( !Protocol.ParseMessage ( vecbyData, iNumBytes ) )
{ {
// set status flags // set status flags
eRet = PS_PROT_OK; eRet = PS_PROT_OK;

View file

@ -99,8 +99,13 @@ void CClient::OnNewConnection()
void CClient::OnReceivePingMessage ( int iMs ) void CClient::OnReceivePingMessage ( int iMs )
{ {
// calculate difference between received time in ms and current time in ms // calculate difference between received time in ms and current time in ms,
emit PingTimeReceived ( CPreciseTime().elapsed() - iMs ); // take care of wrap arounds (if wrapping, do not use result)
const int iCurDiff = PreciseTime.elapsed() - iMs;
if ( iCurDiff >= 0 )
{
emit PingTimeReceived ( iCurDiff );
}
} }
bool CClient::SetServerAddr ( QString strNAddr ) bool CClient::SetServerAddr ( QString strNAddr )

View file

@ -127,7 +127,7 @@ public:
{ Channel.CreateChatTextMes ( strChatText ); } { Channel.CreateChatTextMes ( strChatText ); }
void SendPingMess() void SendPingMess()
{ Channel.CreatePingMes ( CPreciseTime().elapsed() ); }; { Channel.CreatePingMes ( PreciseTime.elapsed() ); };
CSound* GetSndInterface() { return &Sound; } CSound* GetSndInterface() { return &Sound; }
CChannel* GetChannel() { return &Channel; } CChannel* GetChannel() { return &Channel; }
@ -178,6 +178,9 @@ protected:
CAudioResample ResampleObjUpL; // left channel CAudioResample ResampleObjUpL; // left channel
CAudioResample ResampleObjUpR; // right channel CAudioResample ResampleObjUpR; // right channel
// for ping measurement
CPreciseTime PreciseTime;
// debugging, evaluating // debugging, evaluating
CMovingAv<double> RespTimeMoAvBuf; CMovingAv<double> RespTimeMoAvBuf;
QTime TimeLastBlock; QTime TimeLastBlock;

View file

@ -98,13 +98,12 @@ MESSAGES
| 2 bytes number n | n bytes UTF-8 string | | 2 bytes number n | n bytes UTF-8 string |
+------------------+----------------------+ +------------------+----------------------+
- Ping message (for measuring the ping time) PROTMESSID_PING - Ping message (for measuring the ping time) PROTMESSID_PING_MS
+-----------------------------+ +-----------------------------+
| 4 bytes transmit time in ms | | 4 bytes transmit time in ms |
+-----------------------------+ +-----------------------------+
****************************************************************************** ******************************************************************************
* *
* This program is free software; you can redistribute it and/or modify it under * This program is free software; you can redistribute it and/or modify it under
@ -257,11 +256,11 @@ bool CProtocol::ParseMessage ( const CVector<unsigned char>& vecbyData,
const int iNumBytes ) const int iNumBytes )
{ {
/* /*
return code: true -> ok; false -> error return code: false -> ok; true -> error
*/ */
bool bRet, bSendNextMess; bool bRet = false;
bool bSendNextMess;
int iRecCounter, iRecID; int iRecCounter, iRecID;
unsigned int iPos;
CVector<uint8_t> vecData; CVector<uint8_t> vecData;
@ -273,7 +272,7 @@ for ( int i = 0; i < iNumBytes; i++ ) {
// important: vecbyDataConv must have iNumBytes to get it work!!! // important: vecbyDataConv must have iNumBytes to get it work!!!
if ( ParseMessageFrame ( vecbyDataConv, iRecCounter, iRecID, vecData ) ) if ( !ParseMessageFrame ( vecbyDataConv, iRecCounter, iRecID, vecData ) )
{ {
// In case we received a message and returned an answer but our answer // In case we received a message and returned an answer but our answer
// did not make it to the receiver, he will resend his message. We check // did not make it to the receiver, he will resend his message. We check
@ -294,7 +293,7 @@ for ( int i = 0; i < iNumBytes; i++ ) {
if ( iRecID == PROTMESSID_ACKN ) if ( iRecID == PROTMESSID_ACKN )
{ {
// extract data from stream and emit signal for received value // extract data from stream and emit signal for received value
iPos = 0; unsigned int iPos = 0;
const int iData = const int iData =
static_cast<int> ( GetValFromStream ( vecData, iPos, 2 ) ); static_cast<int> ( GetValFromStream ( vecData, iPos, 2 ) );
@ -324,61 +323,57 @@ for ( int i = 0; i < iNumBytes; i++ ) {
} }
else else
{ {
// init position pointer which is used for extracting data from
// received data vector
iPos = 0;
// check which type of message we received and do action // check which type of message we received and do action
switch ( iRecID ) switch ( iRecID )
{ {
case PROTMESSID_JITT_BUF_SIZE: case PROTMESSID_JITT_BUF_SIZE:
EvaluateJitBufMes ( iPos, vecData ); bRet = EvaluateJitBufMes ( vecData );
break; break;
case PROTMESSID_REQ_JITT_BUF_SIZE: case PROTMESSID_REQ_JITT_BUF_SIZE:
EvaluateReqJitBufMes ( iPos, vecData ); bRet = EvaluateReqJitBufMes ( vecData );
break; break;
case PROTMESSID_SERVER_FULL: case PROTMESSID_SERVER_FULL:
EvaluateServerFullMes ( iPos, vecData ); bRet = EvaluateServerFullMes ( vecData );
break; break;
case PROTMESSID_NET_BLSI_FACTOR: case PROTMESSID_NET_BLSI_FACTOR:
EvaluateNetwBlSiFactMes ( iPos, vecData ); bRet = EvaluateNetwBlSiFactMes ( vecData );
break; break;
case PROTMESSID_CHANNEL_GAIN: case PROTMESSID_CHANNEL_GAIN:
EvaluateChanGainMes ( iPos, vecData ); bRet = EvaluateChanGainMes ( vecData );
break; break;
case PROTMESSID_CONN_CLIENTS_LIST: case PROTMESSID_CONN_CLIENTS_LIST:
EvaluateConClientListMes ( iPos, vecData ); bRet = EvaluateConClientListMes ( vecData );
break; break;
case PROTMESSID_REQ_CONN_CLIENTS_LIST: case PROTMESSID_REQ_CONN_CLIENTS_LIST:
EvaluateReqConnClientsList ( iPos, vecData ); bRet = EvaluateReqConnClientsList ( vecData );
break; break;
case PROTMESSID_CHANNEL_NAME: case PROTMESSID_CHANNEL_NAME:
EvaluateChanNameMes ( iPos, vecData ); bRet = EvaluateChanNameMes ( vecData );
break; break;
case PROTMESSID_CHAT_TEXT: case PROTMESSID_CHAT_TEXT:
EvaluateChatTextMes ( iPos, vecData ); bRet = EvaluateChatTextMes ( vecData );
break; break;
case PROTMESSID_PING: case PROTMESSID_PING_MS:
EvaluatePingMes ( iPos, vecData ); bRet = EvaluatePingMes ( vecData );
break; break;
} }
@ -390,19 +385,17 @@ for ( int i = 0; i < iNumBytes; i++ ) {
// save current message ID and counter to find out if message was re-sent // save current message ID and counter to find out if message was re-sent
iOldRecID = iRecID; iOldRecID = iRecID;
iOldRecCnt = iRecCounter; iOldRecCnt = iRecCounter;
bRet = true; // everything was ok
} }
else else
{ {
bRet = false; // return error code bRet = true; // return error code
} }
return bRet; return bRet;
} }
/* Access-functions for creating and parsing messages ----------------------- */ // Access-functions for creating and parsing messages --------------------------
void CProtocol::CreateJitBufMes ( const int iJitBufSize ) void CProtocol::CreateJitBufMes ( const int iJitBufSize )
{ {
CVector<uint8_t> vecData ( 2 ); // 2 bytes of data CVector<uint8_t> vecData ( 2 ); // 2 bytes of data
@ -414,14 +407,24 @@ void CProtocol::CreateJitBufMes ( const int iJitBufSize )
CreateAndSendMessage ( PROTMESSID_JITT_BUF_SIZE, vecData ); CreateAndSendMessage ( PROTMESSID_JITT_BUF_SIZE, vecData );
} }
void CProtocol::EvaluateJitBufMes ( unsigned int iPos, const CVector<uint8_t>& vecData ) bool CProtocol::EvaluateJitBufMes ( const CVector<uint8_t>& vecData )
{ {
unsigned int iPos = 0; // init position pointer
// check size
if ( vecData.Size() != 2 )
{
return true;
}
// extract jitter buffer size // extract jitter buffer size
const int iData = const int iData =
static_cast<int> ( GetValFromStream ( vecData, iPos, 2 ) ); static_cast<int> ( GetValFromStream ( vecData, iPos, 2 ) );
// invoke message action // invoke message action
emit ChangeJittBufSize ( iData ); emit ChangeJittBufSize ( iData );
return false; // no error
} }
void CProtocol::CreateReqJitBufMes() void CProtocol::CreateReqJitBufMes()
@ -429,10 +432,12 @@ void CProtocol::CreateReqJitBufMes()
CreateAndSendMessage ( PROTMESSID_REQ_JITT_BUF_SIZE, CVector<uint8_t> ( 0 ) ); CreateAndSendMessage ( PROTMESSID_REQ_JITT_BUF_SIZE, CVector<uint8_t> ( 0 ) );
} }
void CProtocol::EvaluateReqJitBufMes ( unsigned int iPos, const CVector<uint8_t>& vecData ) bool CProtocol::EvaluateReqJitBufMes ( const CVector<uint8_t>& vecData )
{ {
// invoke message action // invoke message action
emit ReqJittBufSize(); emit ReqJittBufSize();
return false; // no error
} }
void CProtocol::CreateServerFullMes() void CProtocol::CreateServerFullMes()
@ -440,10 +445,12 @@ void CProtocol::CreateServerFullMes()
CreateAndSendMessage ( PROTMESSID_SERVER_FULL, CVector<uint8_t> ( 0 ) ); CreateAndSendMessage ( PROTMESSID_SERVER_FULL, CVector<uint8_t> ( 0 ) );
} }
void CProtocol::EvaluateServerFullMes ( unsigned int iPos, const CVector<uint8_t>& vecData ) bool CProtocol::EvaluateServerFullMes ( const CVector<uint8_t>& vecData )
{ {
// invoke message action // invoke message action
emit ServerFull(); emit ServerFull();
return false; // no error
} }
void CProtocol::CreateNetwBlSiFactMes ( const int iNetwBlSiFact ) void CProtocol::CreateNetwBlSiFactMes ( const int iNetwBlSiFact )
@ -457,13 +464,23 @@ void CProtocol::CreateNetwBlSiFactMes ( const int iNetwBlSiFact )
CreateAndSendMessage ( PROTMESSID_NET_BLSI_FACTOR, vecData ); CreateAndSendMessage ( PROTMESSID_NET_BLSI_FACTOR, vecData );
} }
void CProtocol::EvaluateNetwBlSiFactMes ( unsigned int iPos, const CVector<uint8_t>& vecData ) bool CProtocol::EvaluateNetwBlSiFactMes ( const CVector<uint8_t>& vecData )
{ {
unsigned int iPos = 0; // init position pointer
// check size
if ( vecData.Size() != 2 )
{
return true;
}
const int iData = const int iData =
static_cast<int> ( GetValFromStream ( vecData, iPos, 2 ) ); static_cast<int> ( GetValFromStream ( vecData, iPos, 2 ) );
// invoke message action // invoke message action
emit ChangeNetwBlSiFact ( iData ); emit ChangeNetwBlSiFact ( iData );
return false; // no error
} }
void CProtocol::CreateChanGainMes ( const int iChanID, const double dGain ) void CProtocol::CreateChanGainMes ( const int iChanID, const double dGain )
@ -482,8 +499,16 @@ void CProtocol::CreateChanGainMes ( const int iChanID, const double dGain )
CreateAndSendMessage ( PROTMESSID_CHANNEL_GAIN, vecData ); CreateAndSendMessage ( PROTMESSID_CHANNEL_GAIN, vecData );
} }
void CProtocol::EvaluateChanGainMes ( unsigned int iPos, const CVector<uint8_t>& vecData ) bool CProtocol::EvaluateChanGainMes ( const CVector<uint8_t>& vecData )
{ {
unsigned int iPos = 0; // init position pointer
// check size
if ( vecData.Size() != 3 )
{
return true;
}
// channel ID // channel ID
const int iCurID = const int iCurID =
static_cast<int> ( GetValFromStream ( vecData, iPos, 1 ) ); static_cast<int> ( GetValFromStream ( vecData, iPos, 1 ) );
@ -496,6 +521,8 @@ void CProtocol::EvaluateChanGainMes ( unsigned int iPos, const CVector<uint8_t>&
// invoke message action // invoke message action
emit ChangeChanGain ( iCurID, dNewGain ); emit ChangeChanGain ( iCurID, dNewGain );
return false; // no error
} }
void CProtocol::CreateConClientListMes ( const CVector<CChannelShortInfo>& vecChanInfo ) void CProtocol::CreateConClientListMes ( const CVector<CChannelShortInfo>& vecChanInfo )
@ -542,14 +569,21 @@ void CProtocol::CreateConClientListMes ( const CVector<CChannelShortInfo>& vecCh
CreateAndSendMessage ( PROTMESSID_CONN_CLIENTS_LIST, vecData ); CreateAndSendMessage ( PROTMESSID_CONN_CLIENTS_LIST, vecData );
} }
void CProtocol::EvaluateConClientListMes ( unsigned int iPos, const CVector<uint8_t>& vecData ) bool CProtocol::EvaluateConClientListMes ( const CVector<uint8_t>& vecData )
{ {
unsigned int iPos = 0; // init position pointer
int iData; int iData;
const unsigned int iDataLen = vecData.Size(); const unsigned int iDataLen = vecData.Size();
CVector<CChannelShortInfo> vecChanInfo ( 0 ); CVector<CChannelShortInfo> vecChanInfo ( 0 );
while ( iPos < iDataLen ) while ( iPos < iDataLen )
{ {
// check size (the first 7 bytes)
if ( iDataLen - iPos < 7 )
{
return true;
}
// channel ID (1 byte) // channel ID (1 byte)
const int iChanID = static_cast<int> ( GetValFromStream ( vecData, iPos, 1 ) ); const int iChanID = static_cast<int> ( GetValFromStream ( vecData, iPos, 1 ) );
@ -557,12 +591,18 @@ void CProtocol::EvaluateConClientListMes ( unsigned int iPos, const CVector<uint
const int iIpAddr = static_cast<int> ( GetValFromStream ( vecData, iPos, 4 ) ); const int iIpAddr = static_cast<int> ( GetValFromStream ( vecData, iPos, 4 ) );
// number of bytes for name string (2 bytes) // number of bytes for name string (2 bytes)
const int iStringLen = const unsigned int iStringLen =
static_cast<int> ( GetValFromStream ( vecData, iPos, 2 ) ); static_cast<unsigned int> ( GetValFromStream ( vecData, iPos, 2 ) );
// check size
if ( iDataLen - iPos < iStringLen )
{
return true;
}
// name string (n bytes) // name string (n bytes)
QString strCurStr = ""; QString strCurStr = "";
for ( int j = 0; j < iStringLen; j++ ) for ( unsigned int j = 0; j < iStringLen; j++ )
{ {
// byte-by-byte copying of the string data // byte-by-byte copying of the string data
iData = static_cast<int> ( GetValFromStream ( vecData, iPos, 1 ) ); iData = static_cast<int> ( GetValFromStream ( vecData, iPos, 1 ) );
@ -575,6 +615,8 @@ void CProtocol::EvaluateConClientListMes ( unsigned int iPos, const CVector<uint
// invoke message action // invoke message action
emit ConClientListMesReceived ( vecChanInfo ); emit ConClientListMesReceived ( vecChanInfo );
return false; // no error
} }
void CProtocol::CreateReqConnClientsList() void CProtocol::CreateReqConnClientsList()
@ -582,10 +624,12 @@ void CProtocol::CreateReqConnClientsList()
CreateAndSendMessage ( PROTMESSID_REQ_CONN_CLIENTS_LIST, CVector<uint8_t> ( 0 ) ); CreateAndSendMessage ( PROTMESSID_REQ_CONN_CLIENTS_LIST, CVector<uint8_t> ( 0 ) );
} }
void CProtocol::EvaluateReqConnClientsList ( unsigned int iPos, const CVector<uint8_t>& vecData ) bool CProtocol::EvaluateReqConnClientsList ( const CVector<uint8_t>& vecData )
{ {
// invoke message action // invoke message action
emit ReqConnClientsList(); emit ReqConnClientsList();
return false; // no error
} }
void CProtocol::CreateChanNameMes ( const QString strName ) void CProtocol::CreateChanNameMes ( const QString strName )
@ -594,7 +638,7 @@ void CProtocol::CreateChanNameMes ( const QString strName )
const int iStrLen = strName.size(); // get string size const int iStrLen = strName.size(); // get string size
// size of current list entry // size of current list entry
const int iEntrLen = 2 /* str. size */ + iStrLen; const int iEntrLen = 2 /* string size */ + iStrLen;
// build data vector // build data vector
CVector<uint8_t> vecData ( iEntrLen ); CVector<uint8_t> vecData ( iEntrLen );
@ -613,12 +657,26 @@ void CProtocol::CreateChanNameMes ( const QString strName )
CreateAndSendMessage ( PROTMESSID_CHANNEL_NAME, vecData ); CreateAndSendMessage ( PROTMESSID_CHANNEL_NAME, vecData );
} }
void CProtocol::EvaluateChanNameMes ( unsigned int iPos, const CVector<uint8_t>& vecData ) bool CProtocol::EvaluateChanNameMes ( const CVector<uint8_t>& vecData )
{ {
unsigned int iPos = 0; // init position pointer
// check size (the first 2 bytes)
if ( vecData.Size() < 2 )
{
return true;
}
// number of bytes for name string (2 bytes) // number of bytes for name string (2 bytes)
const int iStrLen = const int iStrLen =
static_cast<int> ( GetValFromStream ( vecData, iPos, 2 ) ); static_cast<int> ( GetValFromStream ( vecData, iPos, 2 ) );
// check size
if ( vecData.Size() - 2 != iStrLen )
{
return true;
}
// name string (n bytes) // name string (n bytes)
QString strName = ""; QString strName = "";
for ( int j = 0; j < iStrLen; j++ ) for ( int j = 0; j < iStrLen; j++ )
@ -630,6 +688,8 @@ void CProtocol::EvaluateChanNameMes ( unsigned int iPos, const CVector<uint8_t>&
// invoke message action // invoke message action
emit ChangeChanName ( strName ); emit ChangeChanName ( strName );
return false; // no error
} }
void CProtocol::CreateChatTextMes ( const QString strChatText ) void CProtocol::CreateChatTextMes ( const QString strChatText )
@ -638,7 +698,7 @@ void CProtocol::CreateChatTextMes ( const QString strChatText )
const int iStrLen = strChatText.size(); // get string size const int iStrLen = strChatText.size(); // get string size
// size of current list entry // size of current list entry
const int iEntrLen = 2 /* str. size */ + iStrLen; const int iEntrLen = 2 /* string size */ + iStrLen;
// build data vector // build data vector
CVector<uint8_t> vecData ( iEntrLen ); CVector<uint8_t> vecData ( iEntrLen );
@ -657,12 +717,26 @@ void CProtocol::CreateChatTextMes ( const QString strChatText )
CreateAndSendMessage ( PROTMESSID_CHAT_TEXT, vecData ); CreateAndSendMessage ( PROTMESSID_CHAT_TEXT, vecData );
} }
void CProtocol::EvaluateChatTextMes ( unsigned int iPos, const CVector<uint8_t>& vecData ) bool CProtocol::EvaluateChatTextMes ( const CVector<uint8_t>& vecData )
{ {
unsigned int iPos = 0; // init position pointer
// check size (the first 2 bytes)
if ( vecData.Size() < 2 )
{
return true;
}
// number of bytes for name string (2 bytes) // number of bytes for name string (2 bytes)
const int iStrLen = const int iStrLen =
static_cast<int> ( GetValFromStream ( vecData, iPos, 2 ) ); static_cast<int> ( GetValFromStream ( vecData, iPos, 2 ) );
// check size
if ( vecData.Size() - 2 != iStrLen )
{
return true;
}
// name string (n bytes) // name string (n bytes)
QString strChatText = ""; QString strChatText = "";
for ( int j = 0; j < iStrLen; j++ ) for ( int j = 0; j < iStrLen; j++ )
@ -674,6 +748,8 @@ void CProtocol::EvaluateChatTextMes ( unsigned int iPos, const CVector<uint8_t>&
// invoke message action // invoke message action
emit ChatTextReceived ( strChatText ); emit ChatTextReceived ( strChatText );
return false; // no error
} }
void CProtocol::CreatePingMes ( const int iMs ) void CProtocol::CreatePingMes ( const int iMs )
@ -686,12 +762,22 @@ void CProtocol::CreatePingMes ( const int iMs )
// byte-by-byte copying of the string data // byte-by-byte copying of the string data
PutValOnStream ( vecData, iPos, static_cast<uint32_t> ( iMs ), 4 ); PutValOnStream ( vecData, iPos, static_cast<uint32_t> ( iMs ), 4 );
CreateAndSendMessage ( PROTMESSID_PING, vecData ); CreateAndSendMessage ( PROTMESSID_PING_MS, vecData );
} }
void CProtocol::EvaluatePingMes ( unsigned int iPos, const CVector<uint8_t>& vecData ) bool CProtocol::EvaluatePingMes ( const CVector<uint8_t>& vecData )
{ {
unsigned int iPos = 0; // init position pointer
// check size
if ( vecData.Size() != 4 )
{
return true;
}
emit PingReceived ( static_cast<int> ( GetValFromStream ( vecData, iPos, 4 ) ) ); emit PingReceived ( static_cast<int> ( GetValFromStream ( vecData, iPos, 4 ) ) );
return false; // no error
} }
@ -716,7 +802,7 @@ bool CProtocol::ParseMessageFrame ( const CVector<uint8_t>& vecIn,
// vector must be at least "MESS_LEN_WITHOUT_DATA_BYTE" bytes long // vector must be at least "MESS_LEN_WITHOUT_DATA_BYTE" bytes long
if ( iVecInLenByte < MESS_LEN_WITHOUT_DATA_BYTE ) if ( iVecInLenByte < MESS_LEN_WITHOUT_DATA_BYTE )
{ {
return false; // return error code return true; // return error code
} }
@ -729,7 +815,7 @@ bool CProtocol::ParseMessageFrame ( const CVector<uint8_t>& vecIn,
// check if tag is correct // check if tag is correct
if ( iTag != 0 ) if ( iTag != 0 )
{ {
return false; // return error code return true; // return error code
} }
/* 2 bytes ID */ /* 2 bytes ID */
@ -744,7 +830,7 @@ bool CProtocol::ParseMessageFrame ( const CVector<uint8_t>& vecIn,
// make sure the length is correct // make sure the length is correct
if ( iLenBy != iVecInLenByte - MESS_LEN_WITHOUT_DATA_BYTE ) if ( iLenBy != iVecInLenByte - MESS_LEN_WITHOUT_DATA_BYTE )
{ {
return false; // return error code return true; // return error code
} }
@ -761,11 +847,11 @@ bool CProtocol::ParseMessageFrame ( const CVector<uint8_t>& vecIn,
if ( CRCObj.GetCRC () != GetValFromStream ( vecIn, iCurPos, 2 ) ) if ( CRCObj.GetCRC () != GetValFromStream ( vecIn, iCurPos, 2 ) )
{ {
return false; // return error code return true; // return error code
} }
// decode data ----- // extract actual data -----
vecData.Init ( iLenBy ); vecData.Init ( iLenBy );
iCurPos = MESS_HEADER_LENGTH_BYTE; // start from beginning of data iCurPos = MESS_HEADER_LENGTH_BYTE; // start from beginning of data
for ( i = 0; i < iLenBy; i++ ) for ( i = 0; i < iLenBy; i++ )
@ -774,7 +860,7 @@ bool CProtocol::ParseMessageFrame ( const CVector<uint8_t>& vecIn,
GetValFromStream ( vecIn, iCurPos, 1 ) ); GetValFromStream ( vecIn, iCurPos, 1 ) );
} }
return true; // everything was ok return false; // everything was ok
} }
uint32_t CProtocol::GetValFromStream ( const CVector<uint8_t>& vecIn, uint32_t CProtocol::GetValFromStream ( const CVector<uint8_t>& vecIn,

View file

@ -40,7 +40,7 @@
#define PROTMESSID_ACKN 1 // acknowledge #define PROTMESSID_ACKN 1 // acknowledge
#define PROTMESSID_JITT_BUF_SIZE 10 // jitter buffer size #define PROTMESSID_JITT_BUF_SIZE 10 // jitter buffer size
#define PROTMESSID_REQ_JITT_BUF_SIZE 11 // request jitter buffer size #define PROTMESSID_REQ_JITT_BUF_SIZE 11 // request jitter buffer size
#define PROTMESSID_PING 12 // for measuring ping time #define PROTMESSID_PING 12 // OLD, not used anymore
#define PROTMESSID_NET_BLSI_FACTOR 13 // network buffer size factor #define PROTMESSID_NET_BLSI_FACTOR 13 // network buffer size factor
#define PROTMESSID_CHANNEL_GAIN 14 // set channel gain for mix #define PROTMESSID_CHANNEL_GAIN 14 // set channel gain for mix
#define PROTMESSID_CONN_CLIENTS_LIST 15 // connected client list #define PROTMESSID_CONN_CLIENTS_LIST 15 // connected client list
@ -48,6 +48,7 @@
#define PROTMESSID_REQ_CONN_CLIENTS_LIST 17 // request connected client list #define PROTMESSID_REQ_CONN_CLIENTS_LIST 17 // request connected client list
#define PROTMESSID_CHANNEL_NAME 18 // set channel name for fader tag #define PROTMESSID_CHANNEL_NAME 18 // set channel name for fader tag
#define PROTMESSID_CHAT_TEXT 19 // contains a chat text #define PROTMESSID_CHAT_TEXT 19 // contains a chat text
#define PROTMESSID_PING_MS 20 // for measuring ping time
// lengths of message as defined in protocol.cpp file // lengths of message as defined in protocol.cpp file
#define MESS_HEADER_LENGTH_BYTE 7 // TAG (2), ID (2), cnt (1), length (2) #define MESS_HEADER_LENGTH_BYTE 7 // TAG (2), ID (2), cnt (1), length (2)
@ -135,16 +136,16 @@ protected:
void CreateAndSendMessage ( const int iID, const CVector<uint8_t>& vecData ); void CreateAndSendMessage ( const int iID, const CVector<uint8_t>& vecData );
void EvaluateJitBufMes ( unsigned int iPos, const CVector<uint8_t>& vecData ); bool EvaluateJitBufMes ( const CVector<uint8_t>& vecData );
void EvaluateReqJitBufMes ( unsigned int iPos, const CVector<uint8_t>& vecData ); bool EvaluateReqJitBufMes ( const CVector<uint8_t>& vecData );
void EvaluateReqConnClientsList ( unsigned int iPos, const CVector<uint8_t>& vecData ); bool EvaluateReqConnClientsList ( const CVector<uint8_t>& vecData );
void EvaluateServerFullMes ( unsigned int iPos, const CVector<uint8_t>& vecData ); bool EvaluateServerFullMes ( const CVector<uint8_t>& vecData );
void EvaluateNetwBlSiFactMes ( unsigned int iPos, const CVector<uint8_t>& vecData ); bool EvaluateNetwBlSiFactMes ( const CVector<uint8_t>& vecData );
void EvaluateChanGainMes ( unsigned int iPos, const CVector<uint8_t>& vecData ); bool EvaluateChanGainMes ( const CVector<uint8_t>& vecData );
void EvaluateChanNameMes ( unsigned int iPos, const CVector<uint8_t>& vecData ); bool EvaluateChanNameMes ( const CVector<uint8_t>& vecData );
void EvaluateChatTextMes ( unsigned int iPos, const CVector<uint8_t>& vecData ); bool EvaluateChatTextMes ( const CVector<uint8_t>& vecData );
void EvaluateConClientListMes ( unsigned int iPos, const CVector<uint8_t>& vecData ); bool EvaluateConClientListMes ( const CVector<uint8_t>& vecData );
void EvaluatePingMes ( unsigned int iPos, const CVector<uint8_t>& vecData ); bool EvaluatePingMes ( const CVector<uint8_t>& vecData );
int iOldRecID, iOldRecCnt; int iOldRecID, iOldRecCnt;

View file

@ -438,8 +438,15 @@ protected:
class CPreciseTime class CPreciseTime
{ {
public: public:
#ifdef _WIN32
// for the Windows version we have to define a minimum timer precision
// -> set it to 1 ms
CPreciseTime() { timeBeginPeriod(1); }
virtual ~CPreciseTime() { timeEndPeriod(1); }
#endif
// precise time (on Windows the QTime is not precise enough) // precise time (on Windows the QTime is not precise enough)
static int elapsed() int elapsed()
{ {
#ifdef _WIN32 #ifdef _WIN32
return timeGetTime(); return timeGetTime();