2014-01-03 15:01:43 -06:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								#!/usr/bin/env python 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# 
							 
						 
					
						
							
								
									
										
										
										
											2013-10-29 07:09:18 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								# This work is licensed under the Creative Commons Attribution-ShareAlike 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# 3.0 Unported License.To view a copy of this license, visit 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# Creative Commons, 444 Castro Street, Suite 900, Mountain View, 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# California, 94041, USA. 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-08-31 11:27:00 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# This is a sample application to bridge traffic between IPSC networks. it uses 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# one required (bridge_rules.py) and one optional (known_bridges.py) additional 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# configuration files. Both files have their own documentation for use. 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# "bridge_rules" contains the IPSC network, Timeslot and TGID matching rules to 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# determine which voice calls are bridged between IPSC networks and which are 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# not. 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# "known_bridges" contains DMR radio ID numbers of known bridges. This file is 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# used when you want bridge.py to be "polite" or serve as a backup bridge. If 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# a known bridge exists in either a source OR target IPSC network, then no 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# bridging between those IPSC networks will take place. This behavior is 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# dynamic and updates each keep-alive interval (main configuration file). 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# For faster failover, configure a short keep-alive time and a low number of 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# missed keep-alives before timout. I recommend 5 sec keep-alive and 3 missed. 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# That gives a worst-case scenario of 15 seconds to fail over. Recovery will 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# typically happen with a single "blip" in the transmission up to about 5 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# seconds. 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# While this file is listed as Beta status, K0USY Group depends on this code 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# for the bridigng of it's many repeaters. We consider it reliable, but you 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# get what you pay for... as usual, no guarantees. 
							 
						 
					
						
							
								
									
										
										
										
											2013-11-24 22:01:20 -06:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2013-10-29 07:09:18 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								from  __future__  import  print_function 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								from  twisted . internet  import  reactor 
							 
						 
					
						
							
								
									
										
										
										
											2014-08-31 11:27:00 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								from  twisted . internet  import  task 
							 
						 
					
						
							
								
									
										
										
										
											2013-11-13 19:07:20 -06:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								from  binascii  import  b2a_hex  as  h 
							 
						 
					
						
							
								
									
										
										
										
											2015-05-13 09:40:56 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								from  time  import  time 
							 
						 
					
						
							
								
									
										
										
										
											2013-10-29 07:09:18 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2013-11-21 18:38:15 -06:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								import  sys 
							 
						 
					
						
							
								
									
										
										
										
											2015-06-30 20:36:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								from  dmrlink  import  IPSC ,  NETWORK ,  networks ,  REPORTS ,  reporting_loop ,  dmr_nat ,  logger ,  hex_str_3 ,  hex_str_4 ,  int_id 
							 
						 
					
						
							
								
									
										
										
										
											2013-10-31 21:45:57 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-01-03 15:01:43 -06:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								__author__  =  ' Cortney T. Buffington, N0MJS ' 
							 
						 
					
						
							
								
									
										
										
										
											2016-04-28 14:28:32 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								__copyright__  =  ' Copyright (c) 2013 - 2016 Cortney T. Buffington, N0MJS and the K0USY Group ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								__credits__  =  ' Adam Fast, KC0YLK; Dave Kierzkowski, KD8EYF; Steve Zingman, N4IRS; Mike Zingman, N4IRR ' 
							 
						 
					
						
							
								
									
										
										
										
											2014-01-03 15:01:43 -06:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								__license__  =  ' Creative Commons Attribution-ShareAlike 3.0 Unported ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								__maintainer__  =  ' Cort Buffington, N0MJS ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								__email__  =  ' n0mjs@me.com ' 
							 
						 
					
						
							
								
									
										
										
										
											2014-08-31 13:18:34 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								__status__  =  ' beta ' 
							 
						 
					
						
							
								
									
										
										
										
											2014-01-03 15:01:43 -06:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2013-11-21 18:50:01 -06:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-05-14 23:00:19 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# Constants for this application 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# 
							 
						 
					
						
							
								
									
										
										
										
											2014-09-18 20:08:54 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								BURST_DATA_TYPE  =  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    ' VOICE_HEAD ' :   ' \x01 ' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    ' VOICE_TERM ' :   ' \x02 ' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    ' SLOT1_VOICE ' :  ' \x0A ' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    ' SLOT2_VOICE ' :  ' \x8A '    
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
									
										
										
										
											2016-05-01 10:49:30 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# Minimum time between different subscribers transmitting on the same TGID 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# 
							 
						 
					
						
							
								
									
										
										
										
											2015-05-14 23:00:19 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								TS_CLEAR_TIME  =  .2 
							 
						 
					
						
							
								
									
										
										
										
											2013-11-14 20:14:16 -06:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2013-11-17 18:13:59 -06:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# Import Bridging rules 
							 
						 
					
						
							
								
									
										
										
										
											2014-08-31 11:27:00 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# Note: A stanza *must* exist for any IPSC configured in the main 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# configuration file and listed as "active". It can be empty,  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# but it has to exist. 
							 
						 
					
						
							
								
									
										
										
										
											2013-11-17 18:13:59 -06:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								try : 
							 
						 
					
						
							
								
									
										
										
										
											2015-05-17 11:19:19 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    from  bridge_rules  import  RULES  as  RULES_FILE 
							 
						 
					
						
							
								
									
										
										
										
											2014-08-31 11:27:00 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    logger . info ( ' Bridge rules file found and rules imported ' ) 
							 
						 
					
						
							
								
									
										
										
										
											2013-11-17 18:13:59 -06:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								except  ImportError : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    sys . exit ( ' Bridging rules file not found or invalid ' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-08-31 11:27:00 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# Convert integer GROUP ID numbers from the config into hex strings 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# we need to send in the actual data packets. 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-05-17 11:19:19 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								for  _ipsc  in  RULES_FILE : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    for  _rule  in  RULES_FILE [ _ipsc ] [ ' GROUP_VOICE ' ] : 
							 
						 
					
						
							
								
									
										
										
										
											2014-08-31 11:27:00 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        _rule [ ' SRC_GROUP ' ]  =  hex_str_3 ( _rule [ ' SRC_GROUP ' ] ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        _rule [ ' DST_GROUP ' ]  =  hex_str_3 ( _rule [ ' DST_GROUP ' ] ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-04-26 18:56:45 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        _rule [ ' SRC_TS ' ]     =  _rule [ ' SRC_TS ' ]  -  1 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        _rule [ ' DST_TS ' ]     =  _rule [ ' DST_TS ' ]  -  1 
							 
						 
					
						
							
								
									
										
										
										
											2016-05-01 07:47:46 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        for  i ,  e  in  enumerate ( _rule [ ' ON ' ] ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            _rule [ ' ON ' ] [ i ]  =  hex_str_3 ( _rule [ ' ON ' ] [ i ] ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        for  i ,  e  in  enumerate ( _rule [ ' OFF ' ] ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            _rule [ ' OFF ' ] [ i ]  =  hex_str_3 ( _rule [ ' OFF ' ] [ i ] ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-05-17 08:14:29 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if  _ipsc  not  in  NETWORK : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        sys . exit ( ' ERROR: Bridge rules found for an IPSC network not configured in main configuration ' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								for  _ipsc  in  NETWORK : 
							 
						 
					
						
							
								
									
										
										
										
											2015-05-17 11:19:19 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if  _ipsc  not  in  RULES_FILE : 
							 
						 
					
						
							
								
									
										
										
										
											2015-05-17 08:14:29 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        sys . exit ( ' ERROR: Bridge rules not found for all IPSC network configured ' ) 
							 
						 
					
						
							
								
									
										
										
										
											2014-08-31 11:27:00 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-05-17 11:19:19 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								RULES  =  RULES_FILE 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-08-31 11:27:00 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# Import List of Bridges 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# This is how we identify known bridges. If one of these is present 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# and it's mode byte is set to bridge, we don't 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								try : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    from  known_bridges  import  BRIDGES 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    logger . info ( ' Known bridges file found and bridge ID list imported  ' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								except  ImportError : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    logger . critical ( ' \' known_bridges.py \'  not found - backup bridge service will not be enabled ' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    BRIDGES  =  [ ] 
							 
						 
					
						
							
								
									
										
										
										
											2013-10-29 07:09:18 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-05-03 19:53:22 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# Import subscriber ACL 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# ACL may be a single list of subscriber IDs 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# Global action is to allow or deny them. Multiple lists with different actions and ranges 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# are not yet implemented. 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								try : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    from  sub_acl  import  ACL_ACTION ,  ACL 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    # uses more memory to build hex strings, but processes MUCH faster when checking for matches 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    for  i ,  e  in  enumerate ( ACL ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        ACL [ i ]  =  hex_str_3 ( ACL [ i ] ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    logger . info ( ' Subscriber access control file found, subscriber ACL imported ' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								except  ImportError : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    logger . critical ( ' \' sub_acl.py \'  not found - all subscriber IDs are valid ' ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-05-03 20:15:55 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    ACL_ACTION  =  ' NONE ' 
							 
						 
					
						
							
								
									
										
										
										
											2016-05-03 19:53:22 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# Depending on which type of ACL is used (PERMIT, DENY... or there isn't one) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# define a differnet function to be used to check the ACL 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  ACL_ACTION  ==  ' PERMIT ' : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    def  allow_sub ( _sub ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if  _sub  in  ACL : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            return  True 
							 
						 
					
						
							
								
									
										
										
										
											2016-05-03 20:15:55 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        else : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            return  False 
							 
						 
					
						
							
								
									
										
										
										
											2016-05-03 19:53:22 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								elif  ACL_ACTION  ==  ' DENY ' : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    def  allow_sub ( _sub ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if  _sub  not  in  ACL : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            return  True 
							 
						 
					
						
							
								
									
										
										
										
											2016-05-03 20:15:55 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        else : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            return  False 
							 
						 
					
						
							
								
									
										
										
										
											2016-05-03 19:53:22 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								else : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    def  allow_sub ( _sub ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        return  True 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-08-31 11:27:00 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-05-14 23:00:19 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								class  bridgeIPSC ( IPSC ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    def  __init__ ( self ,  * args ,  * * kwargs ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        IPSC . __init__ ( self ,  * args ,  * * kwargs ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if  BRIDGES : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            logger . info ( ' Initializing backup/polite bridging ' ) 
							 
						 
					
						
							
								
									
										
										
										
											2014-08-31 11:27:00 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            self . BRIDGE  =  False 
							 
						 
					
						
							
								
									
										
										
										
											2015-05-14 23:00:19 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        else : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            self . BRIDGE  =  True 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            logger . info ( ' Initializing standard bridging ' ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-05-17 11:19:19 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-05-14 23:00:19 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        self . IPSC_STATUS  =  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            ' TS1 ' :  { ' RX_GROUP ' : ' \x00 ' ,  ' TX_GROUP ' : ' \x00 ' ,  ' RX_TIME ' : 0 ,  ' TX_TIME ' : 0 ,  ' RX_SRC_SUB ' : ' \x00 ' ,  ' TX_SRC_SUB ' : ' \x00 ' } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            ' TS2 ' :  { ' RX_GROUP ' : ' \x00 ' ,  ' TX_GROUP ' : ' \x00 ' ,  ' RX_TIME ' : 0 ,  ' TX_TIME ' : 0 ,  ' RX_SRC_SUB ' : ' \x00 ' ,  ' TX_SRC_SUB ' : ' \x00 ' } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    # Setup the backup/polite bridging maintenance loop (based on keep-alive timer) 
							 
						 
					
						
							
								
									
										
										
										
											2014-08-31 11:27:00 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    
							 
						 
					
						
							
								
									
										
										
										
											2015-05-14 23:00:19 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if  BRIDGES : 
							 
						 
					
						
							
								
									
										
										
										
											2014-08-31 11:27:00 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        def  startProtocol ( self ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            IPSC . startProtocol ( self ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-05-14 23:00:19 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-08-31 11:27:00 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            self . _bridge_presence  =  task . LoopingCall ( self . bridge_presence_loop ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            self . _bridge_presence_loop  =  self . _bridge_presence . start ( self . _local [ ' ALIVE_TIMER ' ] ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-05-14 23:00:19 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    # This is the backup/polite bridge maintenance loop 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    def  bridge_presence_loop ( self ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        _temp_bridge  =  True 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        for  peer  in  BRIDGES : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            _peer  =  hex_str_4 ( peer ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            if  _peer  in  self . _peers . keys ( )  and  ( self . _peers [ _peer ] [ ' MODE_DECODE ' ] [ ' TS_1 ' ]  or  self . _peers [ _peer ] [ ' MODE_DECODE ' ] [ ' TS_2 ' ] ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                _temp_bridge  =  False 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                logger . debug ( ' ( %s ) Peer  %s  is an active bridge ' ,  self . _network ,  int_id ( _peer ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            if  _peer  ==  self . _master [ ' RADIO_ID ' ]  \
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                and  self . _master [ ' STATUS ' ] [ ' CONNECTED ' ]  \
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                and  ( self . _master [ ' MODE_DECODE ' ] [ ' TS_1 ' ]  or  self . _master [ ' MODE_DECODE ' ] [ ' TS_2 ' ] ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                _temp_bridge  =  False 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                logger . debug ( ' ( %s ) Master  %s  is an active bridge ' , self . _network ,  int_id ( _peer ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if  self . BRIDGE  !=  _temp_bridge : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            logger . info ( ' ( %s ) Changing bridge status to:  %s ' ,  self . _network ,  _temp_bridge  ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        self . BRIDGE  =  _temp_bridge 
							 
						 
					
						
							
								
									
										
										
										
											2015-05-13 20:35:18 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-05-14 23:00:19 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    #************************************************ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    #     CALLBACK FUNCTIONS FOR USER PACKET TYPES 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    #************************************************ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    # 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    def  group_voice ( self ,  _network ,  _src_sub ,  _dst_group ,  _ts ,  _end ,  _peerid ,  _data ) : 
							 
						 
					
						
							
								
									
										
										
										
											2016-05-03 19:53:22 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        # Check for ACL match, and return if the subscriber is not allowed 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if  allow_sub ( _src_sub )  ==  False : 
							 
						 
					
						
							
								
									
										
										
										
											2016-05-03 20:15:55 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            logger . warning ( ' ( %s ) Group Voice Packet ***REJECTED BY ACL*** From:  %s , IPSC Peer  %s , Destination  %s ' ,  _network ,  int_id ( _src_sub ) ,  int_id ( _peerid ) ,  int_id ( _dst_group ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-05-03 19:53:22 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            return 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        # Process the packet 
							 
						 
					
						
							
								
									
										
										
										
											2015-05-14 23:00:19 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        logger . debug ( ' ( %s ) Group Voice Packet Received From:  %s , IPSC Peer  %s , Destination  %s ' ,  _network ,  int_id ( _src_sub ) ,  int_id ( _peerid ) ,  int_id ( _dst_group ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        _burst_data_type  =  _data [ 30 ]  # Determine the type of voice packet this is (see top of file for possible types) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if  _ts  ==  0 : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            _TS  =  ' TS1 ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        elif  _ts  ==  1 : 
							 
						 
					
						
							
								
									
										
										
										
											2016-05-01 10:49:30 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            _TS  =  ' TS2 '                
							 
						 
					
						
							
								
									
										
										
										
											2016-04-26 18:56:45 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        
							 
						 
					
						
							
								
									
										
										
										
											2016-05-01 07:47:46 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        now  =  time ( )  # Mark packet arrival time -- we'll need this for call contention handling  
							 
						 
					
						
							
								
									
										
										
										
											2015-05-23 08:54:46 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        
							 
						 
					
						
							
								
									
										
										
										
											2015-05-14 23:00:19 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        for  rule  in  RULES [ _network ] [ ' GROUP_VOICE ' ] : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            _target  =  rule [ ' DST_NET ' ]                # Shorthand to reduce length and make it easier to read 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            _status  =  networks [ _target ] . IPSC_STATUS  # Shorthand to reduce length and make it easier to read 
							 
						 
					
						
							
								
									
										
										
										
											2015-05-23 08:54:46 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-05-14 23:00:19 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            # Matching for rules is against the Destination Group in the SOURCE packet (SRC_GROUP) 
							 
						 
					
						
							
								
									
										
										
										
											2016-05-01 10:49:30 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            # if rule['SRC_GROUP'] == _dst_group and rule['SRC_TS'] == _ts: 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            # if BRIDGES: 
							 
						 
					
						
							
								
									
										
										
										
											2016-04-26 18:56:45 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            if  ( rule [ ' SRC_GROUP ' ]  ==  _dst_group  and  rule [ ' SRC_TS ' ]  ==  _ts  and  rule [ ' ACTIVE ' ]  ==  True )  and  ( self . BRIDGE  ==  True  or  networks [ _target ] . BRIDGE  ==  True ) : 
							 
						 
					
						
							
								
									
										
										
										
											2016-05-01 10:49:30 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                # 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                # BEGIN CONTENTION HANDLING 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                #  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                # If this is an inter-DMRlink trunk, this isn't necessary 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                if  RULES [ _network ] [ ' TRUNK ' ]  ==  False :  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    # The rules for each of the 4 "ifs" below are listed here for readability. The Frame To Send is: 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    #   From a different group than last RX from this IPSC, but it has been less than Group Hangtime 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    #   From a different group than last TX to this IPSC, but it has been less than Group Hangtime 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    #   From the same group as the last RX from this IPSC, but from a different subscriber, and it has been less than TS Clear Time 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    #   From the same group as the last TX to this IPSC, but from a different subscriber, and it has been less than TS Clear Time 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    # The "continue" at the end of each means the next iteration of the for loop that tests for matching rules 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    # 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-22 15:02:36 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                    if  ( ( rule [ ' DST_GROUP ' ]  !=  _status [ _TS ] [ ' RX_GROUP ' ] )  and  ( ( now  -  _status [ _TS ] [ ' RX_TIME ' ] )  <  RULES [ _network ] [ ' GROUP_HANGTIME ' ] ) ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                        if  _burst_data_type  ==  BURST_DATA_TYPE [ ' VOICE_HEAD ' ] : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                            logger . info ( ' ( %s ) Call not bridged, target active or in group hangtime: IPSC  %s ,  %s , TGID %s ' ,  _network ,  _target ,  _TS ,  int_id ( rule [ ' DST_GROUP ' ] ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-05-01 10:49:30 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                        continue     
							 
						 
					
						
							
								
									
										
										
										
											2015-07-22 15:02:36 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                    if  ( ( rule [ ' DST_GROUP ' ]  !=  _status [ _TS ] [ ' TX_GROUP ' ] )  and  ( ( now  -  _status [ _TS ] [ ' TX_TIME ' ] )  <  RULES [ _network ] [ ' GROUP_HANGTIME ' ] ) ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                        if  _burst_data_type  ==  BURST_DATA_TYPE [ ' VOICE_HEAD ' ] : 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-27 16:29:23 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                            logger . info ( ' ( %s ) Call not bridged to destination on TGID  %s , target in group hangtime: IPSC  %s ,  %s , TGID %s ' ,  _network ,  int_id ( _status [ _TS ] [ ' TX_GROUP ' ] ) ,  _target ,  _TS ,  int_id ( rule [ ' DST_GROUP ' ] ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-08-06 22:51:34 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                        continue 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-22 15:02:36 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                    if  ( rule [ ' DST_GROUP ' ]  ==  _status [ _TS ] [ ' RX_GROUP ' ] )  and  ( ( now  -  _status [ _TS ] [ ' RX_TIME ' ] )  <  TS_CLEAR_TIME ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                        if  _burst_data_type  ==  BURST_DATA_TYPE [ ' VOICE_HEAD ' ] : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                            logger . info ( ' ( %s ) Call not bridged, matching call already active on target: IPSC  %s ,  %s , TGID %s ' ,  _network ,  _target ,  _TS ,  int_id ( rule [ ' DST_GROUP ' ] ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-08-06 22:51:34 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                        continue 
							 
						 
					
						
							
								
									
										
										
										
											2016-05-01 10:49:30 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                    if  ( rule [ ' DST_GROUP ' ]  ==  _status [ _TS ] [ ' TX_GROUP ' ] )  and  ( _src_sub  !=  _status [ _TS ] [ ' TX_SRC_SUB ' ] )  and  ( ( now  -  _status [ _TS ] [ ' TX_TIME ' ] )  <  TS_CLEAR_TIME ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                        if  _burst_data_type  ==  BURST_DATA_TYPE [ ' VOICE_HEAD ' ] : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                            logger . info ( ' ( %s ) Call not bridged, call bridge in progress from  %s , target: IPSC  %s ,  %s , TGID %s ' ,  _network ,  int_id ( _src_sub ) ,  _target ,  _TS ,  int_id ( rule [ ' DST_GROUP ' ] ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                        continue 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                # 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                # END CONTENTION HANDLING 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                # 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                # 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                # BEGIN FRAME FORWARDING 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                #      
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                # Make a copy of the payload        
							 
						 
					
						
							
								
									
										
										
										
											2015-05-28 09:42:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                _tmp_data  =  _data 
							 
						 
					
						
							
								
									
										
										
										
											2016-05-01 10:49:30 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                
							 
						 
					
						
							
								
									
										
										
										
											2015-05-28 09:42:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                # Re-Write the IPSC SRC to match the target network's ID 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                _tmp_data  =  _tmp_data . replace ( _peerid ,  NETWORK [ _target ] [ ' LOCAL ' ] [ ' RADIO_ID ' ] ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-05-01 10:49:30 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                
							 
						 
					
						
							
								
									
										
										
										
											2015-05-28 09:42:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                # Re-Write the destination Group ID 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                _tmp_data  =  _tmp_data . replace ( _dst_group ,  rule [ ' DST_GROUP ' ] ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                # Re-Write IPSC timeslot value 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                _call_info  =  int_id ( _data [ 17 : 18 ] ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                if  rule [ ' DST_TS ' ]  ==  0 : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    _call_info  & =  ~ ( 1  <<  5 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                elif  rule [ ' DST_TS ' ]  ==  1 : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    _call_info  | =  1  <<  5 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                _call_info  =  chr ( _call_info ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                _tmp_data  =  _tmp_data [ : 17 ]  +  _call_info  +  _tmp_data [ 18 : ]  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                # Re-Write DMR timeslot value 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                # Determine if the slot is present, so we can translate if need be 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                if  _burst_data_type  ==  BURST_DATA_TYPE [ ' SLOT1_VOICE ' ]  or  _burst_data_type  ==  BURST_DATA_TYPE [ ' SLOT2_VOICE ' ] : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    _slot_valid  =  True 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                else : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    _slot_valid  =  False 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                # Re-Write timeslot if necessary... 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                if  _slot_valid : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    if  rule [ ' DST_TS ' ]  ==  0 : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                        _burst_data_type  =  BURST_DATA_TYPE [ ' SLOT1_VOICE ' ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    elif  rule [ ' DST_TS ' ]  ==  1 : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                        _burst_data_type  =  BURST_DATA_TYPE [ ' SLOT2_VOICE ' ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    _tmp_data  =  _tmp_data [ : 30 ]  +  _burst_data_type  +  _tmp_data [ 31 : ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                # Calculate and append the authentication hash for the target network... if necessary 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                if  NETWORK [ _target ] [ ' LOCAL ' ] [ ' AUTH_ENABLED ' ] : 
							 
						 
					
						
							
								
									
										
										
										
											2015-12-11 10:44:27 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                    _tmp_data  =  self . auth_hashed_packet ( NETWORK [ _target ] [ ' LOCAL ' ] [ ' AUTH_KEY ' ] ,  _tmp_data ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-05-28 09:42:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                # Send the packet to all peers in the target IPSC 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                networks [ _target ] . send_to_ipsc ( _tmp_data ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-05-01 10:49:30 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                # 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                # END FRAME FORWARDING 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                # 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                # Set values for the contention handler to test next time there is a frame to forward 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-27 16:34:46 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                _status [ _TS ] [ ' TX_GROUP ' ]  =  rule [ ' DST_GROUP ' ] 
							 
						 
					
						
							
								
									
										
										
										
											2015-05-28 09:42:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                _status [ _TS ] [ ' TX_TIME ' ]  =  now 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                _status [ _TS ] [ ' TX_SRC_SUB ' ]  =  _src_sub 
							 
						 
					
						
							
								
									
										
										
										
											2016-05-01 10:49:30 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                
							 
						 
					
						
							
								
									
										
										
										
											2015-05-28 09:42:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-05-01 10:49:30 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        # Mark the group and time that a packet was recieved for the contention handler to use later 
							 
						 
					
						
							
								
									
										
										
										
											2015-05-28 09:42:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        self . IPSC_STATUS [ _TS ] [ ' RX_GROUP ' ]  =  _dst_group 
							 
						 
					
						
							
								
									
										
										
										
											2016-05-01 10:49:30 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        self . IPSC_STATUS [ _TS ] [ ' RX_TIME ' ]   =  now 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        # 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        # BEGIN IN-BAND SIGNALING BASED ON TGID & VOICE TERMINATOR FRAME 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        # 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        # Activate/Deactivate rules based on group voice activity -- PTT or UA for you c-Bridge dorks. 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        # This will ONLY work for symmetrical rules!!! 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        # Action happens on un-key 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if  _burst_data_type  ==  BURST_DATA_TYPE [ ' VOICE_TERM ' ] : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            # Iterate the rules dictionary 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            for  rule  in  RULES [ _network ] [ ' GROUP_VOICE ' ] : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                # TGID matches an ACTIVATION trigger 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                if  _dst_group  in  rule [ ' ON ' ] : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    # Set the matching rule as ACTIVE 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    rule [ ' ACTIVE ' ]  =  True 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    logger . info ( ' ( %s ) Primary Bridge Rule  \" %s \"  changed to state:  %s ' ,  _network ,  rule [ ' NAME ' ] ,  rule [ ' ACTIVE ' ] ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    # Set reciprocal rules for other IPSCs as ACTIVE 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    _target  =  rule [ ' DST_NET ' ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    for  target_rule  in  RULES [ _target ] [ ' GROUP_VOICE ' ] : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                        if  target_rule [ ' NAME ' ]  ==  rule [ ' NAME ' ] : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                            target_rule [ ' ACTIVE ' ]  =  True 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                            logger . info ( ' ( %s ) Reciprocal Bridge Rule  \" %s \"  in IPSC  \" %s \"  changed to state:  %s ' ,  _network ,  target_rule [ ' NAME ' ] ,  _target ,  rule [ ' ACTIVE ' ] ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                            
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                # TGID matches an DE-ACTIVATION trigger 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                if  _dst_group  in  rule [ ' OFF ' ] : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    # Set the matching rule as ACTIVE 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    rule [ ' ACTIVE ' ]  =  False 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    logger . info ( ' ( %s ) Bridge Rule  \" %s \"  changed to state:  %s ' ,  _network ,  rule [ ' NAME ' ] ,  rule [ ' ACTIVE ' ] ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    # Set reciprocal rules for other IPSCs as ACTIVE 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    _target  =  rule [ ' DST_NET ' ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    for  target_rule  in  RULES [ _target ] [ ' GROUP_VOICE ' ] : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                        if  target_rule [ ' NAME ' ]  ==  rule [ ' NAME ' ] : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                            target_rule [ ' ACTIVE ' ]  =  False 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                            logger . info ( ' ( %s ) Reciprocal Bridge Rule  \" %s \"  in IPSC  \" %s \"  changed to state:  %s ' ,  _network ,  target_rule [ ' NAME ' ] ,  _target ,  rule [ ' ACTIVE ' ] ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        #                     
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        # END IN-BAND SIGNALLING 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        # 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-05-28 09:42:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-05-21 09:39:42 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    def  group_data ( self ,  _network ,  _src_sub ,  _dst_sub ,  _ts ,  _end ,  _peerid ,  _data ) :     
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        logger . debug ( ' ( %s ) Group Data Packet Received From:  %s , IPSC Peer  %s , Destination  %s ' ,  _network ,  int_id ( _src_sub ) ,  int_id ( _peerid ) ,  int_id ( _dst_sub ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        
							 
						 
					
						
							
								
									
										
										
										
											2015-08-14 08:36:29 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        for  target  in  RULES [ _network ] [ ' GROUP_DATA ' ] : 
							 
						 
					
						
							
								
									
										
										
										
											2015-05-28 09:42:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            
							 
						 
					
						
							
								
									
										
										
										
											2015-08-14 08:36:29 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            if  self . BRIDGE  ==  True  or  networks [ target ] . BRIDGE  ==  True : 
							 
						 
					
						
							
								
									
										
										
										
											2015-05-28 09:42:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                _tmp_data  =  _data 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                # Re-Write the IPSC SRC to match the target network's ID 
							 
						 
					
						
							
								
									
										
										
										
											2015-08-14 08:36:29 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                _tmp_data  =  _tmp_data . replace ( _peerid ,  NETWORK [ target ] [ ' LOCAL ' ] [ ' RADIO_ID ' ] ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-05-28 09:42:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                # Calculate and append the authentication hash for the target network... if necessary 
							 
						 
					
						
							
								
									
										
										
										
											2015-08-14 08:36:29 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                if  NETWORK [ target ] [ ' LOCAL ' ] [ ' AUTH_ENABLED ' ] : 
							 
						 
					
						
							
								
									
										
										
										
											2015-12-11 10:44:27 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                    _tmp_data  =  self . auth_hashed_packet ( NETWORK [ target ] [ ' LOCAL ' ] [ ' AUTH_KEY ' ] ,  _tmp_data ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-05-28 09:42:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                # Send the packet to all peers in the target IPSC 
							 
						 
					
						
							
								
									
										
										
										
											2015-08-14 08:36:29 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                networks [ target ] . send_to_ipsc ( _tmp_data ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-05-28 09:42:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-05-21 09:39:42 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    def  private_data ( self ,  _network ,  _src_sub ,  _dst_sub ,  _ts ,  _end ,  _peerid ,  _data ) :     
							 
						 
					
						
							
								
									
										
										
										
											2015-05-23 09:03:06 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        logger . debug ( ' ( %s ) Private Data Packet Received From:  %s , IPSC Peer  %s , Destination  %s ' ,  _network ,  int_id ( _src_sub ) ,  int_id ( _peerid ) ,  int_id ( _dst_sub ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-05-21 09:39:42 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        
							 
						 
					
						
							
								
									
										
										
										
											2015-08-14 08:36:29 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        for  target  in  RULES [ _network ] [ ' PRIVATE_DATA ' ] : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                   
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            if  self . BRIDGE  ==  True  or  networks [ target ] . BRIDGE  ==  True : 
							 
						 
					
						
							
								
									
										
										
										
											2015-05-28 09:42:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                _tmp_data  =  _data 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                # Re-Write the IPSC SRC to match the target network's ID 
							 
						 
					
						
							
								
									
										
										
										
											2015-08-14 08:36:29 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                _tmp_data  =  _tmp_data . replace ( _peerid ,  NETWORK [ target ] [ ' LOCAL ' ] [ ' RADIO_ID ' ] ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-05-28 09:42:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                # Calculate and append the authentication hash for the target network... if necessary 
							 
						 
					
						
							
								
									
										
										
										
											2015-08-14 08:36:29 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                if  NETWORK [ target ] [ ' LOCAL ' ] [ ' AUTH_ENABLED ' ] : 
							 
						 
					
						
							
								
									
										
										
										
											2015-12-11 10:44:27 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                    _tmp_data  =  self . auth_hashed_packet ( NETWORK [ target ] [ ' LOCAL ' ] [ ' AUTH_KEY ' ] ,  _tmp_data ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-05-28 09:42:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                # Send the packet to all peers in the target IPSC 
							 
						 
					
						
							
								
									
										
										
										
											2015-08-14 08:36:29 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                networks [ target ] . send_to_ipsc ( _tmp_data ) 
							 
						 
					
						
							
								
									
										
										
										
											2014-08-31 11:27:00 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2013-12-12 19:59:04 -06:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2013-11-09 11:33:52 -06:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								if  __name__  ==  ' __main__ ' : 
							 
						 
					
						
							
								
									
										
										
										
											2015-05-13 09:40:56 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    logger . info ( ' DMRlink  \' bridge.py \'  (c) 2013-2015 N0MJS & the K0USY Group - SYSTEM STARTING... ' ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-06-30 20:36:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    # INITIALIZE AN IPSC OBJECT (SELF SUSTAINING) FOR EACH CONFIGUED IPSC 
							 
						 
					
						
							
								
									
										
										
										
											2013-11-09 11:33:52 -06:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    for  ipsc_network  in  NETWORK : 
							 
						 
					
						
							
								
									
										
										
										
											2013-12-03 10:48:08 -06:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        if  NETWORK [ ipsc_network ] [ ' LOCAL ' ] [ ' ENABLED ' ] : 
							 
						 
					
						
							
								
									
										
										
										
											2014-04-28 21:42:47 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            networks [ ipsc_network ]  =  bridgeIPSC ( ipsc_network ) 
							 
						 
					
						
							
								
									
										
										
										
											2014-10-31 10:30:18 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            reactor . listenUDP ( NETWORK [ ipsc_network ] [ ' LOCAL ' ] [ ' PORT ' ] ,  networks [ ipsc_network ] ,  interface = NETWORK [ ipsc_network ] [ ' LOCAL ' ] [ ' IP ' ] ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-06-30 20:36:14 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    # INITIALIZE THE REPORTING LOOP IF CONFIGURED 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  REPORTS [ ' REPORT_NETWORKS ' ] : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        reporting  =  task . LoopingCall ( reporting_loop ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        reporting . start ( REPORTS [ ' REPORT_INTERVAL ' ] ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								       
							 
						 
					
						
							
								
									
										
										
										
											2014-04-29 22:00:38 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    reactor . run ( )