From 10f73545ad6d1e24dde94465fd28464206fb2361 Mon Sep 17 00:00:00 2001 From: Cort Buffington Date: Tue, 5 Nov 2013 19:30:31 -0600 Subject: [PATCH] Bridging Now Works --- bridge.py | 8 ++++---- dmrlink.py | 5 +---- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/bridge.py b/bridge.py index 74ad183..adb1b65 100644 --- a/bridge.py +++ b/bridge.py @@ -13,7 +13,7 @@ from twisted.internet import task import binascii import dmrlink -from dmrlink import IPSC, UnauthIPSC, NETWORK, networks, int_id, send_to_ipsc +from dmrlink import IPSC, UnauthIPSC, NETWORK, networks, int_id, send_to_ipsc, dmr_nat RULES = { 'K0USY': { @@ -56,12 +56,12 @@ class bridgeIPSC(IPSC): _data = _data.replace(_peerid, NETWORK[_target]['LOCAL']['RADIO_ID']) # Re-Write the destinaion Group ID _data = _data.replace(_dst_sub, source['DST_GROUP']) + _data = dmr_nat(_data, '\x00\x0C\x30') # Calculate and append the authentication hash for the target network... if necessary - if NETWORK[_target]['LOCAL']['AUTH_KEY'] == True: - _data = hashed_packet(NETWORK[_target]['LOCAL']['AUTH_KEY'], _data) + if NETWORK[_target]['LOCAL']['AUTH_ENABLED'] == True: + _data = self.hashed_packet(NETWORK[_target]['LOCAL']['AUTH_KEY'], _data) # Send the packet to all peers in the target IPSC send_to_ipsc(_target, _data) - print(_target, binascii.b2a_hex(_data)) def private_voice(self, _network, _src_sub, _dst_sub, _ts, _end, _peerid, _data): pass diff --git a/dmrlink.py b/dmrlink.py index 06b675e..9b574ea 100644 --- a/dmrlink.py +++ b/dmrlink.py @@ -228,11 +228,8 @@ def valid_master(_network, _peerid): # Accept a complete packet, ready to be sent, and send it to all active peers + master in an IPSC # def send_to_ipsc(_target, _packet): -# _log = logger.debug - # Send to the Master -# _log('Sending %s to:', binascii.b2a_hex(_packet) + # Send to the Master networks[_target].transport.write(_packet, (NETWORK[_target]['MASTER']['IP'], NETWORK[_target]['MASTER']['PORT'])) -# _log(' Master: %s', binascii.b2a_hex(NETWORK[_target]['MASTER']['RADIO_ID'])) # Send to each connected Peer for peer in NETWORK[_target]['PEERS']: if peer['STATUS']['CONNECTED'] == True: