Module: sip-router
Branch: 4.0
Commit: 1d6e63967ba8eaa5e1cf0d63081ec38439f0bcaa
URL:    
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=1d6e63967ba8eaa5e1cf0d63081ec38439f0bcaa

Author: Daniel-Constantin Mierla <[email protected]>
Committer: Daniel-Constantin Mierla <[email protected]>
Date:   Sat Mar 30 09:24:19 2013 +0100

core: set TOS for tcp IPv6 sockets
(cherry picked from commit b9476db0c1e1ce869c1da2f87dfaf411edf69277)

---

 tcp_main.c |   25 +++++++++++++++++++------
 1 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/tcp_main.c b/tcp_main.c
index 9d3359e..8a650a1 100644
--- a/tcp_main.c
+++ b/tcp_main.c
@@ -373,7 +373,7 @@ static inline int init_sock_keepalive(int s)
  *  disable nagle, tos lowdelay, reuseaddr, non-blocking
  *
  * return -1 on error */
-static int init_sock_opt(int s)
+static int init_sock_opt(int s, int af)
 {
        int flags;
        int optval;
@@ -388,11 +388,24 @@ static int init_sock_opt(int s)
 #endif
        /* tos*/
        optval = tos;
-       if (setsockopt(s, IPPROTO_IP, IP_TOS, (void*)&optval,sizeof(optval)) 
==-1){
-               LOG(L_WARN, "WARNING: init_sock_opt: setsockopt tos: %s\n",
-                               strerror(errno));
-               /* continue since this is not critical */
+       if(af==AF_INET){
+               if (setsockopt(s, IPPROTO_IP, IP_TOS, (void*)&optval,
+                                       sizeof(optval)) ==-1){
+                       LOG(L_WARN, "WARNING: init_sock_opt: setsockopt tos: 
%s\n",
+                                       strerror(errno));
+                       /* continue since this is not critical */
+               }
+#ifdef USE_IPV6
+       } else if(af==AF_INET6){
+               if (setsockopt(s, IPPROTO_IPV6, IPV6_TCLASS,
+                                       (void*)&optval, sizeof(optval)) ==-1) {
+                       LOG(L_WARN, "WARNING: init_sock_opt: setsockopt v6 tos: 
%s\n",
+                                       strerror(errno));
+                       /* continue since this is not critical */
+               }
+#endif
        }
+
 #if  !defined(TCP_DONT_REUSEADDR) 
        optval=1;
        if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR,
@@ -1140,7 +1153,7 @@ inline static int tcp_do_connect( union sockaddr_union* 
server,
                                su2a(server, sizeof(*server)), errno, 
strerror(errno));
                goto error;
        }
-       if (init_sock_opt(s)<0){
+       if (init_sock_opt(s, server->s.sa_family)<0){
                LOG(L_ERR, "ERROR: tcp_do_connect %s: init_sock_opt failed\n",
                                        su2a(server, sizeof(*server)));
                goto error;


_______________________________________________
sr-dev mailing list
[email protected]
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to