aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGES4
-rw-r--r--channels/chan_sip.c25
-rw-r--r--channels/sip/include/sip.h3
-rw-r--r--configs/sip.conf.sample5
4 files changed, 33 insertions, 4 deletions
diff --git a/CHANGES b/CHANGES
index a01077970..44fda375c 100644
--- a/CHANGES
+++ b/CHANGES
@@ -19,8 +19,8 @@ Text Messaging
SIP MESSAGE and XMPP are currently supported. There are options in
jabber.conf and sip.conf to allow enabling these features.
-> jabber.conf: see the "sendtodialplan" and "context" options.
- -> sip.conf: see the "accept_outofcall_message" and "auth_message_requests"
- options.
+ -> sip.conf: see the "accept_outofcall_message", "auth_message_requests"
+ and "outofcall_message_context" options.
The MESSAGE() dialplan function and MessageSend() application have been
added to go along with this functionality. More detailed usage information
can be found on the Asterisk wiki (http://wiki.asterisk.org/).
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 */
diff --git a/configs/sip.conf.sample b/configs/sip.conf.sample
index 49277d64f..21235a6ef 100644
--- a/configs/sip.conf.sample
+++ b/configs/sip.conf.sample
@@ -389,6 +389,11 @@ srvlookup=yes ; Enable DNS SRV lookups on outbound calls
; call. By default, this option is enabled. When enabled, MESSAGE
; requests are passed in to the dialplan.
+;outofcall_message_context = messages ; Context all out of dialog msgs are sent to. When this
+ ; option is not set, the context used during peer matching
+ ; is used. This option can be defined at both the peer and
+ ; global level.
+
;auth_message_requests = yes ; Enabling this option will authenticate MESSAGE requests.
; By default this option is enabled. However, it can be disabled
; should an application desire to not load the Asterisk server with