diff --git a/.gitignore b/.gitignore index 2222747..f51ac60 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,14 @@ *.o *.d .vscode -*.blacklist -*.whitelist -*.interlink -*.terminal -*.service -xlxd -xrfd +./*.blacklist +./*.whitelist +./*.interlink +./*.terminal +./*.service +configure.mk +configure.h +reflector.cfg +src/xlxd +src/xrfd +ambed/ambed diff --git a/ambed/Makefile b/ambed/Makefile index 642b1cf..bab087d 100644 --- a/ambed/Makefile +++ b/ambed/Makefile @@ -1,11 +1,6 @@ #copyright(C) 2020 by Thomas A. Early, N7TAE -################################################################# -# Here is the only things you might need to change -ip = 127.0.0.1 -# set to true for debugging support -debug = false -################################################################# +include configure.mk # If you are going to change this path, you will # need to update the systemd service script @@ -16,18 +11,16 @@ GCC = g++ # uncomment the next line to enable gdb debugging help #DEBUG=true -CFLAGS = -W -MMD -MD -std=c++11 ifeq ($(debug), true) -CFLAGS+=-ggdb3 +CFLAGS = -ggdb3 -W -MMD -MD -std=c++11 +else +CFLAGS = -W -MMD -MD -std=c++11 endif -CFLAGS += -DIP_ADDR=\"$(ip)\" - LDFLAGS = -pthread -SRCS = cagc.cpp cbuffer.cpp cfirfilter.cpp cip.cpp csignalprocessor.cpp cusb3003hrinterface.cpp cvocodecchannel.cpp cvoicepacket.cpp cambepacket.cpp ccallsign.cpp cfixedgain.cpp cpacket.cpp cstream.cpp cusb3000interface.cpp cusb3003interface.cpp cvocodecinterface.cpp main.cpp cambeserver.cpp ccontroller.cpp cftdidevicedescr.cpp cpacketqueue.cpp ctimepoint.cpp cusb3003df2etinterface.cpp cusb3xxxinterface.cpp cvocodecs.cpp cudpsocket.cpp - +SRCS = $(wildcard *.cpp) OBJS = $(SRCS:.cpp=.o) DEPS = $(SRCS:.cpp=.d) EXE = ambed diff --git a/ambed/main.cpp b/ambed/main.cpp index 6fede91..23e3666 100644 --- a/ambed/main.cpp +++ b/ambed/main.cpp @@ -23,23 +23,20 @@ // along with Foobar. If not, see . // ---------------------------------------------------------------------------- +#include + +#include "configure.h" #include "main.h" #include "ctimepoint.h" #include "cambeserver.h" -#include - //////////////////////////////////////////////////////////////////////////////////////// // function declaration -#ifndef IP_ADDR -#define IP_ADDR "127.0.0.1" -#endif - int main() { // initialize ambeserver - g_AmbeServer.SetListenIp(IP_ADDR); + g_AmbeServer.SetListenIp(TRANSCODER_IP); // and let it run std::cout << "Starting AMBEd " << VERSION_MAJOR << "." << VERSION_MINOR << "." << VERSION_REVISION << std::endl << std::endl; diff --git a/install b/install deleted file mode 100755 index ca842e3..0000000 --- a/install +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -cd ambed -make install - -cd ../src -make install - -cd .. diff --git a/radmin b/radmin new file mode 100755 index 0000000..8809601 --- /dev/null +++ b/radmin @@ -0,0 +1,183 @@ +#!/bin/bash +# +# Copyright (c) 2020 by Thomas A. Early N7TAE +# +# 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 2 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, see . + +UninstallReflector () { + if [ -e $xlxserv ] || [ -e $xrfserv ]; then + cd src + sudo make uninstall + cd .. + fi + if [ -e /etc/systemd/system/ambed ]; then + cd ambed + sudo make uninstall + cd .. + fi +} + +InstallReflector () { + if [ "$tcaddress" != none ]; then + cd ambed + sudo make install + cd .. + fi + cd src + if [[ "$callsign" == XLX* ]]; then + if [ ! -e xlxd.whitelist ]; then + echo "Making default whitelist" + cp ../config/xlxd.whitelist . + fi + if [ ! -e xlxd.blacklist ]; then + echo "Making default blacklist" + cp ../config/xlxd.blacklist . + fi + if [ ! -e xlxd.interlink ]; then + echo "Making default interlink" + cp ../config/xlxd.whitelist . + fi + if [[ ${g3support:-$g3support_d} == true ]] && [ ! -e xlxd.terminal ]; then + echo "Making default g3 terminal" + cp ../config/xlxd.terminal . + fi + else + if [ ! -e xrfd.whitelist ]; then + echo "Making default whitelist" + cp ../config/xlxd.whitelist xrfd.whitelist + fi + if [ ! -e xrfd.blacklist ]; then + echo "Making default blacklist" + cp ../config/xlxd.blacklist xrfd.blacklist + fi + if [ ! -e xrfd.interlink ]; then + echo "Making default interlink" + cp ../config/xlxd.whitelist xrfd.interlink + fi + if [[ ${g3support:-$g3support_d} == true ]] && [ ! -e xrfd.terminal ]; then + echo "Making default g3 terminal" + cp ../config/xlxd.terminal xrfd.terminal + fi + fi + sudo make install + cd .. +} + +Clean () { + cd src + make clean + cd ../ambed + make clean + cd .. +} + +Compile () { + local np + WriteCFGFiles + np=`cat /proc/cpuinfo | grep "model name" | wc -l` + cd src + make -j$np + cd .. + if [[ "$callsign" == XLX* ]] && [[ "$tcaddress" != none ]]; then + cd ambed + make -j$np + cd .. + fi +} + +# Execution starts here! + +# file locations +rcfg='reflector.cfg' +srch='src/configure.h' +srcm='src/configure.mk' +ambh='ambed/configure.h' +ambm='ambed/configure.mk' +xlxserv='/etc/systemd/system/xlxd.service' +xrfserv='/etc/systemd/system/xrfd.service' + +# default values +callsign='CHNGME' +nummod=26 +ip4addr='none' +ip6addr='none' +tcaddress='none' +tcmodules='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +g3support=true +dbsupport=false + +if [ -e reflector.cfg ]; then + source reflector.cfg +else + echo 'No configuration file found...' + exit 1 +fi +key='x' +# main loop +while [[ "$key" != q* ]] +do + clear + echo + echo " Reflector Administration, Version #200712" + echo + echo "ls : List configuration file" + if [ -e $xlxserv ] || [ -e $xrfserv ]; then + if [ -e $xlxserv ] && [ -e $xrfserv ]; then + echo "ERROR: both xlxd and xrfd seem to be installed!" + exit 1 + elif [ -e $xlxserv ]; then + echo "us : Uninstall XLX reflector" + elif [ -e $xrfserv ]; then + echo "us : Uninstall XRF reflector" + fi + echo "rr : Restart reflector" + echo "rt : Restart transcoder" + else + echo "cl : Clean objects and executables" + echo "co : Compile executable(s)" + if [[ "$callsign" == XRF* ]] || [[ "$callsign" == XLX* ]]; then + if [[ "$callsign" == XRF* ]] && [ -e src/xrfd ]; then + echo "is : Install XRF reflector" + elif [[ "$callsign" == XLX* ]] && [ -e src/xlxd ]; then + if [[ "$tcaddress" == none ]]; then + echo "is : Install XLX reflector without transcoder" + else + if [ -e ambed/ambed ]; then + echo "is : Install XLX reflector and transcoder" + fi + fi + fi + fi + fi + echo + echo "q : Quit" + echo "u : Unset the value of (revert to the default value)." + read -p "Please input - omit value to toggle a true/false : " key value + + if [[ "$key" == ls* ]]; then + cat reflector.cfg; + read -p "Enter to return: " ans + elif [[ "$key" == us* ]]; then UninstallReflector + elif [[ "$key" == is* ]]; then InstallReflector + elif [[ "$key" == rr* ]]; then + if [[ "$callsign" == XLX* ]] + then sudo systemctl restart xlxd + else sudo systemctl restart xrfd + fi + elif [[ "$key" == rt* ]]; then sudo systemctl restart ambed + elif [[ "$key" == cl* ]]; then Clean + elif [[ "$key" == co* ]]; then Compile + fi +done +exit 0 diff --git a/rconfig b/rconfig new file mode 100755 index 0000000..2f96da0 --- /dev/null +++ b/rconfig @@ -0,0 +1,257 @@ +#!/bin/bash +# +# Copyright (c) 2020 by Thomas A. Early N7TAE +# +# 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 2 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, see . + +SetBooleanValue () { + local dvname + local cv + if [ -z $2 ]; then + if [ -z ${!1+x} ]; then + if [[ "$1" == module_[abc]_* ]]; then + echo matches + dvname=${1//_[abc]_/_x_} + else + echo does not match + dvname=${1}_d + fi + cv=${!dvname} + else + cv=${!1} + fi + if [[ $cv == [tT]* ]]; then + eval ${1}=false + else + eval ${1}=true + fi + elif [[ "$2" == [tT]* ]]; then + eval ${1}=true + else + eval ${1}=false + fi +} + +EvaluateVar () { + if [ -z ${!1+x} ]; then + if [ -z "${!2}" ]; then + echo "'' " + else + echo "${!2} " + fi + else + if [ -z "${!1}" ]; then + echo "''" + else + echo "${!1}" + fi + fi +} + +WriteMemFile () { + local file + file="$rcfg" + echo "# created on `date`" > $file + [ -z ${callsign+x} ] || echo "callsign='$callsign'" >> $file + [ -z ${nummod+x} ] || echo "nummod=$nummod" >> $file + [ -z ${ip4addr+x} ] || echo "ip4addr='$ip4addr'" >> $file + [ -z ${ip6addr+x} ] || echo "ip6addr='$ip6addr'" >> $file + [ -z ${tcaddress+x} ] || echo "tcaddress='$tcaddress'" >> $file + [ -z ${tcmodules+x} ] || echo "tcmodules='$tcmodules'" >> $file + [ -z ${g3support+x} ] || echo "g3support=$g3support" >> $file + [ -z ${dbsupport+x} ] || echo "dbsupport=$dbsupport" >> $file + echo "===========${file}=============" + cat $file +} + +WriteSRCHFile () { + local file + file="$srch" + echo "// Created on `date`" > $file + echo "#define CALLSIGN \"${callsign}\"" >> $file + if [[ "$callsign" == XRF* ]]; then + echo "#define NO_XLX" >> $file + fi + if [ -z ${nummod+x} ]; then + echo "#define NB_OF_MODULES ${nummod_d}" >> $file + else + echo "#define NB_OF_MODULES ${nummod}" >> $file + fi + [ -z ${ip4addr+x} ] || echo "#define LISTEN_IPV4 \"${ip4addr}\"" >> $file + [ -z ${ip6addr+x} ] || echo "#define LISTEN_IPV6 \"${ip6addr}\"" >> $file + if [ ! -z ${tcaddress+x} ]; then + echo "#define TRANSCODER_IP \"${tcaddress}\"" >> $file + if [ -z ${tcmodules+x} ]; then + echo "#define TRANSCODED_MODULES \"${tcmodules_d}\"" >> $file + else + echo "#define TRANSCODED_MODULES \"${tcmodules}\"" >> $file + fi + fi + if [ -z ${g3support+x} ]; then + m=${g3support_d} + else + m=${g3support} + fi + [ $m ] || echo "#define NO_G3" >> $file +} + +WriteSRCMKFile () { + local file + file="$srcm" + echo "# Created on `date`" > $file + if [[ "$callsign" == XLX* ]]; then + echo "is_xlx = true" >> $file + else + echo "is_xlx = false" >> $file + fi + [ -z ${ip4addr+x} ] || echo "ipv4 = $ip4addr" >> $file + [ -z ${ip6addr+x} ] || echo "ipv6 = $ip6addr" >> $file + [ -z ${tcaddress+x} ] || echo "tc_ip = $tcaddress" >> $file + if [ -z ${g3support+x} ]; then + echo "use_g3 = $g3support_d" >> $file + else + echo "use_g3 = $g3support" >> $file + fi + if [ -z ${dbsupport+x} ]; then + echo "debug = $dbsupport_d" >> $file + else + echo "debug = $dbsupport" >> $file + fi +} + +WriteAmbeHFile () { + local file + file="$ambh" + echo "// Created on `date`" > $file + echo "#define TRANSCODER_IP \"${tcaddress}\"" >> $file +} + +WriteAmbeMKFile () { + local file + file="$ambm" + echo "# created on `date`" > $file + if [ -z ${dbsupport+x} ]; then + echo "debug = $dbsupport_d" >> $file + else + echo "debug = $dbsupport" >> $file + fi +} + +WriteCFGFiles () { + WriteMemFile + WriteSRCHFile + WriteSRCMKFile + if [ -z ${tcaddress+x} ]; then + rm -f $ambh $ambm + else + WriteAmbeHFile + WriteAmbeMKFile + fi +} + +ListCFGFiles () +{ + echo "===========${srch}=============" + cat $srch + echo "===========${srcm}=============" + cat $srcm + if [ ! -z ${tcaddress+x} ]; then + echo "===========${ambh}=============" + cat $ambh + echo "===========${ambm}=============" + cat $ambm + fi + read -p "Press to continue: " ans +} + +# Execution starts here! +# file locations +rcfg='reflector.cfg' +srch='src/configure.h' +srcm='src/configure.mk' +ambh='ambed/configure.h' +ambm='ambed/configure.mk' +# default values +callsign_d='CHNGME' +nummod_d=26 +ip4addr_d='none' +ip6addr_d='none' +tcaddress_d='none' +tcmodules_d='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +g3support_d=true +dbsupport_d=false + +if [ -e reflector.cfg ]; then + source reflector.cfg +else + echo 'No configuration file found...' + sleep 1 +fi +key='x' +# main loop +while [[ "$key" != q* ]] +do + clear + echo + echo " Reflector Configuration, Version #200712" + echo + echo -n "cs : Reflector Callsign = "; EvaluateVar callsign{,_d} + echo -n "nm : Number of Modules = "; EvaluateVar nummod{,_d} + echo -n "i4 : IPv4 Listen Address = "; EvaluateVar ip4addr{,_d} + echo -n "i6 : IPv6 Listen Address = "; EvaluateVar ip6addr{,_d} + if [[ "$callsign" == XLX* ]]; then + echo -n "tc : Transcoder Address = "; EvaluateVar tcaddress{,_d} + if [ ! -z ${tcaddress+x} ]; then + echo -n "tm : Transcoder Modules = "; EvaluateVar tcmodules{,_d} + fi + fi + echo -n "g3 : Icom G3 Support = "; EvaluateVar g3support{,_d} + echo -n "db : Debugging Support = "; EvaluateVar dbsupport{,_d} + if [[ "$callsign" == XLX* ]] || [[ "$callsign" == XRF* ]]; then + echo "w : Write configuration filess (overwrites any existing files)" + fi + echo + echo "q : Quit" + echo "u : Unset the value of (revert to the default value)." + read -p "Please input - omit value to toggle a true/false : " key value + + if [[ "$key" == cs* ]]; then + callsign="${value^^}" + callsign="${callsign:0:6}" + if [[ "$callsign" == REF* ]]; then + unset tcaddress tcmodules + fi + elif [[ "$key" == nm* ]]; then nummod="$value" + elif [[ "$key" == i4* ]]; then ip4addr="$value" + elif [[ "$key" == i6* ]]; then ip6addr="$value" + elif [[ "$key" == tc* ]]; then tcaddress="$value" + elif [[ "$key" == tm* ]]; then tcmodules="${value^^}" + elif [[ "$key" == g3* ]]; then SetBooleanValue g3support "$value" + elif [[ "$key" == db* ]]; then SetBooleanValue dbsupport "$value" + elif [[ "$key" == w* ]]; then + WriteCFGFiles + ListCFGFiles + elif [[ "$key" == u* ]]; then + if [[ "$value" == cs* ]]; then unset callsign + elif [[ "$value" == nm* ]]; then unset nummod + elif [[ "$value" == i4* ]]; then unset ip4addr + elif [[ "$value" == i6* ]]; then unset ip6addr + elif [[ "$value" == tc* ]]; then unset tcaddress + elif [[ "$value" == tm* ]]; then unset tcmodules + elif [[ "$value" == g3* ]]; then unset g3support + elif [[ "$value" == db* ]]; then unset dbsupport + fi + fi +done +exit 0 diff --git a/src/Makefile b/src/Makefile index 8e8c356..5645404 100644 --- a/src/Makefile +++ b/src/Makefile @@ -18,45 +18,7 @@ # if you change these locations, make sure the sgs.service file is updated! # you will also break hard coded paths in the dashboard file, index.php. -################## This is the part you can safely edit ####################### - -#### Callsign -# For an xlxd reflector, use XLX???, where ??? is an unused number. -# For an xrfd reflector, use XRF???, where ??? is an unused number. -callsign = XLX797 - -# set it to false for a DStar-only xrf reflector (instead of xlx) -is_xlx = true - -# how many modules? -nb_of_modules = 26 - -#### IP Bindings -# IPv4 - comment out the next line for no IPV4 support -ipv4 = 10.1.10.61 - -# IPv6 - comment out the next line for no IPv6 support -ipv6 = any - -ifeq ($(is_xlx), true) -# We are only concerned with the transcoder if we are building an XLX -# Comment out the next line if there is no transcoder on an XLX build -tc_ip = 127.0.0.1 - -ifdef tc_ip -# Which modules will be transcoded? (A through Z) -tc_mods = ABCDEFGHIJKLMNOPQRSTUVWXYZ -endif - -endif - -# Set it to false for no G3 support -use_g3 = true - -# Set it to true for debugging support -debug = false - -############################################################################### +include configure.mk # if you make changed in these two variable, you'll need to change things # in the main.h file as well as the systemd service file. @@ -67,29 +29,9 @@ DATADIR = /var/lib/xlxd CC = g++ ifeq ($(debug), true) -CFLAGS = -ggdb3 -W -c -std=c++11 -MMD -MD -c -DNB_OF_MODULES=$(nb_of_modules) -DCALLSIGN=\"$(callsign)\" +CFLAGS = -ggdb3 -W -c -std=c++11 -MMD -MD -c else -CFLAGS = -c -W -std=c++11 -MMD -MD -c -DNB_OF_MODULES=$(nb_of_modules) -DCALLSIGN=\"$(callsign)\" -endif - -ifdef ipv4 -CFLAGS += -DLISTEN_IPV4=\"$(ipv4)\" -endif - -ifdef ipv6 -CFLAGS += -DLISTEN_IPV6=\"$(ipv6)\" -endif - -ifdef tc_ip -CFLAGS += -DTRANSCODER_IP=\"$(tc_ip)\" -DTRANSCODED_MODULES=\"$(tc_mods)\" -endif - -ifneq ($(is_xlx), true) -CFLAGS += -DNO_XLX -endif - -ifneq ($(use_g3), true) -CFLAGS += -DNO_G3 +CFLAGS = -c -W -std=c++11 -MMD -MD -c endif LDFLAGS=-pthread diff --git a/src/main.h b/src/main.h index 49a16ac..f7095f1 100644 --- a/src/main.h +++ b/src/main.h @@ -44,21 +44,11 @@ #include #include +#include "configure.h" + //////////////////////////////////////////////////////////////////////////////////////// // defines -// this is just for any "smart" editor, so everything will be "on" -#if ! defined(LISTEN_IPV4) && ! defined(LISTEN_IPV6) && ! defined(CALLSIGN) -#define CALLSIGN "XLX797" -#define LISTEN_IPV4 "10.1.10.61" -#define LISTEN_IPV6 "::" -#define TRANSCODER_IP "127.0.0.1" -#endif - -#ifndef TRANSCODED_MODULES -#define TRANSCODED_MODULES "ABCDEFGHIJKLMNOPQRSTUVWXYZ" -#endif - //// Module configuration #define DSTAR_IPV4 true #define DMR_IPV4 true @@ -85,17 +75,6 @@ //#define DEBUG_NO_ERROR_ON_XML_OPEN_FAIL //#define DEBUG_DUMPFILE -// system constants --------------------------------------------- - -#ifndef NB_OF_MOUDLES -#define NB_OF_MODULES 26 -#endif -#if NB_OF_MODULES < 1 -#define NB_OF_MODULES 1 -#elif NB_OF_MODULES > 26 -#define NB_OF_MODULES 26 -#endif - // protocols --------------------------------------------------- #define NB_OF_PROTOCOLS 8 diff --git a/uninstall b/uninstall deleted file mode 100755 index da87e8b..0000000 --- a/uninstall +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -cd ambed -make uninstall - -cd ../src -make uninstall - -cd ..