[asterisk-commits] dvossel: trunk r292086 - in /trunk: ./ main/netsock2.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Oct 18 11:03:26 CDT 2010
Author: dvossel
Date: Mon Oct 18 11:03:24 2010
New Revision: 292086
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=292086
Log:
Merged revisions 292085 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8
........
r292085 | dvossel | 2010-10-18 11:02:17 -0500 (Mon, 18 Oct 2010) | 7 lines
Fixes qos settings for sockets bound to any IPv6 or IPv4 address.
(closes issue #18099)
Reported by: jamesnet
Patches:
issues_18099_v3.diff uploaded by dvossel (license 671
........
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=292086&r1=292085&r2=292086
==============================================================================
--- trunk/main/netsock2.c (original)
+++ trunk/main/netsock2.c Mon Oct 18 11:03:24 2010
@@ -454,21 +454,34 @@
int ast_set_qos(int sockfd, int tos, int cos, const char *desc)
{
int res;
- int proto_type = IPPROTO_IP; /* ipv4 values by default */
- int dscp_field = IP_TOS;
+ int set_tos;
+ int set_tclass;
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) {
- ast_verb(2, "Using %s TOS bits %d\n", desc, tos);
+ /* If the sock address is IPv6, the TCLASS field must be set. */
+ set_tclass = !ast_getsockname(sockfd, &addr) && ast_sockaddr_is_ipv6(&addr) ? 1 : 0;
+
+ /* If the the sock address is IPv4 or (IPv6 set to any address [::]) set TOS bits */
+ set_tos = (!set_tclass || (set_tclass && ast_sockaddr_is_any(&addr))) ? 1 : 0;
+
+ if (set_tos) {
+ if ((res = setsockopt(sockfd, IPPROTO_IP, IP_TOS, &tos, sizeof(tos)))) {
+ ast_log(LOG_WARNING, "Unable to set %s DSCP TOS value to %d (may be you have no "
+ "root privileges): %s\n", desc, tos, strerror(errno));
+ } else if (tos) {
+ ast_verb(2, "Using %s TOS bits %d\n", desc, tos);
+ }
+ }
+
+ if (set_tclass) {
+ if (!ast_getsockname(sockfd, &addr) && ast_sockaddr_is_ipv6(&addr)) {
+ if ((res = setsockopt(sockfd, IPPROTO_IPV6, IPV6_TCLASS, &tos, sizeof(tos)))) {
+ ast_log(LOG_WARNING, "Unable to set %s DSCP TCLASS field to %d (may be you have no "
+ "root privileges): %s\n", desc, tos, strerror(errno));
+ } else if (tos) {
+ ast_verb(2, "Using %s TOS bits %d in TCLASS field.\n", desc, tos);
+ }
+ }
}
#ifdef linux
More information about the asterisk-commits
mailing list