mirror of
https://github.com/g4klx/MMDVMHost
synced 2025-12-21 06:55:52 +08:00
Merge branch 'SimpleDMR' into AX25_FM
This commit is contained in:
@@ -72,7 +72,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#else
|
#else
|
||||||
#include <winsock.h>
|
#include <ws2tcpip.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define BUFFER_MAX_LEN 128
|
#define BUFFER_MAX_LEN 128
|
||||||
|
|||||||
@@ -173,10 +173,12 @@ m_lockFileName(),
|
|||||||
m_remoteControl(NULL),
|
m_remoteControl(NULL),
|
||||||
m_fixedMode(false)
|
m_fixedMode(false)
|
||||||
{
|
{
|
||||||
|
CUDPSocket::startup();
|
||||||
}
|
}
|
||||||
|
|
||||||
CMMDVMHost::~CMMDVMHost()
|
CMMDVMHost::~CMMDVMHost()
|
||||||
{
|
{
|
||||||
|
CUDPSocket::shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
int CMMDVMHost::run()
|
int CMMDVMHost::run()
|
||||||
|
|||||||
@@ -51,12 +51,16 @@ int main(int argc, char** argv)
|
|||||||
CRemoteCommand::CRemoteCommand(unsigned int port) :
|
CRemoteCommand::CRemoteCommand(unsigned int port) :
|
||||||
m_port(port)
|
m_port(port)
|
||||||
{
|
{
|
||||||
|
CUDPSocket::startup();
|
||||||
|
|
||||||
::LogInitialise(false, ".", "RemoteCommand", 2U, 2U);
|
::LogInitialise(false, ".", "RemoteCommand", 2U, 2U);
|
||||||
}
|
}
|
||||||
|
|
||||||
CRemoteCommand::~CRemoteCommand()
|
CRemoteCommand::~CRemoteCommand()
|
||||||
{
|
{
|
||||||
::LogFinalise();
|
::LogFinalise();
|
||||||
|
|
||||||
|
CUDPSocket::shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
int CRemoteCommand::send(const std::string& command)
|
int CRemoteCommand::send(const std::string& command)
|
||||||
|
|||||||
@@ -37,12 +37,6 @@ m_address_save(address),
|
|||||||
m_port_save(port),
|
m_port_save(port),
|
||||||
m_counter(0U)
|
m_counter(0U)
|
||||||
{
|
{
|
||||||
#if defined(_WIN32) || defined(_WIN64)
|
|
||||||
WSAData data;
|
|
||||||
int wsaRet = ::WSAStartup(MAKEWORD(2, 2), &data);
|
|
||||||
if (wsaRet != 0)
|
|
||||||
LogError("Error from WSAStartup");
|
|
||||||
#endif
|
|
||||||
for (int i = 0; i < UDP_SOCKET_MAX; i++) {
|
for (int i = 0; i < UDP_SOCKET_MAX; i++) {
|
||||||
m_address[i] = "";
|
m_address[i] = "";
|
||||||
m_port[i] = 0U;
|
m_port[i] = 0U;
|
||||||
@@ -56,12 +50,6 @@ m_address_save(),
|
|||||||
m_port_save(port),
|
m_port_save(port),
|
||||||
m_counter(0U)
|
m_counter(0U)
|
||||||
{
|
{
|
||||||
#if defined(_WIN32) || defined(_WIN64)
|
|
||||||
WSAData data;
|
|
||||||
int wsaRet = ::WSAStartup(MAKEWORD(2, 2), &data);
|
|
||||||
if (wsaRet != 0)
|
|
||||||
LogError("Error from WSAStartup");
|
|
||||||
#endif
|
|
||||||
for (int i = 0; i < UDP_SOCKET_MAX; i++) {
|
for (int i = 0; i < UDP_SOCKET_MAX; i++) {
|
||||||
m_address[i] = "";
|
m_address[i] = "";
|
||||||
m_port[i] = 0U;
|
m_port[i] = 0U;
|
||||||
@@ -72,6 +60,20 @@ m_counter(0U)
|
|||||||
|
|
||||||
CUDPSocket::~CUDPSocket()
|
CUDPSocket::~CUDPSocket()
|
||||||
{
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void CUDPSocket::startup()
|
||||||
|
{
|
||||||
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
|
WSAData data;
|
||||||
|
int wsaRet = ::WSAStartup(MAKEWORD(2, 2), &data);
|
||||||
|
if (wsaRet != 0)
|
||||||
|
LogError("Error from WSAStartup");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void CUDPSocket::shutdown()
|
||||||
|
{
|
||||||
#if defined(_WIN32) || defined(_WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
::WSACleanup();
|
::WSACleanup();
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -32,7 +32,6 @@
|
|||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#else
|
#else
|
||||||
#include <winsock2.h>
|
|
||||||
#include <ws2tcpip.h>
|
#include <ws2tcpip.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -61,8 +60,12 @@ public:
|
|||||||
void close();
|
void close();
|
||||||
void close(const unsigned int index);
|
void close(const unsigned int index);
|
||||||
|
|
||||||
|
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);
|
||||||
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 int 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);
|
static bool match(const sockaddr_storage& addr1, const sockaddr_storage& addr2, IPMATCHTYPE type = IMT_ADDRESS_AND_PORT);
|
||||||
|
|
||||||
static bool isNone(const sockaddr_storage& addr);
|
static bool isNone(const sockaddr_storage& addr);
|
||||||
|
|||||||
Reference in New Issue
Block a user