From a22b4d1d5166ed39a8af5359eba3c595c28144b3 Mon Sep 17 00:00:00 2001 From: Tom Early Date: Fri, 21 Aug 2020 12:18:26 -0700 Subject: [PATCH] protocol specific IP address overrides --- README.md | 4 +- rconfig | 229 +++++++++++++++++++++++++++++++++----- src/Makefile | 2 +- src/ccodecstream.cpp | 6 +- src/cdcsprotocol.cpp | 4 +- src/cdcsprotocol.h | 2 +- src/cdextraprotocol.cpp | 4 +- src/cdextraprotocol.h | 2 +- src/cdmrmmdvmprotocol.cpp | 4 +- src/cdmrmmdvmprotocol.h | 2 +- src/cdmrplusprotocol.cpp | 4 +- src/cdmrplusprotocol.h | 2 +- src/cdplusprotocol.cpp | 4 +- src/cdplusprotocol.h | 2 +- src/cg3protocol.cpp | 7 +- src/cg3protocol.h | 2 +- src/cprotoaddress.cpp | 100 +++++++++++++++++ src/cprotoaddress.h | 46 ++++++++ src/cprotocol.cpp | 9 +- src/cprotocol.h | 2 +- src/cprotocols.cpp | 16 +-- src/creflector.h | 20 +--- src/ctranscoder.cpp | 6 +- src/cxlxprotocol.cpp | 4 +- src/cxlxprotocol.h | 2 +- src/cysfprotocol.cpp | 4 +- src/cysfprotocol.h | 2 +- src/main.cpp | 23 +--- src/main.h | 2 - 29 files changed, 405 insertions(+), 111 deletions(-) create mode 100644 src/cprotoaddress.cpp create mode 100644 src/cprotoaddress.h diff --git a/README.md b/README.md index d3897f1..a11e13a 100644 --- a/README.md +++ b/README.md @@ -78,7 +78,9 @@ Configuring, compiling and maintaining your reflector build is easy! Start the c ./rconfig ``` -There are only a few things that need to be specified. Most important are, the reflector callsign and the IP addresses for the IPv4 and IPv6 listen ports and a transcoder port, if there is a transcoder. Dual-stack operation is enabled by specifying both an IPv4 and IPv6 address. IPv6-only single stack can be specified by leaving the IPv6 address set to `none`. It's even possible to operate in an IPv6-only configuration by leaving the IPv4 address to the default `none`. Obviously the transcoder is only specified for an XLX reflector. If you are building an XLX system with a transcoder, you can also specify which channels get transcoder support. There are also true/false flags to prevent G3 support and so that you can build executables that will support gdb debugging. +There are only a few things that need to be specified. Most important are, the reflector callsign and the IP addresses for the IPv4 and IPv6 listen ports and a transcoder port, if there is a transcoder. Dual-stack operation is enabled by specifying both an IPv4 and IPv6 address. IPv6-only single stack can be specified by leaving the IPv6 address set to `none`. It's even possible to operate in an IPv6-only configuration by leaving the IPv4 address to the default `none`. You can override the ip addresses for any of the supported protocol and this is done in a sub-menu. This would allow you to install other Ham-related services that might use the same ports, like a Smart Group Server. + +Obviously the transcoder is only specified for an XLX reflector. If your reflector is configured with a transcoder, you can specify which configured modules will be transcoded. If you are building an XLX system with a transcoder, you can also specify which channels get transcoder support. There are also true/false flags to prevent G3 support and so that you can build executables that will support gdb debugging. You can support your own YSF frequency database. This is very useful for hot-spots that use YSF linking. These linked hot-spots can then use the *WiresX* command on their radios to be able to connect to any configured XLX module. Users can register their TX and RX frequency (typically the same for most hot-spot configurations) on http:<*xlx url*>/wiresx/login.php. Once their hot-spot is registered, XLX will return the correct frequency for their hot-spot when a *WiresX* command is sent to the reflector. You'll need to enable YSF auto-linking, specify a default module and define a database name, user and user password. When you write you XLX configuration, a database **configure.sql** script will be built to not only create the database and database user, but also the table for the hot-spot frequency data. diff --git a/rconfig b/rconfig index f99cf6c..fa335e8 100755 --- a/rconfig +++ b/rconfig @@ -15,7 +15,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -SetBooleanValue () { +SetBooleanValue () +{ local dvname local cv if [ -z $2 ]; then @@ -43,7 +44,8 @@ SetBooleanValue () { fi } -EvaluateVar () { +EvaluateVar () +{ if [ -z ${!1+x} ]; then if [ -z "${!2}" ]; then echo "'' " @@ -59,7 +61,8 @@ EvaluateVar () { fi } -WriteMemFile () { +WriteMemFile () +{ local file file="$rcfg" echo "# created on `date`" > $file @@ -67,6 +70,22 @@ WriteMemFile () { [ -z ${nummod+x} ] || echo "nummod=$nummod" >> $file [ -z ${ip4addr+x} ] || echo "ip4addr='$ip4addr'" >> $file [ -z ${ip6addr+x} ] || echo "ip6addr='$ip6addr'" >> $file + [ -z ${refv4addr+x} ] || echo "refv4addr='$refv4addr'" >> $file + [ -z ${refv6addr+x} ] || echo "refv6addr='$refv6addr'" >> $file + [ -z ${dcsv4addr+x} ] || echo "dcsv4addr='$dcsv4addr'" >> $file + [ -z ${dcsv6addr+x} ] || echo "dcsv6addr='$dcsv6addr'" >> $file + [ -z ${xrfv4addr+x} ] || echo "xrfv4addr='$xrfv4addr'" >> $file + [ -z ${xrfv6addr+x} ] || echo "xrfv6addr='$xrfv6addr'" >> $file + [ -z ${g3_v4addr+x} ] || echo "g3_v4addr='$g3_v4addr'" >> $file +# [ -z ${g3_v6addr+x} ] || echo "g3_v6addr='$g3_v6addr'" >> $file + [ -z ${dmrv4addr+x} ] || echo "dmrv4addr='$dmrv4addr'" >> $file + [ -z ${dmrv6addr+x} ] || echo "dmrv6addr='$dmrv6addr'" >> $file + [ -z ${dmpv4addr+x} ] || echo "dmpv4addr='$dmpv4addr'" >> $file + [ -z ${dmpv6addr+x} ] || echo "dmpv6addr='$dmpv6addr'" >> $file + [ -z ${ysfv4addr+x} ] || echo "ysfv4addr='$ysfv4addr'" >> $file + [ -z ${ysfv6addr+x} ] || echo "ysfv6addr='$ysfv6addr'" >> $file + [ -z ${xlxv4addr+x} ] || echo "xlxv4addr='$xlxv4addr'" >> $file + [ -z ${xlxv6addr+x} ] || echo "xlxv6addr='$xlxv6addr'" >> $file [ -z ${tcaddress+x} ] || echo "tcaddress='$tcaddress'" >> $file [ -z ${tcmodules+x} ] || echo "tcmodules='$tcmodules'" >> $file [ -z ${ysfautolink+x} ] || echo "ysfautolink=$ysfautolink" >> $file @@ -79,7 +98,8 @@ WriteMemFile () { [ -z ${dbsupport+x} ] || echo "dbsupport=$dbsupport" >> $file } -WriteSRCHFile () { +WriteSRCHFile () +{ local file m file="$srch" echo "// Created on `date`" > $file @@ -92,14 +112,62 @@ WriteSRCHFile () { 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 + if [ ! -z ${ip4addr+x} ]; then + echo "#define LISTEN_IPV4 \"${ip4addr}\"" >> $file + if [ ! -z ${refv4addr+x} ]; then + echo "#define LISTEN_V4_DPLUS \"$refv4addr\"" >> $file + fi + if [ ! -z ${dcsv4addr+x} ]; then + echo "#define LISTEN_V4_DCS \"$dcsv4addr\"" >> $file + fi + if [ ! -z ${xrfv4addr+x} ]; then + echo "#define LISTEN_V4_DEXTRA \"$xrfv4addr\"" >> $file + fi + if [[ "$g3support" == true ]] && [ ! -z ${g3_v4addr+x} ]; then + echo "#define LISTEN_V4_G3 \"$g3_v4addr\"" >> $file + fi + if [[ "$callsign" == XLX* ]]; then + if [ ! -z ${dmrv4addr+x} ]; then + echo "#define LISTEN_V4_DMRMMDVM \"$dmrv4addr\"" >> $file + fi + if [ ! -z ${dmpv4addr+x} ]; then + echo "#define LISTEN_V4_DMRPLUS \"$dmpv4addr\"" >> $file + fi + if [ ! -z ${ysfv4addr+x} ]; then + echo "#define LISTEN_V4_YSF \"$ysfv4addr\"" >> $file + fi + if [ ! -z ${xlxv4addr+x} ]; then + echo "#define LISTEN_V4_XLX \"$xlxv4addr\"" >> $file + fi + fi + fi + if [ ! -z ${ip6addr+x} ]; then + echo "#define LISTEN_IPV6 \"${ip6addr}\"" >> $file + if [ ! -z ${refv6addr+x} ]; then + echo "#define LISTEN_V6_PLUS \"$refv6addr\"" >> $file + fi + if [ ! -z ${dcsv6addr+x} ]; then + echo "#define LISTEN_V6_DCS \"$dcsv6addr\"" >> $file + fi + if [ ! -z ${refv6addr+x} ]; then + echo "#define LISTEN_V6_DEXTRA \"$xrfv6addr\"" >> $file + fi + if [[ "$g3support" == true ]] && [ ! -z ${g3_v6addr+x} ]; then + echo "#define LISTEN_V4_G3 \"$g3_v6addr\"" >> $file + fi + if [[ "$callsign" == XLX* ]]; then + if [ ! -z ${dmrv6addr+x} ]; then + echo "#define LISTEN_V4_DMRMMDVM \"$dmrv6addr\"" >> $file + fi + if [ ! -z ${dmpv6addr+x} ]; then + echo "#define LISTEN_V4_DMRPLUS \"$dmpv6addr\"" >> $file + fi + if [ ! -z ${ysfv6addr+x} ]; then + echo "#define LISTEN_V4_YSF \"$ysfv6addr\"" >> $file + fi + if [ ! -z ${xlxv6addr+x} ]; then + echo "#define LISTEN_V4_XLX \"$xlxv6addr\"" >> $file + fi fi fi if [[ "$callsign" == XLX* ]]; then @@ -122,6 +190,14 @@ WriteSRCHFile () { echo '#define YSF_DB_SUPPORT false' >> $file fi fi + 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 @@ -132,7 +208,8 @@ WriteSRCHFile () { fi } -WriteSRCMKFile () { +WriteSRCMKFile () +{ local file file="$srcm" echo "# Created on `date`" > $file @@ -156,14 +233,16 @@ WriteSRCMKFile () { fi } -WriteAmbeHFile () { +WriteAmbeHFile () +{ local file file="$ambh" echo "// Created on `date`" > $file echo "#define TRANSCODER_IP \"${tcaddress}\"" >> $file } -WriteAmbeMKFile () { +WriteAmbeMKFile () +{ local file file="$ambm" echo "# created on `date`" > $file @@ -174,7 +253,8 @@ WriteAmbeMKFile () { fi } -WriteCfgPhpFile () { +WriteCfgPhpFile () +{ cat << EOF > $ysfs $dbcr CREATE DATABASE IF NOT EXISTS ${ysfdbname}; USE ${ysfdbname}; @@ -206,7 +287,8 @@ FLUSH PRIVILEGES; EOF } -WriteCFGFiles () { +WriteCFGFiles () +{ WriteMemFile WriteSRCHFile WriteSRCMKFile @@ -246,6 +328,84 @@ ListCFGFiles () fi } +AddressMenu () +{ + while [[ "$key" != q* ]] + do + clear + echo + echo " IP Address For Each Protocol" + echo + if [ ! -z ${ip4addr+x} ]; then echo " p4 : DPlus IPv4 address = '$refv4addr'"; fi + if [ ! -z ${ip6addr+x} ]; then echo " p6 : DPlus IPv6 address = '$refv6addr'"; fi + if [ ! -z ${ip4addr+x} ]; then echo " c4 : DCS IPv4 address = '$dcsv4addr'"; fi + if [ ! -z ${ip6addr+x} ]; then echo " c6 : DCS IPV6 address = '$dcsv6addr'"; fi + if [ ! -z ${ip4addr+x} ]; then echo " e4 : DExtra IPv4 address = '$xrfv4addr'"; fi + if [ ! -z ${ip6addr+x} ]; then echo " e6 : DExtra IPv6 address = '$xrfv6addr'"; fi + if [[ "$g3support" == true ]]; then + if [ ! -z ${ip4addr+x} ]; then echo " g4 : G3 IPv4 address = '$g3_v4addr'"; fi + # if [ ! -z ${ip6addr+x} ]; then echo " g6 : G3 IPv6 address = '$g3_v6addr'"; fi + fi + if [[ "$callsign" == XLX* ]]; then + if [ ! -z ${ip4addr+x} ]; then echo " d4 : DMR IPv4 address = '$dmrv4addr'"; fi + if [ ! -z ${ip6addr+x} ]; then echo " d6 : DMR IPv6 address = '$dmrv6addr'"; fi + if [ ! -z ${ip4addr+x} ]; then echo " m4 : DMR+ IPv4 address = '$dmpv4addr'"; fi + if [ ! -z ${ip6addr+x} ]; then echo " m6 : DMR+ IPV6 address = '$dmpv6addr'"; fi + if [ ! -z ${ip4addr+x} ]; then echo " y4 : YSF IPv4 address = '$ysfv4addr'"; fi + if [ ! -z ${ip6addr+x} ]; then echo " y6 : YSF IPv6 address = '$ysfv6addr'"; fi + if [ ! -z ${ip4addr+x} ]; then echo " x4 : XLX IPv4 address = '$xlxv4addr'"; fi + if [ ! -z ${ip6addr+x} ]; then echo " x6 : XLX IPv6 address = '$xlxv6addr'"; fi + fi + echo + echo "xx : Clear all Protocol addresses" + echo + echo "q : Return to main menu" + echo "u : Unset the value of ." + echo + read -p "Please input : " key value garbage + if [[ "$key" == p4* ]]; then refv4addr="$value" + elif [[ "$key" == p6* ]]; then refv6addr="$value" + elif [[ "$key" == c4* ]]; then dcsv4addr="$value" + elif [[ "$key" == c6* ]]; then dcsv6addr="$value" + elif [[ "$key" == e4* ]]; then xrfv4addr="$value" + elif [[ "$key" == e6* ]]; then xrfv6addr="$value" + elif [[ "$key" == g4* ]]; then g3_v4addr="$value" + # elif [[ "$key" == g6* ]]; then g3_v6addr="$value" + elif [[ "$key" == d4* ]]; then dmrv4addr="$value" + elif [[ "$key" == d6* ]]; then dmrv6addr="$value" + elif [[ "$key" == m4* ]]; then dmpv4addr="$value" + elif [[ "$key" == m6* ]]; then dmpv6addr="$value" + elif [[ "$key" == y4* ]]; then ysfv4addr="$value" + elif [[ "$key" == y6* ]]; then ysfv6addr="$value" + elif [[ "$key" == x4* ]]; then xlxv4addr="$value" + elif [[ "$key" == x6* ]]; then xlxv6addr="$value" + elif [[ "$key" == xx* ]]; then unset {dcs,dmr,xrf,g3_,dmp,ref,xlx,ysf}v{4,6}addr + elif [[ "$key" == u* ]]; then + if [[ "$value" == p4* ]]; then unset refv4addr + elif [[ "$value" == p6* ]]; then unset refv6addr + elif [[ "$value" == c4* ]]; then unset dcsv4addr + elif [[ "$value" == c6* ]]; then unset dcsv6addr + elif [[ "$value" == e4* ]]; then unset xrfv4addr + elif [[ "$value" == e6* ]]; then unset xrfv6addr + elif [[ "$value" == g4* ]]; then unset g3_v4addr + # elif [[ "$value" == g6* ]]; then unset g3_v6addr + elif [[ "$value" == d4* ]]; then unset dmrv4addr + elif [[ "$value" == d6* ]]; then unset dmrv6addr + elif [[ "$value" == m4* ]]; then unset dmpv4addr + elif [[ "$value" == m6* ]]; then unset dmpv6addr + elif [[ "$value" == y4* ]]; then unset ysfv4addr + elif [[ "$value" == y6* ]]; then unset ysfv6addr + elif [[ "$value" == x4* ]]; then unset xlxv4addr + elif [[ "$value" == x6* ]]; then unset xlxv6addr + fi + fi + if [[ "$callsign" != XLX* ]]; then unset {dmr,dmp,ysf,xlx}v{4,6}v{4,6}addr; fi + if [ -z ${ip4addr+x} ]; then unset {ref,dcs,xrf,dmr,dmp,ysf,xlx,g3_}v4addr; fi + if [ -z ${ip6addr+x} ]; then unset {ref,dcs,xrf,dmr,dmp,ysf,xlx,g3_}v6addr; fi + if [[ "$g3support" != true ]]; then unset g3_v{4,6}addr; fi + done +} + # Execution starts here! # file locations rcfg='reflector.cfg' @@ -307,17 +467,27 @@ while [[ "$key" != q* ]] do clear echo - echo " Reflector Configuration, Version #200813" + echo " Reflector Configuration, Version #200821" echo + echo " ******* REFLECTOR ********" echo -n "cs : Reflector Callsign = "; EvaluateVar callsign{,_d} echo -n "nm : Number of Modules = "; EvaluateVar nummod{,_d} + echo -n "g3 : Icom G3 Support = "; EvaluateVar g3support{,_d} + echo " ******* ADDRESSES ********" echo -n "i4 : IPv4 Listen Address = "; EvaluateVar ip4addr{,_d} echo -n "i6 : IPv6 Listen Address = "; EvaluateVar ip6addr{,_d} + if [ ! -z ${ip4addr+x} ] || [ ! -z ${ip6addr+x} ]; then + if [[ "$callsign" == XLX* ]] || [[ "$callsign" == XRF* ]]; then + echo "am : Protocol IP Address Override Sub-menu" + fi + fi if [[ "$callsign" == XLX* ]]; then + echo " ******* TRANSCODER ********" echo -n "tc : Transcoder Address = "; EvaluateVar tcaddress{,_d} if [ ! -z ${tcaddress+x} ]; then echo -n "tm : Transcoder Modules = "; EvaluateVar tcmodules{,_d} fi + echo " ******* SYSTEM FUSION ********" echo -n "ye : YSF Autolink Enable = "; EvaluateVar ysfautolink{,_d} if [ ! -z ${ysfautolink+x} ]; then if [[ "$ysfautolink" == true ]]; then @@ -331,7 +501,7 @@ do echo -n "yp : YSF Database Password = "; EvaluateVar ysfdbpw{,_d} fi fi - echo -n "g3 : Icom G3 Support = "; EvaluateVar g3support{,_d} + echo " ******* DEBUGGING ********" echo -n "db : Debugging Support = "; EvaluateVar dbsupport{,_d} echo if [[ "$callsign" == XLX* ]] || [[ "$callsign" == XRF* ]]; then @@ -342,11 +512,18 @@ do echo read -p "Please input - omit value to toggle a true/false : " key value garbage - if [[ "$key" == cs* && ( ${value^^} == XRF* || ${value^^} == XLX* ) ]]; then + if [[ "$key" == am* ]]; then + if [ ! -z ${ip4addr+x} ] || [ ! -z ${ip6addr+x} ];then + if [[ "$callsign" == XLX* ]] || [[ "$callsign" == XRF* ]]; then + AddressMenu + key="continue" + fi + fi + elif [[ "$key" == cs* && ( ${value^^} == XRF* || ${value^^} == XLX* ) ]]; then callsign="${value^^}" callsign="${callsign:0:6}" if [[ "$callsign" == XRF* ]]; then - unset tcaddress tcmodules ysfautolink ysfmodule ysflocaldb ysfdbname ysfdbuser ysfdbpw + unset tcaddress tcmodules ysf{autolink,module,localdb,dbname,dbuser,dbpw} {dmr,dmp,ysf,xlx}v{4,6}addr fi elif [[ "$key" == nm* ]]; then nummod="$value" elif [[ "$key" == i4* ]]; then ip4addr="$value" @@ -368,15 +545,15 @@ do ListCFGFiles exit 0 elif [[ "$key" == u* ]]; then - if [[ "$value" == cs* ]]; then unset callsign + if [[ "$value" == cs* ]]; then unset callsign {ref,dcs,xrf,dmr,dmp,ysf,xlx,g3_}v{4,6}addr elif [[ "$value" == nm* ]]; then unset nummod - elif [[ "$value" == i4* ]]; then unset ip4addr - elif [[ "$value" == i6* ]]; then unset ip6addr + elif [[ "$value" == i4* ]]; then unset ip4addr {ref,dcs,xrf,dmr,dmp,ysf,xlx,g3_}v4addr + elif [[ "$value" == i6* ]]; then unset ip6addr {ref,dcs,xrf,dmr,dmp,ysf,xlx,g3_}v6addr elif [[ "$value" == tc* ]]; then unset tcaddress elif [[ "$value" == tm* ]]; then unset tcmodules elif [[ "$value" == ye* ]]; then unset ysfautolink ysfmodule elif [[ "$value" == ym* ]]; then unset ysfmodule - elif [[ "$value" == g3* ]]; then unset g3support + elif [[ "$value" == g3* ]]; then unset g3support g3_v{4,6}addr elif [[ "$value" == db* ]]; then unset dbsupport elif [[ "$value" == yl* ]]; then unset ysflocaldb ysfdbname ysfdbuser ysfdbpw elif [[ "$value" == yd* ]]; then unset ysfdbname diff --git a/src/Makefile b/src/Makefile index ee83549..4c897fa 100644 --- a/src/Makefile +++ b/src/Makefile @@ -36,7 +36,7 @@ endif LDFLAGS=-pthread -XRFSRCS = cbuffer.cpp ccallsign.cpp ccallsignlist.cpp ccallsignlistitem.cpp cclient.cpp cclients.cpp cdcsclient.cpp cdcsprotocol.cpp cdextraclient.cpp cdextrapeer.cpp cdextraprotocol.cpp cdplusclient.cpp cdplusprotocol.cpp cdvframepacket.cpp cdvheaderpacket.cpp cdvlastframepacket.cpp cgatekeeper.cpp cip.cpp cnotification.cpp cpacket.cpp cpacketstream.cpp cpeercallsignlist.cpp cpeer.cpp cpeers.cpp cprotocol.cpp cprotocols.cpp creflector.cpp ctimepoint.cpp cudpsocket.cpp cuser.cpp cusers.cpp cversion.cpp main.cpp +XRFSRCS = cbuffer.cpp ccallsign.cpp ccallsignlist.cpp ccallsignlistitem.cpp cclient.cpp cclients.cpp cdcsclient.cpp cdcsprotocol.cpp cdextraclient.cpp cdextrapeer.cpp cdextraprotocol.cpp cdplusclient.cpp cdplusprotocol.cpp cdvframepacket.cpp cdvheaderpacket.cpp cdvlastframepacket.cpp cgatekeeper.cpp cip.cpp cnotification.cpp cpacket.cpp cpacketstream.cpp cpeercallsignlist.cpp cpeer.cpp cpeers.cpp cprotoaddress.cpp cprotocol.cpp cprotocols.cpp creflector.cpp ctimepoint.cpp cudpsocket.cpp cuser.cpp cusers.cpp cversion.cpp main.cpp XLXSRCS = cbmclient.cpp cbmpeer.cpp cbptc19696.cpp ccrc.cpp cdmriddir.cpp cdmriddirfile.cpp cdmriddirhttp.cpp cdmrmmdvmclient.cpp cdmrmmdvmprotocol.cpp cdmrplusclient.cpp cdmrplusprotocol.cpp cgolay2087.cpp cgolay24128.cpp chamming.cpp cqr1676.cpp crs129.cpp csemaphore.cpp cutils.cpp cwiresxcmd.cpp cwiresxcmdhandler.cpp cwiresxinfo.cpp cxlxclient.cpp cxlxprotocol.cpp cxlxpeer.cpp cysfclient.cpp cysfconvolution.cpp cysffich.cpp cysfnode.cpp cysfnodedir.cpp cysfnodedirfile.cpp cysfnodedirhttp.cpp cysfpayload.cpp cysfprotocol.cpp cysfutils.cpp G3SRCS = cg3client.cpp cg3protocol.cpp crawsocket.cpp cudpmsgsocket.cpp diff --git a/src/ccodecstream.cpp b/src/ccodecstream.cpp index 83259b7..3b5a0d5 100644 --- a/src/ccodecstream.cpp +++ b/src/ccodecstream.cpp @@ -89,12 +89,12 @@ bool CCodecStream::Init(uint16 uiPort) // create socket address, family based on transcoder listen address #ifdef LISTEN_IPV4 #ifdef LISTEN_IPV6 - s = (AF_INET == m_Ip.GetFamily()) ? g_Reflector.GetListenIPv4() : g_Reflector.GetListenIPv6(); + s = (AF_INET == m_Ip.GetFamily()) ? g_Reflector.m_Address.GetV4Address(PROTOCOL_ANY).c_str() : g_Reflector.m_Address.GetV6Address(PROTOCOL_ANY).c_str(); #else - s = g_Reflector.GetListenIPv4(); + s = g_Reflector.m_Address.GetV4Address(PROTOCOL_ANY).c_str(); #endif #else - s = g_Reflector.GetListenIPv6(); + s = g_Reflector.m_Address.GetV6Address(PROTOCOL_ANY).c_str(); #endif CIp ip(m_Ip.GetFamily(), m_uiPort, s); diff --git a/src/cdcsprotocol.cpp b/src/cdcsprotocol.cpp index 6e85b56..70e95ad 100644 --- a/src/cdcsprotocol.cpp +++ b/src/cdcsprotocol.cpp @@ -33,10 +33,10 @@ //////////////////////////////////////////////////////////////////////////////////////// // operation -bool CDcsProtocol::Init(void) +bool CDcsProtocol::Initialize(const char *type, const int ptype, const uint16 port, const bool has_ipv4, const bool has_ipv6) { // base class - if (! CProtocol::Initialize("DCS", DCS_PORT, DSTAR_IPV4, DSTAR_IPV6)) + if (! CProtocol::Initialize(type, ptype, port, has_ipv4, has_ipv6)) return false; // update time diff --git a/src/cdcsprotocol.h b/src/cdcsprotocol.h index f960ead..f52ed14 100644 --- a/src/cdcsprotocol.h +++ b/src/cdcsprotocol.h @@ -51,7 +51,7 @@ class CDcsProtocol : public CProtocol { public: // initialization - bool Init(void); + bool Initialize(const char *type, const int ptype, const uint16 port, const bool has_ipv4, const bool has_ipv6); // task void Task(void); diff --git a/src/cdextraprotocol.cpp b/src/cdextraprotocol.cpp index 3ad0232..0527694 100644 --- a/src/cdextraprotocol.cpp +++ b/src/cdextraprotocol.cpp @@ -35,10 +35,10 @@ //////////////////////////////////////////////////////////////////////////////////////// // operation -bool CDextraProtocol::Initialize(const char *type, const uint16 port, const bool has_ipv4, const bool has_ipv6) +bool CDextraProtocol::Initialize(const char *type, int ptype, const uint16 port, const bool has_ipv4, const bool has_ipv6) { // base class - if (! CProtocol::Initialize(type, port, has_ipv4, has_ipv6)) + if (! CProtocol::Initialize(type, ptype, port, has_ipv4, has_ipv6)) return false; // update time diff --git a/src/cdextraprotocol.h b/src/cdextraprotocol.h index 3a83e0e..3e003b4 100644 --- a/src/cdextraprotocol.h +++ b/src/cdextraprotocol.h @@ -59,7 +59,7 @@ class CDextraProtocol : public CProtocol { public: // initialization - bool Initialize(const char *type, const uint16 port, const bool has_ipv4, const bool has_ipv6); + bool Initialize(const char *type, const int ptype, const uint16 port, const bool has_ipv4, const bool has_ipv6); // task void Task(void); diff --git a/src/cdmrmmdvmprotocol.cpp b/src/cdmrmmdvmprotocol.cpp index 852ac17..0045fc2 100644 --- a/src/cdmrmmdvmprotocol.cpp +++ b/src/cdmrmmdvmprotocol.cpp @@ -54,10 +54,10 @@ static uint8 g_DmrSyncMSData[] = { 0x0D,0x5D,0x7F,0x77,0xFD,0x75,0x70 }; //////////////////////////////////////////////////////////////////////////////////////// // operation -bool CDmrmmdvmProtocol::Initialize(const char *type, const uint16 port, const bool has_ipv4, const bool has_ipv6) +bool CDmrmmdvmProtocol::Initialize(const char *type, const int ptype, const uint16 port, const bool has_ipv4, const bool has_ipv6) { // base class - if (! CProtocol::Initialize(type, port, has_ipv4, has_ipv6)) + if (! CProtocol::Initialize(type, ptype, port, has_ipv4, has_ipv6)) return false; // update time diff --git a/src/cdmrmmdvmprotocol.h b/src/cdmrmmdvmprotocol.h index aa483b9..83d227b 100644 --- a/src/cdmrmmdvmprotocol.h +++ b/src/cdmrmmdvmprotocol.h @@ -68,7 +68,7 @@ class CDmrmmdvmProtocol : public CProtocol { public: // initialization - bool Initialize(const char *type, const uint16 port, const bool has_ipv4, const bool has_ipv6); + bool Initialize(const char *type, const int ptype, const uint16 port, const bool has_ipv4, const bool has_ipv6); // task void Task(void); diff --git a/src/cdmrplusprotocol.cpp b/src/cdmrplusprotocol.cpp index c90245f..08664ac 100644 --- a/src/cdmrplusprotocol.cpp +++ b/src/cdmrplusprotocol.cpp @@ -47,10 +47,10 @@ static uint8 g_DmrSyncMSData[] = { 0x0D,0x5D,0x7F,0x77,0xFD,0x75,0x70 }; //////////////////////////////////////////////////////////////////////////////////////// // operation -bool CDmrplusProtocol::Initialize(const char *type, const uint16 port, const bool has_ipv4, const bool has_ipv6) +bool CDmrplusProtocol::Initialize(const char *type, const int ptype, const uint16 port, const bool has_ipv4, const bool has_ipv6) { // base class - if (! CProtocol::Initialize(type, port, has_ipv4, has_ipv6)) + if (! CProtocol::Initialize(type, ptype, port, has_ipv4, has_ipv6)) return false; // update time diff --git a/src/cdmrplusprotocol.h b/src/cdmrplusprotocol.h index 337d973..fabef59 100644 --- a/src/cdmrplusprotocol.h +++ b/src/cdmrplusprotocol.h @@ -57,7 +57,7 @@ class CDmrplusProtocol : public CProtocol { public: // initialization - bool Initialize(const char *type, const uint16 port, const bool has_ipv4, const bool has_ipv6); + bool Initialize(const char *type, const int pytpe, const uint16 port, const bool has_ipv4, const bool has_ipv6); // task void Task(void); diff --git a/src/cdplusprotocol.cpp b/src/cdplusprotocol.cpp index 109b1b8..e695b9b 100644 --- a/src/cdplusprotocol.cpp +++ b/src/cdplusprotocol.cpp @@ -34,10 +34,10 @@ //////////////////////////////////////////////////////////////////////////////////////// // operation -bool CDplusProtocol::Initialize(const char *type, const uint16 port, const bool has_ipv4, const bool has_ipv6) +bool CDplusProtocol::Initialize(const char *type, const int ptype, const uint16 port, const bool has_ipv4, const bool has_ipv6) { // base class - if (! CProtocol::Initialize(type, port, has_ipv4, has_ipv6)) + if (! CProtocol::Initialize(type, ptype, port, has_ipv4, has_ipv6)) return false; // update time diff --git a/src/cdplusprotocol.h b/src/cdplusprotocol.h index 72275f3..c3817b1 100644 --- a/src/cdplusprotocol.h +++ b/src/cdplusprotocol.h @@ -52,7 +52,7 @@ class CDplusProtocol : public CProtocol { public: // initialization - bool Initialize(const char *type, const uint16 port, const bool has_ipv4, const bool has_ipv6); + bool Initialize(const char *type, const int ptype, const uint16 port, const bool has_ipv4, const bool has_ipv6); // task void Task(void); diff --git a/src/cg3protocol.cpp b/src/cg3protocol.cpp index 4c99afe..80ffe12 100644 --- a/src/cg3protocol.cpp +++ b/src/cg3protocol.cpp @@ -38,7 +38,8 @@ //////////////////////////////////////////////////////////////////////////////////////// // operation -bool CG3Protocol::Initialize(const char */*type*/, const uint16 /*port*/, const bool /*has_ipv4*/, const bool /*has_ipv6*/) +bool CG3Protocol::Initialize(const char */*type*/, const int /*type*/, const uint16 /*port*/, const bool /*has_ipv4*/, const bool /*has_ipv6*/) +// everything is hard coded until ICOM gets their act together and start supporting IPv6 { ReadOptions(); @@ -52,7 +53,7 @@ bool CG3Protocol::Initialize(const char */*type*/, const uint16 /*port*/, const //m_ReflectorCallsign.PatchCallsign(0, (const uint8 *)"XLX", 3); // create our sockets - CIp ip(AF_INET, G3_DV_PORT, g_Reflector.GetListenIPv4()); + CIp ip(AF_INET, G3_DV_PORT, g_Reflector.m_Address.GetV4Address(PROTOCOL_G3).c_str()); if ( ip.IsSet() ) { if (! m_Socket4.Open(ip)) @@ -61,6 +62,8 @@ bool CG3Protocol::Initialize(const char */*type*/, const uint16 /*port*/, const else return false; + std::cout << "Listening on " << ip << std::endl; + //create helper socket ip.SetPort(G3_PRESENCE_PORT); if (! m_PresenceSocket.Open(ip)) diff --git a/src/cg3protocol.h b/src/cg3protocol.h index 42ee418..72a976a 100644 --- a/src/cg3protocol.h +++ b/src/cg3protocol.h @@ -67,7 +67,7 @@ public: CG3Protocol() : m_GwAddress(0u), m_Modules("*"), m_LastModTime(0) {} // initialization - bool Initialize(const char *type, const uint16 port, const bool has_ipv4, const bool has_ipv6); + bool Initialize(const char *type, const int ptype, const uint16 port, const bool has_ipv4, const bool has_ipv6); // close void Close(void); diff --git a/src/cprotoaddress.cpp b/src/cprotoaddress.cpp new file mode 100644 index 0000000..c67c88c --- /dev/null +++ b/src/cprotoaddress.cpp @@ -0,0 +1,100 @@ +// +// Copyright © 2020 Thomas A. Eary, N7TAE +// +// ---------------------------------------------------------------------------- +// This file is part of xlxd. +// +// xlxd 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. +// +// xlxd 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 Foobar. If not, see . +// ---------------------------------------------------------------------------- + +#include "cprotoaddress.h" + +CProtoAddress::CProtoAddress() +{ +#ifdef LISTEN_IPV4 + v4address[PROTOCOL_ANY] = LISTEN_IPV4; +#endif +#ifdef LISTEN_V4_DPLUS + v4address[PROTOCOL_DPLUS] = LISTEN_V4_DPLUS; +#endif +#ifdef LISTEN_V4_DCS + v4address[PROTOCOL_DCS] = LISTEN_V4_DCS; +#endif +#ifdef LISTEN_V4_DEXTRA + v4address[PROTOCOL_DEXTRA] = LISTEN_V4_DEXTRA; +#endif +#ifdef LISTEN_V4_DMRMMDVM + v4address[PROTOCOL_DMRMMDVM] = LISTEN_V4_DMRMMDVM; +#endif +#ifdef LISTEN_V4_DMRPLUS + v4address[PROTOCOL_DMRPLUS] = LISTEN_V4_DMRPLUS; +#endif +#ifdef LISTEN_V4_YSF + v4address[PROTOCOL_YSF] = LISTEN_V4_YSF; +#endif +#ifdef LISTEN_V4_XLX + v4address[PROTOCOL_XLX] = LISTEN_V4_XLX; +#endif +#ifdef LISTEN_V4_G3 + v4address[PROTOCOL_G3] = LISTEN_V4_G3; +#endif + +#ifdef LISTEN_IPV6 + v6address[PROTOCOL_ANY] = LISTEN_IPV6; +#endif +#ifdef LISTEN_V6_DPLUS + v6address[PROTOCOL_DPLUS] = LISTEN_V6_DPLUS; +#endif +#ifdef LISTEN_V6_DCS + v6address[PROTOCOL_DCS] = LISTEN_V6_DCS; +#endif +#ifdef LISTEN_V6_DEXTRA + v6address[PROTOCOL_DEXTRA] = LISTEN_V6_DEXTRA; +#endif +#ifdef LISTEN_V6_DMRMMDVM + v6address[PROTOCOL_DMRMMDVM] = LISTEN_V6_DMRMMDVM; +#endif +#ifdef LISTEN_V6_DMRPLUS + v6address[PROTOCOL_DMRPLUS] = LISTEN_V6_DMRPLUS; +#endif +#ifdef LISTEN_V6_YSF + v6address[PROTOCOL_YSF] = LISTEN_V6_YSF; +#endif +#ifdef LISTEN_V6_XLX + v6address[PROTOCOL_XLX] = LISTEN_V6_XLX; +#endif +#ifdef LISTEN_V6_G3 + v6address[PROTOCOL_G3] = LISTEN_V6_G3; +#endif +} + +#ifdef LISTEN_IPV4 +std::string CProtoAddress::GetV4Address(int protocol) +{ + if (v4address.end() == v4address.find(protocol)) + return v4address[PROTOCOL_ANY]; + else + return v4address[protocol]; +} +#endif + +#ifdef LISTEN_IPV4 +std::string CProtoAddress::GetV6Address(int protocol) +{ + if (v6address.end() == v6address.find(protocol)) + return v6address[PROTOCOL_ANY]; + else + return v6address[protocol]; +} +#endif diff --git a/src/cprotoaddress.h b/src/cprotoaddress.h new file mode 100644 index 0000000..6ea442f --- /dev/null +++ b/src/cprotoaddress.h @@ -0,0 +1,46 @@ +#pragma once + +// +// Copyright © 2020 Thomas A. Eary, N7TAE +// +// ---------------------------------------------------------------------------- +// This file is part of xlxd. +// +// xlxd 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. +// +// xlxd 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 Foobar. If not, see . +// ---------------------------------------------------------------------------- + +#include +#include + +#include "main.h" + +class CProtoAddress +{ +public: + CProtoAddress(); +#ifdef LISTEN_IPV4 + std::string GetV4Address(int protocol); +#endif +#ifdef LISTEN_IPV6 + std::string GetV6Address(int protocol); +#endif + +private: +#ifdef LISTEN_IPV4 + std::unordered_map v4address; +#endif +#ifdef LISTEN_IPV6 + std::unordered_map v6address; +#endif +}; diff --git a/src/cprotocol.cpp b/src/cprotocol.cpp index 6eec5c5..7263121 100644 --- a/src/cprotocol.cpp +++ b/src/cprotocol.cpp @@ -56,7 +56,7 @@ CProtocol::~CProtocol() //////////////////////////////////////////////////////////////////////////////////////// // initialization -bool CProtocol::Initialize(const char *type, const uint16 port, const bool has_ipv4, const bool has_ipv6) +bool CProtocol::Initialize(const char *type, int ptype, const uint16 port, const bool has_ipv4, const bool has_ipv6) { // init reflector apparent callsign m_ReflectorCallsign = g_Reflector.GetCallsign(); @@ -72,19 +72,20 @@ bool CProtocol::Initialize(const char *type, const uint16 port, const bool has_i #ifdef LISTEN_IPV4 if (has_ipv4) { - CIp ip4(AF_INET, port, g_Reflector.GetListenIPv4()); + CIp ip4(AF_INET, port, g_Reflector.m_Address.GetV4Address(ptype).c_str()); if ( ip4.IsSet() ) { if (! m_Socket4.Open(ip4)) return false; } + std::cout << "Listening on " << ip4 << std::endl; } #endif #ifdef LISTEN_IPV6 if (has_ipv6) { - CIp ip6(AF_INET6, port, g_Reflector.GetListenIPv6()); + CIp ip6(AF_INET6, port, g_Reflector.m_Address.GetV6Address(ptype).c_str()); if ( ip6.IsSet() ) { if (! m_Socket6.Open(ip6)) @@ -92,6 +93,7 @@ bool CProtocol::Initialize(const char *type, const uint16 port, const bool has_i m_Socket4.Close(); return false; } + std::cout << "Listening on " << ip6 << std::endl; } } #endif @@ -107,7 +109,6 @@ bool CProtocol::Initialize(const char *type, const uint16 port, const bool has_i return false; } - std::cout << "Initialized " << (type ? type : "DMR") << " protocol on port " << port << std::endl; return true; } diff --git a/src/cprotocol.h b/src/cprotocol.h index a17ada8..f8c4770 100644 --- a/src/cprotocol.h +++ b/src/cprotocol.h @@ -77,7 +77,7 @@ public: virtual ~CProtocol(); // initialization - virtual bool Initialize(const char *type, const uint16 port, const bool has_ipv4, const bool has_ipv6); + virtual bool Initialize(const char *type, const int ptype, const uint16 port, const bool has_ipv4, const bool has_ipv6); virtual void Close(void); // queue diff --git a/src/cprotocols.cpp b/src/cprotocols.cpp index 362fc4f..b0d8b72 100644 --- a/src/cprotocols.cpp +++ b/src/cprotocols.cpp @@ -54,38 +54,38 @@ bool CProtocols::Init(void) m_Mutex.lock(); { m_Protocols.emplace_back(std::unique_ptr(new CDextraProtocol)); - if (! m_Protocols.back()->Initialize("XRF", DEXTRA_PORT, DSTAR_IPV4, DSTAR_IPV6)) + if (! m_Protocols.back()->Initialize("XRF", PROTOCOL_DEXTRA, DEXTRA_PORT, DSTAR_IPV4, DSTAR_IPV6)) return false; m_Protocols.emplace_back(std::unique_ptr(new CDplusProtocol)); - if (! m_Protocols.back()->Initialize("REF", DPLUS_PORT, DSTAR_IPV4, DSTAR_IPV6)) + if (! m_Protocols.back()->Initialize("REF", PROTOCOL_DPLUS, DPLUS_PORT, DSTAR_IPV4, DSTAR_IPV6)) return false; m_Protocols.emplace_back(std::unique_ptr(new CDcsProtocol)); - if (! m_Protocols.back()->Initialize("DCS", DCS_PORT, DSTAR_IPV4, DSTAR_IPV6)) + if (! m_Protocols.back()->Initialize("DCS", PROTOCOL_DCS, DCS_PORT, DSTAR_IPV4, DSTAR_IPV6)) return false; #ifndef NO_XLX m_Protocols.emplace_back(std::unique_ptr(new CDmrmmdvmProtocol)); - if (! m_Protocols.back()->Initialize(nullptr, DMRMMDVM_PORT, DMR_IPV4, DMR_IPV6)) + if (! m_Protocols.back()->Initialize(nullptr, PROTOCOL_DMRMMDVM, DMRMMDVM_PORT, DMR_IPV4, DMR_IPV6)) return false; m_Protocols.emplace_back(std::unique_ptr(new CDmrplusProtocol)); - if (! m_Protocols.back()->Initialize(nullptr, DMRPLUS_PORT, DMR_IPV4, DMR_IPV6)) + if (! m_Protocols.back()->Initialize(nullptr, PROTOCOL_DMRPLUS, DMRPLUS_PORT, DMR_IPV4, DMR_IPV6)) return false; m_Protocols.emplace_back(std::unique_ptr(new CYsfProtocol)); - if (! m_Protocols.back()->Initialize("YSF", YSF_PORT, YSF_IPV4, YSF_IPV6)) + if (! m_Protocols.back()->Initialize("YSF", PROTOCOL_YSF, YSF_PORT, YSF_IPV4, YSF_IPV6)) return false; m_Protocols.emplace_back(std::unique_ptr(new CXlxProtocol)); - if (! m_Protocols.back()->Initialize("XLX", XLX_PORT, DMR_IPV4, DMR_IPV6)) + if (! m_Protocols.back()->Initialize("XLX", PROTOCOL_XLX, XLX_PORT, DMR_IPV4, DMR_IPV6)) return false; #endif #ifndef NO_G3 m_Protocols.emplace_back(std::unique_ptr(new CG3Protocol)); - if (! m_Protocols.back()->Initialize("XLX", G3_DV_PORT, DMR_IPV4, DMR_IPV6)) + if (! m_Protocols.back()->Initialize("XLX", PROTOCOL_G3, G3_DV_PORT, DMR_IPV4, DMR_IPV6)) return false; #endif diff --git a/src/creflector.h b/src/creflector.h index 8578525..072e943 100644 --- a/src/creflector.h +++ b/src/creflector.h @@ -26,6 +26,7 @@ #ifndef creflector_h #define creflector_h +#include "cprotoaddress.h" #include "cusers.h" #include "cclients.h" #include "cpeers.h" @@ -59,16 +60,6 @@ public: void SetCallsign(const CCallsign &callsign) { m_Callsign = callsign; } const CCallsign &GetCallsign(void) const { return m_Callsign; } -#ifdef LISTEN_IPV4 - void SetListenIPv4(const char *a, const int n) { memset(m_IPv4, 0, n); strncpy(m_IPv4, a, n-1); } - const char *GetListenIPv4(void) const { return m_IPv4; } -#endif - -#ifdef LISTEN_IPV6 - void SetListenIPv6(const char *a, const int n) { memset(m_IPv6, 0, n); strncpy(m_IPv6, a, n-1); } - const char *GetListenIPv6(void) const { return m_IPv6; } -#endif - #ifdef TRANSCODER_IP void SetTranscoderIp(const char *a, const int n) { memset(m_AmbedIp, 0, n); strncpy(m_AmbedIp, a, n-1); } const char *GetTranscoderIp(void) const { return m_AmbedIp; } @@ -95,6 +86,9 @@ public: CUsers *GetUsers(void) { m_Users.Lock(); return &m_Users; } void ReleaseUsers(void) { m_Users.Unlock(); } + // IP Addresses + CProtoAddress m_Address; + // get bool IsValidModule(char c) const { return (GetModuleIndex(c) >= 0); } int GetModuleIndex(char) const; @@ -135,12 +129,6 @@ protected: protected: // identity CCallsign m_Callsign; -#ifdef LISTEN_IPV4 - char m_IPv4[INET_ADDRSTRLEN]; -#endif -#ifdef LISTEN_IPV6 - char m_IPv6[INET6_ADDRSTRLEN]; -#endif #ifdef TRANSCODER_IP char m_AmbedIp[INET6_ADDRSTRLEN]; #endif diff --git a/src/ctranscoder.cpp b/src/ctranscoder.cpp index ba54fec..ae145a8 100644 --- a/src/ctranscoder.cpp +++ b/src/ctranscoder.cpp @@ -82,12 +82,12 @@ bool CTranscoder::Init(void) // now open the transcoder port #ifdef LISTEN_IPV4 #ifdef LISTEN_IPV6 - s = (AF_INET == m_Ip.GetFamily()) ? g_Reflector.GetListenIPv4() : g_Reflector.GetListenIPv6(); + s = (AF_INET == m_Ip.GetFamily()) ? g_Reflector.m_Address.GetV4Address(PROTOCOL_ANY).c_str() : g_Reflector.m_Address.GetV6Address(PROTOCOL_ANY).c_str(); #else - s = g_Reflector.GetListenIPv4(); + s = g_Reflector.m_Address.GetV4Address(PROTOCOL_ANY).c_str(); #endif #else - s = g_Reflector.GetListenIPv6(); + s = g_Reflector.m_address.GetV6Address(PROTOCOL_ANY).c_str(); #endif CIp tc(m_Ip.GetFamily(), TRANSCODER_PORT, s); diff --git a/src/cxlxprotocol.cpp b/src/cxlxprotocol.cpp index 29b5461..1d99597 100644 --- a/src/cxlxprotocol.cpp +++ b/src/cxlxprotocol.cpp @@ -35,9 +35,9 @@ //////////////////////////////////////////////////////////////////////////////////////// // operation -bool CXlxProtocol::Initialize(const char *type, const uint16 port, const bool has_ipv4, const bool has_ipv6) +bool CXlxProtocol::Initialize(const char *type, const int ptype, const uint16 port, const bool has_ipv4, const bool has_ipv6) { - if (! CProtocol::Initialize(type, port, has_ipv4, has_ipv6)) + if (! CProtocol::Initialize(type, ptype, port, has_ipv4, has_ipv6)) return false; // update time diff --git a/src/cxlxprotocol.h b/src/cxlxprotocol.h index cbdb330..1ffb09b 100644 --- a/src/cxlxprotocol.h +++ b/src/cxlxprotocol.h @@ -41,7 +41,7 @@ class CXlxProtocol : public CDextraProtocol { public: // initialization - bool Initialize(const char *type, const uint16 port, const bool has_ipv4, const bool has_ipv6); + bool Initialize(const char *type, const int ptype, const uint16 port, const bool has_ipv4, const bool has_ipv6); // task void Task(void); diff --git a/src/cysfprotocol.cpp b/src/cysfprotocol.cpp index 5c74392..918b41d 100644 --- a/src/cysfprotocol.cpp +++ b/src/cysfprotocol.cpp @@ -45,10 +45,10 @@ CYsfProtocol::CYsfProtocol() //////////////////////////////////////////////////////////////////////////////////////// // operation -bool CYsfProtocol::Initialize(const char *type, const uint16 port, const bool has_ipv4, const bool has_ipv6) +bool CYsfProtocol::Initialize(const char *type, const int ptype, const uint16 port, const bool has_ipv4, const bool has_ipv6) { // base class - if (! CProtocol::Initialize(type, port, has_ipv4, has_ipv6)) + if (! CProtocol::Initialize(type, ptype, port, has_ipv4, has_ipv6)) return false; // init the wiresx cmd handler diff --git a/src/cysfprotocol.h b/src/cysfprotocol.h index bb9ff1f..d0cc13b 100644 --- a/src/cysfprotocol.h +++ b/src/cysfprotocol.h @@ -74,7 +74,7 @@ public: CYsfProtocol(); // initialization - bool Initialize(const char *type, const uint16 port, const bool has_ipv4, const bool has_ipv6); + bool Initialize(const char *type, const int ptype, const uint16 port, const bool has_ipv4, const bool has_ipv6); void Close(void); // task diff --git a/src/main.cpp b/src/main.cpp index 9ea8817..1fa1ba4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -56,14 +56,6 @@ int main() // initialize reflector g_Reflector.SetCallsign(cs.c_str()); -#ifdef LISTEN_IPV4 - g_Reflector.SetListenIPv4(LISTEN_IPV4, INET_ADDRSTRLEN); -#endif - -#ifdef LISTEN_IPV6 - g_Reflector.SetListenIPv6(LISTEN_IPV6, INET6_ADDRSTRLEN); -#endif - #ifdef TRANSCODER_IP g_Reflector.SetTranscoderIp(TRANSCODER_IP, INET6_ADDRSTRLEN); #endif @@ -76,20 +68,7 @@ int main() return EXIT_FAILURE; } - std::cout << "Reflector " << g_Reflector.GetCallsign() << "started and listening on "; -#if defined LISTEN_IPV4 - std::cout << g_Reflector.GetListenIPv4() << " for IPv4"; -#if defined LISTEN_IPV6 - std::cout << " and " << g_Reflector.GetListenIPv6() << " for IPv6" << std::endl; -#else - std::cout << std::endl; -#endif -#elif defined LISTEN_IPV6 - std::cout << g_Reflector.GetListenIPv6() << " for IPv6" << std::endl; -#else - std::cout << "...ABORTING! No IP addresses defined!" << std::endl; - return EXIT_FAILURE; -#endif + std::cout << "Reflector " << g_Reflector.GetCallsign() << "started and listening" << std::endl; // write new pid file std::ofstream ofs(PIDFILE_PATH, std::ofstream::out); diff --git a/src/main.h b/src/main.h index dd3140d..36de772 100644 --- a/src/main.h +++ b/src/main.h @@ -79,8 +79,6 @@ // protocols --------------------------------------------------- -#define NB_OF_PROTOCOLS 8 - #define PROTOCOL_ANY -1 #define PROTOCOL_NONE 0 #define PROTOCOL_DEXTRA 1