summaryrefslogtreecommitdiff
path: root/toxcore/network.c
AgeCommit message (Collapse)Author
2019-01-12Implement all min/max functions for (un)signed int types.iphydf
Also, use them in the `onion_client` module.
2019-01-10Fix misaligned 4-byte access in trace logging.iphydf
This code is undefined behaviour as is, and breaks on various platforms requiring strict alignment (many microcontrollers).
2018-08-26Use `bool` in place of 0/1 int values.iphydf
2018-08-26Update copyright to 2018.iphydf
2018-08-16Reduce the number of times `unix_time_update` is called.iphydf
Reduced by, e.g.: * `file_transfer_test`: 33% of the `clock_gettime` calls. * `tox_many_test`: 53% of the `clock_gettime` calls. Other tests will see similar improvements. Real world applications will be closer to 40-50% improvement, since tox_many_test has 100 nodes, while file_transfer_test has 2 nodes.
2018-08-10Use the crypto random functions instead of `rand()`.iphydf
Presumably the uses of `rand()` were fine because they were not used in security-sensitive places, but having to think about whether a crappy RNG is acceptable in each situation requires effort that could better be spent elsewhere. Also, this means that once we have a custom deterministic RNG for testing, that RNG is used everywhere, so all the code is deterministic. It also allowed us to delete a system-specific function that wasn't used anywhere except in a call to `srand()`.
2018-07-19Link -lsocket and -lnsl for socket functions on Solaris.iphydf
Also, added some #defines to make symbols visible that are in BSD but not in UNIX. Solaris needs these, since it's fairly strict with its symbol visibility in system headers.
2018-07-16Set `_XOPEN_SOURCE` to 700 for FreeBSD.iphydf
2018-07-12Style fixes in TCP code; remove MIN and PAIR from util.h.iphydf
* Moved PAIR to toxav, where it's used (but really this should die). * Replace most MIN calls with typed `min_*` calls. Didn't replace the ones where the desired semantics are unclear. Moved the MIN macro to the one place where it's still used. * Avoid assignments in `while` loops. Instead, factored out the loop body into a separate `bool`-returning function. * Use named types for callbacks (`_cb` types). * Avoid assignments in `if` conditions. * Removed `MAKE_REALLOC` and expanded its two calls. We can't have templates in C, and this fake templating is ugly and hard to analyse and debug (it expands on a single line). * Moved epoll system include to the .c file, out of the .h file. * Avoid assignments in expressions (`a = b = c;`). * Avoid multiple declarators per struct member declaration. * Fix naming inconsistencies. * Replace `net_to_host` macro with function.
2018-07-09Factor out time keeping code into its own module: mono_time.c.iphydf
It turns out, `unix_time` is also monotonic, and is used as such, so I've renamed the new functions to `mono_time_*`. 2018-07-08: ``` 00:01 <@irungentoo> the idea used to be that the unix_time() function could go backward in time but I think I might have started using it like if it could not after I changed it so that it would never go back in time ```
2018-06-24Add new Circle CI configuration.iphydf
This one has ASAN enabled, unlike Travis.
2018-06-24Add Logger to various net_crypto functions.iphydf
In preparation for adding log statements. Also, fix an uninitialised variable warning in cppcheck.
2018-06-03Fix macOS macro because of GNU Machyangfl
2018-05-23Fix ipport_isset: port 0 is not a valid port.iphydf
2018-05-20Finish @Diadlo's network Family abstraction.iphydf
The Family stuff in toxcore is a big mess. I'm sure I saw a bunch of bugs on the way, but I'm not verifying that code now, so the bugs stay.
2018-05-20Move system header includes from network.h to network.ciphydf
2018-04-17Improve network error reporting on WindowsMaxim Biro
Windows doesn't report network errors though errno, it has its own facilities.
2018-03-16Remove the use of the 'hh' format specifier.iphydf
It's not supported in mingw. See https://github.com/TokTok/c-toxcore/issues/786.
2018-03-16Simplify sendpacket function, deduplicate some logic.iphydf
2018-02-25Fix warning on Mac OS X and FreeBSD.iphydf
This currently fails the nightly build.
2018-02-24Fix a bunch of compiler warnings and remove suppressions.iphydf
2018-02-24Minor cleanups: dead stores and avoiding complex macros.iphydf
2018-02-14Get rid of the only GNU extension we used.iphydf
2018-02-01Manually serialise RTPHeader struct instead of memcpy.iphydf
2018-01-30Use nullptr as NULL pointer constant instead of NULL or 0.iphydf
This changes only code, no string literals or comments.
2018-01-22Use <stdlib.h> for alloca on FreeBSD.iphydf
https://www.freebsd.org/cgi/man.cgi?alloca If stdlib.h does not define alloca, and we're using GCC (or Clang), we define the macro ourselves in terms of a GCC builtin.
2018-01-21Make the monolith test a C++ binary.iphydf
This way, developers compile toxcore, toxav, and toxencryptsave as C++ at least once at home, reducing the likelyhood of running into travis failures where we compile as C++ in the windows build.
2018-01-11Move Networking_Core struct into the .c file.iphydf
To make it an abstract type everywhere except in network.c.
2018-01-10Call freeaddrinfo on error paths in net_getipport.iphydf
Without these, we'll have a memory leak on error paths.
2017-12-29Remove deprecated ToxDNSiphydf
Based on #331. Fixes #42.
2017-11-15Fix IPv4 and IPv6 loopbacksDiadlo
2017-08-27Remove 'in_addr' and 'addrinfo' mention from network.hDiadlo
2017-08-24Add loopback and broadcast constantsDiadlo
2017-08-24Add platform independent constantsDiadlo
2017-08-24AF_INET -> TOX_AF_INETDiadlo
2017-04-22Revert "Implement tox_loop"Maxim Biro
This reverts commit 5ff099763b1f56414572e1c12eb2f003117db5a0.
2017-04-22Revert "Fix TokTok/c-toxcore#535"Maxim Biro
This reverts commit 439f676d45d75f59f47a000a6adca8e9fe6a6e4e.
2017-04-16Fix TokTok/c-toxcore#535Ansa89
2017-04-13Add TCP_INET family to ip comparatorDiadlo
2017-04-12Added missing includes: <netinet/in.h> and <sys/socket.h>Yuri
Found these missing includes while compiling on FreeBSD 11.
2017-04-01Implement tox_loopAnsa89
2017-03-26Fix network malloc(0) bugDiadlo
2017-03-04Fix formatting with astyleDiadlo
Fix #494
2017-03-04Move 'family' copying after all address checksDiadlo
Fix #495
2017-02-26Add part of platform-independent network API implementationDiadlo
socket -> net_socket htons -> net_htons htonl -> net_htonl connect -> net_connect sendto -> net_sendto_ip4 getaddrinfo -> net_getipport sa_family_t -> Family
2017-01-26Add platform-independent Socket and IP implementationDiadlo
2017-01-21reduce thread-unsafe use of static variableszugz
- rework ip_ntoa() to avoid use of static variables - rework sort_client_list() to avoid use of static variables - move static 'lastdump' into Messenger struct - rework ID2String() to avoid use of static variables; rename to id_to_string() - fetch_broadcast_info(): attempt to mitigate risks from concurrent execution - current_time_monotonic(): attempt to mitigate risks from concurrent execution - comment on non-thread-safety of unix_time_update
2017-01-19Update license headers and remove redundant file name comment.iphydf
"All rights reserved" was incorrect. The project was licensed under GPL3, which means a lot of rights are licensed to everybody in the world, i.e. not reserved to the "Tox Project".
2017-01-11Remove `TOX_DEBUG` and have asserts always enabled.iphydf
These are cheap asserts. I've also replaced the fprintf's with `LOGGER_ERROR` calls.
2017-01-06Revert "Revert "Portability fixes""David Zero
This reverts commit 59e2a844f04a8725e8079f854158aa86ef5988b2, and defines _DARWIN_C_SOURCE in toxcore/network.c