From bfe4bb0f1ec3e2beb2c1d7eab471c2219ad734f3 Mon Sep 17 00:00:00 2001 From: Olle Johansson Date: Wed, 27 Dec 2006 16:49:45 +0000 Subject: [PATCH] Issue #8575 - Buggy cisco MWI support. Normally we try not to change our software for bugs in other devices. But in this case, the Cisco phones are so widespread so we try to implement a fix while waiting for a bugfix from Cisco. git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@48982 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- channels/chan_sip.c | 16 +++++++++++++--- configs/sip.conf.sample | 3 +++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 641dc2e7dd..57bc2396b7 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -781,10 +781,12 @@ struct sip_auth { #define SIP_PAGE2_CALL_ONHOLD (3 << 23) /*!< Call states */ #define SIP_PAGE2_CALL_ONHOLD_ONEDIR (1 << 23) /*!< 23: One directional hold */ #define SIP_PAGE2_CALL_ONHOLD_INACTIVE (1 << 24) /*!< 24: Inactive */ -#define SIP_PAGE2_RFC2833_COMPENSATE (1 << 25) +#define SIP_PAGE2_RFC2833_COMPENSATE (1 << 25) /*!< 25: ???? */ +#define SIP_PAGE2_BUGGY_CISCO_MWI (1 << 26) /*!< 26: Buggy CISCO MWI fix */ #define SIP_PAGE2_FLAGS_TO_COPY \ - (SIP_PAGE2_ALLOWSUBSCRIBE | SIP_PAGE2_ALLOWOVERLAP | SIP_PAGE2_VIDEOSUPPORT | SIP_PAGE2_T38SUPPORT | SIP_PAGE2_RFC2833_COMPENSATE) + (SIP_PAGE2_ALLOWSUBSCRIBE | SIP_PAGE2_ALLOWOVERLAP | SIP_PAGE2_VIDEOSUPPORT | \ + SIP_PAGE2_T38SUPPORT | SIP_PAGE2_RFC2833_COMPENSATE | SIP_PAGE2_BUGGY_CISCO_MWI) /* SIP packet flags */ #define SIP_PKT_DEBUG (1 << 0) /*!< Debug this packet */ @@ -6964,7 +6966,11 @@ static int transmit_notify_with_mwi(struct sip_pvt *p, int newmsgs, int oldmsgs, ast_build_string(&t, &maxbytes, "Messages-Waiting: %s\r\n", newmsgs ? "yes" : "no"); ast_build_string(&t, &maxbytes, "Message-Account: sip:%s@%s\r\n", S_OR(vmexten, default_vmexten), S_OR(p->fromdomain, ast_inet_ntoa(p->ourip))); - ast_build_string(&t, &maxbytes, "Voice-Message: %d/%d (0/0)\r\n", newmsgs, oldmsgs); + /* Cisco has a bug in the SIP stack where it can't accept the + (0/0) notification. This can temporarily be disabled in + sip.conf with the "buggyciscomwi" option */ + ast_build_string(&t, &maxbytes, "Voice-Message: %d/%d%s\r\n", newmsgs, oldmsgs, (ast_test_flag(&p->flags[1], SIP_PAGE2_BUGGY_CISCO_MWI) ? "" : " (0/0)")); + if (p->subscribed) { if (p->expiry) add_header(&req, "Subscription-State", "active"); @@ -15326,6 +15332,10 @@ static int handle_common_options(struct ast_flags *flags, struct ast_flags *mask ast_set_flag(&mask[1], SIP_PAGE2_RFC2833_COMPENSATE); ast_set2_flag(&flags[1], ast_true(v->value), SIP_PAGE2_RFC2833_COMPENSATE); res = 1; + } else if (!strcasecmp(v->name, "buggyciscomwi")) { + ast_set_flag(&mask[1], SIP_PAGE2_BUGGY_CISCO_MWI); + ast_set2_flag(&flags[1], ast_true(v->value), SIP_PAGE2_BUGGY_CISCO_MWI); + res = 1; } return res; diff --git a/configs/sip.conf.sample b/configs/sip.conf.sample index 120987fdc4..3e603bb1f0 100644 --- a/configs/sip.conf.sample +++ b/configs/sip.conf.sample @@ -66,6 +66,9 @@ srvlookup=yes ; Enable DNS SRV lookups on outbound calls ; Defaults to 100 ms ;notifymimetype=text/plain ; Allow overriding of mime type in MWI NOTIFY ;checkmwi=10 ; Default time between mailbox checks for peers +;buggyciscomwi=no ; Cisco SIP firmware doesn't support the MWI RFC + ; fully. Enable this option to not get error messages + ; when sending MWI to phones with this bug. ;vmexten=voicemail ; dialplan extension to reach mailbox sets the ; Message-Account in the MWI notify message ; defaults to "asterisk"