[svn-commits] dvossel: branch 1.8 r291829 - /branches/1.8/main/netsock2.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Oct 14 17:09:37 CDT 2010


Author: dvossel
Date: Thu Oct 14 17:09:32 2010
New Revision: 291829

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=291829
Log:
Set TCLASS field of IPv6 header when sip qos options are set.

(closes issue #18099)
Reported by: jamesnet
Patches:
      issues_18099_v2.diff uploaded by dvossel (license 671)
Tested by: dvossel, jamesnet

Modified:
    branches/1.8/main/netsock2.c

Modified: branches/1.8/main/netsock2.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/main/netsock2.c?view=diff&rev=291829&r1=291828&r2=291829
==============================================================================
--- branches/1.8/main/netsock2.c (original)
+++ branches/1.8/main/netsock2.c Thu Oct 14 17:09:32 2010
@@ -454,8 +454,17 @@
 int ast_set_qos(int sockfd, int tos, int cos, const char *desc)
 {
 	int res;
-
-	if ((res = setsockopt(sockfd, IPPROTO_IP, IP_TOS, &tos, sizeof(tos)))) {
+	int proto_type = IPPROTO_IP; /* ipv4 values by default */
+	int dscp_field = IP_TOS;
+	struct ast_sockaddr addr;
+
+	/* if this is IPv6 we need to set the TCLASS instead of TOS */
+	if (!ast_getsockname(sockfd, &addr) && ast_sockaddr_is_ipv6(&addr)) {
+		proto_type = IPPROTO_IPV6;
+		dscp_field = IPV6_TCLASS;
+	}
+
+	if ((res = setsockopt(sockfd, proto_type, dscp_field, &tos, sizeof(tos)))) {
 		ast_log(LOG_WARNING, "Unable to set %s TOS to %d (may be you have no "
 			"root privileges): %s\n", desc, tos, strerror(errno));
 	} else if (tos) {




More information about the svn-commits mailing list