[asterisk-commits] file: trunk r226060 - in /trunk: ./ channels/ configs/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Oct 27 08:30:34 CDT 2009
Author: file
Date: Tue Oct 27 08:30:27 2009
New Revision: 226060
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=226060
Log:
Add support for receiving unsolicited MWI NOTIFY messages.
This change adds a configuration option to SIP peers, unsolicited_mailbox, which
configures a virtual mailbox to use for received new/old MWI information. This
virtual mailbox can then be used by any device supporting MWI.
(closes issue #13028)
Reported by: AsteriskRocks
Patches:
bug_13028_chan_sip_external_mwi_20090707.patch uploaded by cmaj (license 830)
Modified:
trunk/CHANGES
trunk/channels/chan_sip.c
trunk/configs/sip.conf.sample
Modified: trunk/CHANGES
URL: http://svnview.digium.com/svn/asterisk/trunk/CHANGES?view=diff&rev=226060&r1=226059&r2=226060
==============================================================================
--- trunk/CHANGES (original)
+++ trunk/CHANGES Tue Oct 27 08:30:27 2009
@@ -50,6 +50,9 @@
accessible via AMI and CLI.
* Added 'media_address' configuration option which can be used to explicitly specify
the IP address to use in the SDP for media (audio, video, and text) streams.
+ * Added 'unsolicited_mailbox' configuration option which specifies the virtual mailbox
+ that the new/old count should be stored on if an unsolicited MWI NOTIFY message is
+ received.
IAX2 Changes
-----------
Modified: trunk/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_sip.c?view=diff&rev=226060&r1=226059&r2=226060
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Tue Oct 27 08:30:27 2009
@@ -1995,6 +1995,7 @@
AST_STRING_FIELD(useragent); /*!< User agent in SIP request (saved from registration) */
AST_STRING_FIELD(mwi_from); /*!< Name to place in From header for outgoing NOTIFY requests */
AST_STRING_FIELD(engine); /*!< RTP Engine to use */
+ AST_STRING_FIELD(unsolicited_mailbox); /*!< Mailbox to store received unsolicited MWI NOTIFY messages information in */
);
struct sip_socket socket; /*!< Socket used for this peer */
enum sip_transport default_outbound_transport; /*!< Peer Registration may change the default outbound transport.
@@ -7628,10 +7629,6 @@
if (intended_method == SIP_REFER) {
/* We do support REFER, but not outside of a dialog yet */
transmit_response_using_temp(callid, sin, 1, intended_method, req, "603 Declined (no dialog)");
- } else if (intended_method == SIP_NOTIFY) {
- /* We do not support out-of-dialog NOTIFY either,
- like voicemail notification, so cancel that early */
- transmit_response_using_temp(callid, sin, 1, intended_method, req, "489 Bad event");
} else {
/* Ok, time to create a new SIP dialog object, a pvt */
if ((p = sip_alloc(callid, sin, 1, intended_method, req))) {
@@ -19829,25 +19826,39 @@
}
/* Confirm that we received this packet */
transmit_response(p, "200 OK", req);
- } else if (p->mwi && !strcmp(event, "message-summary")) {
+ } else if (!strcmp(event, "message-summary")) {
+ const char *mailbox = NULL;
char *c = ast_strdupa(get_body(req, "Voice-Message", ':'));
- if (!ast_strlen_zero(c)) {
+ if (!p->mwi) {
+ struct sip_peer *peer = find_peer(NULL, &p->recv, TRUE, FINDPEERS, FALSE, p->socket.type);
+
+ if (peer) {
+ mailbox = ast_strdupa(peer->unsolicited_mailbox);
+ unref_peer(peer, "removing unsolicited mwi ref");
+ }
+ } else {
+ mailbox = p->mwi->mailbox;
+ }
+
+ if (!ast_strlen_zero(mailbox) && !ast_strlen_zero(c)) {
char *old = strsep(&c, " ");
char *new = strsep(&old, "/");
struct ast_event *event;
if ((event = ast_event_new(AST_EVENT_MWI,
- AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, p->mwi->mailbox,
+ AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, mailbox,
AST_EVENT_IE_CONTEXT, AST_EVENT_IE_PLTYPE_STR, "SIP_Remote",
AST_EVENT_IE_NEWMSGS, AST_EVENT_IE_PLTYPE_UINT, atoi(new),
AST_EVENT_IE_OLDMSGS, AST_EVENT_IE_PLTYPE_UINT, atoi(old),
AST_EVENT_IE_END))) {
ast_event_queue_and_cache(event);
}
- }
-
- transmit_response(p, "200 OK", req);
+ transmit_response(p, "200 OK", req);
+ } else {
+ transmit_response(p, "489 Bad event", req);
+ res = -1;
+ }
} else if (!strcmp(event, "keep-alive")) {
/* Used by Sipura/Linksys for NAT pinhole,
* just confirm that we recieved the packet. */
@@ -24897,6 +24908,8 @@
} else if (!strcasecmp(v->name, "disallowed_methods")) {
char *disallow = ast_strdupa(v->value);
mark_parsed_methods(&peer->disallowed_methods, disallow);
+ } else if (!strcasecmp(v->name, "unsolicited_mailbox")) {
+ ast_string_field_set(peer, unsolicited_mailbox, v->value);
}
}
Modified: trunk/configs/sip.conf.sample
URL: http://svnview.digium.com/svn/asterisk/trunk/configs/sip.conf.sample?view=diff&rev=226060&r1=226059&r2=226060
==============================================================================
--- trunk/configs/sip.conf.sample (original)
+++ trunk/configs/sip.conf.sample Tue Oct 27 08:30:27 2009
@@ -975,6 +975,7 @@
; contactdeny ; is to register at the same IP as a SIP provider,
; ; then call oneself, and get redirected to that
; ; same location).
+; unsolicited_mailbox
;[sip_proxy]
; For incoming calls only. Example: FWD (Free World Dialup)
@@ -1015,6 +1016,10 @@
;transport=udp,tcp ; This sets the transport type to udp for outgoing, and will
; ; accept both tcp and udp. Default is udp. The first transport
; ; listed will always be used for outgoing connections.
+;unsolicited_mailbox=4015552299 ; If the remote SIP server sends an unsolicited MWI NOTIFY message the new/old
+; ; message count will be stored in the configured virtual mailbox. It can be used
+; ; by any device supporting MWI by specifying <configured value>@SIP_Remote as the
+; ; mailbox.
;
; Because you might have a large number of similar sections, it is generally
More information about the asterisk-commits
mailing list