Commit Graph

81 Commits

Author SHA1 Message Date
Diadlo 66b8a7685e AF_INET -> TOX_AF_INET 2017-08-24 20:09:08 +03:00
iphydf 1e8fa85aad Add a monolith_test that includes all toxcore sources.
This requires that every symbol, even if static (file-scope), is unique.
The idea is that we can easily run "whole" program static analysis on
programs that include monolith.h ("whole" is in quotes, as we don't
include dependencies like libsodium in this static analysis).
2017-06-04 17:48:23 +00:00
Diadlo b19a9e5464 Add part of platform-independent network API implementation
socket      -> net_socket
htons       -> net_htons
htonl       -> net_htonl
connect     -> net_connect
sendto      -> net_sendto_ip4
getaddrinfo -> net_getipport
sa_family_t -> Family
2017-02-26 23:16:16 +03:00
iphydf 6ae33c16cf Add VLA compatibility macro for C89-ish compilers. 2017-01-28 20:49:12 +00:00
Diadlo f00006cf1d Add platform-independent Socket and IP implementation 2017-01-26 23:11:15 +03:00
Zoff 287a29b826 Add Android build to CI.
Fixes #340
Fixes #457
2017-01-24 11:47:16 +00:00
iphydf 8f96ca6d86 Update license headers and remove redundant file name comment.
"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-19 00:01:44 +00:00
David Zero 8ef1f35ca7 Revert "Revert "Portability fixes""
This reverts commit 59e2a844f0, and
defines _DARWIN_C_SOURCE in toxcore/network.c
2017-01-06 04:20:00 -08:00
endoffile78 59e2a844f0 Revert "Portability fixes"
This reverts commit f3469070fe.
2017-01-05 15:16:56 -06:00
David Zero f3469070fe Portability fixes
- CFLAG gnu99 was changed to c99.
- CXXFLAG c++98 was changed to c++11.
- CFLAG -pedantic-errors was added so that non-ISO C now throws errors.
- _XOPEN_SOURCE feature test macro added and set to 600 to expose SUSv3
  and c99 definitions in modules that required them.
- Fixed tests (and bootstrap daemon logging) that were failing due to
  the altered build flags.
- Avoid string suffix misinterpretation; explicit narrowing conversion.
- Misc. additions to .gitignore to make sure build artifacts don't wind
  up in version control.
2017-01-04 13:44:39 -08:00
iphydf ce29c8e7ec Wrap all sodium/nacl functions in crypto_core.c. 2016-12-22 10:26:59 +00:00
iphydf aed24408db Remove new_nonce function in favour of random_nonce.
`new_nonce` has been an alias for `random_nonce` for a while now. Having
two names for the same operation is confusing. `random_nonce` better
expresses the intent. The documentation for `new_nonce` talks about
guaranteeing that the nonce is different from previous ones, which is
incorrect, it's just quite likely to be different.
2016-11-09 22:30:49 +00:00
iphydf 96c672aef5 Compile as C++ for windows builds.
Compiling as C++ changes nothing semantically, but ensures that we don't
break C++ compatibility while also retaining C compatibility.

C++ compatibility is useful for tooling and additional diagnostics and
analyses.
2016-11-02 18:50:41 +00:00
iphydf 25697990d5 Use socklen_t instead of unsigned int in call to accept.
Not all platforms define `socklen_t` as `unsigned int`. E.g. Android
defines it as `int`.
2016-10-06 11:53:53 +01:00
iphydf 15cb426166 Make toxcore code C++ compatible.
It is still C code, so still compatible with C compilers as well. This
change lets us see more clearly where implicit conversions occur by
making them explicit.
2016-09-24 21:53:50 +01:00
iphydf 78d77349e4 Make TCP_Server opaque.
We should aim to make as many structures module-private as possible.
2016-09-22 11:22:32 +01:00
iphydf 1494e474dd Ensure that all TODOs have an owner.
In the future, all TODOs added either need a bug number (TODO(#NN)) or a
person's github user name. By default, I made irungentoo the owner of
all toxcore TODOs, mannol the owner of toxav TODOs, and myself the owner
of API TODOs.
2016-09-16 12:06:02 +01:00
iphydf 45d28904b9 Use <stdbool.h> and replace _Bool with bool.
This header is a requirement for the public API, therefore is assumed to
exist. It is a C99 standard library header, and _Bool is not intended to
be used directly, except in legacy code that defines bool (and
true/false) itself. We don't use or depend on such code. None of our
client code uses or depends on such code. There is no reason to not use
bool.
2016-09-13 22:01:45 +01:00
iphydf a8823830d3 Add some astyle options to make it do more.
It now enforces a bit more formatting. In particular, padding inside
parentheses is removed. I would like it to remove padding after unary
operators, but there seems to be no option for that.
2016-09-13 01:07:02 +01:00
iphydf 0aa2840164 Group #include directives in 3-4 groups.
1. Current module (if C file).
2. Headers from current library.
3. Headers from other library (e.g. toxcore includes in toxav).
4. System headers.
2016-09-13 00:32:02 +01:00
iphydf a9fbdaf46b Do not use else after return.
http://llvm.org/docs/CodingStandards.html#use-early-exits-and-continue-to-simplify-code
2016-09-02 11:02:56 +01:00
iphydf 633da98ae6 Add braces to all if statements. 2016-08-31 20:04:16 +01:00
Roman Proskuryakov 23b0c9cded fix: replace memset with sodium_memzero for sensitive data 2016-01-27 02:17:40 +03:00
Roman Proskuryakov ed3a794c9b fix: compare sensitive data with sodium_memcmp
fix: make increment_nonce & increment_nonce_number independent of user-controlled input
	fix: make crypto_core more stable agains null ptr dereference
2016-01-27 02:14:59 +03:00
irungentoo 50e0802a62 Removed useless parameter from new_TCP_server() 2015-06-28 22:14:54 -04:00
irungentoo 405558258d Enable SO_REUSEADDR on TCP server socket. 2015-04-11 20:24:39 -04:00
irungentoo a2df5f2f57 Increased max possible amount of TCP connections in TCP server when using epoll. 2015-04-01 13:31:28 -04:00
irungentoo 972e6a9ac5 Use edge trigger on listen socket in TCP_Server.
This may or may not improve things.
2015-02-23 14:46:38 -05:00
irungentoo 085f90432f When socket dies, kill it.
Use epoll to detect when socket closed connection.
2015-02-22 19:45:28 -05:00
irungentoo bca649fa67 Fixed possible TCP server bug.
Function returned success when should have returned failure.
2015-02-21 21:33:34 -05:00
irungentoo 55b4484305 kill_TCP_server() now frees everything in TCP server. 2015-02-07 14:19:55 -05:00
irungentoo 5e1d6f5183 Fix TCP server regression.
onion.c was parsing recieved packets a bit too strictly and discarding
packets that had ips with non valid families.

TCP uses a non valid family to send back the packet to the proper
connected node.
2015-01-13 15:04:41 -05:00
irungentoo c2e394c5c2 Fixed bug with auto tests and cleaned up the code a bit. 2014-12-26 20:12:51 -05:00
xor2003 0ce68b994e Initialise source.port to prevent garbage value 2014-10-17 16:15:22 +04:00
irungentoo 411457dc8f Fixed gcc warnings. 2014-08-28 20:54:05 -04:00
irungentoo bbfa9efff6 Merge branch 'lobiCode-myChan' 2014-08-26 20:21:25 -04:00
slaniCode f1ed0eeabb fix the memory leak in new_TCP_server function 2014-08-27 02:00:52 +02:00
irungentoo c3818ac91f Use epoll_create() instead of epoll_create1() for compatibility with
older kernels.
2014-07-22 12:02:24 -04:00
irungentoo bcfb1261ac Fixed possible bug with TCP nonce not getting incremented. 2014-07-16 20:39:58 -04:00
irungentoo 0486510edc Merge branch 'notsecure-split-video' 2014-07-15 20:00:02 -04:00
notsecure 96249e8b02 fixed some issues 2014-07-15 18:22:04 -04:00
notsecure 22d28ddf36 added priority packet system for TCP server 2014-07-15 17:40:21 -04:00
irungentoo ae7a11cae9 Fixed TCP bug.
Packet was being copied with a wrong, smaller length.
2014-07-15 13:39:32 -04:00
irungentoo 078d60ab92 Fixed bug with TCP.
Don't increment nonce if packet was discarded instead of being sent.
2014-07-15 12:35:57 -04:00
irungentoo 6d4fdb3597 Merge branch 'const_correctness' of https://github.com/schuetzm/ProjectTox-Core 2014-07-02 15:41:59 -04:00
Marc Schütz ece7e535f3 Const-correctness for TCP_server.c 2014-06-30 21:52:07 +02:00
Maxim Biro a32d270330 Reduced number of realloc calls bs_list does 2014-06-20 20:22:03 -04:00
Tux3 / Mlkj / !Lev.uXFMLA dee6c72d2c Fix redundant assignment in TCP_server.c 2014-06-20 13:52:23 +02:00
Marc Schütz 4940c4c62b Const correctness for various packet callbacks 2014-06-13 22:55:15 +02:00
irungentoo 7adefb6e6b Renamed list functions to fix conflict issue on certain machines. 2014-06-06 13:23:21 -04:00