diff options
author | David Vossel <dvossel@digium.com> | 2010-10-14 22:10:20 +0000 |
---|---|---|
committer | David Vossel <dvossel@digium.com> | 2010-10-14 22:10:20 +0000 |
commit | dc0b76c04c4a867797401eec478013ecfb23ebe9 (patch) | |
tree | 7122691b962f578cba5a2dab643ec357d06f2eb5 /main/netsock2.c | |
parent | 58ea3034cea73400ee0bdf41062e5a55913c8d02 (diff) |
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
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@291830 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/netsock2.c')
-rw-r--r-- | main/netsock2.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/main/netsock2.c b/main/netsock2.c index 99f7eac89..ed5964db8 100644 --- a/main/netsock2.c +++ b/main/netsock2.c @@ -454,8 +454,17 @@ ssize_t ast_sendto(int sockfd, const void *buf, size_t len, int flags, 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; + struct ast_sockaddr addr; - if ((res = setsockopt(sockfd, IPPROTO_IP, IP_TOS, &tos, sizeof(tos)))) { + /* 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) { |