Compare commits
107 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 06514567ef | |||
| 3ee762475e | |||
| c8e1d88ecc | |||
| 89040e7c14 | |||
| d68241918b | |||
| ccfd862a0a | |||
| 24dca2e6ad | |||
| 8c1e9e5185 | |||
| a2c0bb54c6 | |||
| 03f9c81d3a | |||
| fdbfbf2362 | |||
| b48e522f85 | |||
| f00d29e8a0 | |||
| 08f6669bd3 | |||
| 8497bb1462 | |||
| ac87c44917 | |||
| 8f0a3d02a5 | |||
| d31c6f7fe7 | |||
| e1174e6aba | |||
| e8f838b3d6 | |||
| 7f7f8bdf74 | |||
| 21c6bf9281 | |||
| 4e3a13daaf | |||
| 9e2876dfae | |||
| c246f3e5db | |||
| 21f9c680be | |||
| 50387c2133 | |||
| 41f04dc28b | |||
| d44a181c06 | |||
| 383ba7e0ae | |||
| 7fc4ce0495 | |||
| 4aa5210f5b | |||
| 3d9aa41fcb | |||
| 2fa615dd37 | |||
| 35ba251e71 | |||
| 30ed93aa30 | |||
| 508b9c7197 | |||
| ed2a1ca549 | |||
| e6949e65ec | |||
| 9ac426aa2d | |||
| 94afc15d7a | |||
| b5e77e64b1 | |||
| 8c2b35ece0 | |||
| bb4356e027 | |||
| 63604a5b38 | |||
| 4643ea47b7 | |||
| 877e1c6c65 | |||
| 364ead81ec | |||
| 717e802b9b | |||
| 857c4d09d0 | |||
| 2e09350ad2 | |||
| 836c655739 | |||
| 281860db0b | |||
| 0f38427f2f | |||
| 112143ec05 | |||
| 887657aa16 | |||
| 7bf0a77e16 | |||
| 28f006b493 | |||
| 99c76b44de | |||
| b9dc33dae5 | |||
| 58c84cf43a | |||
| ef4514b8e0 | |||
| 96514de5cc | |||
| cdae79e0ee | |||
| 429287452a | |||
| 3cb00bc5bd | |||
| d68d3582da | |||
| 3d5437e9a0 | |||
| e00a98f7d2 | |||
| 053914a68b | |||
| 76143f718c | |||
| 83d120c101 | |||
| 0a2edc09a5 | |||
| ab1a536147 | |||
| e6d25534b5 | |||
| 9219b4b2ee | |||
| da607cd542 | |||
| 83299312cc | |||
| 8bbd9ee850 | |||
| 999bbbf5f7 | |||
| 76bb7f1140 | |||
| ece48f3a50 | |||
| 1bc57b5ea4 | |||
| 9e2d2315da | |||
| 3893e12fca | |||
| 8a45e927ae | |||
| f98c12096c | |||
| e5eafeec3e | |||
| d8bfdc7068 | |||
| d689a876aa | |||
| 31c23ae7a0 | |||
| 3878c82513 | |||
| 96b029a927 | |||
| 2ef0dfcd74 | |||
| 1b265d8368 | |||
| 84800d690a | |||
| 9ba975bfff | |||
| e570adbef0 | |||
| 99d0b49559 | |||
| d3a5ee2221 | |||
| 557b21c022 | |||
| 553bcba3a2 | |||
| 101a6e4a11 | |||
| 55a546a239 | |||
| 64a685cd80 | |||
| aefedca6ee | |||
| be13083729 |
Regular → Executable
-32
@@ -1,32 +0,0 @@
|
||||
FROM python:3.7-slim-stretch
|
||||
|
||||
RUN apt update && \
|
||||
apt install -y git && \
|
||||
cd /usr/src/ && \
|
||||
git clone https://github.com/n0mjs710/dmr_utils3 && \
|
||||
cd /usr/src/dmr_utils3 && \
|
||||
./install.sh && \
|
||||
rm -rf /var/lib/apt/lists/* && \
|
||||
cd /opt && \
|
||||
rm -rf /usr/src/dmr_utils3 && \
|
||||
git clone https://github.com/n0mjs710/hblink3
|
||||
|
||||
RUN cd /opt/hblink3/ && \
|
||||
sed -i s/.*python.*//g requirements.txt && \
|
||||
pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
|
||||
ADD entrypoint /entrypoint
|
||||
|
||||
RUN adduser -u 54000 radio && \
|
||||
adduser radio radio && \
|
||||
chmod 755 /entrypoint && \
|
||||
chown radio:radio /entrypoint && \
|
||||
chown radio /opt/hblink3
|
||||
|
||||
RUN chmod 755 /entrypoint
|
||||
|
||||
USER radio
|
||||
EXPOSE 54000
|
||||
|
||||
ENTRYPOINT [ "/entrypoint" ]
|
||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 42 KiB |
+245
@@ -0,0 +1,245 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
inkscape:version="1.0beta1 (d565813, 2019-09-28)"
|
||||
sodipodi:docname="HBlink.svg"
|
||||
id="svg877"
|
||||
height="411.17413"
|
||||
width="1042.9242"
|
||||
viewBox="49.656 217.125 1042.9242 411.17414"
|
||||
version="1.1">
|
||||
<sodipodi:namedview
|
||||
inkscape:current-layer="svg877"
|
||||
inkscape:window-maximized="0"
|
||||
inkscape:window-y="23"
|
||||
inkscape:window-x="583"
|
||||
inkscape:cy="48.366866"
|
||||
inkscape:cx="574.39926"
|
||||
inkscape:zoom="1"
|
||||
fit-margin-left="5"
|
||||
fit-margin-bottom="5"
|
||||
fit-margin-right="5"
|
||||
fit-margin-top="5"
|
||||
units="px"
|
||||
inkscape:pagecheckerboard="true"
|
||||
showgrid="false"
|
||||
id="namedview879"
|
||||
inkscape:window-height="1348"
|
||||
inkscape:window-width="1943"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:pageopacity="0"
|
||||
guidetolerance="10"
|
||||
gridtolerance="10"
|
||||
objecttolerance="10"
|
||||
borderopacity="1"
|
||||
inkscape:document-rotation="0"
|
||||
bordercolor="#666666"
|
||||
pagecolor="#ffffff" />
|
||||
<defs
|
||||
id="defs837">
|
||||
<font-face
|
||||
overline-thickness="0"
|
||||
overline-position="0"
|
||||
strikethrough-thickness="0"
|
||||
strikethrough-position="0"
|
||||
v-hanging="0"
|
||||
v-mathematical="0"
|
||||
v-alphabetic="0"
|
||||
v-ideographic="0"
|
||||
hanging="0"
|
||||
mathematical="0"
|
||||
alphabetic="0"
|
||||
ideographic="0"
|
||||
accent-height="0"
|
||||
stemh="0"
|
||||
stemv="0"
|
||||
id="font-face833"
|
||||
font-weight="400"
|
||||
descent="-255.00488"
|
||||
ascent="945.0073"
|
||||
cap-height="669"
|
||||
x-height="669"
|
||||
slope="0"
|
||||
underline-thickness="20"
|
||||
underline-position="-133"
|
||||
units-per-em="1000"
|
||||
panose-1="2 0 6 0 0 0 0 0 0 0"
|
||||
font-size="96"
|
||||
font-family="Ethnocentric">
|
||||
<font-face-src>
|
||||
<font-face-name
|
||||
name="EthnocentricRg-Regular" />
|
||||
</font-face-src>
|
||||
</font-face>
|
||||
<font-face
|
||||
overline-thickness="0"
|
||||
overline-position="0"
|
||||
strikethrough-thickness="0"
|
||||
strikethrough-position="0"
|
||||
v-hanging="0"
|
||||
v-mathematical="0"
|
||||
v-alphabetic="0"
|
||||
v-ideographic="0"
|
||||
hanging="0"
|
||||
mathematical="0"
|
||||
alphabetic="0"
|
||||
ideographic="0"
|
||||
accent-height="0"
|
||||
stemh="0"
|
||||
stemv="0"
|
||||
id="font-face835"
|
||||
font-weight="400"
|
||||
descent="-255.00488"
|
||||
ascent="945.0073"
|
||||
cap-height="669"
|
||||
x-height="669"
|
||||
slope="0"
|
||||
underline-thickness="20"
|
||||
underline-position="-133"
|
||||
units-per-em="1000"
|
||||
panose-1="2 0 6 0 0 0 0 0 0 0"
|
||||
font-size="48"
|
||||
font-family="Ethnocentric">
|
||||
<font-face-src>
|
||||
<font-face-name
|
||||
name="EthnocentricRg-Regular" />
|
||||
</font-face-src>
|
||||
</font-face>
|
||||
</defs>
|
||||
<metadata
|
||||
id="metadata839"> Produced by OmniGraffle 7.12.1
|
||||
<dc:date>2018-03-14 13:37:44 +0000</dc:date>
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
transform="matrix(3.5262508,0,0,3.5262508,-159.40153,-655.56235)"
|
||||
stroke-opacity="1"
|
||||
stroke="none"
|
||||
stroke-dasharray="none"
|
||||
fill-opacity="1"
|
||||
fill="none"
|
||||
id="Canvas_2">
|
||||
<title
|
||||
id="title841">Canvas 2</title>
|
||||
<g
|
||||
id="Canvas_2: Layer 1">
|
||||
<title
|
||||
id="title843">Layer 1</title>
|
||||
<g
|
||||
id="Group_40">
|
||||
<g
|
||||
id="Graphic_39">
|
||||
<title
|
||||
id="title845">path6007</title>
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path847"
|
||||
stroke-width="3"
|
||||
stroke-linejoin="round"
|
||||
stroke-linecap="round"
|
||||
stroke="#009051"
|
||||
d="m 72.52062,328.5 h 225.5218 c 6.17355,0 11.1782,5.00465 11.1782,11.1782 v 0 c 0,6.17355 -5.00465,11.1782 -11.1782,11.1782 H 72.52062 c -6.17355,0 -11.1782,-5.00465 -11.1782,-11.1782 v 0 c 0,-6.17355 5.00465,-11.1782 11.1782,-11.1782 z" />
|
||||
</g>
|
||||
<g
|
||||
id="Graphic_38">
|
||||
<g
|
||||
style="fill:#009051"
|
||||
id="text852"
|
||||
transform="translate(54.656,222.125)"
|
||||
aria-label="HB">
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path881"
|
||||
style="font-weight:400;font-size:96px;font-family:Ethnocentric;fill:#009051"
|
||||
d="M 84,91 H 64.224 V 66.232 H 26.016 V 91 H 6.048 V 26.776 H 26.016 V 49.528 H 64.224 V 26.776 H 84 Z" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path883"
|
||||
style="font-weight:400;font-size:96px;font-family:Ethnocentric;fill:#009051"
|
||||
d="m 168.7155,57.976 q 4.224,1.248 7.104,4.896 2.976,3.648 2.976,9.408 0,4.032 -1.248,7.488 -1.248,3.36 -4.224,5.856 -2.976,2.496 -8.064,3.936 -4.992,1.44 -12.576,1.44 H 96.2355 V 51.928 h 56.832 q 2.208,0 3.84,-0.864 1.728,-0.96 1.728,-3.456 0,-2.4 -1.728,-3.264 -1.728,-0.864 -3.84,-0.864 h -56.832 l 13.44,-16.704 h 42.528 q 5.76,0 10.368,1.152 4.704,1.056 7.968,3.36 3.36,2.208 5.088,5.568 1.824,3.264 1.824,7.68 0,2.88 -0.768,5.088 -0.768,2.208 -2.016,3.936 -1.152,1.632 -2.784,2.784 -1.536,1.056 -3.168,1.632 z m -52.512,7.68 v 8.832 h 36.576 q 3.264,0 4.704,-1.152 1.44,-1.152 1.44,-3.36 0,-2.112 -1.44,-3.168 -1.44,-1.152 -4.704,-1.152 z" />
|
||||
</g>
|
||||
</g>
|
||||
<g
|
||||
id="Graphic_37">
|
||||
<g
|
||||
style="fill:#ff9300"
|
||||
id="text857"
|
||||
transform="translate(209.109,275)"
|
||||
aria-label="link">
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path886"
|
||||
style="font-weight:400;font-size:48px;font-family:Ethnocentric;fill:#ff9300"
|
||||
d="M 3.024,45 Z M 37.824,36.744 31.392,45 H 3.024 V 12.888 h 9.936 v 23.856 z" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path888"
|
||||
style="font-weight:400;font-size:48px;font-family:Ethnocentric;fill:#ff9300"
|
||||
d="m 41.32425,45 z m 9.936,0 h -9.936 V 12.888 h 9.936 z" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path890"
|
||||
style="font-weight:400;font-size:48px;font-family:Ethnocentric;fill:#ff9300"
|
||||
d="m 57.34875,45 z m 32.688,0.528 q -0.96,0 -1.92,-0.336 -0.912,-0.288 -2.064,-1.392 l -19.68,-17.664 V 45 h -9.024 V 18.36 q 0,-1.584 0.432,-2.736 0.48,-1.152 1.2,-1.872 0.768,-0.72 1.728,-1.056 1.008,-0.336 2.064,-0.336 0.912,0 1.824,0.336 0.96,0.288 2.16,1.392 l 19.68,17.664 V 12.888 h 9.072 V 39.48 q 0,1.584 -0.48,2.736 -0.432,1.152 -1.2,1.92 -0.72,0.72 -1.728,1.056 -1.008,0.336 -2.064,0.336 z" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path892"
|
||||
style="font-weight:400;font-size:48px;font-family:Ethnocentric;fill:#ff9300"
|
||||
d="m 101.36775,45 z m 40.512,0 h -15.024 l -9.696,-8.448 q -2.496,-2.16 -3.84,-3.36 -1.296,-1.2 -2.112,-2.016 0.048,1.104 0.096,2.304 0.048,1.152 0.048,2.304 V 45 h -9.984 V 12.888 h 9.984 v 7.44 q 0,1.488 -0.048,2.928 -0.048,1.44 -0.144,2.688 0.96,-0.864 2.304,-2.112 1.392,-1.296 3.6,-3.12 l 9.264,-7.824 h 14.4 l -12.288,9.216 q -1.584,1.2 -2.832,2.112 -1.2,0.912 -2.16,1.584 -0.96,0.672 -1.776,1.2 -0.768,0.528 -1.536,1.008 1.392,0.96 3.36,2.4 1.968,1.44 5.088,3.984 z" />
|
||||
</g>
|
||||
</g>
|
||||
<g
|
||||
id="Graphic_36">
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
d="m 302.0625,336.9375 h 14.5771 v 6.1875 h -14.5771 z"
|
||||
style="fill:#ffffff"
|
||||
id="rect860" />
|
||||
</g>
|
||||
<g
|
||||
id="Graphic_35">
|
||||
<title
|
||||
id="title863">path6381</title>
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path865"
|
||||
stroke-width="3"
|
||||
stroke-linejoin="round"
|
||||
stroke-linecap="round"
|
||||
stroke="#ff9300"
|
||||
d="M 116.9282,340.3125 H 342.45 c 6.17355,0 11.1782,5.00465 11.1782,11.1782 v 0 c 0,6.17355 -5.00465,11.1782 -11.1782,11.1782 H 116.9282 c -6.17355,0 -11.1782,-5.00465 -11.1782,-11.1782 v 0 c 0,-6.17355 5.00465,-11.1782 11.1782,-11.1782 z" />
|
||||
</g>
|
||||
<g
|
||||
id="Graphic_34">
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
d="m 99,347.625 h 14.5771 v 6.1875 H 99 Z"
|
||||
style="fill:#ffffff"
|
||||
id="rect868" />
|
||||
</g>
|
||||
<g
|
||||
id="Line_33">
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
d="M 93.9375,350.85641 H 120.375"
|
||||
style="stroke:#009051;stroke-width:3;stroke-linecap:round;stroke-linejoin:round"
|
||||
id="line871" />
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 9.1 KiB |
@@ -5,6 +5,8 @@ Please join the DVSwitch group at groups.io for online forum support, discussion
|
||||
|
||||
DVSwitch@groups.io
|
||||
|
||||
A voluntary registrty for HBlink systems with public access has been created at http://hblink-register.com.es Please consider listing your system if you allow open access.
|
||||
|
||||
---
|
||||
|
||||
## PROJECT: Open Source HomeBrew Repeater Proctol Client/Master. ##
|
||||
@@ -13,7 +15,7 @@ DVSwitch@groups.io
|
||||
|
||||
**PURPOSE:** Thanks to the work of Jonathan Naylor, G4KLX; Hans Barthen, DL5DI; Torsten Shultze, DG1HT we have an open protocol for internetworking DMR repeaters. Unfortunately, there's no generic client and/or master stacks. This project is to build an open-source, python-based implementation. You are free to use this software however you want, however we ask that you provide attribution in some public venue (such as project, club, organization web site). This helps us see where the software is in use and track how it is used.
|
||||
|
||||
For those who will ask: This is a piece of software that implements an open-source, amateur radio networking protocol. It is not a network. It is not indended to be a network. It is not intended to replace or circumvent a network. People do those things, code doesn't.
|
||||
For those who will ask: This is a piece of software that implements an open-source, amateur radio networking protocol. It is not a network. It is not intended to be a network. It is not intended to replace or circumvent a network. People do those things, code doesn't.
|
||||
|
||||
**PROPERTY:**
|
||||
This work represents the author's interpretation of the HomeBrew Repeater Protocol, based on the 2015-07-26 documents from DMRplus, "IPSC Protocol Specs for homebrew DMR repeater" as written by Jonathan Naylor, G4KLX; Hans Barthen, DL5DI; Torsten Shultze, DG1HT, also licenced under Creative Commons BY-NC-SA license.
|
||||
@@ -54,7 +56,7 @@ chown 65000 /var/log/hblink.log
|
||||
|
||||
***0x49 DE N0MJS***
|
||||
|
||||
Copyright (C) 2016-2019 Cortney T. Buffington, N0MJS n0mjs@me.com
|
||||
Copyright (C) 2016-2020 Cortney T. Buffington, N0MJS n0mjs@me.com
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
|
||||
|
||||
|
||||
-150
@@ -1,150 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
###############################################################################
|
||||
# Copyright (C) 2016-2019 Cortney T. Buffington, N0MJS <n0mjs@me.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
###############################################################################
|
||||
|
||||
# Python modules we need
|
||||
import sys
|
||||
from bitarray import bitarray
|
||||
from time import time
|
||||
from importlib import import_module
|
||||
|
||||
# Twisted is pretty important, so I keep it separate
|
||||
from twisted.internet.protocol import Factory, Protocol
|
||||
from twisted.protocols.basic import NetstringReceiver
|
||||
from twisted.internet import reactor, task
|
||||
|
||||
# Things we import from the main hblink module
|
||||
from hblink import HBSYSTEM, OPENBRIDGE, systems, hblink_handler, reportFactory, REPORT_OPCODES, mk_aliases
|
||||
from dmr_utils3.utils import bytes_3, int_id, get_alias
|
||||
from dmr_utils3 import decode, bptc, const
|
||||
import config
|
||||
import log
|
||||
from const import *
|
||||
|
||||
# Stuff for socket reporting
|
||||
import pickle
|
||||
# REMOVE LATER from datetime import datetime
|
||||
# The module needs logging, but handlers, etc. are controlled by the parent
|
||||
import logging
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# Does anybody read this stuff? There's a PEP somewhere that says I should do this.
|
||||
__author__ = 'Cortney T. Buffington, N0MJS'
|
||||
__copyright__ = 'Copyright (c) 2016-2018 Cortney T. Buffington, N0MJS and the K0USY Group'
|
||||
__credits__ = 'Colin Durbridge, G4EML, Steve Zingman, N4IRS; Mike Zingman, N4IRR; Jonathan Naylor, G4KLX; Hans Barthen, DL5DI; Torsten Shultze, DG1HT'
|
||||
__license__ = 'GNU GPLv3'
|
||||
__maintainer__ = 'Cort Buffington, N0MJS'
|
||||
__email__ = 'n0mjs@me.com'
|
||||
|
||||
# Module gobal varaibles
|
||||
|
||||
|
||||
class OBP(OPENBRIDGE):
|
||||
|
||||
def __init__(self, _name, _config, _report):
|
||||
OPENBRIDGE.__init__(self, _name, _config, _report)
|
||||
|
||||
|
||||
def dmrd_received(self, _peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data):
|
||||
pass
|
||||
|
||||
|
||||
class HBP(HBSYSTEM):
|
||||
|
||||
def __init__(self, _name, _config, _report):
|
||||
HBSYSTEM.__init__(self, _name, _config, _report)
|
||||
|
||||
def dmrd_received(self, _peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data):
|
||||
pass
|
||||
|
||||
|
||||
|
||||
#************************************************
|
||||
# MAIN PROGRAM LOOP STARTS HERE
|
||||
#************************************************
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
import argparse
|
||||
import sys
|
||||
import os
|
||||
import signal
|
||||
|
||||
# Change the current directory to the location of the application
|
||||
os.chdir(os.path.dirname(os.path.realpath(sys.argv[0])))
|
||||
|
||||
# CLI argument parser - handles picking up the config file from the command line, and sending a "help" message
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('-c', '--config', action='store', dest='CONFIG_FILE', help='/full/path/to/config.file (usually hblink.cfg)')
|
||||
parser.add_argument('-l', '--logging', action='store', dest='LOG_LEVEL', help='Override config file logging level.')
|
||||
cli_args = parser.parse_args()
|
||||
|
||||
# Ensure we have a path for the config file, if one wasn't specified, then use the default (top of file)
|
||||
if not cli_args.CONFIG_FILE:
|
||||
cli_args.CONFIG_FILE = os.path.dirname(os.path.abspath(__file__))+'/hblink.cfg'
|
||||
|
||||
# Call the external routine to build the configuration dictionary
|
||||
CONFIG = config.build_config(cli_args.CONFIG_FILE)
|
||||
|
||||
# Start the system logger
|
||||
if cli_args.LOG_LEVEL:
|
||||
CONFIG['LOGGER']['LOG_LEVEL'] = cli_args.LOG_LEVEL
|
||||
logger = log.config_logging(CONFIG['LOGGER'])
|
||||
logger.info('\n\nCopyright (c) 2013, 2014, 2015, 2016, 2018\n\tThe Regents of the K0USY Group. All rights reserved.\n')
|
||||
logger.debug('(GLOBAL) Logging system started, anything from here on gets logged')
|
||||
|
||||
# Set up the signal handler
|
||||
def sig_handler(_signal, _frame):
|
||||
logger.info('(GLOBAL) SHUTDOWN: CONFBRIDGE IS TERMINATING WITH SIGNAL %s', str(_signal))
|
||||
hblink_handler(_signal, _frame)
|
||||
logger.info('(GLOBAL) SHUTDOWN: ALL SYSTEM HANDLERS EXECUTED - STOPPING REACTOR')
|
||||
reactor.stop()
|
||||
|
||||
# Set signal handers so that we can gracefully exit if need be
|
||||
for sig in [signal.SIGINT, signal.SIGTERM]:
|
||||
signal.signal(sig, sig_handler)
|
||||
|
||||
# Create the name-number mapping dictionaries
|
||||
peer_ids, subscriber_ids, talkgroup_ids = mk_aliases(CONFIG)
|
||||
|
||||
# INITIALIZE THE REPORTING LOOP
|
||||
if CONFIG['REPORTS']['REPORT']:
|
||||
report_server = config_reports(CONFIG, bridgeReportFactory)
|
||||
else:
|
||||
report_server = None
|
||||
logger.info('(REPORT) TCP Socket reporting not configured')
|
||||
|
||||
# HBlink instance creation
|
||||
logger.info('(GLOBAL) HBlink \'bridge.py\' -- SYSTEM STARTING...')
|
||||
for system in CONFIG['SYSTEMS']:
|
||||
if CONFIG['SYSTEMS'][system]['ENABLED']:
|
||||
if CONFIG['SYSTEMS'][system]['MODE'] == 'OPENBRIDGE':
|
||||
systems[system] = OBP(system, CONFIG, report_server)
|
||||
else:
|
||||
systems[system] = HBP(system, CONFIG, report_server)
|
||||
reactor.listenUDP(CONFIG['SYSTEMS'][system]['PORT'], systems[system], interface=CONFIG['SYSTEMS'][system]['IP'])
|
||||
logger.debug('(GLOBAL) %s instance created: %s, %s', CONFIG['SYSTEMS'][system]['MODE'], system, systems[system])
|
||||
|
||||
def loopingErrHandle(failure):
|
||||
logger.error('(GLOBAL) STOPPING REACTOR TO AVOID MEMORY LEAK: Unhandled error in timed loop.\n %s', failure)
|
||||
reactor.stop()
|
||||
|
||||
|
||||
reactor.run()
|
||||
Executable
+295
@@ -0,0 +1,295 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
###############################################################################
|
||||
# Copyright (C) 2016-2019 Cortney T. Buffington, N0MJS <n0mjs@me.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
###############################################################################
|
||||
|
||||
'''
|
||||
This is a very simple call/packet router for Homebrew Repeater Protocol. It
|
||||
will forward traffic from any system to all other systems configured in the
|
||||
hblink.py configuration file. It does not check for call contentions or
|
||||
filter TS/TGID combinations. It should really only be used as a proxy to
|
||||
hide multiple Homebrew repater protocol systems behind what appears as a single
|
||||
repeater, hotspot, etc.
|
||||
|
||||
As is, this program only works with group voice packets. It could work for all
|
||||
of them by removing a few things.
|
||||
|
||||
IT ONLY WORKS FOR HBP SYSTEMS!!! Using it with OpenBridge or XLX wouldn't make
|
||||
a lot of sense, and has the potential to do bad things.
|
||||
'''
|
||||
|
||||
# Python modules we need
|
||||
import sys
|
||||
from bitarray import bitarray
|
||||
from time import time
|
||||
from importlib import import_module
|
||||
from types import ModuleType
|
||||
|
||||
# Twisted is pretty important, so I keep it separate
|
||||
from twisted.internet.protocol import Factory, Protocol
|
||||
from twisted.protocols.basic import NetstringReceiver
|
||||
from twisted.internet import reactor, task
|
||||
|
||||
# Things we import from the main hblink module
|
||||
from hblink import HBSYSTEM, OPENBRIDGE, systems, hblink_handler, reportFactory, REPORT_OPCODES, config_reports, mk_aliases, acl_check
|
||||
from dmr_utils3.utils import bytes_3, int_id, get_alias
|
||||
from dmr_utils3 import decode, bptc, const
|
||||
import config
|
||||
import log
|
||||
import const
|
||||
|
||||
# The module needs logging logging, but handlers, etc. are controlled by the parent
|
||||
import logging
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# Does anybody read this stuff? There's a PEP somewhere that says I should do this.
|
||||
__author__ = 'Cortney T. Buffington, N0MJS'
|
||||
__copyright__ = 'Copyright (c) 2016-2018 Cortney T. Buffington, N0MJS and the K0USY Group'
|
||||
__credits__ = 'Colin Durbridge, G4EML, Steve Zingman, N4IRS; Mike Zingman, N4IRR; Jonathan Naylor, G4KLX; Hans Barthen, DL5DI; Torsten Shultze, DG1HT'
|
||||
__license__ = 'GNU GPLv3'
|
||||
__maintainer__ = 'Cort Buffington, N0MJS'
|
||||
__email__ = 'n0mjs@me.com'
|
||||
__status__ = 'pre-alpha'
|
||||
|
||||
# Module gobal varaibles
|
||||
|
||||
|
||||
class bridgeallSYSTEM(HBSYSTEM):
|
||||
|
||||
def __init__(self, _name, _config, _report):
|
||||
HBSYSTEM.__init__(self, _name, _config, _report)
|
||||
self._laststrid = ''
|
||||
|
||||
# Status information for the system, TS1 & TS2
|
||||
# 1 & 2 are "timeslot"
|
||||
self.STATUS = {
|
||||
1: {
|
||||
'RX_START': time(),
|
||||
'RX_LOSS': 0,
|
||||
'RX_SEQ': 0,
|
||||
'RX_RFS': b'\x00',
|
||||
'TX_RFS': b'\x00',
|
||||
'RX_STREAM_ID': b'\x00',
|
||||
'TX_STREAM_ID': b'\x00',
|
||||
'RX_TGID': b'\x00\x00\x00',
|
||||
'TX_TGID': b'\x00\x00\x00',
|
||||
'RX_TIME': time(),
|
||||
'TX_TIME': time(),
|
||||
'RX_TYPE': const.HBPF_SLT_VTERM,
|
||||
},
|
||||
2: {
|
||||
'RX_START': time(),
|
||||
'RX:LOSS': 0,
|
||||
'RX_SEQ': 0,
|
||||
'RX_RFS': b'\x00',
|
||||
'TX_RFS': b'\x00',
|
||||
'RX_STREAM_ID': b'\x00',
|
||||
'TX_STREAM_ID': b'\x00',
|
||||
'RX_TGID': b'\x00\x00\x00',
|
||||
'TX_TGID': b'\x00\x00\x00',
|
||||
'RX_TIME': time(),
|
||||
'TX_TIME': time(),
|
||||
'RX_TYPE': const.HBPF_SLT_VTERM,
|
||||
}
|
||||
}
|
||||
|
||||
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]
|
||||
_bits = _data[15]
|
||||
|
||||
if _call_type == 'group':
|
||||
|
||||
# Is this is a new call stream?
|
||||
new_stream = (_stream_id != self.STATUS[_slot]['RX_STREAM_ID'])
|
||||
|
||||
if new_stream:
|
||||
self.STATUS[_slot]['RX_START'] = pkt_time
|
||||
self.STATUS[_slot]['RX_LOSS'] = 0
|
||||
self.STATUS[_slot]['RX_SEQ'] = _seq
|
||||
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)
|
||||
else:
|
||||
# This could be much better, it will have errors during roll-over
|
||||
if _seq > (self.STATUS[_slot]['RX_SEQ'] + 1):
|
||||
#print(_seq, self.STATUS[_slot]['RX_SEQ'])
|
||||
self.STATUS[_slot]['RX_LOSS'] += _seq - (self.STATUS[_slot]['RX_SEQ'] + 1)
|
||||
|
||||
# Final actions - Is this a voice terminator?
|
||||
if (_frame_type == const.HBPF_DATA_SYNC) and (_dtype_vseq == const.HBPF_SLT_VTERM) and (self.STATUS[_slot]['RX_TYPE'] != const.HBPF_SLT_VTERM):
|
||||
call_duration = pkt_time - self.STATUS[_slot]['RX_START']
|
||||
logger.info('(%s) *CALL END* STREAM ID: %s SUB: %s (%s) PEER: %s (%s) TGID %s (%s), TS %s, Loss: %s, Duration: %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, self.STATUS[_slot]['RX_LOSS'], call_duration)
|
||||
|
||||
|
||||
for _target in self._CONFIG['SYSTEMS']:
|
||||
if _target != self._system:
|
||||
|
||||
_target_status = systems[_target].STATUS
|
||||
_target_system = self._CONFIG['SYSTEMS'][_target]
|
||||
|
||||
# BEGIN STANDARD CONTENTION HANDLING
|
||||
#
|
||||
# The rules for each of the 4 "ifs" below are listed here for readability. The Frame To Send is:
|
||||
# From a different group than last RX from this HBSystem, but it has been less than Group Hangtime
|
||||
# From a different group than last TX to this HBSystem, but it has been less than Group Hangtime
|
||||
# From the same group as the last RX from this HBSystem, but from a different subscriber, and it has been less than stream timeout
|
||||
# From the same group as the last TX to this HBSystem, but from a different subscriber, and it has been less than stream timeout
|
||||
# The "continue" at the end of each means the next iteration of the for loop that tests for matching rules
|
||||
#
|
||||
if ((_dst_id != _target_status[_slot]['RX_TGID']) and ((pkt_time - _target_status[_slot]['RX_TIME']) < _target_system['GROUP_HANGTIME'])):
|
||||
if _frame_type == const.HBPF_DATA_SYNC and _dtype_vseq == const.HBPF_SLT_VHEAD and self.STATUS[_slot]['RX_STREAM_ID'] != _stream_id:
|
||||
logger.info('(%s) Call not routed to TGID %s, target active or in group hangtime: HBSystem: %s, TS: %s, TGID: %s', self._system, int_id(_dst_id), _target, _slot, int_id(_target_status[_slot]['RX_TGID']))
|
||||
continue
|
||||
if ((_dst_id != _target_status[_slot]['TX_TGID']) and ((pkt_time - _target_status[_slot]['TX_TIME']) < _target_system['GROUP_HANGTIME'])):
|
||||
if _frame_type == const.HBPF_DATA_SYNC and _dtype_vseq == const.HBPF_SLT_VHEAD and self.STATUS[_slot]['RX_STREAM_ID'] != _stream_id:
|
||||
logger.info('(%s) Call not routed to TGID%s, target in group hangtime: HBSystem: %s, TS: %s, TGID: %s', self._system, int_id(_dst_id), _target, _slot, int_id(_target_status[_slot]['TX_TGID']))
|
||||
continue
|
||||
if (_dst_id == _target_status[_slot]['RX_TGID']) and ((pkt_time - _target_status[_slot]['RX_TIME']) < const.STREAM_TO):
|
||||
if _frame_type == const.HBPF_DATA_SYNC and _dtype_vseq == const.HBPF_SLT_VHEAD and self.STATUS[_slot]['RX_STREAM_ID'] != _stream_id:
|
||||
logger.info('(%s) Call not routed to TGID%s, matching call already active on target: HBSystem: %s, TS: %s, TGID: %s', self._system, int_id(_dst_id), _target, _slot, int_id(_target_status[_slot]['RX_TGID']))
|
||||
continue
|
||||
if (_dst_id == _target_status[_slot]['TX_TGID']) and (_rf_src != _target_status[_slot]['TX_RFS']) and ((pkt_time - _target_status[_slot]['TX_TIME']) < const.STREAM_TO):
|
||||
if _frame_type == const.HBPF_DATA_SYNC and _dtype_vseq == const.HBPF_SLT_VHEAD and self.STATUS[_slot]['RX_STREAM_ID'] != _stream_id:
|
||||
logger.info('(%s) Call not routed for subscriber %s, call route in progress on target: HBSystem: %s, TS: %s, TGID: %s, SUB: %s', self._system, int_id(_rf_src), _target, _slot, int_id(_target_status[_slot]['TX_TGID']), int_id(_target_status[_slot]['TX_RFS']))
|
||||
continue
|
||||
|
||||
|
||||
# ACL Processing
|
||||
if self._CONFIG['GLOBAL']['USE_ACL']:
|
||||
if not acl_check(_rf_src, self._CONFIG['GLOBAL']['SUB_ACL']):
|
||||
if _stream_id != _target_status[_slot]['TX_STREAM_ID']:
|
||||
logger.info('(%s) CALL DROPPED ON EGRESS WITH STREAM ID %s FROM SUBSCRIBER %s BY GLOBAL ACL', _target, int_id(_stream_id), int_id(_rf_src))
|
||||
_target_status[_slot]['TX_STREAM_ID'] = _stream_id
|
||||
continue
|
||||
if _slot == 1 and not acl_check(_dst_id, self._CONFIG['GLOBAL']['TG1_ACL']):
|
||||
if _stream_id != _target_status[_slot]['TX_STREAM_ID']:
|
||||
logger.info('(%s) CALL DROPPED ON EGRESS WITH STREAM ID %s ON TGID %s BY GLOBAL TS1 ACL', _target, int_id(_stream_id), int_id(_dst_id))
|
||||
_target_status[_slot]['TX_STREAM_ID'] = _stream_id
|
||||
continue
|
||||
if _slot == 2 and not acl_check(_dst_id, self._CONFIG['GLOBAL']['TG2_ACL']):
|
||||
if _stream_id != _target_status[_slot]['TX_STREAM_ID']:
|
||||
logger.info('(%s) CALL DROPPED ON EGRESS WITH STREAM ID %s ON TGID %s BY GLOBAL TS2 ACL', _target, int_id(_stream_id), int_id(_dst_id))
|
||||
_target_status[_slot]['TX_STREAM_ID'] = _stream_id
|
||||
continue
|
||||
if _target_system['USE_ACL']:
|
||||
if not acl_check(_rf_src, _target_system['SUB_ACL']):
|
||||
if _stream_id != _target_status[_slot]['TX_STREAM_ID']:
|
||||
logger.info('(%s) CALL DROPPED ON EGRESS WITH STREAM ID %s FROM SUBSCRIBER %s BY SYSTEM ACL', _target, int_id(_stream_id), int_id(_rf_src))
|
||||
_target_status[_slot]['TX_STREAM_ID'] = _stream_id
|
||||
continue
|
||||
if _slot == 1 and not acl_check(_dst_id, _target_system['TG1_ACL']):
|
||||
if _stream_id != _target_status[_slot]['TX_STREAM_ID']:
|
||||
logger.info('(%s) CALL DROPPED ON EGRESS WITH STREAM ID %s ON TGID %s BY SYSTEM TS1 ACL', _target, int_id(_stream_id), int_id(_dst_id))
|
||||
_target_status[_slot]['TX_STREAM_ID'] = _stream_id
|
||||
continue
|
||||
if _slot == 2 and not acl_check(_dst_id, _target_system['TG2_ACL']):
|
||||
if _stream_id != _target_status[_slot]['TX_STREAM_ID']:
|
||||
logger.info('(%s) CALL DROPPED ON EGRESS WITH STREAM ID %s ON TGID %s BY SYSTEM TS2 ACL', _target, int_id(_stream_id), int_id(_dst_id))
|
||||
_target_status[_slot]['TX_STREAM_ID'] = _stream_id
|
||||
continue
|
||||
|
||||
# Record this stuff for later
|
||||
# Is this a new call stream?
|
||||
if new_stream:
|
||||
# Record the DST TGID and Stream ID
|
||||
_target_status[_slot]['TX_START'] = pkt_time
|
||||
_target_status[_slot]['TX_TGID'] = _dst_id
|
||||
_target_status[_slot]['TX_RFS'] = _rf_src
|
||||
_target_status[_slot]['TX_PEER'] = _peer_id
|
||||
_target_status[_slot]['TX_STREAM_ID'] = _stream_id
|
||||
|
||||
_target_status[_slot]['TX_TIME'] = pkt_time
|
||||
|
||||
systems[_target].send_system(_data)
|
||||
#logger.debug('(%s) Packet routed to system: %s', self._system, _target)
|
||||
|
||||
# Mark status variables for use later
|
||||
self.STATUS[_slot]['RX_RFS'] = _rf_src
|
||||
self.STATUS[_slot]['RX_SEQ'] = _seq
|
||||
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
|
||||
|
||||
|
||||
#************************************************
|
||||
# MAIN PROGRAM LOOP STARTS HERE
|
||||
#************************************************
|
||||
|
||||
if __name__ == '__main__':
|
||||
import argparse
|
||||
import sys
|
||||
import os
|
||||
import signal
|
||||
from dmr_utils3.utils import try_download, mk_id_dict
|
||||
|
||||
# Change the current directory to the location of the application
|
||||
os.chdir(os.path.dirname(os.path.realpath(sys.argv[0])))
|
||||
|
||||
# CLI argument parser - handles picking up the config file from the command line, and sending a "help" message
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('-c', '--config', action='store', dest='CONFIG_FILE', help='/full/path/to/config.file (usually hblink.cfg)')
|
||||
parser.add_argument('-l', '--logging', action='store', dest='LOG_LEVEL', help='Override config file logging level.')
|
||||
cli_args = parser.parse_args()
|
||||
|
||||
# Ensure we have a path for the config file, if one wasn't specified, then use the default (top of file)
|
||||
if not cli_args.CONFIG_FILE:
|
||||
cli_args.CONFIG_FILE = os.path.dirname(os.path.abspath(__file__))+'/hblink.cfg'
|
||||
|
||||
# Call the external routine to build the configuration dictionary
|
||||
CONFIG = config.build_config(cli_args.CONFIG_FILE)
|
||||
|
||||
# Start the system logger
|
||||
if cli_args.LOG_LEVEL:
|
||||
CONFIG['LOGGER']['LOG_LEVEL'] = cli_args.LOG_LEVEL
|
||||
logger = log.config_logging(CONFIG['LOGGER'])
|
||||
logger.info('\n\nCopyright (c) 2013, 2014, 2015, 2016, 2018, 2019\n\tThe Regents of the K0USY Group. All rights reserved.\n')
|
||||
logger.debug('Logging system started, anything from here on gets logged')
|
||||
|
||||
# Set up the signal handler
|
||||
def sig_handler(_signal, _frame):
|
||||
logger.info('SHUTDOWN: BRIDGE_ALL IS TERMINATING WITH SIGNAL %s', str(_signal))
|
||||
hblink_handler(_signal, _frame)
|
||||
logger.info('SHUTDOWN: ALL SYSTEM HANDLERS EXECUTED - STOPPING REACTOR')
|
||||
reactor.stop()
|
||||
|
||||
# Set signal handers so that we can gracefully exit if need be
|
||||
for sig in [signal.SIGTERM, signal.SIGINT]:
|
||||
signal.signal(sig, sig_handler)
|
||||
|
||||
# Create the name-number mapping dictionaries
|
||||
peer_ids, subscriber_ids, talkgroup_ids = mk_aliases(CONFIG)
|
||||
|
||||
# INITIALIZE THE REPORTING LOOP
|
||||
report_server = config_reports(CONFIG, reportFactory)
|
||||
|
||||
# HBlink instance creation
|
||||
logger.info('HBlink \'bridge_all.py\' -- SYSTEM STARTING...')
|
||||
for system in CONFIG['SYSTEMS']:
|
||||
if CONFIG['SYSTEMS'][system]['ENABLED']:
|
||||
if CONFIG['SYSTEMS'][system]['MODE'] == 'OPENBRIDGE':
|
||||
logger.critical('%s FATAL: Instance is mode \'OPENBRIDGE\', \n\t\t...Which would be tragic for Bridge All, since it carries multiple call\n\t\tstreams simultaneously. bridge_all.py onlyl works with MMDVM-based systems', system)
|
||||
sys.exit('bridge_all.py cannot function with systems that are not MMDVM devices. System {} is configured as an OPENBRIDGE'.format(system))
|
||||
else:
|
||||
systems[system] = bridgeallSYSTEM(system, CONFIG, report_server)
|
||||
reactor.listenUDP(CONFIG['SYSTEMS'][system]['PORT'], systems[system], interface=CONFIG['SYSTEMS'][system]['IP'])
|
||||
logger.debug('%s instance created: %s, %s', CONFIG['SYSTEMS'][system]['MODE'], system, systems[system])
|
||||
|
||||
reactor.run()
|
||||
@@ -86,7 +86,7 @@ def acl_build(_acl, _max):
|
||||
if (const.ID_MIN <= start <= _max) or (const.ID_MIN <= end <= _max):
|
||||
acl.append((start, end))
|
||||
else:
|
||||
sys.exit('ACL CREATION ERROR, VALUE OUT OF RANGE (} - {})IN RANGE-BASED ENTRY: {}'.format(const.ID_MIN, _max, entry))
|
||||
sys.exit('ACL CREATION ERROR, VALUE OUT OF RANGE ({} - {})IN RANGE-BASED ENTRY: {}'.format(const.ID_MIN, _max, entry))
|
||||
else:
|
||||
id = int(entry)
|
||||
if (const.ID_MIN <= id <= _max):
|
||||
@@ -199,52 +199,6 @@ def build_config(_config_file):
|
||||
'LAST_PING_ACK_TIME': 0,
|
||||
}})
|
||||
|
||||
if config.get(section, 'MODE') == 'XLXPEER':
|
||||
CONFIG['SYSTEMS'].update({section: {
|
||||
'MODE': config.get(section, 'MODE'),
|
||||
'ENABLED': config.getboolean(section, 'ENABLED'),
|
||||
'LOOSE': config.getboolean(section, 'LOOSE'),
|
||||
'SOCK_ADDR': (gethostbyname(config.get(section, 'IP')), config.getint(section, 'PORT')),
|
||||
'IP': gethostbyname(config.get(section, 'IP')),
|
||||
'PORT': config.getint(section, 'PORT'),
|
||||
'MASTER_SOCKADDR': (gethostbyname(config.get(section, 'MASTER_IP')), config.getint(section, 'MASTER_PORT')),
|
||||
'MASTER_IP': gethostbyname(config.get(section, 'MASTER_IP')),
|
||||
'MASTER_PORT': config.getint(section, 'MASTER_PORT'),
|
||||
'PASSPHRASE': bytes(config.get(section, 'PASSPHRASE'), 'utf-8'),
|
||||
'CALLSIGN': bytes(config.get(section, 'CALLSIGN').ljust(8)[:8], 'utf-8'),
|
||||
'RADIO_ID': config.getint(section, 'RADIO_ID').to_bytes(4, 'big'),
|
||||
'RX_FREQ': bytes(config.get(section, 'RX_FREQ').ljust(9)[:9], 'utf-8'),
|
||||
'TX_FREQ': bytes(config.get(section, 'TX_FREQ').ljust(9)[:9], 'utf-8'),
|
||||
'TX_POWER': bytes(config.get(section, 'TX_POWER').rjust(2,'0'), 'utf-8'),
|
||||
'COLORCODE': bytes(config.get(section, 'COLORCODE').rjust(2,'0'), 'utf-8'),
|
||||
'LATITUDE': bytes(config.get(section, 'LATITUDE').ljust(8)[:8], 'utf-8'),
|
||||
'LONGITUDE': bytes(config.get(section, 'LONGITUDE').ljust(9)[:9], 'utf-8'),
|
||||
'HEIGHT': bytes(config.get(section, 'HEIGHT').rjust(3,'0'), 'utf-8'),
|
||||
'LOCATION': bytes(config.get(section, 'LOCATION').ljust(20)[:20], 'utf-8'),
|
||||
'DESCRIPTION': bytes(config.get(section, 'DESCRIPTION').ljust(19)[:19], 'utf-8'),
|
||||
'SLOTS': bytes(config.get(section, 'SLOTS'), 'utf-8'),
|
||||
'URL': bytes(config.get(section, 'URL').ljust(124)[:124], 'utf-8'),
|
||||
'SOFTWARE_ID': bytes(config.get(section, 'SOFTWARE_ID').ljust(40)[:40], 'utf-8'),
|
||||
'PACKAGE_ID': bytes(config.get(section, 'PACKAGE_ID').ljust(40)[:40], 'utf-8'),
|
||||
'GROUP_HANGTIME': config.getint(section, 'GROUP_HANGTIME'),
|
||||
'XLXMODULE': config.getint(section, 'XLXMODULE'),
|
||||
'OPTIONS': '',
|
||||
'USE_ACL': config.getboolean(section, 'USE_ACL'),
|
||||
'SUB_ACL': config.get(section, 'SUB_ACL'),
|
||||
'TG1_ACL': config.get(section, 'TGID_TS1_ACL'),
|
||||
'TG2_ACL': config.get(section, 'TGID_TS2_ACL')
|
||||
}})
|
||||
CONFIG['SYSTEMS'][section].update({'XLXSTATS': {
|
||||
'CONNECTION': 'NO', # NO, RTPL_SENT, AUTHENTICATED, CONFIG-SENT, YES
|
||||
'CONNECTED': None,
|
||||
'PINGS_SENT': 0,
|
||||
'PINGS_ACKD': 0,
|
||||
'NUM_OUTSTANDING': 0,
|
||||
'PING_OUTSTANDING': False,
|
||||
'LAST_PING_TX_TIME': 0,
|
||||
'LAST_PING_ACK_TIME': 0,
|
||||
}})
|
||||
|
||||
elif config.get(section, 'MODE') == 'MASTER':
|
||||
CONFIG['SYSTEMS'].update({section: {
|
||||
'MODE': config.get(section, 'MODE'),
|
||||
@@ -274,6 +228,7 @@ def build_config(_config_file):
|
||||
'TARGET_SOCK': (gethostbyname(config.get(section, 'TARGET_IP')), config.getint(section, 'TARGET_PORT')),
|
||||
'TARGET_IP': gethostbyname(config.get(section, 'TARGET_IP')),
|
||||
'TARGET_PORT': config.getint(section, 'TARGET_PORT'),
|
||||
'BOTH_SLOTS': config.getboolean(section, 'BOTH_SLOTS'),
|
||||
'USE_ACL': config.getboolean(section, 'USE_ACL'),
|
||||
'SUB_ACL': config.get(section, 'SUB_ACL'),
|
||||
'TG1_ACL': config.get(section, 'TGID_ACL'),
|
||||
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
mkdir -p /var/tmp/config
|
||||
cd /var/tmp/config
|
||||
git clone https://${GIT_USER}:${GIT_PASSWORD}@${GIT_REPO}
|
||||
|
||||
DIR=$(echo ${GIT_REPO}| sed s/.git$//g | sed s#^.*/##g)
|
||||
|
||||
cp -a /var/tmp/config/${DIR}/*cfg /opt/hblink3/
|
||||
python /opt/hblink3/hblink.py
|
||||
Executable
+127
@@ -0,0 +1,127 @@
|
||||
[GLOBAL]
|
||||
PATH: ./
|
||||
PING_TIME: 5
|
||||
MAX_MISSED: 3
|
||||
USE_ACL: False
|
||||
REG_ACL: DENY:1
|
||||
SUB_ACL: DENY:1
|
||||
TGID_TS1_ACL: PERMIT:ALL
|
||||
TGID_TS2_ACL: PERMIT:ALL
|
||||
|
||||
[REPORTS]
|
||||
REPORT: False
|
||||
REPORT_INTERVAL: 60
|
||||
REPORT_PORT: 4321
|
||||
REPORT_CLIENTS: 127.0.0.1
|
||||
|
||||
[LOGGER]
|
||||
LOG_FILE: /tmp/hblink.log
|
||||
LOG_HANDLERS: console-timed
|
||||
LOG_LEVEL: INFO
|
||||
LOG_NAME: 444.750
|
||||
|
||||
[ALIASES]
|
||||
TRY_DOWNLOAD: False
|
||||
PATH: ./
|
||||
PEER_FILE: peer_ids.json
|
||||
SUBSCRIBER_FILE: subscriber_ids.json
|
||||
TGID_FILE: talkgroup_ids.json
|
||||
PEER_URL: https://www.radioid.net/static/rptrs.json
|
||||
SUBSCRIBER_URL: https://www.radioid.net/static/users.json
|
||||
STALE_DAYS: 7
|
||||
|
||||
[OBP]
|
||||
MODE: OPENBRIDGE
|
||||
ENABLED: True
|
||||
IP:
|
||||
PORT: 50100
|
||||
NETWORK_ID: 1
|
||||
PASSPHRASE: deadbeef
|
||||
#TARGET_IP: olympic.k0usy.org
|
||||
TARGET_IP: 127.0.0.1
|
||||
#TARGET_PORT: 50666
|
||||
TARGET_PORT: 50101
|
||||
BOTH_SLOTS: True
|
||||
USE_ACL: False
|
||||
SUB_ACL: DENY:1
|
||||
TGID_ACL: PERMIT:ALL
|
||||
|
||||
[444.750]
|
||||
MODE: MASTER
|
||||
ENABLED: True
|
||||
REPEAT: True
|
||||
MAX_PEERS: 5
|
||||
EXPORT_AMBE: False
|
||||
IP:
|
||||
PORT: 50001
|
||||
PASSPHRASE: jimmy
|
||||
GROUP_HANGTIME: 10
|
||||
USE_ACL: False
|
||||
REG_ACL: DENY:1
|
||||
SUB_ACL: DENY:1
|
||||
TGID_TS1_ACL: DENY:8
|
||||
TGID_TS2_ACL: PERMIT:3120
|
||||
|
||||
[TWO]
|
||||
MODE: MASTER
|
||||
ENABLED: False
|
||||
REPEAT: True
|
||||
MAX_PEERS: 5
|
||||
EXPORT_AMBE: False
|
||||
IP:
|
||||
PORT:50002
|
||||
PASSPHRASE: jimmy
|
||||
GROUP_HANGTIME: 10
|
||||
USE_ACL: False
|
||||
REG_ACL: DENY:1
|
||||
SUB_ACL: DENY:1
|
||||
TGID_TS1_ACL: DENY:8
|
||||
TGID_TS2_ACL: PERMIT:3120
|
||||
|
||||
[THREE]
|
||||
MODE: MASTER
|
||||
ENABLED: False
|
||||
REPEAT: True
|
||||
MAX_PEERS: 5
|
||||
EXPORT_AMBE: False
|
||||
IP:
|
||||
PORT:50003
|
||||
PASSPHRASE: jimmy
|
||||
GROUP_HANGTIME: 10
|
||||
USE_ACL: False
|
||||
REG_ACL: DENY:1
|
||||
SUB_ACL: DENY:1
|
||||
TGID_TS1_ACL: DENY:8
|
||||
TGID_TS2_ACL: PERMIT:3120
|
||||
|
||||
[KS-DMR]
|
||||
MODE: PEER
|
||||
ENABLED: False
|
||||
LOOSE: False
|
||||
EXPORT_AMBE: False
|
||||
IP:
|
||||
PORT: 54001
|
||||
MASTER_IP: olympic.k0usy.org
|
||||
MASTER_PORT: 62071
|
||||
PASSPHRASE: c0ffee
|
||||
CALLSIGN: W1ABC
|
||||
RADIO_ID: 312312
|
||||
RX_FREQ: 449000000
|
||||
TX_FREQ: 444000000
|
||||
TX_POWER: 25
|
||||
COLORCODE: 1
|
||||
SLOTS: 1
|
||||
LATITUDE: 38.0000
|
||||
LONGITUDE: -095.0000
|
||||
HEIGHT: 75
|
||||
LOCATION: Anywhere, USA
|
||||
DESCRIPTION: This is a cool repeater
|
||||
URL: www.w1abc.org
|
||||
SOFTWARE_ID: 20170620
|
||||
PACKAGE_ID: MMDVM_HBlink
|
||||
GROUP_HANGTIME: 5
|
||||
OPTIONS:
|
||||
USE_ACL: True
|
||||
SUB_ACL: DENY:1
|
||||
TGID_TS1_ACL: PERMIT:ALL
|
||||
TGID_TS2_ACL: PERMIT:ALL
|
||||
Executable
+127
@@ -0,0 +1,127 @@
|
||||
[GLOBAL]
|
||||
PATH: ./
|
||||
PING_TIME: 5
|
||||
MAX_MISSED: 3
|
||||
USE_ACL: False
|
||||
REG_ACL: DENY:1
|
||||
SUB_ACL: DENY:1
|
||||
TGID_TS1_ACL: PERMIT:ALL
|
||||
TGID_TS2_ACL: PERMIT:ALL
|
||||
|
||||
[REPORTS]
|
||||
REPORT: False
|
||||
REPORT_INTERVAL: 60
|
||||
REPORT_PORT: 4321
|
||||
REPORT_CLIENTS: 127.0.0.1
|
||||
|
||||
[LOGGER]
|
||||
LOG_FILE: /tmp/hblink.log
|
||||
LOG_HANDLERS: console-timed
|
||||
LOG_LEVEL: INFO
|
||||
LOG_NAME: 444.800
|
||||
|
||||
[ALIASES]
|
||||
TRY_DOWNLOAD: False
|
||||
PATH: ./
|
||||
PEER_FILE: peer_ids.json
|
||||
SUBSCRIBER_FILE: subscriber_ids.json
|
||||
TGID_FILE: talkgroup_ids.json
|
||||
PEER_URL: https://www.radioid.net/static/rptrs.json
|
||||
SUBSCRIBER_URL: https://www.radioid.net/static/users.json
|
||||
STALE_DAYS: 7
|
||||
|
||||
[OBP]
|
||||
MODE: OPENBRIDGE
|
||||
ENABLED: True
|
||||
IP:
|
||||
PORT: 50101
|
||||
NETWORK_ID: 2
|
||||
PASSPHRASE: deadbeef
|
||||
#TARGET_IP: olympic.k0usy.org
|
||||
TARGET_IP: 127.0.0.1
|
||||
#TARGET_PORT: 50666
|
||||
TARGET_PORT: 50100
|
||||
BOTH_SLOTS: True
|
||||
USE_ACL: False
|
||||
SUB_ACL: DENY:1
|
||||
TGID_ACL: PERMIT:ALL
|
||||
|
||||
[444.800]
|
||||
MODE: MASTER
|
||||
ENABLED: True
|
||||
REPEAT: True
|
||||
MAX_PEERS: 5
|
||||
EXPORT_AMBE: False
|
||||
IP:
|
||||
PORT: 50011
|
||||
PASSPHRASE: jimmy
|
||||
GROUP_HANGTIME: 10
|
||||
USE_ACL: False
|
||||
REG_ACL: DENY:1
|
||||
SUB_ACL: DENY:1
|
||||
TGID_TS1_ACL: DENY:8
|
||||
TGID_TS2_ACL: PERMIT:3120
|
||||
|
||||
[TWO]
|
||||
MODE: MASTER
|
||||
ENABLED: False
|
||||
REPEAT: True
|
||||
MAX_PEERS: 5
|
||||
EXPORT_AMBE: False
|
||||
IP:
|
||||
PORT:50012
|
||||
PASSPHRASE: jimmy
|
||||
GROUP_HANGTIME: 10
|
||||
USE_ACL: False
|
||||
REG_ACL: DENY:1
|
||||
SUB_ACL: DENY:1
|
||||
TGID_TS1_ACL: DENY:8
|
||||
TGID_TS2_ACL: PERMIT:3120
|
||||
|
||||
[THREE]
|
||||
MODE: MASTER
|
||||
ENABLED: False
|
||||
REPEAT: True
|
||||
MAX_PEERS: 5
|
||||
EXPORT_AMBE: False
|
||||
IP:
|
||||
PORT:50013
|
||||
PASSPHRASE: jimmy
|
||||
GROUP_HANGTIME: 10
|
||||
USE_ACL: False
|
||||
REG_ACL: DENY:1
|
||||
SUB_ACL: DENY:1
|
||||
TGID_TS1_ACL: DENY:8
|
||||
TGID_TS2_ACL: PERMIT:3120
|
||||
|
||||
[KS-DMR]
|
||||
MODE: PEER
|
||||
ENABLED: False
|
||||
LOOSE: False
|
||||
EXPORT_AMBE: False
|
||||
IP:
|
||||
PORT: 54011
|
||||
MASTER_IP: olympic.k0usy.org
|
||||
MASTER_PORT: 62071
|
||||
PASSPHRASE: c0ffee
|
||||
CALLSIGN: W1ABC
|
||||
RADIO_ID: 312312
|
||||
RX_FREQ: 449000000
|
||||
TX_FREQ: 444000000
|
||||
TX_POWER: 25
|
||||
COLORCODE: 1
|
||||
SLOTS: 1
|
||||
LATITUDE: 38.0000
|
||||
LONGITUDE: -095.0000
|
||||
HEIGHT: 75
|
||||
LOCATION: Anywhere, USA
|
||||
DESCRIPTION: This is a cool repeater
|
||||
URL: www.w1abc.org
|
||||
SOFTWARE_ID: 20170620
|
||||
PACKAGE_ID: MMDVM_HBlink
|
||||
GROUP_HANGTIME: 5
|
||||
OPTIONS:
|
||||
USE_ACL: True
|
||||
SUB_ACL: DENY:1
|
||||
TGID_TS1_ACL: PERMIT:ALL
|
||||
TGID_TS2_ACL: PERMIT:ALL
|
||||
+5
-34
@@ -120,7 +120,9 @@ STALE_DAYS: 7
|
||||
#
|
||||
# ACLs:
|
||||
# OpenBridge does not 'register', so registration ACL is meaningless.
|
||||
# OpenBridge passes all traffic on TS1, so there is only 1 TGID ACL.
|
||||
# Proper OpenBridge passes all traffic on TS1.
|
||||
# HBlink can extend OPB to use both slots for unit calls only.
|
||||
# Setting "BOTH_SLOTS" True ONLY affects unit traffic!
|
||||
# Otherwise ACLs work as described in the global stanza
|
||||
[OBP-1]
|
||||
MODE: OPENBRIDGE
|
||||
@@ -131,6 +133,7 @@ NETWORK_ID: 3129100
|
||||
PASSPHRASE: password
|
||||
TARGET_IP: 1.2.3.4
|
||||
TARGET_PORT: 62035
|
||||
BOTH_SLOTS: True
|
||||
USE_ACL: True
|
||||
SUB_ACL: DENY:1
|
||||
TGID_ACL: PERMIT:ALL
|
||||
@@ -206,36 +209,4 @@ OPTIONS:
|
||||
USE_ACL: True
|
||||
SUB_ACL: DENY:1
|
||||
TGID_TS1_ACL: PERMIT:ALL
|
||||
TGID_TS2_ACL: PERMIT:ALL
|
||||
|
||||
[XLX-1]
|
||||
MODE: XLXPEER
|
||||
ENABLED: True
|
||||
LOOSE: True
|
||||
EXPORT_AMBE: False
|
||||
IP:
|
||||
PORT: 54002
|
||||
MASTER_IP: 172.16.1.1
|
||||
MASTER_PORT: 62030
|
||||
PASSPHRASE: passw0rd
|
||||
CALLSIGN: W1ABC
|
||||
RADIO_ID: 312000
|
||||
RX_FREQ: 449000000
|
||||
TX_FREQ: 444000000
|
||||
TX_POWER: 25
|
||||
COLORCODE: 1
|
||||
SLOTS: 1
|
||||
LATITUDE: 38.0000
|
||||
LONGITUDE: -095.0000
|
||||
HEIGHT: 75
|
||||
LOCATION: Anywhere, USA
|
||||
DESCRIPTION: This is a cool repeater
|
||||
URL: www.w1abc.org
|
||||
SOFTWARE_ID: 20170620
|
||||
PACKAGE_ID: MMDVM_HBlink
|
||||
GROUP_HANGTIME: 5
|
||||
XLXMODULE: 4004
|
||||
USE_ACL: True
|
||||
SUB_ACL: DENY:1
|
||||
TGID_TS1_ACL: PERMIT:ALL
|
||||
TGID_TS2_ACL: PERMIT:ALL
|
||||
TGID_TS2_ACL: PERMIT:ALL
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
###############################################################################
|
||||
# Copyright (C) 2016-2019 Cortney T. Buffington, N0MJS <n0mjs@me.com>
|
||||
# Copyright (C) 2016-2020 Cortney T. Buffington, N0MJS <n0mjs@me.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -45,11 +45,7 @@ from twisted.internet import reactor, task
|
||||
import log
|
||||
import config
|
||||
from const import *
|
||||
from dmr_utils3.utils import int_id, bytes_4, try_download, mk_id_dict
|
||||
|
||||
# Imports for the reporting server
|
||||
import pickle
|
||||
from reporting_const import *
|
||||
from dmr_utils3.utils import int_id, bytes_4
|
||||
|
||||
# The module needs logging logging, but handlers, etc. are controlled by the parent
|
||||
import logging
|
||||
@@ -66,23 +62,6 @@ __email__ = 'n0mjs@me.com'
|
||||
# Global variables used whether we are a module or __main__
|
||||
systems = {}
|
||||
|
||||
# Timed loop used for reporting HBP status
|
||||
def config_reports(_config, _factory):
|
||||
def reporting_loop(_logger, _server):
|
||||
_logger.debug('(GLOBAL) Periodic reporting loop started')
|
||||
_server.send_config()
|
||||
|
||||
logger.info('(GLOBAL) HBlink TCP reporting server configured')
|
||||
|
||||
report_server = _factory(_config)
|
||||
report_server.clients = []
|
||||
reactor.listenTCP(_config['REPORTS']['REPORT_PORT'], report_server)
|
||||
|
||||
reporting = task.LoopingCall(reporting_loop, logger, report_server)
|
||||
reporting.start(_config['REPORTS']['REPORT_INTERVAL'])
|
||||
|
||||
return report_server
|
||||
|
||||
|
||||
# Shut ourselves down gracefully by disconnecting from the masters and peers.
|
||||
def hblink_handler(_signal, _frame):
|
||||
@@ -105,11 +84,10 @@ def acl_check(_id, _acl):
|
||||
#************************************************
|
||||
|
||||
class OPENBRIDGE(DatagramProtocol):
|
||||
def __init__(self, _name, _config, _report):
|
||||
def __init__(self, _name, _config):
|
||||
# Define a few shortcuts to make the rest of the class more readable
|
||||
self._CONFIG = _config
|
||||
self._system = _name
|
||||
self._report = _report
|
||||
self._config = self._CONFIG['SYSTEMS'][self._system]
|
||||
self._laststrid = deque([], 20)
|
||||
|
||||
@@ -160,8 +138,8 @@ class OPENBRIDGE(DatagramProtocol):
|
||||
_stream_id = _data[16:20]
|
||||
#logger.debug('(%s) DMRD - Seqence: %s, RF Source: %s, Destination ID: %s', self._system, int_id(_seq), int_id(_rf_src), int_id(_dst_id))
|
||||
|
||||
# Sanity check for OpenBridge -- all calls must be on Slot 1
|
||||
if _slot != 1:
|
||||
# Sanity check for OpenBridge -- all calls must be on Slot 1 for Brandmeister or DMR+. Other HBlinks can process timeslot on OPB if the flag is set
|
||||
if _slot != 1 and not self._config['BOTH_SLOTS'] and not _call_type == 'unit':
|
||||
logger.error('(%s) OpenBridge packet discarded because it was not received on slot 1. SID: %s, TGID %s', self._system, int_id(_rf_src), int_id(_dst_id))
|
||||
return
|
||||
|
||||
@@ -200,14 +178,12 @@ class OPENBRIDGE(DatagramProtocol):
|
||||
#************************************************
|
||||
|
||||
class HBSYSTEM(DatagramProtocol):
|
||||
def __init__(self, _name, _config, _report):
|
||||
def __init__(self, _name, _config):
|
||||
# Define a few shortcuts to make the rest of the class more readable
|
||||
self._CONFIG = _config
|
||||
self._system = _name
|
||||
self._report = _report
|
||||
self._config = self._CONFIG['SYSTEMS'][self._system]
|
||||
self._laststrid1 = ''
|
||||
self._laststrid2 = ''
|
||||
self._laststrid = {1: b'', 2: b''}
|
||||
|
||||
# Define shortcuts and generic function names based on the type of system we are
|
||||
if self._config['MODE'] == 'MASTER':
|
||||
@@ -224,13 +200,6 @@ class HBSYSTEM(DatagramProtocol):
|
||||
self.datagramReceived = self.peer_datagramReceived
|
||||
self.dereg = self.peer_dereg
|
||||
|
||||
elif self._config['MODE'] == 'XLXPEER':
|
||||
self._stats = self._config['XLXSTATS']
|
||||
self.send_system = self.send_master
|
||||
self.maintenance_loop = self.peer_maintenance_loop
|
||||
self.datagramReceived = self.peer_datagramReceived
|
||||
self.dereg = self.peer_dereg
|
||||
|
||||
def startProtocol(self):
|
||||
# Set up periodic loop for tracking pings from peers. Run every 'PING_TIME' seconds
|
||||
self._system_maintenance = task.LoopingCall(self.maintenance_loop)
|
||||
@@ -280,41 +249,19 @@ class HBSYSTEM(DatagramProtocol):
|
||||
if _packet[:4] == DMRD:
|
||||
_packet = b''.join([_packet[:11], _peer, _packet[15:]])
|
||||
self.transport.write(_packet, self._peers[_peer]['SOCKADDR'])
|
||||
# KEEP THE FOLLOWING COMMENTED OUT UNLESS YOU'RE DEBUGGING DEEPLY!!!!
|
||||
#logger.debug('(%s) TX Packet to %s on port %s: %s', self._peers[_peer]['RADIO_ID'], self._peers[_peer]['IP'], self._peers[_peer]['PORT'], ahex(_packet))
|
||||
|
||||
def send_master(self, _packet):
|
||||
if _packet[:4] == DMRD:
|
||||
_packet = b''.join([_packet[:11], self._config['RADIO_ID'], _packet[15:]])
|
||||
self.transport.write(_packet, self._config['MASTER_SOCKADDR'])
|
||||
# KEEP THE FOLLOWING COMMENTED OUT UNLESS YOU'RE DEBUGGING DEEPLY!!!!
|
||||
# logger.debug('(%s) TX Packet to %s:%s -- %s', self._system, self._config['MASTER_IP'], self._config['MASTER_PORT'], ahex(_packet))
|
||||
|
||||
def send_xlxmaster(self, radio, xlx, mastersock):
|
||||
radio3 = int.from_bytes(radio, 'big').to_bytes(3, 'big')
|
||||
radio4 = int.from_bytes(radio, 'big').to_bytes(4, 'big')
|
||||
xlx3 = xlx.to_bytes(3, 'big')
|
||||
streamid = randint(0,255).to_bytes(1, 'big')+randint(0,255).to_bytes(1, 'big')+randint(0,255).to_bytes(1, 'big')+randint(0,255).to_bytes(1, 'big')
|
||||
# Wait for .5 secs for the XLX to log us in
|
||||
for packetnr in range(5):
|
||||
if packetnr < 3:
|
||||
# First 3 packets, voice start, stream type e1
|
||||
strmtype = 225
|
||||
payload = bytearray.fromhex('4f2e00b501ae3a001c40a0c1cc7dff57d75df5d5065026f82880bd616f13f185890000')
|
||||
else:
|
||||
# Last 2 packets, voice end, stream type e2
|
||||
strmtype = 226
|
||||
payload = bytearray.fromhex('4f410061011e3a781c30a061ccbdff57d75df5d2534425c02fe0b1216713e885ba0000')
|
||||
packetnr1 = packetnr.to_bytes(1, 'big')
|
||||
strmtype1 = strmtype.to_bytes(1, 'big')
|
||||
_packet = b''.join([DMRD, packetnr1, radio3, xlx3, radio4, strmtype1, streamid, payload])
|
||||
self.transport.write(_packet, mastersock)
|
||||
# KEEP THE FOLLOWING COMMENTED OUT UNLESS YOU'RE DEBUGGING DEEPLY!!!!
|
||||
#logger.debug('(%s) XLX Module Change Packet: %s', self._system, ahex(_packet))
|
||||
return
|
||||
|
||||
def dmrd_received(self, _peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data):
|
||||
pass
|
||||
|
||||
def dmra_recieved(self, _data):
|
||||
pass
|
||||
|
||||
def master_dereg(self):
|
||||
for _peer in self._peers:
|
||||
@@ -327,7 +274,6 @@ class HBSYSTEM(DatagramProtocol):
|
||||
|
||||
# Aliased in __init__ to datagramReceived if system is a master
|
||||
def master_datagramReceived(self, _data, _sockaddr):
|
||||
# Keep This Line Commented Unless HEAVILY Debugging!
|
||||
# logger.debug('(%s) RX packet from %s -- %s', self._system, _sockaddr, ahex(_data))
|
||||
|
||||
# Extract the command, which is various length, all but one 4 significant characters -- RPTCL
|
||||
@@ -353,45 +299,39 @@ class HBSYSTEM(DatagramProtocol):
|
||||
_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]
|
||||
#logger.debug('(%s) DMRD - Seqence: %s, RF Source: %s, Destination ID: %s', self._system, int_id(_seq), int_id(_rf_src), int_id(_dst_id))
|
||||
#logger.debug('(%s) DMRD - Seqence: %s, RF Source: %s, Destination ID: %s', self._system, _seq, int_id(_rf_src), int_id(_dst_id))
|
||||
# ACL Processing
|
||||
if self._CONFIG['GLOBAL']['USE_ACL']:
|
||||
if not acl_check(_rf_src, self._CONFIG['GLOBAL']['SUB_ACL']):
|
||||
if self._laststrid != _stream_id:
|
||||
if self._laststrid[_slot] != _stream_id:
|
||||
logger.info('(%s) CALL DROPPED WITH STREAM ID %s FROM SUBSCRIBER %s BY GLOBAL ACL', self._system, int_id(_stream_id), int_id(_rf_src))
|
||||
if _slot == 1:
|
||||
self._laststrid1 = _stream_id
|
||||
else:
|
||||
self._laststrid2 = _stream_id
|
||||
self._laststrid[_slot] = _stream_id
|
||||
return
|
||||
if _slot == 1 and not acl_check(_dst_id, self._CONFIG['GLOBAL']['TG1_ACL']):
|
||||
if self._laststrid1 != _stream_id:
|
||||
if self._laststrid[_slot] != _stream_id:
|
||||
logger.info('(%s) CALL DROPPED WITH STREAM ID %s ON TGID %s BY GLOBAL TS1 ACL', self._system, int_id(_stream_id), int_id(_dst_id))
|
||||
self._laststrid1 = _stream_id
|
||||
self._laststrid[_slot] = _stream_id
|
||||
return
|
||||
if _slot == 2 and not acl_check(_dst_id, self._CONFIG['GLOBAL']['TG2_ACL']):
|
||||
if self._laststrid2 != _stream_id:
|
||||
if self._laststrid[_slot] != _stream_id:
|
||||
logger.info('(%s) CALL DROPPED WITH STREAM ID %s ON TGID %s BY GLOBAL TS2 ACL', self._system, int_id(_stream_id), int_id(_dst_id))
|
||||
self._laststrid2 = _stream_id
|
||||
self._laststrid[_slot] = _stream_id
|
||||
return
|
||||
if self._config['USE_ACL']:
|
||||
if not acl_check(_rf_src, self._config['SUB_ACL']):
|
||||
if self._laststrid != _stream_id:
|
||||
if self._laststrid[_slot] != _stream_id:
|
||||
logger.info('(%s) CALL DROPPED WITH STREAM ID %s FROM SUBSCRIBER %s BY SYSTEM ACL', self._system, int_id(_stream_id), int_id(_rf_src))
|
||||
if _slot == 1:
|
||||
self._laststrid1 = _stream_id
|
||||
else:
|
||||
self._laststrid2 = _stream_id
|
||||
self._laststrid[_slot] = _stream_id
|
||||
return
|
||||
if _slot == 1 and not acl_check(_dst_id, self._config['TG1_ACL']):
|
||||
if self._laststrid1 != _stream_id:
|
||||
if self._laststrid[_slot] != _stream_id:
|
||||
logger.info('(%s) CALL DROPPED WITH STREAM ID %s ON TGID %s BY SYSTEM TS1 ACL', self._system, int_id(_stream_id), int_id(_dst_id))
|
||||
self._laststrid1 = _stream_id
|
||||
self._laststrid[_slot] = _stream_id
|
||||
return
|
||||
if _slot == 2 and not acl_check(_dst_id, self._config['TG2_ACL']):
|
||||
if self._laststrid2 != _stream_id:
|
||||
if self._laststrid[_slot]!= _stream_id:
|
||||
logger.info('(%s) CALL DROPPED WITH STREAM ID %s ON TGID %s BY SYSTEM TS2 ACL', self._system, int_id(_stream_id), int_id(_dst_id))
|
||||
self._laststrid2 = _stream_id
|
||||
self._laststrid[_slot] = _stream_id
|
||||
return
|
||||
|
||||
# The basic purpose of a master is to repeat to the peers
|
||||
@@ -446,7 +386,7 @@ class HBSYSTEM(DatagramProtocol):
|
||||
logger.info('(%s) Sent Challenge Response to %s for login: %s', self._system, int_id(_peer_id), self._peers[_peer_id]['SALT'])
|
||||
else:
|
||||
self.transport.write(b''.join([MSTNAK, _peer_id]), _sockaddr)
|
||||
logger.warning('(%s) Invalid Login from Radio ID: %s Denied by Registation ACL', self._system, int_id(_peer_id))
|
||||
logger.warning('(%s) Invalid Login from %s Radio ID: %s Denied by Registation ACL', self._system, _sockaddr[0], int_id(_peer_id))
|
||||
else:
|
||||
self.transport.write(b''.join([MSTNAK, _peer_id]), _sockaddr)
|
||||
logger.warning('(%s) Registration denied from Radio ID: %s Maximum number of peers exceeded', self._system, int_id(_peer_id))
|
||||
@@ -526,6 +466,12 @@ class HBSYSTEM(DatagramProtocol):
|
||||
self.transport.write(b''.join([MSTNAK, _peer_id]), _sockaddr)
|
||||
logger.warning('(%s) Ping from Radio ID that is not logged in: %s', self._system, int_id(_peer_id))
|
||||
|
||||
# Talker alias callback
|
||||
elif _command == DMRA:
|
||||
self.dmrd_received(_data)
|
||||
#logger.info('(%s) DMRA recieved', self._system)
|
||||
|
||||
|
||||
else:
|
||||
logger.error('(%s) Unrecognized command. Raw HBP PDU: %s', self._system, ahex(_data))
|
||||
|
||||
@@ -562,41 +508,35 @@ class HBSYSTEM(DatagramProtocol):
|
||||
# ACL Processing
|
||||
if self._CONFIG['GLOBAL']['USE_ACL']:
|
||||
if not acl_check(_rf_src, self._CONFIG['GLOBAL']['SUB_ACL']):
|
||||
if self._laststrid != _stream_id:
|
||||
logger.debug('(%s) CALL DROPPED WITH STREAM ID %s FROM SUBSCRIBER %s BY GLOBAL ACL', self._system, int_id(_stream_id), int_id(_rf_src))
|
||||
if _slot == 1:
|
||||
self._laststrid1 = _stream_id
|
||||
else:
|
||||
self._laststrid2 = _stream_id
|
||||
if self._laststrid[_slot] != _stream_id:
|
||||
logger.info('(%s) CALL DROPPED WITH STREAM ID %s FROM SUBSCRIBER %s BY GLOBAL ACL', self._system, int_id(_stream_id), int_id(_rf_src))
|
||||
self._laststrid[_slot] = _stream_id
|
||||
return
|
||||
if _slot == 1 and not acl_check(_dst_id, self._CONFIG['GLOBAL']['TG1_ACL']):
|
||||
if self._laststrid1 != _stream_id:
|
||||
logger.debug('(%s) CALL DROPPED WITH STREAM ID %s ON TGID %s BY GLOBAL TS1 ACL', self._system, int_id(_stream_id), int_id(_dst_id))
|
||||
self._laststrid1 = _stream_id
|
||||
if self._laststrid[_slot] != _stream_id:
|
||||
logger.info('(%s) CALL DROPPED WITH STREAM ID %s ON TGID %s BY GLOBAL TS1 ACL', self._system, int_id(_stream_id), int_id(_dst_id))
|
||||
self._laststrid[_slot] = _stream_id
|
||||
return
|
||||
if _slot == 2 and not acl_check(_dst_id, self._CONFIG['GLOBAL']['TG2_ACL']):
|
||||
if self._laststrid2 != _stream_id:
|
||||
logger.debug('(%s) CALL DROPPED WITH STREAM ID %s ON TGID %s BY GLOBAL TS2 ACL', self._system, int_id(_stream_id), int_id(_dst_id))
|
||||
self._laststrid2 = _stream_id
|
||||
if self._laststrid[_slot] != _stream_id:
|
||||
logger.info('(%s) CALL DROPPED WITH STREAM ID %s ON TGID %s BY GLOBAL TS2 ACL', self._system, int_id(_stream_id), int_id(_dst_id))
|
||||
self._laststrid[_slot] = _stream_id
|
||||
return
|
||||
if self._config['USE_ACL']:
|
||||
if not acl_check(_rf_src, self._config['SUB_ACL']):
|
||||
if self._laststrid != _stream_id:
|
||||
logger.debug('(%s) CALL DROPPED WITH STREAM ID %s FROM SUBSCRIBER %s BY SYSTEM ACL', self._system, int_id(_stream_id), int_id(_rf_src))
|
||||
if _slot == 1:
|
||||
self._laststrid1 = _stream_id
|
||||
else:
|
||||
self._laststrid2 = _stream_id
|
||||
if self._laststrid[_slot] != _stream_id:
|
||||
logger.info('(%s) CALL DROPPED WITH STREAM ID %s FROM SUBSCRIBER %s BY SYSTEM ACL', self._system, int_id(_stream_id), int_id(_rf_src))
|
||||
self._laststrid[_slot] = _stream_id
|
||||
return
|
||||
if _slot == 1 and not acl_check(_dst_id, self._config['TG1_ACL']):
|
||||
if self._laststrid1 != _stream_id:
|
||||
logger.debug('(%s) CALL DROPPED WITH STREAM ID %s ON TGID %s BY SYSTEM TS1 ACL', self._system, int_id(_stream_id), int_id(_dst_id))
|
||||
self._laststrid1 = _stream_id
|
||||
if self._laststrid[_slot] != _stream_id:
|
||||
logger.info('(%s) CALL DROPPED WITH STREAM ID %s ON TGID %s BY SYSTEM TS1 ACL', self._system, int_id(_stream_id), int_id(_dst_id))
|
||||
self._laststrid[_slot] = _stream_id
|
||||
return
|
||||
if _slot == 2 and not acl_check(_dst_id, self._config['TG2_ACL']):
|
||||
if self._laststrid2 != _stream_id:
|
||||
logger.debug('(%s) CALL DROPPED WITH STREAM ID %s ON TGID %s BY SYSTEM TS2 ACL', self._system, int_id(_stream_id), int_id(_dst_id))
|
||||
self._laststrid2 = _stream_id
|
||||
if self._laststrid[_slot] != _stream_id:
|
||||
logger.info('(%s) CALL DROPPED WITH STREAM ID %s ON TGID %s BY SYSTEM TS2 ACL', self._system, int_id(_stream_id), int_id(_dst_id))
|
||||
self._laststrid[_slot] = _stream_id
|
||||
return
|
||||
|
||||
|
||||
@@ -661,11 +601,7 @@ class HBSYSTEM(DatagramProtocol):
|
||||
self._stats['CONNECTION'] = 'YES'
|
||||
self._stats['CONNECTED'] = time()
|
||||
logger.info('(%s) Connection to Master Completed', self._system)
|
||||
# If we are an XLX, send the XLX module request here.
|
||||
if self._config['MODE'] == 'XLXPEER':
|
||||
self.send_xlxmaster(self._config['RADIO_ID'], int(4000), self._config['MASTER_SOCKADDR'])
|
||||
self.send_xlxmaster(self._config['RADIO_ID'], self._config['XLXMODULE'], self._config['MASTER_SOCKADDR'])
|
||||
logger.info('(%s) Sending XLX Module request', self._system)
|
||||
|
||||
else:
|
||||
self._stats['CONNECTION'] = 'NO'
|
||||
logger.error('(%s) Master ACK Contained wrong ID - Connection Reset', self._system)
|
||||
@@ -697,79 +633,7 @@ class HBSYSTEM(DatagramProtocol):
|
||||
|
||||
else:
|
||||
logger.error('(%s) Received an invalid command in packet: %s', self._system, ahex(_data))
|
||||
|
||||
#
|
||||
# Socket-based reporting section
|
||||
#
|
||||
class report(NetstringReceiver):
|
||||
def __init__(self, factory):
|
||||
self._factory = factory
|
||||
|
||||
def connectionMade(self):
|
||||
self._factory.clients.append(self)
|
||||
logger.info('(REPORT) HBlink reporting client connected: %s', self.transport.getPeer())
|
||||
|
||||
def connectionLost(self, reason):
|
||||
logger.info('(REPORT) HBlink reporting client disconnected: %s', self.transport.getPeer())
|
||||
self._factory.clients.remove(self)
|
||||
|
||||
def stringReceived(self, data):
|
||||
self.process_message(data)
|
||||
|
||||
def process_message(self, _message):
|
||||
opcode = _message[:1]
|
||||
if opcode == REPORT_OPCODES['CONFIG_REQ']:
|
||||
logger.info('(REPORT) HBlink reporting client sent \'CONFIG_REQ\': %s', self.transport.getPeer())
|
||||
self.send_config()
|
||||
else:
|
||||
logger.error('(REPORT) got unknown opcode')
|
||||
|
||||
class reportFactory(Factory):
|
||||
def __init__(self, config):
|
||||
self._config = config
|
||||
|
||||
def buildProtocol(self, addr):
|
||||
if (addr.host) in self._config['REPORTS']['REPORT_CLIENTS'] or '*' in self._config['REPORTS']['REPORT_CLIENTS']:
|
||||
logger.debug('(REPORT) Permitting report server connection attempt from: %s:%s', addr.host, addr.port)
|
||||
return report(self)
|
||||
else:
|
||||
logger.error('(REPORT) Invalid report server connection attempt from: %s:%s', addr.host, addr.port)
|
||||
return None
|
||||
|
||||
def send_clients(self, _message):
|
||||
for client in self.clients:
|
||||
client.sendString(_message)
|
||||
|
||||
def send_config(self):
|
||||
serialized = pickle.dumps(self._config['SYSTEMS'], protocol=2) #.decode('utf-8', errors='ignore') #pickle.HIGHEST_PROTOCOL)
|
||||
self.send_clients(b''.join([REPORT_OPCODES['CONFIG_SND'], serialized]))
|
||||
|
||||
|
||||
# ID ALIAS CREATION
|
||||
# Download
|
||||
def mk_aliases(_config):
|
||||
if _config['ALIASES']['TRY_DOWNLOAD'] == True:
|
||||
# Try updating peer aliases file
|
||||
result = try_download(_config['ALIASES']['PATH'], _config['ALIASES']['PEER_FILE'], _config['ALIASES']['PEER_URL'], _config['ALIASES']['STALE_TIME'])
|
||||
logger.info('(GLOBAL) %s', result)
|
||||
# Try updating subscriber aliases file
|
||||
result = try_download(_config['ALIASES']['PATH'], _config['ALIASES']['SUBSCRIBER_FILE'], _config['ALIASES']['SUBSCRIBER_URL'], _config['ALIASES']['STALE_TIME'])
|
||||
logger.info('(GLOBAL) %s', result)
|
||||
|
||||
# Make Dictionaries
|
||||
peer_ids = mk_id_dict(_config['ALIASES']['PATH'], _config['ALIASES']['PEER_FILE'])
|
||||
if peer_ids:
|
||||
logger.info('(GLOBAL) ID ALIAS MAPPER: peer_ids dictionary is available')
|
||||
|
||||
subscriber_ids = mk_id_dict(_config['ALIASES']['PATH'], _config['ALIASES']['SUBSCRIBER_FILE'])
|
||||
if subscriber_ids:
|
||||
logger.info('(GLOBAL) ID ALIAS MAPPER: subscriber_ids dictionary is available')
|
||||
|
||||
talkgroup_ids = mk_id_dict(_config['ALIASES']['PATH'], _config['ALIASES']['TGID_FILE'])
|
||||
if talkgroup_ids:
|
||||
logger.info('(GLOBAL) ID ALIAS MAPPER: talkgroup_ids dictionary is available')
|
||||
|
||||
return peer_ids, subscriber_ids, talkgroup_ids
|
||||
|
||||
|
||||
#************************************************
|
||||
# MAIN PROGRAM LOOP STARTS HERE
|
||||
@@ -802,7 +666,7 @@ if __name__ == '__main__':
|
||||
if cli_args.LOG_LEVEL:
|
||||
CONFIG['LOGGER']['LOG_LEVEL'] = cli_args.LOG_LEVEL
|
||||
logger = log.config_logging(CONFIG['LOGGER'])
|
||||
logger.info('\n\nCopyright (c) 2013, 2014, 2015, 2016, 2018, 2019\n\tThe Regents of the K0USY Group. All rights reserved.\n')
|
||||
logger.info('\n\nCopyright (c) 2013, 2014, 2015, 2016, 2018, 2019, 2020\n\tThe Regents of the K0USY Group. All rights reserved.\n')
|
||||
logger.debug('(GLOBAL) Logging system started, anything from here on gets logged')
|
||||
|
||||
# Set up the signal handler
|
||||
@@ -816,23 +680,15 @@ if __name__ == '__main__':
|
||||
for sig in [signal.SIGTERM, signal.SIGINT]:
|
||||
signal.signal(sig, sig_handler)
|
||||
|
||||
peer_ids, subscriber_ids, talkgroup_ids = mk_aliases(CONFIG)
|
||||
|
||||
# INITIALIZE THE REPORTING LOOP
|
||||
if CONFIG['REPORTS']['REPORT']:
|
||||
report_server = config_reports(CONFIG, reportFactory)
|
||||
else:
|
||||
report_server = None
|
||||
logger.info('(REPORT) TCP Socket reporting not configured')
|
||||
|
||||
# HBlink instance creation
|
||||
logger.info('(GLOBAL) HBlink \'HBlink.py\' -- SYSTEM STARTING...')
|
||||
for system in CONFIG['SYSTEMS']:
|
||||
if CONFIG['SYSTEMS'][system]['ENABLED']:
|
||||
if CONFIG['SYSTEMS'][system]['MODE'] == 'OPENBRIDGE':
|
||||
systems[system] = OPENBRIDGE(system, CONFIG, report_server)
|
||||
systems[system] = OPENBRIDGE(system, CONFIG)
|
||||
else:
|
||||
systems[system] = HBSYSTEM(system, CONFIG, report_server)
|
||||
systems[system] = HBSYSTEM(system, CONFIG)
|
||||
reactor.listenUDP(CONFIG['SYSTEMS'][system]['PORT'], systems[system], interface=CONFIG['SYSTEMS'][system]['IP'])
|
||||
logger.debug('(GLOBAL) %s instance created: %s, %s', CONFIG['SYSTEMS'][system]['MODE'], system, systems[system])
|
||||
|
||||
|
||||
Executable
+229
@@ -0,0 +1,229 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
###############################################################################
|
||||
# Copyright (C) 2016-2019 Cortney T. Buffington, N0MJS <n0mjs@me.com> (and Mike Zingman N4IRR)
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
###############################################################################
|
||||
|
||||
|
||||
# Python modules we need
|
||||
import sys
|
||||
from bitarray import bitarray
|
||||
from time import time, sleep
|
||||
from importlib import import_module
|
||||
|
||||
# Twisted is pretty important, so I keep it separate
|
||||
from twisted.internet.protocol import Factory, Protocol
|
||||
from twisted.protocols.basic import NetstringReceiver
|
||||
from twisted.internet import reactor, task
|
||||
|
||||
# Things we import from the main hblink module
|
||||
from hblink import HBSYSTEM, systems, hblink_handler, reportFactory, REPORT_OPCODES, config_reports, mk_aliases
|
||||
from dmr_utils3.utils import bytes_3, int_id, get_alias
|
||||
from dmr_utils3 import decode, bptc, const
|
||||
import config
|
||||
import log
|
||||
import const
|
||||
|
||||
# The module needs logging logging, but handlers, etc. are controlled by the parent
|
||||
import logging
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# Does anybody read this stuff? There's a PEP somewhere that says I should do this.
|
||||
__author__ = 'Cortney T. Buffington, N0MJS and Mike Zingman, N4IRR'
|
||||
__copyright__ = 'Copyright (c) 2016-2019 Cortney T. Buffington, N0MJS and the K0USY Group'
|
||||
__license__ = 'GNU GPLv3'
|
||||
__maintainer__ = 'Cort Buffington, N0MJS'
|
||||
__email__ = 'n0mjs@me.com'
|
||||
__status__ = 'pre-alpha'
|
||||
|
||||
# Module gobal varaibles
|
||||
|
||||
class playback(HBSYSTEM):
|
||||
|
||||
def __init__(self, _name, _config, _report):
|
||||
HBSYSTEM.__init__(self, _name, _config, _report)
|
||||
|
||||
# Status information for the system, TS1 & TS2
|
||||
# 1 & 2 are "timeslot"
|
||||
# In TX_EMB_LC, 2-5 are burst B-E
|
||||
self.STATUS = {
|
||||
1: {
|
||||
'RX_START': time(),
|
||||
'RX_SEQ': '\x00',
|
||||
'RX_RFS': '\x00',
|
||||
'TX_RFS': '\x00',
|
||||
'RX_STREAM_ID': '\x00',
|
||||
'TX_STREAM_ID': '\x00',
|
||||
'RX_TGID': '\x00\x00\x00',
|
||||
'TX_TGID': '\x00\x00\x00',
|
||||
'RX_TIME': time(),
|
||||
'TX_TIME': time(),
|
||||
'RX_TYPE': const.HBPF_SLT_VTERM,
|
||||
'RX_LC': '\x00',
|
||||
'TX_H_LC': '\x00',
|
||||
'TX_T_LC': '\x00',
|
||||
'TX_EMB_LC': {
|
||||
1: '\x00',
|
||||
2: '\x00',
|
||||
3: '\x00',
|
||||
4: '\x00',
|
||||
}
|
||||
},
|
||||
2: {
|
||||
'RX_START': time(),
|
||||
'RX_SEQ': '\x00',
|
||||
'RX_RFS': '\x00',
|
||||
'TX_RFS': '\x00',
|
||||
'RX_STREAM_ID': '\x00',
|
||||
'TX_STREAM_ID': '\x00',
|
||||
'RX_TGID': '\x00\x00\x00',
|
||||
'TX_TGID': '\x00\x00\x00',
|
||||
'RX_TIME': time(),
|
||||
'TX_TIME': time(),
|
||||
'RX_TYPE': const.HBPF_SLT_VTERM,
|
||||
'RX_LC': '\x00',
|
||||
'TX_H_LC': '\x00',
|
||||
'TX_T_LC': '\x00',
|
||||
'TX_EMB_LC': {
|
||||
1: '\x00',
|
||||
2: '\x00',
|
||||
3: '\x00',
|
||||
4: '\x00',
|
||||
}
|
||||
}
|
||||
}
|
||||
self.CALL_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]
|
||||
_bits = _data[15]
|
||||
if _call_type == 'group':
|
||||
|
||||
# Is this is a new call stream?
|
||||
if (_stream_id != self.STATUS[_slot]['RX_STREAM_ID']):
|
||||
self.STATUS['RX_START'] = pkt_time
|
||||
logger.info('(%s) *START RECORDING* STREAM ID: %s SUB: %s (%s) REPEATER: %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)
|
||||
self.CALL_DATA.append(_data)
|
||||
self.STATUS[_slot]['RX_STREAM_ID'] = _stream_id
|
||||
return
|
||||
|
||||
# Final actions - Is this a voice terminator?
|
||||
if (_frame_type == const.HBPF_DATA_SYNC) and (_dtype_vseq == const.HBPF_SLT_VTERM) and (self.STATUS[_slot]['RX_TYPE'] != const.HBPF_SLT_VTERM) and (self.CALL_DATA):
|
||||
call_duration = pkt_time - self.STATUS['RX_START']
|
||||
self.CALL_DATA.append(_data)
|
||||
logger.info('(%s) *END RECORDING* STREAM ID: %s', self._system, int_id(_stream_id))
|
||||
sleep(2)
|
||||
logger.info('(%s) *START PLAYBACK* STREAM ID: %s SUB: %s (%s) REPEATER: %s (%s) TGID %s (%s), TS %s, Duration: %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, call_duration)
|
||||
for i in self.CALL_DATA:
|
||||
self.send_system(i)
|
||||
#print(i)
|
||||
sleep(0.06)
|
||||
self.CALL_DATA = []
|
||||
logger.info('(%s) *END PLAYBACK* STREAM ID: %s', self._system, int_id(_stream_id))
|
||||
|
||||
else:
|
||||
if self.CALL_DATA:
|
||||
self.CALL_DATA.append(_data)
|
||||
|
||||
|
||||
# Mark status variables for use later
|
||||
self.STATUS[_slot]['RX_RFS'] = _rf_src
|
||||
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
|
||||
|
||||
|
||||
#************************************************
|
||||
# MAIN PROGRAM LOOP STARTS HERE
|
||||
#************************************************
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
import argparse
|
||||
import sys
|
||||
import os
|
||||
import signal
|
||||
from dmr_utils3.utils import try_download, mk_id_dict
|
||||
|
||||
# Change the current directory to the location of the application
|
||||
os.chdir(os.path.dirname(os.path.realpath(sys.argv[0])))
|
||||
|
||||
# CLI argument parser - handles picking up the config file from the command line, and sending a "help" message
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('-c', '--config', action='store', dest='CONFIG_FILE', help='/full/path/to/config.file (usually hblink.cfg)')
|
||||
parser.add_argument('-l', '--logging', action='store', dest='LOG_LEVEL', help='Override config file logging level.')
|
||||
cli_args = parser.parse_args()
|
||||
|
||||
# Ensure we have a path for the config file, if one wasn't specified, then use the default (top of file)
|
||||
if not cli_args.CONFIG_FILE:
|
||||
cli_args.CONFIG_FILE = os.path.dirname(os.path.abspath(__file__))+'/hblink.cfg'
|
||||
|
||||
# Call the external routine to build the configuration dictionary
|
||||
CONFIG = config.build_config(cli_args.CONFIG_FILE)
|
||||
|
||||
# Start the system logger
|
||||
if cli_args.LOG_LEVEL:
|
||||
CONFIG['LOGGER']['LOG_LEVEL'] = cli_args.LOG_LEVEL
|
||||
logger = log.config_logging(CONFIG['LOGGER'])
|
||||
logger.info('\n\nCopyright (c) 2013, 2014, 2015, 2016, 2018, 2019\n\tThe Founding Members of the K0USY Group. All rights reserved.\n')
|
||||
logger.debug('Logging system started, anything from here on gets logged')
|
||||
|
||||
# Set up the signal handler
|
||||
def sig_handler(_signal, _frame):
|
||||
logger.info('SHUTDOWN: HBROUTER IS TERMINATING WITH SIGNAL %s', str(_signal))
|
||||
hblink_handler(_signal, _frame)
|
||||
logger.info('SHUTDOWN: ALL SYSTEM HANDLERS EXECUTED - STOPPING REACTOR')
|
||||
reactor.stop()
|
||||
|
||||
# Set signal handers so that we can gracefully exit if need be
|
||||
for sig in [signal.SIGTERM, signal.SIGINT]:
|
||||
signal.signal(sig, sig_handler)
|
||||
|
||||
# ID ALIAS CREATION
|
||||
# Download
|
||||
if CONFIG['ALIASES']['TRY_DOWNLOAD'] == True:
|
||||
# Try updating peer aliases file
|
||||
result = try_download(CONFIG['ALIASES']['PATH'], CONFIG['ALIASES']['PEER_FILE'], CONFIG['ALIASES']['PEER_URL'], CONFIG['ALIASES']['STALE_TIME'])
|
||||
logger.info(result)
|
||||
# Try updating subscriber aliases file
|
||||
result = try_download(CONFIG['ALIASES']['PATH'], CONFIG['ALIASES']['SUBSCRIBER_FILE'], CONFIG['ALIASES']['SUBSCRIBER_URL'], CONFIG['ALIASES']['STALE_TIME'])
|
||||
logger.info(result)
|
||||
|
||||
# Create the name-number mapping dictionaries
|
||||
peer_ids, subscriber_ids, talkgroup_ids = mk_aliases(CONFIG)
|
||||
|
||||
# INITIALIZE THE REPORTING LOOP
|
||||
report_server = config_reports(CONFIG, reportFactory)
|
||||
|
||||
# HBlink instance creation
|
||||
logger.info('HBlink \'playback.py\' (c) 2017-2019 Cort Buffington, N0MJS & Mike Zingman, N4IRR -- SYSTEM STARTING...')
|
||||
for system in CONFIG['SYSTEMS']:
|
||||
if CONFIG['SYSTEMS'][system]['ENABLED']:
|
||||
if CONFIG['SYSTEMS'][system]['MODE'] == 'OPENBRIDGE':
|
||||
logger.critical('%s FATAL: Instance is mode \'OPENBRIDGE\', \n\t\t...Which would be tragic for playback, since it carries multiple call\n\t\tstreams simultaneously. playback.py onlyl works with MMDVM-based systems', system)
|
||||
sys.exit('playback.py cannot function with systems that are not MMDVM devices. System {} is configured as an OPENBRIDGE'.format(system))
|
||||
else:
|
||||
systems[system] = playback(system, CONFIG, report_server)
|
||||
reactor.listenUDP(CONFIG['SYSTEMS'][system]['PORT'], systems[system], interface=CONFIG['SYSTEMS'][system]['IP'])
|
||||
logger.debug('%s instance created: %s, %s', CONFIG['SYSTEMS'][system]['MODE'], system, systems[system])
|
||||
|
||||
reactor.run()
|
||||
Executable
+16
@@ -0,0 +1,16 @@
|
||||
BRIDGES = {
|
||||
'1/2': [
|
||||
{'SYSTEM': '444.750', 'TS': 1, 'TGID': 2, 'ACTIVE': True, 'TIMEOUT': 5,'TO_TYPE': 'NONE', 'ON': [], 'OFF': [], 'RESET': []},
|
||||
{'SYSTEM': 'OBP', 'TS': 1, 'TGID': 2, 'ACTIVE': True, 'TIMEOUT': 5,'TO_TYPE': 'NONE', 'ON': [], 'OFF': [], 'RESET': []}
|
||||
],
|
||||
'KANSAS': [
|
||||
{'SYSTEM': '444.750', 'TS': 2, 'TGID': 3120, 'ACTIVE': True, 'TIMEOUT': 5,'TO_TYPE': 'NONE', 'ON': [], 'OFF': [], 'RESET': []},
|
||||
{'SYSTEM': 'OBP', 'TS': 1, 'TGID': 3120, 'ACTIVE': True, 'TIMEOUT': 5,'TO_TYPE': 'NONE', 'ON': [], 'OFF': [], 'RESET': []}
|
||||
]
|
||||
}
|
||||
|
||||
UNIT = ['444.750', 'OBP']
|
||||
|
||||
if __name__ == '__main__':
|
||||
from pprint import pprint
|
||||
pprint(BRIDGES)
|
||||
Executable
+16
@@ -0,0 +1,16 @@
|
||||
BRIDGES = {
|
||||
'1/2': [
|
||||
{'SYSTEM': '444.800', 'TS': 1, 'TGID': 2, 'ACTIVE': True, 'TIMEOUT': 5,'TO_TYPE': 'NONE', 'ON': [], 'OFF': [], 'RESET': []},
|
||||
{'SYSTEM': 'OBP', 'TS': 1, 'TGID': 2, 'ACTIVE': True, 'TIMEOUT': 5,'TO_TYPE': 'NONE', 'ON': [], 'OFF': [], 'RESET': []}
|
||||
],
|
||||
'KANSAS': [
|
||||
{'SYSTEM': '444.800', 'TS': 2, 'TGID': 3120, 'ACTIVE': True, 'TIMEOUT': 5,'TO_TYPE': 'NONE', 'ON': [], 'OFF': [], 'RESET': []},
|
||||
{'SYSTEM': 'OBP', 'TS': 1, 'TGID': 3120, 'ACTIVE': True, 'TIMEOUT': 5,'TO_TYPE': 'NONE', 'ON': [], 'OFF': [], 'RESET': []}
|
||||
]
|
||||
}
|
||||
|
||||
UNIT = ["444.800", "OBP"]
|
||||
|
||||
if __name__ == '__main__':
|
||||
from pprint import pprint
|
||||
pprint(BRIDGES)
|
||||
@@ -47,6 +47,18 @@ BRIDGES = {
|
||||
]
|
||||
}
|
||||
|
||||
'''
|
||||
list the names of each system that should bridge unit to unit (individual) calls.
|
||||
'''
|
||||
|
||||
UNIT = ['ONE', 'TWO']
|
||||
|
||||
'''
|
||||
This is for testing the syntax of the file. It won't eliminate all errors, but running this file
|
||||
like it were a Python program itself will tell you if the syntax is correct!
|
||||
'''
|
||||
|
||||
if __name__ == '__main__':
|
||||
from pprint import pprint
|
||||
pprint(BRIDGES)
|
||||
print(UNIT)
|
||||
|
||||
Regular → Executable
Reference in New Issue
Block a user