diff options
author | mmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-07-27 17:44:06 +0000 |
---|---|---|
committer | mmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-07-27 17:44:06 +0000 |
commit | aa5cf75cf0a7f8b44aade8133adf17c82760ff14 (patch) | |
tree | c9752a94995cf4f57fc7a1bbab7f2fe084129316 /main/udptl.c | |
parent | 4b48dfb2eb2368c05285a7a4db3eccabd29a9b5d (diff) |
Allow for UDPTL to use only even-numbered ports if desired.
There are some VoIP providers out there that will not accept SDP
offers with odd numbered UDPTL ports. While it is my personal opinion
that these VoIP providers are misinterpreting RFC 2327, it really is
not a big deal to play along with their silly little games. Of course,
since restricting UDPTL ports to only even numbers reduces the range
of available ports by half, so the option to use only even port numbers
is off by default. A user can enable the behavior by setting
use_even_ports=yes in udptl.conf.
(closes issue #15182)
Reported by: CGMChris
Patches:
15182.patch uploaded by mmichelson (license 60)
Tested by: CGMChris
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@209131 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/udptl.c')
-rw-r--r-- | main/udptl.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/main/udptl.c b/main/udptl.c index 2ffd08de2..76b4a1444 100644 --- a/main/udptl.c +++ b/main/udptl.c @@ -66,6 +66,7 @@ static int udptlfectype; static int udptlfecentries; static int udptlfecspan; static int udptlmaxdatagram; +static int use_even_ports; #define LOCAL_FAX_MAX_DATAGRAM 1400 #define MAX_FEC_ENTRIES 5 @@ -795,6 +796,9 @@ struct ast_udptl *ast_udptl_new_with_bindaddr(struct sched_context *sched, struc #endif /* Find us a place */ x = (ast_random() % (udptlend - udptlstart)) + udptlstart; + if (use_even_ports && (x & 1)) { + ++x; + } startplace = x; for (;;) { udptl->us.sin_port = htons(x); @@ -807,7 +811,12 @@ struct ast_udptl *ast_udptl_new_with_bindaddr(struct sched_context *sched, struc free(udptl); return NULL; } - if (++x > udptlend) + if (use_even_ports) { + x += 2; + } else { + ++x; + } + if (x > udptlend) x = udptlstart; if (x == startplace) { ast_log(LOG_WARNING, "No UDPTL ports remaining\n"); @@ -1183,6 +1192,7 @@ void ast_udptl_reload(void) udptlfecentries = 0; udptlfecspan = 0; udptlmaxdatagram = 0; + use_even_ports = 0; if ((cfg = ast_config_load("udptl.conf"))) { if ((s = ast_variable_retrieve(cfg, "general", "udptlstart"))) { @@ -1257,6 +1267,9 @@ void ast_udptl_reload(void) udptlfecspan = MAX_FEC_SPAN; } } + if ((s = ast_variable_retrieve(cfg, "general", "use_even_ports"))) { + use_even_ports = ast_true(s); + } ast_config_destroy(cfg); } if (udptlstart >= udptlend) { @@ -1264,6 +1277,14 @@ void ast_udptl_reload(void) udptlstart = 4500; udptlend = 4999; } + if (use_even_ports && (udptlstart & 1)) { + ++udptlstart; + ast_log(LOG_NOTICE, "Odd numbered udptlstart specified but use_even_ports enabled. udptlstart is now %d\n", udptlstart); + } + if (use_even_ports && (udptlend & 1)) { + --udptlend; + ast_log(LOG_NOTICE, "Odd numbered udptlend specified but use_event_ports enabled. udptlend is now %d\n", udptlend); + } if (option_verbose > 1) ast_verbose(VERBOSE_PREFIX_2 "UDPTL allocating from port range %d -> %d\n", udptlstart, udptlend); } |