4
Fork 0

Updated version with bug fixes

This commit is contained in:
R3ABM Artem 2016-07-22 20:26:03 +03:00
parent ff08ac4b2c
commit 9094b61931
2 changed files with 27 additions and 7 deletions

View file

@ -128,7 +128,7 @@ int main(int argc, const char* argv[])
// Parameters for server
const char* serverPort = STRING(REWIND_DEFAULT_PORT);
const char* serverPort = "54004";
const char* serverLocation = NULL;
const char* serverPassword = NULL;
struct addrinfo* serverAddress = NULL;
@ -552,8 +552,8 @@ int main(int argc, const char* argv[])
memcpy(incomingBuffer->data + length, serverPassword, passwordLength);
SHA256(incomingBuffer->data, length + passwordLength, outgoingBuffer->data);
outgoingBuffer->type = htole16(REWIND_TYPE_AUTHENTICATION);
outgoingBuffer->flags = htole16(REWIND_FLAG_DEFAULT_SET);
outgoingBuffer->number = htole32(++ sequenceNumbers[0]);
outgoingBuffer->length = htole16(SHA256_DIGEST_LENGTH);
@ -659,8 +659,9 @@ int main(int argc, const char* argv[])
data->port = proxySocketAddress.sin_port;
outgoingBuffer->type = htole16(REWIND_TYPE_ADDRESS_NOTICE);
outgoingBuffer->flags = htole16(REWIND_FLAG_DEFAULT_SET);
outgoingBuffer->number = htole32(++ sequenceNumbers[0]);
outgoingBuffer->length = htobe16(length);
outgoingBuffer->length = htole16(length);
length += sizeof(struct RewindData);
sendto(uplinkHandle, outgoingBuffer, length, 0, serverAddress->ai_addr, serverAddress->ai_addrlen);
@ -722,8 +723,10 @@ int main(int argc, const char* argv[])
size_t length = sizeof(struct RewindVersionData);
struct RewindVersionData* data = (struct RewindVersionData*)outgoingBuffer->data;
length += sprintf(data->version, "CronosAgent " STRING(VERSION) " " BUILD);
data->number = htole32(repeaterNumber);
data->service = REWIND_SERVICE_CRONOS_AGENT;
length += sprintf(data->version, "CronosAgent " STRING(VERSION) " " BUILD);
outgoingBuffer->type = htole16(REWIND_TYPE_KEEP_ALIVE);
outgoingBuffer->flags = htole16(REWIND_FLAG_DEFAULT_SET);

View file

@ -11,8 +11,7 @@ extern "C"
#pragma pack(push, 1)
#define REWIND_DEFAULT_PORT 54004
#define REWIND_KEEP_ALIVE_INTERVAL 2
#define REWIND_KEEP_ALIVE_INTERVAL 5
#define REWIND_SIGN_LENGTH 8
#define REWIND_PROTOCOL_SIGN "REWIND01"
@ -21,6 +20,7 @@ extern "C"
#define REWIND_CLASS_SYSTEM_CONSOLE 0x0100
#define REWIND_CLASS_SERVER_NOTICE 0x0200
#define REWIND_CLASS_KAIROS_DATA 0x0800
#define REWIND_CLASS_APPLICATION 0x0900
#define REWIND_TYPE_KEEP_ALIVE (REWIND_CLASS_REWIND_CONTROL + 0)
#define REWIND_TYPE_CLOSE (REWIND_CLASS_REWIND_CONTROL + 1)
@ -36,14 +36,25 @@ extern "C"
#define REWIND_TYPE_REMOTE_CONTROL (REWIND_CLASS_KAIROS_DATA + 1)
#define REWIND_TYPE_SNMP_TRAP (REWIND_CLASS_KAIROS_DATA + 2)
#define REWIND_TYPE_SUBSCRIPTION (REWIND_CLASS_APPLICATION + 0x00)
#define REWIND_TYPE_DMR_DATA_BASE (REWIND_CLASS_APPLICATION + 0x10)
#define REWIND_TYPE_DMR_AUDIO_FRAME (REWIND_CLASS_APPLICATION + 0x20)
#define REWIND_FLAG_NONE 0
#define REWIND_FLAG_REAL_TIME_1 (1 << 0)
#define REWIND_FLAG_REAL_TIME_2 (1 << 1)
#define REWIND_FLAG_DEFAULT_SET REWIND_FLAG_NONE
#define REWIND_ROLE_REPEATER_AGENT 0x10
#define REWIND_ROLE_APPLICATION 0x20
#define REWIND_SERVICE_CRONOS_AGENT (REWIND_ROLE_REPEATER_AGENT + 0)
#define REWIND_SERVICE_SIMPLE_APPLICATION (REWIND_ROLE_APPLICATION + 0)
struct RewindVersionData
{
uint32_t number; // Agent ID
uint32_t number; // Remote ID
uint8_t service; // REWIND_SERVICE_*
char version[0]; // Software version
};
@ -53,6 +64,12 @@ struct RewindAddressData
uint16_t port;
};
struct RewindSubscriptionData
{
uint32_t type;
uint32_t number;
};
struct RewindData
{
char sign[REWIND_SIGN_LENGTH];