Index: channels/chan_sip.c =================================================================== --- channels/chan_sip.c (revision 8687) +++ channels/chan_sip.c (working copy) @@ -356,7 +356,9 @@ #define DEFAULT_VIDEOSUPPORT FALSE #define DEFAULT_SRVLOOKUP FALSE /*!< Recommended setting is ON */ #define DEFAULT_COMPACTHEADERS FALSE -#define DEFAULT_TOS FALSE +#define DEFAULT_TOS_SIP (24 << 2) /*!< Call signalling packets should be marked as DSCP CS3 */ +#define DEFAULT_TOS_AUDIO (46 << 2) /*!< Audio packets should be marked as DSCP EF (Expedited Forwarding) */ +#define DEFAULT_TOS_VIDEO (34 << 2) /*!< Video packets should be marked as DSCP AF41 */ #define DEFAULT_ALLOW_EXT_DOM TRUE #define DEFAULT_REALM "asterisk" #define DEFAULT_NOTIFYRINGING TRUE @@ -392,7 +394,9 @@ static int global_regattempts_max; /*!< Registration attempts before giving up */ static int global_allowguest; /*!< allow unauthenticated users/peers to connect? */ static int global_mwitime; /*!< Time between MWI checks for peers */ -static int global_tos; /*!< IP Type of service */ +static int global_tos_sip; /*!< IP type of service for SIP packets */ +static int global_tos_audio; /*!< IP type of service for audio RTP packets */ +static int global_tos_video; /*!< IP type of service for video RTP packets */ static int global_videosupport; /*!< Videosupport on or off */ static int compactheaders; /*!< send compact sip headers */ static int recordhistory; /*!< Record SIP history. Off by default */ @@ -3162,9 +3166,9 @@ free(p); return NULL; } - ast_rtp_settos(p->rtp, global_tos); + ast_rtp_settos(p->rtp, global_tos_audio); if (p->vrtp) - ast_rtp_settos(p->vrtp, global_tos); + ast_rtp_settos(p->vrtp, global_tos_video); p->rtptimeout = global_rtptimeout; p->rtpholdtimeout = global_rtpholdtimeout; p->rtpkeepalive = global_rtpkeepalive; @@ -8285,7 +8289,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", global_tos); + ast_cli(fd, " IP ToS SIP: 0x%x\n", global_tos_sip); + ast_cli(fd, " IP ToS RTP audio: 0x%x\n", global_tos_audio); + ast_cli(fd, " IP ToS RTP video: 0x%x\n", global_tos_video); #ifdef OSP_SUPPORT ast_cli(fd, " OSP Support: Yes\n"); #else @@ -12348,6 +12354,7 @@ int auto_sip_domains = 0; struct sockaddr_in old_bindaddr = bindaddr; int registry_count = 0, peer_count = 0, user_count = 0; + int temp_tos = 0; cfg = ast_config_load(config); @@ -12369,7 +12376,9 @@ outboundproxyip.sin_family = AF_INET; /* Type of address: IPv4 */ ourport = DEFAULT_SIP_PORT; srvlookup = DEFAULT_SRVLOOKUP; - global_tos = DEFAULT_TOS; + global_tos_sip = DEFAULT_TOS_SIP; + global_tos_audio = DEFAULT_TOS_AUDIO; + global_tos_video = DEFAULT_TOS_VIDEO; externhost[0] = '\0'; /* External host name (for behind NAT DynDNS support) */ externexpire = 0; /* Expiration for DNS re-issuing */ externrefresh = 10; @@ -12586,8 +12595,21 @@ if (sip_register(v->value, v->lineno) == 0) registry_count++; } else if (!strcasecmp(v->name, "tos")) { - if (ast_str2tos(v->value, &global_tos)) + if (!ast_str2tos(v->value, &temp_tos)) { + global_tos_sip = temp_tos; + global_tos_audio = temp_tos; + global_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, &global_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, &global_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, &global_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); @@ -12696,10 +12718,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", global_tos); + ast_verbose(VERBOSE_PREFIX_2 "Using TOS bits %d\n", global_tos_sip); } - if (setsockopt(sipsock, IPPROTO_IP, IP_TOS, &global_tos, sizeof(global_tos))) - ast_log(LOG_WARNING, "Unable to set TOS to %d\n", global_tos); + if (setsockopt(sipsock, IPPROTO_IP, IP_TOS, &global_tos_sip, sizeof(global_tos_sip))) + ast_log(LOG_WARNING, "Unable to set TOS to %d\n", global_tos_sip); } } } Index: acl.c =================================================================== --- acl.c (revision 8687) +++ acl.c (working copy) @@ -263,6 +263,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 8687) +++ 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 registrations/subscriptions we allow (seconds) ;minexpiry=60 ; Minimum length of registrations/subscriptions (default 60) ;defaultexpiry=120 ; Default length of incoming/outoing registration