summaryrefslogtreecommitdiff
path: root/toxcore/net_crypto.c
AgeCommit message (Collapse)Author
2020-05-17Format comments according to tokstyle's requirements.iphydf
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-05-05refactor: Disallow multiple initialised declarators per decl.iphydf
We no longer allow: ```c int a = 0, b = 0; int a[3], b[3]; int a, *b; ``` But we do still allow (for now): ```c int a, b; ```
2020-05-04Add logging to TCP and onion client.iphydf
2020-04-19Invert `not_valid` functions and name them `is_valid`.iphydf
Also changed their return type to bool instead of 1/0 ints.
2020-03-22fix typo: now we periodically try to send direct packets when connected by tcpzugz (tox)
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-14use -1 rather than ~0 in unsigned integer typeszugz (tox)
Using ~0 involves a bitwise operation on int, so depends on the internal representation of signed integers.
2019-12-25don't wait for connection when killing Toxsudden6
When tox_kill is called no other thread should be running anymore so this locking is not needed there.
2019-12-23fix invalid use of mutexsudden6
- Moving a pthread_mutex in memory (e.g. via realloc()) is undefined behavior. - add a state for allocated but not yet used crypto connections - change crypto_connection_status signature
2019-01-03Fix indices calculation for congestion control.Evgeny Kurnevsky
2018-09-03Avoid use of global mutable state in mono_time on win32.iphydf
This uses a trick to get read-write access to `this` from a `const` member function, similar to C++ `mutable`, but uglier.
2018-08-27try ipv6 connections even after udp timeoutzugz (tox)
Also adds a test (auto_reconnect_test) which fails without this change.
2018-08-27Make `ip_is_lan` return bool instead of 0/-1.iphydf
This inverts the truthiness of the return value. Previously, 0 meant `true` and -1 meant `false`. Now, `true` (1) means `true` and `false` (0) means `false`.
2018-08-26Update copyright to 2018.iphydf
2018-08-19make Mono_Time an argument to current_time_monotoniczugz (tox)
2018-08-16Use per-instance `Mono_Time` for Messenger and onion.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-07-19Collect `PACKET_ID*` constants in `net_crypto.h`, cleanup their usesJan Malakhovski
2018-07-18replace LOGGER_ERROR with LOGGER_DEBUG on send_data_packet() failure in ↵zugz
send_lossless_packet()
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-08Use named function types for callbacks in net_crypto.iphydf
Also: * compound statements (blocks, e.g. in if/else) must be non-empty. Comments don't count. * `=` is not allowed in subexpressions. We treat it as statement-only. * `++i` is preferred over `i++` in statements. * `Type_Names` are camelsnake-case.
2018-07-08Rename `BS_LIST` to `BS_List` to follow the naming conventions.iphydf
`BS_LIST` would be a constant. `BS_List` is a type name.
2018-07-05Make tox.c unambiguously parseable.iphydf
Rules: 1. Constants are uppercase names: THE_CONSTANT. 2. SUE[1] types start with an uppercase letter and have at least one lowercase letter in it: The_Type, THE_Type. 3. Function types end in "_cb": tox_friend_connection_cb. 4. Variable and function names are all lowercase: the_function. This makes it easier for humans reading the code to determine what an identifier means. I'm not convinced by the enum type name change, but I don't know a better rule. Currently, a lot of enum types are spelled like constants, which is confusing. [1] struct/union/enum
2018-06-29Correct check for net_crypto packet index.Evgeny Kurnevsky
2018-06-28Various minor cleanups in `net_crypto`.iphydf
* Consistently use `num_packets_array` to get the packet count in the packet buffer. * Use `const` in more places. * Typo fix: begginning. * Rewrite `length < 1` for unsigned int to `length == 0`. * Limit scope of some loop variables by using for-init-decl. * Use early return in error paths to reduce indentation and for clarity. * Use `net_unpack_*` instead of manual `ntohs`. * Fix an uninitialised stack variable copy. * Fix a potential null pointer dereference. * Consistently use `get_crypto_connection`. It was inlined in some places. I de-inlined it now. * Add Loggers to some functions in preparation for adding log statements.
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-22Make the net_crypto connection state an enum.iphydf
It was a list of #defines, but clearly this is a discrete and limited set of named values, so an enum is more appropriate.
2018-06-17Minor cleanup: return early on error condition.iphydf
2018-05-29Fix enumeration of Crypto_Connection instancesPavel Karelin
2018-05-23Fix the often call of event tox_friend_connection_statusPavel Karelin
Fixes #868 Is made by: 1. Fix enumeration mechanism of Crypto_Connection instances in function send_crypto_packets() (this item solves the main problem); 2. Disruption of correlation between parameters of different dimensions (the parameters MAX_NUM_SENDPACKET_TRIES and UDP_DIRECT_TIMEOUT have different dimensions).
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-03add comment to func cryptpacket_receivedhqwrong
2018-02-24Fix a bunch of compiler warnings and remove suppressions.iphydf
2018-02-24Some minor cleanups suggested by cppcheck.iphydf
DETECTED=cppcheck
2018-02-14Get rid of the only GNU extension we used.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-16Make DHT a module-private type.iphydf
2018-01-16Make Net_Crypto a module-private type.iphydf
2018-01-16Use apidsl to generate LAN_discovery.h.iphydf
2018-01-14Add random_u16 function and rename the others to match.iphydf
2018-01-10Fix formatting in some C files.iphydf
Also replace &(x) with &x for consistency.
2017-08-24AF_INET -> TOX_AF_INETDiadlo
2017-06-06Fix non-portable zeroing out of doublesMaxim Biro
2017-06-05Document inverted mutex lock/unlock.iphydf
All other code in this file does lock/call/unlock, except this one instance, so we should explain why.
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-28Add VLA compatibility macro for C89-ish compilers.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".