summaryrefslogtreecommitdiff
path: root/res/res_pjsip
diff options
context:
space:
mode:
Diffstat (limited to 'res/res_pjsip')
-rw-r--r--res/res_pjsip/config_global.c44
-rw-r--r--res/res_pjsip/location.c20
-rw-r--r--res/res_pjsip/pjsip_configuration.c20
3 files changed, 72 insertions, 12 deletions
diff --git a/res/res_pjsip/config_global.c b/res/res_pjsip/config_global.c
index c0fede64d..ad03379fd 100644
--- a/res/res_pjsip/config_global.c
+++ b/res/res_pjsip/config_global.c
@@ -37,6 +37,7 @@
#define DEFAULT_FROM_USER "asterisk"
#define DEFAULT_REGCONTEXT ""
#define DEFAULT_CONTACT_EXPIRATION_CHECK_INTERVAL 30
+#define DEFAULT_VOICEMAIL_EXTENSION ""
static char default_useragent[256];
@@ -52,6 +53,8 @@ struct global_config {
AST_STRING_FIELD(endpoint_identifier_order);
/*! User name to place in From header if there is no better option */
AST_STRING_FIELD(default_from_user);
+ /*! Default voicemail extension */
+ AST_STRING_FIELD(default_voicemail_extension);
);
/* Value to put in Max-Forwards header */
unsigned int max_forwards;
@@ -144,20 +147,35 @@ char *ast_sip_get_debug(void)
char *ast_sip_get_regcontext(void)
{
- char *res;
- struct global_config *cfg;
+ char *res;
+ struct global_config *cfg;
- cfg = get_global_cfg();
- if (!cfg) {
- return ast_strdup(DEFAULT_REGCONTEXT);
- }
+ cfg = get_global_cfg();
+ if (!cfg) {
+ return ast_strdup(DEFAULT_REGCONTEXT);
+ }
- res = ast_strdup(cfg->regcontext);
- ao2_ref(cfg, -1);
+ res = ast_strdup(cfg->regcontext);
+ ao2_ref(cfg, -1);
- return res;
+ return res;
}
+char *ast_sip_get_default_voicemail_extension(void)
+{
+ char *res;
+ struct global_config *cfg;
+
+ cfg = get_global_cfg();
+ if (!cfg) {
+ return ast_strdup(DEFAULT_VOICEMAIL_EXTENSION);
+ }
+
+ res = ast_strdup(cfg->default_voicemail_extension);
+ ao2_ref(cfg, -1);
+
+ return res;
+}
char *ast_sip_get_endpoint_identifier_order(void)
{
@@ -347,12 +365,14 @@ int ast_sip_initialize_sorcery_global(void)
OPT_UINT_T, 0, FLDSET(struct global_config, max_initial_qualify_time));
ast_sorcery_object_field_register(sorcery, "global", "default_from_user", DEFAULT_FROM_USER,
OPT_STRINGFIELD_T, 0, STRFLDSET(struct global_config, default_from_user));
+ ast_sorcery_object_field_register(sorcery, "global", "default_voicemail_extension",
+ DEFAULT_VOICEMAIL_EXTENSION, OPT_STRINGFIELD_T, 0, STRFLDSET(struct global_config,
+ default_voicemail_extension));
ast_sorcery_object_field_register(sorcery, "global", "regcontext", DEFAULT_REGCONTEXT,
- OPT_STRINGFIELD_T, 0, STRFLDSET(struct global_config, regcontext));
+ OPT_UINT_T, 0, FLDSET(struct global_config, contact_expiration_check_interval));
ast_sorcery_object_field_register(sorcery, "global", "contact_expiration_check_interval",
__stringify(DEFAULT_CONTACT_EXPIRATION_CHECK_INTERVAL),
- OPT_UINT_T, 0, FLDSET(struct global_config, contact_expiration_check_interval));
-
+ OPT_STRINGFIELD_T, 0, STRFLDSET(struct global_config, regcontext));
if (ast_sorcery_instance_observer_add(sorcery, &observer_callbacks_global)) {
return -1;
diff --git a/res/res_pjsip/location.c b/res/res_pjsip/location.c
index 4284f35f1..735b18f46 100644
--- a/res/res_pjsip/location.c
+++ b/res/res_pjsip/location.c
@@ -35,6 +35,7 @@ static void aor_destroy(void *obj)
ao2_cleanup(aor->permanent_contacts);
ast_string_field_free_memory(aor);
+ ast_free(aor->voicemail_extension);
}
/*! \brief Allocator for AOR */
@@ -442,6 +443,24 @@ static int contacts_to_var_list(const void *obj, struct ast_variable **fields)
return 0;
}
+static int voicemail_extension_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
+{
+ struct ast_sip_aor *aor = obj;
+
+ aor->voicemail_extension = ast_strdup(var->value);
+
+ return aor->voicemail_extension ? 0 : -1;
+}
+
+static int voicemail_extension_to_str(const void *obj, const intptr_t *args, char **buf)
+{
+ const struct ast_sip_aor *aor = obj;
+
+ *buf = ast_strdup(aor->voicemail_extension);
+
+ return 0;
+}
+
int ast_sip_for_each_aor(const char *aors, ao2_callback_fn on_aor, void *arg)
{
char *copy, *name;
@@ -992,6 +1011,7 @@ int ast_sip_initialize_sorcery_location(void)
ast_sorcery_object_field_register(sorcery, "aor", "remove_existing", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_aor, remove_existing));
ast_sorcery_object_field_register_custom(sorcery, "aor", "contact", "", permanent_uri_handler, contacts_to_str, contacts_to_var_list, 0, 0);
ast_sorcery_object_field_register(sorcery, "aor", "mailboxes", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_aor, mailboxes));
+ ast_sorcery_object_field_register_custom(sorcery, "aor", "voicemail_extension", "", voicemail_extension_handler, voicemail_extension_to_str, NULL, 0, 0);
ast_sorcery_object_field_register(sorcery, "aor", "outbound_proxy", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_aor, outbound_proxy));
ast_sorcery_object_field_register(sorcery, "aor", "support_path", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_aor, support_path));
diff --git a/res/res_pjsip/pjsip_configuration.c b/res/res_pjsip/pjsip_configuration.c
index ea808ce4d..06588337c 100644
--- a/res/res_pjsip/pjsip_configuration.c
+++ b/res/res_pjsip/pjsip_configuration.c
@@ -1055,6 +1055,23 @@ static int set_var_to_vl(const void *obj, struct ast_variable **fields)
return 0;
}
+static int voicemail_extension_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
+{
+ struct ast_sip_endpoint *endpoint = obj;
+
+ endpoint->subscription.mwi.voicemail_extension = ast_strdup(var->value);
+
+ return endpoint->subscription.mwi.voicemail_extension ? 0 : -1;
+}
+
+static int voicemail_extension_to_str(const void *obj, const intptr_t *args, char **buf)
+{
+ const struct ast_sip_endpoint *endpoint = obj;
+
+ *buf = ast_strdup(endpoint->subscription.mwi.voicemail_extension);
+
+ return 0;
+}
static void *sip_nat_hook_alloc(const char *name)
{
@@ -1650,7 +1667,9 @@ int ast_res_pjsip_initialize_configuration(const struct ast_module_info *ast_mod
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "rpid_immediate", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, rpid_immediate));
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "send_diversion", "yes", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, id.send_diversion));
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "mailboxes", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, subscription.mwi.mailboxes));
+ ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "voicemail_extension", "", voicemail_extension_handler, voicemail_extension_to_str, NULL, 0, 0);
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "aggregate_mwi", "yes", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, subscription.mwi.aggregate));
+ ast_sorcery_object_field_register(sip_sorcery, "endpoint", "mwi_subscribe_replaces_unsolicited", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, subscription.mwi.subscribe_replaces_unsolicited));
ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "media_encryption", "no", media_encryption_handler, media_encryption_to_str, NULL, 0, 0);
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "use_avpf", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.rtp.use_avpf));
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "force_avp", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.rtp.force_avp));
@@ -1801,6 +1820,7 @@ int ast_res_pjsip_reload_configuration(void)
static void subscription_configuration_destroy(struct ast_sip_endpoint_subscription_configuration *subscription)
{
ast_string_field_free_memory(&subscription->mwi);
+ ast_free(subscription->mwi.voicemail_extension);
}
static void info_configuration_destroy(struct ast_sip_endpoint_info_configuration *info)