diff options
author | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-08-09 16:41:28 +0000 |
---|---|---|
committer | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-08-09 16:41:28 +0000 |
commit | a818fdccc17bd33b7241dfb3a995240f7b2875bc (patch) | |
tree | 58dbac449574b77b6fb579f87e67e53130b9b188 /channels | |
parent | 0849c5a3864f709df92718fb2e93dd0db3bba194 (diff) |
Centralize and fix tos for IAX (bug #4850 inspired)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@6315 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels')
-rwxr-xr-x | channels/chan_iax2.c | 21 | ||||
-rwxr-xr-x | channels/chan_sip.c | 14 |
2 files changed, 9 insertions, 26 deletions
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index 9c12b29f5..34b1de6c7 100755 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -8370,6 +8370,7 @@ static int set_config(char *config_file, int reload) struct ast_variable *v; char *cat; char *utype; + char *tosval; int format; int portno = IAX_DEFAULT_PORTNO; int x; @@ -8399,6 +8400,12 @@ static int set_config(char *config_file, int reload) v = ast_variable_browse(cfg, "general"); + /* Seed initial tos value */ + tosval = ast_variable_retrieve(cfg, "general", "tos"); + if (tosval) { + if (ast_str2tos(v->value, &tos)) + ast_log(LOG_WARNING, "Invalid tos value, should be 'lowdelay', 'throughput', 'reliability', 'mincost', or 'none'\n"); + } while(v) { if (!strcasecmp(v->name, "bindport")){ if (reload) @@ -8529,19 +8536,7 @@ static int set_config(char *config_file, int reload) if (!ast_context_find(regcontext)) ast_context_create(NULL, regcontext, channeltype); } 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 + if (ast_str2tos(v->value, &tos)) 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, "accountcode")) { ast_copy_string(accountcode, v->value, sizeof(accountcode)); diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 898c94581..83c882eb1 100755 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -11030,19 +11030,7 @@ static int reload_config(void) } else if (!strcasecmp(v->name, "recordhistory")) { recordhistory = ast_true(v->value); } else if (!strcasecmp(v->name, "tos")) { - if (sscanf(v->value, "%i", &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 + if (ast_str2tos(v->value, &tos)) 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, "bindport")) { if (sscanf(v->value, "%d", &ourport) == 1) { |