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
This commit is contained in:
David Vossel
2011-06-13 19:43:57 +00:00
parent e42402ba2c
commit 0bd877621e
4 changed files with 33 additions and 4 deletions

View File

@@ -19,8 +19,8 @@ Text Messaging
SIP MESSAGE and XMPP are currently supported. There are options in SIP MESSAGE and XMPP are currently supported. There are options in
jabber.conf and sip.conf to allow enabling these features. jabber.conf and sip.conf to allow enabling these features.
-> jabber.conf: see the "sendtodialplan" and "context" options. -> jabber.conf: see the "sendtodialplan" and "context" options.
-> sip.conf: see the "accept_outofcall_message" and "auth_message_requests" -> sip.conf: see the "accept_outofcall_message", "auth_message_requests"
options. and "outofcall_message_context" options.
The MESSAGE() dialplan function and MessageSend() application have been The MESSAGE() dialplan function and MessageSend() application have been
added to go along with this functionality. More detailed usage information added to go along with this functionality. More detailed usage information
can be found on the Asterisk wiki (http://wiki.asterisk.org/). can be found on the Asterisk wiki (http://wiki.asterisk.org/).

View File

@@ -15757,8 +15757,12 @@ static enum check_auth_result check_peer_ok(struct sip_pvt *p, char *of,
p->callingpres = peer->callingpres; p->callingpres = peer->callingpres;
} }
ast_string_field_set(p, fullcontact, peer->fullcontact); 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); 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, peersecret, peer->secret);
ast_string_field_set(p, peermd5secret, peer->md5secret); ast_string_field_set(p, peermd5secret, peer->md5secret);
ast_string_field_set(p, language, peer->language); 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)) { if (ast_strlen_zero(peer->secret) && ast_strlen_zero(peer->md5secret)) {
ast_string_field_set(p, context, peer->context); 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"); 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_to(msg, "%s", to);
res |= ast_msg_set_from(msg, "%s", get_in_brackets(from)); 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_body(msg, "%s", ast_str_buffer(buf));
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_context(msg, "%s", p->context);
}
res |= ast_msg_set_exten(msg, "%s", p->exten); res |= ast_msg_set_exten(msg, "%s", p->exten);
if (res) { 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[1], &global_flags[1], SIP_PAGE2_FLAGS_TO_COPY);
ast_copy_flags(&peer->flags[2], &global_flags[2], SIP_PAGE3_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, 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, subscribecontext, sip_cfg.default_subscribecontext);
ast_string_field_set(peer, language, default_language); ast_string_field_set(peer, language, default_language);
ast_string_field_set(peer, mohinterpret, default_mohinterpret); 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")) { } else if (!strcasecmp(v->name, "context")) {
ast_string_field_set(peer, context, v->value); ast_string_field_set(peer, context, v->value);
ast_set_flag(&peer->flags[1], SIP_PAGE2_HAVEPEERCONTEXT); 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")) { } else if (!strcasecmp(v->name, "subscribecontext")) {
ast_string_field_set(peer, subscribecontext, v->value); ast_string_field_set(peer, subscribecontext, v->value);
} else if (!strcasecmp(v->name, "fromdomain")) { } else if (!strcasecmp(v->name, "fromdomain")) {
@@ -27661,6 +27679,7 @@ static int reload_config(enum channelreloadreason reason)
sip_cfg.alwaysauthreject = DEFAULT_ALWAYSAUTHREJECT; sip_cfg.alwaysauthreject = DEFAULT_ALWAYSAUTHREJECT;
sip_cfg.auth_options_requests = DEFAULT_AUTH_OPTIONS; sip_cfg.auth_options_requests = DEFAULT_AUTH_OPTIONS;
sip_cfg.auth_message_requests = DEFAULT_AUTH_MESSAGE; sip_cfg.auth_message_requests = DEFAULT_AUTH_MESSAGE;
sip_cfg.messagecontext[0] = '\0';
sip_cfg.accept_outofcall_message = DEFAULT_ACCEPT_OUTOFCALL_MESSAGE; sip_cfg.accept_outofcall_message = DEFAULT_ACCEPT_OUTOFCALL_MESSAGE;
sip_cfg.allowsubscribe = FALSE; sip_cfg.allowsubscribe = FALSE;
sip_cfg.disallowed_methods = SIP_UNKNOWN; 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; sip_cfg.auth_message_requests = ast_true(v->value) ? 1 : 0;
} else if (!strcasecmp(v->name, "accept_outofcall_message")) { } else if (!strcasecmp(v->name, "accept_outofcall_message")) {
sip_cfg.accept_outofcall_message = ast_true(v->value) ? 1 : 0; 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")) { } else if (!strcasecmp(v->name, "mohinterpret")) {
ast_copy_string(default_mohinterpret, v->value, sizeof(default_mohinterpret)); ast_copy_string(default_mohinterpret, v->value, sizeof(default_mohinterpret));
} else if (!strcasecmp(v->name, "mohsuggest")) { } else if (!strcasecmp(v->name, "mohsuggest")) {

View File

@@ -691,6 +691,7 @@ struct sip_settings {
int legacy_useroption_parsing; /*!< Whether to strip useroptions in URI via semicolons */ int legacy_useroption_parsing; /*!< Whether to strip useroptions in URI via semicolons */
int matchexternaddrlocally; /*!< Match externaddr/externhost setting against localnet setting */ int matchexternaddrlocally; /*!< Match externaddr/externhost setting against localnet setting */
char regcontext[AST_MAX_CONTEXT]; /*!< Context for auto-extensions */ 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 */ unsigned int disallowed_methods; /*!< methods that we should never try to use */
int notifyringing; /*!< Send notifications on ringing */ int notifyringing; /*!< Send notifications on ringing */
int notifyhold; /*!< Send notifications on hold */ 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(useragent); /*!< User agent in SIP request */
AST_STRING_FIELD(exten); /*!< Extension where to start */ AST_STRING_FIELD(exten); /*!< Extension where to start */
AST_STRING_FIELD(context); /*!< Context for this call */ 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(subscribecontext); /*!< Subscribecontext */
AST_STRING_FIELD(subscribeuri); /*!< Subscribecontext */ AST_STRING_FIELD(subscribeuri); /*!< Subscribecontext */
AST_STRING_FIELD(fromdomain); /*!< Domain to show in the from field */ 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(description); /*!< Description of this peer */
AST_STRING_FIELD(remotesecret); /*!< Remote secret (trunks, remote devices) */ AST_STRING_FIELD(remotesecret); /*!< Remote secret (trunks, remote devices) */
AST_STRING_FIELD(context); /*!< Default context for incoming calls */ 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(subscribecontext); /*!< Default context for subscriptions */
AST_STRING_FIELD(username); /*!< Temporary username until registration */ AST_STRING_FIELD(username); /*!< Temporary username until registration */
AST_STRING_FIELD(accountcode); /*!< Account code */ AST_STRING_FIELD(accountcode); /*!< Account code */

View File

@@ -389,6 +389,11 @@ srvlookup=yes ; Enable DNS SRV lookups on outbound calls
; call. By default, this option is enabled. When enabled, MESSAGE ; call. By default, this option is enabled. When enabled, MESSAGE
; requests are passed in to the dialplan. ; 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. ;auth_message_requests = yes ; Enabling this option will authenticate MESSAGE requests.
; By default this option is enabled. However, it can be disabled ; By default this option is enabled. However, it can be disabled
; should an application desire to not load the Asterisk server with ; should an application desire to not load the Asterisk server with