From 5f5e2fac94f4348e561c82c665632e1c8e562ff7 Mon Sep 17 00:00:00 2001 From: Tom Early Date: Tue, 20 Apr 2021 09:34:46 -0700 Subject: [PATCH] remote qnrelay target --- QnetRelay.cpp | 10 ++++++---- QnetRelay.h | 2 +- defaults | 3 ++- qnconfig | 10 +++++++--- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/QnetRelay.cpp b/QnetRelay.cpp index bb2463c..1c53ca8 100644 --- a/QnetRelay.cpp +++ b/QnetRelay.cpp @@ -112,7 +112,7 @@ bool CQnetRelay::Run(const char *cfgfile) if (Initialize(cfgfile)) return true; - msock = OpenSocket(MMDVM_IP, MMDVM_OUT_PORT); + msock = OpenSocket(MMDVM_INTERNAL_IP, MMDVM_OUT_PORT); if (msock < 0) return true; @@ -247,7 +247,7 @@ bool CQnetRelay::ProcessGateway(const int len, const unsigned char *raw) printf("DEBUG: ProcessGateway: unexpected voice sequence number %d\n", dsrp.voice.seq); dsrp.voice.err = 0; // NOT SURE WHERE TO GET THIS FROM THE INPUT buf memcpy(dsrp.voice.ambe, dsvt.vasd.voice, 12); - int ret = SendTo(msock, dsrp.title, 21, MMDVM_IP, MMDVM_IN_PORT); + int ret = SendTo(msock, dsrp.title, 21, MMDVM_TARGET_IP, MMDVM_IN_PORT); if (ret != 21) { printf("ERROR: ProcessGateway: Could not write AMBE mmdvmhost packet\n"); @@ -278,7 +278,7 @@ bool CQnetRelay::ProcessGateway(const int len, const unsigned char *raw) memcpy(dsrp.header.my, dsvt.hdr.mycall, 8); memcpy(dsrp.header.nm, dsvt.hdr.sfx, 4); memcpy(dsrp.header.pfcs, dsvt.hdr.pfcs, 2); - int ret = SendTo(msock, dsrp.title, 49, MMDVM_IP, MMDVM_IN_PORT); + int ret = SendTo(msock, dsrp.title, 49, MMDVM_TARGET_IP, MMDVM_IN_PORT); if (ret != 49) { printf("ERROR: ProcessGateway: Could not write Header mmdvmhost packet\n"); @@ -427,7 +427,9 @@ bool CQnetRelay::ReadConfig(const char *cfgFile) RPTR_MOD = 'A' + assigned_module; cfg.GetValue("gateway_tomodem"+std::string(1, 'a'+assigned_module), estr, togate, 1, FILENAME_MAX); - cfg.GetValue(mmdvm_path+"_internal_ip", type, MMDVM_IP, 7, IP_SIZE); + cfg.GetValue(mmdvm_path+"_internal_ip", type, MMDVM_INTERNAL_IP, 7, IP_SIZE); + cfg.GetValue(mmdvm_path+"_target_ip", type, MMDVM_INTERNAL_IP, 7, IP_SIZE); + int i; cfg.GetValue(mmdvm_path+"_local_port", type, i, 10000, 65535); MMDVM_IN_PORT = (unsigned short)i; diff --git a/QnetRelay.h b/QnetRelay.h index e9b0289..cf190e9 100644 --- a/QnetRelay.h +++ b/QnetRelay.h @@ -54,7 +54,7 @@ private: // config data char RPTR_MOD; - std::string MMDVM_IP; + std::string MMDVM_INTERNAL_IP, MMDVM_TARGET_IP; unsigned short MMDVM_IN_PORT, MMDVM_OUT_PORT; bool log_qso, IS_DSTARREPEATER; diff --git a/defaults b/defaults index 5bb3b9e..ca004f3 100644 --- a/defaults +++ b/defaults @@ -111,7 +111,8 @@ module_x_is_hf=false # set to true if this is an HF module # mmdvmhost_tx_frequency=0 # in MHz, not required, set in MMDVM.qn in Hz mmdvmhost_rx_frequency=0 # in Mhz, not required, set in MMDVM.qn in Hz -mmdvmhost_internal_ip='0.0.0.0' # where MMDVMHost will find the QnetRelay program +mmdvmhost_internal_ip='0.0.0.0' # bound port +mmdvmhost_target_ip='127.0.0.1' # where qnrelay will find MMDVMHost or DStarRepeater mmdvmhost_gateway_port=20010 # which port will QnetRelay be sending on mmdvmhost_local_port=20011 # which port will MMDVMHost be sending on mmdvmhost_is_dstarrepeater=false # is this a dstarrepeater or MMDVMHost? diff --git a/qnconfig b/qnconfig index 07632da..977e010 100755 --- a/qnconfig +++ b/qnconfig @@ -454,7 +454,8 @@ ModuleMenu () { echo -n "ap : Set to true if using Access Point Mode = "; EvaluateVar {${mod},itap}_ap_mode elif [[ "${!mod}" == 'mmdvmhost' ]]; then echo -n "dr : System is DStarRepeater, and _NOT_ MMDVMHost = "; EvaluateVar {${mod},mmdvmhost}_is_dstarrepeater - echo -n "ip : Internal IP address = "; EvaluateVar {${mod},mmdvmhost}_internal_ip + echo -n "ip : bound IP address for communication to modem = "; EvaluateVar {${mod},mmdvmhost}_internal_ip + echo -n "ti : IP of MMDVMHost or DStarRepeater = "; EvaluateVar {${mod},mmdvmhost}_target_ip echo -n "gp : Gateway port number = "; EvaluateVar {${mod},mmdvmhost}_gateway_port echo -n "lp : Local port number = "; EvaluateVar {${mod},mmdvmhost}_local_port echo -n "tx : Transmit frequency, in MHz = "; EvaluateVar {${mod},mmdvmhost}_tx_frequency @@ -516,13 +517,14 @@ ModuleMenu () { unset {$mod}_device elif [[ "$key" == sq* ]]; then eval ${mod}_squelch="$value" elif [[ "$key" == td* ]]; then eval ${mod}_tx_delay="$value" + elif [[ "$key" == ti* ]]; then eval ${mod}_target_ip="$value" elif [[ "$key" == tl* ]]; then eval ${mod}_tx_level="$value" elif [[ "$key" == to* ]]; then eval ${mod}_tx_offset="$value" elif [[ "$key" == tx* ]]; then eval ${mod}_tx_frequency="$value" elif [[ "$key" == xx* ]]; then unset ${mod}_{link_at_start,callsign,{,rx_,tx_}frequency,offset,range,agl} unset ${mod}_{inactivity,packet_wait,acknowledge,ack_delay,power,squelch,serial_number,rf_o{n,ff},{r,t}x_level} - unset ${mod}_{duplex,tx_delay,rqst_count,{tx,rx,ptt}_invert,device,internal_ip,{gateway,local}_port} + unset ${mod}_{duplex,tx_delay,rqst_count,{tx,rx,ptt}_invert,device,internal_ip,target_ip,{gateway,local}_port} unset ${mod}_{tx_offset,rx_offset,auto_link,ap_mode} unset ${mod} return @@ -558,6 +560,7 @@ ModuleMenu () { elif [[ "$value" == sn* ]]; then unset ${mod}_serial_number elif [[ "$value" == sq* ]]; then unset ${mod}_squelch elif [[ "$value" == td* ]]; then unset ${mod}_tx_delay + elif [[ "$value" == ti* ]]; then unset ${mod}_target_ip elif [[ "$value" == tl* ]]; then unset ${mod}_tx_level elif [[ "$value" == to* ]]; then unset ${mod}_tx_offset elif [[ "$value" == tx* ]]; then unset ${mod}_tx_frequency @@ -628,6 +631,7 @@ WriteCFGFile () { q=${p}_tx_frequency; [ -z ${!q+x} ] || echo "${q}=${!q}" >> $outFile q=${p}_rx_frequency; [ -z ${!q+x} ] || echo "${q}=${!q}" >> $outFile q=${p}_internal_ip; [ -z ${!q+x} ] || echo "${q}='${!q}'" >> $outFile + q=${p}_target_ip; [ -z ${!q+x} ] || echo "${q}='${!q}'" >> $outFile q=${p}_gateway_port; [ -z ${!q+x} ] || echo "${q}=${!q}" >> $outFile q=${p}_local_port; [ -z ${!q+x} ] || echo "${q}=${!q}" >> $outFile elif [[ "${!p}" == "mmdvmmodem" ]]; then @@ -734,7 +738,7 @@ while [[ "$ans" != q* ]] do clear echo - echo " QnConfig Main Menu V#210409" + echo " QnConfig Main Menu V#210420" echo echo -n "a : Module A - "; if [ -z $module_a ]; then echo ""; else echo "${module_a^^}"; fi echo -n "b : Module B - "; if [ -z $module_b ]; then echo ""; else echo "${module_b^^}"; fi