[asterisk-commits] dvossel: trunk r291830 - in /trunk: ./ main/netsock2.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Oct 14 17:10:24 CDT 2010


Author: dvossel
Date: Thu Oct 14 17:10:20 2010
New Revision: 291830

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=291830
Log:
Merged revisions 291829 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.8

........
  r291829 | dvossel | 2010-10-14 17:09:32 -0500 (Thu, 14 Oct 2010) | 8 lines
  
  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:
    trunk/   (props changed)
    trunk/main/netsock2.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.8-merged' - no diff available.

Modified: trunk/main/netsock2.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/netsock2.c?view=diff&rev=291830&r1=291829&r2=291830
==============================================================================
--- trunk/main/netsock2.c (original)
+++ trunk/main/netsock2.c Thu Oct 14 17:10:20 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 asterisk-commits mailing list