4
Fork 0

Added print of version

This commit is contained in:
R3ABM Artem 2016-07-10 22:06:18 +03:00
parent bca4ec2c2e
commit 29d76989e3

View file

@ -123,6 +123,7 @@ int main(int argc, const char* argv[])
print("\n"); print("\n");
print("CronosAgent for BrandMeister DMR Master Server\n"); print("CronosAgent for BrandMeister DMR Master Server\n");
print("Copyright 2016 Artem Prilutskiy (R3ABM, cyanide.burnout@gmail.com)\n"); print("Copyright 2016 Artem Prilutskiy (R3ABM, cyanide.burnout@gmail.com)\n");
print("Software revision " STRING(VERSION) " build " BUILD "\n");
print("\n"); print("\n");
// Parameters for server // Parameters for server
@ -283,20 +284,13 @@ int main(int argc, const char* argv[])
int mediaHandle; int mediaHandle;
int remoteHandle; int remoteHandle;
struct sockaddr_in proxySocketAddress; struct sockaddr_in proxySocketAddress;
socklen_t proxySocketLength = sizeof(proxySocketAddress); socklen_t proxySocketLength = sizeof(proxySocketAddress);
int socketOptionValue = true;
proxySocketAddress.sin_family = AF_INET; proxySocketAddress.sin_family = AF_INET;
proxySocketAddress.sin_addr.s_addr = htonl(INADDR_ANY); proxySocketAddress.sin_addr.s_addr = htonl(INADDR_ANY);
proxySocketAddress.sin_port = 0;
remoteHandle = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if((remoteHandle < 0) ||
(bind(remoteHandle, (struct sockaddr*)&proxySocketAddress, proxySocketLength) < 0))
{
print("Error opening port for Remote Control\n");
return EXIT_FAILURE;
}
proxySocketAddress.sin_port = htons(proxyTrapPort); proxySocketAddress.sin_port = htons(proxyTrapPort);
trapHandle = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); trapHandle = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if((trapHandle < 0) || if((trapHandle < 0) ||
@ -306,6 +300,16 @@ int main(int argc, const char* argv[])
return EXIT_FAILURE; return EXIT_FAILURE;
} }
proxySocketAddress.sin_port = 0;
remoteHandle = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if((remoteHandle < 0) ||
(bind(remoteHandle, (struct sockaddr*)&proxySocketAddress, proxySocketLength) < 0) ||
(setsockopt(remoteHandle, IPPROTO_IP, IP_PKTINFO, &socketOptionValue, sizeof(socketOptionValue)) < 0))
{
print("Error opening port for Remote Control\n");
return EXIT_FAILURE;
}
proxySocketAddress.sin_port = 0; proxySocketAddress.sin_port = 0;
mediaHandle = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); mediaHandle = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if((mediaHandle < 0) || if((mediaHandle < 0) ||
@ -334,11 +338,6 @@ int main(int argc, const char* argv[])
return EXIT_FAILURE; return EXIT_FAILURE;
} }
// Configure socket options
int value = true;
setsockopt(remoteHandle, IPPROTO_IP, IP_PKTINFO, &value, sizeof(value));
#ifdef __linux__ #ifdef __linux__
// Initialize timer handle // Initialize timer handle
@ -522,7 +521,7 @@ int main(int argc, const char* argv[])
if ((length >= sizeof(struct RewindData)) && if ((length >= sizeof(struct RewindData)) &&
((serverAddress->ai_addr->sa_family == AF_INET) || /* Work-around for Linux */ ((serverAddress->ai_addr->sa_family == AF_INET) || /* Work-around for Linux */
(memcmp(&address, serverAddress->ai_addr, serverAddress->ai_addrlen) == 0)) && (memcmp(&address, serverAddress->ai_addr, serverAddress->ai_addrlen) == 0)) &&
(memcmp(incomingBuffer->sign, REWIND_PROTOCOL_SIGN, REWIND_SIGN_LENGTH) == 0)) (memcmp(incomingBuffer->sign, REWIND_PROTOCOL_SIGN, REWIND_SIGN_LENGTH) == 0))
{ {
uint16_t type = le16toh(incomingBuffer->type); uint16_t type = le16toh(incomingBuffer->type);
size_t length = le16toh(incomingBuffer->length); size_t length = le16toh(incomingBuffer->length);
@ -701,6 +700,7 @@ int main(int argc, const char* argv[])
} }
// Handle timer to transmit keep-alive // Handle timer to transmit keep-alive
#ifdef __linux__ #ifdef __linux__
if (event->data.fd == timerHandle) if (event->data.fd == timerHandle)
{ {