diff --git a/TellusAgent.c b/TellusAgent.c index fcd7449..5665b0e 100644 --- a/TellusAgent.c +++ b/TellusAgent.c @@ -388,7 +388,7 @@ int main(int argc, const char* argv[]) memset(outgoingBuffer, 0, sizeof(struct RewindData)); memcpy(outgoingBuffer, REWIND_PROTOCOL_SIGN, REWIND_SIGN_LENGTH); - struct sockaddr_in repeaterSocketAddresses[3]; + struct sockaddr_in repeaterSocketAddresses[2 * PROXY_PORT_COUNT]; memset(repeaterSocketAddresses, 0, sizeof(repeaterSocketAddresses)); // Main loop @@ -511,9 +511,14 @@ int main(int argc, const char* argv[]) int handle = proxyHandles[selection]; if (CHECK(event, handle)) { + struct sockaddr_in dummyAddress; socklen_t size = sizeof(struct sockaddr_in); uint8_t* buffer = (uint8_t*)outgoingBuffer->data; struct sockaddr_in* address = repeaterSocketAddresses + selection; + + // Move to additional buffer to keep initial value + address += PROXY_PORT_COUNT * (address->si_family != AF_UNSPEC); + size_t length = recvfrom(handle, buffer, BUFFER_SIZE, 0, (struct sockaddr*)address, &size); outgoingBuffer->type = htole16(REWIND_CLASS_HYTERA_DATA + selection);