diff options
author | oej <oej@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-12-16 10:51:53 +0000 |
---|---|---|
committer | oej <oej@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-12-16 10:51:53 +0000 |
commit | b9b03966fb8526497e726b00cf53252268b9fcef (patch) | |
tree | 1737bbf754fc80795d7da8a7e44ef757640a050f /channels | |
parent | 85bbad5334db6eecb6024f1e2b8316a18acfdd74 (diff) |
HUGE improvements to QoS/CoS handling by IgorG
- Refer to the proper documentation
- Implement separate signalling/media QoS/CoS in many channels using RTP
- Improve warnings and verbose messages
- Deprecate some old settings
Minor modifications by me, a big effort from IgorG.
Thanks!
Reported by: IgorG
Patches:
qoscleanup-89394-4-trunk.patch uploaded by IgorG (license 20)
Tested by: IgorG
(closes issue #11145)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@93163 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels')
-rw-r--r-- | channels/chan_h323.c | 20 | ||||
-rw-r--r-- | channels/chan_iax2.c | 8 | ||||
-rw-r--r-- | channels/chan_mgcp.c | 19 | ||||
-rw-r--r-- | channels/chan_sip.c | 30 | ||||
-rw-r--r-- | channels/chan_skinny.c | 29 | ||||
-rw-r--r-- | channels/chan_unistim.c | 24 | ||||
-rw-r--r-- | channels/iax2-provision.c | 2 |
7 files changed, 102 insertions, 30 deletions
diff --git a/channels/chan_h323.c b/channels/chan_h323.c index f6f138c87..87fbcd786 100644 --- a/channels/chan_h323.c +++ b/channels/chan_h323.c @@ -970,7 +970,7 @@ static int __oh323_rtp_create(struct oh323_pvt *pvt) if (h323debug) ast_debug(1, "Created RTP channel\n"); - ast_rtp_setqos(pvt->rtp, tos, cos); + ast_rtp_setqos(pvt->rtp, tos, cos, "H323 RTP"); if (h323debug) ast_debug(1, "Setting NAT on RTP to %d\n", pvt->options.nat); @@ -2904,13 +2904,23 @@ static int reload_config(int is_reload) } else { memcpy(&bindaddr.sin_addr, hp->h_addr, sizeof(bindaddr.sin_addr)); } - } else if (!strcasecmp(v->name, "tos")) { + } else if (!strcasecmp(v->name, "tos")) { /* Needs to be removed in next release */ + ast_log(LOG_WARNING, "The \"tos\" setting is deprecated in this version of Asterisk. Please change to \"tos_audio\".\n"); 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); + ast_log(LOG_WARNING, "Invalid tos_audio value at line %d, refer to QoS documentation\n", v->lineno); } - } else if (!strcasecmp(v->name, "cos")) { + } else if (!strcasecmp(v->name, "tos_audio")) { + if (ast_str2tos(v->value, &tos)) { + ast_log(LOG_WARNING, "Invalid tos_audio value at line %d, refer to QoS documentation\n", v->lineno); + } + } else if (!strcasecmp(v->name, "cos")) { + ast_log(LOG_WARNING, "The \"cos\" setting is deprecated in this version of Asterisk. Please change to \"cos_audio\".\n"); + if (ast_str2cos(v->value, &cos)) { + ast_log(LOG_WARNING, "Invalid cos_audio value at line %d, refer to QoS documentation\n", v->lineno); + } + } else if (!strcasecmp(v->name, "cos_audio")) { 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); + ast_log(LOG_WARNING, "Invalid cos_audio value at line %d, refer to QoS documentation\n", v->lineno); } } else if (!strcasecmp(v->name, "gatekeeper")) { if (!strcasecmp(v->value, "DISABLE")) { diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index 3288800e7..b1205ef92 100644 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -10422,13 +10422,13 @@ static int set_config(char *config_file, int reload) tosval = ast_variable_retrieve(cfg, "general", "tos"); if (tosval) { if (ast_str2tos(tosval, &tos)) - ast_log(LOG_WARNING, "Invalid tos value, see doc/qos.tex for more information.\n"); + ast_log(LOG_WARNING, "Invalid tos value, refer to QoS documentation\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"); + ast_log(LOG_WARNING, "Invalid cos value, refer to QoS documentation\n"); } while(v) { if (!strcasecmp(v->name, "bindport")){ @@ -10601,10 +10601,10 @@ static int set_config(char *config_file, int reload) 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/qos.tex for more information.'\n", v->lineno); + ast_log(LOG_WARNING, "Invalid tos value at line %d, refer to QoS documentation\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); + ast_log(LOG_WARNING, "Invalid cos value at line %d, refer to QoS documentation\n", v->lineno); } else if (!strcasecmp(v->name, "accountcode")) { ast_copy_string(accountcode, v->value, sizeof(accountcode)); } else if (!strcasecmp(v->name, "mohinterpret")) { diff --git a/channels/chan_mgcp.c b/channels/chan_mgcp.c index ae7a3ed14..bd2c66d62 100644 --- a/channels/chan_mgcp.c +++ b/channels/chan_mgcp.c @@ -153,8 +153,9 @@ static ast_group_t cur_callergroup = 0; static ast_group_t cur_pickupgroup = 0; static unsigned int tos = 0; - +static unsigned int tos_audio = 0; static unsigned int cos = 0; +static unsigned int cos_audio = 0; static int immediate = 0; @@ -2591,8 +2592,10 @@ static void start_rtp(struct mgcp_subchannel *sub) sub->rtp = ast_rtp_new_with_bindaddr(sched, io, 1, 0, bindaddr.sin_addr); if (sub->rtp && sub->owner) ast_channel_set_fd(sub->owner, 0, ast_rtp_fd(sub->rtp)); - if (sub->rtp) + if (sub->rtp) { + ast_rtp_setqos(sub->rtp, tos_audio, cos_audio, "MGCP RTP"); ast_rtp_setnat(sub->rtp, sub->nat); + } #if 0 ast_rtp_set_callback(p->rtp, rtpready); ast_rtp_set_data(p->rtp, p); @@ -4097,10 +4100,16 @@ static int reload_config(int reload) capability &= ~format; } else if (!strcasecmp(v->name, "tos")) { 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); + ast_log(LOG_WARNING, "Invalid tos value at line %d, refer to QoS documentation\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, refer to QoS documentation\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); + ast_log(LOG_WARNING, "Invalid cos value at line %d, refer to QoS documentation\n", v->lineno); + } else if (!strcasecmp(v->name, "cos_audio")) { + if (ast_str2cos(v->value, &cos_audio)) + ast_log(LOG_WARNING, "Invalid cos_audio value at line %d, refer to QoS documentation\n", v->lineno); } else if (!strcasecmp(v->name, "port")) { if (sscanf(v->value, "%d", &ourport) == 1) { bindaddr.sin_port = htons(ourport); @@ -4184,7 +4193,7 @@ static int reload_config(int reload) } else { ast_verb(2, "MGCP Listening on %s:%d\n", ast_inet_ntoa(bindaddr.sin_addr), ntohs(bindaddr.sin_port)); - ast_netsock_set_qos(mgcpsock, tos, cos); + ast_netsock_set_qos(mgcpsock, tos, cos, "MGCP"); } } ast_mutex_unlock(&netlock); diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 57b17f198..6e5a3b17a 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -545,7 +545,7 @@ static const struct cfsip_options { #define DEFAULT_COS_SIP 4 #define DEFAULT_COS_AUDIO 5 #define DEFAULT_COS_VIDEO 6 -#define DEFAULT_COS_TEXT 0 +#define DEFAULT_COS_TEXT 5 #define DEFAULT_ALLOW_EXT_DOM TRUE #define DEFAULT_REALM "asterisk" #define DEFAULT_NOTIFYRINGING TRUE @@ -5130,14 +5130,14 @@ static struct sip_pvt *sip_alloc(ast_string_field callid, struct sockaddr_in *si ast_free(p); return NULL; } - ast_rtp_setqos(p->rtp, global_tos_audio, global_cos_audio); + ast_rtp_setqos(p->rtp, global_tos_audio, global_cos_audio, "SIP RTP"); 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_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_setqos(p->vrtp, global_tos_video, global_cos_video); + ast_rtp_setqos(p->vrtp, global_tos_video, global_cos_video, "SIP VRTP"); ast_rtp_setdtmf(p->vrtp, 0); ast_rtp_setdtmfcompensate(p->vrtp, 0); ast_rtp_set_rtptimeout(p->vrtp, global_rtptimeout); @@ -5145,7 +5145,7 @@ static struct sip_pvt *sip_alloc(ast_string_field callid, struct sockaddr_in *si ast_rtp_set_rtpkeepalive(p->vrtp, global_rtpkeepalive); } if (p->trtp) { - ast_rtp_setqos(p->trtp, global_tos_text, global_cos_text); + ast_rtp_setqos(p->trtp, global_tos_text, global_cos_text, "SIP TRTP"); ast_rtp_setdtmf(p->trtp, 0); ast_rtp_setdtmfcompensate(p->trtp, 0); } @@ -18575,24 +18575,28 @@ static int reload_config(enum channelreloadreason reason) 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/qos.tex.\n", v->lineno); + ast_log(LOG_WARNING, "Invalid tos_sip value at line %d, refer to QoS documentation\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/qos.tex.\n", v->lineno); + ast_log(LOG_WARNING, "Invalid tos_audio value at line %d, refer to QoS documentation\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/qos.tex.\n", v->lineno); + ast_log(LOG_WARNING, "Invalid tos_video value at line %d, refer to QoS documentation\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/qos.tex.\n", v->lineno); + ast_log(LOG_WARNING, "Invalid tos_text value at line %d, refer to QoS documentation\n", v->lineno); } else if (!strcasecmp(v->name, "cos_sip")) { - ast_str2cos(v->value, &global_cos_sip); + if (ast_str2cos(v->value, &global_cos_sip)) + ast_log(LOG_WARNING, "Invalid cos_sip value at line %d, refer to QoS documentation\n", v->lineno); } else if (!strcasecmp(v->name, "cos_audio")) { - ast_str2cos(v->value, &global_cos_audio); + if (ast_str2cos(v->value, &global_cos_audio)) + ast_log(LOG_WARNING, "Invalid cos_audio value at line %d, refer to QoS documentation\n", v->lineno); } else if (!strcasecmp(v->name, "cos_video")) { - ast_str2cos(v->value, &global_cos_video); + if (ast_str2cos(v->value, &global_cos_video)) + ast_log(LOG_WARNING, "Invalid cos_video value at line %d, refer to QoS documentation\n", v->lineno); } else if (!strcasecmp(v->name, "cos_text")) { - ast_str2cos(v->value, &global_cos_text); + if (ast_str2cos(v->value, &global_cos_text)) + ast_log(LOG_WARNING, "Invalid cos_text value at line %d, refer to QoS documentation\n", v->lineno); } else if (!strcasecmp(v->name, "bindport")) { int i; if (sscanf(v->value, "%d", &i) == 1) { @@ -18761,7 +18765,7 @@ static int reload_config(enum channelreloadreason reason) } else { ast_verb(2, "SIP Listening on %s:%d\n", ast_inet_ntoa(bindaddr.sin_addr), ntohs(bindaddr.sin_port)); - ast_netsock_set_qos(sipsock, global_tos_sip, global_cos_sip); + ast_netsock_set_qos(sipsock, global_tos_sip, global_cos_sip, "SIP"); } } } diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c index 5c821e183..6c526d461 100644 --- a/channels/chan_skinny.c +++ b/channels/chan_skinny.c @@ -50,6 +50,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/sched.h" #include "asterisk/io.h" #include "asterisk/rtp.h" +#include "asterisk/netsock.h" #include "asterisk/acl.h" #include "asterisk/callerid.h" #include "asterisk/cli.h" @@ -90,6 +91,13 @@ enum skinny_codecs { #define DEFAULT_SKINNY_BACKLOG 2 #define SKINNY_MAX_PACKET 1000 +static unsigned int tos = 0; +static unsigned int tos_audio = 0; +static unsigned int tos_video = 0; +static unsigned int cos = 0; +static unsigned int cos_audio = 0; +static unsigned int cos_video = 0; + static int keep_alive = 120; static char vmexten[AST_MAX_EXTENSION]; /* Voicemail pilot number */ static char used_context[AST_MAX_EXTENSION]; /* Voicemail pilot number */ @@ -2976,9 +2984,11 @@ static void start_rtp(struct skinny_subchannel *sub) ast_channel_set_fd(sub->owner, 3, ast_rtcp_fd(sub->vrtp)); } if (sub->rtp) { + ast_rtp_setqos(sub->rtp, tos_audio, cos_audio, "Skinny RTP"); ast_rtp_setnat(sub->rtp, l->nat); } if (sub->vrtp) { + ast_rtp_setqos(sub->vrtp, tos_video, cos_video, "Skinny VRTP"); ast_rtp_setnat(sub->vrtp, l->nat); } /* Set Frame packetization */ @@ -5516,6 +5526,24 @@ static int reload_config(void) ast_copy_string(regcontext, v->value, sizeof(regcontext)); } else if (!strcasecmp(v->name, "dateformat")) { memcpy(date_format, v->value, sizeof(date_format)); + } else if (!strcasecmp(v->name, "tos")) { + if (ast_str2tos(v->value, &tos)) + ast_log(LOG_WARNING, "Invalid tos value at line %d, refer to QoS documentation\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, refer to QoS documentation\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, refer to QoS documentation\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, refer to QoS documentation\n", v->lineno); + } else if (!strcasecmp(v->name, "cos_audio")) { + if (ast_str2cos(v->value, &cos_audio)) + ast_log(LOG_WARNING, "Invalid cos_audio value at line %d, refer to QoS documentation\n", v->lineno); + } else if (!strcasecmp(v->name, "cos_video")) { + if (ast_str2cos(v->value, &cos_video)) + ast_log(LOG_WARNING, "Invalid cos_video value at line %d, refer to QoS documentation\n", v->lineno); } else if (!strcasecmp(v->name, "allow")) { ast_parse_allow_disallow(&default_prefs, &default_capability, v->value, 1); } else if (!strcasecmp(v->name, "disallow")) { @@ -5604,6 +5632,7 @@ static int reload_config(void) } ast_verb(2, "Skinny listening on %s:%d\n", ast_inet_ntoa(bindaddr.sin_addr), ntohs(bindaddr.sin_port)); + ast_netsock_set_qos(skinnysock, tos, cos, "Skinny"); ast_pthread_create_background(&accept_t,NULL, accept_thread, NULL); } } diff --git a/channels/chan_unistim.c b/channels/chan_unistim.c index 9c1a360ad..d4cb0f347 100644 --- a/channels/chan_unistim.c +++ b/channels/chan_unistim.c @@ -59,6 +59,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/sched.h" #include "asterisk/io.h" #include "asterisk/rtp.h" +#include "asterisk/netsock.h" #include "asterisk/acl.h" #include "asterisk/callerid.h" #include "asterisk/cli.h" @@ -214,6 +215,10 @@ static int unistim_port; static enum autoprovision autoprovisioning = AUTOPROVISIONING_NO; static int unistim_keepalive; static int unistimsock = -1; +static unsigned int tos = 0; +static unsigned int tos_audio = 0; +static unsigned int cos = 0; +static unsigned int cos_audio = 0; static struct io_context *io; static struct sched_context *sched; static struct sockaddr_in public_ip = { 0, }; @@ -2075,8 +2080,10 @@ static void start_rtp(struct unistim_subchannel *sub) sub->owner->fds[0] = ast_rtp_fd(sub->rtp); sub->owner->fds[1] = ast_rtcp_fd(sub->rtp); } - if (sub->rtp) + if (sub->rtp) { + ast_rtp_setqos(sub->rtp, tos_audio, cos_audio, "UNISTIM RTP"); ast_rtp_setnat(sub->rtp, sub->parent->parent->nat); + } /* Create the RTP connection */ ast_rtp_get_us(sub->rtp, &us); @@ -5330,7 +5337,19 @@ static int reload_config(void) unistim_keepalive = atoi(v->value); else if (!strcasecmp(v->name, "port")) unistim_port = atoi(v->value); - else if (!strcasecmp(v->name, "autoprovisioning")) { + else if (!strcasecmp(v->name, "tos")) { + if (ast_str2tos(v->value, &tos)) + ast_log(LOG_WARNING, "Invalid tos value at line %d, refer to QoS documentation\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, refer to QoS documentation\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, refer to QoS documentation\n", v->lineno); + } else if (!strcasecmp(v->name, "cos_audio")) { + if (ast_str2cos(v->value, &cos_audio)) + ast_log(LOG_WARNING, "Invalid cos_audio value at line %d, refer to QoS documentation\n", v->lineno); + } else if (!strcasecmp(v->name, "autoprovisioning")) { if (!strcasecmp(v->value, "no")) autoprovisioning = AUTOPROVISIONING_NO; else if (!strcasecmp(v->value, "yes")) @@ -5511,6 +5530,7 @@ static int reload_config(void) "UNISTIM Listening on %s:%d\n", ast_inet_ntoa(bindaddr.sin_addr), htons(bindaddr.sin_port)); } + ast_netsock_set_qos(unistimsock, tos, cos, "UNISTIM"); } return 0; } diff --git a/channels/iax2-provision.c b/channels/iax2-provision.c index 3ddec3e06..5b52a0934 100644 --- a/channels/iax2-provision.c +++ b/channels/iax2-provision.c @@ -323,7 +323,7 @@ static int iax_template_parse(struct iax_template *cur, struct ast_config *cfg, 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/qos.tex for more information.\n", v->lineno); + ast_log(LOG_WARNING, "Invalid tos value at line %d, refer to QoS documentation\n", v->lineno); } else if (!strcasecmp(v->name, "user")) { strncpy(cur->user, v->value, sizeof(cur->user) - 1); if (strcmp(cur->user, v->value)) |