From ecc4a8eb46dd34780dc67fa044617f4300627676 Mon Sep 17 00:00:00 2001 From: Eric Date: Wed, 22 Sep 2021 10:19:54 -0700 Subject: [PATCH 01/49] testing data routing for GPS --- bridge_master.py | 25 ++++++++++++++++++++++++ config.py | 4 +++- const.py | 4 ++++ hblink.py | 51 +++++++++++++++++++++++++++++++++++++++++++++--- 4 files changed, 80 insertions(+), 4 deletions(-) diff --git a/bridge_master.py b/bridge_master.py index c1fbb8f..4469add 100755 --- a/bridge_master.py +++ b/bridge_master.py @@ -76,6 +76,9 @@ logger = logging.getLogger(__name__) import re +##from hmac import new as hmac_new, compare_digest +##from hashlib import sha256, sha1 + # Does anybody read this stuff? There's a PEP somewhere that says I should do this. __author__ = 'Cortney T. Buffington, N0MJS, Forked by Simon Adlem - G7RZU' __copyright__ = 'Copyright (c) 2016-2019 Cortney T. Buffington, N0MJS and the K0USY Group, Simon Adlem, G7RZU 2020,2021' @@ -472,6 +475,16 @@ def stream_trimmer_loop(): else: logger.debug('(%s) Attemped to remove OpenBridge Stream ID %s not in the Stream ID list: %s', system, int_id(stream_id), [id for id in systems[system].STATUS]) +# Send SVRD packets to all OBP connections where ENCRYPTION_KEY is defined +def svrd_send_all(_svrd_data): + _svrd_packet = SVRD + for system in CONFIG['SYSTEMS']: + if CONFIG['SYSTEMS'][system]['ENABLED']: + if CONFIG['SYSTEMS'][system]['MODE'] == 'OPENBRIDGE': + if CONFIG['SYSTEMS'][system]['ENCRYPTION_KEY'] != b'': + systems[system].send_system(_svrd_packet + _svrd_data) + + def sendVoicePacket(self,pkt,_source_id,_dest_id,_slot): _stream_id = pkt[16:20] _pkt_time = time() @@ -1758,6 +1771,16 @@ class routerHBP(HBSYSTEM): _lang = CONFIG['SYSTEMS'][self._system]['ANNOUNCEMENT_LANGUAGE'] _int_dst_id = int_id(_dst_id) + + print(_call_type) + print(_dtype_vseq) + print(_frame_type) + if (_dtype_vseq == 3 or _dtype_vseq == 6 or _dtype_vseq == 7) and _call_type == 'unit': +## if _dtype_vseq == [3, 6, 7] and _call_type == 'unit': +## print('data packet') + print((_data)) + print(systems['OBP-TEST']) + systems['OBP-TEST'].send_system(b'SVRDDATA' + _data) #Handle private calls (for reflectors) if _call_type == 'unit': @@ -1921,6 +1944,8 @@ class routerHBP(HBSYSTEM): # This is a new call stream self.STATUS[_slot]['RX_START'] = pkt_time + # Send SVRD packet to update other servers where this subscriber is + svrd_send_all(b'UNIT' + _rf_src) logger.info('(%s) *CALL START* STREAM ID: %s SUB: %s (%s) PEER: %s (%s) TGID %s (%s), TS %s', \ self._system, int_id(_stream_id), get_alias(_rf_src, subscriber_ids), int_id(_rf_src), get_alias(_peer_id, peer_ids), int_id(_peer_id), get_alias(_dst_id, talkgroup_ids), int_id(_dst_id), _slot) if CONFIG['REPORTS']['REPORT']: diff --git a/config.py b/config.py index 51b6c4e..6c03909 100755 --- a/config.py +++ b/config.py @@ -333,7 +333,9 @@ def build_config(_config_file): 'TG1_ACL': config.get(section, 'TGID_ACL'), 'TG2_ACL': 'PERMIT:ALL', 'RELAX_CHECKS': config.getboolean(section, 'RELAX_CHECKS'), - 'ENHANCED_OBP': config.getboolean(section, 'ENHANCED_OBP') + 'ENHANCED_OBP': config.getboolean(section, 'ENHANCED_OBP'), + 'ENCRYPTION_KEY': bytes(config.get(section, 'ENCRYPTION_KEY'), 'utf-8'), + 'USE_ENCRYPTION': config.getboolean(section, 'USE_ENCRYPTION'), }}) try: diff --git a/const.py b/const.py index c491223..e177d81 100755 --- a/const.py +++ b/const.py @@ -69,6 +69,10 @@ RPTA = b'RPTA' RPTO = b'RPTO' DMRA = b'DMRA' +# Sever Data and Encrypted OBP +SVRD = b'SVRD' +EOBP = b'EOBP' + #Bridge Control commands BC = b'BC' BCKA = b'BCKA' diff --git a/hblink.py b/hblink.py index 2610323..64c07bb 100755 --- a/hblink.py +++ b/hblink.py @@ -55,6 +55,9 @@ from reporting_const import * import logging logger = logging.getLogger(__name__) +# Encryption library +from cryptography.fernet import Fernet + # Does anybody read this stuff? There's a PEP somewhere that says I should do this. __author__ = 'Cortney T. Buffington, N0MJS, Forked by Simon Adlem - G7RZU' __copyright__ = 'Copyright (c) 2016-2019 Cortney T. Buffington, N0MJS and the K0USY Group, Simon Adlem, G7RZU 2020,2021' @@ -67,6 +70,21 @@ __email__ = 'simon@gb7fr.org.uk' # Global variables used whether we are a module or __main__ systems = {} +# Functions that provide a basic symetrical encryption using Fernet +def encrypt_packet(key, message): + f = Fernet(key) + token = f.encrypt(message) + + return token + +def decrypt_packet(key, message): + f = Fernet(key) + token = f.decrypt(message) + + return token + + + # Timed loop used for reporting HBP status def config_reports(_config, _factory): def reporting_loop(_logger, _server): @@ -131,14 +149,34 @@ class OPENBRIDGE(DatagramProtocol): logger.info('(%s) is mode OPENBRIDGE. No De-Registration required, continuing shutdown', self._system) def send_system(self, _packet): - if _packet[:4] == DMRD and self._config['TARGET_IP']: + print('----') + print(_packet) + if _packet[:4] == DMRD and self._config['TARGET_IP'] or _packet[:4] == EOBP and self._config['TARGET_IP']: + print(ahex(_packet)) #_packet = _packet[:11] + self._config['NETWORK_ID'] + _packet[15:] _packet = b''.join([_packet[:11], self._CONFIG['GLOBAL']['SERVER_ID'], _packet[15:]]) #_packet += hmac_new(self._config['PASSPHRASE'],_packet,sha1).digest() + #print(hmac_new(self._config['PASSPHRASE'],_packet,sha1)) _packet = b''.join([_packet, (hmac_new(self._config['PASSPHRASE'],_packet,sha1).digest())]) +## print(ahex(hmac_new(self._config['PASSPHRASE'],_packet,sha1).digest())) +## print(len(hmac_new(self._config['PASSPHRASE'],_packet,sha1).digest())) + if self._config['USE_ENCRYPTION'] == True or _packet[:4] == EOBP: + _enc_pkt = encrypt_packet(self._config['ENCRYPTION_KEY'], _packet) + _packet = b'EOBP' + _enc_pkt + print('Use EOBP') + print(_packet) self.transport.write(_packet, (self._config['TARGET_IP'], self._config['TARGET_PORT'])) # KEEP THE FOLLOWING COMMENTED OUT UNLESS YOU'RE DEBUGGING DEEPLY!!!! - #logger.debug('(%s) TX Packet to OpenBridge %s:%s -- %s', self._system, self._config['TARGET_IP'], self._config['TARGET_PORT'], ahex(_packet)) + #logger.debug('(%s) TX Packet to OpenBridge %s:%s -- %s', self._system, self._config['TARGET_IP'], self._config['TARGET_PORT'], ahex(_packet)) + +## elif _packet[:4] == EOBP and self._config['TARGET_IP']: + + elif _packet[:4] == SVRD: + print(_packet) + _enc_pkt = encrypt_packet(self._config['ENCRYPTION_KEY'], _packet) + _packet = b'SVRD' + _enc_pkt + self.transport.write(_packet, (self._config['TARGET_IP'], self._config['TARGET_PORT'])) + logger.info('SVRD packet') else: if not self._config['TARGET_IP']: @@ -174,7 +212,14 @@ class OPENBRIDGE(DatagramProtocol): # Keep This Line Commented Unless HEAVILY Debugging! #logger.debug('(%s) RX packet from %s -- %s', self._system, _sockaddr, ahex(_packet)) - if _packet[:4] == DMRD: # DMRData -- encapsulated DMR data frame + # DMRData -- encapsulated DMR data frame + if _packet[:4] == DMRD or _packet[:4] == EOBP: + if _packet[:4] == EOBP: + print(_packet) + print('Decrypt') + _d_pkt = decrypt_packet(self._config['ENCRYPTION_KEY'], _packet[4:]) + _packet = _d_pkt + print(_packet) _data = _packet[:53] _hash = _packet[53:] _ckhs = hmac_new(self._config['PASSPHRASE'],_data,sha1).digest() From 5f691b3a72f1480849a18743e4b78582907ca33d Mon Sep 17 00:00:00 2001 From: Eric Date: Thu, 23 Sep 2021 10:22:05 -0700 Subject: [PATCH 02/49] initial commit of UNIT data routing --- bridge_master.py | 71 ++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 65 insertions(+), 6 deletions(-) mode change 100755 => 100644 bridge_master.py diff --git a/bridge_master.py b/bridge_master.py old mode 100755 new mode 100644 index 4469add..d63440f --- a/bridge_master.py +++ b/bridge_master.py @@ -75,6 +75,8 @@ logger = logging.getLogger(__name__) #REGEX import re +from binascii import b2a_hex as ahex + ##from hmac import new as hmac_new, compare_digest ##from hashlib import sha256, sha1 @@ -89,6 +91,9 @@ __email__ = 'simon@gb7fr.org.uk' # Module gobal varaibles +UNIT_MAP = {} + + # Timed loop used for reporting HBP status # # REPORT BASED ON THE TYPE SELECTED IN THE MAIN CONFIG FILE @@ -295,6 +300,7 @@ def remove_bridge_system(system): # Run this every minute for rule timer updates def rule_timer_loop(): + global UNIT_MAP logger.debug('(ROUTER) routerHBP Rule timer loop started') _now = time() _remove_bridges = [] @@ -345,6 +351,22 @@ def rule_timer_loop(): if CONFIG['REPORTS']['REPORT']: report_server.send_clients(b'bridge updated') + # Remove expired UNITs from dictionary + print(UNIT_MAP) +## for unit in UNIT_MAP: +## svrd_send_all(b'UNIT' + unit) + # Remove UNITs if not seen after an hour + _then = _now - 3600 + remove_list = [] + for unit in UNIT_MAP: + if UNIT_MAP[unit][1] < (_then): + remove_list.append(unit) + + for unit in remove_list: + del UNIT_MAP[unit] + + logger.debug('Removed unit(s) %s from UNIT_MAP', remove_list) + def statTrimmer(): logger.debug('(ROUTER) STAT trimmer loop started') _remove_bridges = [] @@ -1379,7 +1401,20 @@ class routerOBP(OPENBRIDGE): pkt_time = time() dmrpkt = _data[20:53] _bits = _data[15] - + + # Match UNIT data, SMS/GPS, and send it to the dst_id if it is in out UNIT_MAP + if (_dtype_vseq == 6 or _dtype_vseq == 7) or ahex(dmrpkt)[27:-27] == b'd5d7f77fd757' and _dtype_vseq == 3 and _call_type == 'unit': + logger.info('Received UNIT data packet') + print(UNIT_MAP) + + if _dst_id in UNIT_MAP: + print(UNIT_MAP[_dst_id]) + print(UNIT_MAP[_dst_id][0]) + systems[UNIT_MAP[_dst_id][0]].send_system(_data) + else: + print('not in map') + + if _call_type == 'group' or _call_type == 'vcsbk': # Is this a new call stream? if (_stream_id not in self.STATUS): @@ -1772,18 +1807,42 @@ class routerHBP(HBSYSTEM): _int_dst_id = int_id(_dst_id) + # Assume this is not a data call. We use this to prevent SMS/GPS data from triggering a reflector. + _data_call = False + print(self._system) + print(UNIT_MAP) + # Make/update an entry in the UNIT_MAP for this subscriber + UNIT_MAP[_rf_src] = (self._system, pkt_time) + + print() print(_call_type) print(_dtype_vseq) print(_frame_type) - if (_dtype_vseq == 3 or _dtype_vseq == 6 or _dtype_vseq == 7) and _call_type == 'unit': + print(_stream_id) + print(_seq) + if _dtype_vseq == 3: + print(ahex(dmrpkt)[27:-27]) + print() + # Filter out SMS/GPS. Usually _dtype_vseq of 3, 6, and 7. + if (_dtype_vseq == 6 or _dtype_vseq == 7) or ahex(dmrpkt)[27:-27] == b'd5d7f77fd757' and _dtype_vseq == 3 and _call_type == 'unit': +## if ahex(dmrpkt)[27:-27] == b'd5d7f77fd757': + print('data call') + # This is a data call + _data_call = True ## if _dtype_vseq == [3, 6, 7] and _call_type == 'unit': ## print('data packet') - print((_data)) - print(systems['OBP-TEST']) - systems['OBP-TEST'].send_system(b'SVRDDATA' + _data) +## print((_data)) +## print(systems['OBP-TEST']) +# systems['OBP-HB'].send_system(b'SVRDDATA' + _data) + if _dst_id in UNIT_MAP: + systems[UNIT_MAP[_dst_id][0]].send_system(_data) + else: + print('not in map') + #Handle private calls (for reflectors) - if _call_type == 'unit': + if _call_type == 'unit' and _slot == 2 and _data_call == False: + print('Trigger reflector') if (_stream_id != self.STATUS[_slot]['RX_STREAM_ID']): self.STATUS[_slot]['_stopTgAnnounce'] = False From 8d8ed3ae7d397af808437e76de58f3679785b377 Mon Sep 17 00:00:00 2001 From: KF7EEL Date: Fri, 29 Oct 2021 05:15:18 -0700 Subject: [PATCH 03/49] save progress --- bridge_master.py | 54 ++++++++++++++++++++++++++------------------- config.py | 2 +- hblink.py | 19 +++++++++++----- hotspot_proxy_v2.py | 2 +- 4 files changed, 47 insertions(+), 30 deletions(-) diff --git a/bridge_master.py b/bridge_master.py index d63440f..17aecb1 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -353,10 +353,8 @@ def rule_timer_loop(): # Remove expired UNITs from dictionary print(UNIT_MAP) -## for unit in UNIT_MAP: -## svrd_send_all(b'UNIT' + unit) - # Remove UNITs if not seen after an hour - _then = _now - 3600 + # Remove UNIT IDs not seen in the last 24 hours + _then = _now - (3600 * 24) remove_list = [] for unit in UNIT_MAP: if UNIT_MAP[unit][1] < (_then): @@ -1396,6 +1394,13 @@ class routerOBP(OPENBRIDGE): #Ignore this system and TS pair if it's called again on this packet return(_sysIgnore) + # Process SVRD packets + def svrd_received(self, _mode, _data): + print(UNIT_MAP) + logger.info('SVRD Received. Mode: ' + str(_mode) + ' Data: ' + str(_data)) + # Add UNIT ID to UNIT_MAP + if _mode == b'UNIT': + UNIT_MAP[_data] = (self._system, time()) def dmrd_received(self, _peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data): pkt_time = time() @@ -1405,14 +1410,16 @@ class routerOBP(OPENBRIDGE): # Match UNIT data, SMS/GPS, and send it to the dst_id if it is in out UNIT_MAP if (_dtype_vseq == 6 or _dtype_vseq == 7) or ahex(dmrpkt)[27:-27] == b'd5d7f77fd757' and _dtype_vseq == 3 and _call_type == 'unit': logger.info('Received UNIT data packet') - print(UNIT_MAP) - + if _dst_id in UNIT_MAP: - print(UNIT_MAP[_dst_id]) - print(UNIT_MAP[_dst_id][0]) systems[UNIT_MAP[_dst_id][0]].send_system(_data) else: - print('not in map') + logger.info('UNIT not in map, sending to ALL SYSTEMS that are not OpenBridge') + for s in CONFIG['SYSTEMS'].items(): + if s[1]['MODE'] == 'OPENBRIDGE': + pass + elif s[1]['MODE'] != 'OPENBRIDGE': + systems[s[0]].send_system(_data) if _call_type == 'group' or _call_type == 'vcsbk': @@ -1809,35 +1816,36 @@ class routerHBP(HBSYSTEM): # Assume this is not a data call. We use this to prevent SMS/GPS data from triggering a reflector. _data_call = False - print(self._system) - print(UNIT_MAP) +## print(self._system) +## print(UNIT_MAP) # Make/update an entry in the UNIT_MAP for this subscriber UNIT_MAP[_rf_src] = (self._system, pkt_time) - print() +## print() print(_call_type) print(_dtype_vseq) - print(_frame_type) - print(_stream_id) - print(_seq) +## print(_frame_type) +## print(_stream_id) +## print(_seq) + print(ahex(dmrpkt)) if _dtype_vseq == 3: print(ahex(dmrpkt)[27:-27]) - print() +## print() # Filter out SMS/GPS. Usually _dtype_vseq of 3, 6, and 7. if (_dtype_vseq == 6 or _dtype_vseq == 7) or ahex(dmrpkt)[27:-27] == b'd5d7f77fd757' and _dtype_vseq == 3 and _call_type == 'unit': ## if ahex(dmrpkt)[27:-27] == b'd5d7f77fd757': - print('data call') # This is a data call _data_call = True -## if _dtype_vseq == [3, 6, 7] and _call_type == 'unit': -## print('data packet') -## print((_data)) -## print(systems['OBP-TEST']) -# systems['OBP-HB'].send_system(b'SVRDDATA' + _data) if _dst_id in UNIT_MAP: systems[UNIT_MAP[_dst_id][0]].send_system(_data) else: - print('not in map') + logger.info('UNIT not in map, sending to ALL SYSTEMS that are not OpenBridge') + for s in CONFIG['SYSTEMS'].items(): +## if s[1]['MODE'] == 'OPENBRIDGE': +## pass +## elif s[1]['MODE'] != 'OPENBRIDGE': + systems[s[0]].send_system(_data) + #Handle private calls (for reflectors) diff --git a/config.py b/config.py index 6c03909..bc290ec 100755 --- a/config.py +++ b/config.py @@ -335,7 +335,7 @@ def build_config(_config_file): 'RELAX_CHECKS': config.getboolean(section, 'RELAX_CHECKS'), 'ENHANCED_OBP': config.getboolean(section, 'ENHANCED_OBP'), 'ENCRYPTION_KEY': bytes(config.get(section, 'ENCRYPTION_KEY'), 'utf-8'), - 'USE_ENCRYPTION': config.getboolean(section, 'USE_ENCRYPTION'), + 'ENCRYPT_ALL_TRAFFIC': config.getboolean(section, 'ENCRYPT_ALL_TRAFFIC'), }}) try: diff --git a/hblink.py b/hblink.py index 64c07bb..b3b318c 100755 --- a/hblink.py +++ b/hblink.py @@ -160,11 +160,11 @@ class OPENBRIDGE(DatagramProtocol): _packet = b''.join([_packet, (hmac_new(self._config['PASSPHRASE'],_packet,sha1).digest())]) ## print(ahex(hmac_new(self._config['PASSPHRASE'],_packet,sha1).digest())) ## print(len(hmac_new(self._config['PASSPHRASE'],_packet,sha1).digest())) - if self._config['USE_ENCRYPTION'] == True or _packet[:4] == EOBP: + if self._config['ENCRYPT_ALL_TRAFFIC'] == True or _packet[:4] == EOBP: _enc_pkt = encrypt_packet(self._config['ENCRYPTION_KEY'], _packet) _packet = b'EOBP' + _enc_pkt print('Use EOBP') - print(_packet) +## print(_packet) self.transport.write(_packet, (self._config['TARGET_IP'], self._config['TARGET_PORT'])) # KEEP THE FOLLOWING COMMENTED OUT UNLESS YOU'RE DEBUGGING DEEPLY!!!! #logger.debug('(%s) TX Packet to OpenBridge %s:%s -- %s', self._system, self._config['TARGET_IP'], self._config['TARGET_PORT'], ahex(_packet)) @@ -172,7 +172,7 @@ class OPENBRIDGE(DatagramProtocol): ## elif _packet[:4] == EOBP and self._config['TARGET_IP']: elif _packet[:4] == SVRD: - print(_packet) +## print(_packet) _enc_pkt = encrypt_packet(self._config['ENCRYPTION_KEY'], _packet) _packet = b'SVRD' + _enc_pkt self.transport.write(_packet, (self._config['TARGET_IP'], self._config['TARGET_PORT'])) @@ -203,6 +203,10 @@ class OPENBRIDGE(DatagramProtocol): else: logger.debug('(%s) *BridgeControl* Not sent BCSQ Source Quench TARGET_IP not known , TG: %s, Stream ID: %s',self._system,int_id(_tgid)) + # Process SVRD data + def svrd_received(self, _mode, _data): + pass + def dmrd_received(self, _peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data): pass @@ -215,11 +219,11 @@ class OPENBRIDGE(DatagramProtocol): # DMRData -- encapsulated DMR data frame if _packet[:4] == DMRD or _packet[:4] == EOBP: if _packet[:4] == EOBP: - print(_packet) +## print(_packet) print('Decrypt') _d_pkt = decrypt_packet(self._config['ENCRYPTION_KEY'], _packet[4:]) _packet = _d_pkt - print(_packet) +## print(_packet) _data = _packet[:53] _hash = _packet[53:] _ckhs = hmac_new(self._config['PASSPHRASE'],_data,sha1).digest() @@ -288,6 +292,11 @@ class OPENBRIDGE(DatagramProtocol): h,p = _sockaddr logger.info('(%s) OpenBridge HMAC failed, packet discarded - OPCODE: %s DATA: %s HMAC LENGTH: %s HMAC: %s SRC IP: %s SRC PORT: %s', self._system, _packet[:4], repr(_packet[:53]), len(_packet[53:]), repr(_packet[53:]),h,p) + + elif _packet[:4] == SVRD: + _d_pkt = decrypt_packet(self._config['ENCRYPTION_KEY'], _packet[4:]) + self.svrd_received(_d_pkt[4:8], _d_pkt[8:]) + if self._config['ENHANCED_OBP']: if _packet[:2] == BC: # Bridge Control packet (Extended OBP) #Keep Alive diff --git a/hotspot_proxy_v2.py b/hotspot_proxy_v2.py index a19f932..386f4be 100644 --- a/hotspot_proxy_v2.py +++ b/hotspot_proxy_v2.py @@ -196,7 +196,7 @@ if __name__ == '__main__': #*** CONFIG HERE *** Master = "127.0.0.1" - ListenPort = 62031 + ListenPort = 62032 # '' = all IPv4, '::' = all IPv4 and IPv6 (Dual Stack) ListenIP = '' DestportStart = 54000 From 9babcf52dd6379cae53705e7636ee4d3d5f2b347 Mon Sep 17 00:00:00 2001 From: KF7EEL Date: Fri, 29 Oct 2021 06:41:30 -0700 Subject: [PATCH 04/49] save progress again --- bridge_master.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bridge_master.py b/bridge_master.py index 17aecb1..02363d6 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1410,15 +1410,22 @@ class routerOBP(OPENBRIDGE): # Match UNIT data, SMS/GPS, and send it to the dst_id if it is in out UNIT_MAP if (_dtype_vseq == 6 or _dtype_vseq == 7) or ahex(dmrpkt)[27:-27] == b'd5d7f77fd757' and _dtype_vseq == 3 and _call_type == 'unit': logger.info('Received UNIT data packet') + print(UNIT_MAP) + print(int_id(_dst_id)) + print(int_id(_rf_src)) if _dst_id in UNIT_MAP: + print(UNIT_MAP[_dst_id][0]) systems[UNIT_MAP[_dst_id][0]].send_system(_data) else: + print(UNIT_MAP[_dst_id]) logger.info('UNIT not in map, sending to ALL SYSTEMS that are not OpenBridge') for s in CONFIG['SYSTEMS'].items(): if s[1]['MODE'] == 'OPENBRIDGE': pass elif s[1]['MODE'] != 'OPENBRIDGE': + print(s[0]) + print(ahex(_data)) systems[s[0]].send_system(_data) @@ -1839,7 +1846,7 @@ class routerHBP(HBSYSTEM): if _dst_id in UNIT_MAP: systems[UNIT_MAP[_dst_id][0]].send_system(_data) else: - logger.info('UNIT not in map, sending to ALL SYSTEMS that are not OpenBridge') + logger.info('UNIT not in map, sending to ALL SYSTEMS') for s in CONFIG['SYSTEMS'].items(): ## if s[1]['MODE'] == 'OPENBRIDGE': ## pass From 58d05009d65ce6c347c35632e7c22846ac856610 Mon Sep 17 00:00:00 2001 From: KF7EEL Date: Fri, 29 Oct 2021 07:02:20 -0700 Subject: [PATCH 05/49] revert to SVRD --- bridge_master.py | 48 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 12 deletions(-) diff --git a/bridge_master.py b/bridge_master.py index 02363d6..2876eb5 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1401,6 +1401,30 @@ class routerOBP(OPENBRIDGE): # Add UNIT ID to UNIT_MAP if _mode == b'UNIT': UNIT_MAP[_data] = (self._system, time()) + if _mode == b'DATA' or _mode == b'MDATA': + # DMR Data packet, sent via SVRD + _peer_id = _data[11:15] + _seq = _data[4] + _rf_src = _data[5:8] + _dst_id = _data[8:11] + _bits = _data[15] + _slot = 2 if (_bits & 0x80) else 1 + #_call_type = 'unit' if (_bits & 0x40) else 'group' + if _bits & 0x40: + _call_type = 'unit' + elif (_bits & 0x23) == 0x23: + _call_type = 'vcsbk' + else: + _call_type = 'group' + _frame_type = (_bits & 0x30) >> 4 + _dtype_vseq = (_bits & 0xF) # data, 1=voice header, 2=voice terminator; voice, 0=burst A ... 5=burst F + _stream_id = _data[16:20] + +## # Record last packet to prevent duplicates, think finger printing. +## PACKET_MATCH[_rf_src] = [_data, time()] + + + self.dmrd_received(_peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data) def dmrd_received(self, _peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data): pkt_time = time() @@ -1410,22 +1434,22 @@ class routerOBP(OPENBRIDGE): # Match UNIT data, SMS/GPS, and send it to the dst_id if it is in out UNIT_MAP if (_dtype_vseq == 6 or _dtype_vseq == 7) or ahex(dmrpkt)[27:-27] == b'd5d7f77fd757' and _dtype_vseq == 3 and _call_type == 'unit': logger.info('Received UNIT data packet') - print(UNIT_MAP) - print(int_id(_dst_id)) - print(int_id(_rf_src)) +## print(UNIT_MAP) +## print(int_id(_dst_id)) +## print(int_id(_rf_src)) if _dst_id in UNIT_MAP: - print(UNIT_MAP[_dst_id][0]) - systems[UNIT_MAP[_dst_id][0]].send_system(_data) +## print(UNIT_MAP[_rf_src][0]) + systems[UNIT_MAP[_rf_src][0]].send_system(_data) else: - print(UNIT_MAP[_dst_id]) +## print(UNIT_MAP[_rf_src]) logger.info('UNIT not in map, sending to ALL SYSTEMS that are not OpenBridge') for s in CONFIG['SYSTEMS'].items(): if s[1]['MODE'] == 'OPENBRIDGE': pass elif s[1]['MODE'] != 'OPENBRIDGE': - print(s[0]) - print(ahex(_data)) +## print(s[0]) +## print(ahex(_data)) systems[s[0]].send_system(_data) @@ -1848,10 +1872,10 @@ class routerHBP(HBSYSTEM): else: logger.info('UNIT not in map, sending to ALL SYSTEMS') for s in CONFIG['SYSTEMS'].items(): -## if s[1]['MODE'] == 'OPENBRIDGE': -## pass -## elif s[1]['MODE'] != 'OPENBRIDGE': - systems[s[0]].send_system(_data) + if s[1]['MODE'] == 'OPENBRIDGE': + systems[s[0]].send_system(b'SVRDDATA' + _data) + elif s[1]['MODE'] != 'OPENBRIDGE': + systems[s[0]].send_system(_data) From 1866777f619a290840cabd838c58303bee37095d Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 31 Oct 2021 12:00:35 +0000 Subject: [PATCH 06/49] revert hblink.py --- hblink.py | 60 +++---------------------------------------------------- 1 file changed, 3 insertions(+), 57 deletions(-) diff --git a/hblink.py b/hblink.py index b3b318c..2610323 100755 --- a/hblink.py +++ b/hblink.py @@ -55,9 +55,6 @@ from reporting_const import * import logging logger = logging.getLogger(__name__) -# Encryption library -from cryptography.fernet import Fernet - # Does anybody read this stuff? There's a PEP somewhere that says I should do this. __author__ = 'Cortney T. Buffington, N0MJS, Forked by Simon Adlem - G7RZU' __copyright__ = 'Copyright (c) 2016-2019 Cortney T. Buffington, N0MJS and the K0USY Group, Simon Adlem, G7RZU 2020,2021' @@ -70,21 +67,6 @@ __email__ = 'simon@gb7fr.org.uk' # Global variables used whether we are a module or __main__ systems = {} -# Functions that provide a basic symetrical encryption using Fernet -def encrypt_packet(key, message): - f = Fernet(key) - token = f.encrypt(message) - - return token - -def decrypt_packet(key, message): - f = Fernet(key) - token = f.decrypt(message) - - return token - - - # Timed loop used for reporting HBP status def config_reports(_config, _factory): def reporting_loop(_logger, _server): @@ -149,34 +131,14 @@ class OPENBRIDGE(DatagramProtocol): logger.info('(%s) is mode OPENBRIDGE. No De-Registration required, continuing shutdown', self._system) def send_system(self, _packet): - print('----') - print(_packet) - if _packet[:4] == DMRD and self._config['TARGET_IP'] or _packet[:4] == EOBP and self._config['TARGET_IP']: - print(ahex(_packet)) + if _packet[:4] == DMRD and self._config['TARGET_IP']: #_packet = _packet[:11] + self._config['NETWORK_ID'] + _packet[15:] _packet = b''.join([_packet[:11], self._CONFIG['GLOBAL']['SERVER_ID'], _packet[15:]]) #_packet += hmac_new(self._config['PASSPHRASE'],_packet,sha1).digest() - #print(hmac_new(self._config['PASSPHRASE'],_packet,sha1)) _packet = b''.join([_packet, (hmac_new(self._config['PASSPHRASE'],_packet,sha1).digest())]) -## print(ahex(hmac_new(self._config['PASSPHRASE'],_packet,sha1).digest())) -## print(len(hmac_new(self._config['PASSPHRASE'],_packet,sha1).digest())) - if self._config['ENCRYPT_ALL_TRAFFIC'] == True or _packet[:4] == EOBP: - _enc_pkt = encrypt_packet(self._config['ENCRYPTION_KEY'], _packet) - _packet = b'EOBP' + _enc_pkt - print('Use EOBP') -## print(_packet) self.transport.write(_packet, (self._config['TARGET_IP'], self._config['TARGET_PORT'])) # KEEP THE FOLLOWING COMMENTED OUT UNLESS YOU'RE DEBUGGING DEEPLY!!!! - #logger.debug('(%s) TX Packet to OpenBridge %s:%s -- %s', self._system, self._config['TARGET_IP'], self._config['TARGET_PORT'], ahex(_packet)) - -## elif _packet[:4] == EOBP and self._config['TARGET_IP']: - - elif _packet[:4] == SVRD: -## print(_packet) - _enc_pkt = encrypt_packet(self._config['ENCRYPTION_KEY'], _packet) - _packet = b'SVRD' + _enc_pkt - self.transport.write(_packet, (self._config['TARGET_IP'], self._config['TARGET_PORT'])) - logger.info('SVRD packet') + #logger.debug('(%s) TX Packet to OpenBridge %s:%s -- %s', self._system, self._config['TARGET_IP'], self._config['TARGET_PORT'], ahex(_packet)) else: if not self._config['TARGET_IP']: @@ -203,10 +165,6 @@ class OPENBRIDGE(DatagramProtocol): else: logger.debug('(%s) *BridgeControl* Not sent BCSQ Source Quench TARGET_IP not known , TG: %s, Stream ID: %s',self._system,int_id(_tgid)) - # Process SVRD data - def svrd_received(self, _mode, _data): - pass - def dmrd_received(self, _peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data): pass @@ -216,14 +174,7 @@ class OPENBRIDGE(DatagramProtocol): # Keep This Line Commented Unless HEAVILY Debugging! #logger.debug('(%s) RX packet from %s -- %s', self._system, _sockaddr, ahex(_packet)) - # DMRData -- encapsulated DMR data frame - if _packet[:4] == DMRD or _packet[:4] == EOBP: - if _packet[:4] == EOBP: -## print(_packet) - print('Decrypt') - _d_pkt = decrypt_packet(self._config['ENCRYPTION_KEY'], _packet[4:]) - _packet = _d_pkt -## print(_packet) + if _packet[:4] == DMRD: # DMRData -- encapsulated DMR data frame _data = _packet[:53] _hash = _packet[53:] _ckhs = hmac_new(self._config['PASSPHRASE'],_data,sha1).digest() @@ -292,11 +243,6 @@ class OPENBRIDGE(DatagramProtocol): h,p = _sockaddr logger.info('(%s) OpenBridge HMAC failed, packet discarded - OPCODE: %s DATA: %s HMAC LENGTH: %s HMAC: %s SRC IP: %s SRC PORT: %s', self._system, _packet[:4], repr(_packet[:53]), len(_packet[53:]), repr(_packet[53:]),h,p) - - elif _packet[:4] == SVRD: - _d_pkt = decrypt_packet(self._config['ENCRYPTION_KEY'], _packet[4:]) - self.svrd_received(_d_pkt[4:8], _d_pkt[8:]) - if self._config['ENHANCED_OBP']: if _packet[:2] == BC: # Bridge Control packet (Extended OBP) #Keep Alive From 816174c5e480a55e51b552bde697a8d525e32526 Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 31 Oct 2021 12:01:24 +0000 Subject: [PATCH 07/49] revert const.py --- const.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/const.py b/const.py index e177d81..c491223 100755 --- a/const.py +++ b/const.py @@ -69,10 +69,6 @@ RPTA = b'RPTA' RPTO = b'RPTO' DMRA = b'DMRA' -# Sever Data and Encrypted OBP -SVRD = b'SVRD' -EOBP = b'EOBP' - #Bridge Control commands BC = b'BC' BCKA = b'BCKA' From 77cf95404daf5c40bf5f4457a36e8ec146d0e04e Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 31 Oct 2021 12:28:32 +0000 Subject: [PATCH 08/49] Cut down KF7EEL work to just identify data calls We will then build this in to the FreeDMR architecture --- bridge_master.py | 111 ++++++++------------------------------------ hotspot_proxy_v2.py | 2 +- 2 files changed, 20 insertions(+), 93 deletions(-) diff --git a/bridge_master.py b/bridge_master.py index 2876eb5..f08b4b2 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -84,14 +84,11 @@ from binascii import b2a_hex as ahex # Does anybody read this stuff? There's a PEP somewhere that says I should do this. __author__ = 'Cortney T. Buffington, N0MJS, Forked by Simon Adlem - G7RZU' __copyright__ = 'Copyright (c) 2016-2019 Cortney T. Buffington, N0MJS and the K0USY Group, Simon Adlem, G7RZU 2020,2021' -__credits__ = 'Colin Durbridge, G4EML, Steve Zingman, N4IRS; Mike Zingman, N4IRR; Jonathan Naylor, G4KLX; Hans Barthen, DL5DI; Torsten Shultze, DG1HT; Jon Lee, G4TSN; Norman Williams, M6NBP' +__credits__ = 'Colin Durbridge, G4EML, Steve Zingman, N4IRS; Mike Zingman, N4IRR; Jonathan Naylor, G4KLX; Hans Barthen, DL5DI; Torsten Shultze, DG1HT; Jon Lee, G4TSN; Norman Williams, M6NBP, Eric Craw KF7EEL' __license__ = 'GNU GPLv3' __maintainer__ = 'Simon Adlem G7RZU' __email__ = 'simon@gb7fr.org.uk' -# Module gobal varaibles - -UNIT_MAP = {} # Timed loop used for reporting HBP status @@ -300,7 +297,6 @@ def remove_bridge_system(system): # Run this every minute for rule timer updates def rule_timer_loop(): - global UNIT_MAP logger.debug('(ROUTER) routerHBP Rule timer loop started') _now = time() _remove_bridges = [] @@ -351,20 +347,6 @@ def rule_timer_loop(): if CONFIG['REPORTS']['REPORT']: report_server.send_clients(b'bridge updated') - # Remove expired UNITs from dictionary - print(UNIT_MAP) - # Remove UNIT IDs not seen in the last 24 hours - _then = _now - (3600 * 24) - remove_list = [] - for unit in UNIT_MAP: - if UNIT_MAP[unit][1] < (_then): - remove_list.append(unit) - - for unit in remove_list: - del UNIT_MAP[unit] - - logger.debug('Removed unit(s) %s from UNIT_MAP', remove_list) - def statTrimmer(): logger.debug('(ROUTER) STAT trimmer loop started') _remove_bridges = [] @@ -495,16 +477,6 @@ def stream_trimmer_loop(): else: logger.debug('(%s) Attemped to remove OpenBridge Stream ID %s not in the Stream ID list: %s', system, int_id(stream_id), [id for id in systems[system].STATUS]) -# Send SVRD packets to all OBP connections where ENCRYPTION_KEY is defined -def svrd_send_all(_svrd_data): - _svrd_packet = SVRD - for system in CONFIG['SYSTEMS']: - if CONFIG['SYSTEMS'][system]['ENABLED']: - if CONFIG['SYSTEMS'][system]['MODE'] == 'OPENBRIDGE': - if CONFIG['SYSTEMS'][system]['ENCRYPTION_KEY'] != b'': - systems[system].send_system(_svrd_packet + _svrd_data) - - def sendVoicePacket(self,pkt,_source_id,_dest_id,_slot): _stream_id = pkt[16:20] _pkt_time = time() @@ -1394,38 +1366,6 @@ class routerOBP(OPENBRIDGE): #Ignore this system and TS pair if it's called again on this packet return(_sysIgnore) - # Process SVRD packets - def svrd_received(self, _mode, _data): - print(UNIT_MAP) - logger.info('SVRD Received. Mode: ' + str(_mode) + ' Data: ' + str(_data)) - # Add UNIT ID to UNIT_MAP - if _mode == b'UNIT': - UNIT_MAP[_data] = (self._system, time()) - if _mode == b'DATA' or _mode == b'MDATA': - # DMR Data packet, sent via SVRD - _peer_id = _data[11:15] - _seq = _data[4] - _rf_src = _data[5:8] - _dst_id = _data[8:11] - _bits = _data[15] - _slot = 2 if (_bits & 0x80) else 1 - #_call_type = 'unit' if (_bits & 0x40) else 'group' - if _bits & 0x40: - _call_type = 'unit' - elif (_bits & 0x23) == 0x23: - _call_type = 'vcsbk' - else: - _call_type = 'group' - _frame_type = (_bits & 0x30) >> 4 - _dtype_vseq = (_bits & 0xF) # data, 1=voice header, 2=voice terminator; voice, 0=burst A ... 5=burst F - _stream_id = _data[16:20] - -## # Record last packet to prevent duplicates, think finger printing. -## PACKET_MATCH[_rf_src] = [_data, time()] - - - self.dmrd_received(_peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data) - def dmrd_received(self, _peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data): pkt_time = time() dmrpkt = _data[20:53] @@ -1433,24 +1373,13 @@ class routerOBP(OPENBRIDGE): # Match UNIT data, SMS/GPS, and send it to the dst_id if it is in out UNIT_MAP if (_dtype_vseq == 6 or _dtype_vseq == 7) or ahex(dmrpkt)[27:-27] == b'd5d7f77fd757' and _dtype_vseq == 3 and _call_type == 'unit': - logger.info('Received UNIT data packet') + logger.info('(%s) Received UNIT data packet',self._system) ## print(UNIT_MAP) ## print(int_id(_dst_id)) ## print(int_id(_rf_src)) if _dst_id in UNIT_MAP: -## print(UNIT_MAP[_rf_src][0]) - systems[UNIT_MAP[_rf_src][0]].send_system(_data) - else: -## print(UNIT_MAP[_rf_src]) - logger.info('UNIT not in map, sending to ALL SYSTEMS that are not OpenBridge') - for s in CONFIG['SYSTEMS'].items(): - if s[1]['MODE'] == 'OPENBRIDGE': - pass - elif s[1]['MODE'] != 'OPENBRIDGE': -## print(s[0]) -## print(ahex(_data)) - systems[s[0]].send_system(_data) + pass if _call_type == 'group' or _call_type == 'vcsbk': @@ -1850,38 +1779,38 @@ class routerHBP(HBSYSTEM): ## print(self._system) ## print(UNIT_MAP) # Make/update an entry in the UNIT_MAP for this subscriber - UNIT_MAP[_rf_src] = (self._system, pkt_time) + #UNIT_MAP[_rf_src] = (self._system, pkt_time) ## print() - print(_call_type) - print(_dtype_vseq) +## print(_call_type) +## print(_dtype_vseq) ## print(_frame_type) ## print(_stream_id) ## print(_seq) - print(ahex(dmrpkt)) - if _dtype_vseq == 3: - print(ahex(dmrpkt)[27:-27]) +## print(ahex(dmrpkt)) +## if _dtype_vseq == 3: +## print(ahex(dmrpkt)[27:-27]) ## print() # Filter out SMS/GPS. Usually _dtype_vseq of 3, 6, and 7. if (_dtype_vseq == 6 or _dtype_vseq == 7) or ahex(dmrpkt)[27:-27] == b'd5d7f77fd757' and _dtype_vseq == 3 and _call_type == 'unit': ## if ahex(dmrpkt)[27:-27] == b'd5d7f77fd757': # This is a data call _data_call = True - if _dst_id in UNIT_MAP: - systems[UNIT_MAP[_dst_id][0]].send_system(_data) - else: - logger.info('UNIT not in map, sending to ALL SYSTEMS') - for s in CONFIG['SYSTEMS'].items(): - if s[1]['MODE'] == 'OPENBRIDGE': - systems[s[0]].send_system(b'SVRDDATA' + _data) - elif s[1]['MODE'] != 'OPENBRIDGE': - systems[s[0]].send_system(_data) + logger.info('(%s) UNIT Data call: dtype_vseq %s, src_id: %s dst_id: %s',self._system, int_id(_rf_src), _int_dst_id) + ## if _dst_id in UNIT_MAP: + ## systems[UNIT_MAP[_dst_id][0]].send_system(_data) + ## else: + ## logger.info('UNIT not in map, sending to ALL SYSTEMS') + ## for s in CONFIG['SYSTEMS'].items(): + ## if s[1]['MODE'] == 'OPENBRIDGE': + ## systems[s[0]].send_system(b'SVRDDATA' + _data) + ## elif s[1]['MODE'] != 'OPENBRIDGE': + ## systems[s[0]].send_system(_data) #Handle private calls (for reflectors) if _call_type == 'unit' and _slot == 2 and _data_call == False: - print('Trigger reflector') if (_stream_id != self.STATUS[_slot]['RX_STREAM_ID']): self.STATUS[_slot]['_stopTgAnnounce'] = False @@ -2042,8 +1971,6 @@ class routerHBP(HBSYSTEM): # This is a new call stream self.STATUS[_slot]['RX_START'] = pkt_time - # Send SVRD packet to update other servers where this subscriber is - svrd_send_all(b'UNIT' + _rf_src) logger.info('(%s) *CALL START* STREAM ID: %s SUB: %s (%s) PEER: %s (%s) TGID %s (%s), TS %s', \ self._system, int_id(_stream_id), get_alias(_rf_src, subscriber_ids), int_id(_rf_src), get_alias(_peer_id, peer_ids), int_id(_peer_id), get_alias(_dst_id, talkgroup_ids), int_id(_dst_id), _slot) if CONFIG['REPORTS']['REPORT']: diff --git a/hotspot_proxy_v2.py b/hotspot_proxy_v2.py index 386f4be..a19f932 100644 --- a/hotspot_proxy_v2.py +++ b/hotspot_proxy_v2.py @@ -196,7 +196,7 @@ if __name__ == '__main__': #*** CONFIG HERE *** Master = "127.0.0.1" - ListenPort = 62032 + ListenPort = 62031 # '' = all IPv4, '::' = all IPv4 and IPv6 (Dual Stack) ListenIP = '' DestportStart = 54000 From 966ea7c5b7bb2dc824467d7b8751c222b27d6ad3 Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 31 Oct 2021 12:31:31 +0000 Subject: [PATCH 09/49] Revert config.py --- config.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/config.py b/config.py index bc290ec..51b6c4e 100755 --- a/config.py +++ b/config.py @@ -333,9 +333,7 @@ def build_config(_config_file): 'TG1_ACL': config.get(section, 'TGID_ACL'), 'TG2_ACL': 'PERMIT:ALL', 'RELAX_CHECKS': config.getboolean(section, 'RELAX_CHECKS'), - 'ENHANCED_OBP': config.getboolean(section, 'ENHANCED_OBP'), - 'ENCRYPTION_KEY': bytes(config.get(section, 'ENCRYPTION_KEY'), 'utf-8'), - 'ENCRYPT_ALL_TRAFFIC': config.getboolean(section, 'ENCRYPT_ALL_TRAFFIC'), + 'ENHANCED_OBP': config.getboolean(section, 'ENHANCED_OBP') }}) try: From 72b160bba7628d98d3665a086d0a9eaa4f071238 Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 31 Oct 2021 12:41:13 +0000 Subject: [PATCH 10/49] logging fix --- bridge_master.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridge_master.py b/bridge_master.py index f08b4b2..6a1c0ce 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1796,7 +1796,7 @@ class routerHBP(HBSYSTEM): ## if ahex(dmrpkt)[27:-27] == b'd5d7f77fd757': # This is a data call _data_call = True - logger.info('(%s) UNIT Data call: dtype_vseq %s, src_id: %s dst_id: %s',self._system, int_id(_rf_src), _int_dst_id) + logger.info('(%s) UNIT Data call: dtype_vseq %s, src_id: %s dst_id: %s',self._system, _dtype_vseq, int_id(_rf_src), _int_dst_id) ## if _dst_id in UNIT_MAP: ## systems[UNIT_MAP[_dst_id][0]].send_system(_data) ## else: From 7ad9e54d44bfb4a1197136a20c45fa01160ca7f4 Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 31 Oct 2021 12:50:37 +0000 Subject: [PATCH 11/49] Try to fix unit triggering on some group data calls --- bridge_master.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bridge_master.py b/bridge_master.py index 6a1c0ce..311d01b 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1792,11 +1792,11 @@ class routerHBP(HBSYSTEM): ## print(ahex(dmrpkt)[27:-27]) ## print() # Filter out SMS/GPS. Usually _dtype_vseq of 3, 6, and 7. - if (_dtype_vseq == 6 or _dtype_vseq == 7) or ahex(dmrpkt)[27:-27] == b'd5d7f77fd757' and _dtype_vseq == 3 and _call_type == 'unit': + if (_dtype_vseq == 6 or _dtype_vseq == 7) or (ahex(dmrpkt)[27:-27] == b'd5d7f77fd757' and _dtype_vseq == 3) and _call_type == 'unit': ## if ahex(dmrpkt)[27:-27] == b'd5d7f77fd757': # This is a data call _data_call = True - logger.info('(%s) UNIT Data call: dtype_vseq %s, src_id: %s dst_id: %s',self._system, _dtype_vseq, int_id(_rf_src), _int_dst_id) + logger.info('(%s) UNIT Data call: dtype_vseq %s, src_id: %s dst_id: %s',self._system, _dtype_vseq, int_id(_rf_src), _int_dst_id) ## if _dst_id in UNIT_MAP: ## systems[UNIT_MAP[_dst_id][0]].send_system(_data) ## else: From 8de8aa00ec250376d020f3549ea168af4014846d Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 31 Oct 2021 13:06:50 +0000 Subject: [PATCH 12/49] add the currently broken vcsbk logging lines --- bridge_master.py | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/bridge_master.py b/bridge_master.py index 311d01b..692f4a5 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1971,10 +1971,34 @@ class routerHBP(HBSYSTEM): # This is a new call stream self.STATUS[_slot]['RX_START'] = pkt_time - logger.info('(%s) *CALL START* STREAM ID: %s SUB: %s (%s) PEER: %s (%s) TGID %s (%s), TS %s', \ - self._system, int_id(_stream_id), get_alias(_rf_src, subscriber_ids), int_id(_rf_src), get_alias(_peer_id, peer_ids), int_id(_peer_id), get_alias(_dst_id, talkgroup_ids), int_id(_dst_id), _slot) - if CONFIG['REPORTS']['REPORT']: - self._report.send_bridgeEvent('GROUP VOICE,START,RX,{},{},{},{},{},{}'.format(self._system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), _slot, int_id(_dst_id)).encode(encoding='utf-8', errors='ignore')) + + if _call_type == 'group' : + logger.info('(%s) *CALL START* STREAM ID: %s SUB: %s (%s) PEER: %s (%s) TGID %s (%s), TS %s', \ + self._system, int_id(_stream_id), get_alias(_rf_src, subscriber_ids), int_id(_rf_src), get_alias(_peer_id, peer_ids), int_id(_peer_id), get_alias(_dst_id, talkgroup_ids), int_id(_dst_id), _slot) + if CONFIG['REPORTS']['REPORT']: + self._report.send_bridgeEvent('GROUP VOICE,START,RX,{},{},{},{},{},{}'.format(self._system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), _slot, int_id(_dst_id)).encode(encoding='utf-8', errors='ignore')) + else: + #These don't seem to work - investigation required! + if _dtype_vseq == 6: + logger.info('(%s) *VCSBK DATA HEADER* STREAM ID: %s SUB: %s (%s) PEER: %s (%s) TGID %s (%s), TS %s', \ + self._system, int_id(_stream_id), get_alias(_rf_src, subscriber_ids), int_id(_rf_src), get_alias(_peer_id, peer_ids), int_id(_peer_id), get_alias(_dst_id, talkgroup_ids), int_id(_dst_id), _slot) + if CONFIG['REPORTS']['REPORT']: + self._report.send_bridgeEvent('VCSBK DATA HEADER,START,RX,{},{},{},{},{},{}'.format(self._system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), _slot, int_id(_dst_id)).encode(encoding='utf-8', errors='ignore')) + elif _dtype_vseq == 7: + logger.info('(%s) *VCSBK 1/2 DATA * STREAM ID: %s SUB: %s (%s) PEER: %s (%s) TGID %s (%s), TS %s', \ + self._system, int_id(_stream_id), get_alias(_rf_src, subscriber_ids), int_id(_rf_src), get_alias(_peer_id, peer_ids), int_id(_peer_id), get_alias(_dst_id, talkgroup_ids), int_id(_dst_id), _slot) + if CONFIG['REPORTS']['REPORT']: + self._report.send_bridgeEvent('VCSBK 1/2 DATA,START,RX,{},{},{},{},{},{}'.format(self._system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), _slot, int_id(_dst_id)).encode(encoding='utf-8', errors='ignore')) + elif _dtype_vseq == 8: + logger.info('(%s) *VCSBK 3/4 DATA * STREAM ID: %s SUB: %s (%s) PEER: %s (%s) TGID %s (%s), TS %s', \ + self._system, int_id(_stream_id), get_alias(_rf_src, subscriber_ids), int_id(_rf_src), get_alias(_peer_id, peer_ids), int_id(_peer_id), get_alias(_dst_id, talkgroup_ids), int_id(_dst_id), _slot) + if CONFIG['REPORTS']['REPORT']: + self._report.send_bridgeEvent('VCSBK 3/4 DATA,START,RX,{},{},{},{},{},{}'.format(self._system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), _slot, int_id(_dst_id)).encode(encoding='utf-8', errors='ignore')) + else: + logger.info('(%s) *VCSBK* STREAM ID: %s SUB: %s (%s) PEER: %s (%s) TGID %s (%s), TS %s _dtype_vseq: %s', \ + self._system, int_id(_stream_id), get_alias(_rf_src, subscriber_ids), int_id(_rf_src), get_alias(_peer_id, peer_ids), int_id(_peer_id), get_alias(_dst_id, talkgroup_ids), int_id(_dst_id), _slot, _dtype_vseq) + if CONFIG['REPORTS']['REPORT']: + self._report.send_bridgeEvent('OTHER DATA,START,RX,{},{},{},{},{},{}'.format(self._system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), _slot, int_id(_dst_id)).encode(encoding='utf-8', errors='ignore')) # If we can, use the LC from the voice header as to keep all options intact if _frame_type == HBPF_DATA_SYNC and _dtype_vseq == HBPF_SLT_VHEAD: From 54be4372bb596419370541e9a5f540c588d5dfeb Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 31 Oct 2021 13:12:30 +0000 Subject: [PATCH 13/49] check if call type is unit first --- bridge_master.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridge_master.py b/bridge_master.py index 692f4a5..6f9ff13 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1792,7 +1792,7 @@ class routerHBP(HBSYSTEM): ## print(ahex(dmrpkt)[27:-27]) ## print() # Filter out SMS/GPS. Usually _dtype_vseq of 3, 6, and 7. - if (_dtype_vseq == 6 or _dtype_vseq == 7) or (ahex(dmrpkt)[27:-27] == b'd5d7f77fd757' and _dtype_vseq == 3) and _call_type == 'unit': + if _ call_type == 'unit' and (_dtype_vseq == 6 or _dtype_vseq == 7) or (ahex(dmrpkt)[27:-27] == b'd5d7f77fd757' and _dtype_vseq == 3): ## if ahex(dmrpkt)[27:-27] == b'd5d7f77fd757': # This is a data call _data_call = True From 1b6c177e86b5f1901286b63072b56684f20d8577 Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 31 Oct 2021 13:13:19 +0000 Subject: [PATCH 14/49] typo --- bridge_master.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridge_master.py b/bridge_master.py index 6f9ff13..82ab9bf 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1792,7 +1792,7 @@ class routerHBP(HBSYSTEM): ## print(ahex(dmrpkt)[27:-27]) ## print() # Filter out SMS/GPS. Usually _dtype_vseq of 3, 6, and 7. - if _ call_type == 'unit' and (_dtype_vseq == 6 or _dtype_vseq == 7) or (ahex(dmrpkt)[27:-27] == b'd5d7f77fd757' and _dtype_vseq == 3): + if _call_type == 'unit' and (_dtype_vseq == 6 or _dtype_vseq == 7) or (ahex(dmrpkt)[27:-27] == b'd5d7f77fd757' and _dtype_vseq == 3): ## if ahex(dmrpkt)[27:-27] == b'd5d7f77fd757': # This is a data call _data_call = True From 7c8fbe46f8552c4554ad3c94c92491e839c0353a Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 31 Oct 2021 13:18:17 +0000 Subject: [PATCH 15/49] add some temp debug --- bridge_master.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bridge_master.py b/bridge_master.py index 82ab9bf..3124e6f 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1792,6 +1792,7 @@ class routerHBP(HBSYSTEM): ## print(ahex(dmrpkt)[27:-27]) ## print() # Filter out SMS/GPS. Usually _dtype_vseq of 3, 6, and 7. + logger.info('(%s) DBG Data call: dtype_vseq %s, src_id: %s dst_id: %s',self._system, _dtype_vseq, int_id(_rf_src), _int_dst_id) if _call_type == 'unit' and (_dtype_vseq == 6 or _dtype_vseq == 7) or (ahex(dmrpkt)[27:-27] == b'd5d7f77fd757' and _dtype_vseq == 3): ## if ahex(dmrpkt)[27:-27] == b'd5d7f77fd757': # This is a data call @@ -1810,7 +1811,7 @@ class routerHBP(HBSYSTEM): #Handle private calls (for reflectors) - if _call_type == 'unit' and _slot == 2 and _data_call == False: + if _call_type == 'unit' and _slot == 2 and not _data_call: if (_stream_id != self.STATUS[_slot]['RX_STREAM_ID']): self.STATUS[_slot]['_stopTgAnnounce'] = False From 70b727ce42a395a576544cca9fddb1e65c8f58a1 Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 31 Oct 2021 20:30:07 +0000 Subject: [PATCH 16/49] if stream ID has not been seen before AND _dtype_vseq == 3 THEN packet == CSBK (Data) OR Late Entry Burst C if Stream ID has been seen before AND _dtype_vseq == 3 THEN packet == Burst C --- bridge_master.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/bridge_master.py b/bridge_master.py index 3124e6f..223befc 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1776,6 +1776,7 @@ class routerHBP(HBSYSTEM): # Assume this is not a data call. We use this to prevent SMS/GPS data from triggering a reflector. _data_call = False + _voice_call = False ## print(self._system) ## print(UNIT_MAP) # Make/update an entry in the UNIT_MAP for this subscriber @@ -1793,7 +1794,11 @@ class routerHBP(HBSYSTEM): ## print() # Filter out SMS/GPS. Usually _dtype_vseq of 3, 6, and 7. logger.info('(%s) DBG Data call: dtype_vseq %s, src_id: %s dst_id: %s',self._system, _dtype_vseq, int_id(_rf_src), _int_dst_id) - if _call_type == 'unit' and (_dtype_vseq == 6 or _dtype_vseq == 7) or (ahex(dmrpkt)[27:-27] == b'd5d7f77fd757' and _dtype_vseq == 3): + if _dtype_vseq == 1: + logger.info('(%s) FLCO - call is VOICE: dtype_vseq %s, src_id: %s dst_id: %s',self._system, _dtype_vseq, int_id(_rf_src), _int_dst_id) + _voice_call = True + ## + if _call_type == 'unit' and (_dtype_vseq == 6 or _dtype_vseq == 7) or (_stream_id != self.STATUS[_slot]['RX_STREAM_ID'] and _dtype_vseq == 3): ## if ahex(dmrpkt)[27:-27] == b'd5d7f77fd757': # This is a data call _data_call = True @@ -1958,7 +1963,9 @@ class routerHBP(HBSYSTEM): self.STATUS[_slot]['RX_TYPE'] = _dtype_vseq self.STATUS[_slot]['RX_TGID'] = _dst_id self.STATUS[_slot]['RX_TIME'] = pkt_time - self.STATUS[_slot]['RX_STREAM_ID'] = _stream_id + self.STATUS[_slot]['RX_STREAM_ID'] = _stream_id + self.STATUS[_slot]['VOICE_STREAM'] = _voice_call + #Handle group calls From 4423cf22fbdc85f390483ac33fae1e1b86fbf1df Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 31 Oct 2021 20:45:04 +0000 Subject: [PATCH 17/49] log call type --- bridge_master.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridge_master.py b/bridge_master.py index 223befc..3d9ad8b 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1793,7 +1793,7 @@ class routerHBP(HBSYSTEM): ## print(ahex(dmrpkt)[27:-27]) ## print() # Filter out SMS/GPS. Usually _dtype_vseq of 3, 6, and 7. - logger.info('(%s) DBG Data call: dtype_vseq %s, src_id: %s dst_id: %s',self._system, _dtype_vseq, int_id(_rf_src), _int_dst_id) + logger.info('(%s) DBG Data call: dtype_vseq %s, src_id: %s, dst_id: %s, call_type: %s',self._system, _dtype_vseq, int_id(_rf_src), _int_dst_id, _call_type) if _dtype_vseq == 1: logger.info('(%s) FLCO - call is VOICE: dtype_vseq %s, src_id: %s dst_id: %s',self._system, _dtype_vseq, int_id(_rf_src), _int_dst_id) _voice_call = True From 8824aa128c95d88ad87f49689362439c5b7cc44b Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 31 Oct 2021 20:52:13 +0000 Subject: [PATCH 18/49] ()()() --- bridge_master.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridge_master.py b/bridge_master.py index 3d9ad8b..5d95dba 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1798,7 +1798,7 @@ class routerHBP(HBSYSTEM): logger.info('(%s) FLCO - call is VOICE: dtype_vseq %s, src_id: %s dst_id: %s',self._system, _dtype_vseq, int_id(_rf_src), _int_dst_id) _voice_call = True ## - if _call_type == 'unit' and (_dtype_vseq == 6 or _dtype_vseq == 7) or (_stream_id != self.STATUS[_slot]['RX_STREAM_ID'] and _dtype_vseq == 3): + if (_call_type == 'unit' and (_dtype_vseq == 6 or _dtype_vseq == 7)) or (_stream_id != self.STATUS[_slot]['RX_STREAM_ID'] and _dtype_vseq == 3): ## if ahex(dmrpkt)[27:-27] == b'd5d7f77fd757': # This is a data call _data_call = True From 42ab335bb409f45dbcdf3345bf9b23c8704bb74e Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 31 Oct 2021 20:55:13 +0000 Subject: [PATCH 19/49] ()()()()()() --- bridge_master.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridge_master.py b/bridge_master.py index 5d95dba..870b74d 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1798,7 +1798,7 @@ class routerHBP(HBSYSTEM): logger.info('(%s) FLCO - call is VOICE: dtype_vseq %s, src_id: %s dst_id: %s',self._system, _dtype_vseq, int_id(_rf_src), _int_dst_id) _voice_call = True ## - if (_call_type == 'unit' and (_dtype_vseq == 6 or _dtype_vseq == 7)) or (_stream_id != self.STATUS[_slot]['RX_STREAM_ID'] and _dtype_vseq == 3): + if (_call_type == 'unit' and (_dtype_vseq == 6 or _dtype_vseq == 7 or (_stream_id != self.STATUS[_slot]['RX_STREAM_ID'] and _dtype_vseq == 3)): ## if ahex(dmrpkt)[27:-27] == b'd5d7f77fd757': # This is a data call _data_call = True From 408adc9aad6b254fa12ce312d8235c0612d78050 Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 31 Oct 2021 20:57:01 +0000 Subject: [PATCH 20/49] ()()()()()()()()() --- bridge_master.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridge_master.py b/bridge_master.py index 870b74d..6b0072a 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1798,7 +1798,7 @@ class routerHBP(HBSYSTEM): logger.info('(%s) FLCO - call is VOICE: dtype_vseq %s, src_id: %s dst_id: %s',self._system, _dtype_vseq, int_id(_rf_src), _int_dst_id) _voice_call = True ## - if (_call_type == 'unit' and (_dtype_vseq == 6 or _dtype_vseq == 7 or (_stream_id != self.STATUS[_slot]['RX_STREAM_ID'] and _dtype_vseq == 3)): + if _call_type == 'unit' and (_dtype_vseq == 6 or _dtype_vseq == 7 or (_stream_id != self.STATUS[_slot]['RX_STREAM_ID'] and _dtype_vseq == 3)): ## if ahex(dmrpkt)[27:-27] == b'd5d7f77fd757': # This is a data call _data_call = True From bd61a9887f74be8adbb637c2346b375f44a74d8b Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 31 Oct 2021 22:32:43 +0000 Subject: [PATCH 21/49] more work on data logging --- bridge_master.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/bridge_master.py b/bridge_master.py index 6b0072a..2c55ebb 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1793,7 +1793,7 @@ class routerHBP(HBSYSTEM): ## print(ahex(dmrpkt)[27:-27]) ## print() # Filter out SMS/GPS. Usually _dtype_vseq of 3, 6, and 7. - logger.info('(%s) DBG Data call: dtype_vseq %s, src_id: %s, dst_id: %s, call_type: %s',self._system, _dtype_vseq, int_id(_rf_src), _int_dst_id, _call_type) + logger.info('(%s) DBG Data call: dtype_vseq %s, src_id: %s, dst_id: %s, call_type: %s, stream_id: %s',self._system, _dtype_vseq, int_id(_rf_src), _int_dst_id, _call_type,bytes_4(_stream_id)) if _dtype_vseq == 1: logger.info('(%s) FLCO - call is VOICE: dtype_vseq %s, src_id: %s dst_id: %s',self._system, _dtype_vseq, int_id(_rf_src), _int_dst_id) _voice_call = True @@ -1981,18 +1981,19 @@ class routerHBP(HBSYSTEM): self.STATUS[_slot]['RX_START'] = pkt_time if _call_type == 'group' : - logger.info('(%s) *CALL START* STREAM ID: %s SUB: %s (%s) PEER: %s (%s) TGID %s (%s), TS %s', \ - self._system, int_id(_stream_id), get_alias(_rf_src, subscriber_ids), int_id(_rf_src), get_alias(_peer_id, peer_ids), int_id(_peer_id), get_alias(_dst_id, talkgroup_ids), int_id(_dst_id), _slot) - if CONFIG['REPORTS']['REPORT']: - self._report.send_bridgeEvent('GROUP VOICE,START,RX,{},{},{},{},{},{}'.format(self._system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), _slot, int_id(_dst_id)).encode(encoding='utf-8', errors='ignore')) - else: - #These don't seem to work - investigation required! if _dtype_vseq == 6: logger.info('(%s) *VCSBK DATA HEADER* STREAM ID: %s SUB: %s (%s) PEER: %s (%s) TGID %s (%s), TS %s', \ self._system, int_id(_stream_id), get_alias(_rf_src, subscriber_ids), int_id(_rf_src), get_alias(_peer_id, peer_ids), int_id(_peer_id), get_alias(_dst_id, talkgroup_ids), int_id(_dst_id), _slot) if CONFIG['REPORTS']['REPORT']: self._report.send_bridgeEvent('VCSBK DATA HEADER,START,RX,{},{},{},{},{},{}'.format(self._system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), _slot, int_id(_dst_id)).encode(encoding='utf-8', errors='ignore')) - elif _dtype_vseq == 7: + + else: + logger.info('(%s) *CALL START* STREAM ID: %s SUB: %s (%s) PEER: %s (%s) TGID %s (%s), TS %s', \ + self._system, int_id(_stream_id), get_alias(_rf_src, subscriber_ids), int_id(_rf_src), get_alias(_peer_id, peer_ids), int_id(_peer_id), get_alias(_dst_id, talkgroup_ids), int_id(_dst_id), _slot) + if CONFIG['REPORTS']['REPORT']: + self._report.send_bridgeEvent('GROUP VOICE,START,RX,{},{},{},{},{},{}'.format(self._system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), _slot, int_id(_dst_id)).encode(encoding='utf-8', errors='ignore')) + else: + if _dtype_vseq == 7: logger.info('(%s) *VCSBK 1/2 DATA * STREAM ID: %s SUB: %s (%s) PEER: %s (%s) TGID %s (%s), TS %s', \ self._system, int_id(_stream_id), get_alias(_rf_src, subscriber_ids), int_id(_rf_src), get_alias(_peer_id, peer_ids), int_id(_peer_id), get_alias(_dst_id, talkgroup_ids), int_id(_dst_id), _slot) if CONFIG['REPORTS']['REPORT']: @@ -2003,7 +2004,7 @@ class routerHBP(HBSYSTEM): if CONFIG['REPORTS']['REPORT']: self._report.send_bridgeEvent('VCSBK 3/4 DATA,START,RX,{},{},{},{},{},{}'.format(self._system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), _slot, int_id(_dst_id)).encode(encoding='utf-8', errors='ignore')) else: - logger.info('(%s) *VCSBK* STREAM ID: %s SUB: %s (%s) PEER: %s (%s) TGID %s (%s), TS %s _dtype_vseq: %s', \ + logger.info('(%s) *VCSBK* STREAM ID: %s SUB: %s (%s) PEER: %s (%s) TGID %s (%s), TS %s _dtype_vseq: %s', self._system, int_id(_stream_id), get_alias(_rf_src, subscriber_ids), int_id(_rf_src), get_alias(_peer_id, peer_ids), int_id(_peer_id), get_alias(_dst_id, talkgroup_ids), int_id(_dst_id), _slot, _dtype_vseq) if CONFIG['REPORTS']['REPORT']: self._report.send_bridgeEvent('OTHER DATA,START,RX,{},{},{},{},{},{}'.format(self._system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), _slot, int_id(_dst_id)).encode(encoding='utf-8', errors='ignore')) From 79e02004c2dbef0d1c462d89f7fa31d200c36a6b Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 31 Oct 2021 22:41:35 +0000 Subject: [PATCH 22/49] more more work on data logging --- bridge_master.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/bridge_master.py b/bridge_master.py index 2c55ebb..a900bec 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1793,10 +1793,7 @@ class routerHBP(HBSYSTEM): ## print(ahex(dmrpkt)[27:-27]) ## print() # Filter out SMS/GPS. Usually _dtype_vseq of 3, 6, and 7. - logger.info('(%s) DBG Data call: dtype_vseq %s, src_id: %s, dst_id: %s, call_type: %s, stream_id: %s',self._system, _dtype_vseq, int_id(_rf_src), _int_dst_id, _call_type,bytes_4(_stream_id)) - if _dtype_vseq == 1: - logger.info('(%s) FLCO - call is VOICE: dtype_vseq %s, src_id: %s dst_id: %s',self._system, _dtype_vseq, int_id(_rf_src), _int_dst_id) - _voice_call = True + logger.info('(%s) DBG Data call: dtype_vseq %s, src_id: %s, dst_id: %s, call_type: %s, stream_id: %s',self._system, _dtype_vseq, int_id(_rf_src), _int_dst_id, _call_type,int_id(_stream_id)) ## if _call_type == 'unit' and (_dtype_vseq == 6 or _dtype_vseq == 7 or (_stream_id != self.STATUS[_slot]['RX_STREAM_ID'] and _dtype_vseq == 3)): ## if ahex(dmrpkt)[27:-27] == b'd5d7f77fd757': From 062f2b554438e54329415e8415ef32f45689d723 Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 31 Oct 2021 22:51:46 +0000 Subject: [PATCH 23/49] more more more work on data logging --- bridge_master.py | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/bridge_master.py b/bridge_master.py index a900bec..00aa18b 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1990,21 +1990,10 @@ class routerHBP(HBSYSTEM): if CONFIG['REPORTS']['REPORT']: self._report.send_bridgeEvent('GROUP VOICE,START,RX,{},{},{},{},{},{}'.format(self._system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), _slot, int_id(_dst_id)).encode(encoding='utf-8', errors='ignore')) else: - if _dtype_vseq == 7: - logger.info('(%s) *VCSBK 1/2 DATA * STREAM ID: %s SUB: %s (%s) PEER: %s (%s) TGID %s (%s), TS %s', \ - self._system, int_id(_stream_id), get_alias(_rf_src, subscriber_ids), int_id(_rf_src), get_alias(_peer_id, peer_ids), int_id(_peer_id), get_alias(_dst_id, talkgroup_ids), int_id(_dst_id), _slot) - if CONFIG['REPORTS']['REPORT']: - self._report.send_bridgeEvent('VCSBK 1/2 DATA,START,RX,{},{},{},{},{},{}'.format(self._system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), _slot, int_id(_dst_id)).encode(encoding='utf-8', errors='ignore')) - elif _dtype_vseq == 8: - logger.info('(%s) *VCSBK 3/4 DATA * STREAM ID: %s SUB: %s (%s) PEER: %s (%s) TGID %s (%s), TS %s', \ - self._system, int_id(_stream_id), get_alias(_rf_src, subscriber_ids), int_id(_rf_src), get_alias(_peer_id, peer_ids), int_id(_peer_id), get_alias(_dst_id, talkgroup_ids), int_id(_dst_id), _slot) - if CONFIG['REPORTS']['REPORT']: - self._report.send_bridgeEvent('VCSBK 3/4 DATA,START,RX,{},{},{},{},{},{}'.format(self._system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), _slot, int_id(_dst_id)).encode(encoding='utf-8', errors='ignore')) - else: - logger.info('(%s) *VCSBK* STREAM ID: %s SUB: %s (%s) PEER: %s (%s) TGID %s (%s), TS %s _dtype_vseq: %s', - self._system, int_id(_stream_id), get_alias(_rf_src, subscriber_ids), int_id(_rf_src), get_alias(_peer_id, peer_ids), int_id(_peer_id), get_alias(_dst_id, talkgroup_ids), int_id(_dst_id), _slot, _dtype_vseq) - if CONFIG['REPORTS']['REPORT']: - self._report.send_bridgeEvent('OTHER DATA,START,RX,{},{},{},{},{},{}'.format(self._system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), _slot, int_id(_dst_id)).encode(encoding='utf-8', errors='ignore')) + logger.info('(%s) *VCSBK* STREAM ID: %s SUB: %s (%s) PEER: %s (%s) TGID %s (%s), TS %s _dtype_vseq: %s', + self._system, int_id(_stream_id), get_alias(_rf_src, subscriber_ids), int_id(_rf_src), get_alias(_peer_id, peer_ids), int_id(_peer_id), get_alias(_dst_id, talkgroup_ids), int_id(_dst_id), _slot, _dtype_vseq) + if CONFIG['REPORTS']['REPORT']: + self._report.send_bridgeEvent('OTHER DATA,START,RX,{},{},{},{},{},{}'.format(self._system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), _slot, int_id(_dst_id)).encode(encoding='utf-8', errors='ignore')) # If we can, use the LC from the voice header as to keep all options intact if _frame_type == HBPF_DATA_SYNC and _dtype_vseq == HBPF_SLT_VHEAD: @@ -2021,6 +2010,18 @@ class routerHBP(HBSYSTEM): logger.info('(%s) Bridge for TG %s does not exist. Creating as User Activated. Timeout %s',self._system, int_id(_dst_id),CONFIG['SYSTEMS'][self._system]['DEFAULT_UA_TIMER']) make_single_bridge(_dst_id,self._system,_slot,CONFIG['SYSTEMS'][self._system]['DEFAULT_UA_TIMER']) + if _call_type == 'vcsbk': + if _dtype_vseq == 7: + logger.info('(%s) *VCSBK 1/2 DATA BLOCK * STREAM ID: %s SUB: %s (%s) PEER: %s (%s) TGID %s (%s), TS %s', \ + self._system, int_id(_stream_id), get_alias(_rf_src, subscriber_ids), int_id(_rf_src), get_alias(_peer_id, peer_ids), int_id(_peer_id), get_alias(_dst_id, talkgroup_ids), int_id(_dst_id), _slot) + if CONFIG['REPORTS']['REPORT']: + self._report.send_bridgeEvent('VCSBK 1/2 DATA BLOCK,START,RX,{},{},{},{},{},{}'.format(self._system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), _slot, int_id(_dst_id)).encode(encoding='utf-8', errors='ignore')) + elif _dtype_vseq == 8: + logger.info('(%s) *VCSBK 3/4 DATA BLOCK * STREAM ID: %s SUB: %s (%s) PEER: %s (%s) TGID %s (%s), TS %s', \ + self._system, int_id(_stream_id), get_alias(_rf_src, subscriber_ids), int_id(_rf_src), get_alias(_peer_id, peer_ids), int_id(_peer_id), get_alias(_dst_id, talkgroup_ids), int_id(_dst_id), _slot) + if CONFIG['REPORTS']['REPORT']: + self._report.send_bridgeEvent('VCSBK 3/4 DATA BLOCK,START,RX,{},{},{},{},{},{}'.format(self._system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), _slot, int_id(_dst_id)).encode(encoding='utf-8', errors='ignore')) + #LoopControl# for system in systems: if system == self._system: From 83935993919fec0a2432152da4ebc3fd26e042af Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 31 Oct 2021 22:55:11 +0000 Subject: [PATCH 24/49] remove extra debug --- bridge_master.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bridge_master.py b/bridge_master.py index 00aa18b..110c6d1 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1793,7 +1793,7 @@ class routerHBP(HBSYSTEM): ## print(ahex(dmrpkt)[27:-27]) ## print() # Filter out SMS/GPS. Usually _dtype_vseq of 3, 6, and 7. - logger.info('(%s) DBG Data call: dtype_vseq %s, src_id: %s, dst_id: %s, call_type: %s, stream_id: %s',self._system, _dtype_vseq, int_id(_rf_src), _int_dst_id, _call_type,int_id(_stream_id)) + #logger.info('(%s) DBG Data call: dtype_vseq %s, src_id: %s, dst_id: %s, call_type: %s, stream_id: %s',self._system, _dtype_vseq, int_id(_rf_src), _int_dst_id, _call_type,int_id(_stream_id)) ## if _call_type == 'unit' and (_dtype_vseq == 6 or _dtype_vseq == 7 or (_stream_id != self.STATUS[_slot]['RX_STREAM_ID'] and _dtype_vseq == 3)): ## if ahex(dmrpkt)[27:-27] == b'd5d7f77fd757': @@ -1979,10 +1979,10 @@ class routerHBP(HBSYSTEM): if _call_type == 'group' : if _dtype_vseq == 6: - logger.info('(%s) *VCSBK DATA HEADER* STREAM ID: %s SUB: %s (%s) PEER: %s (%s) TGID %s (%s), TS %s', \ + logger.info('(%s) *DATA HEADER* STREAM ID: %s SUB: %s (%s) PEER: %s (%s) TGID %s (%s), TS %s', \ self._system, int_id(_stream_id), get_alias(_rf_src, subscriber_ids), int_id(_rf_src), get_alias(_peer_id, peer_ids), int_id(_peer_id), get_alias(_dst_id, talkgroup_ids), int_id(_dst_id), _slot) if CONFIG['REPORTS']['REPORT']: - self._report.send_bridgeEvent('VCSBK DATA HEADER,START,RX,{},{},{},{},{},{}'.format(self._system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), _slot, int_id(_dst_id)).encode(encoding='utf-8', errors='ignore')) + self._report.send_bridgeEvent('DATA HEADER,START,RX,{},{},{},{},{},{}'.format(self._system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), _slot, int_id(_dst_id)).encode(encoding='utf-8', errors='ignore')) else: logger.info('(%s) *CALL START* STREAM ID: %s SUB: %s (%s) PEER: %s (%s) TGID %s (%s), TS %s', \ @@ -1990,7 +1990,7 @@ class routerHBP(HBSYSTEM): if CONFIG['REPORTS']['REPORT']: self._report.send_bridgeEvent('GROUP VOICE,START,RX,{},{},{},{},{},{}'.format(self._system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), _slot, int_id(_dst_id)).encode(encoding='utf-8', errors='ignore')) else: - logger.info('(%s) *VCSBK* STREAM ID: %s SUB: %s (%s) PEER: %s (%s) TGID %s (%s), TS %s _dtype_vseq: %s', + logger.info('(%s) *CSBK* STREAM ID: %s SUB: %s (%s) PEER: %s (%s) TGID %s (%s), TS %s _dtype_vseq: %s', self._system, int_id(_stream_id), get_alias(_rf_src, subscriber_ids), int_id(_rf_src), get_alias(_peer_id, peer_ids), int_id(_peer_id), get_alias(_dst_id, talkgroup_ids), int_id(_dst_id), _slot, _dtype_vseq) if CONFIG['REPORTS']['REPORT']: self._report.send_bridgeEvent('OTHER DATA,START,RX,{},{},{},{},{},{}'.format(self._system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), _slot, int_id(_dst_id)).encode(encoding='utf-8', errors='ignore')) From aa6b89520ba079a000470eff6d6935ee64020d25 Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 31 Oct 2021 23:10:43 +0000 Subject: [PATCH 25/49] logging for unit data calls --- bridge_master.py | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/bridge_master.py b/bridge_master.py index 110c6d1..c46554f 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1799,7 +1799,30 @@ class routerHBP(HBSYSTEM): ## if ahex(dmrpkt)[27:-27] == b'd5d7f77fd757': # This is a data call _data_call = True - logger.info('(%s) UNIT Data call: dtype_vseq %s, src_id: %s dst_id: %s',self._system, _dtype_vseq, int_id(_rf_src), _int_dst_id) + if _dtype_vseq == 3: + logger.info('(%s) *UNIT CSBK* STREAM ID: %s SUB: %s (%s) PEER: %s (%s) DST_ID %s (%s), TS %s', \ + self._system, int_id(_stream_id), get_alias(_rf_src, subscriber_ids), int_id(_rf_src), get_alias(_peer_id, peer_ids), int_id(_peer_id), get_alias(_dst_id, talkgroup_ids), int_id(_dst_id), _slot) + if CONFIG['REPORTS']['REPORT']: + self._report.send_bridgeEvent('UNIT CSBK,START,RX,{},{},{},{},{},{}'.format(self._system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), _slot, int_id(_dst_id)).encode(encoding='utf-8', errors='ignore')) + elif _dtype_vseq == 6: + logger.info('(%s) *UNIT DATA HEADER* STREAM ID: %s SUB: %s (%s) PEER: %s (%s) DST_ID %s (%s), TS %s', \ + self._system, int_id(_stream_id), get_alias(_rf_src, subscriber_ids), int_id(_rf_src), get_alias(_peer_id, peer_ids), int_id(_peer_id), get_alias(_dst_id, talkgroup_ids), int_id(_dst_id), _slot) + if CONFIG['REPORTS']['REPORT']: + self._report.send_bridgeEvent('UNIT DATA HEADER,START,RX,{},{},{},{},{},{}'.format(self._system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), _slot, int_id(_dst_id)).encode(encoding='utf-8', errors='ignore')) + elif _dtype_vseq == 7: + logger.info('(%s) *UNIT VCSBK 1/2 DATA BLOCK * STREAM ID: %s SUB: %s (%s) PEER: %s (%s) TGID %s (%s), TS %s', \ + self._system, int_id(_stream_id), get_alias(_rf_src, subscriber_ids), int_id(_rf_src), get_alias(_peer_id, peer_ids), int_id(_peer_id), get_alias(_dst_id, talkgroup_ids), int_id(_dst_id), _slot) + if CONFIG['REPORTS']['REPORT']: + self._report.send_bridgeEvent('UNIT VCSBK 1/2 DATA BLOCK,START,RX,{},{},{},{},{},{}'.format(self._system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), _slot, int_id(_dst_id)).encode(encoding='utf-8', errors='ignore')) + elif _dtype_vseq == 8: + logger.info('(%s) *UNIT VCSBK 3/4 DATA BLOCK * STREAM ID: %s SUB: %s (%s) PEER: %s (%s) TGID %s (%s), TS %s', \ + self._system, int_id(_stream_id), get_alias(_rf_src, subscriber_ids), int_id(_rf_src), get_alias(_peer_id, peer_ids), int_id(_peer_id), get_alias(_dst_id, talkgroup_ids), int_id(_dst_id), _slot) + if CONFIG['REPORTS']['REPORT']: + self._report.send_bridgeEvent('UNIT VCSBK 3/4 DATA BLOCK,START,RX,{},{},{},{},{},{}'.format(self._system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), _slot, int_id(_dst_id)).encode(encoding='utf-8', errors='ignore')) + else: + logger.info('(%s) *UNKNOW TYPE* STREAM ID: %s SUB: %s (%s) PEER: %s (%s) TGID %s (%s), TS %s', \ + self._system, int_id(_stream_id), get_alias(_rf_src, subscriber_ids), int_id(_rf_src), get_alias(_peer_id, peer_ids), int_id(_peer_id), get_alias(_dst_id, talkgroup_ids), int_id(_dst_id), _slot) +# ## if _dst_id in UNIT_MAP: ## systems[UNIT_MAP[_dst_id][0]].send_system(_data) ## else: @@ -1990,7 +2013,7 @@ class routerHBP(HBSYSTEM): if CONFIG['REPORTS']['REPORT']: self._report.send_bridgeEvent('GROUP VOICE,START,RX,{},{},{},{},{},{}'.format(self._system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), _slot, int_id(_dst_id)).encode(encoding='utf-8', errors='ignore')) else: - logger.info('(%s) *CSBK* STREAM ID: %s SUB: %s (%s) PEER: %s (%s) TGID %s (%s), TS %s _dtype_vseq: %s', + logger.info('(%s) *VCSBK* STREAM ID: %s SUB: %s (%s) PEER: %s (%s) TGID %s (%s), TS %s _dtype_vseq: %s', self._system, int_id(_stream_id), get_alias(_rf_src, subscriber_ids), int_id(_rf_src), get_alias(_peer_id, peer_ids), int_id(_peer_id), get_alias(_dst_id, talkgroup_ids), int_id(_dst_id), _slot, _dtype_vseq) if CONFIG['REPORTS']['REPORT']: self._report.send_bridgeEvent('OTHER DATA,START,RX,{},{},{},{},{},{}'.format(self._system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), _slot, int_id(_dst_id)).encode(encoding='utf-8', errors='ignore')) From 408c4972bfb2359b5ecf70165d68379d2f2221be Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 31 Oct 2021 23:32:49 +0000 Subject: [PATCH 26/49] Send all UNIT data to all openbridges --- bridge_master.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/bridge_master.py b/bridge_master.py index c46554f..eff2168 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1822,16 +1822,14 @@ class routerHBP(HBSYSTEM): else: logger.info('(%s) *UNKNOW TYPE* STREAM ID: %s SUB: %s (%s) PEER: %s (%s) TGID %s (%s), TS %s', \ self._system, int_id(_stream_id), get_alias(_rf_src, subscriber_ids), int_id(_rf_src), get_alias(_peer_id, peer_ids), int_id(_peer_id), get_alias(_dst_id, talkgroup_ids), int_id(_dst_id), _slot) -# - ## if _dst_id in UNIT_MAP: - ## systems[UNIT_MAP[_dst_id][0]].send_system(_data) - ## else: - ## logger.info('UNIT not in map, sending to ALL SYSTEMS') - ## for s in CONFIG['SYSTEMS'].items(): - ## if s[1]['MODE'] == 'OPENBRIDGE': - ## systems[s[0]].send_system(b'SVRDDATA' + _data) - ## elif s[1]['MODE'] != 'OPENBRIDGE': - ## systems[s[0]].send_system(_data) + + #Send to all openbridges + for system in CONFIG['SYSTEMS']: + if system['MODE'] == 'OPENBRIDGE': + systems[system].send_system(_data) + logger.info('(%s) UNIT Data: %s, Bridged to OBP System: %s TS: %s, DST_ID: %s', self._system, _bridge, _target['SYSTEM'], _target['TS'], int_id(_target['TGID'])) + if CONFIG['REPORTS']['REPORT']: + systems[_target['SYSTEM']]._report.send_bridgeEvent('UNIT DATA,START,TX,{},{},{},{},{},{}'.format(_target['SYSTEM'], int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), _target['TS'], int_id(_target['TGID'])).encode(encoding='utf-8', errors='ignore')) From 31f8babaeec0076734fae7e14df1160a89836b73 Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 31 Oct 2021 23:33:59 +0000 Subject: [PATCH 27/49] Send all UNIT data to all openbridges - typo --- bridge_master.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bridge_master.py b/bridge_master.py index eff2168..175ab1e 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1828,8 +1828,8 @@ class routerHBP(HBSYSTEM): if system['MODE'] == 'OPENBRIDGE': systems[system].send_system(_data) logger.info('(%s) UNIT Data: %s, Bridged to OBP System: %s TS: %s, DST_ID: %s', self._system, _bridge, _target['SYSTEM'], _target['TS'], int_id(_target['TGID'])) - if CONFIG['REPORTS']['REPORT']: - systems[_target['SYSTEM']]._report.send_bridgeEvent('UNIT DATA,START,TX,{},{},{},{},{},{}'.format(_target['SYSTEM'], int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), _target['TS'], int_id(_target['TGID'])).encode(encoding='utf-8', errors='ignore')) + if CONFIG['REPORTS']['REPORT']: + systems[_target['SYSTEM']]._report.send_bridgeEvent('UNIT DATA,START,TX,{},{},{},{},{},{}'.format(_target['SYSTEM'], int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), _target['TS'], int_id(_target['TGID'])).encode(encoding='utf-8', errors='ignore')) From 125224a74c6db2cf638764c1986abba95b9dd962 Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 31 Oct 2021 23:38:01 +0000 Subject: [PATCH 28/49] s --- bridge_master.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bridge_master.py b/bridge_master.py index 175ab1e..7a13b13 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1824,9 +1824,11 @@ class routerHBP(HBSYSTEM): self._system, int_id(_stream_id), get_alias(_rf_src, subscriber_ids), int_id(_rf_src), get_alias(_peer_id, peer_ids), int_id(_peer_id), get_alias(_dst_id, talkgroup_ids), int_id(_dst_id), _slot) #Send to all openbridges - for system in CONFIG['SYSTEMS']: - if system['MODE'] == 'OPENBRIDGE': - systems[system].send_system(_data) + for system in systems: + if system == self._system: + continue + if CONFIG['SYSTEMS'][system]['MODE'] == 'OPENBRIDGE': + system.send_system(_data) logger.info('(%s) UNIT Data: %s, Bridged to OBP System: %s TS: %s, DST_ID: %s', self._system, _bridge, _target['SYSTEM'], _target['TS'], int_id(_target['TGID'])) if CONFIG['REPORTS']['REPORT']: systems[_target['SYSTEM']]._report.send_bridgeEvent('UNIT DATA,START,TX,{},{},{},{},{},{}'.format(_target['SYSTEM'], int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), _target['TS'], int_id(_target['TGID'])).encode(encoding='utf-8', errors='ignore')) From a24dd767cd2e8dcc701ec6c7de0c01c137bdc5be Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 31 Oct 2021 23:40:52 +0000 Subject: [PATCH 29/49] d --- bridge_master.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridge_master.py b/bridge_master.py index 7a13b13..55d9419 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1828,7 +1828,7 @@ class routerHBP(HBSYSTEM): if system == self._system: continue if CONFIG['SYSTEMS'][system]['MODE'] == 'OPENBRIDGE': - system.send_system(_data) + systems[system].send_system(_data) logger.info('(%s) UNIT Data: %s, Bridged to OBP System: %s TS: %s, DST_ID: %s', self._system, _bridge, _target['SYSTEM'], _target['TS'], int_id(_target['TGID'])) if CONFIG['REPORTS']['REPORT']: systems[_target['SYSTEM']]._report.send_bridgeEvent('UNIT DATA,START,TX,{},{},{},{},{},{}'.format(_target['SYSTEM'], int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), _target['TS'], int_id(_target['TGID'])).encode(encoding='utf-8', errors='ignore')) From 6acd75528e8d5b21f1b53344ea459e34b05c5f18 Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 31 Oct 2021 23:43:39 +0000 Subject: [PATCH 30/49] e --- bridge_master.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridge_master.py b/bridge_master.py index 55d9419..d2c5b04 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1829,7 +1829,7 @@ class routerHBP(HBSYSTEM): continue if CONFIG['SYSTEMS'][system]['MODE'] == 'OPENBRIDGE': systems[system].send_system(_data) - logger.info('(%s) UNIT Data: %s, Bridged to OBP System: %s TS: %s, DST_ID: %s', self._system, _bridge, _target['SYSTEM'], _target['TS'], int_id(_target['TGID'])) + logger.info('(%s) UNIT Data Bridged to OBP System: %s TS: %s, DST_ID: %s', self._system, _target['SYSTEM'], _target['TS'], int_id(_target['TGID'])) if CONFIG['REPORTS']['REPORT']: systems[_target['SYSTEM']]._report.send_bridgeEvent('UNIT DATA,START,TX,{},{},{},{},{},{}'.format(_target['SYSTEM'], int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), _target['TS'], int_id(_target['TGID'])).encode(encoding='utf-8', errors='ignore')) From 7ae1f5b50bab60b8c1a3fdf38d86dda5a8519d3b Mon Sep 17 00:00:00 2001 From: Simon Date: Mon, 1 Nov 2021 00:01:30 +0000 Subject: [PATCH 31/49] e --- bridge_master.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bridge_master.py b/bridge_master.py index d2c5b04..9b6b118 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1829,9 +1829,9 @@ class routerHBP(HBSYSTEM): continue if CONFIG['SYSTEMS'][system]['MODE'] == 'OPENBRIDGE': systems[system].send_system(_data) - logger.info('(%s) UNIT Data Bridged to OBP System: %s TS: %s, DST_ID: %s', self._system, _target['SYSTEM'], _target['TS'], int_id(_target['TGID'])) + logger.info('(%s) UNIT Data Bridged to OBP System: %s DST_ID: %s', self._system, system, _target['TS'],_int_dst_id) if CONFIG['REPORTS']['REPORT']: - systems[_target['SYSTEM']]._report.send_bridgeEvent('UNIT DATA,START,TX,{},{},{},{},{},{}'.format(_target['SYSTEM'], int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), _target['TS'], int_id(_target['TGID'])).encode(encoding='utf-8', errors='ignore')) + systems[_target['SYSTEM']]._report.send_bridgeEvent('UNIT DATA,START,TX,{},{},{},{},{},{}'.format(_target['SYSTEM'], int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), 1, _int_dst_id).encode(encoding='utf-8', errors='ignore')) From 06a1c93bd018349d6925bc569a0e767aeaa8f2e9 Mon Sep 17 00:00:00 2001 From: Simon Date: Mon, 1 Nov 2021 00:03:28 +0000 Subject: [PATCH 32/49] e --- bridge_master.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bridge_master.py b/bridge_master.py index 9b6b118..e491eb2 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1829,9 +1829,9 @@ class routerHBP(HBSYSTEM): continue if CONFIG['SYSTEMS'][system]['MODE'] == 'OPENBRIDGE': systems[system].send_system(_data) - logger.info('(%s) UNIT Data Bridged to OBP System: %s DST_ID: %s', self._system, system, _target['TS'],_int_dst_id) + logger.info('(%s) UNIT Data Bridged to OBP System: %s DST_ID: %s', self._system, system,_int_dst_id) if CONFIG['REPORTS']['REPORT']: - systems[_target['SYSTEM']]._report.send_bridgeEvent('UNIT DATA,START,TX,{},{},{},{},{},{}'.format(_target['SYSTEM'], int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), 1, _int_dst_id).encode(encoding='utf-8', errors='ignore')) + systems[_target['SYSTEM']]._report.send_bridgeEvent('UNIT DATA,START,TX,{},{},{},{},{},{}'.format(system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), 1, _int_dst_id).encode(encoding='utf-8', errors='ignore')) From 62f661e19da2d15da6e68896d0e9320815ffa566 Mon Sep 17 00:00:00 2001 From: Simon Date: Mon, 1 Nov 2021 00:11:04 +0000 Subject: [PATCH 33/49] e --- bridge_master.py | 1 + 1 file changed, 1 insertion(+) diff --git a/bridge_master.py b/bridge_master.py index e491eb2..6f975fd 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1827,6 +1827,7 @@ class routerHBP(HBSYSTEM): for system in systems: if system == self._system: continue + print(system) if CONFIG['SYSTEMS'][system]['MODE'] == 'OPENBRIDGE': systems[system].send_system(_data) logger.info('(%s) UNIT Data Bridged to OBP System: %s DST_ID: %s', self._system, system,_int_dst_id) From b42011acfde33e1cb871618d582db3425bf4fd4c Mon Sep 17 00:00:00 2001 From: Simon Date: Mon, 1 Nov 2021 00:12:53 +0000 Subject: [PATCH 34/49] fit report send fault --- bridge_master.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridge_master.py b/bridge_master.py index 6f975fd..21699db 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1832,7 +1832,7 @@ class routerHBP(HBSYSTEM): systems[system].send_system(_data) logger.info('(%s) UNIT Data Bridged to OBP System: %s DST_ID: %s', self._system, system,_int_dst_id) if CONFIG['REPORTS']['REPORT']: - systems[_target['SYSTEM']]._report.send_bridgeEvent('UNIT DATA,START,TX,{},{},{},{},{},{}'.format(system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), 1, _int_dst_id).encode(encoding='utf-8', errors='ignore')) + systems[system]._report.send_bridgeEvent('UNIT DATA,START,TX,{},{},{},{},{},{}'.format(system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), 1, _int_dst_id).encode(encoding='utf-8', errors='ignore')) From d32e8eaa62add0aa84dac1ddaf40bc3a176dea73 Mon Sep 17 00:00:00 2001 From: Simon Date: Tue, 2 Nov 2021 11:50:12 +0000 Subject: [PATCH 35/49] comment out debug in proxy for now --- hotspot_proxy_v2.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hotspot_proxy_v2.py b/hotspot_proxy_v2.py index a19f932..96a0cdc 100644 --- a/hotspot_proxy_v2.py +++ b/hotspot_proxy_v2.py @@ -220,8 +220,8 @@ if __name__ == '__main__': #Override static config from Environment if 'FDPROXY_STATS' in os.environ: Stats = bool(os.environ['FDPROXY_STATS']) - if 'FDPROXY_DEBUG' in os.environ: - Debug = bool(os.environ['FDPROXY_DEBUG']) + # if 'FDPROXY_DEBUG' in os.environ: + # Debug = bool(os.environ['FDPROXY_DEBUG']) if 'FDPROXY_CLIENTINFO' in os.environ: ClientInfo = bool(os.environ['FDPROXY_CLIENTINFO']) if 'FDPROXY_LISTENPORT' in os.environ: From 5d38a98b3a27f0cf73f2d694f3bfdb959660c3ff Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 3 Nov 2021 00:07:20 +0000 Subject: [PATCH 36/49] properly form OBP packet for UNIT DATA --- bridge_master.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bridge_master.py b/bridge_master.py index 21699db..70306ff 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1829,7 +1829,12 @@ class routerHBP(HBSYSTEM): continue print(system) if CONFIG['SYSTEMS'][system]['MODE'] == 'OPENBRIDGE': - systems[system].send_system(_data) + # Clear the TS bit -- all OpenBridge streams are effectively on TS1 + _tmp_bits = _bits & ~(1 << 7) + # Assemble transmit HBP packet header + _tmp_data = b''.join([_data[:15], _tmp_bits.to_bytes(1, 'big'), _data[16:20]]) + _tmp_data = b''.join([_tmp_data, dmrpkt, _data[53:55]]) + systems[system].send_system(_tmp_data) logger.info('(%s) UNIT Data Bridged to OBP System: %s DST_ID: %s', self._system, system,_int_dst_id) if CONFIG['REPORTS']['REPORT']: systems[system]._report.send_bridgeEvent('UNIT DATA,START,TX,{},{},{},{},{},{}'.format(system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), 1, _int_dst_id).encode(encoding='utf-8', errors='ignore')) From db8870d9b4f89840e5ca2db5a3268f8fba16aec3 Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 3 Nov 2021 00:16:05 +0000 Subject: [PATCH 37/49] Add more logging --- bridge_master.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridge_master.py b/bridge_master.py index 70306ff..e481bbe 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1835,7 +1835,7 @@ class routerHBP(HBSYSTEM): _tmp_data = b''.join([_data[:15], _tmp_bits.to_bytes(1, 'big'), _data[16:20]]) _tmp_data = b''.join([_tmp_data, dmrpkt, _data[53:55]]) systems[system].send_system(_tmp_data) - logger.info('(%s) UNIT Data Bridged to OBP System: %s DST_ID: %s', self._system, system,_int_dst_id) + logger.info('(%s) UNIT Data Bridged to OBP System: %s DST_ID: %s, length: %s, data: %s', self._system, system,_int_dst_id,len(_tmp_data,_tmp_data)) if CONFIG['REPORTS']['REPORT']: systems[system]._report.send_bridgeEvent('UNIT DATA,START,TX,{},{},{},{},{},{}'.format(system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), 1, _int_dst_id).encode(encoding='utf-8', errors='ignore')) From 85b782d5e9f9d11f7ceace93659d5bc5c3fa76e7 Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 3 Nov 2021 00:17:41 +0000 Subject: [PATCH 38/49] typo ) --- bridge_master.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridge_master.py b/bridge_master.py index e481bbe..8d1fb0e 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1835,7 +1835,7 @@ class routerHBP(HBSYSTEM): _tmp_data = b''.join([_data[:15], _tmp_bits.to_bytes(1, 'big'), _data[16:20]]) _tmp_data = b''.join([_tmp_data, dmrpkt, _data[53:55]]) systems[system].send_system(_tmp_data) - logger.info('(%s) UNIT Data Bridged to OBP System: %s DST_ID: %s, length: %s, data: %s', self._system, system,_int_dst_id,len(_tmp_data,_tmp_data)) + logger.info('(%s) UNIT Data Bridged to OBP System: %s DST_ID: %s, length: %s, data: %s', self._system, system,_int_dst_id,len(_tmp_data),_tmp_data)) if CONFIG['REPORTS']['REPORT']: systems[system]._report.send_bridgeEvent('UNIT DATA,START,TX,{},{},{},{},{},{}'.format(system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), 1, _int_dst_id).encode(encoding='utf-8', errors='ignore')) From 0758e170dee47ebc2e2c9dba3fd71c5d6f5b632c Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 3 Nov 2021 00:18:35 +0000 Subject: [PATCH 39/49] typo ) again --- bridge_master.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridge_master.py b/bridge_master.py index 8d1fb0e..42e5dd7 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1835,7 +1835,7 @@ class routerHBP(HBSYSTEM): _tmp_data = b''.join([_data[:15], _tmp_bits.to_bytes(1, 'big'), _data[16:20]]) _tmp_data = b''.join([_tmp_data, dmrpkt, _data[53:55]]) systems[system].send_system(_tmp_data) - logger.info('(%s) UNIT Data Bridged to OBP System: %s DST_ID: %s, length: %s, data: %s', self._system, system,_int_dst_id,len(_tmp_data),_tmp_data)) + logger.info('(%s) UNIT Data Bridged to OBP System: %s DST_ID: %s, length: %s, data: %s', self._system, system,_int_dst_id,len(_tmp_data),_tmp_data) if CONFIG['REPORTS']['REPORT']: systems[system]._report.send_bridgeEvent('UNIT DATA,START,TX,{},{},{},{},{},{}'.format(system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), 1, _int_dst_id).encode(encoding='utf-8', errors='ignore')) From aea6a542f2fe43549788d580eab294dd35e83df1 Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 3 Nov 2021 00:21:22 +0000 Subject: [PATCH 40/49] don't need BER and RSSI data on OB --- bridge_master.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridge_master.py b/bridge_master.py index 42e5dd7..9f8ead2 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1833,7 +1833,7 @@ class routerHBP(HBSYSTEM): _tmp_bits = _bits & ~(1 << 7) # Assemble transmit HBP packet header _tmp_data = b''.join([_data[:15], _tmp_bits.to_bytes(1, 'big'), _data[16:20]]) - _tmp_data = b''.join([_tmp_data, dmrpkt, _data[53:55]]) + _tmp_data = b''.join([_tmp_data, dmrpkt) systems[system].send_system(_tmp_data) logger.info('(%s) UNIT Data Bridged to OBP System: %s DST_ID: %s, length: %s, data: %s', self._system, system,_int_dst_id,len(_tmp_data),_tmp_data) if CONFIG['REPORTS']['REPORT']: From af019251f0a0376a4302c99761de11d460a0fe31 Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 3 Nov 2021 00:22:34 +0000 Subject: [PATCH 41/49] missing ] --- bridge_master.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridge_master.py b/bridge_master.py index 9f8ead2..6175af4 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1833,7 +1833,7 @@ class routerHBP(HBSYSTEM): _tmp_bits = _bits & ~(1 << 7) # Assemble transmit HBP packet header _tmp_data = b''.join([_data[:15], _tmp_bits.to_bytes(1, 'big'), _data[16:20]]) - _tmp_data = b''.join([_tmp_data, dmrpkt) + _tmp_data = b''.join([_tmp_data, dmrpkt]) systems[system].send_system(_tmp_data) logger.info('(%s) UNIT Data Bridged to OBP System: %s DST_ID: %s, length: %s, data: %s', self._system, system,_int_dst_id,len(_tmp_data),_tmp_data) if CONFIG['REPORTS']['REPORT']: From 281ece11d510c3145087285a1579888d8b726556 Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 3 Nov 2021 00:55:15 +0000 Subject: [PATCH 42/49] Handle and log incoming unit data packets from OBP and re-route to all other OBPs --- bridge_master.py | 51 ++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 41 insertions(+), 10 deletions(-) diff --git a/bridge_master.py b/bridge_master.py index 6175af4..1c8e0e8 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1372,14 +1372,46 @@ class routerOBP(OPENBRIDGE): _bits = _data[15] # Match UNIT data, SMS/GPS, and send it to the dst_id if it is in out UNIT_MAP - if (_dtype_vseq == 6 or _dtype_vseq == 7) or ahex(dmrpkt)[27:-27] == b'd5d7f77fd757' and _dtype_vseq == 3 and _call_type == 'unit': - logger.info('(%s) Received UNIT data packet',self._system) -## print(UNIT_MAP) -## print(int_id(_dst_id)) -## print(int_id(_rf_src)) - - if _dst_id in UNIT_MAP: - pass + if _call_type == 'unit' and (_dtype_vseq == 6 or _dtype_vseq == 7 or ((_stream_id not in self.STATUS) and _dtype_vseq == 3)): +## if ahex(dmrpkt)[27:-27] == b'd5d7f77fd757': + # This is a data call + _data_call = True + if _dtype_vseq == 3: + logger.info('(%s) *UNIT CSBK* STREAM ID: %s SUB: %s (%s) PEER: %s (%s) DST_ID %s (%s), TS %s', \ + self._system, int_id(_stream_id), get_alias(_rf_src, subscriber_ids), int_id(_rf_src), get_alias(_peer_id, peer_ids), int_id(_peer_id), get_alias(_dst_id, talkgroup_ids), int_id(_dst_id), _slot) + if CONFIG['REPORTS']['REPORT']: + self._report.send_bridgeEvent('UNIT CSBK,START,RX,{},{},{},{},{},{}'.format(self._system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), _slot, int_id(_dst_id)).encode(encoding='utf-8', errors='ignore')) + elif _dtype_vseq == 6: + logger.info('(%s) *UNIT DATA HEADER* STREAM ID: %s SUB: %s (%s) PEER: %s (%s) DST_ID %s (%s), TS %s', \ + self._system, int_id(_stream_id), get_alias(_rf_src, subscriber_ids), int_id(_rf_src), get_alias(_peer_id, peer_ids), int_id(_peer_id), get_alias(_dst_id, talkgroup_ids), int_id(_dst_id), _slot) + if CONFIG['REPORTS']['REPORT']: + self._report.send_bridgeEvent('UNIT DATA HEADER,START,RX,{},{},{},{},{},{}'.format(self._system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), _slot, int_id(_dst_id)).encode(encoding='utf-8', errors='ignore')) + elif _dtype_vseq == 7: + logger.info('(%s) *UNIT VCSBK 1/2 DATA BLOCK * STREAM ID: %s SUB: %s (%s) PEER: %s (%s) TGID %s (%s), TS %s', \ + self._system, int_id(_stream_id), get_alias(_rf_src, subscriber_ids), int_id(_rf_src), get_alias(_peer_id, peer_ids), int_id(_peer_id), get_alias(_dst_id, talkgroup_ids), int_id(_dst_id), _slot) + if CONFIG['REPORTS']['REPORT']: + self._report.send_bridgeEvent('UNIT VCSBK 1/2 DATA BLOCK,START,RX,{},{},{},{},{},{}'.format(self._system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), _slot, int_id(_dst_id)).encode(encoding='utf-8', errors='ignore')) + elif _dtype_vseq == 8: + logger.info('(%s) *UNIT VCSBK 3/4 DATA BLOCK * STREAM ID: %s SUB: %s (%s) PEER: %s (%s) TGID %s (%s), TS %s', \ + self._system, int_id(_stream_id), get_alias(_rf_src, subscriber_ids), int_id(_rf_src), get_alias(_peer_id, peer_ids), int_id(_peer_id), get_alias(_dst_id, talkgroup_ids), int_id(_dst_id), _slot) + if CONFIG['REPORTS']['REPORT']: + self._report.send_bridgeEvent('UNIT VCSBK 3/4 DATA BLOCK,START,RX,{},{},{},{},{},{}'.format(self._system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), _slot, int_id(_dst_id)).encode(encoding='utf-8', errors='ignore')) + else: + logger.info('(%s) *UNKNOWN DATA TYPE* STREAM ID: %s SUB: %s (%s) PEER: %s (%s) TGID %s (%s), TS %s', \ + self._system, int_id(_stream_id), get_alias(_rf_src, subscriber_ids), int_id(_rf_src), get_alias(_peer_id, peer_ids), int_id(_peer_id), get_alias(_dst_id, talkgroup_ids), int_id(_dst_id), _slot) + + #Send to all openbridges + for system in systems: + if system == self._system: + continue + if CONFIG['SYSTEMS'][system]['MODE'] == 'OPENBRIDGE': + # Assemble transmit HBP packet header + _tmp_data = b''.join([_data[:15], _tmp_bits.to_bytes(1, 'big'), _data[16:20]]) + _tmp_data = b''.join([_tmp_data, dmrpkt]) + systems[system].send_system(_tmp_data) + logger.info('(%s) UNIT Data Bridged to OBP System: %s DST_ID: %s', self._system, system,_int_dst_id) + if CONFIG['REPORTS']['REPORT']: + systems[system]._report.send_bridgeEvent('UNIT DATA,START,TX,{},{},{},{},{},{}'.format(system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), 1, _int_dst_id).encode(encoding='utf-8', errors='ignore')) if _call_type == 'group' or _call_type == 'vcsbk': @@ -1827,7 +1859,6 @@ class routerHBP(HBSYSTEM): for system in systems: if system == self._system: continue - print(system) if CONFIG['SYSTEMS'][system]['MODE'] == 'OPENBRIDGE': # Clear the TS bit -- all OpenBridge streams are effectively on TS1 _tmp_bits = _bits & ~(1 << 7) @@ -1835,7 +1866,7 @@ class routerHBP(HBSYSTEM): _tmp_data = b''.join([_data[:15], _tmp_bits.to_bytes(1, 'big'), _data[16:20]]) _tmp_data = b''.join([_tmp_data, dmrpkt]) systems[system].send_system(_tmp_data) - logger.info('(%s) UNIT Data Bridged to OBP System: %s DST_ID: %s, length: %s, data: %s', self._system, system,_int_dst_id,len(_tmp_data),_tmp_data) + logger.info('(%s) UNIT Data Bridged to OBP System: %s DST_ID: %s', self._system, system,_int_dst_id) if CONFIG['REPORTS']['REPORT']: systems[system]._report.send_bridgeEvent('UNIT DATA,START,TX,{},{},{},{},{},{}'.format(system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), 1, _int_dst_id).encode(encoding='utf-8', errors='ignore')) From 74c113ed9210f633725562ba245185a892730827 Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 3 Nov 2021 01:20:06 +0000 Subject: [PATCH 43/49] comment out sending unit data to all OBPs. It's dangerous! --- bridge_master.py | 60 +++++++++++++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 24 deletions(-) diff --git a/bridge_master.py b/bridge_master.py index 1c8e0e8..d600e07 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1401,17 +1401,23 @@ class routerOBP(OPENBRIDGE): self._system, int_id(_stream_id), get_alias(_rf_src, subscriber_ids), int_id(_rf_src), get_alias(_peer_id, peer_ids), int_id(_peer_id), get_alias(_dst_id, talkgroup_ids), int_id(_dst_id), _slot) #Send to all openbridges - for system in systems: - if system == self._system: - continue - if CONFIG['SYSTEMS'][system]['MODE'] == 'OPENBRIDGE': - # Assemble transmit HBP packet header - _tmp_data = b''.join([_data[:15], _tmp_bits.to_bytes(1, 'big'), _data[16:20]]) - _tmp_data = b''.join([_tmp_data, dmrpkt]) - systems[system].send_system(_tmp_data) - logger.info('(%s) UNIT Data Bridged to OBP System: %s DST_ID: %s', self._system, system,_int_dst_id) - if CONFIG['REPORTS']['REPORT']: - systems[system]._report.send_bridgeEvent('UNIT DATA,START,TX,{},{},{},{},{},{}'.format(system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), 1, _int_dst_id).encode(encoding='utf-8', errors='ignore')) + # We don't want to do this without more thought! + # If we are going to do this is requires loop control + # for data packets + # + # Best for now to send all data packet to a single gateway + + #for system in systems: + #if system == self._system: + #continue + #if CONFIG['SYSTEMS'][system]['MODE'] == 'OPENBRIDGE': + #Assemble transmit HBP packet header + #_tmp_data = b''.join([_data[:15], _tmp_bits.to_bytes(1, 'big'), _data[16:20]]) + #_tmp_data = b''.join([_tmp_data, dmrpkt]) + #systems[system].send_system(_tmp_data) + #logger.info('(%s) UNIT Data Bridged to OBP System: %s DST_ID: %s', self._system, system,_int_dst_id) + #if CONFIG['REPORTS']['REPORT']: + #systems[system]._report.send_bridgeEvent('UNIT DATA,START,TX,{},{},{},{},{},{}'.format(system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), 1, _int_dst_id).encode(encoding='utf-8', errors='ignore')) if _call_type == 'group' or _call_type == 'vcsbk': @@ -1856,19 +1862,25 @@ class routerHBP(HBSYSTEM): self._system, int_id(_stream_id), get_alias(_rf_src, subscriber_ids), int_id(_rf_src), get_alias(_peer_id, peer_ids), int_id(_peer_id), get_alias(_dst_id, talkgroup_ids), int_id(_dst_id), _slot) #Send to all openbridges - for system in systems: - if system == self._system: - continue - if CONFIG['SYSTEMS'][system]['MODE'] == 'OPENBRIDGE': - # Clear the TS bit -- all OpenBridge streams are effectively on TS1 - _tmp_bits = _bits & ~(1 << 7) - # Assemble transmit HBP packet header - _tmp_data = b''.join([_data[:15], _tmp_bits.to_bytes(1, 'big'), _data[16:20]]) - _tmp_data = b''.join([_tmp_data, dmrpkt]) - systems[system].send_system(_tmp_data) - logger.info('(%s) UNIT Data Bridged to OBP System: %s DST_ID: %s', self._system, system,_int_dst_id) - if CONFIG['REPORTS']['REPORT']: - systems[system]._report.send_bridgeEvent('UNIT DATA,START,TX,{},{},{},{},{},{}'.format(system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), 1, _int_dst_id).encode(encoding='utf-8', errors='ignore')) + # We don't want to do this without more thought! + # If we are going to do this is requires loop control + # for data packets + # + # Best for now to send all data packet to a single gateway + + #for system in systems: + #if system == self._system: + #continue + #if CONFIG['SYSTEMS'][system]['MODE'] == 'OPENBRIDGE': + #Clear the TS bit -- all OpenBridge streams are effectively on TS1 + #_tmp_bits = _bits & ~(1 << 7) + #Assemble transmit HBP packet header + #_tmp_data = b''.join([_data[:15], _tmp_bits.to_bytes(1, 'big'), _data[16:20]]) + #_tmp_data = b''.join([_tmp_data, dmrpkt]) + #systems[system].send_system(_tmp_data) + #logger.info('(%s) UNIT Data Bridged to OBP System: %s DST_ID: %s', self._system, system,_int_dst_id) + #if CONFIG['REPORTS']['REPORT']: + #systems[system]._report.send_bridgeEvent('UNIT DATA,START,TX,{},{},{},{},{},{}'.format(system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), 1, _int_dst_id).encode(encoding='utf-8', errors='ignore')) From 19f49d4e7ad20ea2e3949cfa538b2538b486deac Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 3 Nov 2021 01:51:21 +0000 Subject: [PATCH 44/49] Send inbound unit data to DATA_GATEWAY --- bridge_master.py | 39 +++++++++++++++++++++++++++++++++++++++ config.py | 3 ++- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/bridge_master.py b/bridge_master.py index d600e07..a1b100a 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1418,6 +1418,25 @@ class routerOBP(OPENBRIDGE): #logger.info('(%s) UNIT Data Bridged to OBP System: %s DST_ID: %s', self._system, system,_int_dst_id) #if CONFIG['REPORTS']['REPORT']: #systems[system]._report.send_bridgeEvent('UNIT DATA,START,TX,{},{},{},{},{},{}'.format(system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), 1, _int_dst_id).encode(encoding='utf-8', errors='ignore')) + + #This allow careful daisychaining to reach a DATA_GATEWAY + #Send UNIT data to data gateway + if CONFIG['GLOBAL']['DATA_GATEWAY'] and CONFIG['GLOBAL']['DATA_GATEWAY'] in systems \ + and CONFIG['SYSTEMS'][CONFIG['SYSTEMS']['DATA_GATEWAY']]['MODE'] == OPENBRIDGE: + #Clear the TS bit -- all OpenBridge streams are effectively on TS1 + _tmp_bits = _bits & ~(1 << 7) + #Assemble transmit HBP packet header + _tmp_data = b''.join([_data[:15], _tmp_bits.to_bytes(1, 'big'), _data[16:20]]) + _tmp_data = b''.join([_tmp_data, dmrpkt]) + systems[system].send_system(_tmp_data) + logger.info('(%s) UNIT Data Bridged to DATA_GATEWAY: %s DST_ID: %s', self._system,CONFIG['GLOBAL']['DATA_GATEWAY'],_int_dst_id) + if CONFIG['REPORTS']['REPORT']: + systems[system]._report.send_bridgeEvent('UNIT DATA,START,TX,{},{},{},{},{},{}'.format(system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), 1, _int_dst_id).encode(encoding='utf-8', errors='ignore')) + else: + if not CONFIG['GLOBAL']['DATA_GATEWAY']: + logger.info('(%s) UNIT Data not Bridged - no DATA_GATEWAY: %s DST_ID: %s',self._system,_int_dst_id) + else: + logger.info('(%s) UNIT Data not Bridged - Problem with DATA_GATEWAY: %s DST_ID: %s',self._system,_int_dst_id) if _call_type == 'group' or _call_type == 'vcsbk': @@ -1881,6 +1900,26 @@ class routerHBP(HBSYSTEM): #logger.info('(%s) UNIT Data Bridged to OBP System: %s DST_ID: %s', self._system, system,_int_dst_id) #if CONFIG['REPORTS']['REPORT']: #systems[system]._report.send_bridgeEvent('UNIT DATA,START,TX,{},{},{},{},{},{}'.format(system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), 1, _int_dst_id).encode(encoding='utf-8', errors='ignore')) + + #Send UNIT data to data gateway + if CONFIG['GLOBAL']['DATA_GATEWAY'] and CONFIG['GLOBAL']['DATA_GATEWAY'] in systems \ + and CONFIG['SYSTEMS'][CONFIG['SYSTEMS']['DATA_GATEWAY']]['MODE'] == OPENBRIDGE: + #Clear the TS bit -- all OpenBridge streams are effectively on TS1 + _tmp_bits = _bits & ~(1 << 7) + #Assemble transmit HBP packet header + _tmp_data = b''.join([_data[:15], _tmp_bits.to_bytes(1, 'big'), _data[16:20]]) + _tmp_data = b''.join([_tmp_data, dmrpkt]) + systems[system].send_system(_tmp_data) + logger.info('(%s) UNIT Data Bridged to DATA_GATEWAY: %s DST_ID: %s', self._system,CONFIG['GLOBAL']['DATA_GATEWAY'],_int_dst_id) + if CONFIG['REPORTS']['REPORT']: + systems[system]._report.send_bridgeEvent('UNIT DATA,START,TX,{},{},{},{},{},{}'.format(system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), 1, _int_dst_id).encode(encoding='utf-8', errors='ignore')) + else: + if not CONFIG['GLOBAL']['DATA_GATEWAY']: + logger.info('(%s) UNIT Data not Bridged - no DATA_GATEWAY: %s DST_ID: %s',self._system,_int_dst_id) + else: + logger.info('(%s) UNIT Data not Bridged - Problem with DATA_GATEWAY: %s DST_ID: %s',self._system,_int_dst_id) + + diff --git a/config.py b/config.py index 51b6c4e..cecd047 100755 --- a/config.py +++ b/config.py @@ -145,7 +145,8 @@ def build_config(_config_file): 'GEN_STAT_BRIDGES': config.getboolean(section, 'GEN_STAT_BRIDGES'), 'ALLOW_NULL_PASSPHRASE': config.getboolean(section, 'ALLOW_NULL_PASSPHRASE'), 'ANNOUNCEMENT_LANGUAGES': config.get(section, 'ANNOUNCEMENT_LANGUAGES'), - 'SERVER_ID': config.getint(section, 'SERVER_ID').to_bytes(4, 'big') + 'SERVER_ID': config.getint(section, 'SERVER_ID').to_bytes(4, 'big'), + 'DATA_GATEWAY': config.get(section, 'DATA_GATEWAY') }) if not CONFIG['GLOBAL']['ANNOUNCEMENT_LANGUAGES']: From 609eda884e04c4e02f53e38e8a021e530607ef16 Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 3 Nov 2021 02:01:17 +0000 Subject: [PATCH 45/49] global --- bridge_master.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bridge_master.py b/bridge_master.py index a1b100a..b3e0fac 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1422,7 +1422,7 @@ class routerOBP(OPENBRIDGE): #This allow careful daisychaining to reach a DATA_GATEWAY #Send UNIT data to data gateway if CONFIG['GLOBAL']['DATA_GATEWAY'] and CONFIG['GLOBAL']['DATA_GATEWAY'] in systems \ - and CONFIG['SYSTEMS'][CONFIG['SYSTEMS']['DATA_GATEWAY']]['MODE'] == OPENBRIDGE: + and CONFIG['SYSTEMS'][CONFIG['GLOBAL']['DATA_GATEWAY']]['MODE'] == OPENBRIDGE: #Clear the TS bit -- all OpenBridge streams are effectively on TS1 _tmp_bits = _bits & ~(1 << 7) #Assemble transmit HBP packet header @@ -1903,7 +1903,7 @@ class routerHBP(HBSYSTEM): #Send UNIT data to data gateway if CONFIG['GLOBAL']['DATA_GATEWAY'] and CONFIG['GLOBAL']['DATA_GATEWAY'] in systems \ - and CONFIG['SYSTEMS'][CONFIG['SYSTEMS']['DATA_GATEWAY']]['MODE'] == OPENBRIDGE: + and CONFIG['SYSTEMS'][CONFIG['GLOBAL']['DATA_GATEWAY']]['MODE'] == OPENBRIDGE: #Clear the TS bit -- all OpenBridge streams are effectively on TS1 _tmp_bits = _bits & ~(1 << 7) #Assemble transmit HBP packet header From 7c75f3e17fc76415f580aab6a37b6350167fa05d Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 3 Nov 2021 02:03:45 +0000 Subject: [PATCH 46/49] global 2 --- bridge_master.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bridge_master.py b/bridge_master.py index b3e0fac..7a09270 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1902,7 +1902,7 @@ class routerHBP(HBSYSTEM): #systems[system]._report.send_bridgeEvent('UNIT DATA,START,TX,{},{},{},{},{},{}'.format(system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), 1, _int_dst_id).encode(encoding='utf-8', errors='ignore')) #Send UNIT data to data gateway - if CONFIG['GLOBAL']['DATA_GATEWAY'] and CONFIG['GLOBAL']['DATA_GATEWAY'] in systems \ + if CONFIG['GLOBAL']['DATA_GATEWAY'] and (CONFIG['GLOBAL']['DATA_GATEWAY'] in systems) \ and CONFIG['SYSTEMS'][CONFIG['GLOBAL']['DATA_GATEWAY']]['MODE'] == OPENBRIDGE: #Clear the TS bit -- all OpenBridge streams are effectively on TS1 _tmp_bits = _bits & ~(1 << 7) @@ -1917,7 +1917,7 @@ class routerHBP(HBSYSTEM): if not CONFIG['GLOBAL']['DATA_GATEWAY']: logger.info('(%s) UNIT Data not Bridged - no DATA_GATEWAY: %s DST_ID: %s',self._system,_int_dst_id) else: - logger.info('(%s) UNIT Data not Bridged - Problem with DATA_GATEWAY: %s DST_ID: %s',self._system,_int_dst_id) + logger.info('(%s) UNIT Data not Bridged - Problem with DATA_GATEWAY: %s DST_ID: %s',self._system, CONFIG['GLOBAL']['DATA_GATEWAY'],_int_dst_id) From e5b9880e4e380cd50b0a2ac46a5adc23f5d9bfe7 Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 3 Nov 2021 02:09:06 +0000 Subject: [PATCH 47/49] better gateway logging --- bridge_master.py | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/bridge_master.py b/bridge_master.py index 7a09270..9e47aeb 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1421,8 +1421,8 @@ class routerOBP(OPENBRIDGE): #This allow careful daisychaining to reach a DATA_GATEWAY #Send UNIT data to data gateway - if CONFIG['GLOBAL']['DATA_GATEWAY'] and CONFIG['GLOBAL']['DATA_GATEWAY'] in systems \ - and CONFIG['SYSTEMS'][CONFIG['GLOBAL']['DATA_GATEWAY']]['MODE'] == OPENBRIDGE: + if CONFIG['GLOBAL']['DATA_GATEWAY'] and (CONFIG['GLOBAL']['DATA_GATEWAY'] in systems) \ + and CONFIG['SYSTEMS'][CONFIG['GLOBAL']['DATA_GATEWAY']]['MODE'] == 'OPENBRIDGE': #Clear the TS bit -- all OpenBridge streams are effectively on TS1 _tmp_bits = _bits & ~(1 << 7) #Assemble transmit HBP packet header @@ -1434,11 +1434,12 @@ class routerOBP(OPENBRIDGE): systems[system]._report.send_bridgeEvent('UNIT DATA,START,TX,{},{},{},{},{},{}'.format(system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), 1, _int_dst_id).encode(encoding='utf-8', errors='ignore')) else: if not CONFIG['GLOBAL']['DATA_GATEWAY']: - logger.info('(%s) UNIT Data not Bridged - no DATA_GATEWAY: %s DST_ID: %s',self._system,_int_dst_id) - else: - logger.info('(%s) UNIT Data not Bridged - Problem with DATA_GATEWAY: %s DST_ID: %s',self._system,_int_dst_id) - - + logger.info('(%s) UNIT Data not Bridged - no DATA_GATEWAY: %s, DST_ID: %s',self._system,_int_dst_id) + elif CONFIG['GLOBAL']['DATA_GATEWAY'] not in systems: + logger.warning('(%s) UNIT Data not Bridged - DATA_GATEWAY: %s not valid. DST_ID: %s',self._system, CONFIG['GLOBAL']['DATA_GATEWAY'],_int_dst_id) + elif CONFIG['SYSTEMS'][CONFIG['GLOBAL']['DATA_GATEWAY']]['MODE'] != 'OPENBRIDGE': + logger.warning('(%s) UNIT Data not Bridged - DATA_GATEWAY: %s not OPENBRIDGE. DST_ID: %s',self._system, CONFIG['GLOBAL']['DATA_GATEWAY'],_int_dst_id) + if _call_type == 'group' or _call_type == 'vcsbk': # Is this a new call stream? if (_stream_id not in self.STATUS): @@ -1903,7 +1904,7 @@ class routerHBP(HBSYSTEM): #Send UNIT data to data gateway if CONFIG['GLOBAL']['DATA_GATEWAY'] and (CONFIG['GLOBAL']['DATA_GATEWAY'] in systems) \ - and CONFIG['SYSTEMS'][CONFIG['GLOBAL']['DATA_GATEWAY']]['MODE'] == OPENBRIDGE: + and CONFIG['SYSTEMS'][CONFIG['GLOBAL']['DATA_GATEWAY']]['MODE'] == 'OPENBRIDGE': #Clear the TS bit -- all OpenBridge streams are effectively on TS1 _tmp_bits = _bits & ~(1 << 7) #Assemble transmit HBP packet header @@ -1915,9 +1916,11 @@ class routerHBP(HBSYSTEM): systems[system]._report.send_bridgeEvent('UNIT DATA,START,TX,{},{},{},{},{},{}'.format(system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), 1, _int_dst_id).encode(encoding='utf-8', errors='ignore')) else: if not CONFIG['GLOBAL']['DATA_GATEWAY']: - logger.info('(%s) UNIT Data not Bridged - no DATA_GATEWAY: %s DST_ID: %s',self._system,_int_dst_id) - else: - logger.info('(%s) UNIT Data not Bridged - Problem with DATA_GATEWAY: %s DST_ID: %s',self._system, CONFIG['GLOBAL']['DATA_GATEWAY'],_int_dst_id) + logger.info('(%s) UNIT Data not Bridged - no DATA_GATEWAY: %s, DST_ID: %s',self._system,_int_dst_id) + elif CONFIG['GLOBAL']['DATA_GATEWAY'] not in systems: + logger.warning('(%s) UNIT Data not Bridged - DATA_GATEWAY: %s not valid. DST_ID: %s',self._system, CONFIG['GLOBAL']['DATA_GATEWAY'],_int_dst_id) + elif CONFIG['SYSTEMS'][CONFIG['GLOBAL']['DATA_GATEWAY']]['MODE'] != 'OPENBRIDGE': + logger.warning('(%s) UNIT Data not Bridged - DATA_GATEWAY: %s not OPENBRIDGE. DST_ID: %s',self._system, CONFIG['GLOBAL']['DATA_GATEWAY'],_int_dst_id) From 3802af35a2d601bc414c703f750ff540a194aabb Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 3 Nov 2021 02:12:24 +0000 Subject: [PATCH 48/49] send to correct system --- bridge_master.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bridge_master.py b/bridge_master.py index 9e47aeb..800da86 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1428,7 +1428,7 @@ class routerOBP(OPENBRIDGE): #Assemble transmit HBP packet header _tmp_data = b''.join([_data[:15], _tmp_bits.to_bytes(1, 'big'), _data[16:20]]) _tmp_data = b''.join([_tmp_data, dmrpkt]) - systems[system].send_system(_tmp_data) + systems[CONFIG['GLOBAL']['DATA_GATEWAY']].send_system(_tmp_data) logger.info('(%s) UNIT Data Bridged to DATA_GATEWAY: %s DST_ID: %s', self._system,CONFIG['GLOBAL']['DATA_GATEWAY'],_int_dst_id) if CONFIG['REPORTS']['REPORT']: systems[system]._report.send_bridgeEvent('UNIT DATA,START,TX,{},{},{},{},{},{}'.format(system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), 1, _int_dst_id).encode(encoding='utf-8', errors='ignore')) @@ -1910,7 +1910,7 @@ class routerHBP(HBSYSTEM): #Assemble transmit HBP packet header _tmp_data = b''.join([_data[:15], _tmp_bits.to_bytes(1, 'big'), _data[16:20]]) _tmp_data = b''.join([_tmp_data, dmrpkt]) - systems[system].send_system(_tmp_data) + systems[CONFIG['GLOBAL']['DATA_GATEWAY']].send_system(_tmp_data) logger.info('(%s) UNIT Data Bridged to DATA_GATEWAY: %s DST_ID: %s', self._system,CONFIG['GLOBAL']['DATA_GATEWAY'],_int_dst_id) if CONFIG['REPORTS']['REPORT']: systems[system]._report.send_bridgeEvent('UNIT DATA,START,TX,{},{},{},{},{},{}'.format(system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), 1, _int_dst_id).encode(encoding='utf-8', errors='ignore')) From 15b38c0c6a600c2a2559f38b6e329bdbc01ec1ef Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 3 Nov 2021 02:27:50 +0000 Subject: [PATCH 49/49] add bool --- bridge_master.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bridge_master.py b/bridge_master.py index 800da86..8e07bfe 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1433,7 +1433,7 @@ class routerOBP(OPENBRIDGE): if CONFIG['REPORTS']['REPORT']: systems[system]._report.send_bridgeEvent('UNIT DATA,START,TX,{},{},{},{},{},{}'.format(system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), 1, _int_dst_id).encode(encoding='utf-8', errors='ignore')) else: - if not CONFIG['GLOBAL']['DATA_GATEWAY']: + if not bool(CONFIG['GLOBAL']['DATA_GATEWAY']): logger.info('(%s) UNIT Data not Bridged - no DATA_GATEWAY: %s, DST_ID: %s',self._system,_int_dst_id) elif CONFIG['GLOBAL']['DATA_GATEWAY'] not in systems: logger.warning('(%s) UNIT Data not Bridged - DATA_GATEWAY: %s not valid. DST_ID: %s',self._system, CONFIG['GLOBAL']['DATA_GATEWAY'],_int_dst_id) @@ -1915,7 +1915,7 @@ class routerHBP(HBSYSTEM): if CONFIG['REPORTS']['REPORT']: systems[system]._report.send_bridgeEvent('UNIT DATA,START,TX,{},{},{},{},{},{}'.format(system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), 1, _int_dst_id).encode(encoding='utf-8', errors='ignore')) else: - if not CONFIG['GLOBAL']['DATA_GATEWAY']: + if not bool(CONFIG['GLOBAL']['DATA_GATEWAY']): logger.info('(%s) UNIT Data not Bridged - no DATA_GATEWAY: %s, DST_ID: %s',self._system,_int_dst_id) elif CONFIG['GLOBAL']['DATA_GATEWAY'] not in systems: logger.warning('(%s) UNIT Data not Bridged - DATA_GATEWAY: %s not valid. DST_ID: %s',self._system, CONFIG['GLOBAL']['DATA_GATEWAY'],_int_dst_id)