Index: channels/chan_iax2.c =================================================================== RCS file: /usr/cvsroot/asterisk/channels/chan_iax2.c,v retrieving revision 1.330 diff -u -u -r1.330 chan_iax2.c --- channels/chan_iax2.c 9 Aug 2005 01:59:59 -0000 1.330 +++ channels/chan_iax2.c 9 Aug 2005 14:30:25 -0000 @@ -8370,6 +8370,7 @@ struct ast_variable *v; char *cat; char *utype; + char *tosval; int format; int portno = IAX_DEFAULT_PORTNO; int x; @@ -8397,6 +8398,25 @@ nochecksums = 0; #endif + /* We have to set tos first, to make sure it is done before setting bindaddr */ + tosval = ast_variable_retrieve(cfg, "general", "tos"); + if (tosval) { + if (sscanf(tosval, "%i", &format) == 1) + tos = format & 0xff; + else if (!strcasecmp(tosval, "lowdelay")) + tos = IPTOS_LOWDELAY; + else if (!strcasecmp(tosval, "throughput")) + tos = IPTOS_THROUGHPUT; + else if (!strcasecmp(tosval, "reliability")) + tos = IPTOS_RELIABILITY; + else if (!strcasecmp(tosval, "mincost")) + tos = IPTOS_MINCOST; + else if (!strcasecmp(tosval, "none")) + tos = 0; + else + ast_log(LOG_WARNING, "Invalid tos value. It should be 'lowdelay', 'throughput', 'reliability', 'mincost', or 'none'\n"); + } + v = ast_variable_browse(cfg, "general"); while(v) { @@ -8528,21 +8548,6 @@ /* Create context if it doesn't exist already */ 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 - 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)); } else if (!strcasecmp(v->name, "amaflags")) {