mirror of
https://github.com/nostar/urfd.git
synced 2026-11-08 04:19:39 +00:00
rename {Get,Set}Module
This commit is contained in:
1 parent
7f81e70233
commit
da6404535e
21 files changed
+79
-79
No files matched your search
@@ -221,7 +221,7 @@ void CBMProtocol::HandleQueue(void)
|
||||
while ( (client = clients->FindNextClient(EProtocol::xlx, it)) != nullptr )
|
||||
{
|
||||
// is this client busy ?
|
||||
if ( !client->IsAMaster() && (client->GetReflectorModule() == packet->GetModule()) )
|
||||
if ( !client->IsAMaster() && (client->GetReflectorModule() == packet->GetPacketModule()) )
|
||||
{
|
||||
// no, send the packet
|
||||
// this is protocol revision dependent
|
||||
|
||||
@@ -219,7 +219,7 @@ void CCallsign::SetDmrid(const uint8_t *buffer, bool UpdateCallsign)
|
||||
SetDmrid((uint32_t)::strtol(sz, nullptr, 16), UpdateCallsign);
|
||||
}
|
||||
|
||||
void CCallsign::SetModule(char c)
|
||||
void CCallsign::SetCSModule(char c)
|
||||
{
|
||||
m_Module = c;
|
||||
CSIn();
|
||||
|
||||
@@ -48,7 +48,7 @@ public:
|
||||
void SetCallsign(const uint8_t *, int, bool = true);
|
||||
void SetDmrid(uint32_t, bool = true);
|
||||
void SetDmrid(const uint8_t *, bool = true);
|
||||
void SetModule(char);
|
||||
void SetCSModule(char);
|
||||
void SetSuffix(const char *);
|
||||
void SetSuffix(const uint8_t *, int);
|
||||
|
||||
@@ -61,7 +61,7 @@ public:
|
||||
const std::string GetCS(unsigned len = 9) const;
|
||||
uint32_t GetDmrid(void) const { return m_uiDmrid; }
|
||||
void GetSuffix(uint8_t *) const;
|
||||
char GetModule(void) const { return m_Module; }
|
||||
char GetCSModule(void) const { return m_Module; }
|
||||
|
||||
// compare
|
||||
bool HasSameCallsign(const CCallsign &) const;
|
||||
|
||||
@@ -108,7 +108,7 @@ void CClient::GetJsonObject(char *Buffer)
|
||||
|
||||
::sprintf(sz, "{\"callsign\":\"%s\",\"module\":\"%c\",\"linkedto\":\"%c\",\"time\":\"%s\"}",
|
||||
cs,
|
||||
m_Callsign.GetModule(),
|
||||
m_Callsign.GetCSModule(),
|
||||
m_ReflectorModule,
|
||||
mbstr);
|
||||
::strcat(Buffer, sz);
|
||||
|
||||
+2
-2
@@ -44,12 +44,12 @@ public:
|
||||
const CCallsign &GetCallsign(void) const { return m_Callsign; }
|
||||
const CIp &GetIp(void) const { return m_Ip; }
|
||||
bool HasModule(void) const { return m_Callsign.HasModule(); }
|
||||
char GetModule(void) const { return m_Callsign.GetModule(); }
|
||||
char GetCSModule(void) const { return m_Callsign.GetCSModule(); }
|
||||
bool HasReflectorModule(void) const { return m_ReflectorModule != ' '; }
|
||||
char GetReflectorModule(void) const { return m_ReflectorModule; }
|
||||
|
||||
// set
|
||||
void SetModule(char c) { m_Callsign.SetModule(c); }
|
||||
void SetCSModule(char c) { m_Callsign.SetCSModule(c); }
|
||||
void SetReflectorModule(char c) { m_ReflectorModule = c; }
|
||||
|
||||
// identity
|
||||
|
||||
@@ -174,7 +174,7 @@ std::shared_ptr<CClient> CClients::FindClient(const CCallsign &Callsign, char mo
|
||||
// find client
|
||||
for ( auto it=begin(); it!=end(); it++ )
|
||||
{
|
||||
if ( (*it)->GetCallsign().HasSameCallsign(Callsign) && ((*it)->GetModule() == module) && ((*it)->GetIp() == Ip) && ((*it)->GetProtocol() == Protocol) )
|
||||
if ( (*it)->GetCallsign().HasSameCallsign(Callsign) && ((*it)->GetCSModule() == module) && ((*it)->GetIp() == Ip) && ((*it)->GetProtocol() == Protocol) )
|
||||
{
|
||||
return *it;
|
||||
}
|
||||
|
||||
@@ -226,7 +226,7 @@ void CDcsProtocol::HandleQueue(void)
|
||||
auto packet = m_Queue.pop();
|
||||
|
||||
// get our sender's id
|
||||
const auto module = packet->GetModule();
|
||||
const auto module = packet->GetPacketModule();
|
||||
|
||||
// check if it's header and update cache
|
||||
if ( packet->IsDvHeader() )
|
||||
@@ -330,7 +330,7 @@ bool CDcsProtocol::IsValidConnectPacket(const CBuffer &Buffer, CCallsign *callsi
|
||||
if ( Buffer.size() == 519 )
|
||||
{
|
||||
callsign->SetCallsign(Buffer.data(), 8);
|
||||
callsign->SetModule(Buffer.data()[8]);
|
||||
callsign->SetCSModule(Buffer.data()[8]);
|
||||
*reflectormodule = Buffer.data()[9];
|
||||
valid = (callsign->IsValid() && IsLetter(*reflectormodule));
|
||||
}
|
||||
@@ -343,13 +343,13 @@ bool CDcsProtocol::IsValidDisconnectPacket(const CBuffer &Buffer, CCallsign *cal
|
||||
if ((Buffer.size() == 11) && (Buffer.data()[9] == ' '))
|
||||
{
|
||||
callsign->SetCallsign(Buffer.data(), 8);
|
||||
callsign->SetModule(Buffer.data()[8]);
|
||||
callsign->SetCSModule(Buffer.data()[8]);
|
||||
valid = callsign->IsValid();
|
||||
}
|
||||
else if ((Buffer.size() == 19) && (Buffer.data()[9] == ' ') && (Buffer.data()[10] == 0x00))
|
||||
{
|
||||
callsign->SetCallsign(Buffer.data(), 8);
|
||||
callsign->SetModule(Buffer.data()[8]);
|
||||
callsign->SetCSModule(Buffer.data()[8]);
|
||||
valid = callsign->IsValid();
|
||||
}
|
||||
return valid;
|
||||
@@ -411,8 +411,8 @@ void CDcsProtocol::EncodeKeepAlivePacket(CBuffer *Buffer, std::shared_ptr<CClien
|
||||
Buffer->Append((uint8_t)Client->GetReflectorModule());
|
||||
Buffer->Append((uint8_t)' ');
|
||||
Buffer->Append((uint8_t *)(const char *)Client->GetCallsign(), CALLSIGN_LEN-1);
|
||||
Buffer->Append((uint8_t)Client->GetModule());
|
||||
Buffer->Append((uint8_t)Client->GetModule());
|
||||
Buffer->Append((uint8_t)Client->GetCSModule());
|
||||
Buffer->Append((uint8_t)Client->GetCSModule());
|
||||
Buffer->Append(tag, sizeof(tag));
|
||||
}
|
||||
|
||||
@@ -424,7 +424,7 @@ void CDcsProtocol::EncodeConnectAckPacket(const CCallsign &Callsign, char Reflec
|
||||
Callsign.GetCallsign(cs);
|
||||
Buffer->Set(cs, CALLSIGN_LEN-1);
|
||||
Buffer->Append((uint8_t)' ');
|
||||
Buffer->Append((uint8_t)Callsign.GetModule());
|
||||
Buffer->Append((uint8_t)Callsign.GetCSModule());
|
||||
Buffer->Append((uint8_t)ReflectorModule);
|
||||
Buffer->Append(tag, sizeof(tag));
|
||||
}
|
||||
@@ -437,7 +437,7 @@ void CDcsProtocol::EncodeConnectNackPacket(const CCallsign &Callsign, char Refle
|
||||
Callsign.GetCallsign(cs);
|
||||
Buffer->Set(cs, CALLSIGN_LEN-1);
|
||||
Buffer->Append((uint8_t)' ');
|
||||
Buffer->Append((uint8_t)Callsign.GetModule());
|
||||
Buffer->Append((uint8_t)Callsign.GetCSModule());
|
||||
Buffer->Append((uint8_t)ReflectorModule);
|
||||
Buffer->Append(tag, sizeof(tag));
|
||||
}
|
||||
@@ -446,7 +446,7 @@ void CDcsProtocol::EncodeDisconnectPacket(CBuffer *Buffer, std::shared_ptr<CClie
|
||||
{
|
||||
Buffer->Set((uint8_t *)(const char *)Client->GetCallsign(), CALLSIGN_LEN-1);
|
||||
Buffer->Append((uint8_t)' ');
|
||||
Buffer->Append((uint8_t)Client->GetModule());
|
||||
Buffer->Append((uint8_t)Client->GetCSModule());
|
||||
Buffer->Append((uint8_t)0x00);
|
||||
Buffer->Append((uint8_t *)(const char *)GetReflectorCallsign(), CALLSIGN_LEN-1);
|
||||
Buffer->Append((uint8_t)' ');
|
||||
|
||||
@@ -106,7 +106,7 @@ void CDextraProtocol::Task(void)
|
||||
// is this an ack for a link request?
|
||||
CPeerCallsignList *list = g_GateKeeper.GetPeerList();
|
||||
CCallsignListItem *item = list->FindListItem(Callsign);
|
||||
if ( item != nullptr && Callsign.GetModule() == item->GetModules()[1] && ToLinkModule == item->GetModules()[0] )
|
||||
if ( item != nullptr && Callsign.GetCSModule() == item->GetModules()[1] && ToLinkModule == item->GetModules()[0] )
|
||||
{
|
||||
std::cout << "DExtra ack packet for module " << ToLinkModule << " from " << Callsign << " at " << Ip << std::endl;
|
||||
|
||||
@@ -245,7 +245,7 @@ void CDextraProtocol::HandleQueue(void)
|
||||
while ( (client = clients->FindNextClient(EProtocol::dextra, it)) != nullptr )
|
||||
{
|
||||
// is this client busy ?
|
||||
if ( !client->IsAMaster() && (client->GetReflectorModule() == packet->GetModule()) )
|
||||
if ( !client->IsAMaster() && (client->GetReflectorModule() == packet->GetPacketModule()) )
|
||||
{
|
||||
// no, send the packet
|
||||
int n = packet->IsDvHeader() ? 5 : 1;
|
||||
@@ -427,7 +427,7 @@ void CDextraProtocol::OnDvHeaderPacketIn(std::unique_ptr<CDvHeaderPacket> &Heade
|
||||
// the module the client is linked to
|
||||
auto m = client->GetReflectorModule();
|
||||
Header->SetRpt2Module(m);
|
||||
rpt2.SetModule(m);
|
||||
rpt2.SetCSModule(m);
|
||||
}
|
||||
// and try to open the stream
|
||||
if ( (stream = g_Reflector.OpenStream(Header, client)) != nullptr )
|
||||
@@ -454,7 +454,7 @@ bool CDextraProtocol::IsValidConnectPacket(const CBuffer &Buffer, CCallsign &cal
|
||||
if ((Buffer.size() == 11) && (Buffer.data()[9] != ' '))
|
||||
{
|
||||
callsign.SetCallsign(Buffer.data(), 8);
|
||||
callsign.SetModule(Buffer.data()[8]);
|
||||
callsign.SetCSModule(Buffer.data()[8]);
|
||||
module = Buffer.data()[9];
|
||||
valid = (callsign.IsValid() && IsLetter(module));
|
||||
// detect revision
|
||||
@@ -480,7 +480,7 @@ bool CDextraProtocol::IsValidDisconnectPacket(const CBuffer &Buffer, CCallsign *
|
||||
if ((Buffer.size() == 11) && (Buffer.data()[9] == ' '))
|
||||
{
|
||||
callsign->SetCallsign(Buffer.data(), 8);
|
||||
callsign->SetModule(Buffer.data()[8]);
|
||||
callsign->SetCSModule(Buffer.data()[8]);
|
||||
valid = callsign->IsValid();
|
||||
}
|
||||
return valid;
|
||||
|
||||
@@ -282,11 +282,11 @@ void CDmrmmdvmProtocol::OnDvHeaderPacketIn(std::unique_ptr<CDvHeaderPacket> &Hea
|
||||
// not linked yet
|
||||
if ( cmd == CMD_LINK )
|
||||
{
|
||||
if ( g_Reflector.IsValidModule(rpt2.GetModule()) )
|
||||
if ( g_Reflector.IsValidModule(rpt2.GetCSModule()) )
|
||||
{
|
||||
std::cout << "DMRmmdvm client " << client->GetCallsign() << " linking on module " << rpt2.GetModule() << std::endl;
|
||||
std::cout << "DMRmmdvm client " << client->GetCallsign() << " linking on module " << rpt2.GetCSModule() << std::endl;
|
||||
// link
|
||||
client->SetReflectorModule(rpt2.GetModule());
|
||||
client->SetReflectorModule(rpt2.GetCSModule());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -308,12 +308,12 @@ void CDmrmmdvmProtocol::OnDvHeaderPacketIn(std::unique_ptr<CDvHeaderPacket> &Hea
|
||||
// replace rpt2 module with currently linked module
|
||||
auto m = client->GetReflectorModule();
|
||||
Header->SetRpt2Module(m);
|
||||
rpt2.SetModule(m);
|
||||
rpt2.SetCSModule(m);
|
||||
}
|
||||
}
|
||||
|
||||
// and now, re-check module is valid && that it's not a private call
|
||||
if ( g_Reflector.IsValidModule(rpt2.GetModule()) && (CallType == DMR_GROUP_CALL) )
|
||||
if ( g_Reflector.IsValidModule(rpt2.GetCSModule()) && (CallType == DMR_GROUP_CALL) )
|
||||
{
|
||||
// yes, try to open the stream
|
||||
if ( (stream = g_Reflector.OpenStream(Header, client)) != nullptr )
|
||||
@@ -354,7 +354,7 @@ void CDmrmmdvmProtocol::HandleQueue(void)
|
||||
auto packet = m_Queue.pop();
|
||||
|
||||
// get our sender's id
|
||||
const auto mod = packet->GetModule();
|
||||
const auto mod = packet->GetPacketModule();
|
||||
|
||||
// encode
|
||||
CBuffer buffer;
|
||||
@@ -409,7 +409,7 @@ void CDmrmmdvmProtocol::HandleQueue(void)
|
||||
while ( (client = clients->FindNextClient(EProtocol::dmrmmdvm, it)) != nullptr )
|
||||
{
|
||||
// is this client busy ?
|
||||
if ( !client->IsAMaster() && (client->GetReflectorModule() == packet->GetModule()) )
|
||||
if ( !client->IsAMaster() && (client->GetReflectorModule() == packet->GetPacketModule()) )
|
||||
{
|
||||
// no, send the packet
|
||||
Send(buffer, client->GetIp());
|
||||
@@ -471,7 +471,7 @@ bool CDmrmmdvmProtocol::IsValidKeepAlivePacket(const CBuffer &Buffer, CCallsign
|
||||
{
|
||||
uint32_t uiRptrId = MAKEDWORD(MAKEWORD(Buffer.data()[10],Buffer.data()[9]),MAKEWORD(Buffer.data()[8],Buffer.data()[7]));
|
||||
callsign->SetDmrid(uiRptrId, true);
|
||||
callsign->SetModule(MMDVM_MODULE_ID);
|
||||
callsign->SetCSModule(MMDVM_MODULE_ID);
|
||||
valid = callsign->IsValid();
|
||||
}
|
||||
return valid;
|
||||
@@ -486,7 +486,7 @@ bool CDmrmmdvmProtocol::IsValidConnectPacket(const CBuffer &Buffer, CCallsign *c
|
||||
{
|
||||
uint32_t uiRptrId = MAKEDWORD(MAKEWORD(Buffer.data()[7],Buffer.data()[6]),MAKEWORD(Buffer.data()[5],Buffer.data()[4]));
|
||||
callsign->SetDmrid(uiRptrId, true);
|
||||
callsign->SetModule(MMDVM_MODULE_ID);
|
||||
callsign->SetCSModule(MMDVM_MODULE_ID);
|
||||
valid = callsign->IsValid();
|
||||
if ( !valid)
|
||||
{
|
||||
@@ -505,7 +505,7 @@ bool CDmrmmdvmProtocol::IsValidAuthenticationPacket(const CBuffer &Buffer, CCall
|
||||
{
|
||||
uint32_t uiRptrId = MAKEDWORD(MAKEWORD(Buffer.data()[7],Buffer.data()[6]),MAKEWORD(Buffer.data()[5],Buffer.data()[4]));
|
||||
callsign->SetDmrid(uiRptrId, true);
|
||||
callsign->SetModule(MMDVM_MODULE_ID);
|
||||
callsign->SetCSModule(MMDVM_MODULE_ID);
|
||||
valid = callsign->IsValid();
|
||||
if ( !valid)
|
||||
{
|
||||
@@ -525,7 +525,7 @@ bool CDmrmmdvmProtocol::IsValidDisconnectPacket(const CBuffer &Buffer, CCallsign
|
||||
{
|
||||
uint32_t uiRptrId = MAKEDWORD(MAKEWORD(Buffer.data()[7],Buffer.data()[6]),MAKEWORD(Buffer.data()[5],Buffer.data()[4]));
|
||||
callsign->SetDmrid(uiRptrId, true);
|
||||
callsign->SetModule(MMDVM_MODULE_ID);
|
||||
callsign->SetCSModule(MMDVM_MODULE_ID);
|
||||
valid = callsign->IsValid();
|
||||
}
|
||||
return valid;
|
||||
@@ -540,7 +540,7 @@ bool CDmrmmdvmProtocol::IsValidConfigPacket(const CBuffer &Buffer, CCallsign *ca
|
||||
{
|
||||
uint32_t uiRptrId = MAKEDWORD(MAKEWORD(Buffer.data()[7],Buffer.data()[6]),MAKEWORD(Buffer.data()[5],Buffer.data()[4]));
|
||||
callsign->SetDmrid(uiRptrId, true);
|
||||
callsign->SetModule(MMDVM_MODULE_ID);
|
||||
callsign->SetCSModule(MMDVM_MODULE_ID);
|
||||
valid = callsign->IsValid();
|
||||
if ( !valid)
|
||||
{
|
||||
@@ -560,7 +560,7 @@ bool CDmrmmdvmProtocol::IsValidOptionPacket(const CBuffer &Buffer, CCallsign *ca
|
||||
{
|
||||
uint32_t uiRptrId = MAKEDWORD(MAKEWORD(Buffer.data()[7],Buffer.data()[6]),MAKEWORD(Buffer.data()[5],Buffer.data()[4]));
|
||||
callsign->SetDmrid(uiRptrId, true);
|
||||
callsign->SetModule(MMDVM_MODULE_ID);
|
||||
callsign->SetCSModule(MMDVM_MODULE_ID);
|
||||
valid = callsign->IsValid();
|
||||
}
|
||||
return valid;
|
||||
@@ -641,9 +641,9 @@ bool CDmrmmdvmProtocol::IsValidDvHeaderPacket(const CBuffer &Buffer, std::unique
|
||||
// build DVHeader
|
||||
CCallsign csMY = CCallsign("", uiSrcId);
|
||||
CCallsign rpt1 = CCallsign("", uiRptrId);
|
||||
rpt1.SetModule(MMDVM_MODULE_ID);
|
||||
rpt1.SetCSModule(MMDVM_MODULE_ID);
|
||||
CCallsign rpt2 = m_ReflectorCallsign;
|
||||
rpt2.SetModule(DmrDstIdToModule(uiDstId));
|
||||
rpt2.SetCSModule(DmrDstIdToModule(uiDstId));
|
||||
|
||||
// and packet
|
||||
header = std::unique_ptr<CDvHeaderPacket>(new CDvHeaderPacket(uiSrcId, CCallsign("CQCQCQ"), rpt1, rpt2, uiStreamId, 0, 0));
|
||||
|
||||
@@ -227,7 +227,7 @@ void CDmrplusProtocol::HandleQueue(void)
|
||||
auto packet = m_Queue.pop();
|
||||
|
||||
// get our sender's id
|
||||
const auto mod = packet->GetModule();
|
||||
const auto mod = packet->GetPacketModule();
|
||||
|
||||
// encode
|
||||
CBuffer buffer;
|
||||
@@ -274,7 +274,7 @@ void CDmrplusProtocol::HandleQueue(void)
|
||||
while ( (client = clients->FindNextClient(EProtocol::dmrplus, it)) != nullptr )
|
||||
{
|
||||
// is this client busy ?
|
||||
if ( !client->IsAMaster() && (client->GetReflectorModule() == packet->GetModule()) )
|
||||
if ( !client->IsAMaster() && (client->GetReflectorModule() == packet->GetPacketModule()) )
|
||||
{
|
||||
// no, send the packet
|
||||
Send(buffer, client->GetIp());
|
||||
@@ -365,7 +365,7 @@ bool CDmrplusProtocol::IsValidConnectPacket(const CBuffer &Buffer, CCallsign *ca
|
||||
sz[8] = 0;
|
||||
uint32_t dmrid = atoi(sz);
|
||||
callsign->SetDmrid(dmrid, true);
|
||||
callsign->SetModule(DMRPLUS_MODULE_ID);
|
||||
callsign->SetCSModule(DMRPLUS_MODULE_ID);
|
||||
memcpy(sz, &Buffer.data()[8], 4);
|
||||
sz[4] = 0;
|
||||
*reflectormodule = DmrDstIdToModule(atoi(sz));
|
||||
@@ -388,7 +388,7 @@ bool CDmrplusProtocol::IsValidDisconnectPacket(const CBuffer &Buffer, CCallsign
|
||||
sz[8] = 0;
|
||||
uint32_t dmrid = atoi(sz);
|
||||
callsign->SetDmrid(dmrid, true);
|
||||
callsign->SetModule(DMRPLUS_MODULE_ID);
|
||||
callsign->SetCSModule(DMRPLUS_MODULE_ID);
|
||||
*reflectormodule = Buffer.data()[11] - '0' + 'A';
|
||||
valid = (callsign->IsValid() && std::isupper(*reflectormodule));
|
||||
}
|
||||
@@ -415,9 +415,9 @@ bool CDmrplusProtocol::IsValidDvHeaderPacket(const CIp &Ip, const CBuffer &Buffe
|
||||
// build DVHeader
|
||||
CCallsign csMY = CCallsign("", uiSrcId);
|
||||
CCallsign rpt1 = CCallsign("", uiSrcId);
|
||||
rpt1.SetModule(DMRPLUS_MODULE_ID);
|
||||
rpt1.SetCSModule(DMRPLUS_MODULE_ID);
|
||||
CCallsign rpt2 = m_ReflectorCallsign;
|
||||
rpt2.SetModule(DmrDstIdToModule(uiDstId));
|
||||
rpt2.SetCSModule(DmrDstIdToModule(uiDstId));
|
||||
uint32_t uiStreamId = IpToStreamId(Ip);
|
||||
|
||||
// and packet
|
||||
|
||||
@@ -185,7 +185,7 @@ void CDplusProtocol::OnDvHeaderPacketIn(std::unique_ptr<CDvHeaderPacket> &Header
|
||||
CCallsign rpt2(Header->GetRpt2Callsign());
|
||||
|
||||
// first, check module is valid
|
||||
if ( g_Reflector.IsValidModule(rpt2.GetModule()) )
|
||||
if ( g_Reflector.IsValidModule(rpt2.GetCSModule()) )
|
||||
{
|
||||
// find this client
|
||||
std::shared_ptr<CClient>client = g_Reflector.GetClients()->FindClient(Ip, EProtocol::dplus);
|
||||
@@ -199,7 +199,7 @@ void CDplusProtocol::OnDvHeaderPacketIn(std::unique_ptr<CDvHeaderPacket> &Header
|
||||
// now we know its module, let's update it
|
||||
if ( !client->HasModule() )
|
||||
{
|
||||
client->SetModule(rpt1.GetModule());
|
||||
client->SetCSModule(rpt1.GetCSModule());
|
||||
}
|
||||
// get client callsign
|
||||
rpt1 = client->GetCallsign();
|
||||
@@ -236,7 +236,7 @@ void CDplusProtocol::HandleQueue(void)
|
||||
auto packet = m_Queue.pop();
|
||||
|
||||
// get our sender's id
|
||||
const auto mod = packet->GetModule();
|
||||
const auto mod = packet->GetPacketModule();
|
||||
|
||||
// check if it's header and update cache
|
||||
if ( packet->IsDvHeader() )
|
||||
|
||||
@@ -87,7 +87,7 @@ CDvHeaderPacket::CDvHeaderPacket(const CM17Packet &m17) : CPacket(m17)
|
||||
m_uiCrc = 0;
|
||||
m_csUR = CCallsign("CQCQCQ");
|
||||
m_csMY = m_csRPT1 = m_csRPT2 = m17.GetSourceCallsign();
|
||||
m_csRPT1.SetModule('G');
|
||||
m_csRPT1.SetCSModule('G');
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -78,14 +78,14 @@ public:
|
||||
const CCallsign &GetMyCallsign(void) const { return m_csMY; }
|
||||
|
||||
// get modules
|
||||
char GetUrModule(void) const { return m_csUR.GetModule(); }
|
||||
char GetRpt1Module(void) const { return m_csRPT1.GetModule(); }
|
||||
char GetRpt2Module(void) const { return m_csRPT2.GetModule(); }
|
||||
char GetMyModule(void) const { return m_csMY.GetModule(); }
|
||||
char GetUrModule(void) const { return m_csUR.GetCSModule(); }
|
||||
char GetRpt1Module(void) const { return m_csRPT1.GetCSModule(); }
|
||||
char GetRpt2Module(void) const { return m_csRPT2.GetCSModule(); }
|
||||
char GetMyModule(void) const { return m_csMY.GetCSModule(); }
|
||||
|
||||
// set callsigns
|
||||
void SetRpt2Callsign(const CCallsign &cs) { m_csRPT2 = cs; }
|
||||
void SetRpt2Module(char c) { m_csRPT2.SetModule(c); }
|
||||
void SetRpt2Module(char c) { m_csRPT2.SetCSModule(c); }
|
||||
|
||||
// operators
|
||||
bool operator ==(const CDvHeaderPacket &) const;
|
||||
|
||||
@@ -260,7 +260,7 @@ void CG3Protocol::ConfigTask(void)
|
||||
|
||||
if (isRepeaterCall)
|
||||
{
|
||||
if ((Call.HasSameCallsign(GetReflectorCallsign())) && (g_Reflector.IsValidModule(Call.GetModule())))
|
||||
if ((Call.HasSameCallsign(GetReflectorCallsign())) && (g_Reflector.IsValidModule(Call.GetCSModule())))
|
||||
{
|
||||
Buffer.data()[3] = 0x00; // ok
|
||||
}
|
||||
@@ -276,7 +276,7 @@ void CG3Protocol::ConfigTask(void)
|
||||
Buffer.data()[3] = 0x01; // reject
|
||||
}
|
||||
|
||||
char module = Call.GetModule();
|
||||
char module = Call.GetCSModule();
|
||||
|
||||
if (!strchr(m_Modules.c_str(), module) && !strchr(m_Modules.c_str(), '*'))
|
||||
{
|
||||
@@ -299,7 +299,7 @@ void CG3Protocol::ConfigTask(void)
|
||||
|
||||
if (isRepeaterCall)
|
||||
{
|
||||
Buffer.Append((uint8_t)Call.GetModule());
|
||||
Buffer.Append((uint8_t)Call.GetCSModule());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -460,7 +460,7 @@ void CG3Protocol::HandleQueue(void)
|
||||
while ( (client = clients->FindNextClient(EProtocol::g3, it)) != nullptr )
|
||||
{
|
||||
// is this client busy ?
|
||||
if ( !client->IsAMaster() && (client->GetReflectorModule() == packet->GetModule()) )
|
||||
if ( !client->IsAMaster() && (client->GetReflectorModule() == packet->GetPacketModule()) )
|
||||
{
|
||||
// not busy, send the packet
|
||||
int n = packet->IsDvHeader() ? 5 : 1;
|
||||
@@ -545,9 +545,9 @@ void CG3Protocol::OnDvHeaderPacketIn(std::unique_ptr<CDvHeaderPacket> &Header, c
|
||||
// move it to the proper module
|
||||
if (m_ReflectorCallsign.HasSameCallsign(rpt2))
|
||||
{
|
||||
if (client->GetReflectorModule() != rpt2.GetModule())
|
||||
if (client->GetReflectorModule() != rpt2.GetCSModule())
|
||||
{
|
||||
auto new_module = rpt2.GetModule();
|
||||
auto new_module = rpt2.GetCSModule();
|
||||
if (strchr(m_Modules.c_str(), '*') || strchr(m_Modules.c_str(), new_module))
|
||||
{
|
||||
client->SetReflectorModule(new_module);
|
||||
|
||||
@@ -41,7 +41,7 @@ const CCallsign &CM17Packet::GetSourceCallsign() const
|
||||
|
||||
char CM17Packet::GetDestModule() const
|
||||
{
|
||||
return destination.GetModule();
|
||||
return destination.GetCSModule();
|
||||
}
|
||||
|
||||
uint16_t CM17Packet::GetFrameNumber() const
|
||||
|
||||
@@ -218,7 +218,7 @@ void CM17Protocol::HandleQueue(void)
|
||||
auto packet = m_Queue.pop();
|
||||
|
||||
// get our sender's id
|
||||
const auto module = packet->GetModule();
|
||||
const auto module = packet->GetPacketModule();
|
||||
|
||||
// check if it's header and update cache
|
||||
if ( packet->IsDvHeader() )
|
||||
@@ -387,7 +387,7 @@ void CM17Protocol::EncodeM17Packet(SM17Frame &frame, const CDvHeaderPacket &Head
|
||||
// first, the dest and src callsigns
|
||||
Header.GetRpt2Callsign().CodeOut(frame.lich.addr_dst);
|
||||
CCallsign from = g_Reflector.GetCallsign();
|
||||
from.SetModule(Header.GetModule());
|
||||
from.SetCSModule(Header.GetPacketModule());
|
||||
from.CodeOut(frame.lich.addr_src);
|
||||
// then the frame type, if the incoming frame is NOT an M17 1600, then it will be Voice only
|
||||
frame.lich.frametype = htons((ECodecType::c2_1600==codec_in) ? 0x7U : 0x5U);
|
||||
|
||||
+4
-4
@@ -59,16 +59,16 @@ public:
|
||||
uint8_t GetYsfPacketId(void) const { return m_uiYsfPacketId; }
|
||||
uint8_t GetYsfPacketSubId(void) const { return m_uiYsfPacketSubId; }
|
||||
uint8_t GetYsfPacketFrameId(void) const { return m_uiYsfPacketFrameId; }
|
||||
char GetModule(void) const { return m_cModule; }
|
||||
char GetPacketModule(void) const { return m_cModule; }
|
||||
bool IsLocalOrigin(void) const { return (m_eOrigin == EOrigin::local); }
|
||||
bool IsSecond(void) const { return m_bIsSecond; }
|
||||
ECodecType GetCodecIn(void) const { return m_eCodecIn; }
|
||||
|
||||
// set
|
||||
void UpdatePids(const uint32_t);
|
||||
void SetModule(char cMod) { m_cModule = cMod; }
|
||||
void SetLocalOrigin(void) { m_eOrigin = EOrigin::local; }
|
||||
void SetRemotePeerOrigin(void) { m_eOrigin = EOrigin::peer; }
|
||||
void SetPacketModule(char cMod) { m_cModule = cMod; }
|
||||
void SetLocalOrigin(void) { m_eOrigin = EOrigin::local; }
|
||||
void SetRemotePeerOrigin(void) { m_eOrigin = EOrigin::peer; }
|
||||
|
||||
protected:
|
||||
// data
|
||||
|
||||
@@ -182,7 +182,7 @@ std::shared_ptr<CPacketStream> CReflector::OpenStream(std::unique_ptr<CDvHeaderP
|
||||
}
|
||||
|
||||
// get the module's queue
|
||||
char module = DvHeader->GetModule();
|
||||
char module = DvHeader->GetPacketModule();
|
||||
auto stream = GetStream(module);
|
||||
if ( stream == nullptr )
|
||||
{
|
||||
@@ -289,7 +289,7 @@ void CReflector::RouterThread(const char ThisModule)
|
||||
if ( packet != nullptr )
|
||||
{
|
||||
// set origin
|
||||
packet->SetModule(ThisModule);
|
||||
packet->SetPacketModule(ThisModule);
|
||||
|
||||
// iterate on all protocols
|
||||
m_Protocols.Lock();
|
||||
@@ -303,7 +303,7 @@ void CReflector::RouterThread(const char ThisModule)
|
||||
{
|
||||
// get our callsign
|
||||
CCallsign csRPT = (*it)->GetReflectorCallsign();
|
||||
csRPT.SetModule(ThisModule);
|
||||
csRPT.SetCSModule(ThisModule);
|
||||
(dynamic_cast<CDvHeaderPacket *>(packetClone.get()))->SetRpt2Callsign(csRPT);
|
||||
}
|
||||
|
||||
|
||||
@@ -231,7 +231,7 @@ void CURFProtocol::HandleQueue(void)
|
||||
while ( (client = clients->FindNextClient(EProtocol::xlx, it)) != nullptr )
|
||||
{
|
||||
// is this client busy ?
|
||||
if ( !client->IsAMaster() && (client->GetReflectorModule() == packet->GetModule()) )
|
||||
if ( !client->IsAMaster() && (client->GetReflectorModule() == packet->GetPacketModule()) )
|
||||
{
|
||||
// no, send the packet
|
||||
// this is protocol revision dependent
|
||||
|
||||
+2
-2
@@ -66,7 +66,7 @@ void CUser::WriteXml(std::ofstream &xmlFile)
|
||||
xmlFile << "<STATION>" << std::endl;
|
||||
xmlFile << "\t<Callsign>" << m_My << "</Callsign>" << std::endl;
|
||||
xmlFile << "\t<Via node>" << m_Rpt1 << "</Via node>" << std::endl;
|
||||
xmlFile << "\t<On module>" << m_Rpt2.GetModule() << "</On module>" << std::endl;
|
||||
xmlFile << "\t<On module>" << m_Rpt2.GetCSModule() << "</On module>" << std::endl;
|
||||
xmlFile << "\t<Via peer>" << m_Xlx << "</Via peer>" << std::endl;
|
||||
|
||||
char mbstr[100];
|
||||
@@ -92,7 +92,7 @@ void CUser::GetJsonObject(char *Buffer)
|
||||
::sprintf(sz, "{\"callsign\":\"%s\",\"node\":\"%s\",\"module\":\"%c\",\"time\":\"%s\"}",
|
||||
my,
|
||||
rpt1,
|
||||
m_Rpt1.GetModule(),
|
||||
m_Rpt1.GetCSModule(),
|
||||
mbstr);
|
||||
::strcat(Buffer, sz);
|
||||
}
|
||||
|
||||
@@ -248,7 +248,7 @@ void CYsfProtocol::OnDvHeaderPacketIn(std::unique_ptr<CDvHeaderPacket> &Header,
|
||||
// get module it's linked to
|
||||
auto m = client->GetReflectorModule();
|
||||
Header->SetRpt2Module(m);
|
||||
rpt2.SetModule(m);
|
||||
rpt2.SetCSModule(m);
|
||||
|
||||
// and try to open the stream
|
||||
if ( (stream = g_Reflector.OpenStream(Header, client)) != nullptr )
|
||||
@@ -261,7 +261,7 @@ void CYsfProtocol::OnDvHeaderPacketIn(std::unique_ptr<CDvHeaderPacket> &Header,
|
||||
g_Reflector.ReleaseClients();
|
||||
|
||||
// update last heard
|
||||
if ( g_Reflector.IsValidModule(rpt2.GetModule()) )
|
||||
if ( g_Reflector.IsValidModule(rpt2.GetCSModule()) )
|
||||
{
|
||||
g_Reflector.GetUsers()->Hearing(my, rpt1, rpt2);
|
||||
g_Reflector.ReleaseUsers();
|
||||
@@ -282,7 +282,7 @@ void CYsfProtocol::HandleQueue(void)
|
||||
auto packet = m_Queue.pop();
|
||||
|
||||
// get our sender's id
|
||||
const auto mod = packet->GetModule();
|
||||
const auto mod = packet->GetPacketModule();
|
||||
|
||||
// encode
|
||||
CBuffer buffer;
|
||||
@@ -330,7 +330,7 @@ void CYsfProtocol::HandleQueue(void)
|
||||
while ( (client = clients->FindNextClient(EProtocol::ysf, it)) != nullptr )
|
||||
{
|
||||
// is this client busy ?
|
||||
if ( !client->IsAMaster() && (client->GetReflectorModule() == packet->GetModule()) )
|
||||
if ( !client->IsAMaster() && (client->GetReflectorModule() == packet->GetPacketModule()) )
|
||||
{
|
||||
// no, send the packet
|
||||
Send(buffer, client->GetIp());
|
||||
@@ -387,7 +387,7 @@ bool CYsfProtocol::IsValidConnectPacket(const CBuffer &Buffer, CCallsign *callsi
|
||||
if ( (Buffer.size() == 14) && (Buffer.Compare(tag, sizeof(tag)) == 0) )
|
||||
{
|
||||
callsign->SetCallsign(Buffer.data()+4, 8);
|
||||
callsign->SetModule(YSF_MODULE_ID);
|
||||
callsign->SetCSModule(YSF_MODULE_ID);
|
||||
valid = (callsign->IsValid());
|
||||
}
|
||||
return valid;
|
||||
@@ -431,12 +431,12 @@ bool CYsfProtocol::IsValidDvHeaderPacket(const CIp &Ip, const CYSFFICH &Fich, co
|
||||
memcpy(sz, &(Buffer.data()[4]), YSF_CALLSIGN_LENGTH);
|
||||
sz[YSF_CALLSIGN_LENGTH] = 0;
|
||||
CCallsign rpt1 = CCallsign((const char *)sz);
|
||||
rpt1.SetModule(YSF_MODULE_ID);
|
||||
rpt1.SetCSModule(YSF_MODULE_ID);
|
||||
CCallsign rpt2 = m_ReflectorCallsign;
|
||||
// as YSF protocol does not provide a module-tranlatable
|
||||
// destid, set module to none and rely on OnDvHeaderPacketIn()
|
||||
// to later fill it with proper value
|
||||
rpt2.SetModule(' ');
|
||||
rpt2.SetCSModule(' ');
|
||||
|
||||
// and packet
|
||||
header = std::unique_ptr<CDvHeaderPacket>(new CDvHeaderPacket(csMY, CCallsign("CQCQCQ"), rpt1, rpt2, uiStreamId, Fich.getFN()));
|
||||
@@ -754,7 +754,7 @@ bool CYsfProtocol::IsValidwirexPacket(const CBuffer &Buffer, CYSFFICH *Fich, CCa
|
||||
{
|
||||
// get callsign
|
||||
Callsign->SetCallsign(&(Buffer.data()[4]), CALLSIGN_LEN, false);
|
||||
Callsign->SetModule(YSF_MODULE_ID);
|
||||
Callsign->SetCSModule(YSF_MODULE_ID);
|
||||
// decode payload
|
||||
if ( Fich->getFN() == 0U )
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user