USRP parameters for two-way client

pull/1/head
Tom Early 3 years ago
parent 95e8c4d07a
commit 9b1df226a4

@ -12,7 +12,7 @@ Country = GB
Sponsor = My Home Club Sponsor = My Home Club
[IpAddresses] [IP Addresses]
# Binding addresses are usually the 'any' address # Binding addresses are usually the 'any' address
IPv4Binding = 0.0.0.0 IPv4Binding = 0.0.0.0
@ -80,10 +80,11 @@ Port = 10017
[USRP] [USRP]
Enable = false Enable = false
Port = 32000 RxPort = 34000
TxPort = 32000
Module = A # this has to be a transcoded module! Module = A # this has to be a transcoded module!
Callsign = ALLSTAR Callsign = ALLSTAR
#FilePath = /home/usr/Clients.txt # An experimental area of development #FilePath = /home/usr/Clients.txt
[YSF] [YSF]
Port = 42000 Port = 42000

@ -51,7 +51,7 @@
#define JG3 "G3" #define JG3 "G3"
#define JG3TERMINALPATH "G3TerminalPath" #define JG3TERMINALPATH "G3TerminalPath"
#define JINTERLINKPATH "InterlinkPath" #define JINTERLINKPATH "InterlinkPath"
#define JIPADDRESSES "IpAddresses" #define JIPADDRESSES "IP Addresses"
#define JIPV4BINDING "IPv4Binding" #define JIPV4BINDING "IPv4Binding"
#define JIPV4EXTERNAL "IPv4External" #define JIPV4EXTERNAL "IPv4External"
#define JIPV6BINDING "IPv6Binding" #define JIPV6BINDING "IPv6Binding"
@ -73,10 +73,12 @@
#define JREGISTRATIONDESCRIPTION "RegistrationDescription" #define JREGISTRATIONDESCRIPTION "RegistrationDescription"
#define JREGISTRATIONID "RegistrationID" #define JREGISTRATIONID "RegistrationID"
#define JREGISTRATIONNAME "RegistrationName" #define JREGISTRATIONNAME "RegistrationName"
#define JRXPORT "RxPort"
#define JSPONSOR "Sponsor" #define JSPONSOR "Sponsor"
#define JSYSOPEMAIL "SysopEmail" #define JSYSOPEMAIL "SysopEmail"
#define JTRANSCODED "Transcoded" #define JTRANSCODED "Transcoded"
#define JTRANSCODER "Transcoder" #define JTRANSCODER "Transcoder"
#define JTXPORT "TxPort"
#define JURF "URF" #define JURF "URF"
#define JURL "URL" #define JURL "URL"
#define JUSRP "USRP" #define JUSRP "USRP"
@ -396,8 +398,10 @@ bool CConfigure::ReadData(const std::string &path)
case ESection::usrp: case ESection::usrp:
if (0 == key.compare(JENABLE)) if (0 == key.compare(JENABLE))
data[g_Keys.usrp.enable] = IS_TRUE(value[0]); data[g_Keys.usrp.enable] = IS_TRUE(value[0]);
else if (0 == key.compare(JPORT)) else if (0 == key.compare(JTXPORT))
data[g_Keys.usrp.port] = getUnsigned(value, "USRP Port", 1024, 65535, 32000); data[g_Keys.usrp.txport] = getUnsigned(value, "USRP TxPort", 1024, 65535, 32000);
else if (0 == key.compare(JRXPORT))
data[g_Keys.usrp.rxport] = getUnsigned(value, "USRP RxPort", 1024, 65535, 34000);
else if (0 == key.compare(JMODULE)) else if (0 == key.compare(JMODULE))
data[g_Keys.usrp.module] = value.substr(0, 1); data[g_Keys.usrp.module] = value.substr(0, 1);
else if (0 == key.compare(JCALLSIGN)) else if (0 == key.compare(JCALLSIGN))
@ -684,7 +688,8 @@ bool CConfigure::ReadData(const std::string &path)
rval = true; rval = true;
} }
} }
isDefined(ErrorLevel::fatal, JUSRP, JPORT, g_Keys.usrp.port, rval); isDefined(ErrorLevel::fatal, JUSRP, JTXPORT, g_Keys.usrp.txport, rval);
isDefined(ErrorLevel::fatal, JUSRP, JRXPORT, g_Keys.usrp.rxport, rval);
isDefined(ErrorLevel::fatal, JUSRP, JCALLSIGN, g_Keys.usrp.callsign, rval); isDefined(ErrorLevel::fatal, JUSRP, JCALLSIGN, g_Keys.usrp.callsign, rval);
//if (isDefined(ErrorLevel::fatal, JUSRP, JFILEPATH, g_Keys.usrp.filepath, rval)) //if (isDefined(ErrorLevel::fatal, JUSRP, JFILEPATH, g_Keys.usrp.filepath, rval))
if (data.contains(g_Keys.usrp.filepath)) if (data.contains(g_Keys.usrp.filepath))

@ -49,8 +49,8 @@ struct SJsonKeys {
modules { "Modules", "TranscodedModules", modules { "Modules", "TranscodedModules",
"DescriptionA", "DescriptionB", "DescriptionC", "DescriptionD", "DescriptionE", "DescriptionF", "DescriptionG", "DescriptionH", "DescriptionI", "DescriptionJ", "DescriptionK", "DescriptionL", "DescriptionM", "DescriptionN", "DescriptionO", "DescriptionP", "DescriptionQ", "DescriptionR", "DescriptionS", "DescriptionT", "DescriptionU", "DescriptionV", "DescriptionW", "DescriptionX", "DescriptionY", "DescriptionZ" }; "DescriptionA", "DescriptionB", "DescriptionC", "DescriptionD", "DescriptionE", "DescriptionF", "DescriptionG", "DescriptionH", "DescriptionI", "DescriptionJ", "DescriptionK", "DescriptionL", "DescriptionM", "DescriptionN", "DescriptionO", "DescriptionP", "DescriptionQ", "DescriptionR", "DescriptionS", "DescriptionT", "DescriptionU", "DescriptionV", "DescriptionW", "DescriptionX", "DescriptionY", "DescriptionZ" };
struct USRP { const std::string enable, port, module, callsign, filepath; } struct USRP { const std::string enable, txport,rxport, module, callsign, filepath; }
usrp { "usrpEnable", "urspPort", "usrpModule", "usrpCallsign", "usrpFilePath" }; usrp { "usrpEnable", "urspTxPort", "usrpRxPort", "usrpModule", "usrpCallsign", "usrpFilePath" };
struct P25NXDN { const std::string port, autolinkmod, reflectorid; } struct P25NXDN { const std::string port, autolinkmod, reflectorid; }
p25 { "P25Port", "P25AutolinkMod", "P25ReflectorID" }, p25 { "P25Port", "P25AutolinkMod", "P25ReflectorID" },

@ -94,7 +94,7 @@ bool CProtocols::Init(void)
if (g_Conf.GetBoolean(g_Keys.usrp.enable)) if (g_Conf.GetBoolean(g_Keys.usrp.enable))
{ {
m_Protocols.emplace_back(std::unique_ptr<CUSRPProtocol>(new CUSRPProtocol)); m_Protocols.emplace_back(std::unique_ptr<CUSRPProtocol>(new CUSRPProtocol));
if (! m_Protocols.back()->Initialize("USRP", EProtocol::usrp, uint16_t(g_Conf.GetUnsigned(g_Keys.usrp.port)), USRP_IPV4, USRP_IPV6)) if (! m_Protocols.back()->Initialize("USRP", EProtocol::usrp, uint16_t(g_Conf.GetUnsigned(g_Keys.usrp.rxport)), USRP_IPV4, USRP_IPV6))
return false; return false;
} }

@ -1,4 +1,7 @@
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// urfd -- The universal reflector // urfd -- The universal reflector
// Copyright © 2023 Thomas A. Early N7TAE
// Copyright © 2023 Doug McLain AD8DP // Copyright © 2023 Doug McLain AD8DP
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
@ -14,7 +17,7 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include "Defines.h"
#include <string.h> #include <string.h>
#include "USRPClient.h" #include "USRPClient.h"
#include "USRPProtocol.h" #include "USRPProtocol.h"
@ -39,13 +42,21 @@ bool CUSRPProtocol::Initialize(const char *type, const EProtocol ptype, const ui
std::ifstream file; std::ifstream file;
std::streampos size; std::streampos size;
// base class // base class, create the listing port for the read-write client
if (! CProtocol::Initialize(type, ptype, port, has_ipv4, has_ipv6)) if (! CProtocol::Initialize(type, ptype, port, has_ipv4, has_ipv6))
return false; return false;
m_CStr.assign(g_Conf.GetString(g_Keys.usrp.callsign)); m_Module = g_Conf.GetAutolinkModule(g_Keys.usrp.module);
m_Module = g_Conf.GetString(g_Keys.usrp.module).at(0);
// create the one special USRP Tx/Rx client
m_Callsign.SetCallsign(g_Conf.GetString(g_Keys.usrp.callsign), false);
CIp ip(AF_INET, uint16_t(g_Conf.GetUnsigned(g_Keys.usrp.txport)), g_Conf.GetString(g_Keys.ip.ipv4bind).c_str());
auto newclient = std::make_shared<CUSRPClient>(m_Callsign, ip);
newclient->SetReflectorModule(m_Module);
g_Refl.GetClients()->AddClient(newclient);
g_Refl.ReleaseClients();
// now create "listen-only" clients, as many as specified
file.open(g_Conf.GetString(g_Keys.usrp.filepath), std::ios::in | std::ios::binary | std::ios::ate); file.open(g_Conf.GetString(g_Keys.usrp.filepath), std::ios::in | std::ios::binary | std::ios::ate);
if ( file.is_open() ) if ( file.is_open() )
{ {
@ -79,9 +90,10 @@ bool CUSRPProtocol::Initialize(const char *type, const EProtocol ptype, const ui
((port = ::strtok(nullptr, ";")) != nullptr) && ((port = ::strtok(nullptr, ";")) != nullptr) &&
((clientcs = ::strtok(nullptr, ";")) != nullptr) ) ((clientcs = ::strtok(nullptr, ";")) != nullptr) )
{ {
uint32_t ui = atoi(port); uint16_t ui = atoi(port);
CIp Ip(AF_INET, ui, ip); CIp Ip(AF_INET, ui, ip);
CCallsign cs(clientcs); CCallsign cs;
cs.SetCallsign(clientcs, false);
auto newclient = std::make_shared<CUSRPClient>(cs, Ip); auto newclient = std::make_shared<CUSRPClient>(cs, Ip);
newclient->SetReflectorModule(m_Module); newclient->SetReflectorModule(m_Module);
g_Refl.GetClients()->AddClient(newclient); g_Refl.GetClients()->AddClient(newclient);
@ -274,14 +286,12 @@ bool CUSRPProtocol::IsValidDvPacket(const CIp &Ip, const CBuffer &Buffer, std::u
if ( !stream ) if ( !stream )
{ {
m_uiStreamId = static_cast<uint32_t>(::rand()); m_uiStreamId = static_cast<uint32_t>(::rand());
CCallsign csMY, rpt1, rpt2, csUR; CCallsign csMY;
csMY.SetCallsign(m_CStr, false); CCallsign rpt1 = m_Callsign;
rpt1.SetCallsign(m_CStr, false); CCallsign rpt2 = m_ReflectorCallsign;
rpt2 = m_ReflectorCallsign;
csUR.SetCallsign("CQCQCQ", false);
rpt1.SetCSModule(m_Module); rpt1.SetCSModule(m_Module);
rpt2.SetCSModule(' '); rpt2.SetCSModule(' ');
header = std::unique_ptr<CDvHeaderPacket>(new CDvHeaderPacket(csMY, csUR, rpt1, rpt2, m_uiStreamId, true)); header = std::unique_ptr<CDvHeaderPacket>(new CDvHeaderPacket(csMY, CCallsign("CQCQCQ"), rpt1, rpt2, m_uiStreamId, true));
OnDvHeaderPacketIn(header, Ip); OnDvHeaderPacketIn(header, Ip);
} }
@ -307,11 +317,9 @@ bool CUSRPProtocol::IsValidDvHeaderPacket(const CIp &Ip, const CBuffer &Buffer,
CCallsign csMY = CCallsign("", uiSrcId); CCallsign csMY = CCallsign("", uiSrcId);
CCallsign rpt1 = CCallsign("", uiSrcId); CCallsign rpt1 = CCallsign("", uiSrcId);
CCallsign rpt2 = m_ReflectorCallsign; CCallsign rpt2 = m_ReflectorCallsign;
CCallsign csUR;
csUR.SetCallsign("CQCQCQ", false);
rpt1.SetCSModule(m_Module); rpt1.SetCSModule(m_Module);
rpt2.SetCSModule(' '); rpt2.SetCSModule(' ');
header = std::unique_ptr<CDvHeaderPacket>(new CDvHeaderPacket(csMY, csUR, rpt1, rpt2, m_uiStreamId, true)); header = std::unique_ptr<CDvHeaderPacket>(new CDvHeaderPacket(csMY, CCallsign("CQCQCQ"), rpt1, rpt2, m_uiStreamId, true));
} }
return true; return true;
} }

@ -70,6 +70,7 @@ protected:
private: private:
// CConfigure data // CConfigure data
std::string m_CStr; CCallsign m_Callsign;
char m_Module; char m_Module;
uint16_t m_txPort;
}; };

Loading…
Cancel
Save

Powered by TurnKey Linux.