diff --git a/CronosAgent.c b/CronosAgent.c index c5bf5cf..63f53ca 100644 --- a/CronosAgent.c +++ b/CronosAgent.c @@ -597,15 +597,15 @@ int main(int argc, const char* argv[]) uint8_t* buffer = (uint8_t*)outgoingBuffer->data; size_t length = recvfrom(mediaHandle, buffer, BUFFER_SIZE, 0, (struct sockaddr*)&address, &size); - if ((size == sizeof(struct sockaddr_in)) && + if ((size == sizeof(struct sockaddr_in)) && (address.sin_addr.s_addr == repeaterSocketAddress.sin_addr.s_addr) && (length >= KAIROS_EXCHANGE_HEADER_LENGTH) && (le32toh(*(uint32_t*)buffer) == KAIROS_HAM_RECORD_ID)) { - uint16_t number = ++ sequenceNumbers[buffer[8] & 3]; + int value = buffer[8] & 3; outgoingBuffer->type = htole16(REWIND_TYPE_EXTERNAL_SERVER); - outgoingBuffer->flags = htole16(buffer[8] < 4); - outgoingBuffer->number = htole32(number); + outgoingBuffer->flags = htole16(value); + outgoingBuffer->number = htole32(++ sequenceNumbers[value]); outgoingBuffer->length = htole16(length); length += sizeof(struct RewindData); sendto(uplinkHandle, outgoingBuffer, length, 0, serverAddress->ai_addr, serverAddress->ai_addrlen); @@ -686,7 +686,7 @@ int main(int argc, const char* argv[]) uint8_t* buffer = (uint8_t*)outgoingBuffer->data; size_t length = recvfrom(trapHandle, buffer, BUFFER_SIZE, 0, (struct sockaddr*)&address, &size); - if ((size == sizeof(struct sockaddr_in)) && + if ((size == sizeof(struct sockaddr_in)) && (address.sin_addr.s_addr == repeaterSocketAddress.sin_addr.s_addr) && (buffer[0] == (ASN_UNIVERSAL | ASN_CONSTRUCTOR | ASN_SEQUENCE)) && (length >= 20)) diff --git a/Rewind.h b/Rewind.h index 8fa1ea9..14ef5df 100644 --- a/Rewind.h +++ b/Rewind.h @@ -36,7 +36,8 @@ extern "C" #define REWIND_TYPE_REMOTE_CONTROL (REWIND_CLASS_KAIROS_DATA + 1) #define REWIND_TYPE_SNMP_TRAP (REWIND_CLASS_KAIROS_DATA + 2) -#define REWIND_FLAG_REAL_TIME (1 << 0) +#define REWIND_FLAG_SLOT_1 (1 << 0) +#define REWIND_FLAG_SLOT_2 (1 << 1) struct RewindVersionData {