summaryrefslogtreecommitdiff
path: root/toxcore/network.c
AgeCommit message (Collapse)Author
2020-05-05refactor: Remove multi-declarators entirely.iphydf
We no longer allow `int a, b;`. In the few cases where we used it, we instead better * limit the scope of the identifier (e.g. in a for-init-decl) * split the line and have 2 separate declarators, because the identifiers designate different types of things (e.g. friend numbers and group numbers).
2020-04-13Fix things not being initialized if creating a TCP-only networkRobin Linden
2020-04-07Remove newlines from the end of LOGGER format strings.iphydf
See https://github.com/TokTok/hs-tokstyle/pull/49 for the corresponding tokstyle analysis.
2020-03-22Minor cleanups in network code.iphydf
Remove useless parameter, replace with assert (just to be sure). Also replaced some memsets with 0-initialiser and memcpy with assignment.
2020-03-18Check that LOGGER macros are only called with string literals.iphydf
Avoid any dynamic format strings, even ones like `cond ? "str1" : "str2"`.
2020-03-14Avoid casting back and forth between void-ptr.iphydf
In windows network code, we implement inet_pton and inet_ntop, which take void pointers. We can do slightly better because we already know the type when we call these functions, so we can avoid casting between void pointer and the addr struct types.
2020-03-14Fix up comments a bit to start being more uniform.iphydf
Tokstyle (check-cimple) will start enforcing comment formats at some point. It will not support arbitrary stuff in comments, and will parse them. The result can then be semantically analysed.
2020-03-14Use spdx license identifier instead of GPL blurb.iphydf
2020-03-06Use `net_pack` instead of casting bytes to ints.iphydf
The current code violates the C standard and causes crashes on strict alignment architectures.
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