From 48a100f0df2a3609495abc0871da032445b5bb40 Mon Sep 17 00:00:00 2001 From: Cort Buffington Date: Wed, 13 Nov 2013 19:07:20 -0600 Subject: [PATCH] Fixed a few more bugs... AND found some caveats, which will be listed as issues shortly. --- bridge.py | 7 +++++-- dmrlink.py | 16 ++++++++++------ log.py | 5 +++-- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/bridge.py b/bridge.py index 8833a45..c48d6ec 100644 --- a/bridge.py +++ b/bridge.py @@ -10,6 +10,7 @@ from __future__ import print_function from twisted.internet.protocol import DatagramProtocol from twisted.internet import reactor from twisted.internet import task +from binascii import b2a_hex as h import binascii import dmrlink @@ -18,6 +19,7 @@ from dmrlink import IPSC, UnauthIPSC, NETWORK, networks, int_id, send_to_ipsc, d RULES = { 'K0USY': { 'GROUP_VOICE': [ + {'SRC_GROUP': b'\x00\x00\x03', 'DST_NET': 'LAWRENCE', 'DST_GROUP': b'\x00\x00\x03'}, {'SRC_GROUP': b'\x00\x0C\x30', 'DST_NET': 'LAWRENCE', 'DST_GROUP': b'\x00\x0C\x30'}, {'SRC_GROUP': b'\x00\x0C\x30', 'DST_NET': 'TEST', 'DST_GROUP': b'\x00\x00\xD2'} ], @@ -30,6 +32,7 @@ RULES = { }, 'LAWRENCE': { 'GROUP_VOICE': [ + {'SRC_GROUP': b'\x00\x00\x03', 'DST_NET': 'K0USY', 'DST_GROUP': b'\x00\x00\x03'}, {'SRC_GROUP': b'\x00\x0C\x30', 'DST_NET': 'K0USY', 'DST_GROUP': b'\x00\x0C\x30'}, {'SRC_GROUP': b'\x00\x0C\x30', 'DST_NET': 'TEST', 'DST_GROUP': b'\x00\x00\xD2'} ], @@ -61,7 +64,7 @@ class bridgeIPSC(IPSC): self.ACTIVE_CALLS = [] #def datagramReceived(self, data, (host, port)): - # print(binascii.b2a_hex(data)) + # print(h(data)) #************************************************ @@ -112,7 +115,7 @@ class bridgeUnauthIPSC(bridgeIPSC): def hashed_packet(self, _key, _data): return _data - # Remove the hash from a packet and return the payload + # Remove the hash from a packet and return the payload... except don't # def strip_hash(self, _data): return _data diff --git a/dmrlink.py b/dmrlink.py index 9f5df1f..12530ec 100644 --- a/dmrlink.py +++ b/dmrlink.py @@ -195,12 +195,16 @@ 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): - # Send to the Master - networks[_target].transport.write(_packet, (NETWORK[_target]['MASTER']['IP'], NETWORK[_target]['MASTER']['PORT'])) + _network = NETWORK[_target] + _network_instance = networks[_target] + _peers = _network['PEERS'] + + # Send to the Master + _network_instance.transport.write(_packet, (_network['MASTER']['IP'], _network['MASTER']['PORT'])) # Send to each connected Peer - for peer in networks[_target]['PEERS'].keys(): - if peer['STATUS']['CONNECTED'] == True: - networks[_target].transport.write(_packet, (peer['IP'], peer['PORT'])) + for peer in _peers.keys(): + if _peers[peer]['STATUS']['CONNECTED'] == True: + _network_instance.transport.write(_packet, (_peers[peer]['IP'], _peers[peer]['PORT'])) # De-register a peer from an IPSC by removing it's infomation @@ -763,7 +767,7 @@ class UnauthIPSC(IPSC): def hashed_packet(self, _key, _data): return _data - # Remove the hash from a packet and return the payload + # Remove the hash from a packet and return the payload... except don't # def strip_hash(_self, _data): return _data diff --git a/log.py b/log.py index 6141497..1614f4e 100644 --- a/log.py +++ b/log.py @@ -10,6 +10,7 @@ from __future__ import print_function from twisted.internet.protocol import DatagramProtocol from twisted.internet import reactor from twisted.internet import task +from binascii import b2a_hex as h import struct import time @@ -37,7 +38,7 @@ class logIPSC(IPSC): print('({}) Call Control Type 3 Packet Received' .format(_network)) def xcmp_xnl(self, _network, _data): - print('({}) XCMP/XNL Packet Received From: {}' .format(_network, binascii.b2a_hex(_data))) + print('({}) XCMP/XNL Packet Received From: {}' .format(_network, h(_data))) def group_voice(self, _network, _src_sub, _dst_sub, _ts, _end, _peerid, _data): # _log = logger.debug @@ -102,7 +103,7 @@ class logUnauthIPSC(logIPSC): def hashed_packet(self, _key, _data): return _data - # Remove the hash from a packet and return the payload + # Remove the hash from a packet and return the payload... except don't # def strip_hash(self, _data): return _data