summaryrefslogtreecommitdiff
path: root/toxcore/LAN_discovery.c
AgeCommit message (Collapse)Author
2018-10-16Support DragonFlyBSD and prune unused variables.Leonid Bobrov
2018-09-06Avoid recursion in `ip_is_lan` and `ip_is_local`.iphydf
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-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-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-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-02-24Fix a bunch of compiler warnings and remove suppressions.iphydf
2018-02-14Get rid of the only GNU extension we used.iphydf
2018-02-08Reject discovery packets coming from outside the LAN.iphydf
Even if that means rejecting packets from ourselves if our IP is not a "LAN" IP.
2018-02-08Fix LAN discovery on FreeBSD.iphydf
Also, add an auto-test for bootstrap and for LAN discovery. Bootstrap is never tested otherwise, and LAN discovery is a prerequisite for everything else. Having these two tests lets us rule out or identify LAN discovery as a possible cause for test failures.
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-16Use apidsl to generate LAN_discovery.h.iphydf
2018-01-14Filter out annoying log statements in unit tests.iphydf
These may be useful when debugging toxcore locally, but are not useful in unit tests.
2018-01-11Move Networking_Core struct into the .c file.iphydf
To make it an abstract type everywhere except in network.c.
2017-10-04Add log info message, when someone found client with LAN discoveryDiadlo
2017-08-24Add loopback and broadcast constantsDiadlo
2017-08-24AF_INET -> TOX_AF_INETDiadlo
2017-04-12Added missing includes: <netinet/in.h> and <sys/socket.h>Yuri
Found these missing includes while compiling on FreeBSD 11.
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-26Add platform-independent Socket and IP implementationDiadlo
2017-01-21reduce thread-unsafe use of static variableszugz
- 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-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".
2016-12-22Wrap all sodium/nacl functions in crypto_core.c.iphydf
2016-11-02Compile as C++ for windows builds.iphydf
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-09-24Make toxcore code C++ compatible.iphydf
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-16Ensure that all TODOs have an owner.iphydf
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-13Use <stdbool.h> and replace _Bool with bool.iphydf
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-13Group #include directives in 3-4 groups.iphydf
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-06Allocate sizeof(IP_ADAPTER_INFO) bytes instead of sizeof(T*).iphydf
https://msdn.microsoft.com/en-gb/library/windows/desktop/aa365917(v=vs.85).aspx shows an example use of GetAdaptersInfo that does it this way.
2016-09-02Do not use `else` after `return`.iphydf
http://llvm.org/docs/CodingStandards.html#use-early-exits-and-continue-to-simplify-code
2016-09-01Sort #includes in all source files.iphydf
2016-08-31Add braces to all if statements.iphydf
2016-08-18Make tox_callback_friend_name stateless.iphydf
See #27 and #40 for details.
2015-05-18If we get the ip/port of a relay on a local ip, assume that our friendirungentoo
is hosting a relay on his ip.
2015-04-27Move LAN discovery from Messenger to friend_connection.irungentoo
2015-01-22Zero broadcast ips are invalid.irungentoo
2014-11-21Cleaned up packet length types in toxcore.irungentoo
They are now all uint16_t instead of sometimes being uint32_t. Replaced some other uint32_t with unsigned ints.
2014-11-11Prevent connection ips from switching on LAN.irungentoo
2014-10-17Merge branch 'master' of https://github.com/xor2003/toxcoreirungentoo
2014-10-17forgotten to free memory in pAdapterInfoxor2003
2014-08-03remove unneeded printf's/prevent stdout spamJfreegman
2014-07-20LAN discovery should now work on windows machines with multipleirungentoo
ethernet devices. Added some code to get real adapter broadcast addresses on windows.
2014-06-13Const correctness for various packet callbacksMarc Schütz
2014-06-07Toxcore closer to building correctly with gcc -std=c99.irungentoo
2014-04-26Fixed minor issue.irungentoo
Socket used to find the broadcast ip was not closed when there was more than 16 broadcast interfaces.
2014-01-17Incorporated onion into Tox.irungentoo
Fixed a couple of issues related to that.
2013-12-05Shared address space for stacking NAT (CGN) is, just like 'regular' private ↵Coren[m]
address space, LAN.