Commit graph

15 commits

Author SHA1 Message Date
Jonathan Naylor
72654cf02a Fix missing Log.h handling in UDPSocket.cpp 2020-10-31 22:08:38 +00:00
Jonathan Naylor
a0d60b894d Add optional log file rotation and UDP socket reopening. 2020-10-31 21:35:09 +00:00
Jonathan Naylor
5eabb93078 Fix Windows execution. 2020-09-20 21:31:32 +01:00
SASANO Takayoshi
f2543de3da fix CUDPSocket(port) constructor bug
constructor CUDPSocket(port) cannot create properly, fixed
2020-09-06 16:32:33 +09:00
SASANO Takayoshi
def0edbaca UDPSocket renewal (2)
introduced YSFClients code

	match_addr(addr1, addr2) -> match(addr1, addr2, IMT_ADDRESS_ONLY)
	isnone() -> isNone()
	open(sockaddr_storage&) added (this refers address family only)
2020-09-06 15:48:22 +09:00
SASANO Takayoshi
457be810a3 UDPSocket renewal
Currently there is six variations of (IPv4) UDPSocket.cpp.

- FMClients, NXDNClients, P25Clients, YSFClients(YSFParrot)
	use ::fprintf() for logging

- YSFClients(YSFReflector)
	use LogError() and LogInfo() for logging
	special open(string &bindaddr) function

- YSFClients(YSFGateway), DAPNETGateway
	use LogError() and LogInfo() for logging

- P25Clients, DMRGateway
	use LogError() for logging
	no LogInfo("Opening UDP port on") message

- NXDNClients
	use LogError() for logging
	no LogInfo("Opening UDP port on") message
	add #include <ifaddrs.h>

- MMDVMHost
	use LogError() for logging
	no LogInfo("Opening UDP port on") message
	no assert(!address.empty()) at constructor

to avoid explosion, commonized them.

	switch ::fprintf()/LogError by #define HAVE_LOG_H
	always display LogInfo("Opening UDP port on") message
	delete #include <ifaddrs.h>, this is not needed
	no assert(!address.empty()) at constructor

and to support YSFReflector, add multiple socket support.
default is #define UDP_SOCKET_MAX 1 so normally this feature is disabled.

added these functions.

	CUDPSocket()	(constructor without any parameters)
	open(index, af, addr, port)
	close(index)

CUDPSocket() means CUDPSocket(address = "", port = 0)
index selects socket, address and port is defined at open.

to have compatibility for old codes, these function works as

	CUDPSocket(addr, port)	store addr and port to index #0
	CUDPSocket(port)	store addr = "" and port to index #0
	open()		open with addr and port of index #0, AF_UNSPEC
	open(af)	open with addr and port of index #0, specified af
	close()		close *all* sockets

read/write operation is for all opened sockets.
2020-09-06 12:09:37 +09:00
SASANO Takayoshi
6de0bdb536 add match_addr()
match() compares IP address and port
match_addr() compares IP address only
2020-07-03 04:35:22 +09:00
SASANO Takayoshi
88bbb0cd0f use getaddrinfo() AI_PASSIVE flag, to remove "::" and "0.0.0.0" 2020-04-06 18:35:12 +09:00
SASANO Takayoshi
dad47317e6 set INADDR_ANY/IN6ADDR_ANY_INIT address string to m_socket
when CUDPSocket::open() is called with m_address (in CUDPSocket) is nothing,
IPv4 socket is created by "0.0.0.0" (INADDR_ANY) address.

This causes a problem that DMRGateway cannot connect to reflector on IPv6.
To choose default INADDR_ANY/IN6ADDR_ANY_INIT address, added
open(address_family) in UDPSocket.cpp.

Following code sets address string at construction, not modified.
	NXDNNetwork.cpp
	POCSAGNetwork.cpp
	YSFNetwork.cpp

Other codes does not set, modified open() -> open(address_family)
	DMRNetwork.cpp
	DStarNetwork.cpp
	MMDVMHost.cpp
	MobileGPS.cpp
	P25Network.cpp
	RemoteCommand.cpp
	RemoteControl.cpp

I think there is more clever method, but I have no other idea.

Maybe IPv6 support for digital radio works, but RemoteControl can work
IPv4 only.
2020-04-06 18:35:12 +09:00
SASANO Takayoshi
5dccd5c5ce add match(), isnone() utility function
match() checks address family, IP address and port between
two sockaddr_storages.

isnone() checks sockaddr_storage has INADDR_NONE IPv4 address.
(sockaddr_storage has this address when lookup() failed)
2020-03-28 04:37:51 +09:00
SASANO Takayoshi
022d1a768b add IPv6 support (code from DAPNETGateway-IPv6) 2020-03-27 06:25:54 +09:00
Jonathan Naylor
134646265e Fix bugs in NXDN networking. 2018-02-13 19:07:30 +00:00
Jonathan Naylor
5c6e0ea4c1 Fix assert error. 2016-04-04 17:00:59 +01:00
Jonathan Naylor
8860b72e6c Changes based on debugging. 2016-01-25 22:36:16 +00:00
Jonathan Naylor
d34d85c04b Initial commit 2016-01-14 18:45:04 +00:00