Browse code

core: set TOS for IPv6 sctp sockets

Daniel-Constantin Mierla authored on 30/03/2013 08:15:00
Showing 1 changed files
... ...
@@ -451,10 +451,22 @@ static int sctp_init_sock_opt_common(int s, int af)
451 451
 #endif
452 452
 	/* set tos */
453 453
 	optval = tos;
454
-	if (setsockopt(s, IPPROTO_IP, IP_TOS, (void*)&optval,sizeof(optval)) ==-1){
455
-		LOG(L_WARN, "WARNING: sctp_init_sock_opt_common: setsockopt tos: %s\n",
456
-				strerror(errno));
457
-		/* continue since this is not critical */
454
+	if(af==AF_INET){
455
+		if (setsockopt(s, IPPROTO_IP, IP_TOS, (void*)&optval,
456
+					sizeof(optval)) ==-1){
457
+			LM_WARN("sctp_init_sock_opt_common: setsockopt tos: %s\n",
458
+					strerror(errno));
459
+			/* continue since this is not critical */
460
+		}
461
+#ifdef USE_IPV6
462
+	} else if(af==AF_INET6){
463
+		if (setsockopt(s, IPPROTO_IPV6, IPV6_TCLASS,
464
+					(void*)&optval, sizeof(optval)) ==-1) {
465
+			LM_WARN("sctp_init_sock_opt_common: setsockopt v6 tos: %s\n",
466
+					strerror(errno));
467
+			/* continue since this is not critical */
468
+		}
469
+#endif
458 470
 	}
459 471
 	
460 472
 	/* set receive buffer: SO_RCVBUF*/