summaryrefslogtreecommitdiff
path: root/channels
diff options
context:
space:
mode:
authorDavid Vossel <dvossel@digium.com>2011-06-13 19:43:57 +0000
committerDavid Vossel <dvossel@digium.com>2011-06-13 19:43:57 +0000
commit0bd877621e6fff640962026b1420f10c16a3fa14 (patch)
tree440b1bb951f297c4059dd928e94d806e2e262162 /channels
parente42402ba2c835624d0b7ba02837776a9c5792125 (diff)
Addition of "outofcall_message_context" sip.conf option.
Review: https://reviewboard.asterisk.org/r/1265/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@323212 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels')
-rw-r--r--channels/chan_sip.c25
-rw-r--r--channels/sip/include/sip.h3
2 files changed, 26 insertions, 2 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index cb9b8b26a..a16684a83 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -15757,8 +15757,12 @@ static enum check_auth_result check_peer_ok(struct sip_pvt *p, char *of,
p->callingpres = peer->callingpres;
}
ast_string_field_set(p, fullcontact, peer->fullcontact);
- if (!ast_strlen_zero(peer->context))
+ if (!ast_strlen_zero(peer->context)) {
ast_string_field_set(p, context, peer->context);
+ }
+ if (!ast_strlen_zero(peer->messagecontext)) {
+ ast_string_field_set(p, messagecontext, peer->messagecontext);
+ }
ast_string_field_set(p, peersecret, peer->secret);
ast_string_field_set(p, peermd5secret, peer->md5secret);
ast_string_field_set(p, language, peer->language);
@@ -16088,6 +16092,9 @@ static void receive_message(struct sip_pvt *p, struct sip_request *req, struct a
if (ast_strlen_zero(peer->secret) && ast_strlen_zero(peer->md5secret)) {
ast_string_field_set(p, context, peer->context);
}
+ if (!ast_strlen_zero(peer->messagecontext)) {
+ ast_string_field_set(p, messagecontext, peer->messagecontext);
+ }
peer = unref_peer(peer, "from find_peer() in receive_message");
}
}
@@ -16108,7 +16115,15 @@ static void receive_message(struct sip_pvt *p, struct sip_request *req, struct a
res = ast_msg_set_to(msg, "%s", to);
res |= ast_msg_set_from(msg, "%s", get_in_brackets(from));
res |= ast_msg_set_body(msg, "%s", ast_str_buffer(buf));
- res |= ast_msg_set_context(msg, "%s", p->context);
+
+ if (!ast_strlen_zero(p->messagecontext)) {
+ res |= ast_msg_set_context(msg, "%s", p->messagecontext);
+ } else if (!ast_strlen_zero(sip_cfg.messagecontext)) {
+ res |= ast_msg_set_context(msg, "%s", sip_cfg.messagecontext);
+ } else {
+ res |= ast_msg_set_context(msg, "%s", p->context);
+ }
+
res |= ast_msg_set_exten(msg, "%s", p->exten);
if (res) {
@@ -26679,6 +26694,7 @@ static void set_peer_defaults(struct sip_peer *peer)
ast_copy_flags(&peer->flags[1], &global_flags[1], SIP_PAGE2_FLAGS_TO_COPY);
ast_copy_flags(&peer->flags[2], &global_flags[2], SIP_PAGE3_FLAGS_TO_COPY);
ast_string_field_set(peer, context, sip_cfg.default_context);
+ ast_string_field_set(peer, messagecontext, sip_cfg.messagecontext);
ast_string_field_set(peer, subscribecontext, sip_cfg.default_subscribecontext);
ast_string_field_set(peer, language, default_language);
ast_string_field_set(peer, mohinterpret, default_mohinterpret);
@@ -26973,6 +26989,8 @@ static struct sip_peer *build_peer(const char *name, struct ast_variable *v, str
} else if (!strcasecmp(v->name, "context")) {
ast_string_field_set(peer, context, v->value);
ast_set_flag(&peer->flags[1], SIP_PAGE2_HAVEPEERCONTEXT);
+ } else if (!strcasecmp(v->name, "outofcall_message_context")) {
+ ast_string_field_set(peer, messagecontext, v->value);
} else if (!strcasecmp(v->name, "subscribecontext")) {
ast_string_field_set(peer, subscribecontext, v->value);
} else if (!strcasecmp(v->name, "fromdomain")) {
@@ -27661,6 +27679,7 @@ static int reload_config(enum channelreloadreason reason)
sip_cfg.alwaysauthreject = DEFAULT_ALWAYSAUTHREJECT;
sip_cfg.auth_options_requests = DEFAULT_AUTH_OPTIONS;
sip_cfg.auth_message_requests = DEFAULT_AUTH_MESSAGE;
+ sip_cfg.messagecontext[0] = '\0';
sip_cfg.accept_outofcall_message = DEFAULT_ACCEPT_OUTOFCALL_MESSAGE;
sip_cfg.allowsubscribe = FALSE;
sip_cfg.disallowed_methods = SIP_UNKNOWN;
@@ -27914,6 +27933,8 @@ static int reload_config(enum channelreloadreason reason)
sip_cfg.auth_message_requests = ast_true(v->value) ? 1 : 0;
} else if (!strcasecmp(v->name, "accept_outofcall_message")) {
sip_cfg.accept_outofcall_message = ast_true(v->value) ? 1 : 0;
+ } else if (!strcasecmp(v->name, "outofcall_message_context")) {
+ ast_copy_string(sip_cfg.messagecontext, v->value, sizeof(sip_cfg.messagecontext));
} else if (!strcasecmp(v->name, "mohinterpret")) {
ast_copy_string(default_mohinterpret, v->value, sizeof(default_mohinterpret));
} else if (!strcasecmp(v->name, "mohsuggest")) {
diff --git a/channels/sip/include/sip.h b/channels/sip/include/sip.h
index 0eb8be350..e8dba3067 100644
--- a/channels/sip/include/sip.h
+++ b/channels/sip/include/sip.h
@@ -691,6 +691,7 @@ struct sip_settings {
int legacy_useroption_parsing; /*!< Whether to strip useroptions in URI via semicolons */
int matchexternaddrlocally; /*!< Match externaddr/externhost setting against localnet setting */
char regcontext[AST_MAX_CONTEXT]; /*!< Context for auto-extensions */
+ char messagecontext[AST_MAX_CONTEXT]; /*!< Default context for out of dialog msgs. */
unsigned int disallowed_methods; /*!< methods that we should never try to use */
int notifyringing; /*!< Send notifications on ringing */
int notifyhold; /*!< Send notifications on hold */
@@ -939,6 +940,7 @@ struct sip_pvt {
AST_STRING_FIELD(useragent); /*!< User agent in SIP request */
AST_STRING_FIELD(exten); /*!< Extension where to start */
AST_STRING_FIELD(context); /*!< Context for this call */
+ AST_STRING_FIELD(messagecontext); /*!< Default context for outofcall messages. */
AST_STRING_FIELD(subscribecontext); /*!< Subscribecontext */
AST_STRING_FIELD(subscribeuri); /*!< Subscribecontext */
AST_STRING_FIELD(fromdomain); /*!< Domain to show in the from field */
@@ -1172,6 +1174,7 @@ struct sip_peer {
AST_STRING_FIELD(description); /*!< Description of this peer */
AST_STRING_FIELD(remotesecret); /*!< Remote secret (trunks, remote devices) */
AST_STRING_FIELD(context); /*!< Default context for incoming calls */
+ AST_STRING_FIELD(messagecontext); /*!< Default context for outofcall messages. */
AST_STRING_FIELD(subscribecontext); /*!< Default context for subscriptions */
AST_STRING_FIELD(username); /*!< Temporary username until registration */
AST_STRING_FIELD(accountcode); /*!< Account code */