Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 02dc63075c | |||
| b587c92431 | |||
| 0b1d190791 | |||
| 844339f27b | |||
| 46b1ad92f7 | |||
| 12eab90fa5 | |||
| 8f5c636888 | |||
| cd823fb07d | |||
| 7340309638 | |||
| 9e7f9961f4 | |||
| d6fafd256a | |||
| 0ee36acc52 | |||
| 313078039e | |||
| 72721d9870 |
+6
-4
@@ -654,7 +654,7 @@ class IPSC(DatagramProtocol):
|
|||||||
self.PEER_ALIVE_REPLY_PKT = (PEER_ALIVE_REPLY + self._local_id + self.TS_FLAGS)
|
self.PEER_ALIVE_REPLY_PKT = (PEER_ALIVE_REPLY + self._local_id + self.TS_FLAGS)
|
||||||
#
|
#
|
||||||
# Master Link Maintenance Packets
|
# Master Link Maintenance Packets
|
||||||
self.MASTER_REG_REPLY_PKT = (MASTER_REG_REPLY + self._local_id + self.TS_FLAGS + str(self._local['NUM_PEERS']) + IPSC_VER)
|
# self.MASTER_REG_REPLY_PKT is not static and must be generated when it is sent
|
||||||
self.MASTER_ALIVE_REPLY_PKT = (MASTER_ALIVE_REPLY + self._local_id + self.TS_FLAGS + IPSC_VER)
|
self.MASTER_ALIVE_REPLY_PKT = (MASTER_ALIVE_REPLY + self._local_id + self.TS_FLAGS + IPSC_VER)
|
||||||
self.PEER_LIST_REPLY_PKT = (PEER_LIST_REPLY + self._local_id)
|
self.PEER_LIST_REPLY_PKT = (PEER_LIST_REPLY + self._local_id)
|
||||||
#
|
#
|
||||||
@@ -684,7 +684,7 @@ class IPSC(DatagramProtocol):
|
|||||||
# CALLBACK FUNCTIONS FOR USER PACKET TYPES
|
# CALLBACK FUNCTIONS FOR USER PACKET TYPES
|
||||||
#************************************************
|
#************************************************
|
||||||
|
|
||||||
def call_mon_origin(self, _network, _data):
|
def call_mon_status(self, _network, _data):
|
||||||
logger.debug('(%s) Repeater Call Monitor Origin Packet Received: %s',_network, h(_data))
|
logger.debug('(%s) Repeater Call Monitor Origin Packet Received: %s',_network, h(_data))
|
||||||
|
|
||||||
def call_mon_rpt(self, _network, _data):
|
def call_mon_rpt(self, _network, _data):
|
||||||
@@ -1005,8 +1005,8 @@ class IPSC(DatagramProtocol):
|
|||||||
return
|
return
|
||||||
|
|
||||||
# ORIGINATED BY PEERS, NOT IPSC MAINTENANCE: Call monitoring is all we've found here so far
|
# ORIGINATED BY PEERS, NOT IPSC MAINTENANCE: Call monitoring is all we've found here so far
|
||||||
elif _packettype == CALL_MON_ORIGIN:
|
elif _packettype == CALL_MON_STATUS:
|
||||||
self.call_mon_origin(self._network, data)
|
self.call_mon_status(self._network, data)
|
||||||
return
|
return
|
||||||
|
|
||||||
elif _packettype == CALL_MON_RPT:
|
elif _packettype == CALL_MON_RPT:
|
||||||
@@ -1143,6 +1143,8 @@ class IPSC(DatagramProtocol):
|
|||||||
_decoded_mode = process_mode_byte(_hex_mode)
|
_decoded_mode = process_mode_byte(_hex_mode)
|
||||||
_decoded_flags = process_flags_bytes(_hex_flags)
|
_decoded_flags = process_flags_bytes(_hex_flags)
|
||||||
|
|
||||||
|
self.MASTER_REG_REPLY_PKT = (MASTER_REG_REPLY + self._local_id + self.TS_FLAGS + hex_str_2(self._local['NUM_PEERS']) + IPSC_VER)
|
||||||
|
|
||||||
master_reg_reply_packet = self.hashed_packet(self._local['AUTH_KEY'], self.MASTER_REG_REPLY_PKT)
|
master_reg_reply_packet = self.hashed_packet(self._local['AUTH_KEY'], self.MASTER_REG_REPLY_PKT)
|
||||||
self.transport.write(master_reg_reply_packet, (host, port))
|
self.transport.write(master_reg_reply_packet, (host, port))
|
||||||
logger.debug('(%s) Master Registration Packet Received from peer %s', self._network, int_id(_peerid))
|
logger.debug('(%s) Master Registration Packet Received from peer %s', self._network, int_id(_peerid))
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
# Known IPSC Message Types
|
# Known IPSC Message Types
|
||||||
CALL_CONFIRMATION = '\x05' # Confirmation FROM the recipient of a confirmed call.
|
CALL_CONFIRMATION = '\x05' # Confirmation FROM the recipient of a confirmed call.
|
||||||
CALL_MON_ORIGIN = '\x61' # |
|
CALL_MON_STATUS = '\x61' # |
|
||||||
CALL_MON_RPT = '\x62' # | Exact meaning unknown
|
CALL_MON_RPT = '\x62' # | Exact meaning unknown
|
||||||
CALL_MON_NACK = '\x63' # |
|
CALL_MON_NACK = '\x63' # |
|
||||||
XCMP_XNL = '\x70' # XCMP/XNL control message
|
XCMP_XNL = '\x70' # XCMP/XNL control message
|
||||||
@@ -44,10 +44,10 @@ IPSC_VER_22 = '\x04'
|
|||||||
LINK_TYPE_IPSC = '\x04'
|
LINK_TYPE_IPSC = '\x04'
|
||||||
|
|
||||||
# IPSC Version and Link Type are Used for a 4-byte version field in registration packets
|
# IPSC Version and Link Type are Used for a 4-byte version field in registration packets
|
||||||
IPSC_VER = LINK_TYPE_IPSC + IPSC_VER_19 + LINK_TYPE_IPSC + IPSC_VER_17
|
IPSC_VER = LINK_TYPE_IPSC + IPSC_VER_17 + LINK_TYPE_IPSC + IPSC_VER_16
|
||||||
|
|
||||||
# Packets that must originate from a peer (or master peer)
|
# Packets that must originate from a peer (or master peer)
|
||||||
ANY_PEER_REQUIRED = [GROUP_VOICE, PVT_VOICE, GROUP_DATA, PVT_DATA, CALL_MON_ORIGIN, CALL_MON_RPT, CALL_MON_NACK, XCMP_XNL, RPT_WAKE_UP, DE_REG_REQ]
|
ANY_PEER_REQUIRED = [GROUP_VOICE, PVT_VOICE, GROUP_DATA, PVT_DATA, CALL_MON_STATUS, CALL_MON_RPT, CALL_MON_NACK, XCMP_XNL, RPT_WAKE_UP, DE_REG_REQ]
|
||||||
|
|
||||||
# Packets that must originate from a non-master peer
|
# Packets that must originate from a non-master peer
|
||||||
PEER_REQUIRED = [PEER_ALIVE_REQ, PEER_ALIVE_REPLY, PEER_REG_REQ, PEER_REG_REPLY]
|
PEER_REQUIRED = [PEER_ALIVE_REQ, PEER_ALIVE_REPLY, PEER_REG_REQ, PEER_REG_REPLY]
|
||||||
@@ -94,11 +94,20 @@ STATUS = {
|
|||||||
'\x01': 'Active',
|
'\x01': 'Active',
|
||||||
'\x02': 'End',
|
'\x02': 'End',
|
||||||
'\x05': 'TS In Use',
|
'\x05': 'TS In Use',
|
||||||
|
'\x08': 'RPT Disabled',
|
||||||
|
'\x09': 'RF Interference',
|
||||||
'\x0A': 'BSID ON',
|
'\x0A': 'BSID ON',
|
||||||
'\x0B': 'Timeout',
|
'\x0B': 'Timeout',
|
||||||
'\x0C': 'TX Interrupt'
|
'\x0C': 'TX Interrupt'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
REPEAT = {
|
||||||
|
'\x01': 'Repeating',
|
||||||
|
'\x02': 'Idle',
|
||||||
|
'\x03': 'TS Disabled',
|
||||||
|
'\x04': 'TS Enabled'
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# Conditions for accepting certain types of messages... the cornerstone of a secure IPSC system :)
|
# Conditions for accepting certain types of messages... the cornerstone of a secure IPSC system :)
|
||||||
'''
|
'''
|
||||||
@@ -113,7 +122,7 @@ REQ_VALID_MASTER = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
REQ_MASTER_CONNECTED = [
|
REQ_MASTER_CONNECTED = [
|
||||||
CALL_MON_ORIGIN,
|
CALL_MON_STATUS,
|
||||||
CALL_MON_RPT,
|
CALL_MON_RPT,
|
||||||
CALL_MON_NACK,
|
CALL_MON_NACK,
|
||||||
XCMP_XNL,
|
XCMP_XNL,
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ from twisted.internet import reactor
|
|||||||
from twisted.internet import task
|
from twisted.internet import task
|
||||||
from binascii import b2a_hex as h
|
from binascii import b2a_hex as h
|
||||||
|
|
||||||
import time
|
import datetime
|
||||||
import binascii
|
import binascii
|
||||||
import dmrlink
|
import dmrlink
|
||||||
from dmrlink import IPSC, NETWORK, networks, get_info, int_id, subscriber_ids, peer_ids, talkgroup_ids, logger
|
from dmrlink import IPSC, NETWORK, networks, get_info, int_id, subscriber_ids, peer_ids, talkgroup_ids, logger
|
||||||
@@ -35,6 +35,10 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
sys.exit('IPSC message types file not found or invalid')
|
sys.exit('IPSC message types file not found or invalid')
|
||||||
|
|
||||||
|
status = True
|
||||||
|
rpt = False
|
||||||
|
nack = False
|
||||||
|
|
||||||
class rcmIPSC(IPSC):
|
class rcmIPSC(IPSC):
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
@@ -44,17 +48,21 @@ class rcmIPSC(IPSC):
|
|||||||
# CALLBACK FUNCTIONS FOR USER PACKET TYPES
|
# CALLBACK FUNCTIONS FOR USER PACKET TYPES
|
||||||
#************************************************
|
#************************************************
|
||||||
#
|
#
|
||||||
def call_mon_origin(self, _network, _data):
|
def call_mon_status(self, _network, _data):
|
||||||
_source = _data[1:5]
|
if not status:
|
||||||
|
return
|
||||||
|
_source = _data[1:5]
|
||||||
_ipsc_src = _data[5:9]
|
_ipsc_src = _data[5:9]
|
||||||
_rf_src = _data[16:19]
|
_seq_num = _data[9:13]
|
||||||
_rf_tgt = _data[19:22]
|
_ts = _data[13]
|
||||||
|
_status = _data[15] # suspect [14:16] but nothing in leading byte?
|
||||||
_ts = _data[13]
|
_rf_src = _data[16:19]
|
||||||
_status = _data[15]
|
_rf_tgt = _data[19:22]
|
||||||
_type = _data[22]
|
_type = _data[22]
|
||||||
_sec = _data[24]
|
_prio = _data[23]
|
||||||
|
_sec = _data[24]
|
||||||
|
|
||||||
|
_source = get_info(int_id(_source), peer_ids)
|
||||||
_ipsc_src = get_info(int_id(_ipsc_src), peer_ids)
|
_ipsc_src = get_info(int_id(_ipsc_src), peer_ids)
|
||||||
_rf_src = get_info(int_id(_rf_src), subscriber_ids)
|
_rf_src = get_info(int_id(_rf_src), subscriber_ids)
|
||||||
|
|
||||||
@@ -63,20 +71,69 @@ class rcmIPSC(IPSC):
|
|||||||
else:
|
else:
|
||||||
_rf_tgt = get_info(int_id(_rf_tgt), subscriber_ids)
|
_rf_tgt = get_info(int_id(_rf_tgt), subscriber_ids)
|
||||||
|
|
||||||
|
print('Call Monitor - Call Status')
|
||||||
|
print('TIME: ', datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
|
||||||
|
print('DATA SOURCE: ', _source)
|
||||||
print('IPSC: ', _network)
|
print('IPSC: ', _network)
|
||||||
print('IPSC Source: ', _ipsc_src)
|
print('IPSC Source: ', _ipsc_src)
|
||||||
print('Timeslot: ', TS[_ts])
|
print('Timeslot: ', TS[_ts])
|
||||||
print('Status: ', STATUS[_status])
|
try:
|
||||||
print('Type: ', TYPE[_type])
|
print('Status: ', STATUS[_status])
|
||||||
|
except KeyError:
|
||||||
|
print('Status (unknown): ', h(status))
|
||||||
|
try:
|
||||||
|
print('Type: ', TYPE[_type])
|
||||||
|
except KeyError:
|
||||||
|
print('Type (unknown): ', h(_type))
|
||||||
print('Source Sub: ', _rf_src)
|
print('Source Sub: ', _rf_src)
|
||||||
print('Target Sub: ', _rf_tgt)
|
print('Target Sub: ', _rf_tgt)
|
||||||
print()
|
print()
|
||||||
|
|
||||||
|
def call_mon_rpt(self, _network, _data):
|
||||||
|
if not rpt:
|
||||||
|
return
|
||||||
|
_source = _data[1:5]
|
||||||
|
_ts1_state = _data[5]
|
||||||
|
_ts2_state = _data[6]
|
||||||
|
|
||||||
|
_source = get_info(int_id(_source), peer_ids)
|
||||||
|
|
||||||
|
print('Call Monitor - Repeater State')
|
||||||
|
print('TIME: ', datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
|
||||||
|
print('DATA SOURCE: ', _source)
|
||||||
|
|
||||||
|
try:
|
||||||
|
print('TS1 State: ', REPEAT[_ts1_state])
|
||||||
|
except KeyError:
|
||||||
|
print('TS1 State (unknown): ', h(_ts1_state))
|
||||||
|
try:
|
||||||
|
print('TS2 State: ', REPEAT[_ts2_state])
|
||||||
|
except KeyError:
|
||||||
|
print('TS2 State (unknown): ', h(_ts2_state))
|
||||||
|
print()
|
||||||
|
|
||||||
|
def call_mon_nack(self, _network, _data):
|
||||||
|
if not nack:
|
||||||
|
return
|
||||||
|
_source = _data[1:5]
|
||||||
|
_nack = _data[5]
|
||||||
|
|
||||||
|
_source = get_info(int_id(_source), peer_ids)
|
||||||
|
|
||||||
|
print('Call Monitor - Transmission NACK')
|
||||||
|
print('TIME: ', datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
|
||||||
|
print('DATA SOURCE: ', _source)
|
||||||
|
try:
|
||||||
|
print('NACK Cause: ', NACK[_nack])
|
||||||
|
except KeyError:
|
||||||
|
print('NACK Cause (unknown): ', h(_nack))
|
||||||
|
print()
|
||||||
|
|
||||||
def repeater_wake_up(self, _network, _data):
|
def repeater_wake_up(self, _network, _data):
|
||||||
_source = _data[1:5]
|
_source = _data[1:5]
|
||||||
_source_dec = int_id(_source)
|
_source_dec = int_id(_source)
|
||||||
_source_name = get_info(_source_dec, peer_ids)
|
_source_name = get_info(_source_dec, peer_ids)
|
||||||
print('({}) Repeater Wake-Up Packet Received: {} ({})' .format(_network, _source_name, _source_dec))
|
#print('({}) Repeater Wake-Up Packet Received: {} ({})' .format(_network, _source_name, _source_dec))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
Reference in New Issue
Block a user