mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-30 18:40:46 +00:00
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:
@@ -490,7 +490,7 @@
|
|||||||
;aors= ; AoR s to be used with the endpoint (default: "")
|
;aors= ; AoR s to be used with the endpoint (default: "")
|
||||||
;auth= ; Authentication Object s associated with the endpoint (default: "")
|
;auth= ; Authentication Object s associated with the endpoint (default: "")
|
||||||
;callerid= ; CallerID information for the endpoint (default: "")
|
;callerid= ; CallerID information for the endpoint (default: "")
|
||||||
;callerid_privacy= ; Default privacy level (default: "")
|
;callerid_privacy=allowed ; Default privacy level (default: "allowed")
|
||||||
;callerid_tag= ; Internal id_tag for the endpoint (default: "")
|
;callerid_tag= ; Internal id_tag for the endpoint (default: "")
|
||||||
;context=default ; Dialplan context for inbound sessions (default:
|
;context=default ; Dialplan context for inbound sessions (default:
|
||||||
; "default")
|
; "default")
|
||||||
@@ -596,10 +596,10 @@
|
|||||||
; this endpoint (default: "")
|
; this endpoint (default: "")
|
||||||
;from_domain= ; Domain to user in From header for requests to this endpoint
|
;from_domain= ; Domain to user in From header for requests to this endpoint
|
||||||
; (default: "")
|
; (default: "")
|
||||||
;dtls_verify= ; Verify that the provided peer certificate is valid (default:
|
;dtls_verify=no ; Verify that the provided peer certificate is valid (default:
|
||||||
; "")
|
; "no")
|
||||||
;dtls_rekey= ; Interval at which to renegotiate the TLS session and rekey
|
;dtls_rekey=0 ; Interval at which to renegotiate the TLS session and rekey
|
||||||
; the SRTP session (default: "")
|
; the SRTP session (default: "0")
|
||||||
;dtls_cert_file= ; Path to certificate file to present to peer (default:
|
;dtls_cert_file= ; Path to certificate file to present to peer (default:
|
||||||
; "")
|
; "")
|
||||||
;dtls_private_key= ; Path to private key for certificate file (default:
|
;dtls_private_key= ; Path to private key for certificate file (default:
|
||||||
|
@@ -349,7 +349,7 @@ static int transport_tls_method_handler(const struct aco_option *opt, struct ast
|
|||||||
{
|
{
|
||||||
struct ast_sip_transport *transport = obj;
|
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;
|
transport->tls.method = PJSIP_SSL_DEFAULT_METHOD;
|
||||||
} else if (!strcasecmp(var->value, "unspecified")) {
|
} else if (!strcasecmp(var->value, "unspecified")) {
|
||||||
transport->tls.method = PJSIP_SSL_UNSPECIFIED_METHOD;
|
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;
|
struct ast_sip_transport *transport = obj;
|
||||||
pj_ssl_cipher cipher;
|
pj_ssl_cipher cipher;
|
||||||
|
|
||||||
|
if (ast_strlen_zero(var->value)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (transport->tls.ciphers_num == (SIP_TLS_MAX_CIPHERS - 1)) {
|
if (transport->tls.ciphers_num == (SIP_TLS_MAX_CIPHERS - 1)) {
|
||||||
return -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;
|
struct ast_sip_transport *transport = obj;
|
||||||
int error = 0;
|
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))) {
|
if (!(transport->localnet = ast_append_ha("d", var->value, transport->localnet, &error))) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@@ -290,9 +290,14 @@ static int permanent_uri_handler(const struct aco_option *opt, struct ast_variab
|
|||||||
{
|
{
|
||||||
struct ast_sip_aor *aor = obj;
|
struct ast_sip_aor *aor = obj;
|
||||||
const char *aor_id = ast_sorcery_object_get_id(aor);
|
const char *aor_id = ast_sorcery_object_get_id(aor);
|
||||||
char *contacts = ast_strdupa(var->value);
|
char *contacts;
|
||||||
char *contact_uri;
|
char *contact_uri;
|
||||||
|
|
||||||
|
if (ast_strlen_zero(var->value)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
contacts = ast_strdupa(var->value);
|
||||||
while ((contact_uri = strsep(&contacts, ","))) {
|
while ((contact_uri = strsep(&contacts, ","))) {
|
||||||
struct ast_sip_contact *contact;
|
struct ast_sip_contact *contact;
|
||||||
char contact_id[strlen(aor_id) + strlen(contact_uri) + 2 + 1];
|
char contact_id[strlen(aor_id) + strlen(contact_uri) + 2 + 1];
|
||||||
|
@@ -559,13 +559,9 @@ static int group_handler(const struct aco_option *opt,
|
|||||||
struct ast_sip_endpoint *endpoint = obj;
|
struct ast_sip_endpoint *endpoint = obj;
|
||||||
|
|
||||||
if (!strncmp(var->name, "call_group", 10)) {
|
if (!strncmp(var->name, "call_group", 10)) {
|
||||||
if (!(endpoint->pickup.callgroup = ast_get_group(var->value))) {
|
endpoint->pickup.callgroup = ast_get_group(var->value);
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
} else if (!strncmp(var->name, "pickup_group", 12)) {
|
} else if (!strncmp(var->name, "pickup_group", 12)) {
|
||||||
if (!(endpoint->pickup.pickupgroup = ast_get_group(var->value))) {
|
endpoint->pickup.pickupgroup = ast_get_group(var->value);
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -603,12 +599,18 @@ static int named_groups_handler(const struct aco_option *opt,
|
|||||||
struct ast_sip_endpoint *endpoint = obj;
|
struct ast_sip_endpoint *endpoint = obj;
|
||||||
|
|
||||||
if (!strncmp(var->name, "named_call_group", 16)) {
|
if (!strncmp(var->name, "named_call_group", 16)) {
|
||||||
if (!(endpoint->pickup.named_callgroups =
|
if (ast_strlen_zero(var->value)) {
|
||||||
|
endpoint->pickup.named_callgroups =
|
||||||
|
ast_unref_namedgroups(endpoint->pickup.named_callgroups);
|
||||||
|
} else if (!(endpoint->pickup.named_callgroups =
|
||||||
ast_get_namedgroups(var->value))) {
|
ast_get_namedgroups(var->value))) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} else if (!strncmp(var->name, "named_pickup_group", 18)) {
|
} else if (!strncmp(var->name, "named_pickup_group", 18)) {
|
||||||
if (!(endpoint->pickup.named_pickupgroups =
|
if (ast_strlen_zero(var->value)) {
|
||||||
|
endpoint->pickup.named_pickupgroups =
|
||||||
|
ast_unref_namedgroups(endpoint->pickup.named_pickupgroups);
|
||||||
|
} else if (!(endpoint->pickup.named_pickupgroups =
|
||||||
ast_get_namedgroups(var->value))) {
|
ast_get_namedgroups(var->value))) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -808,7 +810,15 @@ static int set_var_handler(const struct aco_option *opt,
|
|||||||
{
|
{
|
||||||
struct ast_sip_endpoint *endpoint = obj;
|
struct ast_sip_endpoint *endpoint = obj;
|
||||||
struct ast_variable *new_var;
|
struct ast_variable *new_var;
|
||||||
char *name = ast_strdupa(var->value), *val = strchr(name, '=');
|
char *name;
|
||||||
|
char *val;
|
||||||
|
|
||||||
|
if (ast_strlen_zero(var->value)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
name = ast_strdupa(var->value);
|
||||||
|
val = strchr(name, '=');
|
||||||
|
|
||||||
if (!val) {
|
if (!val) {
|
||||||
return -1;
|
return -1;
|
||||||
@@ -1677,7 +1687,7 @@ int ast_res_pjsip_initialize_configuration(const struct ast_module_info *ast_mod
|
|||||||
ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "direct_media_glare_mitigation", "none", direct_media_glare_mitigation_handler, direct_media_glare_mitigation_to_str, NULL, 0, 0);
|
ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "direct_media_glare_mitigation", "none", direct_media_glare_mitigation_handler, direct_media_glare_mitigation_to_str, NULL, 0, 0);
|
||||||
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "disable_direct_media_on_nat", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.direct_media.disable_on_nat));
|
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "disable_direct_media_on_nat", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.direct_media.disable_on_nat));
|
||||||
ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "callerid", "", caller_id_handler, caller_id_to_str, NULL, 0, 0);
|
ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "callerid", "", caller_id_handler, caller_id_to_str, NULL, 0, 0);
|
||||||
ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "callerid_privacy", "", caller_id_privacy_handler, caller_id_privacy_to_str, NULL, 0, 0);
|
ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "callerid_privacy", "allowed", caller_id_privacy_handler, caller_id_privacy_to_str, NULL, 0, 0);
|
||||||
ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "callerid_tag", "", caller_id_tag_handler, caller_id_tag_to_str, NULL, 0, 0);
|
ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "callerid_tag", "", caller_id_tag_handler, caller_id_tag_to_str, NULL, 0, 0);
|
||||||
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "trust_id_inbound", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, id.trust_inbound));
|
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "trust_id_inbound", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, id.trust_inbound));
|
||||||
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "trust_id_outbound", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, id.trust_outbound));
|
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "trust_id_outbound", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, id.trust_outbound));
|
||||||
@@ -1720,8 +1730,8 @@ int ast_res_pjsip_initialize_configuration(const struct ast_module_info *ast_mod
|
|||||||
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "from_domain", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, fromdomain));
|
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "from_domain", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, fromdomain));
|
||||||
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "mwi_from_user", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, subscription.mwi.fromuser));
|
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "mwi_from_user", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, subscription.mwi.fromuser));
|
||||||
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "rtp_engine", "asterisk", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, media.rtp.engine));
|
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "rtp_engine", "asterisk", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, media.rtp.engine));
|
||||||
ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "dtls_verify", "", dtls_handler, dtlsverify_to_str, NULL, 0, 0);
|
ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "dtls_verify", "no", dtls_handler, dtlsverify_to_str, NULL, 0, 0);
|
||||||
ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "dtls_rekey", "", dtls_handler, dtlsrekey_to_str, NULL, 0, 0);
|
ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "dtls_rekey", "0", dtls_handler, dtlsrekey_to_str, NULL, 0, 0);
|
||||||
ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "dtls_cert_file", "", dtls_handler, dtlscertfile_to_str, NULL, 0, 0);
|
ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "dtls_cert_file", "", dtls_handler, dtlscertfile_to_str, NULL, 0, 0);
|
||||||
ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "dtls_private_key", "", dtls_handler, dtlsprivatekey_to_str, NULL, 0, 0);
|
ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "dtls_private_key", "", dtls_handler, dtlsprivatekey_to_str, NULL, 0, 0);
|
||||||
ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "dtls_cipher", "", dtls_handler, dtlscipher_to_str, NULL, 0, 0);
|
ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "dtls_cipher", "", dtls_handler, dtlscipher_to_str, NULL, 0, 0);
|
||||||
|
@@ -160,6 +160,10 @@ static int ip_identify_match_handler(const struct aco_option *opt, struct ast_va
|
|||||||
char *input_string = ast_strdupa(var->value);
|
char *input_string = ast_strdupa(var->value);
|
||||||
char *current_string;
|
char *current_string;
|
||||||
|
|
||||||
|
if (ast_strlen_zero(var->value)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
while ((current_string = strsep(&input_string, ","))) {
|
while ((current_string = strsep(&input_string, ","))) {
|
||||||
struct ast_sockaddr *addrs;
|
struct ast_sockaddr *addrs;
|
||||||
int num_addrs = 0, error = 0, i;
|
int num_addrs = 0, error = 0, i;
|
||||||
|
Reference in New Issue
Block a user