upstream: fix network ports data type;

pull/1/head
Bryan Biedenkapp 5 years ago
parent 5fd9f1d8ea
commit 13e39b0927

@ -1354,7 +1354,7 @@ bool Host::createModem()
yaml::Node udpProtocol = modemProtocol["udp"]; yaml::Node udpProtocol = modemProtocol["udp"];
std::string udpMode = udpProtocol["mode"].as<std::string>("master"); std::string udpMode = udpProtocol["mode"].as<std::string>("master");
std::string udpAddress = udpProtocol["endpointAddress"].as<std::string>(); std::string udpAddress = udpProtocol["endpointAddress"].as<std::string>();
uint32_t udpPort = udpProtocol["port"].as<uint32_t>(REMOTE_MODEM_PORT); uint16_t udpPort = (uint16_t)udpProtocol["port"].as<uint32_t>(REMOTE_MODEM_PORT);
bool rxInvert = modemConf["rxInvert"].as<bool>(false); bool rxInvert = modemConf["rxInvert"].as<bool>(false);
bool txInvert = modemConf["txInvert"].as<bool>(false); bool txInvert = modemConf["txInvert"].as<bool>(false);
@ -1513,11 +1513,11 @@ bool Host::createNetwork()
{ {
yaml::Node networkConf = m_conf["network"]; yaml::Node networkConf = m_conf["network"];
std::string address = networkConf["address"].as<std::string>(); std::string address = networkConf["address"].as<std::string>();
uint32_t port = networkConf["port"].as<uint32_t>(TRAFFIC_DEFAULT_PORT); uint16_t port = (uint16_t)networkConf["port"].as<uint32_t>(TRAFFIC_DEFAULT_PORT);
uint32_t local = networkConf["local"].as<uint32_t>(0U); uint16_t local = (uint16_t)networkConf["local"].as<uint32_t>(0U);
bool rconEnable = networkConf["rconEnable"].as<bool>(false); bool rconEnable = networkConf["rconEnable"].as<bool>(false);
std::string rconAddress = networkConf["rconAddress"].as<std::string>("127.0.0.1"); std::string rconAddress = networkConf["rconAddress"].as<std::string>("127.0.0.1");
uint32_t rconPort = networkConf["rconPort"].as<uint32_t>(RCON_DEFAULT_PORT); uint16_t rconPort = (uint16_t)networkConf["rconPort"].as<uint32_t>(RCON_DEFAULT_PORT);
std::string rconPassword = networkConf["rconPassword"].as<std::string>(); std::string rconPassword = networkConf["rconPassword"].as<std::string>();
bool rconDebug = networkConf["rconDebug"].as<bool>(false); bool rconDebug = networkConf["rconDebug"].as<bool>(false);
uint32_t id = networkConf["id"].as<uint32_t>(0U); uint32_t id = networkConf["id"].as<uint32_t>(0U);

@ -54,7 +54,7 @@ const uint32_t BUFFER_LENGTH = 2000U;
/// <param name="address">Hostname/IP address to connect to.</param> /// <param name="address">Hostname/IP address to connect to.</param>
/// <param name="modemPort">Port number.</param> /// <param name="modemPort">Port number.</param>
/// <param name="master"></param> /// <param name="master"></param>
UDPPort::UDPPort(const std::string& address, uint32_t modemPort) : UDPPort::UDPPort(const std::string& address, uint16_t modemPort) :
m_socket(modemPort), m_socket(modemPort),
m_addr(), m_addr(),
m_addrLen(0U), m_addrLen(0U),

@ -50,7 +50,7 @@ namespace modem
class HOST_SW_API UDPPort : public IModemPort { class HOST_SW_API UDPPort : public IModemPort {
public: public:
/// <summary>Initializes a new instance of the UDPPort class.</summary> /// <summary>Initializes a new instance of the UDPPort class.</summary>
UDPPort(const std::string& modemAddress, uint32_t modemPort); UDPPort(const std::string& modemAddress, uint16_t modemPort);
/// <summary>Finalizes a instance of the UDPPort class.</summary> /// <summary>Finalizes a instance of the UDPPort class.</summary>
virtual ~UDPPort(); virtual ~UDPPort();

@ -54,7 +54,7 @@ using namespace network;
/// <param name="slot2">Flag indicating whether DMR slot 2 is enabled for network traffic.</param> /// <param name="slot2">Flag indicating whether DMR slot 2 is enabled for network traffic.</param>
/// <param name="allowActivityTransfer">Flag indicating that the system activity logs will be sent to the network.</param> /// <param name="allowActivityTransfer">Flag indicating that the system activity logs will be sent to the network.</param>
/// <param name="allowDiagnosticTransfer">Flag indicating that the system diagnostic logs will be sent to the network.</param> /// <param name="allowDiagnosticTransfer">Flag indicating that the system diagnostic logs will be sent to the network.</param>
BaseNetwork::BaseNetwork(uint32_t localPort, uint32_t id, bool duplex, bool debug, bool slot1, bool slot2, bool allowActivityTransfer, bool allowDiagnosticTransfer) : BaseNetwork::BaseNetwork(uint16_t localPort, uint32_t id, bool duplex, bool debug, bool slot1, bool slot2, bool allowActivityTransfer, bool allowDiagnosticTransfer) :
m_id(id), m_id(id),
m_slot1(slot1), m_slot1(slot1),
m_slot2(slot2), m_slot2(slot2),

@ -190,7 +190,7 @@ namespace network
class HOST_SW_API BaseNetwork { class HOST_SW_API BaseNetwork {
public: public:
/// <summary>Initializes a new instance of the BaseNetwork class.</summary> /// <summary>Initializes a new instance of the BaseNetwork class.</summary>
BaseNetwork(uint32_t localPort, uint32_t id, bool duplex, bool debug, bool slot1, bool slot2, bool transferActivityLog, bool transferDiagnosticLog); BaseNetwork(uint16_t localPort, uint32_t id, bool duplex, bool debug, bool slot1, bool slot2, bool transferActivityLog, bool transferDiagnosticLog);
/// <summary>Finalizes a instance of the BaseNetwork class.</summary> /// <summary>Finalizes a instance of the BaseNetwork class.</summary>
virtual ~BaseNetwork(); virtual ~BaseNetwork();

@ -58,7 +58,7 @@ using namespace network;
/// <param name="allowActivityTransfer">Flag indicating that the system activity logs will be sent to the network.</param> /// <param name="allowActivityTransfer">Flag indicating that the system activity logs will be sent to the network.</param>
/// <param name="allowDiagnosticTransfer">Flag indicating that the system diagnostic logs will be sent to the network.</param> /// <param name="allowDiagnosticTransfer">Flag indicating that the system diagnostic logs will be sent to the network.</param>
/// <param name="updateLookup">Flag indicating that the system will accept radio ID and talkgroup ID lookups from the network.</param> /// <param name="updateLookup">Flag indicating that the system will accept radio ID and talkgroup ID lookups from the network.</param>
Network::Network(const std::string& address, uint32_t port, uint32_t local, uint32_t id, const std::string& password, Network::Network(const std::string& address, uint16_t port, uint16_t local, uint32_t id, const std::string& password,
bool duplex, bool debug, bool slot1, bool slot2, bool allowActivityTransfer, bool allowDiagnosticTransfer, bool updateLookup) : bool duplex, bool debug, bool slot1, bool slot2, bool allowActivityTransfer, bool allowDiagnosticTransfer, bool updateLookup) :
BaseNetwork(local, id, duplex, debug, slot1, slot2, allowActivityTransfer, allowDiagnosticTransfer), BaseNetwork(local, id, duplex, debug, slot1, slot2, allowActivityTransfer, allowDiagnosticTransfer),
m_address(address), m_address(address),
@ -185,7 +185,7 @@ void Network::clock(uint32_t ms)
} }
sockaddr_storage address; sockaddr_storage address;
unsigned int addrLen; uint32_t addrLen;
int length = m_socket.read(m_buffer, DATA_PACKET_LENGTH, address, addrLen); int length = m_socket.read(m_buffer, DATA_PACKET_LENGTH, address, addrLen);
if (length < 0) { if (length < 0) {
LogError(LOG_NET, "Socket has failed, retrying connection to the master"); LogError(LOG_NET, "Socket has failed, retrying connection to the master");

@ -49,7 +49,7 @@ namespace network
class HOST_SW_API Network : public BaseNetwork { class HOST_SW_API Network : public BaseNetwork {
public: public:
/// <summary>Initializes a new instance of the Network class.</summary> /// <summary>Initializes a new instance of the Network class.</summary>
Network(const std::string& address, uint32_t port, uint32_t local, uint32_t id, const std::string& password, Network(const std::string& address, uint16_t port, uint16_t local, uint32_t id, const std::string& password,
bool duplex, bool debug, bool slot1, bool slot2, bool transferActivityLog, bool transferDiagnosticLog, bool updateLookup); bool duplex, bool debug, bool slot1, bool slot2, bool transferActivityLog, bool transferDiagnosticLog, bool updateLookup);
/// <summary>Finalizes a instance of the Network class.</summary> /// <summary>Finalizes a instance of the Network class.</summary>
~Network(); ~Network();
@ -78,7 +78,7 @@ namespace network
private: private:
std::string m_address; std::string m_address;
unsigned int m_port; uint16_t m_port;
std::string m_password; std::string m_password;

@ -108,7 +108,7 @@ const uint32_t RC_BUFFER_LENGTH = 140U;
/// <param name="port">Network port number.</param> /// <param name="port">Network port number.</param>
/// <param name="password">Authentication password.</param> /// <param name="password">Authentication password.</param>
/// <param name="debug"></param> /// <param name="debug"></param>
RemoteControl::RemoteControl(const std::string& address, uint32_t port, const std::string& password, bool debug) : RemoteControl::RemoteControl(const std::string& address, uint16_t port, const std::string& password, bool debug) :
m_socket(address, port), m_socket(address, port),
m_p25MFId(p25::P25_MFG_STANDARD), m_p25MFId(p25::P25_MFG_STANDARD),
m_password(password), m_password(password),

@ -57,7 +57,7 @@ namespace p25 { class HOST_SW_API Control; }
class HOST_SW_API RemoteControl { class HOST_SW_API RemoteControl {
public: public:
/// <summary>Initializes a new instance of the RemoteControl class.</summary> /// <summary>Initializes a new instance of the RemoteControl class.</summary>
RemoteControl(const std::string& address, uint32_t port, const std::string& password, bool debug); RemoteControl(const std::string& address, uint16_t port, const std::string& password, bool debug);
/// <summary>Finalizes a instance of the RemoteControl class.</summary> /// <summary>Finalizes a instance of the RemoteControl class.</summary>
~RemoteControl(); ~RemoteControl();

@ -49,7 +49,7 @@ using namespace network;
/// </summary> /// </summary>
/// <param name="address">Hostname/IP address to connect to.</param> /// <param name="address">Hostname/IP address to connect to.</param>
/// <param name="port">Port number.</param> /// <param name="port">Port number.</param>
UDPSocket::UDPSocket(const std::string& address, uint32_t port) : UDPSocket::UDPSocket(const std::string& address, uint16_t port) :
m_address_save(address), m_address_save(address),
m_port_save(port), m_port_save(port),
m_counter(0U) m_counter(0U)
@ -66,7 +66,7 @@ UDPSocket::UDPSocket(const std::string& address, uint32_t port) :
/// Initializes a new instance of the UDPSocket class. /// Initializes a new instance of the UDPSocket class.
/// </summary> /// </summary>
/// <param name="port">Port number.</param> /// <param name="port">Port number.</param>
UDPSocket::UDPSocket(uint32_t port) : UDPSocket::UDPSocket(uint16_t port) :
m_address_save(), m_address_save(),
m_port_save(port), m_port_save(port),
m_counter(0U) m_counter(0U)
@ -115,7 +115,7 @@ bool UDPSocket::open(uint32_t af)
/// <param name="address"></param> /// <param name="address"></param>
/// <param name="port"></param> /// <param name="port"></param>
/// <returns>True, if UDP socket is opened, otherwise false.</returns> /// <returns>True, if UDP socket is opened, otherwise false.</returns>
bool UDPSocket::open(const uint32_t index, const uint32_t af, const std::string& address, const uint32_t port) bool UDPSocket::open(const uint32_t index, const uint32_t af, const std::string& address, const uint16_t port)
{ {
sockaddr_storage addr; sockaddr_storage addr;
uint32_t addrlen; uint32_t addrlen;
@ -362,7 +362,7 @@ void UDPSocket::shutdown()
/// <param name="addr">Socket address structure.</param> /// <param name="addr">Socket address structure.</param>
/// <param name="addrLen"></param> /// <param name="addrLen"></param>
/// <returns>Zero if no error during lookup, otherwise error.</returns> /// <returns>Zero if no error during lookup, otherwise error.</returns>
int UDPSocket::lookup(const std::string& hostname, uint32_t port, sockaddr_storage& addr, uint32_t& addrLen) int UDPSocket::lookup(const std::string& hostname, uint16_t port, sockaddr_storage& addr, uint32_t& addrLen)
{ {
struct addrinfo hints; struct addrinfo hints;
::memset(&hints, 0, sizeof(hints)); ::memset(&hints, 0, sizeof(hints));
@ -379,12 +379,12 @@ int UDPSocket::lookup(const std::string& hostname, uint32_t port, sockaddr_stora
/// <param name="addrLen"></param> /// <param name="addrLen"></param>
/// <param name="hints"></param> /// <param name="hints"></param>
/// <returns>Zero if no error during lookup, otherwise error.</returns> /// <returns>Zero if no error during lookup, otherwise error.</returns>
int UDPSocket::lookup(const std::string& hostname, uint32_t port, sockaddr_storage& addr, uint32_t& addrLen, struct addrinfo& hints) int UDPSocket::lookup(const std::string& hostname, uint16_t port, sockaddr_storage& addr, uint32_t& addrLen, struct addrinfo& hints)
{ {
std::string portstr = std::to_string(port); std::string portstr = std::to_string(port);
struct addrinfo* res; struct addrinfo* res;
/* port is always digits, no needs to lookup service */ // port is always digits, no needs to lookup service
hints.ai_flags |= AI_NUMERICSERV; hints.ai_flags |= AI_NUMERICSERV;
int err = getaddrinfo(hostname.empty() ? NULL : hostname.c_str(), portstr.c_str(), &hints, &res); int err = getaddrinfo(hostname.empty() ? NULL : hostname.c_str(), portstr.c_str(), &hints, &res);
@ -464,8 +464,6 @@ std::string UDPSocket::address(const sockaddr_storage& addr)
std::string address = std::string(); std::string address = std::string();
char str[INET_ADDRSTRLEN]; char str[INET_ADDRSTRLEN];
switch (addr.ss_family) { switch (addr.ss_family) {
case AF_INET: case AF_INET:
{ {

@ -69,9 +69,9 @@ namespace network
class HOST_SW_API UDPSocket { class HOST_SW_API UDPSocket {
public: public:
/// <summary>Initializes a new instance of the UDPSocket class.</summary> /// <summary>Initializes a new instance of the UDPSocket class.</summary>
UDPSocket(const std::string& address, uint32_t port = 0U); UDPSocket(const std::string& address, uint16_t port = 0U);
/// <summary>Initializes a new instance of the UDPSocket class.</summary> /// <summary>Initializes a new instance of the UDPSocket class.</summary>
UDPSocket(uint32_t port = 0U); UDPSocket(uint16_t port = 0U);
/// <summary>Initializes a new instance of the UDPSocket class.</summary> /// <summary>Initializes a new instance of the UDPSocket class.</summary>
~UDPSocket(); ~UDPSocket();
@ -80,7 +80,7 @@ namespace network
/// <summary>Opens UDP socket connection.</summary> /// <summary>Opens UDP socket connection.</summary>
bool open(const sockaddr_storage& address); bool open(const sockaddr_storage& address);
/// <summary>Opens UDP socket connection.</summary> /// <summary>Opens UDP socket connection.</summary>
bool open(const uint32_t index, const uint32_t af, const std::string& address, const uint32_t port); bool open(const uint32_t index, const uint32_t af, const std::string& address, const uint16_t port);
/// <summary>Read data from the UDP socket.</summary> /// <summary>Read data from the UDP socket.</summary>
int read(uint8_t* buffer, uint32_t length, sockaddr_storage& address, uint32_t& addrLen); int read(uint8_t* buffer, uint32_t length, sockaddr_storage& address, uint32_t& addrLen);
@ -98,9 +98,9 @@ namespace network
static void shutdown(); static void shutdown();
/// <summary>Helper to lookup a hostname and resolve it to an IP address.</summary> /// <summary>Helper to lookup a hostname and resolve it to an IP address.</summary>
static int lookup(const std::string& hostName, uint32_t port, sockaddr_storage& address, uint32_t& addrLen); static int lookup(const std::string& hostName, uint16_t port, sockaddr_storage& address, uint32_t& addrLen);
/// <summary>Helper to lookup a hostname and resolve it to an IP address.</summary> /// <summary>Helper to lookup a hostname and resolve it to an IP address.</summary>
static int lookup(const std::string& hostName, uint32_t port, sockaddr_storage& address, uint32_t& addrLen, struct addrinfo& hints); static int lookup(const std::string& hostName, uint16_t port, sockaddr_storage& address, uint32_t& addrLen, struct addrinfo& hints);
/// <summary></summary> /// <summary></summary>
static bool match(const sockaddr_storage& addr1, const sockaddr_storage& addr2, IPMATCHTYPE type = IMT_ADDRESS_AND_PORT); static bool match(const sockaddr_storage& addr1, const sockaddr_storage& addr2, IPMATCHTYPE type = IMT_ADDRESS_AND_PORT);

Loading…
Cancel
Save

Powered by TurnKey Linux.