summaryrefslogtreecommitdiff
path: root/toxcore/util.h
AgeCommit message (Collapse)Author
2020-03-14Use spdx license identifier instead of GPL blurb.iphydf
2020-03-05Use net_pack/unpack instead of host_to_net.iphydf
The latter is doing pretty much the same thing but in a confusing way (it doesn't change the type of the variable, but does change the semantics).
2019-01-12Implement all min/max functions for (un)signed int types.iphydf
Also, use them in the `onion_client` module.
2018-09-14Standardise header guards.iphydf
Using the full path including the repo name.
2018-08-26Update copyright to 2018.iphydf
2018-08-12Remove last use of the `MIN` macro.iphydf
We use functions for this instead.
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-07-09Add a thread-safe version of unix_time and friends.iphydf
These are not used in a thread-safe way, but it opens the path towards per-tox-instance time keeping and removal of some unsafe global state.
2018-07-09Move `load_state` and its helper functions to their own module.iphydf
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-02-17Make outgoing Filetransfers round-robin.zoff99
Instead of 1 FT blocking all others.
2018-02-08Add some unit tests for util.h.iphydf
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.
2016-09-30Remove return after no-return situation (and other cleanups).iphydf
Cleanups: - Fix header guards to not use reserved names. - Avoid name shadowing. - Removed an unused variable found by avoiding name shadowing.
2016-09-24Move ring buffer out of toxcore/util into toxav.iphydf
Toxcore itself doesn't use this data structure. Only toxav does, so now toxav owns the code for it.
2016-09-19Revert "Make ToxAV stateless"iphydf
This reverts commit 21f8db12c45bd56293262cd4abfb73cd9abec821. It is currently broken. Incoming call callbacks are not invoked, and instead the client goes offline immediately.
2016-09-17Make ToxAV statelessGregory Mullen (grayhatter)
2016-09-06Improve static and const correctness.iphydf
- Any non-externally-visible declarations should be `static`. - Casting away the `const` qualifier from pointers-to-const is dangerous. All but one instance of this are now correct. The one instance where we can't keep `const` is one where toxav code actually writes to a chunk of memory marked as `const`. This code also assumes 4 byte alignment of data packets. I don't know whether that is a valid assumption, but it's likely unportable, and *not* obviously correct. - Replaced empty parameter lists with `(void)` to avoid passing parameters to it. Empty parameter lists are old style declarations for unknown number and type of arguments. - Commented out (as `#if DHT_HARDENING` block) the hardening code that was never executed. - Minor style fix: don't use `default` in enum-switches unless the number of enumerators in the default case is very large. In this case, it was 2, so we want to list them both explicitly to be warned about missing one if we add one in the future. - Removed the only two function declarations from nTox.h and put them into nTox.c. They are not used outside and nTox is not a library.
2016-09-01Sort #includes in all source files.iphydf
2015-11-03Astyle.irungentoo
2015-10-10New Adaptive BR algorithm, cleanups and fixesEniz Vukovic
2015-08-09Updated with upstreammannol
2015-08-02Save fixes.irungentoo
2015-04-13Started custom RTCPmannol
2015-01-24Current progressmannol
2014-11-29Merge branch 'mutex-1' of https://github.com/mannol/toxcoreirungentoo
2014-11-29More av cleanupmannol
2014-11-18av refactormannol
2014-10-24Portability saving fixes for big endian systems.irungentoo_trip
Saves should now be portable from big endian to little endian systems though I need someone to actually test it to be sure I didn't mess up.
2014-09-30Rework toxav/rtp.c to use ntohl/htonl and ntohs/htonssin
Now we can also remove the helper routines from toxcore/util.[ch].
2014-06-10Const correctness in various interdependent filesMarc Schütz
2014-06-10Const correctness for toxcore/util.cMarc Schütz
2014-05-31Fixed byte order and removed log functions from misc_toolsmannol
2014-04-27Yeah many callsmannol
2014-01-19Added no_replay and added some things to the docs.irungentoo
2013-12-15Code cleanups.irungentoo
No functionality changed.
2013-10-28Merge branch 'master' into hardenirungentoo
Also removed some old, useless loading code.
2013-10-24Merge remote-tracking branch 'upstream/master' into ↵Coren[m]
cleanup_unix_time_id_eq_cpy_is_timeout Conflicts: toxcore/net_crypto.c
2013-10-24Astyled some files.irungentoo
2013-10-24Move unix_time(), id_cpy()/id_eq(), is_timeout() to util.*Coren[m]
unix_time(): - returns local value for current epoch - value is updated explicitly with unix_time_update() called at new_DHT()/doMessenger()/do_DHT() is_timeout(): - uses the local value for current epoch id_cpy()/id_eq() => id_copy()/id_equal(): - centralized duplicate definitions - replaced (most) memcpy()/memcmp() of (*, *, CLIENT_ID_SIZE) with id_copy()/id_equal()
2013-10-23Code cleanups.irungentoo
2013-09-27expanded Client_data to hold two addresses (IPv4, IPv6) instead of oneCoren[m]
Compilerflag: CLIENT_ONETOONE_IP (to define in DHT.h, default unset i.e. NEW case: two addresses) Every function in DHT{_test}.c working on Client_data has been rewritten to store IPv4 addresses in assoc4, IPv6 addresses in assoc6. Loading/Storing of states defined with other compiler switch is transparently adjusting to the differences. DHT.h, DHT.c: - introduction and handling of the structure changes DHT_test.c, Messenger.c: - logging adapted to new structures util.h: - LOGGING isn't undefined per default anymore
2013-09-17astyled everything.irungentoo
2013-09-16Merge remote-tracking branch 'upstream/master' into MessengerLoadSaveCoren[m]
Conflicts: toxcore/Messenger.c toxcore/util.c toxcore/util.h
2013-09-14Change sublength to 32 bits. Someone might have more than (sizeof(Friends) / ↵Coren[m]
65536) friends...
2013-09-13State loading/saving: Instead of a blob, segment into sections marked with tags.Coren[m]
Primary rationale: The part that DHT saves changes if IP is expanded to IPv6. To let people keep their friends/name, change the datafile format now, while everybody is still on the same page. Loading/Saving rewritten to allow a part of the file to be incomprehensible to the loading routine. Added a magic cookie at the beginning to mark the file as tox's. Changes in some part of the datafile can be skipped and the remaining parts still be consumed. Allows a wide margin of forward compatibility (like the IP to IPv6 transition, but also e.g. a change in the key format). As long as the file is not completely garbled, the routine will read as much as possible. Only the KEY section is considered mandatory: a malformed key section leads to a negative result. util.*: - holds the driving function which jumps from section to section and calls back with section length and tag (type) Messenger.c,DHT.*: - new loading functions call the util-function with a callback, which subsequently consumes the sections - old routines are kept to fall back onto if the magic cookie at the beginning isn't present - saving is still done in one local routine
2013-09-11toxcore/util.h:Coren[m]
- moved cmdline_parsefor_ipv46() to testing/misc_tools.c
2013-09-11cmdline parsing of --ipv4/6 plucked into utilCoren[m]