1
0
Fork 0

Fix network ports datatype (unsigned int -> unsigned short). UDPSocket: fix old bug using m_port instead of m_port[x].

master
Daniel Caujolle-Bert 3 years ago
parent c9660478c5
commit fc76b0f4ab
No known key found for this signature in database
GPG Key ID: 51AED7171EC00614

@ -25,7 +25,7 @@
#include <cstring>
#include <cmath>
CAPRSWriter::CAPRSWriter(const std::string& callsign, const std::string& rptSuffix, const std::string& address, unsigned int port, const std::string& suffix, bool debug) :
CAPRSWriter::CAPRSWriter(const std::string& callsign, const std::string& rptSuffix, const std::string& address, unsigned short port, const std::string& suffix, bool debug) :
m_idTimer(1000U),
m_callsign(callsign),
m_debug(debug),

@ -42,7 +42,7 @@
class CAPRSWriter {
public:
CAPRSWriter(const std::string& callsign, const std::string& rptSuffix, const std::string& address, unsigned int port, const std::string& suffix, bool debug);
CAPRSWriter(const std::string& callsign, const std::string& rptSuffix, const std::string& address, unsigned short port, const std::string& suffix, bool debug);
~CAPRSWriter();
bool open();

@ -178,11 +178,11 @@ bool CConf::read()
else if (::strcmp(key, "RptAddress") == 0)
m_rptAddress = value;
else if (::strcmp(key, "RptPort") == 0)
m_rptPort = (unsigned int)::atoi(value);
m_rptPort = (unsigned short)::atoi(value);
else if (::strcmp(key, "LocalAddress") == 0)
m_myAddress = value;
else if (::strcmp(key, "LocalPort") == 0)
m_myPort = (unsigned int)::atoi(value);
m_myPort = (unsigned short)::atoi(value);
else if (::strcmp(key, "RFHangTime") == 0)
m_ysfRFHangTime = m_fcsRFHangTime = m_rfHangTime = (unsigned int)::atoi(value);
else if (::strcmp(key, "NetHangTime") == 0)
@ -225,7 +225,7 @@ bool CConf::read()
else if (::strcmp(key, "Address") == 0)
m_aprsAddress = value;
else if (::strcmp(key, "Port") == 0)
m_aprsPort = (unsigned int)::atoi(value);
m_aprsPort = (unsigned short)::atoi(value);
else if (::strcmp(key, "Suffix") == 0)
m_aprsSuffix = value;
else if (::strcmp(key, "Description") == 0)
@ -286,7 +286,7 @@ bool CConf::read()
else if (::strcmp(key, "Name") == 0)
dgIdData->m_name = value;
else if (::strcmp(key, "Port") == 0)
dgIdData->m_port = (unsigned int)::atoi(value);
dgIdData->m_port = (unsigned short)::atoi(value);
else if (::strcmp(key, "Local") == 0)
dgIdData->m_local = (unsigned int)::atoi(value);
else if (::strcmp(key, "DGId") == 0)
@ -335,7 +335,7 @@ std::string CConf::getRptAddress() const
return m_rptAddress;
}
unsigned int CConf::getRptPort() const
unsigned short CConf::getRptPort() const
{
return m_rptPort;
}
@ -345,7 +345,7 @@ std::string CConf::getMyAddress() const
return m_myAddress;
}
unsigned int CConf::getMyPort() const
unsigned short CConf::getMyPort() const
{
return m_myPort;
}
@ -435,7 +435,7 @@ std::string CConf::getAPRSAddress() const
return m_aprsAddress;
}
unsigned int CConf::getAPRSPort() const
unsigned short CConf::getAPRSPort() const
{
return m_aprsPort;
}

@ -33,8 +33,8 @@ struct DGIdData {
bool m_static;
std::string m_name;
std::string m_address;
unsigned int m_port;
unsigned int m_local;
unsigned short m_port;
unsigned short m_local;
unsigned int m_netDGId;
std::vector<IMRSDestination*> m_destinations;
unsigned int m_rfHangTime;
@ -55,9 +55,9 @@ public:
std::string getSuffix() const;
unsigned int getId() const;
std::string getRptAddress() const;
unsigned int getRptPort() const;
unsigned short getRptPort() const;
std::string getMyAddress() const;
unsigned int getMyPort() const;
unsigned short getMyPort() const;
bool getBleep() const;
bool getDebug() const;
bool getDaemon() const;
@ -81,7 +81,7 @@ public:
// The APRS section
bool getAPRSEnabled() const;
std::string getAPRSAddress() const;
unsigned int getAPRSPort() const;
unsigned short getAPRSPort() const;
std::string getAPRSSuffix() const;
std::string getAPRSDescription() const;
@ -102,9 +102,9 @@ private:
std::string m_suffix;
unsigned int m_id;
std::string m_rptAddress;
unsigned int m_rptPort;
unsigned short m_rptPort;
std::string m_myAddress;
unsigned int m_myPort;
unsigned short m_myPort;
unsigned int m_rfHangTime;
unsigned int m_netHangTime;
bool m_bleep;
@ -127,7 +127,7 @@ private:
bool m_aprsEnabled;
std::string m_aprsAddress;
unsigned int m_aprsPort;
unsigned short m_aprsPort;
std::string m_aprsSuffix;
std::string m_aprsDescription;

@ -199,7 +199,7 @@ int CDGIdGateway::run()
bool debug = m_conf.getDebug();
std::string myAddress = m_conf.getMyAddress();
unsigned int myPort = m_conf.getMyPort();
unsigned short myPort = m_conf.getMyPort();
CYSFNetwork rptNetwork(myAddress, myPort, "MMDVM", rptAddr, rptAddrLen, m_callsign, debug);
ret = rptNetwork.open();
@ -243,7 +243,7 @@ int CDGIdGateway::run()
if (type == "FCS") {
std::string name = (*it)->m_name;
unsigned int local = (*it)->m_local;
unsigned short local = (*it)->m_local;
unsigned int txFrequency = m_conf.getTxFrequency();
unsigned int rxFrequency = m_conf.getRxFrequency();
std::string locator = calculateLocator();
@ -303,7 +303,7 @@ int CDGIdGateway::run()
LogMessage("Added IMRS:%s to DG-ID %u%s", name.c_str(), dgid, statc ? " (Static)" : "");
}
} else if (type == "Gateway") {
unsigned int local = (*it)->m_local;
unsigned short local = (*it)->m_local;
sockaddr_storage addr;
unsigned int addrLen;
@ -319,7 +319,7 @@ int CDGIdGateway::run()
LogWarning("Unable to resolve the address for the YSF Gateway");
}
} else if (type == "Parrot") {
unsigned int local = (*it)->m_local;
unsigned short local = (*it)->m_local;
sockaddr_storage addr;
unsigned int addrLen;
@ -335,7 +335,7 @@ int CDGIdGateway::run()
LogWarning("Unable to resolve the address for the YSF Parrot");
}
} else if (type == "YSF2DMR") {
unsigned int local = (*it)->m_local;
unsigned short local = (*it)->m_local;
sockaddr_storage addr;
unsigned int addrLen;
@ -351,7 +351,7 @@ int CDGIdGateway::run()
LogWarning("Unable to resolve the address for YSF2DMR");
}
} else if (type == "YSF2NXDN") {
unsigned int local = (*it)->m_local;
unsigned short local = (*it)->m_local;
sockaddr_storage addr;
unsigned int addrLen;
@ -367,7 +367,7 @@ int CDGIdGateway::run()
LogWarning("Unable to resolve the address for YSF2NXDN");
}
} else if (type == "YSF2P25") {
unsigned int local = (*it)->m_local;
unsigned short local = (*it)->m_local;
sockaddr_storage addr;
unsigned int addrLen;
@ -609,7 +609,7 @@ void CDGIdGateway::createGPS()
return;
std::string address = m_conf.getAPRSAddress();
unsigned int port = m_conf.getAPRSPort();
unsigned short port = m_conf.getAPRSPort();
std::string suffix = m_conf.getAPRSSuffix();
bool debug = m_conf.getDebug();

@ -29,7 +29,7 @@ const char* FCS_VERSION = "MMDVM";
const unsigned int BUFFER_LENGTH = 200U;
CFCSNetwork::CFCSNetwork(const std::string& reflector, unsigned int port, const std::string& callsign, unsigned int rxFrequency, unsigned int txFrequency, const std::string& locator, unsigned int id, bool statc, bool debug) :
CFCSNetwork::CFCSNetwork(const std::string& reflector, unsigned short port, const std::string& callsign, unsigned int rxFrequency, unsigned int txFrequency, const std::string& locator, unsigned int id, bool statc, bool debug) :
m_socket(port),
m_debug(debug),
m_addr(),

@ -30,7 +30,7 @@
class CFCSNetwork : public CDGIdNetwork {
public:
CFCSNetwork(const std::string& reflector, unsigned int port, const std::string& callsign, unsigned int rxFrequency, unsigned int txFrequency, const std::string& locator, unsigned int id, bool statc, bool debug);
CFCSNetwork(const std::string& reflector, unsigned short port, const std::string& callsign, unsigned int rxFrequency, unsigned int txFrequency, const std::string& locator, unsigned int id, bool statc, bool debug);
virtual ~CFCSNetwork();
virtual std::string getDesc(unsigned int dgId);

@ -28,11 +28,12 @@
#if defined(HAVE_LOG_H)
#include "Log.h"
#else
#define LogMessage(fmt, ...) ::fprintf(stderr, fmt "\n", ## __VA_ARGS__)
#define LogError(fmt, ...) ::fprintf(stderr, fmt "\n", ## __VA_ARGS__)
#define LogInfo(fmt, ...) ::fprintf(stderr, fmt "\n", ## __VA_ARGS__)
#endif
CUDPSocket::CUDPSocket(const std::string& address, unsigned int port) :
CUDPSocket::CUDPSocket(const std::string& address, unsigned short port) :
m_address_save(address),
m_port_save(port),
m_counter(0U)
@ -45,7 +46,7 @@ m_counter(0U)
}
}
CUDPSocket::CUDPSocket(unsigned int port) :
CUDPSocket::CUDPSocket(unsigned short port) :
m_address_save(),
m_port_save(port),
m_counter(0U)
@ -79,7 +80,7 @@ void CUDPSocket::shutdown()
#endif
}
int CUDPSocket::lookup(const std::string& hostname, unsigned int port, sockaddr_storage& addr, unsigned int& address_length)
int CUDPSocket::lookup(const std::string& hostname, unsigned short port, sockaddr_storage& addr, unsigned int& address_length)
{
struct addrinfo hints;
::memset(&hints, 0, sizeof(hints));
@ -87,7 +88,7 @@ int CUDPSocket::lookup(const std::string& hostname, unsigned int port, sockaddr_
return lookup(hostname, port, addr, address_length, hints);
}
int CUDPSocket::lookup(const std::string& hostname, unsigned int port, sockaddr_storage& addr, unsigned int& address_length, struct addrinfo& hints)
int CUDPSocket::lookup(const std::string& hostname, unsigned short port, sockaddr_storage& addr, unsigned int& address_length, struct addrinfo& hints)
{
std::string portstr = std::to_string(port);
struct addrinfo *res;
@ -170,7 +171,7 @@ bool CUDPSocket::open(unsigned int af)
return open(0, af, m_address_save, m_port_save);
}
bool CUDPSocket::open(const unsigned int index, const unsigned int af, const std::string& address, const unsigned int port)
bool CUDPSocket::open(const unsigned int index, const unsigned int af, const std::string& address, const unsigned short port)
{
sockaddr_storage addr;
unsigned int addrlen;
@ -187,6 +188,8 @@ bool CUDPSocket::open(const unsigned int index, const unsigned int af, const std
return false;
}
close(index);
int fd = ::socket(addr.ss_family, SOCK_DGRAM, 0);
if (fd < 0) {
#if defined(_WIN32) || defined(_WIN64)
@ -222,7 +225,7 @@ bool CUDPSocket::open(const unsigned int index, const unsigned int af, const std
return false;
}
LogInfo("Opening UDP port on %u", port);
LogInfo("Opening UDP port on %hu", port);
}
return true;
@ -291,7 +294,7 @@ int CUDPSocket::read(unsigned char* buffer, unsigned int length, sockaddr_storag
LogError("Error returned from recvfrom, err: %d", errno);
if (len == -1 && errno == ENOTSOCK) {
LogMessage("Re-opening UDP port on %u", m_port);
LogMessage("Re-opening UDP port on %hu", m_port[index]);
close();
open();
}
@ -343,13 +346,13 @@ bool CUDPSocket::write(const unsigned char* buffer, unsigned int length, const s
void CUDPSocket::close()
{
for (int i = 0; i < UDP_SOCKET_MAX; i++)
close(m_fd[i]);
for (unsigned int i = 0; i < UDP_SOCKET_MAX; i++)
close(i);
}
void CUDPSocket::close(const unsigned int index)
{
if (m_fd[index] >= 0) {
if ((index < UDP_SOCKET_MAX) && (m_fd[index] >= 0)) {
#if defined(_WIN32) || defined(_WIN64)
::closesocket(m_fd[index]);
#else

@ -46,13 +46,13 @@ enum IPMATCHTYPE {
class CUDPSocket {
public:
CUDPSocket(const std::string& address, unsigned int port = 0U);
CUDPSocket(unsigned int port = 0U);
CUDPSocket(const std::string& address, unsigned short port = 0U);
CUDPSocket(unsigned short port = 0U);
~CUDPSocket();
bool open(unsigned int af = AF_UNSPEC);
bool open(const sockaddr_storage& address);
bool open(const unsigned int index, const unsigned int af, const std::string& address, const unsigned int port);
bool open(const unsigned int index, const unsigned int af, const std::string& address, const unsigned short port);
int read(unsigned char* buffer, unsigned int length, sockaddr_storage& address, unsigned int &address_length);
bool write(const unsigned char* buffer, unsigned int length, const sockaddr_storage& address, unsigned int address_length);
@ -63,8 +63,8 @@ public:
static void startup();
static void shutdown();
static int lookup(const std::string& hostName, unsigned int port, sockaddr_storage& address, unsigned int& address_length);
static int lookup(const std::string& hostName, unsigned int port, sockaddr_storage& address, unsigned int& address_length, struct addrinfo& hints);
static int lookup(const std::string& hostName, unsigned short port, sockaddr_storage& address, unsigned int& address_length);
static int lookup(const std::string& hostName, unsigned short port, sockaddr_storage& address, unsigned int& address_length, struct addrinfo& hints);
static bool match(const sockaddr_storage& addr1, const sockaddr_storage& addr2, IPMATCHTYPE type = IMT_ADDRESS_AND_PORT);

@ -47,8 +47,8 @@ const unsigned char YSF_CM_INDIVIDUAL = 0x03U;
const unsigned char YSF_MR_NOT_BUSY = 0x01U;
const unsigned char YSF_MR_BUSY = 0x02U;
const unsigned int FCS_PORT = 62500U;
const unsigned short FCS_PORT = 62500U;
const unsigned int IMRS_PORT = 21110U;
const unsigned short IMRS_PORT = 21110U;
#endif

@ -27,7 +27,7 @@
const unsigned int BUFFER_LENGTH = 200U;
CYSFNetwork::CYSFNetwork(const std::string& localAddress, unsigned int localPort, const std::string& name, const sockaddr_storage& addr, unsigned int addrLen, const std::string& callsign, bool debug) :
CYSFNetwork::CYSFNetwork(const std::string& localAddress, unsigned short localPort, const std::string& name, const sockaddr_storage& addr, unsigned int addrLen, const std::string& callsign, bool debug) :
m_socket(localAddress, localPort),
m_debug(debug),
m_addr(addr),
@ -56,7 +56,7 @@ m_state(DS_NOTOPEN)
}
}
CYSFNetwork::CYSFNetwork(unsigned int localPort, const std::string& name, const sockaddr_storage& addr, unsigned int addrLen, const std::string& callsign, bool statc, bool debug) :
CYSFNetwork::CYSFNetwork(unsigned short localPort, const std::string& name, const sockaddr_storage& addr, unsigned int addrLen, const std::string& callsign, bool statc, bool debug) :
m_socket(localPort),
m_debug(debug),
m_addr(addr),

@ -30,8 +30,8 @@
class CYSFNetwork : public CDGIdNetwork {
public:
CYSFNetwork(const std::string& localAddress, unsigned int localPort, const std::string& name, const sockaddr_storage& addr, unsigned int addrLen, const std::string& callsign, bool debug);
CYSFNetwork(unsigned int localPort, const std::string& name, const sockaddr_storage& addr, unsigned int addrLen, const std::string& callsign, bool statc, bool debug);
CYSFNetwork(const std::string& localAddress, unsigned short localPort, const std::string& name, const sockaddr_storage& addr, unsigned int addrLen, const std::string& callsign, bool debug);
CYSFNetwork(unsigned short localPort, const std::string& name, const sockaddr_storage& addr, unsigned int addrLen, const std::string& callsign, bool statc, bool debug);
virtual ~CYSFNetwork();
virtual std::string getDesc(unsigned int dgId);

@ -58,7 +58,7 @@ bool CYSFReflectors::load()
if (p1 != NULL && p2 != NULL && p3 != NULL && p4 != NULL && p5 != NULL && p6 != NULL) {
std::string host = std::string(p4);
unsigned int port = (unsigned int)::atoi(p5);
unsigned short port = (unsigned short)::atoi(p5);
if (::strstr(p1, "YCS") == NULL && ::strstr(p2, "YCS") == NULL) {
sockaddr_storage addr;

@ -25,7 +25,7 @@
#include <cstring>
#include <cmath>
CAPRSWriter::CAPRSWriter(const std::string& callsign, const std::string& rptSuffix, const std::string& address, unsigned int port, const std::string& suffix, bool debug) :
CAPRSWriter::CAPRSWriter(const std::string& callsign, const std::string& rptSuffix, const std::string& address, unsigned short port, const std::string& suffix, bool debug) :
m_idTimer(1000U),
m_callsign(callsign),
m_debug(debug),

@ -42,7 +42,7 @@
class CAPRSWriter {
public:
CAPRSWriter(const std::string& callsign, const std::string& rptSuffix, const std::string& address, unsigned int port, const std::string& suffix, bool debug);
CAPRSWriter(const std::string& callsign, const std::string& rptSuffix, const std::string& address, unsigned short port, const std::string& suffix, bool debug);
~CAPRSWriter();
bool open();

@ -183,11 +183,11 @@ bool CConf::read()
else if (::strcmp(key, "RptAddress") == 0)
m_rptAddress = value;
else if (::strcmp(key, "RptPort") == 0)
m_rptPort = (unsigned int)::atoi(value);
m_rptPort = (unsigned short)::atoi(value);
else if (::strcmp(key, "LocalAddress") == 0)
m_myAddress = value;
else if (::strcmp(key, "LocalPort") == 0)
m_myPort = (unsigned int)::atoi(value);
m_myPort = (unsigned short)::atoi(value);
else if (::strcmp(key, "WiresXMakeUpper") == 0)
m_wiresXMakeUpper = ::atoi(value) == 1;
else if (::strcmp(key, "WiresXCommandPassthrough") == 0)
@ -230,7 +230,7 @@ bool CConf::read()
else if (::strcmp(key, "Address") == 0)
m_aprsAddress = value;
else if (::strcmp(key, "Port") == 0)
m_aprsPort = (unsigned int)::atoi(value);
m_aprsPort = (unsigned short)::atoi(value);
else if (::strcmp(key, "Suffix") == 0)
m_aprsSuffix = value;
else if (::strcmp(key, "Description") == 0)
@ -250,7 +250,7 @@ bool CConf::read()
if (::strcmp(key, "Enable") == 0)
m_ysfNetworkEnabled = ::atoi(value) == 1;
else if (::strcmp(key, "Port") == 0)
m_ysfNetworkPort = (unsigned int)::atoi(value);
m_ysfNetworkPort = (unsigned short)::atoi(value);
else if (::strcmp(key, "Hosts") == 0)
m_ysfNetworkHosts = value;
else if (::strcmp(key, "ReloadTime") == 0)
@ -258,26 +258,26 @@ bool CConf::read()
else if (::strcmp(key, "ParrotAddress") == 0)
m_ysfNetworkParrotAddress = value;
else if (::strcmp(key, "ParrotPort") == 0)
m_ysfNetworkParrotPort = (unsigned int)::atoi(value);
m_ysfNetworkParrotPort = (unsigned short)::atoi(value);
else if (::strcmp(key, "YSF2DMRAddress") == 0)
m_ysfNetworkYSF2DMRAddress = value;
else if (::strcmp(key, "YSF2DMRPort") == 0)
m_ysfNetworkYSF2DMRPort = (unsigned int)::atoi(value);
m_ysfNetworkYSF2DMRPort = (unsigned short)::atoi(value);
else if (::strcmp(key, "YSF2NXDNAddress") == 0)
m_ysfNetworkYSF2NXDNAddress = value;
else if (::strcmp(key, "YSF2NXDNPort") == 0)
m_ysfNetworkYSF2NXDNPort = (unsigned int)::atoi(value);
m_ysfNetworkYSF2NXDNPort = (unsigned short)::atoi(value);
else if (::strcmp(key, "YSF2P25Address") == 0)
m_ysfNetworkYSF2P25Address = value;
else if (::strcmp(key, "YSF2P25Port") == 0)
m_ysfNetworkYSF2P25Port = (unsigned int)::atoi(value);
m_ysfNetworkYSF2P25Port = (unsigned short)::atoi(value);
} else if (section == SECTION_FCS_NETWORK) {
if (::strcmp(key, "Enable") == 0)
m_fcsNetworkEnabled = ::atoi(value) == 1;
else if (::strcmp(key, "Rooms") == 0)
m_fcsNetworkFile = value;
else if (::strcmp(key, "Port") == 0)
m_fcsNetworkPort = (unsigned int)::atoi(value);
m_fcsNetworkPort = (unsigned short)::atoi(value);
} else if (section == SECTION_GPSD) {
if (::strcmp(key, "Enable") == 0)
m_gpsdEnabled = ::atoi(value) == 1;
@ -289,7 +289,7 @@ bool CConf::read()
if (::strcmp(key, "Enable") == 0)
m_remoteCommandsEnabled = ::atoi(value) == 1;
else if (::strcmp(key, "Port") == 0)
m_remoteCommandsPort = (unsigned int)::atoi(value);
m_remoteCommandsPort = (unsigned short)::atoi(value);
}
}
@ -318,7 +318,7 @@ std::string CConf::getRptAddress() const
return m_rptAddress;
}
unsigned int CConf::getRptPort() const
unsigned short CConf::getRptPort() const
{
return m_rptPort;
}
@ -328,7 +328,7 @@ std::string CConf::getMyAddress() const
return m_myAddress;
}
unsigned int CConf::getMyPort() const
unsigned short CConf::getMyPort() const
{
return m_myPort;
}
@ -428,7 +428,7 @@ std::string CConf::getAPRSAddress() const
return m_aprsAddress;
}
unsigned int CConf::getAPRSPort() const
unsigned short CConf::getAPRSPort() const
{
return m_aprsPort;
}
@ -473,7 +473,7 @@ bool CConf::getYSFNetworkEnabled() const
return m_ysfNetworkEnabled;
}
unsigned int CConf::getYSFNetworkPort() const
unsigned short CConf::getYSFNetworkPort() const
{
return m_ysfNetworkPort;
}
@ -493,7 +493,7 @@ std::string CConf::getYSFNetworkParrotAddress() const
return m_ysfNetworkParrotAddress;
}
unsigned int CConf::getYSFNetworkParrotPort() const
unsigned short CConf::getYSFNetworkParrotPort() const
{
return m_ysfNetworkParrotPort;
}
@ -503,7 +503,7 @@ std::string CConf::getYSFNetworkYSF2DMRAddress() const
return m_ysfNetworkYSF2DMRAddress;
}
unsigned int CConf::getYSFNetworkYSF2DMRPort() const
unsigned short CConf::getYSFNetworkYSF2DMRPort() const
{
return m_ysfNetworkYSF2DMRPort;
}
@ -513,7 +513,7 @@ std::string CConf::getYSFNetworkYSF2NXDNAddress() const
return m_ysfNetworkYSF2NXDNAddress;
}
unsigned int CConf::getYSFNetworkYSF2NXDNPort() const
unsigned short CConf::getYSFNetworkYSF2NXDNPort() const
{
return m_ysfNetworkYSF2NXDNPort;
}
@ -523,7 +523,7 @@ std::string CConf::getYSFNetworkYSF2P25Address() const
return m_ysfNetworkYSF2P25Address;
}
unsigned int CConf::getYSFNetworkYSF2P25Port() const
unsigned short CConf::getYSFNetworkYSF2P25Port() const
{
return m_ysfNetworkYSF2P25Port;
}
@ -539,7 +539,7 @@ std::string CConf::getFCSNetworkFile() const
return m_fcsNetworkFile;
}
unsigned int CConf::getFCSNetworkPort() const
unsigned short CConf::getFCSNetworkPort() const
{
return m_fcsNetworkPort;
}
@ -564,7 +564,7 @@ bool CConf::getRemoteCommandsEnabled() const
return m_remoteCommandsEnabled;
}
unsigned int CConf::getRemoteCommandsPort() const
unsigned short CConf::getRemoteCommandsPort() const
{
return m_remoteCommandsPort;
}

@ -34,9 +34,9 @@ public:
std::string getSuffix() const;
unsigned int getId() const;
std::string getRptAddress() const;
unsigned int getRptPort() const;
unsigned short getRptPort() const;
std::string getMyAddress() const;
unsigned int getMyPort() const;
unsigned short getMyPort() const;
bool getWiresXMakeUpper() const;
bool getWiresXCommandPassthrough() const;
bool getDebug() const;
@ -62,7 +62,7 @@ public:
// The APRS section
bool getAPRSEnabled() const;
std::string getAPRSAddress() const;
unsigned int getAPRSPort() const;
unsigned short getAPRSPort() const;
std::string getAPRSSuffix() const;
std::string getAPRSDescription() const;
@ -75,22 +75,22 @@ public:
// The YSF Network section
bool getYSFNetworkEnabled() const;
unsigned int getYSFNetworkPort() const;
unsigned short getYSFNetworkPort() const;
std::string getYSFNetworkHosts() const;
unsigned int getYSFNetworkReloadTime() const;
std::string getYSFNetworkParrotAddress() const;
unsigned int getYSFNetworkParrotPort() const;
unsigned short getYSFNetworkParrotPort() const;
std::string getYSFNetworkYSF2DMRAddress() const;
unsigned int getYSFNetworkYSF2DMRPort() const;
unsigned short getYSFNetworkYSF2DMRPort() const;
std::string getYSFNetworkYSF2NXDNAddress() const;
unsigned int getYSFNetworkYSF2NXDNPort() const;
unsigned short getYSFNetworkYSF2NXDNPort() const;
std::string getYSFNetworkYSF2P25Address() const;
unsigned int getYSFNetworkYSF2P25Port() const;
unsigned short getYSFNetworkYSF2P25Port() const;
// The FCS Network section
bool getFCSNetworkEnabled() const;
std::string getFCSNetworkFile() const;
unsigned int getFCSNetworkPort() const;
unsigned short getFCSNetworkPort() const;
// The GPSD section
bool getGPSDEnabled() const;
@ -99,7 +99,7 @@ public:
// The Remote Commands section
bool getRemoteCommandsEnabled() const;
unsigned int getRemoteCommandsPort() const;
unsigned short getRemoteCommandsPort() const;
private:
std::string m_file;
@ -107,9 +107,9 @@ private:
std::string m_suffix;
unsigned int m_id;
std::string m_rptAddress;
unsigned int m_rptPort;
unsigned short m_rptPort;
std::string m_myAddress;
unsigned int m_myPort;
unsigned short m_myPort;
bool m_wiresXMakeUpper;
bool m_wiresXCommandPassthrough;
bool m_debug;
@ -132,7 +132,7 @@ private:
bool m_aprsEnabled;
std::string m_aprsAddress;
unsigned int m_aprsPort;
unsigned short m_aprsPort;
std::string m_aprsSuffix;
std::string m_aprsDescription;
@ -143,28 +143,28 @@ private:
bool m_networkDebug;
bool m_ysfNetworkEnabled;
unsigned int m_ysfNetworkPort;
unsigned short m_ysfNetworkPort;
std::string m_ysfNetworkHosts;
unsigned int m_ysfNetworkReloadTime;
std::string m_ysfNetworkParrotAddress;
unsigned int m_ysfNetworkParrotPort;
unsigned short m_ysfNetworkParrotPort;
std::string m_ysfNetworkYSF2DMRAddress;
unsigned int m_ysfNetworkYSF2DMRPort;
unsigned short m_ysfNetworkYSF2DMRPort;
std::string m_ysfNetworkYSF2NXDNAddress;
unsigned int m_ysfNetworkYSF2NXDNPort;
unsigned short m_ysfNetworkYSF2NXDNPort;
std::string m_ysfNetworkYSF2P25Address;
unsigned int m_ysfNetworkYSF2P25Port;
unsigned short m_ysfNetworkYSF2P25Port;
bool m_fcsNetworkEnabled;
std::string m_fcsNetworkFile;
unsigned int m_fcsNetworkPort;
unsigned short m_fcsNetworkPort;
bool m_gpsdEnabled;
std::string m_gpsdAddress;
std::string m_gpsdPort;
bool m_remoteCommandsEnabled;
unsigned int m_remoteCommandsPort;
unsigned short m_remoteCommandsPort;
};
#endif

@ -29,7 +29,7 @@ const char* FCS_VERSION = "MMDVM";
const unsigned int BUFFER_LENGTH = 200U;
CFCSNetwork::CFCSNetwork(unsigned int port, const std::string& callsign, unsigned int rxFrequency, unsigned int txFrequency, const std::string& locator, unsigned int id, bool debug) :
CFCSNetwork::CFCSNetwork(unsigned short port, const std::string& callsign, unsigned int rxFrequency, unsigned int txFrequency, const std::string& locator, unsigned int id, bool debug) :
m_socket(port),
m_debug(debug),
m_addr(),

@ -36,7 +36,7 @@ enum FCS_STATE {
class CFCSNetwork {
public:
CFCSNetwork(unsigned int port, const std::string& callsign, unsigned int rxFrequency, unsigned int txFrequency, const std::string& locator, unsigned int id, bool debug);
CFCSNetwork(unsigned short port, const std::string& callsign, unsigned int rxFrequency, unsigned int txFrequency, const std::string& locator, unsigned int id, bool debug);
~CFCSNetwork();
bool open();

@ -28,11 +28,12 @@
#if defined(HAVE_LOG_H)
#include "Log.h"
#else
#define LogMessage(fmt, ...) ::fprintf(stderr, fmt "\n", ## __VA_ARGS__)
#define LogError(fmt, ...) ::fprintf(stderr, fmt "\n", ## __VA_ARGS__)
#define LogInfo(fmt, ...) ::fprintf(stderr, fmt "\n", ## __VA_ARGS__)
#endif
CUDPSocket::CUDPSocket(const std::string& address, unsigned int port) :
CUDPSocket::CUDPSocket(const std::string& address, unsigned short port) :
m_address_save(address),
m_port_save(port),
m_counter(0U)
@ -45,7 +46,7 @@ m_counter(0U)
}
}
CUDPSocket::CUDPSocket(unsigned int port) :
CUDPSocket::CUDPSocket(unsigned short port) :
m_address_save(),
m_port_save(port),
m_counter(0U)
@ -79,7 +80,7 @@ void CUDPSocket::shutdown()
#endif
}
int CUDPSocket::lookup(const std::string& hostname, unsigned int port, sockaddr_storage& addr, unsigned int& address_length)
int CUDPSocket::lookup(const std::string& hostname, unsigned short port, sockaddr_storage& addr, unsigned int& address_length)
{
struct addrinfo hints;
::memset(&hints, 0, sizeof(hints));
@ -87,7 +88,7 @@ int CUDPSocket::lookup(const std::string& hostname, unsigned int port, sockaddr_
return lookup(hostname, port, addr, address_length, hints);
}
int CUDPSocket::lookup(const std::string& hostname, unsigned int port, sockaddr_storage& addr, unsigned int& address_length, struct addrinfo& hints)
int CUDPSocket::lookup(const std::string& hostname, unsigned short port, sockaddr_storage& addr, unsigned int& address_length, struct addrinfo& hints)
{
std::string portstr = std::to_string(port);
struct addrinfo *res;
@ -170,7 +171,7 @@ bool CUDPSocket::open(unsigned int af)
return open(0, af, m_address_save, m_port_save);
}
bool CUDPSocket::open(const unsigned int index, const unsigned int af, const std::string& address, const unsigned int port)
bool CUDPSocket::open(const unsigned int index, const unsigned int af, const std::string& address, const unsigned short port)
{
sockaddr_storage addr;
unsigned int addrlen;
@ -187,6 +188,8 @@ bool CUDPSocket::open(const unsigned int index, const unsigned int af, const std
return false;
}
close(index);
int fd = ::socket(addr.ss_family, SOCK_DGRAM, 0);
if (fd < 0) {
#if defined(_WIN32) || defined(_WIN64)
@ -222,7 +225,7 @@ bool CUDPSocket::open(const unsigned int index, const unsigned int af, const std
return false;
}
LogInfo("Opening UDP port on %u", port);
LogInfo("Opening UDP port on %hu", port);
}
return true;
@ -291,7 +294,7 @@ int CUDPSocket::read(unsigned char* buffer, unsigned int length, sockaddr_storag
LogError("Error returned from recvfrom, err: %d", errno);
if (len == -1 && errno == ENOTSOCK) {
LogMessage("Re-opening UDP port on %u", m_port);
LogMessage("Re-opening UDP port on %hu", m_port[index]);
close();
open();
}
@ -343,13 +346,13 @@ bool CUDPSocket::write(const unsigned char* buffer, unsigned int length, const s
void CUDPSocket::close()
{
for (int i = 0; i < UDP_SOCKET_MAX; i++)
close(m_fd[i]);
for (unsigned int i = 0; i < UDP_SOCKET_MAX; i++)
close(i);
}
void CUDPSocket::close(const unsigned int index)
{
if (m_fd[index] >= 0) {
if ((index < UDP_SOCKET_MAX) && (m_fd[index] >= 0)) {
#if defined(_WIN32) || defined(_WIN64)
::closesocket(m_fd[index]);
#else

@ -46,13 +46,13 @@ enum IPMATCHTYPE {
class CUDPSocket {
public:
CUDPSocket(const std::string& address, unsigned int port = 0U);
CUDPSocket(unsigned int port = 0U);
CUDPSocket(const std::string& address, unsigned short port = 0U);
CUDPSocket(unsigned short port = 0U);
~CUDPSocket();
bool open(unsigned int af = AF_UNSPEC);
bool open(const sockaddr_storage& address);
bool open(const unsigned int index, const unsigned int af, const std::string& address, const unsigned int port);
bool open(const unsigned int index, const unsigned int af, const std::string& address, const unsigned short port);
int read(unsigned char* buffer, unsigned int length, sockaddr_storage& address, unsigned int &address_length);
bool write(const unsigned char* buffer, unsigned int length, const sockaddr_storage& address, unsigned int address_length);
@ -63,8 +63,8 @@ public:
static void startup();
static void shutdown();
static int lookup(const std::string& hostName, unsigned int port, sockaddr_storage& address, unsigned int& address_length);
static int lookup(const std::string& hostName, unsigned int port, sockaddr_storage& address, unsigned int& address_length, struct addrinfo& hints);
static int lookup(const std::string& hostName, unsigned short port, sockaddr_storage& address, unsigned int& address_length);
static int lookup(const std::string& hostName, unsigned short port, sockaddr_storage& address, unsigned int& address_length, struct addrinfo& hints);
static bool match(const sockaddr_storage& addr1, const sockaddr_storage& addr2, IPMATCHTYPE type = IMT_ADDRESS_AND_PORT);

@ -153,22 +153,22 @@ void CWiresX::setInfo(const std::string& name, unsigned int txFrequency, unsigne
m_header[i + 14U] = m_node.at(i);
}
void CWiresX::setParrot(const std::string& address, unsigned int port)
void CWiresX::setParrot(const std::string& address, unsigned short port)
{
m_reflectors.setParrot(address, port);
}
void CWiresX::setYSF2DMR(const std::string& address, unsigned int port)
void CWiresX::setYSF2DMR(const std::string& address, unsigned short port)
{
m_reflectors.setYSF2DMR(address, port);
}
void CWiresX::setYSF2NXDN(const std::string& address, unsigned int port)
void CWiresX::setYSF2NXDN(const std::string& address, unsigned short port)
{
m_reflectors.setYSF2NXDN(address, port);
}
void CWiresX::setYSF2P25(const std::string& address, unsigned int port)
void CWiresX::setYSF2P25(const std::string& address, unsigned short port)
{
m_reflectors.setYSF2P25(address, port);
}

@ -51,10 +51,10 @@ public:
~CWiresX();
void setInfo(const std::string& name, unsigned int txFrequency, unsigned int rxFrequency);
void setParrot(const std::string& address, unsigned int port);
void setYSF2DMR(const std::string& address, unsigned int port);
void setYSF2NXDN(const std::string& address, unsigned int port);
void setYSF2P25(const std::string& address, unsigned int port);
void setParrot(const std::string& address, unsigned short port);
void setYSF2DMR(const std::string& address, unsigned short port);
void setYSF2NXDN(const std::string& address, unsigned short port);
void setYSF2P25(const std::string& address, unsigned short port);
void addFCSRoom(const std::string& id, const std::string& name);
bool start();

@ -47,6 +47,6 @@ const unsigned char YSF_CM_INDIVIDUAL = 0x03U;
const unsigned char YSF_MR_NOT_BUSY = 0x01U;
const unsigned char YSF_MR_BUSY = 0x02U;
const unsigned int FCS_PORT = 62500U;
const unsigned short FCS_PORT = 62500U;
#endif

@ -199,7 +199,7 @@ int CYSFGateway::run()
}
std::string myAddress = m_conf.getMyAddress();
unsigned int myPort = m_conf.getMyPort();
unsigned short myPort = m_conf.getMyPort();
CYSFNetwork rptNetwork(myAddress, myPort, m_callsign, debug);
ret = rptNetwork.setDestination("MMDVM", rptAddr, rptAddrLen);
@ -211,7 +211,7 @@ int CYSFGateway::run()
bool ysfNetworkEnabled = m_conf.getYSFNetworkEnabled();
if (ysfNetworkEnabled) {
unsigned int ysfPort = m_conf.getYSFNetworkPort();
unsigned short ysfPort = m_conf.getYSFNetworkPort();
m_ysfNetwork = new CYSFNetwork(ysfPort, m_callsign, debug);
}
@ -222,7 +222,7 @@ int CYSFGateway::run()
std::string locator = calculateLocator();
unsigned int id = m_conf.getId();
unsigned int fcsPort = m_conf.getFCSNetworkPort();
unsigned short fcsPort = m_conf.getFCSNetworkPort();
m_fcsNetwork = new CFCSNetwork(fcsPort, m_callsign, rxFrequency, txFrequency, locator, id, debug);
ret = m_fcsNetwork->open();
@ -454,7 +454,7 @@ void CYSFGateway::createGPS()
return;
std::string address = m_conf.getAPRSAddress();
unsigned int port = m_conf.getAPRSPort();
unsigned short port = m_conf.getAPRSPort();
std::string suffix = m_conf.getAPRSSuffix();
bool debug = m_conf.getDebug();
@ -503,7 +503,7 @@ void CYSFGateway::createWiresX(CYSFNetwork* rptNetwork)
m_wiresX->setInfo(name, txFrequency, rxFrequency);
std::string address = m_conf.getYSFNetworkParrotAddress();
unsigned int port = m_conf.getYSFNetworkParrotPort();
unsigned short port = m_conf.getYSFNetworkParrotPort();
if (port > 0U)
m_wiresX->setParrot(address, port);

@ -27,7 +27,7 @@
const unsigned int BUFFER_LENGTH = 200U;
CYSFNetwork::CYSFNetwork(const std::string& address, unsigned int port, const std::string& callsign, bool debug) :
CYSFNetwork::CYSFNetwork(const std::string& address, unsigned short port, const std::string& callsign, bool debug) :
m_socket(address, port),
m_debug(debug),
m_addr(),
@ -60,7 +60,7 @@ m_linked(false)
}
}
CYSFNetwork::CYSFNetwork(unsigned int port, const std::string& callsign, bool debug) :
CYSFNetwork::CYSFNetwork(unsigned short port, const std::string& callsign, bool debug) :
m_socket(port),
m_debug(debug),
m_addr(),

@ -29,8 +29,8 @@
class CYSFNetwork {
public:
CYSFNetwork(const std::string& address, unsigned int port, const std::string& callsign, bool debug);
CYSFNetwork(unsigned int port, const std::string& callsign, bool debug);
CYSFNetwork(const std::string& address, unsigned short port, const std::string& callsign, bool debug);
CYSFNetwork(unsigned short port, const std::string& callsign, bool debug);
~CYSFNetwork();
bool setDestination(const std::string& name, const sockaddr_storage& addr, unsigned int addrLen);

@ -76,25 +76,25 @@ static bool refComparison(const CYSFReflector* r1, const CYSFReflector* r2)
return false;
}
void CYSFReflectors::setParrot(const std::string& address, unsigned int port)
void CYSFReflectors::setParrot(const std::string& address, unsigned short port)
{
m_parrotAddress = address;
m_parrotPort = port;
}
void CYSFReflectors::setYSF2DMR(const std::string& address, unsigned int port)
void CYSFReflectors::setYSF2DMR(const std::string& address, unsigned short port)
{
m_YSF2DMRAddress = address;
m_YSF2DMRPort = port;
}
void CYSFReflectors::setYSF2NXDN(const std::string& address, unsigned int port)
void CYSFReflectors::setYSF2NXDN(const std::string& address, unsigned short port)
{
m_YSF2NXDNAddress = address;
m_YSF2NXDNPort = port;
}
void CYSFReflectors::setYSF2P25(const std::string& address, unsigned int port)
void CYSFReflectors::setYSF2P25(const std::string& address, unsigned short port)
{
m_YSF2P25Address = address;
m_YSF2P25Port = port;
@ -128,7 +128,7 @@ bool CYSFReflectors::load()
if (p1 != NULL && p2 != NULL && p3 != NULL && p4 != NULL && p5 != NULL && p6 != NULL) {
std::string host = std::string(p4);
unsigned int port = (unsigned int)::atoi(p5);
unsigned short port = (unsigned short)::atoi(p5);
sockaddr_storage addr;
unsigned int addrLen;

@ -59,10 +59,10 @@ public:
CYSFReflectors(const std::string& hostsFile, unsigned int reloadTime, bool makeUpper);
~CYSFReflectors();
void setParrot(const std::string& address, unsigned int port);
void setYSF2DMR(const std::string& address, unsigned int port);
void setYSF2NXDN(const std::string& address, unsigned int port);
void setYSF2P25(const std::string& address, unsigned int port);
void setParrot(const std::string& address, unsigned short port);
void setYSF2DMR(const std::string& address, unsigned short port);
void setYSF2NXDN(const std::string& address, unsigned short port);
void setYSF2P25(const std::string& address, unsigned short port);
void addFCSRoom(const std::string& id, const std::string& name);
bool load();
@ -81,13 +81,13 @@ public:
private:
std::string m_hostsFile;
std::string m_parrotAddress;
unsigned int m_parrotPort;
unsigned short m_parrotPort;
std::string m_YSF2DMRAddress;
unsigned int m_YSF2DMRPort;
unsigned short m_YSF2DMRPort;
std::string m_YSF2NXDNAddress;
unsigned int m_YSF2NXDNPort;
unsigned short m_YSF2NXDNPort;
std::string m_YSF2P25Address;
unsigned int m_YSF2P25Port;
unsigned short m_YSF2P25Port;
std::vector<std::pair<std::string, std::string>> m_fcsRooms;
std::vector<CYSFReflector*> m_newReflectors;
std::vector<CYSFReflector*> m_currReflectors;

@ -24,7 +24,7 @@
const unsigned int BUFFER_LENGTH = 200U;
CNetwork::CNetwork(unsigned int port) :
CNetwork::CNetwork(unsigned short port) :
m_socket(port),
m_addr(),
m_addrLen(0U)

@ -26,7 +26,7 @@
class CNetwork {
public:
CNetwork(unsigned int port);
CNetwork(unsigned short port);
~CNetwork();
bool open();

@ -33,7 +33,7 @@
#define LogInfo(fmt, ...) ::fprintf(stderr, fmt "\n", ## __VA_ARGS__)
#endif
CUDPSocket::CUDPSocket(const std::string& address, unsigned int port) :
CUDPSocket::CUDPSocket(const std::string& address, unsigned short port) :
m_address_save(address),
m_port_save(port),
m_counter(0U)
@ -46,7 +46,7 @@ m_counter(0U)
}
}
CUDPSocket::CUDPSocket(unsigned int port) :
CUDPSocket::CUDPSocket(unsigned short port) :
m_address_save(),
m_port_save(port),
m_counter(0U)
@ -80,7 +80,7 @@ void CUDPSocket::shutdown()
#endif
}
int CUDPSocket::lookup(const std::string& hostname, unsigned int port, sockaddr_storage& addr, unsigned int& address_length)
int CUDPSocket::lookup(const std::string& hostname, unsigned short port, sockaddr_storage& addr, unsigned int& address_length)
{
struct addrinfo hints;
::memset(&hints, 0, sizeof(hints));
@ -88,7 +88,7 @@ int CUDPSocket::lookup(const std::string& hostname, unsigned int port, sockaddr_
return lookup(hostname, port, addr, address_length, hints);
}
int CUDPSocket::lookup(const std::string& hostname, unsigned int port, sockaddr_storage& addr, unsigned int& address_length, struct addrinfo& hints)
int CUDPSocket::lookup(const std::string& hostname, unsigned short port, sockaddr_storage& addr, unsigned int& address_length, struct addrinfo& hints)
{
std::string portstr = std::to_string(port);
struct addrinfo *res;
@ -171,7 +171,7 @@ bool CUDPSocket::open(unsigned int af)
return open(0, af, m_address_save, m_port_save);
}
bool CUDPSocket::open(const unsigned int index, const unsigned int af, const std::string& address, const unsigned int port)
bool CUDPSocket::open(const unsigned int index, const unsigned int af, const std::string& address, const unsigned short port)
{
sockaddr_storage addr;
unsigned int addrlen;
@ -188,6 +188,8 @@ bool CUDPSocket::open(const unsigned int index, const unsigned int af, const std
return false;
}
close(index);
int fd = ::socket(addr.ss_family, SOCK_DGRAM, 0);
if (fd < 0) {
#if defined(_WIN32) || defined(_WIN64)
@ -223,7 +225,7 @@ bool CUDPSocket::open(const unsigned int index, const unsigned int af, const std
return false;
}
LogInfo("Opening UDP port on %u", port);
LogInfo("Opening UDP port on %hu", port);
}
return true;
@ -292,7 +294,7 @@ int CUDPSocket::read(unsigned char* buffer, unsigned int length, sockaddr_storag
LogError("Error returned from recvfrom, err: %d", errno);
if (len == -1 && errno == ENOTSOCK) {
LogMessage("Re-opening UDP port on %u", m_port);
LogMessage("Re-opening UDP port on %hu", m_port[index]);
close();
open();
}
@ -344,13 +346,13 @@ bool CUDPSocket::write(const unsigned char* buffer, unsigned int length, const s
void CUDPSocket::close()
{
for (int i = 0; i < UDP_SOCKET_MAX; i++)
close(m_fd[i]);
for (unsigned int i = 0; i < UDP_SOCKET_MAX; i++)
close(i);
}
void CUDPSocket::close(const unsigned int index)
{
if (m_fd[index] >= 0) {
if ((index < UDP_SOCKET_MAX) && (m_fd[index] >= 0)) {
#if defined(_WIN32) || defined(_WIN64)
::closesocket(m_fd[index]);
#else

@ -46,13 +46,13 @@ enum IPMATCHTYPE {
class CUDPSocket {
public:
CUDPSocket(const std::string& address, unsigned int port = 0U);
CUDPSocket(unsigned int port = 0U);
CUDPSocket(const std::string& address, unsigned short port = 0U);
CUDPSocket(unsigned short port = 0U);
~CUDPSocket();
bool open(unsigned int af = AF_UNSPEC);
bool open(const sockaddr_storage& address);
bool open(const unsigned int index, const unsigned int af, const std::string& address, const unsigned int port);
bool open(const unsigned int index, const unsigned int af, const std::string& address, const unsigned short port);
int read(unsigned char* buffer, unsigned int length, sockaddr_storage& address, unsigned int &address_length);
bool write(const unsigned char* buffer, unsigned int length, const sockaddr_storage& address, unsigned int address_length);
@ -63,8 +63,8 @@ public:
static void startup();
static void shutdown();
static int lookup(const std::string& hostName, unsigned int port, sockaddr_storage& address, unsigned int& address_length);
static int lookup(const std::string& hostName, unsigned int port, sockaddr_storage& address, unsigned int& address_length, struct addrinfo& hints);
static int lookup(const std::string& hostName, unsigned short port, sockaddr_storage& address, unsigned int& address_length);
static int lookup(const std::string& hostName, unsigned short port, sockaddr_storage& address, unsigned int& address_length, struct addrinfo& hints);
static bool match(const sockaddr_storage& addr1, const sockaddr_storage& addr2, IPMATCHTYPE type = IMT_ADDRESS_AND_PORT);

@ -35,7 +35,7 @@ int main(int argc, char** argv)
return 1;
}
unsigned int port = ::atoi(argv[1U]);
unsigned short port = (unsigned short)::atoi(argv[1U]);
if (port == 0U) {
::fprintf(stderr, "YSFParrot: invalid port number - %s\n", argv[1U]);
return 1;
@ -47,7 +47,7 @@ int main(int argc, char** argv)
return 0;
}
CYSFParrot::CYSFParrot(unsigned int port) :
CYSFParrot::CYSFParrot(unsigned short port) :
m_port(port)
{
CUDPSocket::startup();

@ -22,13 +22,13 @@
class CYSFParrot
{
public:
CYSFParrot(unsigned int port);
CYSFParrot(unsigned short port);
~CYSFParrot();
void run();
private:
unsigned int m_port;
unsigned short m_port;
};
#endif

@ -137,7 +137,7 @@ bool CConf::read()
m_logFileRotate = ::atoi(value) == 1;
} else if (section == SECTION_NETWORK) {
if (::strcmp(key, "Port") == 0)
m_networkPort = (unsigned int)::atoi(value);
m_networkPort = (unsigned short)::atoi(value);
else if (::strcmp(key, "Debug") == 0)
m_networkDebug = ::atoi(value) == 1;
} else if (section == SECTION_BLOCKLIST) {
@ -198,7 +198,7 @@ bool CConf::getLogFileRotate() const
return m_logFileRotate;
}
unsigned int CConf::getNetworkPort() const
unsigned short CConf::getNetworkPort() const
{
return m_networkPort;
}

@ -46,7 +46,7 @@ public:
bool getLogFileRotate() const;
// The Network section
unsigned int getNetworkPort() const;
unsigned short getNetworkPort() const;
bool getNetworkDebug() const;
// The Block List section
@ -67,7 +67,7 @@ private:
std::string m_logFileRoot;
bool m_logFileRotate;
unsigned int m_networkPort;
unsigned short m_networkPort;
bool m_networkDebug;
std::string m_blockListFile;

@ -25,7 +25,7 @@
#include <cassert>
#include <cstring>
CNetwork::CNetwork(unsigned int port, unsigned int id, const std::string& name, const std::string& description, bool debug) :
CNetwork::CNetwork(unsigned short port, unsigned int id, const std::string& name, const std::string& description, bool debug) :
m_socket(),
m_port(port),
m_id(id),

@ -28,7 +28,7 @@
class CNetwork {
public:
CNetwork(unsigned int port, unsigned int id, const std::string& name, const std::string& description, bool debug);
CNetwork(unsigned short port, unsigned int id, const std::string& name, const std::string& description, bool debug);
~CNetwork();
bool open();

Loading…
Cancel
Save