Routing rules work, but can't translate yet
Looks like the LC needs decoded, re-written, and re-encoded (FEC) before we can re-write the TGID.
This commit is contained in:
		
							parent
							
								
									973c93ece4
								
							
						
					
					
						commit
						adc0203379
					
				
							
								
								
									
										27
									
								
								hb_router.py
									
									
									
									
									
								
							
							
						
						
									
										27
									
								
								hb_router.py
									
									
									
									
									
								
							@ -10,6 +10,7 @@ from __future__ import print_function
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
# Python modules we need
 | 
					# Python modules we need
 | 
				
			||||||
import sys
 | 
					import sys
 | 
				
			||||||
 | 
					from binascii import b2a_hex as h
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Debugging functions
 | 
					# Debugging functions
 | 
				
			||||||
from pprint import pprint
 | 
					from pprint import pprint
 | 
				
			||||||
@ -67,50 +68,48 @@ __status__     = 'pre-alpha'
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
class routerMASTER(HBMASTER):
 | 
					class routerMASTER(HBMASTER):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def dmrd_received(_radio_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _stream_id, _data):
 | 
					    def dmrd_received(self, _radio_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _stream_id, _data):
 | 
				
			||||||
        _bits = int_id(_data[15])
 | 
					        _bits = int_id(_data[15])
 | 
				
			||||||
 | 
					 | 
				
			||||||
        if _call_type == 'group':
 | 
					        if _call_type == 'group':
 | 
				
			||||||
            for rule in RULES[self._master]['GROUP_VOICE']:
 | 
					            for rule in RULES[self._master]['GROUP_VOICE']:
 | 
				
			||||||
                _target = rule['DST_NET']
 | 
					                _target = rule['DST_NET']
 | 
				
			||||||
                if (rule['SRC_GROUP'] == _dst_id and rule['SRC_TS'] == _slot and rule['ACTIVE'] == True):
 | 
					                if (rule['SRC_GROUP'] == _dst_id and rule['SRC_TS'] == _slot and rule['ACTIVE'] == True):
 | 
				
			||||||
                    if RULE['SRC_TS'] != RULE['DST_TS']:
 | 
					                    if rule['SRC_TS'] != rule['DST_TS']:
 | 
				
			||||||
                        _tmp_bits = _bits ^ 1 << 7
 | 
					                        _tmp_bits = _bits ^ 1 << 7
 | 
				
			||||||
                    else:
 | 
					                    else:
 | 
				
			||||||
                        _tmp_bits = _bits
 | 
					                        _tmp_bits = _bits
 | 
				
			||||||
                    _tmp_data = _data[:8] + rule['DST_GROUP'] + _data[12:15] + chr(bits) + _data[16:]
 | 
					                    _tmp_data = _data[:8] + rule['DST_GROUP'] + _data[11:15] + chr(_bits) + _data[16:]
 | 
				
			||||||
                    print(h(_tmp_data))
 | 
					                    print(h(_data))
 | 
				
			||||||
                    print(h(_tmp_data))
 | 
					                    print(h(_tmp_data))
 | 
				
			||||||
                    systems[_target].send_system(_tmp_data)
 | 
					                    systems[_target].send_system(_tmp_data)
 | 
				
			||||||
                
 | 
					                
 | 
				
			||||||
                    logger.debug('(%s) Packet routed %s to system: %s', self._master, CONFIG[_target]['MODE'], _target)
 | 
					                    logger.debug('(%s) Packet routed to %s system: %s', self._master, CONFIG['SYSTEMS'][_target]['MODE'], _target)
 | 
				
			||||||
                else:
 | 
					                else:
 | 
				
			||||||
                    logger.debug('(%s) Packet router found no target for packet. Destination was: %s on target network %s', self._master, _dst_id, _target)
 | 
					                    logger.debug('(%s) Packet router no target TS/TGID %s/%s on target network %s', self._master, _slot, int_id(_dst_id), _target)
 | 
				
			||||||
                    continue
 | 
					                    continue
 | 
				
			||||||
                
 | 
					                
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class routerCLIENT(HBCLIENT):
 | 
					class routerCLIENT(HBCLIENT):
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    def dmrd_received(_radio_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _stream_id, _data):
 | 
					    def dmrd_received(self, _radio_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _stream_id, _data):
 | 
				
			||||||
        _bits = int_id(_data[15])
 | 
					        _bits = int_id(_data[15])
 | 
				
			||||||
 | 
					 | 
				
			||||||
        if _call_type == 'group':
 | 
					        if _call_type == 'group':
 | 
				
			||||||
            for rule in RULES[self._client]['GROUP_VOICE']:
 | 
					            for rule in RULES[self._client]['GROUP_VOICE']:
 | 
				
			||||||
                _target = rule['DST_NET']
 | 
					                _target = rule['DST_NET']
 | 
				
			||||||
                if (rule['SRC_GROUP'] == _dst_id and rule['SRC_TS'] == _slot and rule['ACTIVE'] == True):
 | 
					                if (rule['SRC_GROUP'] == _dst_id and rule['SRC_TS'] == _slot and rule['ACTIVE'] == True):
 | 
				
			||||||
                    if RULE['SRC_TS'] != RULE['DST_TS']:
 | 
					                    if rule['SRC_TS'] != rule['DST_TS']:
 | 
				
			||||||
                        _tmp_bits = _bits ^ 1 << 7
 | 
					                        _tmp_bits = _bits ^ 1 << 7
 | 
				
			||||||
                    else:
 | 
					                    else:
 | 
				
			||||||
                        _tmp_bits = _bits
 | 
					                        _tmp_bits = _bits
 | 
				
			||||||
                    _tmp_data = _data[:8] + rule['DST_GROUP'] + _data[12:15] + chr(bits) + _data[16:]
 | 
					                    _tmp_data = _data[:8] + rule['DST_GROUP'] + _data[11:15] + chr(_bits) + _data[16:]
 | 
				
			||||||
                    print(h(_tmp_data))
 | 
					                    print(h(_data))
 | 
				
			||||||
                    print(h(_tmp_data))
 | 
					                    print(h(_tmp_data))
 | 
				
			||||||
                    systems[_target].send_system(_tmp_data)
 | 
					                    systems[_target].send_system(_tmp_data)
 | 
				
			||||||
                    
 | 
					                    
 | 
				
			||||||
                    logger.debug('(%s) Packet routed to %s system: %s', self._client, CONFIG[_target]['MODE'], _target)
 | 
					                    logger.debug('(%s) Packet routed to %s system: %s', self._client, CONFIG['SYSTEMS'][_target]['MODE'], _target)
 | 
				
			||||||
                
 | 
					                
 | 
				
			||||||
                else:
 | 
					                else:
 | 
				
			||||||
                    logger.debug('(%s) Packet router found no target for packet. Destination was: %s on target network %s', self._client, _dst_id, _target)
 | 
					                    logger.debug('(%s) Packet router no target TS/TGID %s/%s on target network %s', self._master, _slot, int_id(_dst_id), _target)
 | 
				
			||||||
                    continue
 | 
					                    continue
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#************************************************
 | 
					#************************************************
 | 
				
			||||||
 | 
				
			|||||||
@ -203,7 +203,7 @@ class HBMASTER(DatagramProtocol):
 | 
				
			|||||||
    # regardless of the system type (MASTER or CLIENT)
 | 
					    # regardless of the system type (MASTER or CLIENT)
 | 
				
			||||||
    send_system = send_clients
 | 
					    send_system = send_clients
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    def dmrd_received(_radio_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _stream_id, _data):
 | 
					    def dmrd_received(self, _radio_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _stream_id, _data):
 | 
				
			||||||
        pass
 | 
					        pass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def datagramReceived(self, _data, (_host, _port)):
 | 
					    def datagramReceived(self, _data, (_host, _port)):
 | 
				
			||||||
@ -224,7 +224,7 @@ class HBMASTER(DatagramProtocol):
 | 
				
			|||||||
                _dst_id = _data[8:11]
 | 
					                _dst_id = _data[8:11]
 | 
				
			||||||
                _bits = int_id(_data[15])
 | 
					                _bits = int_id(_data[15])
 | 
				
			||||||
                _slot = 2 if (_bits & 0x80) else 1
 | 
					                _slot = 2 if (_bits & 0x80) else 1
 | 
				
			||||||
                _call_type = 'group' if (_bits & 0x40) else 'unit'
 | 
					                _call_type = 'unit' if (_bits & 0x40) else 'group'
 | 
				
			||||||
                _raw_frame_type = (_bits & 0x30) >> 4
 | 
					                _raw_frame_type = (_bits & 0x30) >> 4
 | 
				
			||||||
                if _raw_frame_type == 0b00:
 | 
					                if _raw_frame_type == 0b00:
 | 
				
			||||||
                    _frame_type = 'voice'
 | 
					                    _frame_type = 'voice'
 | 
				
			||||||
@ -415,7 +415,7 @@ class HBCLIENT(DatagramProtocol):
 | 
				
			|||||||
    # regardless of the system type (MASTER or CLIENT)
 | 
					    # regardless of the system type (MASTER or CLIENT)
 | 
				
			||||||
    send_system = send_master
 | 
					    send_system = send_master
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    def dmrd_received(_radio_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _stream_id, _data):
 | 
					    def dmrd_received(self, _radio_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _stream_id, _data):
 | 
				
			||||||
        pass
 | 
					        pass
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    def datagramReceived(self, _data, (_host, _port)):
 | 
					    def datagramReceived(self, _data, (_host, _port)):
 | 
				
			||||||
@ -434,7 +434,7 @@ class HBCLIENT(DatagramProtocol):
 | 
				
			|||||||
                    _dst_id = _data[8:11]
 | 
					                    _dst_id = _data[8:11]
 | 
				
			||||||
                    _bits = int_id(_data[15])
 | 
					                    _bits = int_id(_data[15])
 | 
				
			||||||
                    _slot = 2 if (_bits & 0x80) else 1
 | 
					                    _slot = 2 if (_bits & 0x80) else 1
 | 
				
			||||||
                    _call_type = 'group' if (_bits & 0x40) else 'unit'
 | 
					                    _call_type = 'unit' if (_bits & 0x40) else 'group'
 | 
				
			||||||
                    _raw_frame_type = (_bits & 0x30) >> 4
 | 
					                    _raw_frame_type = (_bits & 0x30) >> 4
 | 
				
			||||||
                    if _raw_frame_type == 0b00:
 | 
					                    if _raw_frame_type == 0b00:
 | 
				
			||||||
                        _frame_type = 'voice'
 | 
					                        _frame_type = 'voice'
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user