Added CRC field to statistics class.
This commit is contained in:
parent
a6a6e296bc
commit
b8a5196a89
2 changed files with 23 additions and 1 deletions
|
@ -39,6 +39,11 @@ namespace IPC {
|
|||
val = ((long)p[0] << 24) | ((long)p[1] << 16) | ((long)p[2] << 8) | p[3];
|
||||
}
|
||||
|
||||
/// Reads a long value of p in host order to val.
|
||||
static void btohl(char * p, unsigned int & val) {
|
||||
val = ((long)p[0] << 24) | ((long)p[1] << 16) | ((long)p[2] << 8) | p[3];
|
||||
}
|
||||
|
||||
/// Reads a long long value of p in host order to val.
|
||||
static void btohll(char * p, long long & val) {
|
||||
val = ((long long)p[0] << 56) | ((long long)p[1] << 48) | ((long long)p[2] << 40) | ((long long)p[3] << 32) | ((long long)p[4] << 24) | ((long long)p[5] << 16) | ((long long)p[6] << 8) | p[7];
|
||||
|
@ -577,6 +582,18 @@ namespace IPC {
|
|||
return std::string(data + 68, std::min((int)strlen(data + 68), 20));
|
||||
}
|
||||
|
||||
///\brief Sets checksum field
|
||||
void statExchange::crc(unsigned int sum) {
|
||||
htobl(data + 88, sum);
|
||||
}
|
||||
|
||||
///\brief Gets checksum field
|
||||
unsigned int statExchange::crc() {
|
||||
unsigned int result;
|
||||
btohl(data + 88, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
///\brief Creates a semaphore guard, locks the semaphore on call
|
||||
semGuard::semGuard(semaphore * thisSemaphore) : mySemaphore(thisSemaphore) {
|
||||
mySemaphore->wait();
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
#include <semaphore.h>
|
||||
#endif
|
||||
|
||||
#define STAT_EX_SIZE 92
|
||||
|
||||
namespace IPC {
|
||||
|
||||
///\brief A class used for the exchange of statistics over shared memory.
|
||||
|
@ -32,7 +34,9 @@ namespace IPC {
|
|||
std::string streamName();
|
||||
void connector(std::string name);
|
||||
std::string connector();
|
||||
private:
|
||||
void crc(unsigned int sum);
|
||||
unsigned int crc();
|
||||
private:
|
||||
///\brief The payload for the stat exchange
|
||||
/// - 8 byte - now (timestamp of last statistics)
|
||||
/// - 4 byte - time (duration of the current connection)
|
||||
|
@ -42,6 +46,7 @@ namespace IPC {
|
|||
/// - 16 byte - host (ip address of the peer)
|
||||
/// - 20 byte - streamName (name of the stream peer is viewing)
|
||||
/// - 20 byte - connector (name of the connector the peer is using)
|
||||
/// - 4 byte - CRC32 of user agent (or zero if none)
|
||||
char * data;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue