External Server port is allocated dynamically starting now
This commit is contained in:
parent
fb9e8c3bf0
commit
bca4ec2c2e
1 changed files with 11 additions and 15 deletions
|
@ -125,14 +125,14 @@ int main(int argc, const char* argv[])
|
||||||
print("Copyright 2016 Artem Prilutskiy (R3ABM, cyanide.burnout@gmail.com)\n");
|
print("Copyright 2016 Artem Prilutskiy (R3ABM, cyanide.burnout@gmail.com)\n");
|
||||||
print("\n");
|
print("\n");
|
||||||
|
|
||||||
// Parameters of server
|
// Parameters for server
|
||||||
|
|
||||||
const char* serverPort = STRING(REWIND_DEFAULT_PORT);
|
const char* serverPort = STRING(REWIND_DEFAULT_PORT);
|
||||||
const char* serverLocation = NULL;
|
const char* serverLocation = NULL;
|
||||||
const char* serverPassword = NULL;
|
const char* serverPassword = NULL;
|
||||||
struct addrinfo* serverAddress = NULL;
|
struct addrinfo* serverAddress = NULL;
|
||||||
|
|
||||||
// Parameters of repeater
|
// Parameters for repeater
|
||||||
|
|
||||||
int proxyTrapPort = 162;
|
int proxyTrapPort = 162;
|
||||||
int proxyMediaPort = KAIROS_HAM_DEFAULT_PORT;
|
int proxyMediaPort = KAIROS_HAM_DEFAULT_PORT;
|
||||||
|
@ -154,14 +154,13 @@ int main(int argc, const char* argv[])
|
||||||
{ "server-password", required_argument, NULL, 'w' },
|
{ "server-password", required_argument, NULL, 'w' },
|
||||||
{ "server-address", required_argument, NULL, 's' },
|
{ "server-address", required_argument, NULL, 's' },
|
||||||
{ "server-port", required_argument, NULL, 'p' },
|
{ "server-port", required_argument, NULL, 'p' },
|
||||||
{ "media-port", required_argument, NULL, 'b' },
|
|
||||||
{ "trap-port", required_argument, NULL, 't' },
|
{ "trap-port", required_argument, NULL, 't' },
|
||||||
{ "service-mode", required_argument, NULL, 'm' },
|
{ "service-mode", required_argument, NULL, 'm' },
|
||||||
{ NULL, 0, NULL, 0 }
|
{ NULL, 0, NULL, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
int selection = 0;
|
int selection = 0;
|
||||||
while ((selection = getopt_long(argc, CAST(char* const*, argv), "n:r:c:w:s:p:b:t:m:", options, NULL)) != EOF)
|
while ((selection = getopt_long(argc, CAST(char* const*, argv), "n:r:c:w:s:p:t:m:", options, NULL)) != EOF)
|
||||||
switch (selection)
|
switch (selection)
|
||||||
{
|
{
|
||||||
case 'n':
|
case 'n':
|
||||||
|
@ -188,10 +187,6 @@ int main(int argc, const char* argv[])
|
||||||
serverPort = optarg;
|
serverPort = optarg;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'b':
|
|
||||||
proxyMediaPort = strtol(optarg, NULL, 10);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 't':
|
case 't':
|
||||||
proxyTrapPort = strtol(optarg, NULL, 10);
|
proxyTrapPort = strtol(optarg, NULL, 10);
|
||||||
break;
|
break;
|
||||||
|
@ -215,7 +210,6 @@ int main(int argc, const char* argv[])
|
||||||
" --server-password <access password of BrandMeister DMR Server>\n"
|
" --server-password <access password of BrandMeister DMR Server>\n"
|
||||||
" --server-address <domain name of BrandMeister DMR Server>\n"
|
" --server-address <domain name of BrandMeister DMR Server>\n"
|
||||||
" --server-port <local port for BrandMeister DMR Server>\n"
|
" --server-port <local port for BrandMeister DMR Server>\n"
|
||||||
" --media-port <media port for KAIROS External Servier>\n"
|
|
||||||
" --trap-port <port for SNMP Traps>\n"
|
" --trap-port <port for SNMP Traps>\n"
|
||||||
" --service-mode <set of bits>\n"
|
" --service-mode <set of bits>\n"
|
||||||
" bit 0 - print to standard output\n"
|
" bit 0 - print to standard output\n"
|
||||||
|
@ -289,6 +283,7 @@ 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);
|
||||||
|
|
||||||
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);
|
||||||
|
@ -296,7 +291,7 @@ int main(int argc, const char* argv[])
|
||||||
proxySocketAddress.sin_port = 0;
|
proxySocketAddress.sin_port = 0;
|
||||||
remoteHandle = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
remoteHandle = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
||||||
if((remoteHandle < 0) ||
|
if((remoteHandle < 0) ||
|
||||||
(bind(remoteHandle, (struct sockaddr*)&proxySocketAddress, sizeof(proxySocketAddress)) < 0))
|
(bind(remoteHandle, (struct sockaddr*)&proxySocketAddress, proxySocketLength) < 0))
|
||||||
{
|
{
|
||||||
print("Error opening port for Remote Control\n");
|
print("Error opening port for Remote Control\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
@ -305,18 +300,19 @@ int main(int argc, const char* argv[])
|
||||||
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) ||
|
||||||
(bind(trapHandle, (struct sockaddr*)&proxySocketAddress, sizeof(proxySocketAddress)) < 0))
|
(bind(trapHandle, (struct sockaddr*)&proxySocketAddress, proxySocketLength) < 0))
|
||||||
{
|
{
|
||||||
print("Error opening port for SNMP Traps\n");
|
print("Error opening port for SNMP Traps\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
proxySocketAddress.sin_port = htons(proxyMediaPort);
|
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) ||
|
||||||
(bind(mediaHandle, (struct sockaddr*)&proxySocketAddress, sizeof(proxySocketAddress)) < 0))
|
(bind(mediaHandle, (struct sockaddr*)&proxySocketAddress, proxySocketLength) < 0) ||
|
||||||
|
(getsockname(mediaHandle, (struct sockaddr*)&proxySocketAddress, &proxySocketLength) < 0))
|
||||||
{
|
{
|
||||||
print("Error opening port for KAIROS External Server\n");
|
print("Error opening port for External Server\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -662,7 +658,7 @@ int main(int argc, const char* argv[])
|
||||||
size_t length = sizeof(struct RewindAddressData);
|
size_t length = sizeof(struct RewindAddressData);
|
||||||
struct RewindAddressData* data = (struct RewindAddressData*)outgoingBuffer->data;
|
struct RewindAddressData* data = (struct RewindAddressData*)outgoingBuffer->data;
|
||||||
data->address = information->ipi_addr;
|
data->address = information->ipi_addr;
|
||||||
data->port = htons(proxyMediaPort);
|
data->port = proxySocketAddress.sin_port;
|
||||||
|
|
||||||
outgoingBuffer->type = htole16(REWIND_TYPE_ADDRESS_NOTICE);
|
outgoingBuffer->type = htole16(REWIND_TYPE_ADDRESS_NOTICE);
|
||||||
outgoingBuffer->number = htole32(++ sequenceNumbers[0]);
|
outgoingBuffer->number = htole32(++ sequenceNumbers[0]);
|
||||||
|
|
Loading…
Add table
Reference in a new issue