From 412c3255c27750edf2f59ee7042ed1106bb59812 Mon Sep 17 00:00:00 2001 From: Artem Prilutskiy Date: Sun, 7 Aug 2016 18:05:48 +0300 Subject: [PATCH] Trying to solve issue with RA using IPTOS_LOWDELAY --- CronosAgent.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/CronosAgent.c b/CronosAgent.c index d912aa6..3b2ae03 100644 --- a/CronosAgent.c +++ b/CronosAgent.c @@ -10,6 +10,7 @@ #include #include +#include #include #include @@ -307,10 +308,10 @@ int main(int argc, const char* argv[]) int trapHandle; int mediaHandle; int remoteHandle; + int socketOptionValue; struct sockaddr_in proxySocketAddress; socklen_t proxySocketLength = sizeof(proxySocketAddress); - int socketOptionValue = true; proxySocketAddress.sin_family = AF_INET; proxySocketAddress.sin_addr.s_addr = htonl(INADDR_ANY); @@ -324,6 +325,7 @@ int main(int argc, const char* argv[]) return EXIT_FAILURE; } + socketOptionValue = true; proxySocketAddress.sin_port = 0; remoteHandle = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); if((remoteHandle < 0) || @@ -334,11 +336,13 @@ int main(int argc, const char* argv[]) return EXIT_FAILURE; } + socketOptionValue = IPTOS_LOWDELAY; proxySocketAddress.sin_port = 0; mediaHandle = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); if((mediaHandle < 0) || (bind(mediaHandle, (struct sockaddr*)&proxySocketAddress, proxySocketLength) < 0) || - (getsockname(mediaHandle, (struct sockaddr*)&proxySocketAddress, &proxySocketLength) < 0)) + (getsockname(mediaHandle, (struct sockaddr*)&proxySocketAddress, &proxySocketLength) < 0) || + (setsockopt(mediaHandle, IPPROTO_IP, IP_TOS, &socketOptionValue, sizeof(socketOptionValue)) < 0)) { print("Error opening port for External Server\n"); return EXIT_FAILURE;