Commit Graph

124 Commits

Author SHA1 Message Date
Maxim Biro c7f63737eb Revert "Implement tox_loop"
This reverts commit 5ff099763b.
2017-04-22 15:31:25 -04:00
Yuri f751fcfbf6 Added missing includes: <netinet/in.h> and <sys/socket.h>
Found these missing includes while compiling on FreeBSD 11.
2017-04-12 21:35:14 +00:00
Ansa89 5ff099763b Implement tox_loop 2017-04-01 17:47:34 +02:00
Diadlo f675474c08 Fix network malloc(0) bug 2017-03-26 12:40:52 +00:00
Diadlo c1e3358dcd Fix formatting with astyle
Fix #494
2017-03-04 15:32:00 +03: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
iphydf ce0bf232d1 Add appveyor build for native windows tests.
It doesn't compile, yet. A few changes (like VLA support) need to be made
before we can enable appveyor as a required PR check.
2017-01-22 11:56:02 +00:00
zugz b630121f2f reduce thread-unsafe use of static variables
- 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-21 22:08:52 +01: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
iphydf 5019a5aaf9 Change packet kind enum to use hex constants.
Hex constants make it clearer that you can only use 2 nibbles (the two
digits of the number, displayed as two columns in the source code), i.e.
1 byte, for the packet kind. It also makes the bit representation easier
to see.
2016-11-06 15:46:27 +00:00
Gregory Mullen (grayhatter) ee3121c3f6 Convert series of NET_PACKET_* defines into a typedef enum
fixup! TravisCI shorten IRC message
2016-11-05 15:12:04 -07:00
iphydf 54de13c1c7 Fix compilation for Windows.
- Mingw32 didn't read MSDN, so behaves badly despite lean and mean.
- Avoid alignment issues on windows with packed bitfields in the RTP header.
  This change makes the program ill-formed in C99, but I don't know the correct
  fix at the moment, and I don't want to keep the Windows build broken for too
  long.
2016-09-08 11:37:35 +01:00
iphydf 584debc7b6 Prevent <winsock.h> inclusion by <windows.h>. 2016-09-07 11:21:11 +01:00
iphydf 5b57ab6332 Improve C standard compliance.
- Don't cast between object and function pointers.
- Use standard compliant `__VA_ARGS__` in macros.
- Add explicit `__extension__` on unnamed union in struct (it's a GNU
  extension).
- Remove ; after function definitions.
- Replace `const T foo = 3;` for integral types `T` with `enum { foo = 3 };`.
  Folding integral constants like that as compile time constants is a GNU
  extension. Arrays allocated with `foo` as dimension are VLAs on strictly
  compliant C99 compilers.
- Replace empty initialiser list `{}` with zero-initialiser-list `{0}`.
  The former is a GNU extension meaning the latter.
- Cast `T*` (where `T != void`) to `void *` in format arguments. While any
  object pointer can be implicitly converted to and from `void *`, this
  conversion does not happen in variadic function calls.
- Replace arithmetic on `void *` with arithmetic on `char *`. The former
  is non-compliant.
- Replace non-`int`-derived types (like `uint16_t`, which is
  `short`-derived) in bit fields with `int`-derived types. Using any type
  other than `int` or `unsigned int` (or any of their aliases) in bit
  fields is a GNU extension.
2016-09-06 11:09:10 +01:00
iphydf 77db27331e Sort #includes in all source files. 2016-09-01 16:35:46 +01:00
iphydf 13ae9e9a93 Move logging to a callback.
This removes the global logger (which by the way was deleted when the first tox
was killed, so other toxes would then stop logging). Various bits of the code
now carry a logger or pass it around. It's a bit less transparent now, but now
there is no need to have a global logger, and clients can decide what to log and
where.
2016-08-27 01:16:14 +01:00
iphydf a5e35180c7 Make tox_callback_friend_name stateless.
See #27 and #40 for details.
2016-08-18 00:01:53 +01:00
Roman Yepishev 9035325e56 Remove magic numbers from addr_resolve
* Add #defines for INET/INET6 returns
* Remove magic number 3 - exact AF_INET/INET6 result found.
* Updated network_test.c
2016-02-27 11:45:02 -05:00
irungentoo d05e39274c Make tox_new return TOX_ERR_NEW_PORT_ALLOC for all socket related errors. 2015-04-13 08:32:33 -04:00
irungentoo 405558258d Enable SO_REUSEADDR on TCP server socket. 2015-04-11 20:24:39 -04:00
irungentoo 7afab000f7 tox_new now sets error to TOX_ERR_NEW_PORT_ALLOC when binding to port fails. 2015-03-12 13:03:14 -04:00
saneki 6e8762b30a Allow for specifying the port range to use in Tox_Options 2015-02-27 11:58:00 -06:00
irungentoo 93a998d15a Code cleanups.
Moved some functions to onion.c.

Fixed possible portability issues.
2015-01-01 21:30:42 -05:00
irungentoo 8ac13beea4 Code cleanup.
Added length checks to ipport_pack() function.
2014-12-31 15:24:09 -05:00
irungentoo 4c8737785a Removed now useless packet id. 2014-12-31 13:01:01 -05:00
Maxim Biro 377da127a1 Added HTTP proxy support 2014-12-13 23:59:50 -05:00
irungentoo 6bbb939855 Cleaned up packet length types in toxcore.
They are now all uint16_t instead of sometimes being uint32_t.

Replaced some other uint32_t with unsigned ints.
2014-11-21 20:18:29 -05:00
Maxim Biro 3d23982250 Fixed return value comment of new_networking function 2014-10-12 19:38:12 -04:00
irungentoo d5d84818fe More groupchats code written. 2014-09-25 21:05:17 -04:00
irungentoo ebdfa892b3 Removed now useless atributes from structs. 2014-09-25 16:49:05 -04:00
irungentoo d67624bf99 Removed groupchats from core. 2014-09-25 16:48:18 -04:00
irungentoo 9cb0c98a9c Reduce max udp packet size to 2K. 2014-09-17 21:01:08 -04:00
irungentoo dbab15cf0c Remove useless code. 2014-08-14 14:43:01 -04:00
irungentoo 8d15ccc347 Don't set connection to established if packet is kill packet.
Removed now useless defines in network.h
2014-07-21 12:58:28 -04:00
irungentoo 97ad1e62b6 Added addr_parse_ip() to network.h header.
Removed useless semicolons.
2014-07-20 20:08:00 -04:00
Marc Schütz 4940c4c62b Const correctness for various packet callbacks 2014-06-13 22:55:15 +02:00
irungentoo 07936960df Astyle and fixes. 2014-06-10 18:35:55 -04:00
Marc Schütz 8bdf487d19 Const correctness in toxcore/network.c 2014-06-10 18:54:16 +02:00
irungentoo f2101a7d86 Toxcore closer to building correctly with gcc -std=c99. 2014-06-07 22:56:52 -04:00
irungentoo 99572e944a IN6_ARE_ADDR_EQUAL was used only once, replaced it. 2014-06-07 19:47:00 -04:00
irungentoo 1bad0b5eea Fixed TOX_MAX_MESSAGE_LENGTH define.
Removed some useless code from toxcore.

Astyled core code with new version of astyle.
2014-06-01 18:55:52 -04:00
irungentoo f818c1a197 Added functions to send and receive lossy encrypted packets over
the Tox connection.

A/V should now work over TCP.
2014-05-21 15:28:14 -04:00
notsecure ede8455a5a function comments in header 2014-05-19 11:56:45 -04:00
notsecure cecefd290a mistakes
forgot to build before pushing
2014-05-19 11:34:40 -04:00
notsecure 0d711afbec IP_Port packing unpacking in onion.c 2014-05-19 09:18:04 -04:00
irungentoo 77d2ad373a Fixed IP_Port packed struct being 1 byte too big on windows. 2014-05-18 16:07:26 -04:00
irungentoo a5da6df144 Net_crypto can now handle packets sent as TCP OOB packets.
Added timestamp to know which DHT public key is good in case
onion_client and net_crypto report different ones.
2014-05-17 12:33:22 -04:00
irungentoo 4dc0af61c6 All time in core is now monotonic. 2014-05-03 11:58:45 -04:00