Index: channels/chan_sip.c =================================================================== --- channels/chan_sip.c (revision 8694) +++ channels/chan_sip.c (working copy) @@ -415,7 +415,9 @@ static int sipdebug = 0; static struct sockaddr_in debugaddr; -static int tos = 0; +static int tos_sip = 24 << 2; /*!< Call signalling packets should be marked as DSCP CS3 */ +static int tos_audio = 46 << 2; /*!< Audio packets should be marked as DSCP EF (Expedited Forwarding) */ +static int tos_video = 34 << 2; /*!< Video packets should be marked as DSCP AF41 */ static int videosupport = 0; @@ -3061,9 +3063,9 @@ free(p); return NULL; } - ast_rtp_settos(p->rtp, tos); + ast_rtp_settos(p->rtp, tos_audio); if (p->vrtp) - ast_rtp_settos(p->vrtp, tos); + ast_rtp_settos(p->vrtp, tos_video); p->rtptimeout = global_rtptimeout; p->rtpholdtimeout = global_rtpholdtimeout; p->rtpkeepalive = global_rtpkeepalive; @@ -8157,7 +8159,9 @@ ast_cli(fd, " From: Domain: %s\n", default_fromdomain); ast_cli(fd, " Record SIP history: %s\n", recordhistory ? "On" : "Off"); ast_cli(fd, " Call Events: %s\n", callevents ? "On" : "Off"); - ast_cli(fd, " IP ToS: 0x%x\n", tos); + ast_cli(fd, " IP ToS SIP: 0x%x\n", tos_sip); + ast_cli(fd, " IP ToS RTP audio: 0x%x\n", tos_audio); + ast_cli(fd, " IP ToS RTP video: 0x%x\n", tos_video); #ifdef OSP_SUPPORT ast_cli(fd, " OSP Support: Yes\n"); #else @@ -12273,6 +12277,7 @@ struct ast_flags dummy; int auto_sip_domains = 0; struct sockaddr_in old_bindaddr = bindaddr; + int temp_tos = 0; cfg = ast_config_load(config); @@ -12331,7 +12336,9 @@ srvlookup = 0; autocreatepeer = 0; regcontext[0] = '\0'; - tos = 0; + tos_sip = 24 << 2; + tos_audio = 46 << 2; + tos_video = 34 << 2; expiry = DEFAULT_EXPIRY; global_allowguest = 1; @@ -12502,8 +12509,21 @@ } else if (!strcasecmp(v->name, "register")) { sip_register(v->value, v->lineno); } else if (!strcasecmp(v->name, "tos")) { - if (ast_str2tos(v->value, &tos)) + if (!ast_str2tos(v->value, &temp_tos)) { + tos_sip = temp_tos; + tos_audio = temp_tos; + tos_video = temp_tos; + } else ast_log(LOG_WARNING, "Invalid tos value at line %d, should be 'lowdelay', 'throughput', 'reliability', 'mincost', or 'none'\n", v->lineno); + } else if (!strcasecmp(v->name, "tos_sip")) { + if (ast_str2tos(v->value, &tos_sip)) + ast_log(LOG_WARNING, "Invalid tos_sip value at line %d, should be 'lowdelay', 'throughput', 'reliability', 'mincost', or 'none'\n", v->lineno); + } else if (!strcasecmp(v->name, "tos_audio")) { + if (ast_str2tos(v->value, &tos_audio)) + ast_log(LOG_WARNING, "Invalid tos_audio value at line %d, should be 'lowdelay', 'throughput', 'reliability', 'mincost', or 'none'\n", v->lineno); + } else if (!strcasecmp(v->name, "tos_video")) { + if (ast_str2tos(v->value, &tos_video)) + ast_log(LOG_WARNING, "Invalid tos_video value at line %d, should be 'lowdelay', 'throughput', 'reliability', 'mincost', or 'none'\n", v->lineno); } else if (!strcasecmp(v->name, "bindport")) { if (sscanf(v->value, "%d", &ourport) == 1) { bindaddr.sin_port = htons(ourport); @@ -12603,10 +12623,10 @@ if (option_verbose > 1) { ast_verbose(VERBOSE_PREFIX_2 "SIP Listening on %s:%d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), bindaddr.sin_addr), ntohs(bindaddr.sin_port)); - ast_verbose(VERBOSE_PREFIX_2 "Using TOS bits %d\n", tos); + ast_verbose(VERBOSE_PREFIX_2 "Using SIP TOS bits %d\n", tos_sip); } - if (setsockopt(sipsock, IPPROTO_IP, IP_TOS, &tos, sizeof(tos))) - ast_log(LOG_WARNING, "Unable to set TOS to %d\n", tos); + if (setsockopt(sipsock, IPPROTO_IP, IP_TOS, &tos_sip, sizeof(tos_sip))) + ast_log(LOG_WARNING, "Unable to set SIP TOS to %d\n", tos_sip); } } } Index: acl.c =================================================================== --- acl.c (revision 8694) +++ acl.c (working copy) @@ -262,6 +262,42 @@ *tos = IPTOS_MINCOST; else if (!strcasecmp(value, "none")) *tos = 0; + else if (!strcasecmp(value, "ef")) + *tos = 46 << 2; + else if (!strcasecmp(value, "af43")) + *tos = 38 << 2; + else if (!strcasecmp(value, "af42")) + *tos = 36 << 2; + else if (!strcasecmp(value, "af41")) + *tos = 34 << 2; + else if (!strcasecmp(value, "cs4")) + *tos = 32 << 2; + else if (!strcasecmp(value, "af33")) + *tos = 30 << 2; + else if (!strcasecmp(value, "af32")) + *tos = 28 << 2; + else if (!strcasecmp(value, "af31")) + *tos = 26 << 2; + else if (!strcasecmp(value, "cs3")) + *tos = 24 << 2; + else if (!strcasecmp(value, "af23")) + *tos = 22 << 2; + else if (!strcasecmp(value, "af22")) + *tos = 20 << 2; + else if (!strcasecmp(value, "af21")) + *tos = 18 << 2; + else if (!strcasecmp(value, "cs2")) + *tos = 16 << 2; + else if (!strcasecmp(value, "af13")) + *tos = 14 << 2; + else if (!strcasecmp(value, "af12")) + *tos = 12 << 2; + else if (!strcasecmp(value, "af11")) + *tos = 10 << 2; + else if (!strcasecmp(value, "cs1")) + *tos = 8 << 2; + else if (!strcasecmp(value, "be")) + *tos = 0; else return -1; return 0; Index: configs/sip.conf.sample =================================================================== --- configs/sip.conf.sample (revision 8694) +++ configs/sip.conf.sample (working copy) @@ -56,8 +56,32 @@ ;pedantic=yes ; Enable slow, pedantic checking for Pingtel ; and multiline formatted headers for strict ; SIP compatibility (defaults to "no") -;tos=184 ; Set IP QoS to either a keyword or numeric val -;tos=lowdelay ; lowdelay,throughput,reliability,mincost,none + +; Set IP QoS to either a keyword or a numeric value. Different QoS +; settings are possible for different types of traffic. By default +; SIP packets are set to DSCP CS3, RTP audio packets are set to DSCP +; EF, and RTP video packets are set to DSCP AF41. For more +; information on why these are set this way see the "Enterprise QoS +; Solution Reference Network Design Guide" version 3.3 from Cisco at: +; +; http://www.cisco.com/application/pdf/en/us/guest/netsol/ns432/c649/ccmigration_09186a008049b062.pdf +; +; The allowable values for any of the tos_* parameters are: +; +; be, cs1, af11, af12, af13, cs2, af21, af22, af23, cs3, af31, af32, +; af33, cs4, af41, af42, af42, ef, lowdelay, throughput, reliability, +; mincost, none +; +; The tos_* parameters will also take numeric values. +; +; The lowdelay, throughput, reliability, and mincost values are +; deprecated. The old "tos" parameter is deprecated because it sets +; the IP QoS for all three types of packets to the same QoS value. +; +;tos_sip=cs3 ; Sets TOS for SIP packets. +;tos_audio=ef ; Sets TOS for RTP audio packets. +;tos_video=af41 ; Sets TOS for RTP video packets. + ;maxexpiry=3600 ; Max length of incoming registration we allow ;defaultexpiry=120 ; Default length of incoming/outoing registration ;notifymimetype=text/plain ; Allow overriding of mime type in MWI NOTIFY