[sr-dev] git:master: core: set TOS for IPv6 sctp sockets

Daniel-Constantin Mierla miconda at gmail.com
Sat Mar 30 09:26:01 CET 2013


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

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Sat Mar 30 09:15:00 2013 +0100

core: set TOS for IPv6 sctp sockets

---

 sctp_server.c |   20 ++++++++++++++++----
 1 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/sctp_server.c b/sctp_server.c
index fbe83ea..511842e 100644
--- a/sctp_server.c
+++ b/sctp_server.c
@@ -451,10 +451,22 @@ static int sctp_init_sock_opt_common(int s, int af)
 #endif
 	/* set tos */
 	optval = tos;
-	if (setsockopt(s, IPPROTO_IP, IP_TOS, (void*)&optval,sizeof(optval)) ==-1){
-		LOG(L_WARN, "WARNING: sctp_init_sock_opt_common: 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){
+			LM_WARN("sctp_init_sock_opt_common: 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) {
+			LM_WARN("sctp_init_sock_opt_common: setsockopt v6 tos: %s\n",
+					strerror(errno));
+			/* continue since this is not critical */
+		}
+#endif
 	}
 	
 	/* set receive buffer: SO_RCVBUF*/




More information about the sr-dev mailing list