Module: sip-router
Branch: 4.0
Commit: e83d6d4c34fb04223f5754fff1248286e1345e7d
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=e83d6d4…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Wed Mar 27 20:53:00 2013 +0100
core: set TOS for IPv6 UDP sockets
- reported by Klaus Feichtinger, FS#179
(cherry picked from commit 084be456bc0fab015cf9964ac85651fa60ea77c9)
---
udp_server.c | 21 +++++++++++++++++----
1 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/udp_server.c b/udp_server.c
index 3889a65..d4efe13 100644
--- a/udp_server.c
+++ b/udp_server.c
@@ -321,11 +321,24 @@ int udp_init(struct socket_info* sock_info)
}
/* tos */
optval = tos;
- if (setsockopt(sock_info->socket, IPPROTO_IP, IP_TOS, (void*)&optval,
- sizeof(optval)) ==-1){
- LOG(L_WARN, "WARNING: udp_init: setsockopt tos: %s\n", strerror(errno));
- /* continue since this is not critical */
+ if (addr->s.sa_family==AF_INET){
+ if (setsockopt(sock_info->socket, IPPROTO_IP, IP_TOS, (void*)&optval,
+ sizeof(optval)) ==-1){
+ LOG(L_WARN, "WARNING: udp_init: setsockopt tos: %s\n",
+ strerror(errno));
+ /* continue since this is not critical */
+ }
+#ifdef USE_IPV6
+ } else if (addr->s.sa_family==AF_INET6){
+ if (setsockopt(sock_info->socket, IPPROTO_IPV6, IPV6_TCLASS,
+ (void*)&optval, sizeof(optval)) ==-1) {
+ LOG(L_WARN, "WARNING: udp_init: setsockopt v6 tos: %s\n",
+ strerror(errno));
+ /* continue since this is not critical */
+ }
+#endif
}
+
#if defined (__OS_linux) && defined(UDP_ERRORS)
optval=1;
/* enable error receiving on unconnected sockets */