diff -Naur asterisk-62242.orig/channels/chan_h323.c asterisk-62242.patched-9540/channels/chan_h323.c
--- asterisk-62242.orig/channels/chan_h323.c 2007-04-28 09:22:24.000000000 +0700
+++ asterisk-62242.patched-9540/channels/chan_h323.c 2007-04-28 09:30:57.000000000 +0700
@@ -150,6 +150,7 @@
static int userbyalias = 1;
static int acceptAnonymous = 1;
static int tos = 0;
+static int cos = 0;
static char secret[50];
static unsigned int unique = 0;
@@ -979,7 +980,7 @@
if (h323debug)
ast_log(LOG_DEBUG, "Created RTP channel\n");
- ast_rtp_settos(pvt->rtp, tos);
+ ast_rtp_setqos(pvt->rtp, tos, cos);
if (h323debug)
ast_log(LOG_DEBUG, "Setting NAT on RTP to %d\n", pvt->options.nat);
@@ -2858,6 +2859,7 @@
userbyalias = 1;
acceptAnonymous = 1;
tos = 0;
+ cos = 0;
/* Copy the default jb config over global_jbconf */
memcpy(&global_jbconf, &default_jbconf, sizeof(struct ast_jb_conf));
@@ -2900,20 +2902,12 @@
memcpy(&bindaddr.sin_addr, hp->h_addr, sizeof(bindaddr.sin_addr));
}
} else if (!strcasecmp(v->name, "tos")) {
- if (sscanf(v->value, "%d", &format)) {
- tos = format & 0xff;
- } else if (!strcasecmp(v->value, "lowdelay")) {
- tos = IPTOS_LOWDELAY;
- } else if (!strcasecmp(v->value, "throughput")) {
- tos = IPTOS_THROUGHPUT;
- } else if (!strcasecmp(v->value, "reliability")) {
- tos = IPTOS_RELIABILITY;
- } else if (!strcasecmp(v->value, "mincost")) {
- tos = IPTOS_MINCOST;
- } else if (!strcasecmp(v->value, "none")) {
- tos = 0;
- } else {
- ast_log(LOG_WARNING, "Invalid tos value at line %d, should be 'lowdelay', 'throughput', 'reliability', 'mincost', or 'none'\n", v->lineno);
+ if (ast_str2tos(v->value, &tos)) {
+ ast_log(LOG_WARNING, "Invalid tos value at line %d, for more info read doc/qos.tex\n", v->lineno);
+ }
+ } else if (!strcasecmp(v->name, "cos")) {
+ if (ast_str2cos(v->value, &cos)) {
+ ast_log(LOG_WARNING, "Invalid cos value at line %d, for more info read doc/qos.tex\n", v->lineno);
}
} else if (!strcasecmp(v->name, "gatekeeper")) {
if (!strcasecmp(v->value, "DISABLE")) {
diff -Naur asterisk-62242.orig/channels/chan_iax2.c asterisk-62242.patched-9540/channels/chan_iax2.c
--- asterisk-62242.orig/channels/chan_iax2.c 2007-04-28 09:22:24.000000000 +0700
+++ asterisk-62242.patched-9540/channels/chan_iax2.c 2007-04-28 09:30:57.000000000 +0700
@@ -177,6 +177,8 @@
static unsigned int tos = 0;
+static unsigned int cos = 0;
+
static int min_reg_expire;
static int max_reg_expire;
@@ -8497,7 +8499,7 @@
sin.sin_addr.s_addr = INADDR_ANY;
if (ast_netsock_find(netsock, &sin)) {
sin.sin_addr.s_addr = orig_saddr;
- sock = ast_netsock_bind(outsock, io, srcaddr, port, tos, socket_read, NULL);
+ sock = ast_netsock_bind(outsock, io, srcaddr, port, tos, cos, socket_read, NULL);
if (sock) {
sockfd = ast_netsock_sockfd(sock);
ast_netsock_unref(sock);
@@ -9152,7 +9154,13 @@
tosval = ast_variable_retrieve(cfg, "general", "tos");
if (tosval) {
if (ast_str2tos(tosval, &tos))
- ast_log(LOG_WARNING, "Invalid tos value, see doc/ip-tos.txt for more information.\n");
+ ast_log(LOG_WARNING, "Invalid tos value, see doc/qos.tex for more information.\n");
+ }
+ /* Seed initial cos value */
+ tosval = ast_variable_retrieve(cfg, "general", "cos");
+ if (tosval) {
+ if (ast_str2cos(tosval, &cos))
+ ast_log(LOG_WARNING, "Invalid cos value, see doc/qos.tex for more information.\n");
}
while(v) {
if (!strcasecmp(v->name, "bindport")){
@@ -9220,7 +9228,7 @@
if (reload) {
ast_log(LOG_NOTICE, "Ignoring bindaddr on reload\n");
} else {
- if (!(ns = ast_netsock_bind(netsock, io, v->value, portno, tos, socket_read, NULL))) {
+ if (!(ns = ast_netsock_bind(netsock, io, v->value, portno, tos, cos, socket_read, NULL))) {
ast_log(LOG_WARNING, "Unable apply binding to '%s' at line %d\n", v->value, v->lineno);
} else {
if (option_verbose > 1) {
@@ -9327,7 +9335,10 @@
ast_context_create(NULL, regcontext, "IAX2");
} else if (!strcasecmp(v->name, "tos")) {
if (ast_str2tos(v->value, &tos))
- ast_log(LOG_WARNING, "Invalid tos value at line %d, see doc/ip-tos.txt for more information.'\n", v->lineno);
+ ast_log(LOG_WARNING, "Invalid tos value at line %d, see doc/qos.tex for more information.'\n", v->lineno);
+ } else if (!strcasecmp(v->name, "cos")) {
+ if (ast_str2cos(v->value, &cos))
+ ast_log(LOG_WARNING, "Invalid cos value at line %d, see doc/qos.tex for more information.'\n", v->lineno);
} else if (!strcasecmp(v->name, "accountcode")) {
ast_copy_string(accountcode, v->value, sizeof(accountcode));
} else if (!strcasecmp(v->name, "mohinterpret")) {
@@ -9357,7 +9368,7 @@
}
if (defaultsockfd < 0) {
- if (!(ns = ast_netsock_bind(netsock, io, "0.0.0.0", portno, tos, socket_read, NULL))) {
+ if (!(ns = ast_netsock_bind(netsock, io, "0.0.0.0", portno, tos, cos, socket_read, NULL))) {
ast_log(LOG_ERROR, "Unable to create network socket: %s\n", strerror(errno));
} else {
if (option_verbose > 1)
diff -Naur asterisk-62242.orig/channels/chan_mgcp.c asterisk-62242.patched-9540/channels/chan_mgcp.c
--- asterisk-62242.orig/channels/chan_mgcp.c 2007-04-28 09:22:24.000000000 +0700
+++ asterisk-62242.patched-9540/channels/chan_mgcp.c 2007-04-28 10:16:25.000000000 +0700
@@ -71,6 +71,7 @@
#include "asterisk/app.h"
#include "asterisk/musiconhold.h"
#include "asterisk/utils.h"
+#include "asterisk/netsock.h"
#include "asterisk/causes.h"
#include "asterisk/dsp.h"
#include "asterisk/devicestate.h"
@@ -162,7 +163,9 @@
static ast_group_t cur_callergroup = 0;
static ast_group_t cur_pickupgroup = 0;
-static int tos = 0;
+static unsigned int tos = 0;
+
+static unsigned int cos = 0;
static int immediate = 0;
@@ -4129,20 +4132,11 @@
else
capability &= ~format;
} else if (!strcasecmp(v->name, "tos")) {
- if (sscanf(v->value, "%d", &format) == 1)
- tos = format & 0xff;
- else if (!strcasecmp(v->value, "lowdelay"))
- tos = IPTOS_LOWDELAY;
- else if (!strcasecmp(v->value, "throughput"))
- tos = IPTOS_THROUGHPUT;
- else if (!strcasecmp(v->value, "reliability"))
- tos = IPTOS_RELIABILITY;
- else if (!strcasecmp(v->value, "mincost"))
- tos = IPTOS_MINCOST;
- else if (!strcasecmp(v->value, "none"))
- tos = 0;
- else
- ast_log(LOG_WARNING, "Invalid tos value at line %d, should be 'lowdelay', 'throughput', 'reliability', 'mincost', or 'none'\n", v->lineno);
+ if (ast_str2tos(v->value, &tos))
+ ast_log(LOG_WARNING, "Invalid tos value at line %d, see doc/qos.tex for more information.\n", v->lineno);
+ } else if (!strcasecmp(v->name, "cos")) {
+ if (ast_str2cos(v->value, &cos))
+ ast_log(LOG_WARNING, "Invalid cos value at line %d, see doc/qos.tex for more information.\n", v->lineno);
} else if (!strcasecmp(v->name, "port")) {
if (sscanf(v->value, "%d", &ourport) == 1) {
bindaddr.sin_port = htons(ourport);
@@ -4229,10 +4223,8 @@
if (option_verbose > 1) {
ast_verbose(VERBOSE_PREFIX_2 "MGCP Listening on %s:%d\n",
ast_inet_ntoa(bindaddr.sin_addr), ntohs(bindaddr.sin_port));
- ast_verbose(VERBOSE_PREFIX_2 "Using TOS bits %d\n", tos);
}
- if (setsockopt(mgcpsock, IPPROTO_IP, IP_TOS, &tos, sizeof(tos)))
- ast_log(LOG_WARNING, "Unable to set TOS to %d\n", tos);
+ ast_netsock_set_qos(mgcpsock, tos, cos);
}
}
ast_mutex_unlock(&netlock);
diff -Naur asterisk-62242.orig/channels/chan_sip.c asterisk-62242.patched-9540/channels/chan_sip.c
--- asterisk-62242.orig/channels/chan_sip.c 2007-04-28 09:22:24.000000000 +0700
+++ asterisk-62242.patched-9540/channels/chan_sip.c 2007-04-28 09:30:57.000000000 +0700
@@ -136,6 +136,7 @@
#include "asterisk/linkedlists.h"
#include "asterisk/stringfields.h"
#include "asterisk/monitor.h"
+#include "asterisk/netsock.h"
#include "asterisk/localtime.h"
#include "asterisk/abstract_jb.h"
#include "asterisk/compiler.h"
@@ -511,6 +512,10 @@
#define DEFAULT_TOS_AUDIO 0 /*!< Audio packets should be marked as DSCP EF (Expedited Forwarding), but the default is 0 to be compatible with previous versions. */
#define DEFAULT_TOS_VIDEO 0 /*!< Video packets should be marked as DSCP AF41, but the default is 0 to be compatible with previous versions. */
#define DEFAULT_TOS_TEXT 0 /*!< Text packets should be marked as XXXX XXXX, but the default is 0 to be compatible with previous versions. */
+#define DEFAULT_COS_SIP 4
+#define DEFAULT_COS_AUDIO 5
+#define DEFAULT_COS_VIDEO 6
+#define DEFAULT_COS_TEXT 0
#define DEFAULT_ALLOW_EXT_DOM TRUE
#define DEFAULT_REALM "asterisk"
#define DEFAULT_NOTIFYRINGING TRUE
@@ -565,6 +570,10 @@
static unsigned int global_tos_audio; /*!< IP type of service for audio RTP packets */
static unsigned int global_tos_video; /*!< IP type of service for video RTP packets */
static unsigned int global_tos_text; /*!< IP type of service for text RTP packets */
+static unsigned int global_cos_sip; /*!< 802.1p class of service for SIP packets */
+static unsigned int global_cos_audio; /*!< 802.1p class of service for audio RTP packets */
+static unsigned int global_cos_video; /*!< 802.1p class of service for video RTP packets */
+static unsigned int global_cos_text; /*!< 802.1p class of service for text RTP packets */
static int compactheaders; /*!< send compact sip headers */
static int recordhistory; /*!< Record SIP history. Off by default */
static int dumphistory; /*!< Dump history to verbose before destroying SIP dialog */
@@ -4602,14 +4611,14 @@
free(p);
return NULL;
}
+ ast_rtp_setqos(p->rtp, global_tos_audio, global_cos_audio);
ast_rtp_setdtmf(p->rtp, ast_test_flag(&p->flags[0], SIP_DTMF) == SIP_DTMF_RFC2833);
ast_rtp_setdtmfcompensate(p->rtp, ast_test_flag(&p->flags[1], SIP_PAGE2_RFC2833_COMPENSATE));
- ast_rtp_settos(p->rtp, global_tos_audio);
ast_rtp_set_rtptimeout(p->rtp, global_rtptimeout);
ast_rtp_set_rtpholdtimeout(p->rtp, global_rtpholdtimeout);
ast_rtp_set_rtpkeepalive(p->rtp, global_rtpkeepalive);
if (p->vrtp) {
- ast_rtp_settos(p->vrtp, global_tos_video);
+ ast_rtp_setqos(p->vrtp, global_tos_video, global_cos_video);
ast_rtp_setdtmf(p->vrtp, 0);
ast_rtp_setdtmfcompensate(p->vrtp, 0);
ast_rtp_set_rtptimeout(p->vrtp, global_rtptimeout);
@@ -4617,12 +4626,12 @@
ast_rtp_set_rtpkeepalive(p->vrtp, global_rtpkeepalive);
}
if (p->trtp) {
- ast_rtp_settos(p->trtp, global_tos_text);
+ ast_rtp_setqos(p->trtp, global_tos_text, global_cos_text);
ast_rtp_setdtmf(p->trtp, 0);
ast_rtp_setdtmfcompensate(p->trtp, 0);
}
if (p->udptl)
- ast_udptl_settos(p->udptl, global_tos_audio);
+ ast_udptl_setqos(p->udptl, global_tos_audio, global_cos_audio);
p->maxcallbitrate = default_maxcallbitrate;
}
@@ -11026,6 +11035,11 @@
ast_cli(fd, " IP ToS RTP audio: %s\n", ast_tos2str(global_tos_audio));
ast_cli(fd, " IP ToS RTP video: %s\n", ast_tos2str(global_tos_video));
ast_cli(fd, " IP ToS RTP text: %s\n", ast_tos2str(global_tos_text));
+ ast_cli(fd, " 802.1p CoS SIP: %d\n", global_cos_sip);
+ ast_cli(fd, " 802.1p CoS RTP audio: %d\n", global_cos_audio);
+ ast_cli(fd, " 802.1p CoS RTP video: %d\n", global_cos_video);
+ ast_cli(fd, " 802.1p CoS RTP text: %d\n", global_cos_text);
+
ast_cli(fd, " T38 fax pt UDPTL: %s\n", ast_test_flag(&global_flags[1], SIP_PAGE2_T38SUPPORT_UDPTL) ? "Yes" : "No");
#ifdef WHEN_WE_HAVE_T38_FOR_OTHER_TRANSPORTS
ast_cli(fd, " T38 fax pt RTP: %s\n", ast_test_flag(&global_flags[1], SIP_PAGE2_T38SUPPORT_RTP) ? "Yes" : "No");
@@ -17022,6 +17036,11 @@
global_tos_audio = DEFAULT_TOS_AUDIO;
global_tos_video = DEFAULT_TOS_VIDEO;
global_tos_text = DEFAULT_TOS_TEXT;
+ global_cos_sip = DEFAULT_COS_SIP;
+ global_cos_audio = DEFAULT_COS_AUDIO;
+ global_cos_video = DEFAULT_COS_VIDEO;
+ global_cos_text = DEFAULT_COS_TEXT;
+
externhost[0] = '\0'; /* External host name (for behind NAT DynDNS support) */
externexpire = 0; /* Expiration for DNS re-issuing */
externrefresh = 10;
@@ -17307,16 +17326,24 @@
registry_count++;
} 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, recommended value is 'cs3'. See doc/ip-tos.txt.\n", v->lineno);
+ ast_log(LOG_WARNING, "Invalid tos_sip value at line %d, recommended value is 'cs3'. See doc/qos.tex.\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, recommended value is 'ef'. See doc/ip-tos.txt.\n", v->lineno);
+ ast_log(LOG_WARNING, "Invalid tos_audio value at line %d, recommended value is 'ef'. See doc/qos.tex.\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, recommended value is 'af41'. See doc/ip-tos.txt.\n", v->lineno);
+ ast_log(LOG_WARNING, "Invalid tos_video value at line %d, recommended value is 'af41'. See doc/qos.tex.\n", v->lineno);
} else if (!strcasecmp(v->name, "tos_text")) {
if (ast_str2tos(v->value, &global_tos_text))
- ast_log(LOG_WARNING, "Invalid tos_text value at line %d, recommended value is 'af41'. See doc/ip-tos.txt.\n", v->lineno);
+ ast_log(LOG_WARNING, "Invalid tos_text value at line %d, recommended value is 'af41'. See doc/qos.tex.\n", v->lineno);
+ } else if (!strcasecmp(v->name, "cos_sip")) {
+ ast_str2cos(v->value, &global_cos_sip);
+ } else if (!strcasecmp(v->name, "cos_audio")) {
+ ast_str2cos(v->value, &global_cos_audio);
+ } else if (!strcasecmp(v->name, "cos_video")) {
+ ast_str2cos(v->value, &global_cos_video);
+ } else if (!strcasecmp(v->name, "cos_text")) {
+ ast_str2cos(v->value, &global_cos_text);
} else if (!strcasecmp(v->name, "bindport")) {
if (sscanf(v->value, "%d", &ourport) == 1) {
bindaddr.sin_port = htons(ourport);
@@ -17484,10 +17511,8 @@
if (option_verbose > 1)
ast_verbose(VERBOSE_PREFIX_2 "SIP Listening on %s:%d\n",
ast_inet_ntoa(bindaddr.sin_addr), ntohs(bindaddr.sin_port));
- if (setsockopt(sipsock, IPPROTO_IP, IP_TOS, &global_tos_sip, sizeof(global_tos_sip)))
- ast_log(LOG_WARNING, "Unable to set SIP TOS to %s\n", ast_tos2str(global_tos_sip));
- else if (option_verbose > 1)
- ast_verbose(VERBOSE_PREFIX_2 "Using SIP TOS: %s\n", ast_tos2str(global_tos_sip));
+
+ ast_netsock_set_qos(sipsock, global_tos_sip, global_tos_sip);
}
}
}
diff -Naur asterisk-62242.orig/channels/iax2-provision.c asterisk-62242.patched-9540/channels/iax2-provision.c
--- asterisk-62242.orig/channels/iax2-provision.c 2007-04-28 09:22:24.000000000 +0700
+++ asterisk-62242.patched-9540/channels/iax2-provision.c 2007-04-28 09:30:57.000000000 +0700
@@ -332,7 +332,7 @@
ast_log(LOG_WARNING, "Ignoring invalid codec '%s' for '%s' at line %d\n", v->value, s, v->lineno);
} else if (!strcasecmp(v->name, "tos")) {
if (ast_str2tos(v->value, &cur->tos))
- ast_log(LOG_WARNING, "Invalid tos value at line %d, see doc/ip-tos.txt for more information.\n", v->lineno);
+ ast_log(LOG_WARNING, "Invalid tos value at line %d, see doc/qos.tex for more information.\n", v->lineno);
} else if (!strcasecmp(v->name, "user")) {
strncpy(cur->user, v->value, sizeof(cur->user) - 1);
if (strcmp(cur->user, v->value))
diff -Naur asterisk-62242.orig/configs/h323.conf.sample asterisk-62242.patched-9540/configs/h323.conf.sample
--- asterisk-62242.orig/configs/h323.conf.sample 2007-04-28 09:22:43.000000000 +0700
+++ asterisk-62242.patched-9540/configs/h323.conf.sample 2007-04-28 09:30:57.000000000 +0700
@@ -4,7 +4,7 @@
[general]
port = 1720
;bindaddr = 1.2.3.4 ; this SHALL contain a single, valid IP address for this machine
-;tos=lowdelay
+;tos=ef
;
; You may specify a global default AMA flag for iaxtel calls. It must be
; one of 'default', 'omit', 'billing', or 'documentation'. These flags
diff -Naur asterisk-62242.orig/configs/iax.conf.sample asterisk-62242.patched-9540/configs/iax.conf.sample
--- asterisk-62242.orig/configs/iax.conf.sample 2007-04-28 09:22:43.000000000 +0700
+++ asterisk-62242.patched-9540/configs/iax.conf.sample 2007-04-28 09:30:57.000000000 +0700
@@ -229,8 +229,9 @@
;
;authdebug=no
;
-; See doc/README.tos for a description of the tos parameters.
+; See doc/qos.tex for a description of the tos parameters.
;tos=ef
+;cos=5
;
; If regcontext is specified, Asterisk will dynamically create and destroy
; a NoOp priority 1 extension for a given peer who registers or unregisters
diff -Naur asterisk-62242.orig/configs/iaxprov.conf.sample asterisk-62242.patched-9540/configs/iaxprov.conf.sample
--- asterisk-62242.orig/configs/iaxprov.conf.sample 2007-04-28 09:22:43.000000000 +0700
+++ asterisk-62242.patched-9540/configs/iaxprov.conf.sample 2007-04-28 09:30:57.000000000 +0700
@@ -53,7 +53,7 @@
;
flags=register,heartbeat
;
-; See doc/README.tos for a description of this parameter.
+; See doc/qos.tex for a description of this parameter.
;tos=ef
;
; Example iaxy provisioning
diff -Naur asterisk-62242.orig/configs/mgcp.conf.sample asterisk-62242.patched-9540/configs/mgcp.conf.sample
--- asterisk-62242.orig/configs/mgcp.conf.sample 2007-04-28 09:22:43.000000000 +0700
+++ asterisk-62242.patched-9540/configs/mgcp.conf.sample 2007-04-28 09:30:57.000000000 +0700
@@ -5,6 +5,9 @@
;port = 2427
;bindaddr = 0.0.0.0
+; See doc/qos.tex for a description of the tos parameters.
+;tos=ef
+
;------------------------------ JITTER BUFFER CONFIGURATION --------------------------
; jbenable = yes ; Enables the use of a jitterbuffer on the receiving side of a
; MGCP channel. Defaults to "no". An enabled jitterbuffer will
diff -Naur asterisk-62242.orig/configs/sip.conf.sample asterisk-62242.patched-9540/configs/sip.conf.sample
--- asterisk-62242.orig/configs/sip.conf.sample 2007-04-28 09:22:43.000000000 +0700
+++ asterisk-62242.patched-9540/configs/sip.conf.sample 2007-04-28 09:30:57.000000000 +0700
@@ -57,10 +57,16 @@
; and multiline formatted headers for strict
; SIP compatibility (defaults to "no")
-; See doc/README.tos for a description of these parameters.
+; See doc/qos.tex for a description of these parameters.
;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.
+;tos_text=af41 ; Sets TOS for RTP text packets.
+
+;cos_sip=4 ; Sets CoS for SIP packets.
+;cos_audio=6 ; Sets CoS for RTP audio packets.
+;cos_video=5 ; Sets CoS for RTP video packets.
+;cos_text=0 ; Sets CoS for RTP text packets.
;maxexpiry=3600 ; Maximum allowed time of incoming registrations
; and subscriptions (seconds)
diff -Naur asterisk-62242.orig/contrib/scripts/vlancos asterisk-62242.patched-9540/contrib/scripts/vlancos
--- asterisk-62242.orig/contrib/scripts/vlancos 1970-01-01 06:00:00.000000000 +0600
+++ asterisk-62242.patched-9540/contrib/scripts/vlancos 2007-04-28 09:30:57.000000000 +0700
@@ -0,0 +1 @@
+
diff -Naur asterisk-62242.orig/doc/asterisk.tex asterisk-62242.patched-9540/doc/asterisk.tex
--- asterisk-62242.orig/doc/asterisk.tex 2007-04-28 09:22:31.000000000 +0700
+++ asterisk-62242.patched-9540/doc/asterisk.tex 2007-04-28 09:30:57.000000000 +0700
@@ -44,8 +44,8 @@
\input{cliprompt.tex}
\subsection{Extensions}
\input{extensions.tex}
- \subsection{IP Type of Service}
- \input{ip-tos.tex}
+ \subsection{IP Quality of Service}
+ \input{qos.tex}
\subsection{MP3 Support}
\input{mp3.tex}
\subsection{ICES}
diff -Naur asterisk-62242.orig/doc/ip-tos.tex asterisk-62242.patched-9540/doc/ip-tos.tex
--- asterisk-62242.orig/doc/ip-tos.tex 2007-04-28 09:22:31.000000000 +0700
+++ asterisk-62242.patched-9540/doc/ip-tos.tex 1970-01-01 06:00:00.000000000 +0600
@@ -1,81 +0,0 @@
-\subsubsection{Introduction}
-
-Asterisk can set the Type of Service (TOS) byte on outgoing IP packets
-for various protocols. The TOS byte is used by the network to provide
-some level of Quality of Service (QoS) even if the network is
-congested with other traffic.
-
-\subsubsection{SIP}
-
-In sip.conf, there are three parameters that control the TOS settings:
-"tos\_sip", "tos\_audio", and "tos\_video". tos\_sip controls what TOS SIP call
-signalling packets are set to. tos\_audio controls what TOS RTP audio
-packets are set to. tos\_video controls what TOS RTP video packets are
-set to.
-
-There is a "tos" parameter that is supported for backwards
-compatibility. The tos parameter should be avoided in sip.conf
-because it sets all three tos settings in sip.conf to the same value.
-
-\subsubsection{IAX2}
-In iax.conf, there is a "tos" parameter that sets the global default TOS
-for IAX packets generated by chan\_iax2. Since IAX connections combine
-signalling, audio, and video into one UDP stream, it is not possible
-to set the TOS separately for the different types of traffic.
-
-In iaxprov.conf, there is a "tos" parameter that tells the IAXy what TOS
-to set on packets it generates. As with the parameter in iax.conf,
-IAX packets generated by an IAXy cannot have different TOS settings
-based upon the type of packet. However different IAXy devices can
-have different TOS settings.
-
-The allowable values for any of the tos* parameters are:
-CS0, CS1, CS2, CS3, CS4, CS5, CS6, CS7, AF11, AF12, AF13,
-AF21, AF22, AF23, AF31, AF32, AF33, AF41, AF42, AF43 and
-ef (expedited forwarding),
-
-The tos* parameters also take numeric values.
-
-The lowdelay, throughput, reliability, mincost, and none values are
-deprecated because they set the IP TOS using the outdated "IP
-precedence" model as defined in RFC 791 and RFC 1349. They still
-work in this version of Asterisk, but will be removed in future releases.
-
-\begin{verbatim}
-===========================================
-Configuration Parameter Recommended
-File Setting
--------------------------------------------
-sip.conf tos\_sip cs3
-sip.conf tos\_audio ef
-sip.conf tos\_video af41
--------------------------------------------
-iax.conf tos ef
--------------------------------------------
-iaxprov.conf tos ef
-===========================================
-\end{verbatim}
-
-\subsubsection{Reference}
-
-RFC 2474 - "Definition of the Differentiated Services Field
-(DS field) in the IPv4 and IPv6 Headers", Nichols, K., et al,
-December 1998.
-
-IANA Assignments, DSCP registry
-Differentiated Services Field Codepoints
-http://www.iana.org/assignments/dscp-registry
-
-To get the most out of setting the TOS on packets generated by
-Asterisk, you will need to ensure that your network handles packets
-with a TOS properly. For Cisco devices, see the previously mentioned
-"Enterprise QoS Solution Reference Network Design Guide". For Linux
-systems see the "Linux Advanced Routing \& Traffic Control HOWTO" at
-.
-
-For more information on Quality of
-Service for VoIP networks see the "Enterprise QoS Solution Reference
-Network Design Guide" version 3.3 from Cisco at:
-
-
-
diff -Naur asterisk-62242.orig/doc/qos.tex asterisk-62242.patched-9540/doc/qos.tex
--- asterisk-62242.orig/doc/qos.tex 1970-01-01 06:00:00.000000000 +0600
+++ asterisk-62242.patched-9540/doc/qos.tex 2007-04-28 09:30:57.000000000 +0700
@@ -0,0 +1,119 @@
+\subsubsection{Introduction}
+
+Asterisk can set the Type of Service (TOS) byte on outgoing IP packets
+for various protocols. The TOS byte is used by the network to provide
+some level of Quality of Service (QoS) even if the network is
+congested with other traffic.
+
+Also asterisk running on Linux can set 802.1p CoS marks in VLAN packets
+for all used VoIP protocols. It is useful when you are working in switched
+enviropment. For maping skb->priority and VLAN CoS mark you need to use
+command "vconfig set_egress_map [vlan-device] [skb-priority] [vlan-qos]".
+
+\subsubsection{SIP}
+
+In sip.conf, there are three parameters that control the TOS settings:
+"tos\_sip", "tos\_audio" and "tos\_video". tos\_sip controls what TOS SIP
+call signalling packets are set to. tos\_audio controls what TOS RTP audio
+packets are set to. tos\_video controls what TOS RTP video packets are
+set to.
+
+There are four parameters to control 802.1p CoS: "cos\_sip", "cos\_audio",
+"cos\_video" and "cos\_text". It's behavior the same as writen above.
+
+There is a "tos" parameter that is supported for backwards
+compatibility. The tos parameter should be avoided in sip.conf
+because it sets all three tos settings in sip.conf to the same value.
+
+\subsubsection{IAX2}
+In iax.conf, there is a "tos" parameter that sets the global default TOS
+for IAX packets generated by chan\_iax2. Since IAX connections combine
+signalling, audio, and video into one UDP stream, it is not possible
+to set the TOS separately for the different types of traffic.
+
+In iaxprov.conf, there is a "tos" parameter that tells the IAXy what TOS
+to set on packets it generates. As with the parameter in iax.conf,
+IAX packets generated by an IAXy cannot have different TOS settings
+based upon the type of packet. However different IAXy devices can
+have different TOS settings.
+
+\subsubsection{H.323}
+Also support TOS and CoS.
+
+\subsubsection{MGCP}
+Also support TOS and CoS.
+
+\subsubsection{IP TOS values}
+
+The allowable values for any of the tos* parameters are:
+CS0, CS1, CS2, CS3, CS4, CS5, CS6, CS7, AF11, AF12, AF13,
+AF21, AF22, AF23, AF31, AF32, AF33, AF41, AF42, AF43 and
+ef (expedited forwarding),
+
+The tos* parameters also take numeric values.
+
+The lowdelay, throughput, reliability, mincost, and none values are
+deprecated because they set the IP TOS using the outdated "IP
+precedence" model as defined in RFC 791 and RFC 1349. They still
+work in this version of Asterisk, but will be removed in future releases.
+
+\subsubsection{802.1p CoS values}
+
+As 802.1p uses 3 bites from VLAN header, there are parameter can take
+integer values from 0 to 7.
+
+
+\begin{verbatim}
+===========================================
+Configuration Parameter Recommended
+File Setting
+-------------------------------------------
+sip.conf tos\_sip cs3
+sip.conf tos\_audio ef
+sip.conf tos\_video af41
+sip.conf tos\_text af41
+sip.conf cos\_sip 4
+sip.conf cos\_audio 6
+sip.conf cos\_video 5
+sip.conf cos\_text 0
+-------------------------------------------
+iax.conf tos ef
+iax.conf cos 6
+-------------------------------------------
+iaxprov.conf tos ef
+-------------------------------------------
+mgcp.conf tos ef
+mgcp.conf cos 6
+-------------------------------------------
+h323.conf tos ef
+h323.conf cos 6
+===========================================
+\end{verbatim}
+
+\subsubsection{Reference}
+
+IEEE 802.1Q Standard:
+http://standards.ieee.org/getieee802/download/802.1Q-1998.pdf
+Related protocols: IEEE 802.3, 802.2, 802.1D, 802.1Q
+
+RFC 2474 - "Definition of the Differentiated Services Field
+(DS field) in the IPv4 and IPv6 Headers", Nichols, K., et al,
+December 1998.
+
+IANA Assignments, DSCP registry
+Differentiated Services Field Codepoints
+http://www.iana.org/assignments/dscp-registry
+
+To get the most out of setting the TOS on packets generated by
+Asterisk, you will need to ensure that your network handles packets
+with a TOS properly. For Cisco devices, see the previously mentioned
+"Enterprise QoS Solution Reference Network Design Guide". For Linux
+systems see the "Linux Advanced Routing \& Traffic Control HOWTO" at
+.
+
+For more information on Quality of
+Service for VoIP networks see the "Enterprise QoS Solution Reference
+Network Design Guide" version 3.3 from Cisco at:
+
+
+
diff -Naur asterisk-62242.orig/include/asterisk/acl.h asterisk-62242.patched-9540/include/asterisk/acl.h
--- asterisk-62242.orig/include/asterisk/acl.h 2007-04-28 09:22:33.000000000 +0700
+++ asterisk-62242.patched-9540/include/asterisk/acl.h 2007-04-28 09:30:57.000000000 +0700
@@ -57,6 +57,9 @@
int ast_ouraddrfor(struct in_addr *them, struct in_addr *us);
int ast_find_ourip(struct in_addr *ourip, struct sockaddr_in bindaddr);
+
+int ast_str2cos(const char *value, unsigned int *cos);
+
int ast_str2tos(const char *value, unsigned int *tos);
const char *ast_tos2str(unsigned int tos);
diff -Naur asterisk-62242.orig/include/asterisk/netsock.h asterisk-62242.patched-9540/include/asterisk/netsock.h
--- asterisk-62242.orig/include/asterisk/netsock.h 2007-04-28 09:22:34.000000000 +0700
+++ asterisk-62242.patched-9540/include/asterisk/netsock.h 2007-04-28 09:43:33.000000000 +0700
@@ -41,10 +41,10 @@
int ast_netsock_init(struct ast_netsock_list *list);
struct ast_netsock *ast_netsock_bind(struct ast_netsock_list *list, struct io_context *ioc,
- const char *bindinfo, int defaultport, int tos, ast_io_cb callback, void *data);
+ const char *bindinfo, int defaultport, int tos, int cos, ast_io_cb callback, void *data);
struct ast_netsock *ast_netsock_bindaddr(struct ast_netsock_list *list, struct io_context *ioc,
- struct sockaddr_in *bindaddr, int tos, ast_io_cb callback, void *data);
+ struct sockaddr_in *bindaddr, int tos, int cos, ast_io_cb callback, void *data);
int ast_netsock_free(struct ast_netsock_list *list, struct ast_netsock *netsock);
@@ -53,6 +53,8 @@
struct ast_netsock *ast_netsock_find(struct ast_netsock_list *list,
struct sockaddr_in *sa);
+int ast_netsock_set_qos(int netsocket, int tos, int cos);
+
int ast_netsock_sockfd(const struct ast_netsock *ns);
const struct sockaddr_in *ast_netsock_boundaddr(const struct ast_netsock *ns);
diff -Naur asterisk-62242.orig/include/asterisk/rtp.h asterisk-62242.patched-9540/include/asterisk/rtp.h
--- asterisk-62242.orig/include/asterisk/rtp.h 2007-04-28 09:22:33.000000000 +0700
+++ asterisk-62242.patched-9540/include/asterisk/rtp.h 2007-04-28 09:30:57.000000000 +0700
@@ -168,7 +168,7 @@
int ast_rtp_sendcng(struct ast_rtp *rtp, int level);
-int ast_rtp_settos(struct ast_rtp *rtp, int tos);
+int ast_rtp_setqos(struct ast_rtp *rtp, int tos, int cos);
/*! \brief Setting RTP payload types from lines in a SDP description: */
void ast_rtp_pt_clear(struct ast_rtp* rtp);
diff -Naur asterisk-62242.orig/include/asterisk/udptl.h asterisk-62242.patched-9540/include/asterisk/udptl.h
--- asterisk-62242.orig/include/asterisk/udptl.h 2007-04-28 09:22:33.000000000 +0700
+++ asterisk-62242.patched-9540/include/asterisk/udptl.h 2007-04-28 09:30:57.000000000 +0700
@@ -73,7 +73,7 @@
int ast_udptl_fd(struct ast_udptl *udptl);
-int ast_udptl_settos(struct ast_udptl *udptl, int tos);
+int ast_udptl_setqos(struct ast_udptl *udptl, int tos, int cos);
void ast_udptl_set_m_type(struct ast_udptl* udptl, int pt);
diff -Naur asterisk-62242.orig/main/acl.c asterisk-62242.patched-9540/main/acl.c
--- asterisk-62242.orig/main/acl.c 2007-04-28 09:22:42.000000000 +0700
+++ asterisk-62242.patched-9540/main/acl.c 2007-04-28 09:30:57.000000000 +0700
@@ -278,6 +278,20 @@
{ "EF", 0x2E },
};
+int ast_str2cos(const char *value, unsigned int *cos)
+{
+ int fval;
+
+ if (sscanf(value, "%d", &fval) == 1) {
+ if (fval < 8) {
+ *cos = fval;
+ return 0;
+ }
+ }
+
+ return -1;
+}
+
int ast_str2tos(const char *value, unsigned int *tos)
{
int fval;
diff -Naur asterisk-62242.orig/main/netsock.c asterisk-62242.patched-9540/main/netsock.c
--- asterisk-62242.orig/main/netsock.c 2007-04-28 09:22:42.000000000 +0700
+++ asterisk-62242.patched-9540/main/netsock.c 2007-04-28 09:45:06.000000000 +0700
@@ -119,7 +119,7 @@
return sock;
}
-struct ast_netsock *ast_netsock_bindaddr(struct ast_netsock_list *list, struct io_context *ioc, struct sockaddr_in *bindaddr, int tos, ast_io_cb callback, void *data)
+struct ast_netsock *ast_netsock_bindaddr(struct ast_netsock_list *list, struct io_context *ioc, struct sockaddr_in *bindaddr, int tos, int cos, ast_io_cb callback, void *data)
{
int netsocket = -1;
int *ioref;
@@ -142,12 +142,9 @@
close(netsocket);
return NULL;
}
- if (option_verbose > 1)
- ast_verbose(VERBOSE_PREFIX_2 "Using TOS bits %d\n", tos);
-
- if (setsockopt(netsocket, IPPROTO_IP, IP_TOS, &tos, sizeof(tos)))
- ast_log(LOG_WARNING, "Unable to set TOS to %d\n", tos);
+ ast_netsock_set_qos(netsocket, tos, cos);
+
ast_enable_packet_fragmentation(netsocket);
if (!(ns = ast_calloc(1, sizeof(struct ast_netsock)))) {
@@ -172,7 +169,32 @@
return ns;
}
-struct ast_netsock *ast_netsock_bind(struct ast_netsock_list *list, struct io_context *ioc, const char *bindinfo, int defaultport, int tos, ast_io_cb callback, void *data)
+int ast_netsock_set_qos(int netsocket, int tos, int cos)
+{
+ int res;
+
+ if ((res = setsockopt(netsocket, IPPROTO_IP, IP_TOS, &tos, sizeof(tos))))
+ ast_log(LOG_WARNING, "Unable to set TOS to %d\n", tos);
+ else {
+ if (option_verbose > 1)
+ ast_verbose(VERBOSE_PREFIX_2 "Using TOS bits %d\n", tos);
+ }
+
+#if defined(linux)
+ if (setsockopt(netsocket, SOL_SOCKET, SO_PRIORITY, &cos, sizeof(cos)))
+ ast_log(LOG_WARNING, "Unable to set CoS to %d\n", cos);
+ else
+ {
+ if (option_verbose > 1)
+ ast_verbose(VERBOSE_PREFIX_2 "Using CoS mark %d\n", tos);
+ }
+#endif
+
+ return res;
+}
+
+
+struct ast_netsock *ast_netsock_bind(struct ast_netsock_list *list, struct io_context *ioc, const char *bindinfo, int defaultport, int tos, int cos, ast_io_cb callback, void *data)
{
struct sockaddr_in sin;
char *tmp;
@@ -193,7 +215,7 @@
inet_aton(host, &sin.sin_addr);
- return ast_netsock_bindaddr(list, ioc, &sin, tos, callback, data);
+ return ast_netsock_bindaddr(list, ioc, &sin, tos, cos, callback, data);
}
int ast_netsock_sockfd(const struct ast_netsock *ns)
diff -Naur asterisk-62242.orig/main/rtp.c asterisk-62242.patched-9540/main/rtp.c
--- asterisk-62242.orig/main/rtp.c 2007-04-28 09:22:42.000000000 +0700
+++ asterisk-62242.patched-9540/main/rtp.c 2007-04-28 09:30:57.000000000 +0700
@@ -53,6 +53,7 @@
#include "asterisk/config.h"
#include "asterisk/lock.h"
#include "asterisk/utils.h"
+#include "asterisk/netsock.h"
#include "asterisk/cli.h"
#include "asterisk/unaligned.h"
#include "asterisk/utils.h"
@@ -2040,13 +2041,9 @@
return ast_rtp_new_with_bindaddr(sched, io, rtcpenable, callbackmode, ia);
}
-int ast_rtp_settos(struct ast_rtp *rtp, int tos)
+int ast_rtp_setqos(struct ast_rtp *rtp, int tos, int cos)
{
- int res;
-
- if ((res = setsockopt(rtp->s, IPPROTO_IP, IP_TOS, &tos, sizeof(tos))))
- ast_log(LOG_WARNING, "Unable to set TOS to %d\n", tos);
- return res;
+ return ast_netsock_set_qos(rtp->s, tos, cos);
}
void ast_rtp_set_peer(struct ast_rtp *rtp, struct sockaddr_in *them)
diff -Naur asterisk-62242.orig/main/udptl.c asterisk-62242.patched-9540/main/udptl.c
--- asterisk-62242.orig/main/udptl.c 2007-04-28 09:22:42.000000000 +0700
+++ asterisk-62242.patched-9540/main/udptl.c 2007-04-28 09:30:57.000000000 +0700
@@ -73,6 +73,7 @@
#include "asterisk/config.h"
#include "asterisk/lock.h"
#include "asterisk/utils.h"
+#include "asterisk/netsock.h"
#include "asterisk/cli.h"
#include "asterisk/unaligned.h"
#include "asterisk/utils.h"
@@ -872,13 +873,9 @@
return ast_udptl_new_with_bindaddr(sched, io, callbackmode, ia);
}
-int ast_udptl_settos(struct ast_udptl *udptl, int tos)
+int ast_udptl_setqos(struct ast_udptl *udptl, int tos, int cos)
{
- int res;
-
- if ((res = setsockopt(udptl->fd, IPPROTO_IP, IP_TOS, &tos, sizeof(tos))))
- ast_log(LOG_WARNING, "UDPTL unable to set TOS to %d\n", tos);
- return res;
+ return ast_netsock_set_qos(udptl->fd, tos, cos);
}
void ast_udptl_set_peer(struct ast_udptl *udptl, struct sockaddr_in *them)
diff -Naur asterisk-62242.orig/pbx/pbx_dundi.c asterisk-62242.patched-9540/pbx/pbx_dundi.c
--- asterisk-62242.orig/pbx/pbx_dundi.c 2007-04-28 09:22:19.000000000 +0700
+++ asterisk-62242.patched-9540/pbx/pbx_dundi.c 2007-04-28 09:30:57.000000000 +0700
@@ -68,6 +68,7 @@
#include "asterisk/sched.h"
#include "asterisk/io.h"
#include "asterisk/utils.h"
+#include "asterisk/netsock.h"
#include "asterisk/crypto.h"
#include "asterisk/astdb.h"
#include "asterisk/acl.h"
@@ -4573,12 +4574,8 @@
ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port), strerror(errno));
return AST_MODULE_LOAD_FAILURE;
}
-
- if (option_verbose > 1)
- ast_verbose(VERBOSE_PREFIX_2 "Using TOS bits %d\n", tos);
-
- if (setsockopt(netsocket, IPPROTO_IP, IP_TOS, &tos, sizeof(tos)))
- ast_log(LOG_WARNING, "Unable to set TOS to %d\n", tos);
+
+ ast_netsock_set_qos(netsocket, tos, 0);
if (start_network_thread()) {
ast_log(LOG_ERROR, "Unable to start network thread\n");