[Asterisk-bugs] [Asterisk 0010164]: Incorrect notify handling when hints contain multiple devices

noreply at bugs.digium.com noreply at bugs.digium.com
Mon Jul 9 21:54:51 CDT 2007


A NOTE has been added to this issue. 
====================================================================== 
http://bugs.digium.com/view.php?id=10164 
====================================================================== 
Reported By:                nic_bellamy
Assigned To:                
====================================================================== 
Project:                    Asterisk
Issue ID:                   10164
Category:                   Channels/chan_sip/Subscriptions
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     new
Asterisk Version:            1.2.20  
SVN Branch (only for SVN checkouts, not tarball releases): N/A  
SVN Revision (number only!):  
Disclaimer on File?:        Yes 
Request Review:              
====================================================================== 
Date Submitted:             07-09-2007 21:48 CDT
Last Modified:              07-09-2007 21:54 CDT
====================================================================== 
Summary:                    Incorrect notify handling when hints contain
multiple devices
Description: 
There's a logic flaw in transmit_state_notify():

When sending a state notification, the hints for the extension are checked
to see if the device is offline; if so it overrides the state notification
to say "not online".

The problem: if your hint contains multiple devices, _any_ of these being
offline will override the state. The state should only be overridden if
_all_ the hinted devices are offline.

This breaks BLFs for Polycom devices (and anything else using pidf/xpidf
notifications) when you have multiple devices hinted.

This was introduced by the fix for http://bugs.digium.com/view.php?id=9536.
====================================================================== 

---------------------------------------------------------------------- 
 nic_bellamy - 07-09-07 21:54  
---------------------------------------------------------------------- 
Well, ok - patch _would_ be attached, but it's asking me to sign the
license agreement. There is already one on file under Vadacom Ltd. Signing
again requires going through all the corporate procedures, at which point
your name will be mud with my CEO - "What, they *lost* the agreement!?"

Properly disclaimed code:

Index: channels/chan_sip.c
===================================================================
--- channels/chan_sip.c (revision 1546)
+++ channels/chan_sip.c (working copy)
@@ -5239,14 +5239,21 @@
        /* Check which device/devices we are watching  and if they are
registered */
        if (ast_get_hint(hint, sizeof(hint), NULL, 0, NULL, p->context,
p->exten)) {
                char *hint2 = hint, *individual_hint = NULL;
+               int hint_count = 0, unavailable_count = 0;
+
                while ((individual_hint = strsep(&hint2, "&"))) {
-                       /* If they are not registered, we will override
notification and show no availability */
+                       hint_count++;
+
                        if (ast_device_state(individual_hint) ==
AST_DEVICE_UNAVAILABLE) {
-                               local_state = NOTIFY_CLOSED;
-                               pidfstate = "away";
-                               pidfnote = "Not online";
+                               unavailable_count++;
                        }
                }
+               /* If none of the hinted devices are registered, we will
override notification and show no availability */
+               if (hint_count > 0 && hint_count == unavailable_count) {
+                       local_state = NOTIFY_CLOSED;
+                       pidfstate = "away";
+                       pidfnote = "Not online";
+               }
        }
 
        ast_copy_string(from, get_header(&p->initreq, "From"),
sizeof(from)); 

Issue History 
Date Modified   Username       Field                    Change               
====================================================================== 
07-09-07 21:54  nic_bellamy    Note Added: 0067026                          
======================================================================




More information about the Asterisk-bugs mailing list