PJSIP: Handle defaults properly

This updates the code behind PJSIP configuration options with custom
handlers to deal with the assigned default values properly where it
makes sense and adjusting the default value where it doesn't. Before
applying this patch, there were several cases where the default value
for an option would prevent that config section from loading properly.

Reported by: Thomas Thompson
Review: https://reviewboard.asterisk.org/r/4019/
........

Merged revisions 424263 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@424266 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Kinsey Moore
2014-10-01 12:27:05 +00:00
parent ac095304e6
commit e3da76a352
5 changed files with 48 additions and 19 deletions

View File

@@ -349,7 +349,7 @@ static int transport_tls_method_handler(const struct aco_option *opt, struct ast
{
struct ast_sip_transport *transport = obj;
if (!strcasecmp(var->value, "default")) {
if (ast_strlen_zero(var->value) || !strcasecmp(var->value, "default")) {
transport->tls.method = PJSIP_SSL_DEFAULT_METHOD;
} else if (!strcasecmp(var->value, "unspecified")) {
transport->tls.method = PJSIP_SSL_UNSPECIFIED_METHOD;
@@ -416,6 +416,10 @@ static int transport_tls_cipher_handler(const struct aco_option *opt, struct ast
struct ast_sip_transport *transport = obj;
pj_ssl_cipher cipher;
if (ast_strlen_zero(var->value)) {
return 0;
}
if (transport->tls.ciphers_num == (SIP_TLS_MAX_CIPHERS - 1)) {
return -1;
}
@@ -468,6 +472,12 @@ static int transport_localnet_handler(const struct aco_option *opt, struct ast_v
struct ast_sip_transport *transport = obj;
int error = 0;
if (ast_strlen_zero(var->value)) {
ast_free_ha(transport->localnet);
transport->localnet = NULL;
return 0;
}
if (!(transport->localnet = ast_append_ha("d", var->value, transport->localnet, &error))) {
return -1;
}