Commit graph

258 commits

Author SHA1 Message Date
Stephen Seo a11c99e115 Remove unused TSQueue and RingBuffer 2019-11-06 14:42:35 +09:00
Stephen Seo 7c889eee6a Fixes and improvements (add use of TSLQueue)
Replace "unsigned long long" in TSLQueue with "unsigned long" to keep
compatibility with C.

Add top_and_pop_and_rsize() to TSLQueue.

Fix log levels in UDPC.

Replace TSQueue with TSLQueue in UDPC_Context.
Also fix NetworkTest with TSLQueue related changes.
2019-11-06 14:39:09 +09:00
Stephen Seo 742db465dd Minor fix to size pointer in TSLQueue iterator
Prevent pointer change errors by making the pointer itself const.
2019-11-06 13:34:55 +09:00
Stephen Seo a5873624aa Fix size count in TSLQueue when using iterator 2019-11-06 13:32:39 +09:00
Stephen Seo 3f338be365 Add more tests to UnitTest for TSLQueue 2019-11-06 12:54:03 +09:00
Stephen Seo 3830be6e2d Add iterator to TSLQueue
Removed shared_ptr "locks", replaced by iterator owning a lock_guard.
2019-11-03 18:46:25 +09:00
Stephen Seo 10899ffaab Replace std::list with own doubly-linked-list
TODO iterator
2019-10-29 20:33:16 +09:00
Stephen Seo 3dc12683e8 Add remove() to TSLQueue's iterator wrapper
Minor additions to UnitTest.
2019-10-28 11:09:48 +09:00
Stephen Seo 78862dc29d Add WIP UnitTests for TSLQueue 2019-10-24 20:25:41 +09:00
Stephen Seo aa132fbf12 Add prefix inc/dec to TSLQIterWrapper 2019-10-24 17:58:13 +09:00
Stephen Seo ebedd06fdb Add missing impl fn to TSLQueue 2019-10-24 17:51:40 +09:00
Stephen Seo 04d8abab84 Add impl of TSLQueue (TODO UnitTests) 2019-10-24 17:49:28 +09:00
Stephen Seo 0402442929 Begin work on TSLQueue 2019-10-22 20:24:23 +09:00
Stephen Seo 0f435613bc Refactor logging
Removed redundant checking of logging type in log_impl* .
2019-10-22 19:27:55 +09:00
Stephen Seo b11d87ca12 Rework sendPkts (sending queue)
Changed sendPkts in ConnectionData to std::deque, added a TSQueue
cSendPkts to Context. Queued packets will be moved to corresponding
ConnectionData instances during update, dropping with a warning those
where a connection does not exist.

Minor other fixes.

Some additions to TSQueue.
2019-09-27 20:19:48 +09:00
Stephen Seo 98e88237ce Implement header verification via libsodium
The original 20 byte header is now verified with public-key-crypto using
libsodium.

Also some fixes where ntohs/htons was not used where it should be.
2019-09-23 20:11:12 +09:00
Stephen Seo 328d44fbb6 Add support for MINGW compiler 2019-09-21 12:15:49 +09:00
Stephen Seo aa7255c2e5 Fixes and improvements
Fix use of accept-connections flag.
Fix use of TSQueue (add top_and_pop_and_rsize fn).
Reduce sleep time of threadedUpdate to 8 ms.
2019-09-20 16:59:16 +09:00
Stephen Seo 27528bfbc5 Use macro to conditionally log
This should skip evaluating log parameters if the log level is not met.
2019-09-20 14:26:59 +09:00
Stephen Seo 5a3c7cd9a0 Many fixes, including sending packets with payload
Implemented UDPC_get_received
Added UDPC_get_list_connected and UDPC_free_list_connected.
2019-09-20 14:02:41 +09:00
Stephen Seo f6ba9e21b6 Fix parsing of ipv6 link-local address
Add support for numeric id in suffix of ipv6 link-local address.
2019-09-19 14:30:10 +09:00
Stephen Seo 71f7bc4977 Fix Windows support 2019-09-19 12:23:15 +09:00
Stephen Seo 0e22357d55 Rename enum types to avoid name conflict 2019-09-19 10:58:19 +09:00
Stephen Seo 8661af9529 Attempt to make code platform agnostic
Getting scope_id from device name from ipv6 link-local address was
previously using only a unix supported api. Added (untested) code to do
the same for windows machines.
2019-09-19 10:35:22 +09:00
Stephen Seo 5eb0feb22b Fix atostr 2019-09-18 18:39:35 +09:00
Stephen Seo 355f3b2bd0 Add support for link-local ipv6 addr 2019-09-18 17:35:14 +09:00
Stephen Seo 31c40d4739 Fix NetworkTest
Allow setting listen addr to "any".
2019-09-18 13:56:04 +09:00
Stephen Seo fefbfc8d70 Fix setting trigger-send flag
Fix trigger-send flag related bug where send time of packets were
inconsistent.
Also fix UDPC_client_initiate_connection not immediately sending connection
packet.
2019-09-18 11:42:16 +09:00
Stephen Seo 2bc6eeffe9 Impl NetworkTest, fixes and refactoring
Basic connections can now be tested with NetworkTest.
Also includes fixes to UDPC that now create a working connection.

TODO Fix client sending at good rate even in bad rate mode.
2019-09-17 20:33:47 +09:00
Stephen Seo a642db53f0 Add support for UDPC_strtoa to accept ipv4 input
UDPC_strtoa can now return an ipv4-mapped ipv6 address given an ipv4
string. Also, added validation of input strings via regex.
2019-09-17 17:17:16 +09:00
Stephen Seo 17d05b4a19 Use mutex for thread safety 2019-09-16 12:00:25 +09:00
Stephen Seo d159bd84b7 Add command parsing for NetworkTest 2019-09-16 11:52:03 +09:00
Stephen Seo e320a6343e Impl threaded init/update 2019-09-16 11:40:43 +09:00
Stephen Seo 255930db9a Replace ipv4 with ipv6
ipv6 also supports sending to ipv4.
2019-09-07 16:36:11 +09:00
Stephen Seo 38eb06f105 Make atostr more thread safe
atostr now can hold 64 different results, and can be called from
multiple threads. Thus, a returned string buffer is valid until atostr
is called 64 more times.
2019-09-03 16:19:47 +09:00
Stephen Seo 05cb45ca14 Prevent exceptions being thrown in TSQueue
TSQueue's top() and top_and_pop() now return std::optional<T> instead of
just T.
2019-09-03 15:15:09 +09:00
Stephen Seo 150deb7e5c Expose ConnectionId to C interface, fixes
Removed UDPC:ConnectionIdentifier from UDPC_Defines.hpp and added
ConnectionId to UDPConnection.h, and replaced/fixed instances of the
older type.
2019-09-03 12:06:46 +09:00
Stephen Seo 0167c4953b Add top_and_pop fn to TSQueue 2019-08-30 15:55:43 +09:00
Stephen Seo ee85ced0e0 Minor fixes 2019-08-30 14:57:24 +09:00
Stephen Seo ba5d9178dc Simpifly opaque struct handle to context 2019-08-30 12:11:07 +09:00
Stephen Seo e8c07680a6 Remove already resolved TODO comment 2019-08-30 12:04:39 +09:00
Stephen Seo fe41bbb764 Use opaque struct as handle in C interface, fix
Fixed log_impl_next.
2019-08-30 12:03:26 +09:00
Stephen Seo 3a754e97b5 Impl logging, minor fixes/refactorings 2019-08-29 12:56:09 +09:00
Stephen Seo 6aa2e8aa51 Minor formatting fix 2019-08-29 11:20:36 +09:00
Stephen Seo d027b1703a Add client_initiate_connection fn, some fixes 2019-08-29 11:07:24 +09:00
Stephen Seo f10521ec52 Impl drop all connections with specific addr
Fix UDPC_drop_connection that didn't fully cleanup connection data.

Added UDPC_drop_connection_addr fn that drops all connections with a
specific addr.
2019-08-28 16:38:14 +09:00
Stephen Seo 8dba751929 Some fixes
Fix id of sent packet stored in network byte order instead of native
order.

Fix failing to send packet not stopping storing sent packet data.
2019-08-28 15:54:18 +09:00
Stephen Seo 35bc629b1b Add some Unit Tests for UDPC 2019-08-27 18:03:30 +09:00
Stephen Seo 8883d84b9b Minor fix 2019-08-27 17:53:18 +09:00
Stephen Seo 1382cc6b7c Store connections based on both addr and port
Previous implementation only stored based on addr only, preventing
connections from/to the same address but different ports.
2019-08-27 17:00:29 +09:00