less compiler warnings
This commit is contained in:
+1
-1
@@ -257,7 +257,7 @@ error_t parse_opt(int key, char *arg, struct argp_state *state)
|
|||||||
opt->foreground = true;
|
opt->foreground = true;
|
||||||
break;
|
break;
|
||||||
case 'p': // --port=8888
|
case 'p': // --port=8888
|
||||||
opt->port = parseInt(arg, 10, 1, 65535, result);
|
opt->port = (uint16_t)parseInt(arg, 10, 1, 65535, result);
|
||||||
if (result != RESULT_OK) {
|
if (result != RESULT_OK) {
|
||||||
argp_error(state, "invalid port");
|
argp_error(state, "invalid port");
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
|||||||
+2
-1
@@ -23,6 +23,7 @@
|
|||||||
#include "result.h"
|
#include "result.h"
|
||||||
#include "data.h"
|
#include "data.h"
|
||||||
#include "message.h"
|
#include "message.h"
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
/** \file main.h */
|
/** \file main.h */
|
||||||
|
|
||||||
@@ -46,7 +47,7 @@ struct options
|
|||||||
bool generateSyn; //!< enable AUTO-SYN symbol generation
|
bool generateSyn; //!< enable AUTO-SYN symbol generation
|
||||||
|
|
||||||
bool foreground; //!< run in foreground
|
bool foreground; //!< run in foreground
|
||||||
int port; //!< port to listen for client connections [8888]
|
uint16_t port; //!< port to listen for client connections [8888]
|
||||||
bool localOnly; //!< listen on 127.0.0.1 interface only
|
bool localOnly; //!< listen on 127.0.0.1 interface only
|
||||||
|
|
||||||
const char* logFile; //!< log file name [/var/log/ebusd.log]
|
const char* logFile; //!< log file name [/var/log/ebusd.log]
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ void Connection::run()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Network::Network(const bool local, const int port, WQueue<NetMessage*>* netQueue)
|
Network::Network(const bool local, const uint16_t port, WQueue<NetMessage*>* netQueue)
|
||||||
: m_netQueue(netQueue), m_listening(false)
|
: m_netQueue(netQueue), m_listening(false)
|
||||||
{
|
{
|
||||||
if (local)
|
if (local)
|
||||||
|
|||||||
+1
-1
@@ -220,7 +220,7 @@ public:
|
|||||||
* @param port the tcp port to listening.
|
* @param port the tcp port to listening.
|
||||||
* @param netQueue the remote queue for network messages.
|
* @param netQueue the remote queue for network messages.
|
||||||
*/
|
*/
|
||||||
Network(const bool local, const int port, WQueue<NetMessage*>* netQueue);
|
Network(const bool local, const uint16_t port, WQueue<NetMessage*>* netQueue);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* destructor.
|
* destructor.
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ Device* Device::create(const char* name, const bool checkDevice,
|
|||||||
}
|
}
|
||||||
free(host);
|
free(host);
|
||||||
address.sin_family = AF_INET;
|
address.sin_family = AF_INET;
|
||||||
address.sin_port = htons(port);
|
address.sin_port = htons((uint16_t)port);
|
||||||
return new NetworkDevice(name, address, logRawFunc);
|
return new NetworkDevice(name, address, logRawFunc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ bool TCPSocket::isValid()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TCPSocket* TCPClient::connect(const string& server, const int& port)
|
TCPSocket* TCPClient::connect(const string& server, const uint16_t& port)
|
||||||
{
|
{
|
||||||
struct sockaddr_in address;
|
struct sockaddr_in address;
|
||||||
int ret;
|
int ret;
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
/** \file tcpsocket.h */
|
/** \file tcpsocket.h */
|
||||||
|
|
||||||
@@ -67,7 +68,7 @@ public:
|
|||||||
* returns the tcp port.
|
* returns the tcp port.
|
||||||
* @return the tcp port.
|
* @return the tcp port.
|
||||||
*/
|
*/
|
||||||
int getPort() const { return m_port; }
|
uint16_t getPort() const { return m_port; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns the ip address.
|
* returns the ip address.
|
||||||
@@ -92,7 +93,7 @@ private:
|
|||||||
int m_sfd;
|
int m_sfd;
|
||||||
|
|
||||||
/** port of tcp socket */
|
/** port of tcp socket */
|
||||||
int m_port;
|
uint16_t m_port;
|
||||||
|
|
||||||
/** ip address of tcp socket */
|
/** ip address of tcp socket */
|
||||||
string m_ip;
|
string m_ip;
|
||||||
@@ -119,7 +120,7 @@ public:
|
|||||||
* @param port the tcp port.
|
* @param port the tcp port.
|
||||||
* @return pointer to an opened tcp socket.
|
* @return pointer to an opened tcp socket.
|
||||||
*/
|
*/
|
||||||
TCPSocket* connect(const string& server, const int& port);
|
TCPSocket* connect(const string& server, const uint16_t& port);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -135,7 +136,7 @@ public:
|
|||||||
* @param port the tcp port.
|
* @param port the tcp port.
|
||||||
* @param address the ip address.
|
* @param address the ip address.
|
||||||
*/
|
*/
|
||||||
TCPServer(const int port, const string address)
|
TCPServer(const uint16_t port, const string address)
|
||||||
: m_lfd(0), m_port(port), m_address(address), m_listening(false) {}
|
: m_lfd(0), m_port(port), m_address(address), m_listening(false) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -166,7 +167,7 @@ private:
|
|||||||
int m_lfd;
|
int m_lfd;
|
||||||
|
|
||||||
/** listening tcp port */
|
/** listening tcp port */
|
||||||
int m_port;
|
uint16_t m_port;
|
||||||
|
|
||||||
/** listening tcp socket ip address */
|
/** listening tcp socket ip address */
|
||||||
string m_address;
|
string m_address;
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ using namespace std;
|
|||||||
struct options
|
struct options
|
||||||
{
|
{
|
||||||
const char* server; //!< ebusd server host (name or ip) [localhost]
|
const char* server; //!< ebusd server host (name or ip) [localhost]
|
||||||
unsigned int port; //!< ebusd server port [8888]
|
uint16_t port; //!< ebusd server port [8888]
|
||||||
|
|
||||||
char* const *args; //!< arguments to pass to ebusd
|
char* const *args; //!< arguments to pass to ebusd
|
||||||
unsigned int argCount; //!< number of arguments to pass to ebusd
|
unsigned int argCount; //!< number of arguments to pass to ebusd
|
||||||
@@ -90,6 +90,7 @@ error_t parse_opt(int key, char *arg, struct argp_state *state)
|
|||||||
{
|
{
|
||||||
struct options *opt = (struct options*)state->input;
|
struct options *opt = (struct options*)state->input;
|
||||||
char* strEnd = NULL;
|
char* strEnd = NULL;
|
||||||
|
unsigned int port;
|
||||||
switch (key) {
|
switch (key) {
|
||||||
// Device settings:
|
// Device settings:
|
||||||
case 's': // --server=localhost
|
case 's': // --server=localhost
|
||||||
@@ -100,11 +101,12 @@ error_t parse_opt(int key, char *arg, struct argp_state *state)
|
|||||||
opt->server = arg;
|
opt->server = arg;
|
||||||
break;
|
break;
|
||||||
case 'p': // --port=8888
|
case 'p': // --port=8888
|
||||||
opt->port = (unsigned int)strtoul(arg, &strEnd, 10);
|
port = strtoul(arg, &strEnd, 10);
|
||||||
if (strEnd == NULL || *strEnd != 0 || opt->port < 1 || opt->port > 65535) {
|
if (strEnd == NULL || *strEnd != 0 || port < 1 || port > 65535) {
|
||||||
argp_error(state, "invalid port");
|
argp_error(state, "invalid port");
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
opt->port = (uint16_t)port;
|
||||||
break;
|
break;
|
||||||
case ARGP_KEY_ARGS:
|
case ARGP_KEY_ARGS:
|
||||||
opt->args = state->argv + state->next;
|
opt->args = state->argv + state->next;
|
||||||
@@ -230,7 +232,7 @@ string fetchData(TCPSocket* socket, bool& listening)
|
|||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
void connect(const char* host, int port, char* const *args, int argCount)
|
void connect(const char* host, uint16_t port, char* const *args, int argCount)
|
||||||
{
|
{
|
||||||
|
|
||||||
TCPClient* client = new TCPClient();
|
TCPClient* client = new TCPClient();
|
||||||
|
|||||||
Reference in New Issue
Block a user