Review Board 1.7.16


Fix Distributed Device State broken at sites using res_xmpp or res_jabber where Secuity Advisory AST-2012-015 is inplace.

Review Request #2452 - Created April 14, 2013 and submitted

Alec Davis
1.8 to trunk
ASTERISK-21429
Reviewers
asterisk-dev
Asterisk
The site that doesn't update it's devicestates from the remotesite is the site with ASR-2012-015 inplace.

This fixes the scenario where one site doesn't send the IE cachable=1 in the XMPP/Jabber message, to a newer system that expects to see it.

If the IE 'cachable' isn't present we need to default to AST_DEVSTATE_CACHABLE.
 Assigning the cachable variable directly from ast_event_get_ie_uint is wrong, if the IE 'cachable' isn't found ast_event_get_ie_uint() will return 0, 0 = AST_DEVSTATE_NOT_CACHABLE

We need to read the 'cachable' IE into a string first, allowing us to check that it exists, if it doesn't exist then default to cachable=AST_DEVSTATE_CACHABLE.
 If the 'cachable' IE does exist, then convert to a uint, validate value and go with it.


Caused by:
https://issues.asterisk.org/jira/browse/ASTERISK-20175
Yes, change device state, at either site, and it's reflected in the other. One site is prior to ASTERISK-21075.

Tested both sites at r385594, and states correct at both sites.

Changes between revision 3 and 4

1 2 3 4
1 2 3 4

  1. branches/11/main/devicestate.c: Loading...
branches/11/main/devicestate.c
Diff Revision 3 Diff Revision 4
[20] 723 lines
[+20] [+] static void devstate_change_collector_cb(const struct ast_event *event, void *data)
724

    
   
724

   
725
	strcpy(sc->device, device);
725
	strcpy(sc->device, device);
726
	sc->eid = *eid;
726
	sc->eid = *eid;
727
	sc->state = state;
727
	sc->state = state;
728

    
   
728

   

    
   
729
	/* For 'cachable' we cannot use ast_event_get_ie_uint(), it overwrites the default of AST_DEVSTATE_CACHABLE we

    
   
730
	 * have already setup for 'cachable', if for whatever reason the AST_EVENT_IE_CACHABLE wasn't

    
   
731
	 * posted in the event ast_event_get_ie_uint() is going will return 0,

    
   
732
	 * which equates to AST_DEVSTATE_NOT_CACHABLE the first enumeration in 'ast_devstate_cache'.

    
   
733
	 */

    
   
734

   
729
	if ((cachable_str = ast_event_get_ie_str(event, AST_EVENT_IE_CACHABLE))) {
735
	if ((cachable_str = ast_event_get_ie_str(event, AST_EVENT_IE_CACHABLE))) {
730
		sscanf(cachable_str, "%30u", &cachable);
736
		sscanf(cachable_str, "%30u", &cachable);
731
	}
737
	}
732
	sc->cachable = cachable;
738
	sc->cachable = cachable;
733

    
   
739

   
[+20] [20] 81 lines
  1. branches/11/main/devicestate.c: Loading...

https://reviewboard.asterisk.org/ runs on a server provided by Digium, Inc. and uses bandwidth donated to the open source Asterisk community by API Digital Communications in Huntsville, AL USA.
Please report problems with this site to asteriskteam@digium.com.