Skip to content

Commit

Permalink
Regularise the local address handling across all of the protocol.
Browse files Browse the repository at this point in the history
  • Loading branch information
g4klx committed Apr 25, 2021
1 parent 8b45e04 commit 7008c62
Show file tree
Hide file tree
Showing 22 changed files with 158 additions and 96 deletions.
86 changes: 63 additions & 23 deletions Conf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ m_modemI2CPort(),
m_modemI2CAddress(0x22U),
m_modemModemAddress(),
m_modemModemPort(0U),
m_modemLocalAddress(),
m_modemLocalPort(0U),
m_modemRXInvert(false),
m_modemTXInvert(false),
Expand Down Expand Up @@ -233,14 +234,16 @@ m_ax25Trace(false),
m_dstarNetworkEnabled(false),
m_dstarGatewayAddress(),
m_dstarGatewayPort(0U),
m_dstarLocalAddress(),
m_dstarLocalPort(0U),
m_dstarNetworkModeHang(3U),
m_dstarNetworkDebug(false),
m_dmrNetworkEnabled(false),
m_dmrNetworkType("Gateway"),
m_dmrNetworkAddress(),
m_dmrNetworkPort(0U),
m_dmrNetworkLocal(0U),
m_dmrNetworkRemoteAddress(),
m_dmrNetworkRemotePort(0U),
m_dmrNetworkLocalAddress(),
m_dmrNetworkLocalPort(0U),
m_dmrNetworkPassword(),
m_dmrNetworkOptions(),
m_dmrNetworkDebug(false),
Expand All @@ -249,15 +252,16 @@ m_dmrNetworkSlot1(true),
m_dmrNetworkSlot2(true),
m_dmrNetworkModeHang(3U),
m_fusionNetworkEnabled(false),
m_fusionNetworkMyAddress(),
m_fusionNetworkMyPort(0U),
m_fusionNetworkLocalAddress(),
m_fusionNetworkLocalPort(0U),
m_fusionNetworkGatewayAddress(),
m_fusionNetworkGatewayPort(0U),
m_fusionNetworkModeHang(3U),
m_fusionNetworkDebug(false),
m_p25NetworkEnabled(false),
m_p25GatewayAddress(),
m_p25GatewayPort(0U),
m_p25LocalAddress(),
m_p25LocalPort(0U),
m_p25NetworkModeHang(3U),
m_p25NetworkDebug(false),
Expand All @@ -272,6 +276,7 @@ m_nxdnNetworkDebug(false),
m_m17NetworkEnabled(false),
m_m17GatewayAddress(),
m_m17GatewayPort(0U),
m_m17LocalAddress(),
m_m17LocalPort(0U),
m_m17NetworkModeHang(3U),
m_m17NetworkDebug(false),
Expand Down Expand Up @@ -536,6 +541,8 @@ bool CConf::read()
m_modemModemAddress = value;
else if (::strcmp(key, "ModemPort") == 0)
m_modemModemPort = (unsigned short)::atoi(value);
else if (::strcmp(key, "LocalAddress") == 0)
m_modemLocalAddress = value;
else if (::strcmp(key, "LocalPort") == 0)
m_modemLocalPort = (unsigned short)::atoi(value);
else if (::strcmp(key, "RXInvert") == 0)
Expand Down Expand Up @@ -897,6 +904,8 @@ bool CConf::read()
m_dstarGatewayAddress = value;
else if (::strcmp(key, "GatewayPort") == 0)
m_dstarGatewayPort = (unsigned short)::atoi(value);
else if (::strcmp(key, "LocalAddress") == 0)
m_dstarLocalAddress = value;
else if (::strcmp(key, "LocalPort") == 0)
m_dstarLocalPort = (unsigned short)::atoi(value);
else if (::strcmp(key, "ModeHang") == 0)
Expand All @@ -908,12 +917,14 @@ bool CConf::read()
m_dmrNetworkEnabled = ::atoi(value) == 1;
else if (::strcmp(key, "Type") == 0)
m_dmrNetworkType = value;
else if (::strcmp(key, "Address") == 0)
m_dmrNetworkAddress = value;
else if (::strcmp(key, "Port") == 0)
m_dmrNetworkPort = (unsigned short)::atoi(value);
else if (::strcmp(key, "Local") == 0)
m_dmrNetworkLocal = (unsigned short)::atoi(value);
else if (::strcmp(key, "RemoteAddress") == 0)
m_dmrNetworkRemoteAddress = value;
else if (::strcmp(key, "RemotePort") == 0)
m_dmrNetworkRemotePort = (unsigned short)::atoi(value);
else if (::strcmp(key, "LocalAddress") == 0)
m_dmrNetworkLocalAddress = value;
else if (::strcmp(key, "LocalPort") == 0)
m_dmrNetworkLocalPort = (unsigned short)::atoi(value);
else if (::strcmp(key, "Password") == 0)
m_dmrNetworkPassword = value;
else if (::strcmp(key, "Options") == 0)
Expand All @@ -932,9 +943,9 @@ bool CConf::read()
if (::strcmp(key, "Enable") == 0)
m_fusionNetworkEnabled = ::atoi(value) == 1;
else if (::strcmp(key, "LocalAddress") == 0)
m_fusionNetworkMyAddress = value;
m_fusionNetworkLocalAddress = value;
else if (::strcmp(key, "LocalPort") == 0)
m_fusionNetworkMyPort = (unsigned short)::atoi(value);
m_fusionNetworkLocalPort = (unsigned short)::atoi(value);
else if (::strcmp(key, "GatewayAddress") == 0)
m_fusionNetworkGatewayAddress = value;
else if (::strcmp(key, "GatewayPort") == 0)
Expand All @@ -950,6 +961,8 @@ bool CConf::read()
m_p25GatewayAddress = value;
else if (::strcmp(key, "GatewayPort") == 0)
m_p25GatewayPort = (unsigned short)::atoi(value);
else if (::strcmp(key, "LocalAddress") == 0)
m_p25LocalAddress = value;
else if (::strcmp(key, "LocalPort") == 0)
m_p25LocalPort = (unsigned short)::atoi(value);
else if (::strcmp(key, "ModeHang") == 0)
Expand All @@ -974,6 +987,8 @@ bool CConf::read()
} else if (section == SECTION_M17_NETWORK) {
if (::strcmp(key, "Enable") == 0)
m_m17NetworkEnabled = ::atoi(value) == 1;
else if (::strcmp(key, "LocalAddress") == 0)
m_m17LocalAddress = value;
else if (::strcmp(key, "LocalPort") == 0)
m_m17LocalPort = (unsigned short)::atoi(value);
else if (::strcmp(key, "GatewayAddress") == 0)
Expand Down Expand Up @@ -1294,6 +1309,11 @@ unsigned short CConf::getModemModemPort() const
return m_modemModemPort;
}

std::string CConf::getModemLocalAddress() const
{
return m_modemLocalAddress;
}

unsigned short CConf::getModemLocalPort() const
{
return m_modemLocalPort;
Expand Down Expand Up @@ -1959,6 +1979,11 @@ unsigned short CConf::getDStarGatewayPort() const
return m_dstarGatewayPort;
}

std::string CConf::getDStarLocalAddress() const
{
return m_dstarLocalAddress;
}

unsigned short CConf::getDStarLocalPort() const
{
return m_dstarLocalPort;
Expand All @@ -1984,19 +2009,24 @@ std::string CConf::getDMRNetworkType() const
return m_dmrNetworkType;
}

std::string CConf::getDMRNetworkAddress() const
std::string CConf::getDMRNetworkRemoteAddress() const
{
return m_dmrNetworkRemoteAddress;
}

unsigned short CConf::getDMRNetworkRemotePort() const
{
return m_dmrNetworkAddress;
return m_dmrNetworkRemotePort;
}

unsigned short CConf::getDMRNetworkPort() const
std::string CConf::getDMRNetworkLocalAddress() const
{
return m_dmrNetworkPort;
return m_dmrNetworkLocalAddress;
}

unsigned short CConf::getDMRNetworkLocal() const
unsigned short CConf::getDMRNetworkLocalPort() const
{
return m_dmrNetworkLocal;
return m_dmrNetworkLocalPort;
}

std::string CConf::getDMRNetworkPassword() const
Expand Down Expand Up @@ -2039,14 +2069,14 @@ bool CConf::getFusionNetworkEnabled() const
return m_fusionNetworkEnabled;
}

std::string CConf::getFusionNetworkMyAddress() const
std::string CConf::getFusionNetworkLocalAddress() const
{
return m_fusionNetworkMyAddress;
return m_fusionNetworkLocalAddress;
}

unsigned short CConf::getFusionNetworkMyPort() const
unsigned short CConf::getFusionNetworkLocalPort() const
{
return m_fusionNetworkMyPort;
return m_fusionNetworkLocalPort;
}

std::string CConf::getFusionNetworkGatewayAddress() const
Expand Down Expand Up @@ -2084,6 +2114,11 @@ unsigned short CConf::getP25GatewayPort() const
return m_p25GatewayPort;
}

std::string CConf::getP25LocalAddress() const
{
return m_p25LocalAddress;
}

unsigned short CConf::getP25LocalPort() const
{
return m_p25LocalPort;
Expand Down Expand Up @@ -2154,6 +2189,11 @@ unsigned short CConf::getM17GatewayPort() const
return m_m17GatewayPort;
}

std::string CConf::getM17LocalAddress() const
{
return m_m17LocalAddress;
}

unsigned short CConf::getM17LocalPort() const
{
return m_m17LocalPort;
Expand Down
30 changes: 20 additions & 10 deletions Conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class CConf
unsigned int getModemI2CAddress() const;
std::string getModemModemAddress() const;
unsigned short getModemModemPort() const;
std::string getModemLocalAddress() const;
unsigned short getModemLocalPort() const;
bool getModemRXInvert() const;
bool getModemTXInvert() const;
Expand Down Expand Up @@ -232,16 +233,18 @@ class CConf
bool getDStarNetworkEnabled() const;
std::string getDStarGatewayAddress() const;
unsigned short getDStarGatewayPort() const;
std::string getDStarLocalAddress() const;
unsigned short getDStarLocalPort() const;
unsigned int getDStarNetworkModeHang() const;
bool getDStarNetworkDebug() const;

// The DMR Network section
bool getDMRNetworkEnabled() const;
std::string getDMRNetworkType() const;
std::string getDMRNetworkAddress() const;
unsigned short getDMRNetworkPort() const;
unsigned short getDMRNetworkLocal() const;
std::string getDMRNetworkRemoteAddress() const;
unsigned short getDMRNetworkRemotePort() const;
std::string getDMRNetworkLocalAddress() const;
unsigned short getDMRNetworkLocalPort() const;
std::string getDMRNetworkPassword() const;
std::string getDMRNetworkOptions() const;
bool getDMRNetworkDebug() const;
Expand All @@ -252,8 +255,8 @@ class CConf

// The System Fusion Network section
bool getFusionNetworkEnabled() const;
std::string getFusionNetworkMyAddress() const;
unsigned short getFusionNetworkMyPort() const;
std::string getFusionNetworkLocalAddress() const;
unsigned short getFusionNetworkLocalPort() const;
std::string getFusionNetworkGatewayAddress() const;
unsigned short getFusionNetworkGatewayPort() const;
unsigned int getFusionNetworkModeHang() const;
Expand All @@ -263,6 +266,7 @@ class CConf
bool getP25NetworkEnabled() const;
std::string getP25GatewayAddress() const;
unsigned short getP25GatewayPort() const;
std::string getP25LocalAddress() const;
unsigned short getP25LocalPort() const;
unsigned int getP25NetworkModeHang() const;
bool getP25NetworkDebug() const;
Expand All @@ -281,6 +285,7 @@ class CConf
bool getM17NetworkEnabled() const;
std::string getM17GatewayAddress() const;
unsigned short getM17GatewayPort() const;
std::string getM17LocalAddress() const;
unsigned short getM17LocalPort() const;
unsigned int getM17NetworkModeHang() const;
bool getM17NetworkDebug() const;
Expand Down Expand Up @@ -406,6 +411,7 @@ class CConf
unsigned int m_modemI2CAddress;
std::string m_modemModemAddress;
unsigned short m_modemModemPort;
std::string m_modemLocalAddress;
unsigned short m_modemLocalPort;
bool m_modemRXInvert;
bool m_modemTXInvert;
Expand Down Expand Up @@ -550,15 +556,17 @@ class CConf
bool m_dstarNetworkEnabled;
std::string m_dstarGatewayAddress;
unsigned short m_dstarGatewayPort;
std::string m_dstarLocalAddress;
unsigned short m_dstarLocalPort;
unsigned int m_dstarNetworkModeHang;
bool m_dstarNetworkDebug;

bool m_dmrNetworkEnabled;
std::string m_dmrNetworkType;
std::string m_dmrNetworkAddress;
unsigned short m_dmrNetworkPort;
unsigned short m_dmrNetworkLocal;
std::string m_dmrNetworkRemoteAddress;
unsigned short m_dmrNetworkRemotePort;
std::string m_dmrNetworkLocalAddress;
unsigned short m_dmrNetworkLocalPort;
std::string m_dmrNetworkPassword;
std::string m_dmrNetworkOptions;
bool m_dmrNetworkDebug;
Expand All @@ -568,8 +576,8 @@ class CConf
unsigned int m_dmrNetworkModeHang;

bool m_fusionNetworkEnabled;
std::string m_fusionNetworkMyAddress;
unsigned short m_fusionNetworkMyPort;
std::string m_fusionNetworkLocalAddress;
unsigned short m_fusionNetworkLocalPort;
std::string m_fusionNetworkGatewayAddress;
unsigned short m_fusionNetworkGatewayPort;
unsigned int m_fusionNetworkModeHang;
Expand All @@ -578,6 +586,7 @@ class CConf
bool m_p25NetworkEnabled;
std::string m_p25GatewayAddress;
unsigned short m_p25GatewayPort;
std::string m_p25LocalAddress;
unsigned short m_p25LocalPort;
unsigned int m_p25NetworkModeHang;
bool m_p25NetworkDebug;
Expand All @@ -594,6 +603,7 @@ class CConf
bool m_m17NetworkEnabled;
std::string m_m17GatewayAddress;
unsigned short m_m17GatewayPort;
std::string m_m17LocalAddress;
unsigned short m_m17LocalPort;
unsigned int m_m17NetworkModeHang;
bool m_m17NetworkDebug;
Expand Down
4 changes: 2 additions & 2 deletions DMRDirectNetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const unsigned int BUFFER_LENGTH = 500U;
const unsigned int HOMEBREW_DATA_PACKET_LENGTH = 55U;


CDMRDirectNetwork::CDMRDirectNetwork(const std::string& address, unsigned short port, unsigned short local, unsigned int id, const std::string& password, bool duplex, const char* version, bool slot1, bool slot2, HW_TYPE hwType, bool debug) :
CDMRDirectNetwork::CDMRDirectNetwork(const std::string& address, unsigned short port, const std::string& localAddress, unsigned short localPort, unsigned int id, const std::string& password, bool duplex, const char* version, bool slot1, bool slot2, HW_TYPE hwType, bool debug) :
m_address(address),
m_port(port),
m_addr(),
Expand All @@ -40,7 +40,7 @@ m_password(password),
m_duplex(duplex),
m_version(version),
m_debug(debug),
m_socket(local),
m_socket(localAddress, localPort),
m_enabled(false),
m_slot1(slot1),
m_slot2(slot2),
Expand Down
2 changes: 1 addition & 1 deletion DMRDirectNetwork.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
class CDMRDirectNetwork : public IDMRNetwork
{
public:
CDMRDirectNetwork(const std::string& address, unsigned short port, unsigned short local, unsigned int id, const std::string& password, bool duplex, const char* version, bool slot1, bool slot2, HW_TYPE hwType, bool debug);
CDMRDirectNetwork(const std::string& remoteAddress, unsigned short remotePort, const std::string& localAddress, unsigned short localPort, unsigned int id, const std::string& password, bool duplex, const char* version, bool slot1, bool slot2, HW_TYPE hwType, bool debug);
virtual ~CDMRDirectNetwork();

virtual void setOptions(const std::string& options);
Expand Down
4 changes: 2 additions & 2 deletions DMRGatewayNetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const unsigned int BUFFER_LENGTH = 500U;
const unsigned int HOMEBREW_DATA_PACKET_LENGTH = 55U;


CDMRGatewayNetwork::CDMRGatewayNetwork(const std::string& address, unsigned short port, unsigned short local, unsigned int id, bool duplex, const char* version, bool slot1, bool slot2, HW_TYPE hwType, bool debug) :
CDMRGatewayNetwork::CDMRGatewayNetwork(const std::string& address, unsigned short port, const std::string& localAddress, unsigned short localPort, unsigned int id, bool duplex, const char* version, bool slot1, bool slot2, HW_TYPE hwType, bool debug) :
m_addressStr(address),
m_addr(),
m_addrLen(0U),
Expand All @@ -40,7 +40,7 @@ m_id(NULL),
m_duplex(duplex),
m_version(version),
m_debug(debug),
m_socket(local),
m_socket(localAddress, localPort),
m_enabled(false),
m_slot1(slot1),
m_slot2(slot2),
Expand Down
2 changes: 1 addition & 1 deletion DMRGatewayNetwork.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
class CDMRGatewayNetwork : public IDMRNetwork
{
public:
CDMRGatewayNetwork(const std::string& address, unsigned short port, unsigned short local, unsigned int id, bool duplex, const char* version, bool slot1, bool slot2, HW_TYPE hwType, bool debug);
CDMRGatewayNetwork(const std::string& remoteAddress, unsigned short remotePort, const std::string& localAddress, unsigned short localPort, unsigned int id, bool duplex, const char* version, bool slot1, bool slot2, HW_TYPE hwType, bool debug);
virtual ~CDMRGatewayNetwork();

virtual void setOptions(const std::string& options);
Expand Down
4 changes: 2 additions & 2 deletions DStarNetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@

const unsigned int BUFFER_LENGTH = 100U;

CDStarNetwork::CDStarNetwork(const std::string& gatewayAddress, unsigned short gatewayPort, unsigned short localPort, bool duplex, const char* version, bool debug) :
m_socket(localPort),
CDStarNetwork::CDStarNetwork(const std::string& gatewayAddress, unsigned short gatewayPort, const std::string& localAddress, unsigned short localPort, bool duplex, const char* version, bool debug) :
m_socket(localAddress, localPort),
m_addr(),
m_addrLen(0U),
m_duplex(duplex),
Expand Down
Loading

0 comments on commit 7008c62

Please sign in to comment.