Showing preview only (1,860K chars total). Download the full file or copy to clipboard to get everything.
Repository: irungentoo/toxcore
Branch: master
Commit: bf69b54f6400
Files: 178
Total size: 1.7 MB
Directory structure:
gitextract_ltqu1_1u/
├── .gitignore
├── .travis.yml
├── COPYING
├── DONATORS
├── INSTALL.md
├── Makefile.am
├── README.md
├── auto_tests/
│ ├── Makefile.inc
│ ├── TCP_test.c
│ ├── assoc_test.c
│ ├── crypto_test.c
│ ├── dht_test.c
│ ├── encryptsave_test.c
│ ├── friends_test.c
│ ├── helpers.h
│ ├── messenger_test.c
│ ├── network_test.c
│ ├── onion_test.c
│ ├── skeleton_test.c
│ ├── tox_test.c
│ ├── toxav_basic_test.c
│ └── toxav_many_test.c
├── autogen.sh
├── configure.ac
├── dist-build/
│ ├── android-arm.sh
│ ├── android-armv7.sh
│ ├── android-build.sh
│ ├── android-mips.sh
│ └── android-x86.sh
├── docs/
│ ├── Group-Chats.md
│ ├── Hardening.txt
│ ├── Hardening_docs.txt
│ ├── Prevent_Tracking.txt
│ ├── TCP_Network.txt
│ ├── TODO.md
│ ├── Tox_middle_level_network_protocol.txt
│ ├── av_api.md
│ └── updates/
│ ├── Crypto.md
│ ├── DHT.md
│ ├── Spam-Prevention.md
│ └── Symmetric-NAT-Transversal.md
├── libtoxav.pc.in
├── libtoxcore.pc.in
├── m4/
│ └── pkg.m4
├── other/
│ ├── DHT_bootstrap.c
│ ├── DHTnodes
│ ├── Makefile.inc
│ ├── apidsl/
│ │ ├── README.md
│ │ ├── tox.in.h
│ │ └── toxav.in.h
│ ├── astyle/
│ │ ├── README.md
│ │ ├── astylerc
│ │ └── pre-commit
│ ├── bootstrap_daemon/
│ │ ├── README.md
│ │ ├── docker/
│ │ │ ├── Dockerfile
│ │ │ └── get-nodes.py
│ │ ├── src/
│ │ │ ├── Makefile.inc
│ │ │ ├── command_line_arguments.c
│ │ │ ├── command_line_arguments.h
│ │ │ ├── config.c
│ │ │ ├── config_defaults.h
│ │ │ ├── global.h
│ │ │ ├── log.c
│ │ │ ├── log.h
│ │ │ └── tox-bootstrapd.c
│ │ ├── tox-bootstrapd.conf
│ │ ├── tox-bootstrapd.service
│ │ └── tox-bootstrapd.sh
│ ├── bootstrap_node_packets.c
│ ├── bootstrap_node_packets.h
│ ├── fun/
│ │ ├── bootstrap_node_info.py
│ │ ├── cracker.c
│ │ ├── make-funny-savefile.py
│ │ ├── sign.c
│ │ └── strkey.c
│ └── osx_build_script_toxcore.sh
├── super_donators/
│ ├── LittleVulpix
│ ├── grencez_tok5.c
│ └── sir@cmpwn.com
├── testing/
│ ├── DHT_test.c
│ ├── Makefile.inc
│ ├── Messenger_test.c
│ ├── av_test.c
│ ├── dns3_test.c
│ ├── irc_syncbot.c
│ ├── misc_tools.c
│ ├── nTox.c
│ ├── nTox.h
│ ├── tox_shell.c
│ └── tox_sync.c
├── tox.spec.in
├── toxav/
│ ├── Makefile.inc
│ ├── audio.c
│ ├── audio.h
│ ├── bwcontroller.c
│ ├── bwcontroller.h
│ ├── group.c
│ ├── group.h
│ ├── msi.c
│ ├── msi.h
│ ├── rtp.c
│ ├── rtp.h
│ ├── toxav.c
│ ├── toxav.h
│ ├── toxav_old.c
│ ├── video.c
│ └── video.h
├── toxcore/
│ ├── DHT.c
│ ├── DHT.h
│ ├── LAN_discovery.c
│ ├── LAN_discovery.h
│ ├── Makefile.inc
│ ├── Messenger.c
│ ├── Messenger.h
│ ├── TCP_client.c
│ ├── TCP_client.h
│ ├── TCP_connection.c
│ ├── TCP_connection.h
│ ├── TCP_server.c
│ ├── TCP_server.h
│ ├── assoc.c
│ ├── assoc.h
│ ├── crypto_core.c
│ ├── crypto_core.h
│ ├── friend_connection.c
│ ├── friend_connection.h
│ ├── friend_requests.c
│ ├── friend_requests.h
│ ├── group.c
│ ├── group.h
│ ├── list.c
│ ├── list.h
│ ├── logger.c
│ ├── logger.h
│ ├── misc_tools.h
│ ├── net_crypto.c
│ ├── net_crypto.h
│ ├── network.c
│ ├── network.h
│ ├── onion.c
│ ├── onion.h
│ ├── onion_announce.c
│ ├── onion_announce.h
│ ├── onion_client.c
│ ├── onion_client.h
│ ├── ping.c
│ ├── ping.h
│ ├── ping_array.c
│ ├── ping_array.h
│ ├── tox.c
│ ├── tox.h
│ ├── tox_old.h
│ ├── tox_old_code.h
│ ├── util.c
│ └── util.h
├── toxdns/
│ ├── Makefile.inc
│ ├── toxdns.c
│ └── toxdns.h
└── toxencryptsave/
├── Makefile.inc
├── crypto_pwhash_scryptsalsa208sha256/
│ ├── crypto_pwhash_scryptsalsa208sha256.h
│ ├── crypto_scrypt-common.c
│ ├── crypto_scrypt.h
│ ├── export.h
│ ├── nosse/
│ │ └── pwhash_scryptsalsa208sha256_nosse.c
│ ├── note_to_maintainers.txt
│ ├── pbkdf2-sha256.c
│ ├── pbkdf2-sha256.h
│ ├── pwhash_scryptsalsa208sha256.c
│ ├── runtime.c
│ ├── runtime.h
│ ├── scrypt_platform.c
│ ├── sse/
│ │ └── pwhash_scryptsalsa208sha256_sse.c
│ ├── sysendian.h
│ ├── utils.c
│ └── utils.h
├── defines.h
├── toxencryptsave.c
└── toxencryptsave.h
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
# OS files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trash*
Icon?
ethumbs.db
Thumbs.db
*.tmp
# Make
CMakeCache.txt
CMakeFiles
Makefile
cmake_install.cmake
install_manifest.txt
tags
Makefile.in
# Testing
testing/data
*~
# Vim
*.swp
# Object files
*.o
*.lo
*.a
# Executables
*.exe
*.out
*.app
*.la
# Misc (?)
m4/*
configure
configure_aux
!m4/pkg.m4
aclocal.m4
config.h*
config.log
config.status
stamp-h1
autom4te.cache
libtoxcore.pc
libtoxav.pc
libtool
.deps
.libs
.dirstamp
build/
#kdevelop
.kdev/
*.kdev*
# Netbeans
nbproject
# astyle
*.orig
# Android buildscript
android-toolchain-*
toxcore-android-*
# cscope files list
cscope.files
# rpm
tox.spec
================================================
FILE: .travis.yml
================================================
sudo: required
dist: trusty
language: c
compiler:
- gcc
- clang
before_script:
- sudo add-apt-repository ppa:avsm/ocaml42+opam12 -y
- sudo apt-get update -qq
- sudo apt-get install ocaml opam astyle -qq
- sudo apt-get install libconfig-dev libvpx-dev libopus-dev check -qq
# build apidsl
- git clone https://github.com/iphydf/apidsl
- cd apidsl
- export OPAMYES=1
- opam init
- opam install ocamlfind ppx_deriving menhir
- eval `opam config env`
- make -j3
- cd ..
# install sodium, as it's not in Ubuntu Trusty
- git clone git://github.com/jedisct1/libsodium.git
- cd libsodium
- git checkout tags/1.0.8
- ./autogen.sh
- ./configure
- make -j3
- sudo make install
- cd ..
- sudo ldconfig
script:
# check if toxcore.h and toxav.h match apidsl tox.in.h and toxav.in.h
# tox.h
- ./apidsl/_build/apigen.native ./other/apidsl/tox.in.h > tox.h
- astyle --options=./other/astyle/astylerc tox.h
- diff -u tox.h ./toxcore/tox.h
# toxav.h
- ./apidsl/_build/apigen.native ./other/apidsl/toxav.in.h > toxav.h
- astyle --options=./other/astyle/astylerc toxav.h
- diff -u toxav.h ./toxav/toxav.h
# build toxcore and run tests
- ./autogen.sh
- CFLAGS="-Ofast -Wall -Wextra" ./configure --enable-daemon --enable-ntox
- make
- make check
- cat build/test-suite.log
- make dist
notifications:
email: false
irc:
channels:
- "chat.freenode.net#tox-dev"
on_success: always
on_failure: always
================================================
FILE: COPYING
================================================
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
================================================
FILE: DONATORS
================================================
Minnesota > Florida
vdo <vdo@greyfaze.net>
Spitfire is best technicolor horse.
if bad people don't hate you, you're doing something wrong
Pinkie Pie is best pony.
JRS was here
qTox is so bloated it doesn't even fit in a 64-bit address space
================================================
FILE: INSTALL.md
================================================
#Install Instructions
- [Installation](#installation)
- [Unix like](#unix)
- [Quick install](#quick-install)
- [Build manually](#build-manually)
- [Compile toxcore](#compile-toxcore)
- [OS X](#osx)
- [Homebrew](#homebrew)
- [Non-Homebrew](#non-homebrew)
- [Windows](#windows)
- [Cross-Compile](#windows-cross-compile)
- [Setting up a VM](#windows-cross-compile-vm)
- [Setting up the environment](#windows-cross-compile-environment)
- [Compiling](#windows-cross-compile-compiling)
- [Native](#windows-native)
- [Additional](#additional)
- [Advanced configure options](#aconf)
- [A/V support](#av)
- [libtoxav](#libtoxav)
- [Bootstrap daemon](#bootstrapd)
- [nTox](#ntox)
<a name="installation" />
##Installation
<a name="unix" />
###Most Unix like OSes:
#### Quick install:
On Gentoo:
```
# layman -f && layman -a tox-overlay && emerge net-libs/tox
```
And you're done `:)`</br>
If you happen to run some other distro which isn't made for compiling, there are steps below:
#### Build manually
Build dependencies:
Note: package fetching commands may vary by OS.
On Ubuntu `< 15.04` / Debian `< 8`:
```bash
sudo apt-get install build-essential libtool autotools-dev automake checkinstall check git yasm
```
On Ubuntu `>= 15.04` / Debian `>= 8`:
```bash
sudo apt-get install build-essential libtool autotools-dev automake checkinstall check git yasm libsodium13 libsodium-dev
```
On Fedora:
```bash
dnf groupinstall "Development Tools"
dnf install libtool autoconf automake check check-devel
```
Using ``dnf install @"Development Tools"`` is also valid and slightly shorter / cleaner way. ``@"Rpm Development Tools"`` would carry the remaining dependencies listed here.
On SunOS:
```pfexcec
pkg install autoconf automake gcc-47
```
On FreeBSD 10+:
```tcsh
pkg install net-im/tox
```
Note, if you install from ports select NaCl for performance, and sodium if you want it to be portable.
**For A/V support, also install the dependences listed in the [libtoxav](#libtoxav) section.** Note that you have to install those dependencies **before** compiling `toxcore`.
You should get and install [libsodium](https://github.com/jedisct1/libsodium). If you have installed `libsodium` from repo, ommit this step, and jump directly to [compiling toxcore](#compile-toxcore):
```bash
git clone https://github.com/jedisct1/libsodium.git
cd libsodium
git checkout tags/1.0.3
./autogen.sh
./configure && make check
sudo checkinstall --install --pkgname libsodium --pkgversion 1.0.0 --nodoc
sudo ldconfig
cd ..
```
Or if checkinstall is not easily available for your distribution (e.g., Fedora),
this will install the libs to /usr/local/lib and the headers to /usr/local/include:
```bash
git clone https://github.com/jedisct1/libsodium.git
cd libsodium
git checkout tags/1.0.3
./autogen.sh
./configure
make check
sudo make install
cd ..
```
If your default prefix is ``/usr/local`` and you happen to get an error that says ``"error while loading shared libraries: libtoxcore.so.0: cannot open shared object file: No such file or directory"``, then you can try running ``sudo ldconfig``. If that doesn't fix it, run:
```bash
echo '/usr/local/lib/' | sudo tee -a /etc/ld.so.conf.d/locallib.conf
sudo ldconfig
```
You may run into a situation where there is no ``/etc/ld.so.conf.d`` directory. You could either create it manually, or append path to local library to ``ld.so.conf``:
```bash
echo '/usr/local/lib/' | sudo tee -a /etc/ld.so.conf
sudo ldconfig
```
##### Compile toxcore
Then clone this repo, generate makefile, and install `toxcore` system-wide:
```bash
git clone https://github.com/irungentoo/toxcore.git
cd toxcore
autoreconf -i
./configure
make
sudo make install
```
<a name="osx" />
###OS X:
You need the latest XCode with the Developer Tools (Preferences -> Downloads -> Command Line Tools).
The following libraries are required along with libsodium and cmake for Mountain Lion and XCode 4.6.3 install libtool, automake and autoconf. You can download them with Homebrew, or install them manually.
**Note: OS X users can also install Toxcore using [osx_build_script_toxcore.sh](other/osx_build_script_toxcore.sh)**
There are no binaries/executables going to /bin/ or /usr/bin/ now. Everything is compiled and ran from the inside your local branch. See [Usage](#usage) below.
<a name="homebrew" />
####Homebrew:
To install from the formula:
```bash
brew tap Tox/tox
brew install --HEAD libtoxcore
```
To do it manually:
```
brew install libtool automake autoconf libsodium check
```
Then clone this repo and generate makefile:
```bash
git clone https://github.com/irungentoo/toxcore.git
cd toxcore
autoreconf -i
./configure
make
make install
```
If execution fails with errors like "dyld: Library not loaded: /opt/tox-im/lib/libtoxcore.0.dylib", you may need to specify libsodium path:
Determine paths:
```
brew list libsodium
```
Configure include and lib folder and build again:
```bash
./configure --with-libsodium-headers=/usr/local/Cellar/libsodium/1.0.0/include/ --with-libsodium-libs=/usr/local/Cellar/libsodium/1.0.0/lib/
make
make install
```
<a name="non-homebrew" />
####Non-homebrew:
Grab the following packages:
* https://gnu.org/software/libtool/
* https://gnu.org/software/autoconf/
* https://gnu.org/software/automake/
* https://github.com/jedisct1/libsodium
* http://check.sourceforge.net/
* http://yasm.tortall.net/Download.html (install before libvpx)
* https://code.google.com/p/webm/downloads/list
* http://www.opus-codec.org/downloads/
* http://www.freedesktop.org/wiki/Software/pkg-config/
Macports: (https://www.macports.org/)
All toxcore dependencies can be installed from MacPorts. This is often easier on PowerPC Macs,
and any version of OS X prior to 10.6, since Homebrew is supported on 10.6 and up, but not much
(or at all) on older systems. A few packages have slightly different names from the corresponding
package in Debian.
Same: libtool autoconf automake libsodium check yasm
Different: libvpx (webm) libopus pkgconfig gettext
(the libintl, from gettext, built into OS X 10.5 is missing libintl_setlocale, but the Macports build has it)
Verify where libintl is on your system: (MacPorts puts it in /opt/local)
```
for d in /usr/local/lib /opt/local/lib /usr/lib /lib; do ls -l $d/libintl.*; done
```
Check if that copy has libintl_setlocale:
```
nm /opt/local/lib/libintl.8.dylib | grep _libintl_setlocale
```
Certain other tools may not be installed, or outdated, and should also be installed from MacPorts for simplicity: git cmake
If libsodium was installed with MacPorts, you may want to symlink the copy in /opt/local/lib to /usr/local/lib. That way you don't need special configure switches for toxcore to find libsodium, and every time MacPorts updates libsodium, the new version will be linked to toxcore every time you build:
```
ln -s /opt/local/lib/libsodium.dylib /usr/local/lib/libsodium.dylib
```
Much of the build can then be done as for other platforms: git clone, and so on. Differences will be noted with (OS X 10.5 specific)
pkg-config is important for enabling a/v support in tox core, failure to install pkg-config will prevent tox core form finding the required libopus/libvpx libraries. (pkg-config may not configure properly, if you get an error about GLIB, run configure with the following parameter, --with-internal-glib).
Uncompress and install them all. Make sure to follow the README as the instructions change, but they all follow the same pattern below:
```bash
./configure
make
sudo make install
```
Compiling and installing Tox Core
```bash
cd toxcore
autoreconf -i
./configure (OS X 10.5 specific)
./configure CC="gcc -arch ppc -arch i386" CXX="g++ -arch ppc -arch i386" CPP="gcc -E" CXXCPP="g++ -E"
make
make install (OS X 10.5 specific)
should be: sudo make install
If it worked, you should have all the toxcore dylibs in /usr/local/lib: (besides the four below, the rest are symlinks to these)
$ ls -la /usr/local/lib/libtox*.dylib
libtoxav.0.dylib
libtoxcore.0.dylib
libtoxdns.0.dylib
libtoxencryptsave.0.dylib
to check what CPU architecture they're compiled for:
$ lipo -i /usr/local/lib/libtoxencryptsave.0.dylib
You should now be able to move on to compiling Toxic/Venom or some other client application
There is also a shell script called "osx_build_script_toxcore.txt" which automates everything from "git pull" to "sudo make install", once the dependencies are already taken care of by MacPorts.
```
If after running ./configure you get an error about core being unable to find libsodium (and you have installed it) run the following in place of ./configure;
```
./configure --with-libsodium-headers=/usr/local/include/ --with-libsodium-libs=/usr/local/lib
```
Ensure you set the locations correctly depending on where you installed libsodium on your computer.
If there is a problem with opus (for A/V) and you don't get a libtoxav, then try to set the pkg-config environment variable beforehand:
```
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
```
<a name="windows" />
###Windows:
<a name="windows-cross-compile" />
####Cross-compile
It's a bit challenging to build Tox and all of its dependencies nativly on Windows, so we will show an easier, less error and headache prone method of building it -- cross-compiling.
<a name="windows-cross-compile-vm" />
#####Setting up a VM
We will assume that you don't have any VM running Linux around and will guide you from the ground up.
First, you would need to get a virtual machine and a Linux distribution image file.
For a virtual machine we will use VirtualBox. You can get it [here](https://www.virtualbox.org/wiki/Downloads).
For a Linux distribution we will use Lubuntu 14.04 32-bit, which you can get [here](https://help.ubuntu.com/community/Lubuntu/GetLubuntu).
After you have those downloaded, install the VirtualBox and create a VM in it. The default of 512mb of RAM and 8gb of dynamically-allocated virtual hard drive would be enough.
When you have created the VM, go into its **Settings** -> **System** -> **Processor** and add some cores, if you have any additional available, for faster builds.
Then, go to **Settings** -> **Storage**, click on **Empty** under **Controller: IDE**, click on the little disc icon on the right side of the window, click on **Choose a virtual CD/DVD disk file** and select the downloaded Lubuntu image file.
Start the VM and follow the installation instructions.
After Lubuntu is installed and you have booted into it, in VirtualBox menu on top of the window select **Devices** -> **Insert Guest Additions CD image...**.
Open terminal from **Lubuntu's menu** -> **Accessories**.
Execute:
```bash
sudo apt-get update
sudo apt-get install build-essential -y
cd /media/*/*/
sudo ./VBoxLinuxAdditions.run
```
After that, create a folder called `toxbuild` somewhere on your Windows system. The go to **Devices** -> **Shared Folders Settings...** in the VirtualBox menu, add the `toxbuild` folder there and set **Auto-mount** and **Make Permanent** options.
Execute:
```bash
sudo adduser `whoami` vboxsf
```
Note the use of a [grave accent](http://en.wikipedia.org/wiki/Grave_accent) instead of an apostrophe.
Then just reboot the system with:
```bash
sudo reboot
```
After the system is booted, go to **Devices** -> **Shared Clipboard** and select **Bidirectional**. Now you will be able to copy-paste text between the host and the guest systems.
Now that the virtual machine is all set up, let's move to getting build dependencies and setting up environment variables.
<a name="windows-cross-compile-environment" />
#####Setting up the environment
First we will install all tools that we would need for building:
```bash
sudo apt-get install build-essential libtool autotools-dev automake checkinstall check git yasm pkg-config mingw-w64 -y
```
Then we will define a few variables, **depending on which you will build either 32-bit or 64-bit Tox**.
For 32-bit Tox build, do:
```bash
WINDOWS_TOOLCHAIN=i686-w64-mingw32
LIB_VPX_TARGET=x86-win32-gcc
```
For 64-bit Tox build, do:
```bash
WINDOWS_TOOLCHAIN=x86_64-w64-mingw32
LIB_VPX_TARGET=x86_64-win64-gcc
```
This is the only difference between 32-bit and 64-bit build procedures.
For speeding up the build process do:
```
MAKEFLAGS=j$(nproc)
export MAKEFLAGS
```
And let's make a folder where we will be building everything at
```bash
cd ~
mkdir prefix
cd prefix
PREFIX_DIR=$(pwd)
cd ..
mkdir build
cd build
```
<a name="windows-cross-compile-compiling" />
#####Compiling
Now we will build libraries needed for audio/video: VPX and Opus.
VPX:
```bash
git clone https://chromium.googlesource.com/webm/libvpx
cd libvpx
git checkout tags/v1.3.0
CROSS="$WINDOWS_TOOLCHAIN"- ./configure --target="$LIB_VPX_TARGET" --prefix="$PREFIX_DIR" --disable-examples --disable-unit-tests --disable-shared --enable-static
make
make install
cd ..
```
Opus:
```bash
wget http://downloads.xiph.org/releases/opus/opus-1.1.tar.gz
tar -xf opus-1.1.tar.gz
cd opus-1.1
./configure --host="$WINDOWS_TOOLCHAIN" --prefix="$PREFIX_DIR" --disable-extra-programs --disable-doc --disable-shared --enable-static
make
make install
cd ..
```
Now we will build sodium crypto library:
```bash
git clone https://github.com/jedisct1/libsodium/
cd libsodium
git checkout tags/1.0.3
./autogen.sh
./configure --host="$WINDOWS_TOOLCHAIN" --prefix="$PREFIX_DIR" --disable-shared --enable-static
make
make install
cd ..
```
And finally we will build Tox:
```bash
git clone https://github.com/irungentoo/toxcore
cd toxcore
./autogen.sh
./configure --host="$WINDOWS_TOOLCHAIN" --prefix="$PREFIX_DIR" --disable-ntox --disable-tests --disable-testing --with-dependency-search="$PREFIX_DIR" --disable-shared --enable-static
make
make install
cd ..
```
Then we make Tox shared library:
```bash
cd "$PREFIX_DIR"
mkdir tmp
cd tmp
$WINDOWS_TOOLCHAIN-ar x ../lib/libtoxcore.a
$WINDOWS_TOOLCHAIN-ar x ../lib/libtoxav.a
$WINDOWS_TOOLCHAIN-ar x ../lib/libtoxdns.a
$WINDOWS_TOOLCHAIN-ar x ../lib/libtoxencryptsave.a
$WINDOWS_TOOLCHAIN-gcc -Wl,--export-all-symbols -Wl,--out-implib=libtox.dll.a -shared -o libtox.dll *.o ../lib/*.a /usr/$WINDOWS_TOOLCHAIN/lib/libwinpthread.a -liphlpapi -lws2_32 -static-libgcc
```
And we will copy it over to the `toxbuild` directory:
```bash
mkdir -p /media/sf_toxbuild/release/lib
cp libtox.dll.a /media/sf_toxbuild/release/lib
mkdir -p /media/sf_toxbuild/release/bin
cp libtox.dll /media/sf_toxbuild/release/bin
mkdir -p /media/sf_toxbuild/release/include
cp -r ../include/tox /media/sf_toxbuild/release/include
```
That's it. Now you should have `release/bin/libtox.dll`, `release/bin/libtox.dll.a` and `release/include/tox/<headers>` in your `toxbuild` directory on the Windows system.
<a name="windows-native" />
####Native
Note that the Native instructions are incomplete, in a sense that they miss instructions needed for adding audio/video support to Tox. You also might stumble upon some unknown MinGW+msys issues while trying to build it.
You should install:
- [MinGW](http://sourceforge.net/projects/mingw/)
When installing MinGW, make sure to select the MSYS option in the installer.
MinGW will install an "MinGW shell" (you should get a shortcut for it), make sure to perform all operations (i.e., generating/running configure script, compiling, etc.) from the MinGW shell.
First download the source tarball from https://download.libsodium.org/libsodium/releases/ and build it.
Assuming that you got the libsodium-1.0.0.tar.gz release:
```cmd
tar -zxvf libsodium-1.0.0.tar.gz
cd libsodium-1.0.0
./configure
make
make install
cd ..
```
You can also use a precompiled win32 binary of libsodium, however you will have to place the files in places where they can be found, i.e., dll's go to /bin headers to /include and libraries to /lib directories in your MinGW shell.
Next, install toxcore library, should either clone this repo by using git, or just download a [zip of current Master branch](https://github.com/irungentoo/toxcore/archive/master.zip) and extract it somewhere.
Assuming that you now have the sources in the toxcore directory:
```cmd
cd toxcore
autoreconf -i
./configure
make
make install
```
<a name="Clients" />
####Clients:
While [Toxic](https://github.com/tox/toxic) is no longer in core, a list of Tox clients are located in our [wiki](https://wiki.tox.chat/doku.php?id=clients)
<a name="additional" />
##Additional
<a name="aconf" />
###Advanced configure options:
- --prefix=/where/to/install
- --with-libsodium-headers=/path/to/libsodium/include/
- --with-libsodium-libs=/path/to/sodiumtest/lib/
- --enable-silent-rules less verbose build output (undo: "make V=1")
- --disable-silent-rules verbose build output (undo: "make V=0")
- --disable-tests build unit tests (default: auto)
- --disable-av disable A/V support (default: auto) see: [libtoxav](#libtoxav)
- --enable-ntox build nTox client (default: no) see: [nTox](#ntox)
- --enable-daemon build DHT bootstrap daemon (default=no) see: [Bootstrap daemon](#bootstrapd)
- --enable-shared[=PKGS] build shared libraries [default=yes]
- --enable-static[=PKGS] build static libraries [default=yes]
<a name="av" />
###A/V support:
<a name="libtoxav" />
####libtoxav:
'libtoxav' is needed for A/V support and it's enabled by default. You can disable it by adding --disable-av argument to ./configure script like so:
```bash
./configure --disable-av
```
There are 2 dependencies required for libtoxav: libopus and libvpx. If they are not installed A/V support is dropped.
Install on fedora:
```bash
yum install opus-devel libvpx-devel
```
Install on ubuntu:
```bash
sudo apt-get install libopus-dev libvpx-dev pkg-config
```
If you get the "Unable to locate package libopus-dev" message, add the following ppa and try again:
```bash
sudo add-apt-repository ppa:ubuntu-sdk-team/ppa && sudo apt-get update && sudo apt-get dist-upgrade
```
Install from source (example for most unix-like OS's):
libvpx:
```bash
git clone https://chromium.googlesource.com/webm/libvpx
cd libvpx
./configure
make -j3
sudo make install
cd ..
```
libopus:
```bash
wget http://downloads.xiph.org/releases/opus/opus-1.0.3.tar.gz
tar xvzf opus-1.0.3.tar.gz
cd opus-1.0.3
./configure
make -j3
sudo make install
cd ..
```
<a name="bootstrapd" />
###Bootstrap daemon:
Daemon is disabled by default. You can enable it by adding --enable-daemon argument to ./configure script like so:
```bash
./configure --enable-daemon
```
There is one dependency required for bootstrap daemon: `libconfig-dev` >= 1.4.
Install on fedora:
```bash
yum install libconfig-devel
```
Install on ubuntu:
```bash
sudo apt-get install libconfig-dev
```
OS X homebrew:
```
brew install libconfig
```
OS X non-homebrew:
Grab the following [package](http://www.hyperrealm.com/libconfig/), uncompress and install
See this [readme](other/bootstrap_daemon/README.md) on how to set up the bootstrap daemon.
<a name="ntox" />
###nTox test cli:
nTox is disabled by default. You can enable it by adding --enable-ntox argument to ./configure script like so:
```bash
./configure --enable-ntox
```
There is one dependency required for nTox: libncurses.
Install on fedora:
```bash
yum install ncurses-devel
```
Install on ubuntu:
```bash
sudo apt-get install ncurses-dev
```
================================================
FILE: Makefile.am
================================================
SUBDIRS = build
ACLOCAL_AMFLAGS = -I m4
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = $(top_builddir)/libtoxcore.pc
BUILT_SOURCES = $(top_builddir)/libtoxcore.pc
CLEANFILES = $(top_builddir)/libtoxcore.pc
EXTRA_DIST = \
README.md \
libtoxcore.pc.in \
tox.spec \
dist-build/android-arm.sh \
dist-build/android-armv7.sh \
dist-build/android-x86.sh \
dist-build/android-mips.sh \
dist-build/android-build.sh \
$(top_srcdir)/docs/updates/Crypto.md \
$(top_srcdir)/docs/updates/Spam-Prevention.md \
$(top_srcdir)/docs/updates/Symmetric-NAT-Transversal.md \
$(top_srcdir)/other/astyle/README.md \
$(top_srcdir)/other/astyle/astylerc \
$(top_srcdir)/other/astyle/pre-commit
if BUILD_AV
pkgconfig_DATA += $(top_builddir)/libtoxav.pc
BUILT_SOURCES += $(top_builddir)/libtoxav.pc
CLEANFILES += $(top_builddir)/libtoxav.pc
EXTRA_DIST += libtoxav.pc.in
endif
================================================
FILE: README.md
================================================

***
With the rise of government surveillance programs, Tox, a FOSS initiative, aims to be an easy to use, all-in-one communication platform that ensures full privacy and secure message delivery.<br /> <br />
[**Website**](https://tox.chat) **|** [**Wiki**](https://wiki.tox.chat/) **|** [**Blog**](https://blog.tox.chat/) **|** [**FAQ**](https://wiki.tox.chat/doku.php?id=users:faq) **|** [**Binaries/Downloads**](https://wiki.tox.chat/Binaries) **|** [**Clients**](https://wiki.tox.chat/doku.php?id=clients) **|** [**Compiling**](/INSTALL.md)
**IRC Channels:** [#tox@freenode](https://webchat.freenode.net/?channels=tox), [#tox-dev@freenode](https://webchat.freenode.net/?channels=tox-dev)
## The Complex Stuff:
### UDP vs. TCP
Tox must use UDP simply because [hole punching](https://en.wikipedia.org/wiki/UDP_hole_punching) with TCP is not as reliable.
However, Tox does use [TCP relays](/docs/TCP_Network.txt) as a fallback if it encounters a firewall that prevents UDP hole punching.
### Connecting & Communicating
Every peer is represented as a [byte string](https://en.wikipedia.org/wiki/String_(computer_science)) (the public key [Tox ID] of the peer). By using torrent-style DHT, peers can find the IP of other peers by using their Tox ID. Once the IP is obtained, peers can initiate a [secure](/docs/updates/Crypto.md) connection with each other. Once the connection is made, peers can exchange messages, send files, start video chats, etc. using encrypted communications.
**Current build status:** [](https://travis-ci.org/irungentoo/toxcore)
## Q&A:
### What are your goals with Tox?
We want Tox to be as simple as possible while remaining as secure as possible.
### Why are you doing this? There are already a bunch of free Skype alternatives.
The goal of this project is to create a configuration-free P2P Skype replacement. “Configuration-free” means that the user will simply have to open the program and will be capable of adding people and communicating with them without having to set up an account. There are many so-called Skype replacements, but all of them are either hard to configure for the normal user or suffer from being way too centralized.
## TODO:
- [TODO](/docs/TODO.md)
## Documentation:
- [Compiling](/INSTALL.md)
- [DHT Protocol](/docs/updates/DHT.md)<br />
- [Crypto](/docs/updates/Crypto.md)<br />
================================================
FILE: auto_tests/Makefile.inc
================================================
if BUILD_TESTS
TESTS = encryptsave_test messenger_autotest crypto_test network_test assoc_test onion_test TCP_test tox_test dht_autotest
check_PROGRAMS = encryptsave_test messenger_autotest crypto_test network_test assoc_test onion_test TCP_test tox_test dht_autotest
AUTOTEST_CFLAGS = \
$(LIBSODIUM_CFLAGS) \
$(NACL_CFLAGS) \
$(CHECK_CFLAGS)
AUTOTEST_LDADD = \
$(LIBSODIUM_LDFLAGS) \
$(NACL_LDFLAGS) \
libtoxcore.la \
libtoxencryptsave.la \
$(LIBSODIUM_LIBS) \
$(NACL_OBJECTS) \
$(NACL_LIBS) \
$(CHECK_LIBS)
if BUILD_AV
TESTS += toxav_basic_test toxav_many_test
check_PROGRAMS += toxav_basic_test toxav_many_test
AUTOTEST_LDADD += libtoxav.la
endif
messenger_autotest_SOURCES = ../auto_tests/messenger_test.c
messenger_autotest_CFLAGS = $(AUTOTEST_CFLAGS)
messenger_autotest_LDADD = $(AUTOTEST_LDADD)
crypto_test_SOURCES = ../auto_tests/crypto_test.c
crypto_test_CFLAGS = $(AUTOTEST_CFLAGS)
crypto_test_LDADD = $(AUTOTEST_LDADD)
network_test_SOURCES = ../auto_tests/network_test.c
network_test_CFLAGS = $(AUTOTEST_CFLAGS)
network_test_LDADD = $(AUTOTEST_LDADD)
assoc_test_SOURCES = ../auto_tests/assoc_test.c
assoc_test_CFLAGS = $(AUTOTEST_CFLAGS)
assoc_test_LDADD = $(AUTOTEST_LDADD)
onion_test_SOURCES = ../auto_tests/onion_test.c
onion_test_CFLAGS = $(AUTOTEST_CFLAGS)
onion_test_LDADD = $(AUTOTEST_LDADD)
TCP_test_SOURCES = ../auto_tests/TCP_test.c
TCP_test_CFLAGS = $(AUTOTEST_CFLAGS)
TCP_test_LDADD = $(AUTOTEST_LDADD)
tox_test_SOURCES = ../auto_tests/tox_test.c
tox_test_CFLAGS = $(AUTOTEST_CFLAGS)
tox_test_LDADD = $(AUTOTEST_LDADD)
dht_autotest_SOURCES = ../auto_tests/dht_test.c
dht_autotest_CFLAGS = $(AUTOTEST_CFLAGS)
dht_autotest_LDADD = $(AUTOTEST_LDADD)
if BUILD_AV
toxav_basic_test_SOURCES = ../auto_tests/toxav_basic_test.c
toxav_basic_test_CFLAGS = $(AUTOTEST_CFLAGS)
toxav_basic_test_LDADD = $(AUTOTEST_LDADD) $(AV_LIBS)
toxav_many_test_SOURCES = ../auto_tests/toxav_many_test.c
toxav_many_test_CFLAGS = $(AUTOTEST_CFLAGS)
toxav_many_test_LDADD = $(AUTOTEST_LDADD)
endif
endif
encryptsave_test_SOURCES = ../auto_tests/encryptsave_test.c
encryptsave_test_CFLAGS = $(AUTOTEST_CFLAGS)
encryptsave_test_LDADD = $(AUTOTEST_LDADD)
EXTRA_DIST += $(top_srcdir)/auto_tests/friends_test.c \
$(top_srcdir)/auto_tests/helpers.h
================================================
FILE: auto_tests/TCP_test.c
================================================
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/types.h>
#include <stdint.h>
#include <string.h>
#include <check.h>
#include <stdlib.h>
#include <time.h>
#include "../toxcore/TCP_server.h"
#include "../toxcore/TCP_client.h"
#include "../toxcore/util.h"
#include "helpers.h"
#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
#define c_sleep(x) Sleep(1*x)
#else
#include <unistd.h>
#define c_sleep(x) usleep(1000*x)
#endif
#define NUM_PORTS 3
uint16_t ports[NUM_PORTS] = {1234, 33445, 25643};
START_TEST(test_basic)
{
uint8_t self_public_key[crypto_box_PUBLICKEYBYTES];
uint8_t self_secret_key[crypto_box_SECRETKEYBYTES];
crypto_box_keypair(self_public_key, self_secret_key);
TCP_Server *tcp_s = new_TCP_server(1, NUM_PORTS, ports, self_secret_key, NULL);
ck_assert_msg(tcp_s != NULL, "Failed to create TCP relay server");
ck_assert_msg(tcp_s->num_listening_socks == NUM_PORTS, "Failed to bind to all ports");
sock_t sock = socket(AF_INET6, SOCK_STREAM, IPPROTO_TCP);
struct sockaddr_in6 addr6_loopback = {0};
addr6_loopback.sin6_family = AF_INET6;
addr6_loopback.sin6_port = htons(ports[rand() % NUM_PORTS]);
addr6_loopback.sin6_addr = in6addr_loopback;
int ret = connect(sock, (struct sockaddr *)&addr6_loopback, sizeof(addr6_loopback));
ck_assert_msg(ret == 0, "Failed to connect to TCP relay server");
uint8_t f_public_key[crypto_box_PUBLICKEYBYTES];
uint8_t f_secret_key[crypto_box_SECRETKEYBYTES];
uint8_t f_nonce[crypto_box_NONCEBYTES];
crypto_box_keypair(f_public_key, f_secret_key);
random_nonce(f_nonce);
uint8_t t_secret_key[crypto_box_SECRETKEYBYTES];
uint8_t handshake_plain[TCP_HANDSHAKE_PLAIN_SIZE];
crypto_box_keypair(handshake_plain, t_secret_key);
memcpy(handshake_plain + crypto_box_PUBLICKEYBYTES, f_nonce, crypto_box_NONCEBYTES);
uint8_t handshake[TCP_CLIENT_HANDSHAKE_SIZE];
memcpy(handshake, f_public_key, crypto_box_PUBLICKEYBYTES);
new_nonce(handshake + crypto_box_PUBLICKEYBYTES);
ret = encrypt_data(self_public_key, f_secret_key, handshake + crypto_box_PUBLICKEYBYTES, handshake_plain,
TCP_HANDSHAKE_PLAIN_SIZE, handshake + crypto_box_PUBLICKEYBYTES + crypto_box_NONCEBYTES);
ck_assert_msg(ret == TCP_CLIENT_HANDSHAKE_SIZE - (crypto_box_PUBLICKEYBYTES + crypto_box_NONCEBYTES),
"Encrypt failed.");
ck_assert_msg(send(sock, handshake, TCP_CLIENT_HANDSHAKE_SIZE - 1, 0) == TCP_CLIENT_HANDSHAKE_SIZE - 1, "send Failed.");
c_sleep(50);
do_TCP_server(tcp_s);
c_sleep(50);
do_TCP_server(tcp_s);
c_sleep(50);
ck_assert_msg(send(sock, handshake + (TCP_CLIENT_HANDSHAKE_SIZE - 1), 1, 0) == 1, "send Failed.");
c_sleep(50);
do_TCP_server(tcp_s);
c_sleep(50);
do_TCP_server(tcp_s);
c_sleep(50);
uint8_t response[TCP_SERVER_HANDSHAKE_SIZE];
uint8_t response_plain[TCP_HANDSHAKE_PLAIN_SIZE];
ck_assert_msg(recv(sock, response, TCP_SERVER_HANDSHAKE_SIZE, 0) == TCP_SERVER_HANDSHAKE_SIZE, "recv Failed.");
ret = decrypt_data(self_public_key, f_secret_key, response, response + crypto_box_NONCEBYTES,
TCP_SERVER_HANDSHAKE_SIZE - crypto_box_NONCEBYTES, response_plain);
ck_assert_msg(ret == TCP_HANDSHAKE_PLAIN_SIZE, "Decrypt Failed.");
uint8_t f_nonce_r[crypto_box_NONCEBYTES];
uint8_t f_shared_key[crypto_box_BEFORENMBYTES];
encrypt_precompute(response_plain, t_secret_key, f_shared_key);
memcpy(f_nonce_r, response_plain + crypto_box_BEFORENMBYTES, crypto_box_NONCEBYTES);
uint8_t r_req_p[1 + crypto_box_PUBLICKEYBYTES] = {0};
memcpy(r_req_p + 1, f_public_key, crypto_box_PUBLICKEYBYTES);
uint8_t r_req[2 + 1 + crypto_box_PUBLICKEYBYTES + crypto_box_MACBYTES];
uint16_t size = 1 + crypto_box_PUBLICKEYBYTES + crypto_box_MACBYTES;
size = htons(size);
ret = encrypt_data_symmetric(f_shared_key, f_nonce, r_req_p, 1 + crypto_box_PUBLICKEYBYTES, r_req + 2);
increment_nonce(f_nonce);
memcpy(r_req, &size, 2);
uint32_t i;
for (i = 0; i < sizeof(r_req); ++i) {
ck_assert_msg(send(sock, r_req + i, 1, 0) == 1, "send Failed.");
//ck_assert_msg(send(sock, r_req, sizeof(r_req), 0) == sizeof(r_req), "send Failed.");
do_TCP_server(tcp_s);
c_sleep(50);
}
do_TCP_server(tcp_s);
c_sleep(50);
uint8_t packet_resp[4096];
int recv_data_len;
ck_assert_msg((recv_data_len = recv(sock, packet_resp, 2 + 2 + crypto_box_PUBLICKEYBYTES + crypto_box_MACBYTES,
0)) == 2 + 2 + crypto_box_PUBLICKEYBYTES + crypto_box_MACBYTES, "recv Failed. %u", recv_data_len);
memcpy(&size, packet_resp, 2);
ck_assert_msg(ntohs(size) == 2 + crypto_box_PUBLICKEYBYTES + crypto_box_MACBYTES, "Wrong packet size.");
uint8_t packet_resp_plain[4096];
ret = decrypt_data_symmetric(f_shared_key, f_nonce_r, packet_resp + 2, recv_data_len - 2, packet_resp_plain);
ck_assert_msg(ret != -1, "decryption failed");
increment_nonce(f_nonce_r);
ck_assert_msg(packet_resp_plain[0] == 1, "wrong packet id %u", packet_resp_plain[0]);
ck_assert_msg(packet_resp_plain[1] == 0, "connection not refused %u", packet_resp_plain[1]);
ck_assert_msg(public_key_cmp(packet_resp_plain + 2, f_public_key) == 0, "key in packet wrong");
kill_TCP_server(tcp_s);
}
END_TEST
struct sec_TCP_con {
sock_t sock;
uint8_t public_key[crypto_box_PUBLICKEYBYTES];
uint8_t recv_nonce[crypto_box_NONCEBYTES];
uint8_t sent_nonce[crypto_box_NONCEBYTES];
uint8_t shared_key[crypto_box_BEFORENMBYTES];
};
struct sec_TCP_con *new_TCP_con(TCP_Server *tcp_s)
{
struct sec_TCP_con *sec_c = malloc(sizeof(struct sec_TCP_con));
sock_t sock = socket(AF_INET6, SOCK_STREAM, IPPROTO_TCP);
struct sockaddr_in6 addr6_loopback = {0};
addr6_loopback.sin6_family = AF_INET6;
addr6_loopback.sin6_port = htons(ports[rand() % NUM_PORTS]);
addr6_loopback.sin6_addr = in6addr_loopback;
int ret = connect(sock, (struct sockaddr *)&addr6_loopback, sizeof(addr6_loopback));
ck_assert_msg(ret == 0, "Failed to connect to TCP relay server");
uint8_t f_secret_key[crypto_box_SECRETKEYBYTES];
crypto_box_keypair(sec_c->public_key, f_secret_key);
random_nonce(sec_c->sent_nonce);
uint8_t t_secret_key[crypto_box_SECRETKEYBYTES];
uint8_t handshake_plain[TCP_HANDSHAKE_PLAIN_SIZE];
crypto_box_keypair(handshake_plain, t_secret_key);
memcpy(handshake_plain + crypto_box_PUBLICKEYBYTES, sec_c->sent_nonce, crypto_box_NONCEBYTES);
uint8_t handshake[TCP_CLIENT_HANDSHAKE_SIZE];
memcpy(handshake, sec_c->public_key, crypto_box_PUBLICKEYBYTES);
new_nonce(handshake + crypto_box_PUBLICKEYBYTES);
ret = encrypt_data(tcp_s->public_key, f_secret_key, handshake + crypto_box_PUBLICKEYBYTES, handshake_plain,
TCP_HANDSHAKE_PLAIN_SIZE, handshake + crypto_box_PUBLICKEYBYTES + crypto_box_NONCEBYTES);
ck_assert_msg(ret == TCP_CLIENT_HANDSHAKE_SIZE - (crypto_box_PUBLICKEYBYTES + crypto_box_NONCEBYTES),
"Encrypt failed.");
ck_assert_msg(send(sock, handshake, TCP_CLIENT_HANDSHAKE_SIZE - 1, 0) == TCP_CLIENT_HANDSHAKE_SIZE - 1, "send Failed.");
do_TCP_server(tcp_s);
c_sleep(50);
ck_assert_msg(send(sock, handshake + (TCP_CLIENT_HANDSHAKE_SIZE - 1), 1, 0) == 1, "send Failed.");
c_sleep(50);
do_TCP_server(tcp_s);
uint8_t response[TCP_SERVER_HANDSHAKE_SIZE];
uint8_t response_plain[TCP_HANDSHAKE_PLAIN_SIZE];
ck_assert_msg(recv(sock, response, TCP_SERVER_HANDSHAKE_SIZE, 0) == TCP_SERVER_HANDSHAKE_SIZE, "recv Failed.");
ret = decrypt_data(tcp_s->public_key, f_secret_key, response, response + crypto_box_NONCEBYTES,
TCP_SERVER_HANDSHAKE_SIZE - crypto_box_NONCEBYTES, response_plain);
ck_assert_msg(ret == TCP_HANDSHAKE_PLAIN_SIZE, "Decrypt Failed.");
encrypt_precompute(response_plain, t_secret_key, sec_c->shared_key);
memcpy(sec_c->recv_nonce, response_plain + crypto_box_BEFORENMBYTES, crypto_box_NONCEBYTES);
sec_c->sock = sock;
return sec_c;
}
void kill_TCP_con(struct sec_TCP_con *con)
{
kill_sock(con->sock);
free(con);
}
int write_packet_TCP_secure_connection(struct sec_TCP_con *con, uint8_t *data, uint16_t length)
{
uint8_t packet[sizeof(uint16_t) + length + crypto_box_MACBYTES];
uint16_t c_length = htons(length + crypto_box_MACBYTES);
memcpy(packet, &c_length, sizeof(uint16_t));
int len = encrypt_data_symmetric(con->shared_key, con->sent_nonce, data, length, packet + sizeof(uint16_t));
if ((unsigned int)len != (sizeof(packet) - sizeof(uint16_t)))
return -1;
increment_nonce(con->sent_nonce);
ck_assert_msg(send(con->sock, packet, sizeof(packet), 0) == sizeof(packet), "send failed");
return 0;
}
int read_packet_sec_TCP(struct sec_TCP_con *con, uint8_t *data, uint16_t length)
{
int len;
ck_assert_msg((len = recv(con->sock, data, length, 0)) == length, "wrong len %i\n", len);
ck_assert_msg((len = decrypt_data_symmetric(con->shared_key, con->recv_nonce, data + 2, length - 2, data)) != -1,
"Decrypt failed");
increment_nonce(con->recv_nonce);
return len;
}
START_TEST(test_some)
{
uint8_t self_public_key[crypto_box_PUBLICKEYBYTES];
uint8_t self_secret_key[crypto_box_SECRETKEYBYTES];
crypto_box_keypair(self_public_key, self_secret_key);
TCP_Server *tcp_s = new_TCP_server(1, NUM_PORTS, ports, self_secret_key, NULL);
ck_assert_msg(tcp_s != NULL, "Failed to create TCP relay server");
ck_assert_msg(tcp_s->num_listening_socks == NUM_PORTS, "Failed to bind to all ports");
struct sec_TCP_con *con1 = new_TCP_con(tcp_s);
struct sec_TCP_con *con2 = new_TCP_con(tcp_s);
struct sec_TCP_con *con3 = new_TCP_con(tcp_s);
uint8_t requ_p[1 + crypto_box_PUBLICKEYBYTES];
requ_p[0] = 0;
memcpy(requ_p + 1, con3->public_key, crypto_box_PUBLICKEYBYTES);
write_packet_TCP_secure_connection(con1, requ_p, sizeof(requ_p));
memcpy(requ_p + 1, con1->public_key, crypto_box_PUBLICKEYBYTES);
write_packet_TCP_secure_connection(con3, requ_p, sizeof(requ_p));
do_TCP_server(tcp_s);
c_sleep(50);
uint8_t data[2048];
int len = read_packet_sec_TCP(con1, data, 2 + 1 + 1 + crypto_box_PUBLICKEYBYTES + crypto_box_MACBYTES);
ck_assert_msg(len == 1 + 1 + crypto_box_PUBLICKEYBYTES, "wrong len %u", len);
ck_assert_msg(data[0] == 1, "wrong packet id %u", data[0]);
ck_assert_msg(data[1] == 16, "connection not refused %u", data[1]);
ck_assert_msg(public_key_cmp(data + 2, con3->public_key) == 0, "key in packet wrong");
len = read_packet_sec_TCP(con3, data, 2 + 1 + 1 + crypto_box_PUBLICKEYBYTES + crypto_box_MACBYTES);
ck_assert_msg(len == 1 + 1 + crypto_box_PUBLICKEYBYTES, "wrong len %u", len);
ck_assert_msg(data[0] == 1, "wrong packet id %u", data[0]);
ck_assert_msg(data[1] == 16, "connection not refused %u", data[1]);
ck_assert_msg(public_key_cmp(data + 2, con1->public_key) == 0, "key in packet wrong");
uint8_t test_packet[512] = {16, 17, 16, 86, 99, 127, 255, 189, 78};
write_packet_TCP_secure_connection(con3, test_packet, sizeof(test_packet));
write_packet_TCP_secure_connection(con3, test_packet, sizeof(test_packet));
write_packet_TCP_secure_connection(con3, test_packet, sizeof(test_packet));
c_sleep(50);
do_TCP_server(tcp_s);
c_sleep(50);
len = read_packet_sec_TCP(con1, data, 2 + 2 + crypto_box_MACBYTES);
ck_assert_msg(len == 2, "wrong len %u", len);
ck_assert_msg(data[0] == 2, "wrong packet id %u", data[0]);
ck_assert_msg(data[1] == 16, "wrong peer id %u", data[1]);
len = read_packet_sec_TCP(con3, data, 2 + 2 + crypto_box_MACBYTES);
ck_assert_msg(len == 2, "wrong len %u", len);
ck_assert_msg(data[0] == 2, "wrong packet id %u", data[0]);
ck_assert_msg(data[1] == 16, "wrong peer id %u", data[1]);
len = read_packet_sec_TCP(con1, data, 2 + sizeof(test_packet) + crypto_box_MACBYTES);
ck_assert_msg(len == sizeof(test_packet), "wrong len %u", len);
ck_assert_msg(memcmp(data, test_packet, sizeof(test_packet)) == 0, "packet is wrong %u %u %u %u", data[0], data[1],
data[sizeof(test_packet) - 2], data[sizeof(test_packet) - 1]);
len = read_packet_sec_TCP(con1, data, 2 + sizeof(test_packet) + crypto_box_MACBYTES);
ck_assert_msg(len == sizeof(test_packet), "wrong len %u", len);
ck_assert_msg(memcmp(data, test_packet, sizeof(test_packet)) == 0, "packet is wrong %u %u %u %u", data[0], data[1],
data[sizeof(test_packet) - 2], data[sizeof(test_packet) - 1]);
len = read_packet_sec_TCP(con1, data, 2 + sizeof(test_packet) + crypto_box_MACBYTES);
ck_assert_msg(len == sizeof(test_packet), "wrong len %u", len);
ck_assert_msg(memcmp(data, test_packet, sizeof(test_packet)) == 0, "packet is wrong %u %u %u %u", data[0], data[1],
data[sizeof(test_packet) - 2], data[sizeof(test_packet) - 1]);
write_packet_TCP_secure_connection(con1, test_packet, sizeof(test_packet));
write_packet_TCP_secure_connection(con1, test_packet, sizeof(test_packet));
write_packet_TCP_secure_connection(con1, test_packet, sizeof(test_packet));
c_sleep(50);
do_TCP_server(tcp_s);
c_sleep(50);
len = read_packet_sec_TCP(con3, data, 2 + sizeof(test_packet) + crypto_box_MACBYTES);
ck_assert_msg(len == sizeof(test_packet), "wrong len %u", len);
ck_assert_msg(memcmp(data, test_packet, sizeof(test_packet)) == 0, "packet is wrong %u %u %u %u", data[0], data[1],
data[sizeof(test_packet) - 2], data[sizeof(test_packet) - 1]);
len = read_packet_sec_TCP(con3, data, 2 + sizeof(test_packet) + crypto_box_MACBYTES);
ck_assert_msg(len == sizeof(test_packet), "wrong len %u", len);
ck_assert_msg(memcmp(data, test_packet, sizeof(test_packet)) == 0, "packet is wrong %u %u %u %u", data[0], data[1],
data[sizeof(test_packet) - 2], data[sizeof(test_packet) - 1]);
len = read_packet_sec_TCP(con3, data, 2 + sizeof(test_packet) + crypto_box_MACBYTES);
ck_assert_msg(len == sizeof(test_packet), "wrong len %u", len);
ck_assert_msg(memcmp(data, test_packet, sizeof(test_packet)) == 0, "packet is wrong %u %u %u %u", data[0], data[1],
data[sizeof(test_packet) - 2], data[sizeof(test_packet) - 1]);
uint8_t ping_packet[1 + sizeof(uint64_t)] = {4, 8, 6, 9, 67};
write_packet_TCP_secure_connection(con1, ping_packet, sizeof(ping_packet));
c_sleep(50);
do_TCP_server(tcp_s);
c_sleep(50);
len = read_packet_sec_TCP(con1, data, 2 + sizeof(ping_packet) + crypto_box_MACBYTES);
ck_assert_msg(len == sizeof(ping_packet), "wrong len %u", len);
ck_assert_msg(data[0] == 5, "wrong packet id %u", data[0]);
ck_assert_msg(memcmp(ping_packet + 1, data + 1, sizeof(uint64_t)) == 0, "wrong packet data");
kill_TCP_server(tcp_s);
kill_TCP_con(con1);
kill_TCP_con(con2);
kill_TCP_con(con3);
}
END_TEST
static int response_callback_good;
static uint8_t response_callback_connection_id;
static uint8_t response_callback_public_key[crypto_box_PUBLICKEYBYTES];
static int response_callback(void *object, uint8_t connection_id, const uint8_t *public_key)
{
if (set_tcp_connection_number(object - 2, connection_id, 7) != 0)
return 1;
response_callback_connection_id = connection_id;
memcpy(response_callback_public_key, public_key, crypto_box_PUBLICKEYBYTES);
response_callback_good++;
return 0;
}
static int status_callback_good;
static uint8_t status_callback_connection_id;
static uint8_t status_callback_status;
static int status_callback(void *object, uint32_t number, uint8_t connection_id, uint8_t status)
{
if (object != (void *)2)
return 1;
if (number != 7)
return 1;
status_callback_connection_id = connection_id;
status_callback_status = status;
status_callback_good++;
return 0;
}
static int data_callback_good;
static int data_callback(void *object, uint32_t number, uint8_t connection_id, const uint8_t *data, uint16_t length)
{
if (object != (void *)3)
return 1;
if (number != 7)
return 1;
if (length != 5)
return 1;
if (data[0] == 1 && data[1] == 2 && data[2] == 3 && data[3] == 4 && data[4] == 5) {
data_callback_good++;
return 0;
}
return 1;
}
static int oob_data_callback_good;
static uint8_t oob_pubkey[crypto_box_PUBLICKEYBYTES];
static int oob_data_callback(void *object, const uint8_t *public_key, const uint8_t *data, uint16_t length)
{
if (object != (void *)4)
return 1;
if (length != 5)
return 1;
if (public_key_cmp(public_key, oob_pubkey) != 0)
return 1;
if (data[0] == 1 && data[1] == 2 && data[2] == 3 && data[3] == 4 && data[4] == 5) {
oob_data_callback_good++;
return 0;
}
return 1;
}
START_TEST(test_client)
{
unix_time_update();
uint8_t self_public_key[crypto_box_PUBLICKEYBYTES];
uint8_t self_secret_key[crypto_box_SECRETKEYBYTES];
crypto_box_keypair(self_public_key, self_secret_key);
TCP_Server *tcp_s = new_TCP_server(1, NUM_PORTS, ports, self_secret_key, NULL);
ck_assert_msg(tcp_s != NULL, "Failed to create TCP relay server");
ck_assert_msg(tcp_s->num_listening_socks == NUM_PORTS, "Failed to bind to all ports");
uint8_t f_public_key[crypto_box_PUBLICKEYBYTES];
uint8_t f_secret_key[crypto_box_SECRETKEYBYTES];
crypto_box_keypair(f_public_key, f_secret_key);
IP_Port ip_port_tcp_s;
ip_port_tcp_s.port = htons(ports[rand() % NUM_PORTS]);
ip_port_tcp_s.ip.family = AF_INET6;
ip_port_tcp_s.ip.ip6.in6_addr = in6addr_loopback;
TCP_Client_Connection *conn = new_TCP_connection(ip_port_tcp_s, self_public_key, f_public_key, f_secret_key, 0);
c_sleep(50);
do_TCP_connection(conn);
ck_assert_msg(conn->status == TCP_CLIENT_UNCONFIRMED, "Wrong status. Expected: %u, is: %u", TCP_CLIENT_UNCONFIRMED,
conn->status);
c_sleep(50);
do_TCP_server(tcp_s);
c_sleep(50);
do_TCP_connection(conn);
ck_assert_msg(conn->status == TCP_CLIENT_CONFIRMED, "Wrong status. Expected: %u, is: %u", TCP_CLIENT_CONFIRMED,
conn->status);
c_sleep(500);
do_TCP_connection(conn);
ck_assert_msg(conn->status == TCP_CLIENT_CONFIRMED, "Wrong status. Expected: %u, is: %u", TCP_CLIENT_CONFIRMED,
conn->status);
c_sleep(500);
do_TCP_connection(conn);
ck_assert_msg(conn->status == TCP_CLIENT_CONFIRMED, "Wrong status. Expected: %u, is: %u", TCP_CLIENT_CONFIRMED,
conn->status);
do_TCP_server(tcp_s);
c_sleep(50);
ck_assert_msg(conn->status == TCP_CLIENT_CONFIRMED, "Wrong status. Expected: %u, is: %u", TCP_CLIENT_CONFIRMED,
conn->status);
uint8_t f2_public_key[crypto_box_PUBLICKEYBYTES];
uint8_t f2_secret_key[crypto_box_SECRETKEYBYTES];
crypto_box_keypair(f2_public_key, f2_secret_key);
ip_port_tcp_s.port = htons(ports[rand() % NUM_PORTS]);
TCP_Client_Connection *conn2 = new_TCP_connection(ip_port_tcp_s, self_public_key, f2_public_key, f2_secret_key, 0);
routing_response_handler(conn, response_callback, ((void *)conn) + 2);
routing_status_handler(conn, status_callback, (void *)2);
routing_data_handler(conn, data_callback, (void *)3);
oob_data_handler(conn, oob_data_callback, (void *)4);
oob_data_callback_good = response_callback_good = status_callback_good = data_callback_good = 0;
c_sleep(50);
do_TCP_connection(conn);
do_TCP_connection(conn2);
c_sleep(50);
do_TCP_server(tcp_s);
c_sleep(50);
do_TCP_connection(conn);
do_TCP_connection(conn2);
c_sleep(50);
uint8_t data[5] = {1, 2, 3, 4, 5};
memcpy(oob_pubkey, f2_public_key, crypto_box_PUBLICKEYBYTES);
send_oob_packet(conn2, f_public_key, data, 5);
send_routing_request(conn, f2_public_key);
send_routing_request(conn2, f_public_key);
c_sleep(50);
do_TCP_server(tcp_s);
c_sleep(50);
do_TCP_connection(conn);
do_TCP_connection(conn2);
ck_assert_msg(oob_data_callback_good == 1, "oob callback not called");
ck_assert_msg(response_callback_good == 1, "response callback not called");
ck_assert_msg(public_key_cmp(response_callback_public_key, f2_public_key) == 0, "wrong public key");
ck_assert_msg(status_callback_good == 1, "status callback not called");
ck_assert_msg(status_callback_status == 2, "wrong status");
ck_assert_msg(status_callback_connection_id == response_callback_connection_id, "connection ids not equal");
c_sleep(50);
do_TCP_server(tcp_s);
ck_assert_msg(send_data(conn2, 0, data, 5) == 1, "send data failed");
c_sleep(50);
do_TCP_server(tcp_s);
c_sleep(50);
do_TCP_connection(conn);
do_TCP_connection(conn2);
ck_assert_msg(data_callback_good == 1, "data callback not called");
status_callback_good = 0;
send_disconnect_request(conn2, 0);
c_sleep(50);
do_TCP_server(tcp_s);
c_sleep(50);
do_TCP_connection(conn);
do_TCP_connection(conn2);
ck_assert_msg(status_callback_good == 1, "status callback not called");
ck_assert_msg(status_callback_status == 1, "wrong status");
kill_TCP_server(tcp_s);
kill_TCP_connection(conn);
kill_TCP_connection(conn2);
}
END_TEST
START_TEST(test_client_invalid)
{
unix_time_update();
uint8_t self_public_key[crypto_box_PUBLICKEYBYTES];
uint8_t self_secret_key[crypto_box_SECRETKEYBYTES];
crypto_box_keypair(self_public_key, self_secret_key);
uint8_t f_public_key[crypto_box_PUBLICKEYBYTES];
uint8_t f_secret_key[crypto_box_SECRETKEYBYTES];
crypto_box_keypair(f_public_key, f_secret_key);
IP_Port ip_port_tcp_s;
ip_port_tcp_s.port = htons(ports[rand() % NUM_PORTS]);
ip_port_tcp_s.ip.family = AF_INET6;
ip_port_tcp_s.ip.ip6.in6_addr = in6addr_loopback;
TCP_Client_Connection *conn = new_TCP_connection(ip_port_tcp_s, self_public_key, f_public_key, f_secret_key, 0);
c_sleep(50);
do_TCP_connection(conn);
ck_assert_msg(conn->status == TCP_CLIENT_CONNECTING, "Wrong status. Expected: %u, is: %u", TCP_CLIENT_CONNECTING,
conn->status);
c_sleep(5000);
do_TCP_connection(conn);
ck_assert_msg(conn->status == TCP_CLIENT_CONNECTING, "Wrong status. Expected: %u, is: %u", TCP_CLIENT_CONNECTING,
conn->status);
c_sleep(6000);
do_TCP_connection(conn);
ck_assert_msg(conn->status == TCP_CLIENT_DISCONNECTED, "Wrong status. Expected: %u, is: %u", TCP_CLIENT_DISCONNECTED,
conn->status);
kill_TCP_connection(conn);
}
END_TEST
#include "../toxcore/TCP_connection.h"
_Bool tcp_data_callback_called;
static int tcp_data_callback(void *object, int id, const uint8_t *data, uint16_t length)
{
if (object != (void *)120397)
return -1;
if (id != 123)
return -1;
if (length != 6)
return -1;
if (memcmp(data, "Gentoo", length) != 0)
return -1;
tcp_data_callback_called = 1;
return 0;
}
START_TEST(test_tcp_connection)
{
tcp_data_callback_called = 0;
unix_time_update();
uint8_t self_public_key[crypto_box_PUBLICKEYBYTES];
uint8_t self_secret_key[crypto_box_SECRETKEYBYTES];
crypto_box_keypair(self_public_key, self_secret_key);
TCP_Server *tcp_s = new_TCP_server(1, NUM_PORTS, ports, self_secret_key, NULL);
ck_assert_msg(public_key_cmp(tcp_s->public_key, self_public_key) == 0, "Wrong public key");
TCP_Proxy_Info proxy_info;
proxy_info.proxy_type = TCP_PROXY_NONE;
crypto_box_keypair(self_public_key, self_secret_key);
TCP_Connections *tc_1 = new_tcp_connections(self_secret_key, &proxy_info);
ck_assert_msg(public_key_cmp(tc_1->self_public_key, self_public_key) == 0, "Wrong public key");
crypto_box_keypair(self_public_key, self_secret_key);
TCP_Connections *tc_2 = new_tcp_connections(self_secret_key, &proxy_info);
ck_assert_msg(public_key_cmp(tc_2->self_public_key, self_public_key) == 0, "Wrong public key");
IP_Port ip_port_tcp_s;
ip_port_tcp_s.port = htons(ports[rand() % NUM_PORTS]);
ip_port_tcp_s.ip.family = AF_INET6;
ip_port_tcp_s.ip.ip6.in6_addr = in6addr_loopback;
int connection = new_tcp_connection_to(tc_1, tc_2->self_public_key, 123);
ck_assert_msg(connection == 0, "Connection id wrong");
ck_assert_msg(add_tcp_relay_connection(tc_1, connection, ip_port_tcp_s, tcp_s->public_key) == 0,
"Could not add tcp relay to connection\n");
ip_port_tcp_s.port = htons(ports[rand() % NUM_PORTS]);
connection = new_tcp_connection_to(tc_2, tc_1->self_public_key, 123);
ck_assert_msg(connection == 0, "Connection id wrong");
ck_assert_msg(add_tcp_relay_connection(tc_2, connection, ip_port_tcp_s, tcp_s->public_key) == 0,
"Could not add tcp relay to connection\n");
ck_assert_msg(new_tcp_connection_to(tc_2, tc_1->self_public_key, 123) == -1, "Managed to readd same connection\n");
c_sleep(50);
do_TCP_server(tcp_s);
c_sleep(50);
do_tcp_connections(tc_1);
do_tcp_connections(tc_2);
c_sleep(50);
do_TCP_server(tcp_s);
c_sleep(50);
do_tcp_connections(tc_1);
do_tcp_connections(tc_2);
c_sleep(50);
do_TCP_server(tcp_s);
c_sleep(50);
do_tcp_connections(tc_1);
do_tcp_connections(tc_2);
int ret = send_packet_tcp_connection(tc_1, 0, "Gentoo", 6);
ck_assert_msg(ret == 0, "could not send packet.");
set_packet_tcp_connection_callback(tc_2, &tcp_data_callback, (void *) 120397);
c_sleep(50);
do_TCP_server(tcp_s);
c_sleep(50);
do_tcp_connections(tc_1);
do_tcp_connections(tc_2);
ck_assert_msg(tcp_data_callback_called, "could not recv packet.");
ck_assert_msg(tcp_connection_to_online_tcp_relays(tc_1, 0) == 1, "Wrong number of connected relays");
ck_assert_msg(kill_tcp_connection_to(tc_1, 0) == 0, "could not kill connection to\n");
c_sleep(50);
do_TCP_server(tcp_s);
c_sleep(50);
do_tcp_connections(tc_1);
do_tcp_connections(tc_2);
ck_assert_msg(send_packet_tcp_connection(tc_1, 0, "Gentoo", 6) == -1, "could send packet.");
ck_assert_msg(kill_tcp_connection_to(tc_2, 0) == 0, "could not kill connection to\n");
kill_TCP_server(tcp_s);
kill_tcp_connections(tc_1);
kill_tcp_connections(tc_2);
}
END_TEST
_Bool tcp_oobdata_callback_called;
static int tcp_oobdata_callback(void *object, const uint8_t *public_key, unsigned int id, const uint8_t *data,
uint16_t length)
{
if (length != 6)
return -1;
if (memcmp(data, "Gentoo", length) != 0)
return -1;
if (tcp_send_oob_packet(object, id, public_key, data, length) == 0)
tcp_oobdata_callback_called = 1;
return 0;
}
START_TEST(test_tcp_connection2)
{
tcp_oobdata_callback_called = 0;
tcp_data_callback_called = 0;
unix_time_update();
uint8_t self_public_key[crypto_box_PUBLICKEYBYTES];
uint8_t self_secret_key[crypto_box_SECRETKEYBYTES];
crypto_box_keypair(self_public_key, self_secret_key);
TCP_Server *tcp_s = new_TCP_server(1, NUM_PORTS, ports, self_secret_key, NULL);
ck_assert_msg(public_key_cmp(tcp_s->public_key, self_public_key) == 0, "Wrong public key");
TCP_Proxy_Info proxy_info;
proxy_info.proxy_type = TCP_PROXY_NONE;
crypto_box_keypair(self_public_key, self_secret_key);
TCP_Connections *tc_1 = new_tcp_connections(self_secret_key, &proxy_info);
ck_assert_msg(public_key_cmp(tc_1->self_public_key, self_public_key) == 0, "Wrong public key");
crypto_box_keypair(self_public_key, self_secret_key);
TCP_Connections *tc_2 = new_tcp_connections(self_secret_key, &proxy_info);
ck_assert_msg(public_key_cmp(tc_2->self_public_key, self_public_key) == 0, "Wrong public key");
IP_Port ip_port_tcp_s;
ip_port_tcp_s.port = htons(ports[rand() % NUM_PORTS]);
ip_port_tcp_s.ip.family = AF_INET6;
ip_port_tcp_s.ip.ip6.in6_addr = in6addr_loopback;
int connection = new_tcp_connection_to(tc_1, tc_2->self_public_key, 123);
ck_assert_msg(connection == 0, "Connection id wrong");
ck_assert_msg(add_tcp_relay_connection(tc_1, connection, ip_port_tcp_s, tcp_s->public_key) == 0,
"Could not add tcp relay to connection\n");
ck_assert_msg(add_tcp_relay_global(tc_2, ip_port_tcp_s, tcp_s->public_key) == 0, "Could not add global relay");
c_sleep(50);
do_TCP_server(tcp_s);
c_sleep(50);
do_tcp_connections(tc_1);
do_tcp_connections(tc_2);
c_sleep(50);
do_TCP_server(tcp_s);
c_sleep(50);
do_tcp_connections(tc_1);
do_tcp_connections(tc_2);
c_sleep(50);
do_TCP_server(tcp_s);
c_sleep(50);
do_tcp_connections(tc_1);
do_tcp_connections(tc_2);
int ret = send_packet_tcp_connection(tc_1, 0, "Gentoo", 6);
ck_assert_msg(ret == 0, "could not send packet.");
set_oob_packet_tcp_connection_callback(tc_2, &tcp_oobdata_callback, tc_2);
set_packet_tcp_connection_callback(tc_1, &tcp_data_callback, (void *) 120397);
c_sleep(50);
do_TCP_server(tcp_s);
c_sleep(50);
do_tcp_connections(tc_1);
do_tcp_connections(tc_2);
ck_assert_msg(tcp_oobdata_callback_called, "could not recv packet.");
c_sleep(50);
do_TCP_server(tcp_s);
c_sleep(50);
do_tcp_connections(tc_1);
do_tcp_connections(tc_2);
ck_assert_msg(tcp_data_callback_called, "could not recv packet.");
ck_assert_msg(kill_tcp_connection_to(tc_1, 0) == 0, "could not kill connection to\n");
kill_TCP_server(tcp_s);
kill_tcp_connections(tc_1);
kill_tcp_connections(tc_2);
}
END_TEST
Suite *TCP_suite(void)
{
Suite *s = suite_create("TCP");
DEFTESTCASE_SLOW(basic, 5);
DEFTESTCASE_SLOW(some, 10);
DEFTESTCASE_SLOW(client, 10);
DEFTESTCASE_SLOW(client_invalid, 15);
DEFTESTCASE_SLOW(tcp_connection, 20);
DEFTESTCASE_SLOW(tcp_connection2, 20);
return s;
}
int main(int argc, char *argv[])
{
srand((unsigned int) time(NULL));
Suite *TCP = TCP_suite();
SRunner *test_runner = srunner_create(TCP);
int number_failed = 0;
srunner_run_all(test_runner, CK_NORMAL);
number_failed = srunner_ntests_failed(test_runner);
srunner_free(test_runner);
return number_failed;
}
================================================
FILE: auto_tests/assoc_test.c
================================================
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#define AUTO_TEST
#include "../toxcore/DHT.h"
#include "../toxcore/assoc.h"
#include "../toxcore/util.h"
#include <sys/types.h>
#include <stdint.h>
#include <string.h>
#include <check.h>
#include "helpers.h"
START_TEST(test_basics)
{
/* TODO: real test */
uint8_t id[crypto_box_PUBLICKEYBYTES];
Assoc *assoc = new_Assoc_default(id);
ck_assert_msg(assoc != NULL, "failed to create default assoc");
kill_Assoc(assoc);
assoc = new_Assoc(17, 4, id); /* results in an assoc of 16/3 */
ck_assert_msg(assoc != NULL, "failed to create customized assoc");
IP_Port ipp;
ipp.ip.family = AF_INET;
ipp.ip.ip4.uint8[0] = 1;
ipp.port = htons(12345);
IPPTs ippts_send;
ippts_send.ip_port = ipp;
ippts_send.timestamp = unix_time();
IP_Port ipp_recv = ipp;
uint8_t res = Assoc_add_entry(assoc, id, &ippts_send, &ipp_recv, 0);
ck_assert_msg(res == 0, "stored self as entry: expected %u, got %u", 0, res);
id[0]++;
res = Assoc_add_entry(assoc, id, &ippts_send, &ipp_recv, 0);
ck_assert_msg(res == 1, "failed to store entry: expected %u, got %u", 1, res);
Assoc_close_entries close_entries;
memset(&close_entries, 0, sizeof(close_entries));
close_entries.count = 4;
close_entries.count_good = 2;
close_entries.wanted_id = id;
Client_data *entries[close_entries.count];
close_entries.result = entries;
uint8_t found = Assoc_get_close_entries(assoc, &close_entries);
ck_assert_msg(found == 1, "get_close_entries(): expected %u, got %u", 1, found);
kill_Assoc(assoc);
}
END_TEST
START_TEST(test_fillup)
{
/* TODO: real test */
int i, j;
uint8_t id[crypto_box_PUBLICKEYBYTES];
//uint32_t a = current_time();
uint32_t a = 2710106197;
srand(a);
for (i = 0; i < crypto_box_PUBLICKEYBYTES; ++i) {
id[i] = rand();
}
Assoc *assoc = new_Assoc(6, 15, id);
ck_assert_msg(assoc != NULL, "failed to create default assoc");
struct entry {
uint8_t id[crypto_box_PUBLICKEYBYTES];
IPPTs ippts_send;
IP_Port ipp_recv;
};
unsigned int fail = 0;
struct entry entries[128];
struct entry closest[8];
for (j = 0; j < 128; ++j) {
for (i = 0; i < crypto_box_PUBLICKEYBYTES; ++i) {
entries[j].id[i] = rand();
}
IP_Port ipp;
ipp.ip.family = AF_INET;
ipp.ip.ip4.uint32 = rand();
ipp.port = rand();
entries[j].ippts_send.ip_port = ipp;
entries[j].ippts_send.timestamp = unix_time();
ipp.ip.ip4.uint32 = rand();
ipp.port = rand();
entries[j].ipp_recv = ipp;
if (j % 16 == 0) {
memcpy(entries[j].id, id, crypto_box_PUBLICKEYBYTES - 30);
memcpy(&closest[j / 16], &entries[j], sizeof(struct entry));
}
uint8_t res = Assoc_add_entry(assoc, entries[j].id, &entries[j].ippts_send, &entries[j].ipp_recv, 1);
ck_assert_msg(res == 1, "failed to store entry: expected %u, got %u, j = %u", 1, res, j);
}
int good = 0;
Assoc_close_entries close_entries;
memset(&close_entries, 0, sizeof(close_entries));
close_entries.count = 8;
close_entries.count_good = 8;
close_entries.wanted_id = id;
Client_data *entri[close_entries.count];
close_entries.result = entri;
uint8_t found = Assoc_get_close_entries(assoc, &close_entries);
ck_assert_msg(found == 8, "get_close_entries(): expected %u, got %u", 1, found);
for (i = 0; i < 8; ++i) {
for (j = 0; j < 8; ++j) {
if (id_equal(entri[j]->public_key, closest[i].id))
++good;
}
}
ck_assert_msg(good == 8, "Entries found were not the closest ones. Only %u/8 were.", good);
//printf("good: %u %u %u\n", good, a, ((uint32_t)current_time() - a));
kill_Assoc(assoc);
}
END_TEST
Suite *Assoc_suite(void)
{
Suite *s = suite_create("Assoc");
DEFTESTCASE(basics);
DEFTESTCASE(fillup);
return s;
}
int main(int argc, char *argv[])
{
unix_time_update();
Suite *Assoc = Assoc_suite();
SRunner *test_runner = srunner_create(Assoc);
srunner_set_fork_status(test_runner, CK_NOFORK);
srunner_run_all(test_runner, CK_NORMAL);
int number_failed = srunner_ntests_failed(test_runner);
srunner_free(test_runner);
return number_failed;
}
================================================
FILE: auto_tests/crypto_test.c
================================================
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "../toxcore/net_crypto.h"
#include <sys/types.h>
#include <stdint.h>
#include <string.h>
#include <check.h>
#include <stdlib.h>
#include <time.h>
#include "helpers.h"
void rand_bytes(uint8_t *b, size_t blen)
{
size_t i;
for (i = 0; i < blen; i++) {
b[i] = rand();
}
}
// These test vectors are from libsodium's test suite
unsigned char alicesk[32] = {
0x77, 0x07, 0x6d, 0x0a, 0x73, 0x18, 0xa5, 0x7d,
0x3c, 0x16, 0xc1, 0x72, 0x51, 0xb2, 0x66, 0x45,
0xdf, 0x4c, 0x2f, 0x87, 0xeb, 0xc0, 0x99, 0x2a,
0xb1, 0x77, 0xfb, 0xa5, 0x1d, 0xb9, 0x2c, 0x2a
};
unsigned char bobpk[32] = {
0xde, 0x9e, 0xdb, 0x7d, 0x7b, 0x7d, 0xc1, 0xb4,
0xd3, 0x5b, 0x61, 0xc2, 0xec, 0xe4, 0x35, 0x37,
0x3f, 0x83, 0x43, 0xc8, 0x5b, 0x78, 0x67, 0x4d,
0xad, 0xfc, 0x7e, 0x14, 0x6f, 0x88, 0x2b, 0x4f
};
unsigned char nonce[24] = {
0x69, 0x69, 0x6e, 0xe9, 0x55, 0xb6, 0x2b, 0x73,
0xcd, 0x62, 0xbd, 0xa8, 0x75, 0xfc, 0x73, 0xd6,
0x82, 0x19, 0xe0, 0x03, 0x6b, 0x7a, 0x0b, 0x37
};
unsigned char test_m[131] = {
0xbe, 0x07, 0x5f, 0xc5, 0x3c, 0x81, 0xf2, 0xd5,
0xcf, 0x14, 0x13, 0x16, 0xeb, 0xeb, 0x0c, 0x7b,
0x52, 0x28, 0xc5, 0x2a, 0x4c, 0x62, 0xcb, 0xd4,
0x4b, 0x66, 0x84, 0x9b, 0x64, 0x24, 0x4f, 0xfc,
0xe5, 0xec, 0xba, 0xaf, 0x33, 0xbd, 0x75, 0x1a,
0x1a, 0xc7, 0x28, 0xd4, 0x5e, 0x6c, 0x61, 0x29,
0x6c, 0xdc, 0x3c, 0x01, 0x23, 0x35, 0x61, 0xf4,
0x1d, 0xb6, 0x6c, 0xce, 0x31, 0x4a, 0xdb, 0x31,
0x0e, 0x3b, 0xe8, 0x25, 0x0c, 0x46, 0xf0, 0x6d,
0xce, 0xea, 0x3a, 0x7f, 0xa1, 0x34, 0x80, 0x57,
0xe2, 0xf6, 0x55, 0x6a, 0xd6, 0xb1, 0x31, 0x8a,
0x02, 0x4a, 0x83, 0x8f, 0x21, 0xaf, 0x1f, 0xde,
0x04, 0x89, 0x77, 0xeb, 0x48, 0xf5, 0x9f, 0xfd,
0x49, 0x24, 0xca, 0x1c, 0x60, 0x90, 0x2e, 0x52,
0xf0, 0xa0, 0x89, 0xbc, 0x76, 0x89, 0x70, 0x40,
0xe0, 0x82, 0xf9, 0x37, 0x76, 0x38, 0x48, 0x64,
0x5e, 0x07, 0x05
};
unsigned char test_c[147] = {
0xf3, 0xff, 0xc7, 0x70, 0x3f, 0x94, 0x00, 0xe5,
0x2a, 0x7d, 0xfb, 0x4b, 0x3d, 0x33, 0x05, 0xd9,
0x8e, 0x99, 0x3b, 0x9f, 0x48, 0x68, 0x12, 0x73,
0xc2, 0x96, 0x50, 0xba, 0x32, 0xfc, 0x76, 0xce,
0x48, 0x33, 0x2e, 0xa7, 0x16, 0x4d, 0x96, 0xa4,
0x47, 0x6f, 0xb8, 0xc5, 0x31, 0xa1, 0x18, 0x6a,
0xc0, 0xdf, 0xc1, 0x7c, 0x98, 0xdc, 0xe8, 0x7b,
0x4d, 0xa7, 0xf0, 0x11, 0xec, 0x48, 0xc9, 0x72,
0x71, 0xd2, 0xc2, 0x0f, 0x9b, 0x92, 0x8f, 0xe2,
0x27, 0x0d, 0x6f, 0xb8, 0x63, 0xd5, 0x17, 0x38,
0xb4, 0x8e, 0xee, 0xe3, 0x14, 0xa7, 0xcc, 0x8a,
0xb9, 0x32, 0x16, 0x45, 0x48, 0xe5, 0x26, 0xae,
0x90, 0x22, 0x43, 0x68, 0x51, 0x7a, 0xcf, 0xea,
0xbd, 0x6b, 0xb3, 0x73, 0x2b, 0xc0, 0xe9, 0xda,
0x99, 0x83, 0x2b, 0x61, 0xca, 0x01, 0xb6, 0xde,
0x56, 0x24, 0x4a, 0x9e, 0x88, 0xd5, 0xf9, 0xb3,
0x79, 0x73, 0xf6, 0x22, 0xa4, 0x3d, 0x14, 0xa6,
0x59, 0x9b, 0x1f, 0x65, 0x4c, 0xb4, 0x5a, 0x74,
0xe3, 0x55, 0xa5
};
START_TEST(test_known)
{
unsigned char c[147];
unsigned char m[131];
int clen, mlen;
ck_assert_msg(sizeof(c) == sizeof(m) + crypto_box_MACBYTES * sizeof(unsigned char),
"cyphertext should be crypto_box_MACBYTES bytes longer than plaintext");
ck_assert_msg(sizeof(test_c) == sizeof(c), "sanity check failed");
ck_assert_msg(sizeof(test_m) == sizeof(m), "sanity check failed");
clen = encrypt_data(bobpk, alicesk, nonce, test_m, sizeof(test_m) / sizeof(unsigned char), c);
ck_assert_msg(memcmp(test_c, c, sizeof(c)) == 0, "cyphertext doesn't match test vector");
ck_assert_msg(clen == sizeof(c) / sizeof(unsigned char), "wrong ciphertext length");
mlen = decrypt_data(bobpk, alicesk, nonce, test_c, sizeof(test_c) / sizeof(unsigned char), m);
ck_assert_msg(memcmp(test_m, m, sizeof(m)) == 0, "decrypted text doesn't match test vector");
ck_assert_msg(mlen == sizeof(m) / sizeof(unsigned char), "wrong plaintext length");
}
END_TEST
START_TEST(test_fast_known)
{
unsigned char k[crypto_box_BEFORENMBYTES];
unsigned char c[147];
unsigned char m[131];
int clen, mlen;
encrypt_precompute(bobpk, alicesk, k);
ck_assert_msg(sizeof(c) == sizeof(m) + crypto_box_MACBYTES * sizeof(unsigned char),
"cyphertext should be crypto_box_MACBYTES bytes longer than plaintext");
ck_assert_msg(sizeof(test_c) == sizeof(c), "sanity check failed");
ck_assert_msg(sizeof(test_m) == sizeof(m), "sanity check failed");
clen = encrypt_data_symmetric(k, nonce, test_m, sizeof(test_m) / sizeof(unsigned char), c);
ck_assert_msg(memcmp(test_c, c, sizeof(c)) == 0, "cyphertext doesn't match test vector");
ck_assert_msg(clen == sizeof(c) / sizeof(unsigned char), "wrong ciphertext length");
mlen = decrypt_data_symmetric(k, nonce, test_c, sizeof(test_c) / sizeof(unsigned char), m);
ck_assert_msg(memcmp(test_m, m, sizeof(m)) == 0, "decrypted text doesn't match test vector");
ck_assert_msg(mlen == sizeof(m) / sizeof(unsigned char), "wrong plaintext length");
}
END_TEST
START_TEST(test_endtoend)
{
unsigned char pk1[crypto_box_PUBLICKEYBYTES];
unsigned char sk1[crypto_box_SECRETKEYBYTES];
unsigned char pk2[crypto_box_PUBLICKEYBYTES];
unsigned char sk2[crypto_box_SECRETKEYBYTES];
unsigned char k1[crypto_box_BEFORENMBYTES];
unsigned char k2[crypto_box_BEFORENMBYTES];
unsigned char n[crypto_box_NONCEBYTES];
unsigned char m[500];
unsigned char c1[sizeof(m) + crypto_box_MACBYTES];
unsigned char c2[sizeof(m) + crypto_box_MACBYTES];
unsigned char c3[sizeof(m) + crypto_box_MACBYTES];
unsigned char c4[sizeof(m) + crypto_box_MACBYTES];
unsigned char m1[sizeof(m)];
unsigned char m2[sizeof(m)];
unsigned char m3[sizeof(m)];
unsigned char m4[sizeof(m)];
int mlen;
int c1len, c2len, c3len, c4len;
int m1len, m2len, m3len, m4len;
int testno;
// Test 100 random messages and keypairs
for (testno = 0; testno < 100; testno++) {
//Generate random message (random length from 100 to 500)
mlen = (rand() % 400) + 100;
rand_bytes(m, mlen);
rand_bytes(n, crypto_box_NONCEBYTES);
//Generate keypairs
crypto_box_keypair(pk1, sk1);
crypto_box_keypair(pk2, sk2);
//Precompute shared keys
encrypt_precompute(pk2, sk1, k1);
encrypt_precompute(pk1, sk2, k2);
ck_assert_msg(memcmp(k1, k2, crypto_box_BEFORENMBYTES) == 0, "encrypt_precompute: bad");
//Encrypt all four ways
c1len = encrypt_data(pk2, sk1, n, m, mlen, c1);
c2len = encrypt_data(pk1, sk2, n, m, mlen, c2);
c3len = encrypt_data_symmetric(k1, n, m, mlen, c3);
c4len = encrypt_data_symmetric(k2, n, m, mlen, c4);
ck_assert_msg(c1len == c2len && c1len == c3len && c1len == c4len, "cyphertext lengths differ");
ck_assert_msg(c1len == mlen + (int)crypto_box_MACBYTES, "wrong cyphertext length");
ck_assert_msg(memcmp(c1, c2, c1len) == 0 && memcmp(c1, c3, c1len) == 0
&& memcmp(c1, c4, c1len) == 0, "crypertexts differ");
//Decrypt all four ways
m1len = decrypt_data(pk2, sk1, n, c1, c1len, m1);
m2len = decrypt_data(pk1, sk2, n, c1, c1len, m2);
m3len = decrypt_data_symmetric(k1, n, c1, c1len, m3);
m4len = decrypt_data_symmetric(k2, n, c1, c1len, m4);
ck_assert_msg(m1len == m2len && m1len == m3len && m1len == m4len, "decrypted text lengths differ");
ck_assert_msg(m1len == mlen, "wrong decrypted text length");
ck_assert_msg(memcmp(m1, m2, mlen) == 0 && memcmp(m1, m3, mlen) == 0
&& memcmp(m1, m4, mlen) == 0, "decrypted texts differ");
ck_assert_msg(memcmp(m1, m, mlen) == 0, "wrong decrypted text");
}
}
END_TEST
START_TEST(test_large_data)
{
unsigned char k[crypto_box_BEFORENMBYTES];
unsigned char n[crypto_box_NONCEBYTES];
unsigned char m1[MAX_CRYPTO_PACKET_SIZE - crypto_box_MACBYTES];
unsigned char c1[sizeof(m1) + crypto_box_MACBYTES];
unsigned char m1prime[sizeof(m1)];
unsigned char m2[MAX_CRYPTO_PACKET_SIZE];
unsigned char c2[sizeof(m2) + crypto_box_MACBYTES];
int c1len, c2len;
int m1plen;
//Generate random messages
rand_bytes(m1, sizeof(m1));
rand_bytes(m2, sizeof(m2));
rand_bytes(n, crypto_box_NONCEBYTES);
//Generate key
rand_bytes(k, crypto_box_BEFORENMBYTES);
c1len = encrypt_data_symmetric(k, n, m1, sizeof(m1), c1);
c2len = encrypt_data_symmetric(k, n, m2, sizeof(m2), c2);
ck_assert_msg(c1len == sizeof(m1) + crypto_box_MACBYTES, "could not encrypt");
ck_assert_msg(c2len == sizeof(m2) + crypto_box_MACBYTES, "could not encrypt");
m1plen = decrypt_data_symmetric(k, n, c1, c1len, m1prime);
ck_assert_msg(m1plen == sizeof(m1), "decrypted text lengths differ");
ck_assert_msg(memcmp(m1prime, m1, sizeof(m1)) == 0, "decrypted texts differ");
}
END_TEST
START_TEST(test_large_data_symmetric)
{
unsigned char k[crypto_box_KEYBYTES];
unsigned char n[crypto_box_NONCEBYTES];
unsigned char m1[16 * 16 * 16];
unsigned char c1[sizeof(m1) + crypto_box_MACBYTES];
unsigned char m1prime[sizeof(m1)];
int c1len;
int m1plen;
//Generate random messages
rand_bytes(m1, sizeof(m1));
rand_bytes(n, crypto_box_NONCEBYTES);
//Generate key
new_symmetric_key(k);
c1len = encrypt_data_symmetric(k, n, m1, sizeof(m1), c1);
ck_assert_msg(c1len == sizeof(m1) + crypto_box_MACBYTES, "could not encrypt data");
m1plen = decrypt_data_symmetric(k, n, c1, c1len, m1prime);
ck_assert_msg(m1plen == sizeof(m1), "decrypted text lengths differ");
ck_assert_msg(memcmp(m1prime, m1, sizeof(m1)) == 0, "decrypted texts differ");
}
END_TEST
void increment_nonce_number_cmp(uint8_t *nonce, uint32_t num)
{
uint32_t num1, num2;
memcpy(&num1, nonce + (crypto_box_NONCEBYTES - sizeof(num1)), sizeof(num1));
num1 = ntohl(num1);
num2 = num + num1;
if (num2 < num1) {
uint32_t i;
for (i = crypto_box_NONCEBYTES - sizeof(num1); i != 0; --i) {
++nonce[i - 1];
if (nonce[i - 1] != 0)
break;
}
}
num2 = htonl(num2);
memcpy(nonce + (crypto_box_NONCEBYTES - sizeof(num2)), &num2, sizeof(num2));
}
START_TEST(test_increment_nonce)
{
long long unsigned int i;
uint8_t n[crypto_box_NONCEBYTES];
for (i = 0; i < crypto_box_NONCEBYTES; ++i)
n[i] = rand();
uint8_t n1[crypto_box_NONCEBYTES];
memcpy(n1, n, crypto_box_NONCEBYTES);
for (i = 0; i < (1 << 18); ++i) {
increment_nonce_number_cmp(n, 1);
increment_nonce(n1);
ck_assert_msg(memcmp(n, n1, crypto_box_NONCEBYTES) == 0, "Bad increment_nonce function");
}
for (i = 0; i < (1 << 18); ++i) {
uint32_t r = rand();
increment_nonce_number_cmp(n, r);
increment_nonce_number(n1, r);
ck_assert_msg(memcmp(n, n1, crypto_box_NONCEBYTES) == 0, "Bad increment_nonce_number function");
}
}
END_TEST
Suite *crypto_suite(void)
{
Suite *s = suite_create("Crypto");
DEFTESTCASE(known);
DEFTESTCASE(fast_known);
DEFTESTCASE_SLOW(endtoend, 15); /* waiting up to 15 seconds */
DEFTESTCASE(large_data);
DEFTESTCASE(large_data_symmetric);
DEFTESTCASE_SLOW(increment_nonce, 20);
return s;
}
int main(int argc, char *argv[])
{
srand((unsigned int) time(NULL));
Suite *crypto = crypto_suite();
SRunner *test_runner = srunner_create(crypto);
int number_failed = 0;
srunner_run_all(test_runner, CK_NORMAL);
number_failed = srunner_ntests_failed(test_runner);
srunner_free(test_runner);
return number_failed;
}
================================================
FILE: auto_tests/dht_test.c
================================================
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/param.h>
#include <time.h>
#include "../toxcore/tox.h"
#include "../toxcore/DHT.c"
#include "helpers.h"
#define swap(x,y) do \
{ unsigned char swap_temp[sizeof(x) == sizeof(y) ? (signed)sizeof(x) : -1]; \
memcpy(swap_temp,&y,sizeof(x)); \
memcpy(&y,&x, sizeof(x)); \
memcpy(&x,swap_temp,sizeof(x)); \
} while(0)
void mark_bad(IPPTsPng *ipptp)
{
ipptp->timestamp = unix_time() - 2 * BAD_NODE_TIMEOUT;
ipptp->hardening.routes_requests_ok = 0;
ipptp->hardening.send_nodes_ok = 0;
ipptp->hardening.testing_requests = 0;
}
void mark_possible_bad(IPPTsPng *ipptp)
{
ipptp->timestamp = unix_time();
ipptp->hardening.routes_requests_ok = 0;
ipptp->hardening.send_nodes_ok = 0;
ipptp->hardening.testing_requests = 0;
}
void mark_good(IPPTsPng *ipptp)
{
ipptp->timestamp = unix_time();
ipptp->hardening.routes_requests_ok = (HARDENING_ALL_OK >> 0) & 1;
ipptp->hardening.send_nodes_ok = (HARDENING_ALL_OK >> 1) & 1;
ipptp->hardening.testing_requests = (HARDENING_ALL_OK >> 2) & 1;
}
void mark_all_good(Client_data *list, uint32_t length, uint8_t ipv6)
{
uint32_t i;
for (i = 0; i < length; ++i) {
if (ipv6)
mark_good(&list[i].assoc6);
else
mark_good(&list[i].assoc4);
}
}
/* Returns 1 if public_key has a furthest distance to comp_client_id
than all public_key's in the list */
uint8_t is_furthest(const uint8_t *comp_client_id, Client_data *list, uint32_t length, const uint8_t *public_key)
{
uint32_t i;
for (i = 0; i < length; ++i)
if (id_closest(comp_client_id, public_key, list[i].public_key) == 1)
return 0;
return 1;
}
int client_in_list(Client_data *list, uint32_t length, const uint8_t *public_key)
{
int i;
for (i = 0; i < (int)length; ++i)
if (id_equal(public_key, list[i].public_key))
return i;
return -1;
}
void test_addto_lists_update(DHT *dht,
Client_data *list,
uint32_t length,
IP_Port *ip_port)
{
int used, test, test1, test2, found;
IP_Port test_ipp;
uint8_t test_id[crypto_box_PUBLICKEYBYTES];
uint8_t ipv6 = ip_port->ip.family == AF_INET6 ? 1 : 0;
// check id update for existing ip_port
test = rand() % length;
ipport_copy(&test_ipp, ipv6 ? &list[test].assoc6.ip_port : &list[test].assoc4.ip_port);
randombytes(test_id, sizeof(test_id));
used = addto_lists(dht, test_ipp, test_id);
ck_assert_msg(used >= 1, "Wrong number of added clients");
// it is possible to have ip_port duplicates in the list, so ip_port @ found not always equal to ip_port @ test
found = client_in_list(list, length, test_id);
ck_assert_msg(found >= 0, "Client id is not in the list");
ck_assert_msg(ipport_equal(&test_ipp, ipv6 ? &list[found].assoc6.ip_port : &list[found].assoc4.ip_port),
"Client IP_Port is incorrect");
// check ip_port update for existing id
test = rand() % length;
test_ipp.port = rand() % TOX_PORT_DEFAULT;
id_copy(test_id, list[test].public_key);
used = addto_lists(dht, test_ipp, test_id);
ck_assert_msg(used >= 1, "Wrong number of added clients");
// it is not possible to have id duplicates in the list, so id @ found must be equal id @ test
ck_assert_msg(client_in_list(list, length, test_id) == test, "Client id is not in the list");
ck_assert_msg(ipport_equal(&test_ipp, ipv6 ? &list[test].assoc6.ip_port : &list[test].assoc4.ip_port),
"Client IP_Port is incorrect");
// check ip_port update for existing id and ip_port (... port ... id ...)
test1 = rand() % (length / 2);
test2 = rand() % (length / 2) + length / 2;
ipport_copy(&test_ipp, ipv6 ? &list[test1].assoc6.ip_port : &list[test1].assoc4.ip_port);
id_copy(test_id, list[test2].public_key);
if (ipv6) list[test2].assoc6.ip_port.port = -1;
else list[test2].assoc4.ip_port.port = -1;
used = addto_lists(dht, test_ipp, test_id);
ck_assert_msg(used >= 1, "Wrong number of added clients");
ck_assert_msg(client_in_list(list, length, test_id) == test2, "Client id is not in the list");
ck_assert_msg(ipport_equal(&test_ipp, ipv6 ? &list[test2].assoc6.ip_port : &list[test2].assoc4.ip_port),
"Client IP_Port is incorrect");
// check ip_port update for existing id and ip_port (... id ... port ...)
test1 = rand() % (length / 2);
test2 = rand() % (length / 2) + length / 2;
ipport_copy(&test_ipp, ipv6 ? &list[test2].assoc6.ip_port : &list[test2].assoc4.ip_port);
id_copy(test_id, list[test1].public_key);
if (ipv6) list[test1].assoc6.ip_port.port = -1;
else list[test1].assoc4.ip_port.port = -1;
used = addto_lists(dht, test_ipp, test_id);
ck_assert_msg(used >= 1, "Wrong number of added clients");
ck_assert_msg(client_in_list(list, length, test_id) == test1, "Client id is not in the list");
ck_assert_msg(ipport_equal(&test_ipp, ipv6 ? &list[test1].assoc6.ip_port : &list[test1].assoc4.ip_port),
"Client IP_Port is incorrect");
}
void test_addto_lists_bad(DHT *dht,
Client_data *list,
uint32_t length,
IP_Port *ip_port)
{
// check "bad" clients replacement
int used, test1, test2, test3;
uint8_t public_key[crypto_box_PUBLICKEYBYTES], test_id1[crypto_box_PUBLICKEYBYTES], test_id2[crypto_box_PUBLICKEYBYTES],
test_id3[crypto_box_PUBLICKEYBYTES];
uint8_t ipv6 = ip_port->ip.family == AF_INET6 ? 1 : 0;
randombytes(public_key, sizeof(public_key));
mark_all_good(list, length, ipv6);
test1 = rand() % (length / 3);
test2 = rand() % (length / 3) + length / 3;
test3 = rand() % (length / 3) + 2 * length / 3;
ck_assert_msg(!(test1 == test2 || test1 == test3 || test2 == test3), "Wrong test indices are chosen");
id_copy((uint8_t *)&test_id1, list[test1].public_key);
id_copy((uint8_t *)&test_id2, list[test2].public_key);
id_copy((uint8_t *)&test_id3, list[test3].public_key);
// mark nodes as "bad"
if (ipv6) {
mark_bad(&list[test1].assoc6);
mark_bad(&list[test2].assoc6);
mark_bad(&list[test3].assoc6);
} else {
mark_bad(&list[test1].assoc4);
mark_bad(&list[test2].assoc4);
mark_bad(&list[test3].assoc4);
}
ip_port->port += 1;
used = addto_lists(dht, *ip_port, public_key);
ck_assert_msg(used >= 1, "Wrong number of added clients");
ck_assert_msg(client_in_list(list, length, public_key) >= 0, "Client id is not in the list");
ck_assert_msg(client_in_list(list, length, test_id2) >= 0, "Wrong bad client removed");
ck_assert_msg(client_in_list(list, length, test_id3) >= 0, "Wrong bad client removed");
}
void test_addto_lists_possible_bad(DHT *dht,
Client_data *list,
uint32_t length,
IP_Port *ip_port,
const uint8_t *comp_client_id)
{
// check "possibly bad" clients replacement
int used, test1, test2, test3;
uint8_t public_key[crypto_box_PUBLICKEYBYTES], test_id1[crypto_box_PUBLICKEYBYTES], test_id2[crypto_box_PUBLICKEYBYTES],
test_id3[crypto_box_PUBLICKEYBYTES];
uint8_t ipv6 = ip_port->ip.family == AF_INET6 ? 1 : 0;
randombytes(public_key, sizeof(public_key));
mark_all_good(list, length, ipv6);
test1 = rand() % (length / 3);
test2 = rand() % (length / 3) + length / 3;
test3 = rand() % (length / 3) + 2 * length / 3;
ck_assert_msg(!(test1 == test2 || test1 == test3 || test2 == test3), "Wrong test indices are chosen");
id_copy((uint8_t *)&test_id1, list[test1].public_key);
id_copy((uint8_t *)&test_id2, list[test2].public_key);
id_copy((uint8_t *)&test_id3, list[test3].public_key);
// mark nodes as "possibly bad"
if (ipv6) {
mark_possible_bad(&list[test1].assoc6);
mark_possible_bad(&list[test2].assoc6);
mark_possible_bad(&list[test3].assoc6);
} else {
mark_possible_bad(&list[test1].assoc4);
mark_possible_bad(&list[test2].assoc4);
mark_possible_bad(&list[test3].assoc4);
}
ip_port->port += 1;
used = addto_lists(dht, *ip_port, public_key);
ck_assert_msg(used >= 1, "Wrong number of added clients");
ck_assert_msg(client_in_list(list, length, public_key) >= 0, "Client id is not in the list");
int inlist_id1 = client_in_list(list, length, test_id1) >= 0;
int inlist_id2 = client_in_list(list, length, test_id2) >= 0;
int inlist_id3 = client_in_list(list, length, test_id3) >= 0;
ck_assert_msg(inlist_id1 + inlist_id2 + inlist_id3 == 2, "Wrong client removed");
if (!inlist_id1) {
ck_assert_msg(id_closest(comp_client_id, test_id2, test_id1) == 1,
"Id has been removed but is closer to than another one");
ck_assert_msg(id_closest(comp_client_id, test_id3, test_id1) == 1,
"Id has been removed but is closer to than another one");
} else if (!inlist_id2) {
ck_assert_msg(id_closest(comp_client_id, test_id1, test_id2) == 1,
"Id has been removed but is closer to than another one");
ck_assert_msg(id_closest(comp_client_id, test_id3, test_id2) == 1,
"Id has been removed but is closer to than another one");
} else if (!inlist_id3) {
ck_assert_msg(id_closest(comp_client_id, test_id1, test_id3) == 1,
"Id has been removed but is closer to than another one");
ck_assert_msg(id_closest(comp_client_id, test_id2, test_id3) == 1,
"Id has been removed but is closer to than another one");
}
}
void test_addto_lists_good(DHT *dht,
Client_data *list,
uint32_t length,
IP_Port *ip_port,
const uint8_t *comp_client_id)
{
uint8_t public_key[crypto_box_PUBLICKEYBYTES];
uint8_t ipv6 = ip_port->ip.family == AF_INET6 ? 1 : 0;
mark_all_good(list, length, ipv6);
// check "good" client id replacement
do {
randombytes(public_key, sizeof(public_key));
} while (is_furthest(comp_client_id, list, length, public_key));
ip_port->port += 1;
addto_lists(dht, *ip_port, public_key);
ck_assert_msg(client_in_list(list, length, public_key) >= 0, "Good client id is not in the list");
// check "good" client id skip
do {
randombytes(public_key, sizeof(public_key));
} while (!is_furthest(comp_client_id, list, length, public_key));
ip_port->port += 1;
addto_lists(dht, *ip_port, public_key);
ck_assert_msg(client_in_list(list, length, public_key) == -1, "Good client id is in the list");
}
void test_addto_lists(IP ip)
{
Networking_Core *net = new_networking(ip, TOX_PORT_DEFAULT);
ck_assert_msg(net != 0, "Failed to create Networking_Core");
DHT *dht = new_DHT(net);
ck_assert_msg(dht != 0, "Failed to create DHT");
IP_Port ip_port = { .ip = ip, .port = TOX_PORT_DEFAULT };
uint8_t public_key[crypto_box_PUBLICKEYBYTES];
int i, used;
// check lists filling
for (i = 0; i < MAX(LCLIENT_LIST, MAX_FRIEND_CLIENTS); ++i) {
randombytes(public_key, sizeof(public_key));
used = addto_lists(dht, ip_port, public_key);
ck_assert_msg(used == dht->num_friends + 1, "Wrong number of added clients with existing ip_port");
}
for (i = 0; i < MAX(LCLIENT_LIST, MAX_FRIEND_CLIENTS); ++i) {
ip_port.port += 1;
used = addto_lists(dht, ip_port, public_key);
ck_assert_msg(used == dht->num_friends + 1, "Wrong number of added clients with existing public_key");
}
for (i = 0; i < MAX(LCLIENT_LIST, MAX_FRIEND_CLIENTS); ++i) {
ip_port.port += 1;
randombytes(public_key, sizeof(public_key));
used = addto_lists(dht, ip_port, public_key);
ck_assert_msg(used >= 1, "Wrong number of added clients");
}
/*check: Current behavior if there are two clients with the same id is
* to replace the first ip by the second. */
test_addto_lists_update(dht, dht->close_clientlist, LCLIENT_LIST, &ip_port);
for (i = 0; i < dht->num_friends; ++i)
test_addto_lists_update(dht, dht->friends_list[i].client_list, MAX_FRIEND_CLIENTS, &ip_port);
// check "bad" entries
test_addto_lists_bad(dht, dht->close_clientlist, LCLIENT_LIST, &ip_port);
for (i = 0; i < dht->num_friends; ++i)
test_addto_lists_bad(dht, dht->friends_list[i].client_list, MAX_FRIEND_CLIENTS, &ip_port);
// check "possibly bad" entries
/*
test_addto_lists_possible_bad(dht, dht->close_clientlist, LCLIENT_LIST, &ip_port, dht->self_public_key);
for (i = 0; i < dht->num_friends; ++i)
test_addto_lists_possible_bad(dht, dht->friends_list[i].client_list, MAX_FRIEND_CLIENTS, &ip_port,
dht->friends_list[i].public_key);
*/
// check "good" entries
test_addto_lists_good(dht, dht->close_clientlist, LCLIENT_LIST, &ip_port, dht->self_public_key);
for (i = 0; i < dht->num_friends; ++i)
test_addto_lists_good(dht, dht->friends_list[i].client_list, MAX_FRIEND_CLIENTS, &ip_port,
dht->friends_list[i].public_key);
kill_DHT(dht);
kill_networking(net);
}
START_TEST(test_addto_lists_ipv4)
{
IP ip;
ip_init(&ip, 0);
test_addto_lists(ip);
}
END_TEST
START_TEST(test_addto_lists_ipv6)
{
IP ip;
ip_init(&ip, 1);
test_addto_lists(ip);
}
END_TEST
#define DHT_DEFAULT_PORT (TOX_PORT_DEFAULT + 20)
#define DHT_LIST_LENGTH 128
void print_pk(uint8_t *public_key)
{
uint32_t j;
for (j = 0; j < crypto_box_PUBLICKEYBYTES; j++) {
printf("%02hhX", public_key[j]);
}
printf("\n");
}
void test_add_to_list(uint8_t cmp_list[][crypto_box_PUBLICKEYBYTES + 1], unsigned int length, const uint8_t *pk,
const uint8_t *cmp_pk)
{
uint8_t p_b[crypto_box_PUBLICKEYBYTES];
unsigned int i;
for (i = 0; i < length; ++i) {
if (!cmp_list[i][crypto_box_PUBLICKEYBYTES]) {
memcpy(cmp_list[i], pk, crypto_box_PUBLICKEYBYTES);
cmp_list[i][crypto_box_PUBLICKEYBYTES] = 1;
return;
} else {
if (memcmp(cmp_list[i], pk, crypto_box_PUBLICKEYBYTES) == 0) {
return;
}
}
}
for (i = 0; i < length; ++i) {
if (id_closest(cmp_pk, cmp_list[i], pk) == 2) {
memcpy(p_b, cmp_list[i], crypto_box_PUBLICKEYBYTES);
memcpy(cmp_list[i], pk, crypto_box_PUBLICKEYBYTES);
test_add_to_list(cmp_list, length, p_b, cmp_pk);
break;
}
}
}
#define NUM_DHT 100
void test_list_main()
{
DHT *dhts[NUM_DHT];
uint8_t cmp_list1[NUM_DHT][MAX_FRIEND_CLIENTS][crypto_box_PUBLICKEYBYTES + 1];
memset(cmp_list1, 0, sizeof(cmp_list1));
IP ip;
ip_init(&ip, 1);
unsigned int i, j, k, l;
for (i = 0; i < NUM_DHT; ++i) {
IP ip;
ip_init(&ip, 1);
dhts[i] = new_DHT(new_networking(ip, DHT_DEFAULT_PORT + i));
ck_assert_msg(dhts[i] != 0, "Failed to create dht instances %u", i);
ck_assert_msg(dhts[i]->net->port != DHT_DEFAULT_PORT + i, "Bound to wrong port");
}
for (j = 0; j < NUM_DHT; ++j) {
for (i = 1; i < NUM_DHT; ++i) {
test_add_to_list(cmp_list1[j], MAX_FRIEND_CLIENTS, dhts[(i + j) % NUM_DHT]->self_public_key, dhts[j]->self_public_key);
}
}
for (j = 0; j < NUM_DHT; ++j) {
for (i = 0; i < NUM_DHT; ++i) {
if (i == j)
continue;
IP_Port ip_port;
ip_init(&ip_port.ip, 0);
ip_port.ip.ip4.uint32 = rand();
ip_port.port = rand() % (UINT16_MAX - 1);
++ip_port.port;
addto_lists(dhts[j], ip_port, dhts[i]->self_public_key);
}
}
/*
print_pk(dhts[0]->self_public_key);
for (i = 0; i < MAX_FRIEND_CLIENTS; ++i) {
printf("----Entry %u----\n", i);
print_pk(cmp_list1[i]);
}
*/
unsigned int m_count = 0;
for (l = 0; l < NUM_DHT; ++l) {
for (i = 0; i < MAX_FRIEND_CLIENTS; ++i) {
for (j = 1; j < NUM_DHT; ++j) {
if (memcmp(cmp_list1[l][i], dhts[(l + j) % NUM_DHT]->self_public_key, crypto_box_PUBLICKEYBYTES) != 0)
continue;
unsigned int count = 0;
for (k = 0; k < LCLIENT_LIST; ++k) {
if (memcmp(dhts[l]->self_public_key, dhts[(l + j) % NUM_DHT]->close_clientlist[k].public_key,
crypto_box_PUBLICKEYBYTES) == 0)
++count;
}
if (count != 1) {
print_pk(dhts[l]->self_public_key);
for (k = 0; k < MAX_FRIEND_CLIENTS; ++k) {
printf("----Entry %u----\n", k);
print_pk(cmp_list1[l][k]);
}
for (k = 0; k < LCLIENT_LIST; ++k) {
printf("----Closel %u----\n", k);
print_pk(dhts[(l + j) % NUM_DHT]->close_clientlist[k].public_key);
}
print_pk(dhts[(l + j) % NUM_DHT]->self_public_key);
}
ck_assert_msg(count == 1, "Nodes in search don't know ip of friend. %u %u %u", i, j, count);
Node_format ln[MAX_SENT_NODES];
int n = get_close_nodes(dhts[(l + j) % NUM_DHT], dhts[l]->self_public_key, ln, 0, 1, 0);
ck_assert_msg(n == MAX_SENT_NODES, "bad num close %u | %u %u", n, i, j);
count = 0;
for (k = 0; k < MAX_SENT_NODES; ++k) {
if (memcmp(dhts[l]->self_public_key, ln[k].public_key, crypto_box_PUBLICKEYBYTES) == 0)
++count;
}
ck_assert_msg(count == 1, "Nodes in search don't know ip of friend. %u %u %u", i, j, count);
/*
for (k = 0; k < MAX_SENT_NODES; ++k) {
printf("----gn %u----\n", k);
print_pk(ln[k].public_key);
}*/
++m_count;
}
}
}
ck_assert_msg(m_count == (NUM_DHT) * (MAX_FRIEND_CLIENTS), "Bad count. %u != %u", m_count,
(NUM_DHT) * (MAX_FRIEND_CLIENTS));
for (i = 0; i < NUM_DHT; ++i) {
void *n = dhts[i]->net;
kill_DHT(dhts[i]);
kill_networking(n);
}
}
START_TEST(test_list)
{
unsigned int i;
for (i = 0; i < 10; ++i)
test_list_main();
}
END_TEST
void ip_callback(void *data, int32_t number, IP_Port ip_port)
{
}
#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
#define c_sleep(x) Sleep(1*x)
#else
#include <unistd.h>
#define c_sleep(x) usleep(1000*x)
#endif
#define NUM_DHT_FRIENDS 20
START_TEST(test_DHT_test)
{
uint32_t to_comp = 8394782;
DHT *dhts[NUM_DHT];
unsigned int i, j;
for (i = 0; i < NUM_DHT; ++i) {
IP ip;
ip_init(&ip, 1);
dhts[i] = new_DHT(new_networking(ip, DHT_DEFAULT_PORT + i));
ck_assert_msg(dhts[i] != 0, "Failed to create dht instances %u", i);
ck_assert_msg(dhts[i]->net->port != DHT_DEFAULT_PORT + i, "Bound to wrong port");
}
struct {
uint16_t tox1;
uint16_t tox2;
} pairs[NUM_DHT_FRIENDS];
uint8_t address[TOX_ADDRESS_SIZE];
unsigned int num_f = 0;
for (i = 0; i < NUM_DHT_FRIENDS; ++i) {
loop_top:
pairs[i].tox1 = rand() % NUM_DHT;
pairs[i].tox2 = (pairs[i].tox1 + (rand() % (NUM_DHT - 1)) + 1) % NUM_DHT;
for (j = 0; j < i; ++j) {
if (pairs[j].tox2 == pairs[i].tox2 && pairs[j].tox1 == pairs[i].tox1)
goto loop_top;
}
uint16_t lock_count = 0;
ck_assert_msg(DHT_addfriend(dhts[pairs[i].tox2], dhts[pairs[i].tox1]->self_public_key, &ip_callback, &to_comp, 1337,
&lock_count) == 0, "Failed to add friend");
ck_assert_msg(lock_count == 1, "bad lock count: %u %u", lock_count, i);
}
for (i = 0; i < NUM_DHT; ++i) {
IP_Port ip_port;
ip_init(&ip_port.ip, 1);
ip_port.ip.ip6.uint8[15] = 1;
ip_port.port = htons(DHT_DEFAULT_PORT + i);
DHT_bootstrap(dhts[(i - 1) % NUM_DHT], ip_port, dhts[i]->self_public_key);
}
while (1) {
uint16_t counter = 0;
for (i = 0; i < NUM_DHT_FRIENDS; ++i) {
IP_Port a;
if (DHT_getfriendip(dhts[pairs[i].tox2], dhts[pairs[i].tox1]->self_public_key, &a) == 1)
++counter;
}
if (counter == NUM_DHT_FRIENDS) {
break;
}
for (i = 0; i < NUM_DHT; ++i) {
networking_poll(dhts[i]->net);
do_DHT(dhts[i]);
}
c_sleep(500);
}
for (i = 0; i < NUM_DHT; ++i) {
void *n = dhts[i]->net;
kill_DHT(dhts[i]);
kill_networking(n);
}
}
END_TEST
Suite *dht_suite(void)
{
Suite *s = suite_create("DHT");
//DEFTESTCASE(addto_lists_ipv4);
//DEFTESTCASE(addto_lists_ipv6);
DEFTESTCASE_SLOW(list, 20);
DEFTESTCASE_SLOW(DHT_test, 50);
return s;
}
int main(int argc, char *argv[])
{
srand((unsigned int) time(NULL));
Suite *dht = dht_suite();
SRunner *test_runner = srunner_create(dht);
int number_failed = 0;
//srunner_set_fork_status(test_runner, CK_NOFORK);
srunner_run_all(test_runner, CK_NORMAL);
number_failed = srunner_ntests_failed(test_runner);
srunner_free(test_runner);
return number_failed;
}
================================================
FILE: auto_tests/encryptsave_test.c
================================================
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/types.h>
#include <stdint.h>
#include <string.h>
#include <check.h>
#include <stdlib.h>
#include <time.h>
#include "helpers.h"
#include "../toxcore/tox.h"
#include "../toxencryptsave/toxencryptsave.h"
#include "../toxcore/crypto_core.h"
#ifdef VANILLA_NACL
#include "../toxencryptsave/crypto_pwhash_scryptsalsa208sha256/crypto_pwhash_scryptsalsa208sha256.h"
#endif
unsigned char salt[32] = {0xB1, 0xC2, 0x09, 0xEE, 0x50, 0x6C, 0xF0, 0x20, 0xC4, 0xD6, 0xEB, 0xC0, 0x44, 0x51, 0x3B, 0x60, 0x4B, 0x39, 0x4A, 0xCF, 0x09, 0x53, 0x4F, 0xEA, 0x08, 0x41, 0xFA, 0xCA, 0x66, 0xD2, 0x68, 0x7F};
unsigned char known_key[crypto_box_BEFORENMBYTES] = {0x29, 0x36, 0x1c, 0x9e, 0x65, 0xbb, 0x46, 0x8b, 0xde, 0xa1, 0xac, 0xf, 0xd5, 0x11, 0x81, 0xc8, 0x29, 0x28, 0x17, 0x23, 0xa6, 0xc3, 0x6b, 0x77, 0x2e, 0xd7, 0xd3, 0x10, 0xeb, 0xd2, 0xf7, 0xc8};
char *pw = "hunter2";
unsigned int pwlen = 7;
unsigned char known_key2[crypto_box_BEFORENMBYTES] = {0x7a, 0xfa, 0x95, 0x45, 0x36, 0x8a, 0xa2, 0x5c, 0x40, 0xfd, 0xc0, 0xe2, 0x35, 0x8, 0x7, 0x88, 0xfa, 0xf9, 0x37, 0x86, 0xeb, 0xff, 0x50, 0x4f, 0x3, 0xe2, 0xf6, 0xd9, 0xef, 0x9, 0x17, 0x1};
// same as above, except standard opslimit instead of extra ops limit for test_known_kdf, and hash pw before kdf for compat
/* cause I'm shameless */
void accept_friend_request(Tox *m, const uint8_t *public_key, const uint8_t *data, size_t length, void *userdata)
{
if (*((uint32_t *)userdata) != 974536)
return;
if (length == 7 && memcmp("Gentoo", data, 7) == 0) {
tox_friend_add_norequest(m, public_key, 0);
}
}
START_TEST(test_known_kdf)
{
unsigned char out[crypto_box_BEFORENMBYTES];
crypto_pwhash_scryptsalsa208sha256(out,
crypto_box_BEFORENMBYTES,
pw,
pwlen,
salt,
crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_INTERACTIVE * 8,
crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_INTERACTIVE);
ck_assert_msg(memcmp(out, known_key, crypto_box_BEFORENMBYTES) == 0, "derived key is wrong");
}
END_TEST
START_TEST(test_save_friend)
{
Tox *tox1 = tox_new(0, 0);
Tox *tox2 = tox_new(0, 0);
ck_assert_msg(tox1 || tox2, "Failed to create 2 tox instances");
uint32_t to_compare = 974536;
tox_callback_friend_request(tox2, accept_friend_request, &to_compare);
uint8_t address[TOX_ADDRESS_SIZE];
tox_self_get_address(tox2, address);
uint32_t test = tox_friend_add(tox1, address, (uint8_t *)"Gentoo", 7, 0);
ck_assert_msg(test != UINT32_MAX, "Failed to add friend");
size_t size = tox_get_savedata_size(tox1);
uint8_t data[size];
tox_get_savedata(tox1, data);
size_t size2 = size + TOX_PASS_ENCRYPTION_EXTRA_LENGTH;
uint8_t enc_data[size2];
TOX_ERR_ENCRYPTION error1;
bool ret = tox_pass_encrypt(data, size, "correcthorsebatterystaple", 25, enc_data, &error1);
ck_assert_msg(ret, "failed to encrypted save: %u", error1);
ck_assert_msg(tox_is_data_encrypted(enc_data), "magic number missing");
struct Tox_Options options;
tox_options_default(&options);
options.savedata_type = TOX_SAVEDATA_TYPE_TOX_SAVE;
options.savedata_data = enc_data;
options.savedata_length = size2;
TOX_ERR_NEW err2;
Tox *tox3 = tox_new(&options, &err2);
ck_assert_msg(err2 == TOX_ERR_NEW_LOAD_ENCRYPTED, "wrong error! %u. should fail with %u", err2,
TOX_ERR_NEW_LOAD_ENCRYPTED);
uint8_t dec_data[size];
TOX_ERR_DECRYPTION err3;
ret = tox_pass_decrypt(enc_data, size2, "correcthorsebatterystaple", 25, dec_data, &err3);
ck_assert_msg(ret, "failed to decrypt save: %u", err3);
options.savedata_data = dec_data;
options.savedata_length = size;
tox3 = tox_new(&options, &err2);
ck_assert_msg(err2 == TOX_ERR_NEW_OK, "failed to load from decrypted data: %u", err2);
uint8_t address2[TOX_PUBLIC_KEY_SIZE];
ret = tox_friend_get_public_key(tox3, 0, address2, 0);
ck_assert_msg(ret, "no friends!");
ck_assert_msg(memcmp(address, address2, TOX_PUBLIC_KEY_SIZE) == 0, "addresses don't match!");
size = tox_get_savedata_size(tox3);
uint8_t data2[size];
tox_get_savedata(tox3, data2);
TOX_PASS_KEY key;
memcpy(key.salt, salt, 32);
memcpy(key.key, known_key2, crypto_box_BEFORENMBYTES);
size2 = size + TOX_PASS_ENCRYPTION_EXTRA_LENGTH;
uint8_t encdata2[size2];
ret = tox_pass_key_encrypt(data2, size, &key, encdata2, &error1);
ck_assert_msg(ret, "failed to key encrypt %u", error1);
ck_assert_msg(tox_is_data_encrypted(encdata2), "magic number the second missing");
uint8_t out1[size], out2[size];
ret = tox_pass_decrypt(encdata2, size2, pw, pwlen, out1, &err3);
ck_assert_msg(ret, "failed to pw decrypt %u", err3);
ret = tox_pass_key_decrypt(encdata2, size2, &key, out2, &err3);
ck_assert_msg(ret, "failed to key decrypt %u", err3);
ck_assert_msg(memcmp(out1, out2, size) == 0, "differing output data");
// and now with the code in use (I only bothered with manually to debug this, and it seems a waste
// to remove the manual check now that it's there)
options.savedata_data = out1;
options.savedata_length = size;
Tox *tox4 = tox_new(&options, &err2);
ck_assert_msg(err2 == TOX_ERR_NEW_OK, "failed to new the third");
uint8_t address5[TOX_PUBLIC_KEY_SIZE];
ret = tox_friend_get_public_key(tox4, 0, address5, 0);
ck_assert_msg(ret, "no friends! the third");
ck_assert_msg(memcmp(address, address2, TOX_PUBLIC_KEY_SIZE) == 0, "addresses don't match! the third");
tox_kill(tox1);
tox_kill(tox2);
tox_kill(tox3);
tox_kill(tox4);
}
END_TEST
START_TEST(test_keys)
{
TOX_ERR_ENCRYPTION encerr;
TOX_ERR_DECRYPTION decerr;
TOX_ERR_KEY_DERIVATION keyerr;
TOX_PASS_KEY key;
bool ret = tox_derive_key_from_pass("123qweasdzxc", 12, &key, &keyerr);
ck_assert_msg(ret, "generic failure 1: %u", keyerr);
uint8_t *string = "No Patrick, mayonnaise is not an instrument."; // 44
uint8_t encrypted[44 + TOX_PASS_ENCRYPTION_EXTRA_LENGTH];
ret = tox_pass_key_encrypt(string, 44, &key, encrypted, &encerr);
ck_assert_msg(ret, "generic failure 2: %u", encerr);
uint8_t encrypted2[44 + TOX_PASS_ENCRYPTION_EXTRA_LENGTH];
ret = tox_pass_encrypt(string, 44, "123qweasdzxc", 12, encrypted2, &encerr);
ck_assert_msg(ret, "generic failure 3: %u", encerr);
uint8_t out1[44 + TOX_PASS_ENCRYPTION_EXTRA_LENGTH];
uint8_t out2[44 + TOX_PASS_ENCRYPTION_EXTRA_LENGTH];
ret = tox_pass_key_decrypt(encrypted, 44 + TOX_PASS_ENCRYPTION_EXTRA_LENGTH, &key, out1, &decerr);
ck_assert_msg(ret, "generic failure 4: %u", decerr);
ck_assert_msg(memcmp(out1, string, 44) == 0, "decryption 1 failed");
ret = tox_pass_decrypt(encrypted2, 44 + TOX_PASS_ENCRYPTION_EXTRA_LENGTH, "123qweasdzxc", 12, out2, &decerr);
ck_assert_msg(ret, "generic failure 5: %u", decerr);
ck_assert_msg(memcmp(out2, string, 44) == 0, "decryption 2 failed");
ret = tox_pass_decrypt(encrypted2, 44 + TOX_PASS_ENCRYPTION_EXTRA_LENGTH, NULL, 0, out2, &decerr);
ck_assert_msg(!ret, "Decrypt succeeded with wrong pass");
ck_assert_msg(decerr != TOX_ERR_DECRYPTION_FAILED, "Bad error code %u", decerr);
// test that pass_decrypt can decrypt things from pass_key_encrypt
ret = tox_pass_decrypt(encrypted, 44 + TOX_PASS_ENCRYPTION_EXTRA_LENGTH, "123qweasdzxc", 12, out1, &decerr);
ck_assert_msg(ret, "generic failure 6: %u", decerr);
ck_assert_msg(memcmp(out1, string, 44) == 0, "decryption 3 failed");
uint8_t salt[TOX_PASS_SALT_LENGTH];
ck_assert_msg(tox_get_salt(encrypted, salt), "couldn't get salt");
TOX_PASS_KEY key2;
ret = tox_derive_key_with_salt("123qweasdzxc", 12, salt, &key2, &keyerr);
ck_assert_msg(ret, "generic failure 7: %u", keyerr);
ck_assert_msg(0 == memcmp(&key, &key2, sizeof(TOX_PASS_KEY)), "salt comparison failed");
}
END_TEST
Suite *encryptsave_suite(void)
{
Suite *s = suite_create("encryptsave");
DEFTESTCASE_SLOW(known_kdf, 60);
DEFTESTCASE_SLOW(save_friend, 20);
DEFTESTCASE_SLOW(keys, 30);
return s;
}
int main(int argc, char *argv[])
{
srand((unsigned int) time(NULL));
Suite *encryptsave = encryptsave_suite();
SRunner *test_runner = srunner_create(encryptsave);
int number_failed = 0;
srunner_run_all(test_runner, CK_NORMAL);
number_failed = srunner_ntests_failed(test_runner);
srunner_free(test_runner);
return number_failed;
}
================================================
FILE: auto_tests/friends_test.c
================================================
/* Unit testing for friend requests, statuses, and messages.
* Purpose: Check that messaging functions actually do what
* they're supposed to by setting up two local clients.
*
* Design: (Subject to change.)
* 1. Parent sends a friend request, and waits for a response.
* It it doesn't get one, it kills the child.
* 2. Child gets friend request, accepts, then waits for a status change.
* 3. The parent waits on a status change, killing the child if it takes
* too long.
* 4. The child gets the status change, then sends a message. After that,
* it returns. If if doesn't get the status change, it just loops forever.
* 5. After getting the status change, the parent waits for a message, on getting
* one, it waits on the child to return, then returns 0.
*
* Note about "waiting":
* Wait time is decided by WAIT_COUNT and WAIT_TIME. c_sleep(WAIT_TIME) WAIT_COUNT
* times. This is used both to ensure that we don't loop forever on a broken build,
* and that we don't get too slow with messaging. The current time is 15 seconds. */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "../toxcore/friend_requests.h"
#include "../toxcore/Messenger.h"
#include <assert.h>
#include <unistd.h>
#include <sys/mman.h>
#include <signal.h>
#include <sys/wait.h>
#define WAIT_COUNT 30
#define WAIT_TIME 500
#ifndef MAP_ANONYMOUS
#define MAP_ANONYMOUS MAP_ANON
#endif
/* first step, second step */
#define FIRST_FLAG 0x1
#define SECOND_FLAG 0x2
/* ensure that we sleep in milliseconds */
#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
#define c_sleep(x) Sleep(x)
#else
#define c_sleep(x) usleep(1000*x)
#endif
#define PORT 33445
static Messenger *m;
uint8_t *parent_id = NULL;
uint8_t *child_id = NULL;
pid_t child_pid = 0;
int request_flags = 0;
void do_tox(DHT *dht)
{
static int dht_on = 0;
if (!dht_on && DHT_isconnected(dht)) {
dht_on = 1;
} else if (dht_on && !DHT_isconnected(dht)) {
dht_on = 0;
}
doMessenger(m);
}
void parent_confirm_message(Messenger *m, int num, uint8_t *data, uint16_t length, void *userdata)
{
puts("OK");
request_flags |= SECOND_FLAG;
}
void parent_confirm_status(Messenger *m, int num, uint8_t *data, uint16_t length, void *userdata)
{
puts("OK");
request_flags |= FIRST_FLAG;
}
int parent_friend_request(DHT *dht)
{
char *message = "Watson, come here, I need you.";
int len = strlen(message);
int i = 0;
fputs("Sending child request.", stdout);
fflush(stdout);
m_addfriend(m, child_id, (uint8_t *)message, len);
/* wait on the status change */
for (i = 0; i < WAIT_COUNT; i++) {
do_tox(dht);
if (request_flags & FIRST_FLAG)
break;
fputs(".", stdout);
fflush(stdout);
c_sleep(WAIT_TIME);
}
if (!(request_flags & FIRST_FLAG)) {
fputs("\nfriends_test: The child took to long to respond!\n"
"Friend requests may be broken, failing build!\n", stderr);
kill(child_pid, SIGKILL);
return -1;
}
return 0;
}
void child_got_request(Messenger *m, uint8_t *public_key, uint8_t *data, uint16_t length, void *userdata)
{
fputs("OK\nsending status to parent", stdout);
fflush(stdout);
m_addfriend_norequest(m, public_key);
request_flags |= FIRST_FLAG;
}
void child_got_statuschange(Messenger *m, int friend_num, uint8_t *string, uint16_t length, void *userdata)
{
request_flags |= SECOND_FLAG;
}
int parent_wait_for_message(DHT *dht)
{
int i = 0;
fputs("Parent waiting for message.", stdout);
fflush(stdout);
for (i = 0; i < WAIT_COUNT; i++) {
do_tox(dht);
if (request_flags & SECOND_FLAG)
break;
fputs(".", stdout);
fflush(stdout);
c_sleep(WAIT_TIME);
}
if (!(request_flags & SECOND_FLAG)) {
fputs("\nParent hasn't received the message yet!\n"
"Messaging may be broken, failing the build!\n", stderr);
kill(child_pid, SIGKILL);
return -1;
}
return 0;
}
void cleanup(void)
{
munmap(parent_id, crypto_box_PUBLICKEYBYTES);
munmap(child_id, crypto_box_PUBLICKEYBYTES);
puts("============= END TEST =============");
}
int main(int argc, char *argv[])
{
puts("=========== FRIENDS_TEST ===========");
/* set up the global memory */
parent_id = mmap(NULL, crypto_box_PUBLICKEYBYTES, PROT_READ | PROT_WRITE,
MAP_SHARED | MAP_ANONYMOUS, -1, 0);
child_id = mmap(NULL, crypto_box_PUBLICKEYBYTES, PROT_READ | PROT_WRITE,
MAP_SHARED | MAP_ANONYMOUS, -1, 0);
fputs("friends_test: Starting test...\n", stdout);
if ((child_pid = fork()) == 0) {
/* child */
int i = 0;
char *message = "Y-yes Mr. Watson?";
m = initMessenger();
Messenger_save(m, child_id);
msync(child_id, crypto_box_PUBLICKEYBYTES, MS_SYNC);
m_callback_friendrequest(m, child_got_request, NULL);
m_callback_statusmessage(m, child_got_statuschange, NULL);
/* wait on the friend request */
while (!(request_flags & FIRST_FLAG))
do_tox(m->dht);
/* wait for the status change */
while (!(request_flags & SECOND_FLAG))
do_tox(m->dht);
for (i = 0; i < 6; i++) {
/* send the message six times, just to be sure */
m_sendmessage(m, 0, (uint8_t *)message, strlen(message));
do_tox(m->dht);
}
cleanupMessenger(m);
return 0;
}
/* parent */
if (atexit(cleanup) != 0) {
fputs("friends_test: atexit() failed!\nFailing build...\n", stderr);
kill(child_pid, SIGKILL);
return -1;
}
m = initMessenger();
msync(parent_id, crypto_box_PUBLICKEYBYTES, MS_SYNC);
m_callback_statusmessage(m, parent_confirm_status, NULL);
m_callback_friendmessage(m, parent_confirm_message, NULL);
/* hacky way to give the child time to set up */
c_sleep(50);
Messenger_save(m, parent_id);
if (parent_friend_request(m->dht) == -1)
return -1;
if (parent_wait_for_message(m->dht) == -1)
return -1;
wait(NULL);
fputs("friends_test: Build passed!\n", stdout);
return 0;
}
================================================
FILE: auto_tests/helpers.h
================================================
#ifndef TOXCORE_TEST_HELPERS_H
#define TOXCORE_TEST_HELPERS_H
#include <check.h>
#define DEFTESTCASE(NAME) \
TCase *tc_##NAME = tcase_create(#NAME); \
tcase_add_test(tc_##NAME, test_##NAME); \
suite_add_tcase(s, tc_##NAME);
#define DEFTESTCASE_SLOW(NAME, TIMEOUT) \
DEFTESTCASE(NAME) \
tcase_set_timeout(tc_##NAME, TIMEOUT);
#endif // TOXCORE_TEST_HELPERS_H
================================================
FILE: auto_tests/messenger_test.c
================================================
/* unit tests for /core/Messenger.c
* Design:
* Just call every non-static function in Messenger.c, checking that
* they return as they should with check calls. "Bad" calls of the type
* function(bad_data, good_length) are _not_ checked for, this type
* of call is the fault of the client code.
*
* Note:
* None of the functions here test things that rely on the network, i.e.
* checking that status changes are received, messages can be sent, etc.
* All of that is done in a separate test, with two local clients running. */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "../testing/misc_tools.c" // hex_string_to_bin
#include "../toxcore/Messenger.h"
#include <sys/types.h>
#include <stdint.h>
#include <string.h>
#include <check.h>
#include "helpers.h"
#define REALLY_BIG_NUMBER ((1) << (sizeof(uint16_t) * 7))
#define STRINGS_EQUAL(X, Y) (strcmp(X, Y) == 0)
char *friend_id_str = "e4b3d5030bc99494605aecc33ceec8875640c1d74aa32790e821b17e98771c4a00000000f1db";
/* in case we need more than one ID for a test */
char *good_id_a_str = "DB9B569D14850ED8364C3744CAC2C8FF78985D213E980C7C508D0E91E8E45441";
char *good_id_b_str = "d3f14b6d384d8f5f2a66cff637e69f28f539c5de61bc29744785291fa4ef4d64";
char *bad_id_str = "9B569D14ff637e69f2";
unsigned char *friend_id = NULL;
unsigned char *good_id_a = NULL;
unsigned char *good_id_b = NULL;
unsigned char *bad_id = NULL;
int friend_id_num = 0;
Messenger *m;
START_TEST(test_m_sendmesage)
{
char *message = "h-hi :3";
int good_len = strlen(message);
int bad_len = MAX_CRYPTO_PACKET_SIZE;
ck_assert(m_send_message_generic(m, -1, MESSAGE_NORMAL, (uint8_t *)message, good_len, 0) == -1);
ck_assert(m_send_message_generic(m, REALLY_BIG_NUMBER, MESSAGE_NORMAL, (uint8_t *)message, good_len, 0) == -1);
ck_assert(m_send_message_generic(m, 17, MESSAGE_NORMAL, (uint8_t *)message, good_len, 0) == -1);
ck_assert(m_send_message_generic(m, friend_id_num, MESSAGE_NORMAL, (uint8_t *)message, bad_len, 0) == -2);
}
END_TEST
START_TEST(test_m_get_userstatus_size)
{
int rc = 0;
ck_assert_msg((m_get_statusmessage_size(m, -1) == -1),
"m_get_statusmessage_size did NOT catch an argument of -1");
ck_assert_msg((m_get_statusmessage_size(m, REALLY_BIG_NUMBER) == -1),
"m_get_statusmessage_size did NOT catch the following argument: %d\n",
REALLY_BIG_NUMBER);
rc = m_get_statusmessage_size(m, friend_id_num);
/* this WILL error if the original m_addfriend_norequest() failed */
ck_assert_msg((rc >= 0 && rc <= MAX_STATUSMESSAGE_LENGTH),
"m_get_statusmessage_size is returning out of range values! (%i)\n"
"(this can be caused by the error of m_addfriend_norequest"
" in the beginning of the suite)\n", rc);
}
END_TEST
START_TEST(test_m_set_userstatus)
{
char *status = "online!";
uint16_t good_length = strlen(status);
uint16_t bad_length = REALLY_BIG_NUMBER;
ck_assert_msg((m_set_statusmessage(m, (uint8_t *)status, bad_length) == -1),
"m_set_userstatus did NOT catch the following length: %d\n",
REALLY_BIG_NUMBER);
ck_assert_msg((m_set_statusmessage(m, (uint8_t *)status, good_length) == 0),
"m_set_userstatus did NOT return 0 on the following length: %d\n"
"MAX_STATUSMESSAGE_LENGTH: %d\n", good_length, MAX_STATUSMESSAGE_LENGTH);
}
END_TEST
START_TEST(test_m_get_friend_connectionstatus)
{
ck_assert_msg((m_get_friend_connectionstatus(m, -1) == -1),
"m_get_friend_connectionstatus did NOT catch an argument of -1.\n");
ck_assert_msg((m_get_friend_connectionstatus(m, REALLY_BIG_NUMBER) == -1),
"m_get_friend_connectionstatus did NOT catch an argument of %d.\n",
REALLY_BIG_NUMBER);
}
END_TEST
START_TEST(test_m_friend_exists)
{
ck_assert_msg((m_friend_exists(m, -1) == 0),
"m_friend_exists did NOT catch an argument of -1.\n");
ck_assert_msg((m_friend_exists(m, REALLY_BIG_NUMBER) == 0),
"m_friend_exists did NOT catch an argument of %d.\n",
REALLY_BIG_NUMBER);
}
END_TEST
START_TEST(test_m_delfriend)
{
ck_assert_msg((m_delfriend(m, -1) == -1),
"m_delfriend did NOT catch an argument of -1\n");
ck_assert_msg((m_delfriend(m, REALLY_BIG_NUMBER) == -1),
"m_delfriend did NOT catch the following number: %d\n",
REALLY_BIG_NUMBER);
}
END_TEST
/*
START_TEST(test_m_addfriend)
{
char *good_data = "test";
char *bad_data = "";
int good_len = strlen(good_data);
int bad_len = strlen(bad_data);
int really_bad_len = (MAX_CRYPTO_PACKET_SIZE - crypto_box_PUBLICKEYBYTES
- crypto_box_NONCEBYTES - crypto_box_BOXZEROBYTES
+ crypto_box_ZEROBYTES + 100); */
/* TODO: Update this properly to latest master
if(m_addfriend(m, (uint8_t *)friend_id, (uint8_t *)good_data, really_bad_len) != FAERR_TOOLONG)
ck_abort_msg("m_addfriend did NOT catch the following length: %d\n", really_bad_len);
*/
/* this will return an error if the original m_addfriend_norequest() failed */
/* if(m_addfriend(m, (uint8_t *)friend_id, (uint8_t *)good_data, good_len) != FAERR_ALREADYSENT)
ck_abort_msg("m_addfriend did NOT catch adding a friend we already have.\n"
"(this can be caused by the error of m_addfriend_norequest in"
" the beginning of the suite)\n");
if(m_addfriend(m, (uint8_t *)good_id_b, (uint8_t *)bad_data, bad_len) != FAERR_NOMESSAGE)
ck_abort_msg("m_addfriend did NOT catch the following length: %d\n", bad_len);
*/
/* this should REALLY return an error */
/*
* TODO: validate client_id in m_addfriend?
if(m_addfriend((uint8_t *)bad_id, (uint8_t *)good_data, good_len) >= 0)
ck_abort_msg("The following ID passed through "
"m_addfriend without an error:\n'%s'\n", bad_id_str);
}
END_TEST */
START_TEST(test_setname)
{
char *good_name = "consensualCorn";
int good_length = strlen(good_name);
int bad_length = REALLY_BIG_NUMBER;
ck_assert_msg((setname(m, (uint8_t *)good_name, bad_length) == -1),
"setname() did NOT error on %d as a length argument!\n", bad_length);
ck_assert_msg((setname(m, (uint8_t *)good_name, good_length) == 0),
"setname() did NOT return 0 on good arguments!\n");
}
END_TEST
START_TEST(test_getself_name)
{
char *nickname = "testGallop";
int len = strlen(nickname);
char nick_check[len];
setname(m, (uint8_t *)nickname, len);
getself_name(m, (uint8_t *)nick_check);
ck_assert_msg((memcmp(nickname, nick_check, len) == 0),
"getself_name failed to return the known name!\n"
"known name: %s\nreturned: %s\n", nickname, nick_check);
}
END_TEST
/* this test is excluded for now, due to lack of a way
* to set a friend's status for now.
* ideas:
* if we have access to the friends list, we could
* just add a status manually ourselves. */
/*
START_TEST(test_m_copy_userstatus)
{
assert(m_copy_userstatus(-1, buf, MAX_USERSTATUS_LENGTH) == -1);
assert(m_copy_userstatus(REALLY_BIG_NUMBER, buf, MAX_USERSTATUS_LENGTH) == -1);
m_copy_userstatus(friend_id_num, buf, MAX_USERSTATUS_LENGTH + 6);
assert(STRINGS_EQUAL(name_buf, friend_id_status));
}
END_TEST
*/
START_TEST(test_getname)
{
uint8_t name_buf[MAX_NAME_LENGTH];
uint8_t test_name[] = {'f', 'o', 'o'};
ck_assert(getname(m, -1, name_buf) == -1);
ck_assert(getname(m, REALLY_BIG_NUMBER, name_buf) == -1);
memcpy(m->friendlist[0].name, &test_name[0], 3);
m->friendlist[0].name_length = 4;
ck_assert(getname(m, 0, &name_buf[0]) == 4);
ck_assert(strcmp((char *)&name_buf[0], "foo") == 0);
}
END_TEST
START_TEST(test_dht_state_saveloadsave)
{
/* validate that:
* a) saving stays within the confined space
* b) a save()d state can be load()ed back successfully
* c) a second save() is of equal size
* d) the second save() is of equal content */
size_t i, extra = 64;
size_t size = DHT_size(m->dht);
uint8_t buffer[size + 2 * extra];
memset(buffer, 0xCD, extra);
memset(buffer + extra + size, 0xCD, extra);
DHT_save(m->dht, buffer + extra);
for (i = 0; i < extra; i++) {
ck_assert_msg(buffer[i] == 0xCD, "Buffer underwritten from DHT_save() @%u", i);
ck_assert_msg(buffer[extra + size + i] == 0xCD, "Buffer overwritten from DHT_save() @%u", i);
}
int res = DHT_load(m->dht, buffer + extra, size);
if (res == -1)
ck_assert_msg(res == 0, "Failed to load back stored buffer: res == -1");
else {
char msg[128];
size_t offset = res >> 4;
uint8_t *ptr = buffer + extra + offset;
sprintf(msg, "Failed to load back stored buffer: 0x%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx @%zu/%zu, code %d",
ptr[-2], ptr[-1], ptr[0], ptr[1], ptr[2], ptr[3], ptr[4], ptr[5], offset, size, res & 0x0F);
ck_assert_msg(res == 0, msg);
}
size_t size2 = DHT_size(m->dht);
ck_assert_msg(size == size2, "Messenger \"grew\" in size from a store/load cycle: %u -> %u", size, size2);
uint8_t buffer2[size2];
DHT_save(m->dht, buffer2);
ck_assert_msg(!memcmp(buffer + extra, buffer2, size), "DHT state changed by store/load/store cycle");
}
END_TEST
START_TEST(test_messenger_state_saveloadsave)
{
/* validate that:
* a) saving stays within the confined space
* b) a save()d state can be load()ed back successfully
* c) a second save() is of equal size
* d) the second save() is of equal content */
size_t i, extra = 64;
size_t size = messenger_size(m);
uint8_t buffer[size + 2 * extra];
memset(buffer, 0xCD, extra);
memset(buffer + extra + size, 0xCD, extra);
messenger_save(m, buffer + extra);
for (i = 0; i < extra; i++) {
ck_assert_msg(buffer[i] == 0xCD, "Buffer underwritten from messenger_save() @%u", i);
ck_assert_msg(buffer[extra + size + i] == 0xCD, "Buffer overwritten from messenger_save() @%u", i);
}
int res = messenger_load(m, buffer + extra, size);
if (res == -1)
ck_assert_msg(res == 0, "Failed to load back stored buffer: res == -1");
else {
char msg[128];
size_t offset = res >> 4;
uint8_t *ptr = buffer + extra + offset;
sprintf(msg, "Failed to load back stored buffer: 0x%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx @%zu/%zu, code %d",
ptr[-2], ptr[-1], ptr[0], ptr[1], ptr[2], ptr[3], ptr[4], ptr[5], offset, size, res & 0x0F);
ck_assert_msg(res == 0, msg);
}
size_t size2 = messenger_size(m);
ck_assert_msg(size == size2, "Messenger \"grew\" in size from a store/load cycle: %u -> %u", size, size2);
uint8_t buffer2[size2];
messenger_save(m, buffer2);
ck_assert_msg(!memcmp(buffer + extra, buffer2, size), "Messenger state changed by store/load/store cycle");
}
END_TEST
Suite *messenger_suite(void)
{
Suite *s = suite_create("Messenger");
DEFTESTCASE(dht_state_saveloadsave);
DEFTESTCASE(messenger_state_saveloadsave);
DEFTESTCASE(getself_name);
DEFTESTCASE(m_get_userstatus_size);
DEFTESTCASE(m_set_userstatus);
/* DEFTESTCASE(m_addfriend); */
DEFTESTCASE(m_friend_exists);
DEFTESTCASE(m_get_friend_connectionstatus);
DEFTESTCASE(m_delfriend);
DEFTESTCASE(setname);
DEFTESTCASE(getname);
DEFTESTCASE(m_sendmesage);
return s;
}
int main(int argc, char *argv[])
{
Suite *messenger = messenger_suite();
SRunner *test_runner = srunner_create(messenger);
int number_failed = 0;
friend_id = hex_string_to_bin(friend_id_str);
good_id_a = hex_string_to_bin(good_id_a_str);
good_id_b = hex_string_to_bin(good_id_b_str);
bad_id = hex_string_to_bin(bad_id_str);
/* IPv6 status from global define */
Messenger_Options options = {0};
options.ipv6enabled = TOX_ENABLE_IPV6_DEFAULT;
m = new_messenger(&options, 0);
/* setup a default friend and friendnum */
if (m_addfriend_norequest(m, (uint8_t *)friend_id) < 0)
fputs("m_addfriend_norequest() failed on a valid ID!\n"
"this was CRITICAL to the test, and the build WILL fail.\n"
"the tests will continue now...\n\n", stderr);
if ((friend_id_num = getfriend_id(m, (uint8_t *)friend_id)) < 0)
fputs("getfriend_id() failed on a valid ID!\n"
"this was CRITICAL to the test, and the build WILL fail.\n"
"the tests will continue now...\n\n", stderr);
srunner_run_all(test_runner, CK_NORMAL);
number_failed = srunner_ntests_failed(test_runner);
srunner_free(test_runner);
free(friend_id);
free(good_id_a);
free(good_id_b);
free(bad_id);
kill_messenger(m);
return number_failed;
}
================================================
FILE: auto_tests/network_test.c
================================================
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/types.h>
#include <stdint.h>
#include <string.h>
#include <check.h>
#include <stdlib.h>
#include <time.h>
#include "../toxcore/network.h"
#include "helpers.h"
START_TEST(test_addr_resolv_localhost)
{
#ifdef __CYGWIN__
/* force initialization of network stack
* normally this should happen automatically
* cygwin doesn't do it for every network related function though
* e.g. not for getaddrinfo... */
socket(0, 0, 0);
errno = 0;
#endif
const char localhost[] = "localhost";
int localhost_split = 0;
IP ip;
ip_init(&ip, 0); // ipv6enabled = 0
int res = addr_resolve(localhost, &ip, NULL);
ck_assert_msg(res > 0, "Resolver failed: %u, %s (%x, %x)", errno, strerror(errno));
if (res > 0) {
ck_assert_msg(ip.family == AF_INET, "Expected family AF_INET, got %u.", ip.family);
ck_assert_msg(ip.ip4.uint32 == htonl(0x7F000001), "Expected 127.0.0.1, got %s.", inet_ntoa(ip.ip4.in_addr));
}
ip_init(&ip, 1); // ipv6enabled = 1
res = addr_resolve(localhost, &ip, NULL);
if (!(res & TOX_ADDR_RESOLVE_INET6)) {
res = addr_resolve("ip6-localhost", &ip, NULL);
localhost_split = 1;
}
ck_assert_msg(res > 0, "Resolver failed: %u, %s (%x, %x)", errno, strerror(errno));
if (res > 0) {
ck_assert_msg(ip.family == AF_INET6, "Expected family AF_INET6 (%u), got %u.", AF_INET6, ip.family);
ck_assert_msg(!memcmp(&ip.ip6, &in6addr_loopback, sizeof(IP6)), "Expected ::1, got %s.", ip_ntoa(&ip));
}
if (!localhost_split) {
ip_init(&ip, 1); // ipv6enabled = 1
ip.family = AF_UNSPEC;
IP extra;
ip_reset(&extra);
res = addr_resolve(localhost, &ip, &extra);
ck_assert_msg(res > 0, "Resolver failed: %u, %s (%x, %x)", errno, strerror(errno));
if (res > 0) {
ck_assert_msg(ip.family == AF_INET6, "Expected family AF_INET6 (%u), got %u.", AF_INET6, ip.family);
ck_assert_msg(!memcmp(&ip.ip6, &in6addr_loopback, sizeof(IP6)), "Expected ::1, got %s.", ip_ntoa(&ip));
ck_assert_msg(extra.family == AF_INET, "Expected family AF_INET (%u), got %u.", AF_INET, extra.family);
ck_assert_msg(extra.ip4.uint32 == htonl(0x7F000001), "Expected 127.0.0.1, got %s.", inet_ntoa(extra.ip4.in_addr));
}
} else {
printf("Localhost seems to be split in two.\n");
}
}
END_TEST
START_TEST(test_ip_equal)
{
int res;
IP ip1, ip2;
ip_reset(&ip1);
ip_reset(&ip2);
res = ip_equal(NULL, NULL);
ck_assert_msg(res == 0, "ip_equal(NULL, NULL): expected result 0, got %u.", res);
res = ip_equal(&ip1, NULL);
ck_assert_msg(res == 0, "ip_equal(PTR, NULL): expected result 0, got %u.", res);
res = ip_equal(NULL, &ip1);
ck_assert_msg(res == 0, "ip_equal(NULL, PTR): expected result 0, got %u.", res);
ip1.family = AF_INET;
ip1.ip4.uint32 = htonl(0x7F000001);
res = ip_equal(&ip1, &ip2);
ck_assert_msg(res == 0, "ip_equal( {AF_INET, 127.0.0.1}, {AF_UNSPEC, 0} ): expected result 0, got %u.", res);
ip2.family = AF_INET;
ip2.ip4.uint32 = htonl(0x7F000001);
res = ip_equal(&ip1, &ip2);
ck_assert_msg(res != 0, "ip_equal( {AF_INET, 127.0.0.1}, {AF_INET, 127.0.0.1} ): expected result != 0, got 0.");
ip2.ip4.uint32 = htonl(0x7F000002);
res = ip_equal(&ip1, &ip2);
ck_assert_msg(res == 0, "ip_equal( {AF_INET, 127.0.0.1}, {AF_INET, 127.0.0.2} ): expected result 0, got %u.", res);
ip2.family = AF_INET6;
ip2.ip6.uint32[0] = 0;
ip2.ip6.uint32[1] = 0;
ip2.ip6.uint32[2] = htonl(0xFFFF);
ip2.ip6.uint32[3] = htonl(0x7F000001);
ck_assert_msg(IN6_IS_ADDR_V4MAPPED(&ip2.ip6.in6_addr) != 0,
"IN6_IS_ADDR_V4MAPPED(::ffff:127.0.0.1): expected != 0, got 0.");
res = ip_equal(&ip1, &ip2);
ck_assert_msg(res != 0, "ip_equal( {AF_INET, 127.0.0.1}, {AF_INET6, ::ffff:127.0.0.1} ): expected result != 0, got 0.");
memcpy(&ip2.ip6, &in6addr_loopback, sizeof(IP6));
res = ip_equal(&ip1, &ip2);
ck_assert_msg(res == 0, "ip_equal( {AF_INET, 127.0.0.1}, {AF_INET6, ::1} ): expected result 0, got %u.", res);
memcpy(&ip1, &ip2, sizeof(IP));
res = ip_equal(&ip1, &ip2);
ck_assert_msg(res != 0, "ip_equal( {AF_INET6, ::1}, {AF_INET6, ::1} ): expected result != 0, got 0.");
ip2.ip6.uint8[15]++;
res = ip_equal(&ip1, &ip2);
ck_assert_msg(res == 0, "ip_equal( {AF_INET6, ::1}, {AF_INET6, ::2} ): expected result 0, got %res.", res);
}
END_TEST
Suite *network_suite(void)
{
Suite *s = suite_create("Network");
DEFTESTCASE(addr_resolv_localhost);
DEFTESTCASE(ip_equal);
return s;
}
int main()
{
srand((unsigned int) time(NULL));
Suite *network = network_suite();
SRunner *test_runner = srunner_create(network);
int number_failed = 0;
srunner_run_all(test_runner, CK_NORMAL);
number_failed = srunner_ntests_failed(test_runner);
srunner_free(test_runner);
return number_failed;
}
================================================
FILE: auto_tests/onion_test.c
================================================
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/types.h>
#include <stdint.h>
#include <string.h>
#include <check.h>
#include <stdlib.h>
#include <time.h>
#include "../toxcore/onion.h"
#include "../toxcore/onion_announce.h"
#include "../toxcore/onion_client.h"
#include "../toxcore/util.h"
#include "helpers.h"
#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
#define c_sleep(x) Sleep(1*x)
#else
#include <unistd.h>
#define c_sleep(x) usleep(1000*x)
#endif
void do_onion(Onion *onion)
{
networking_poll(onion->net);
do_DHT(onion->dht);
}
static int handled_test_1;
static int handle_test_1(void *object, IP_Port source, const uint8_t *packet, uint16_t length)
{
Onion *onion = object;
if (memcmp(packet, "\x83 Install Gentoo", sizeof("\x83 Install Gentoo")) != 0)
return 1;
if (send_onion_response(onion->net, source, (uint8_t *)"\x84 install gentoo", sizeof("\x84 install gentoo"),
packet + sizeof("\x83 Install Gentoo")) == -1)
return 1;
handled_test_1 = 1;
return 0;
}
static int handled_test_2;
static int handle_test_2(void *object, IP_Port source, const uint8_t *packet, uint16_t length)
{
if (length != sizeof("\x84 install Gentoo"))
return 1;
if (memcmp(packet, (uint8_t *)"\x84 install gentoo", sizeof("\x84 install gentoo")) != 0)
return 1;
handled_test_2 = 1;
return 0;
}
/*
void print_client_id(uint8_t *client_id, uint32_t length)
{
uint32_t j;
for (j = 0; j < length; j++) {
printf("%02hhX", client_id[j]);
}
printf("\n");
}
*/
uint8_t sb_data[ONION_ANNOUNCE_SENDBACK_DATA_LENGTH];
static int handled_test_3;
uint8_t test_3_pub_key[crypto_box_PUBLICKEYBYTES];
uint8_t test_3_ping_id[crypto_hash_sha256_BYTES];
static int handle_test_3(void *object, IP_Port source, const uint8_t *packet, uint16_t length)
{
Onion *onion = object;
if (length != (1 + crypto_box_NONCEBYTES + ONION_ANNOUNCE_SENDBACK_DATA_LENGTH + 1 + crypto_hash_sha256_BYTES +
crypto_box_MACBYTES))
return 1;
uint8_t plain[1 + crypto_hash_sha256_BYTES];
//print_client_id(packet, length);
int len = decrypt_data(test_3_pub_key, onion->dht->self_secret_key, packet + 1 + ONION_ANNOUNCE_SENDBACK_DATA_LENGTH,
packet + 1 + ONION_ANNOUNCE_SENDBACK_DATA_LENGTH + crypto_box_NONCEBYTES,
1 + crypto_hash_sha256_BYTES + crypto_box_MACBYTES, plain);
if (len == -1)
return 1;
if (memcmp(packet + 1, sb_data, ONION_ANNOUNCE_SENDBACK_DATA_LENGTH) != 0)
return 1;
memcpy(test_3_ping_id, plain + 1, crypto_hash_sha256_BYTES);
//print_client_id(test_3_ping_id, sizeof(test_3_ping_id));
handled_test_3 = 1;
return 0;
}
uint8_t nonce[crypto_box_NONCEBYTES];
static int handled_test_4;
static int handle_test_4(void *object, IP_Port source, const uint8_t *packet, uint16_t length)
{
Onion *onion = object;
if (length != (1 + crypto_box_NONCEBYTES + crypto_box_PUBLICKEYBYTES + sizeof("Install gentoo") + crypto_box_MACBYTES))
return 1;
uint8_t plain[sizeof("Install gentoo")] = {0};
if (memcmp(nonce, packet + 1, crypto_box_NONCEBYTES) != 0)
return 1;
int len = decrypt_data(packet + 1 + crypto_box_NONCEBYTES, onion->dht->self_secret_key, packet + 1,
packet + 1 + crypto_box_NONCEBYTES + crypto_box_PUBLICKEYBYTES, sizeof("Install gentoo") + crypto_box_MACBYTES, plain);
if (len == -1)
return 1;
if (memcmp(plain, "Install gentoo", sizeof("Install gentoo")) != 0)
return 1;
handled_test_4 = 1;
return 0;
}
START_TEST(test_basic)
{
IP ip;
ip_init(&ip, 1);
ip.ip6.uint8[15] = 1;
Onion *onion1 = new_onion(new_DHT(new_networking(ip, 34567)));
Onion *onion2 = new_onion(new_DHT(new_networking(ip, 34568)));
ck_assert_msg((onion1 != NULL) && (onion2 != NULL), "Onion failed initializing.");
networking_registerhandler(onion2->net, NET_PACKET_ANNOUNCE_REQUEST, &handle_test_1, onion2);
IP_Port on1 = {ip, onion1->net->port};
Node_format n1;
memcpy(n1.public_key, onion1->dht->self_public_key, crypto_box_PUBLICKEYBYTES);
n1.ip_port = on1;
IP_Port on2 = {ip, onion2->net->port};
Node_format n2;
memcpy(n2.public_key, onion2->dht->self_public_key, crypto_box_PUBLICKEYBYTES);
n2.ip_port = on2;
Node_format nodes[4];
nodes[0] = n1;
nodes[1] = n2;
nodes[2] = n1;
nodes[3] = n2;
Onion_Path path;
create_onion_path(onion1->dht, &path, nodes);
int ret = send_onion_packet(onion1->net, &path, nodes[3].ip_port, (uint8_t *)"\x83 Install Gentoo",
sizeof("\x83 Install Gentoo"));
ck_assert_msg(ret == 0, "Failed to create/send onion packet.");
handled_test_1 = 0;
while (handled_test_1 == 0) {
do_onion(onion1);
do_onion(onion2);
}
networking_registerhandler(onion1->net, NET_PACKET_ANNOUNCE_RESPONSE, &handle_test_2, onion1);
handled_test_2 = 0;
while (handled_test_2 == 0) {
do_onion(onion1);
do_onion(onion2);
}
Onion_Announce *onion1_a = new_onion_announce(onion1->dht);
Onion_Announce *onion2_a = new_onion_announce(onion2->dht);
networking_registerhandler(onion1->net, NET_PACKET_ANNOUNCE_RESPONSE, &handle_test_3, onion1);
ck_assert_msg((onion1_a != NULL) && (onion2_a != NULL), "Onion_Announce failed initializing.");
uint8_t zeroes[64] = {0};
randombytes(sb_data, sizeof(sb_data));
uint64_t s;
memcpy(&s, sb_data, sizeof(uint64_t));
memcpy(test_3_pub_key, nodes[3].public_key, crypto_box_PUBLICKEYBYTES);
ret = send_announce_request(onion1->net, &path, nodes[3], onion1->dht->self_public_key,
onion1->dht->self_secret_key,
zeroes, onion1->dht->self_public_key, onion1->dht->self_public_key, s);
ck_assert_msg(ret == 0, "Failed to create/send onion announce_request packet.");
handled_test_3 = 0;
while (handled_test_3 == 0) {
do_onion(onion1);
do_onion(onion2);
c_sleep(50);
}
randombytes(sb_data, sizeof(sb_data));
memcpy(&s, sb_data, sizeof(uint64_t));
memcpy(onion2_a->entries[1].public_key, onion2->dht->self_public_key, crypto_box_PUBLICKEYBYTES);
onion2_a->entries[1].time = unix_time();
networking_registerhandler(onion1->net, NET_PACKET_ONION_DATA_RESPONSE, &handle_test_4, onion1);
send_announce_request(onion1->net, &path, nodes[3], onion1->dht->self_public_key, onion1->dht->self_secret_key,
test_3_ping_id, onion1->dht->self_public_key, onion1->dht->self_public_key, s);
while (memcmp(onion2_a->entries[ONION_ANNOUNCE_MAX_ENTRIES - 2].public_key, onion1->dht->self_public_key,
crypto_box_PUBLICKEYBYTES) != 0) {
do_onion(onion1);
do_onion(onion2);
c_sleep(50);
}
c_sleep(1000);
Onion *onion3 = new_onion(new_DHT(new_networking(ip, 34569)));
ck_assert_msg((onion3 != NULL), "Onion failed initializing.");
new_nonce(nonce);
ret = send_data_request(onion3->net, &path, nodes[3].ip_port, onion1->dht->self_public_key,
onion1->dht->self_public_key,
nonce, (uint8_t *)"Install gentoo", sizeof("Install gentoo"));
ck_assert_msg(ret == 0, "Failed to create/send onion data_request packet.");
handled_test_4 = 0;
while (handled_test_4 == 0) {
do_onion(onion1);
do_onion(onion2);
c_sleep(50);
}
kill_onion_announce(onion1_a);
kill_onion_announce(onion2_a);
{
Onion *onion = onion1;
Networking_Core *net = onion->dht->net;
DHT *dht = onion->dht;
kill_onion(onion);
kill_DHT(dht);
kill_networking(net);
}
{
Onion *onion = onion2;
Networking_Core *net = onion->dht->net;
DHT *dht = onion->dht;
kill_onion(onion);
kill_DHT(dht);
kill_networking(net);
}
{
Onion *onion = onion3;
Networking_Core *net = onion->dht->net;
DHT *dht = onion->dht;
kill_onion(onion);
kill_DHT(dht);
kill_networking(net);
}
}
END_TEST
typedef struct {
Onion *onion;
Onion_Announce *onion_a;
Onion_Client *onion_c;
} Onions;
Onions *new_onions(uint16_t port)
{
IP ip;
ip_init(&ip, 1);
ip.ip6.uint8[15] = 1;
Onions *on = malloc(sizeof(Onions));
DHT *dht = new_DHT(new_networking(ip, port));
on->onion = new_onion(dht);
on->onion_a = new_onion_announce(dht);
TCP_Proxy_Info inf = {0};
on->onion_c = new_onion_client(new_net_crypto(dht, &inf));
if (on->onion && on->onion_a && on->onion_c)
return on;
return NULL;
}
void do_onions(Onions *on)
{
networking_poll(on->onion->net);
do_DHT(on->onion->dht);
do_onion_client(on->onion_c);
}
void kill_onions(Onions *on)
{
Networking_Core *net = on->onion->dht->net;
DHT *dht = on->onion->dht;
Net_Crypto *c = on->onion_c->c;
kill_onion_client(on->onion_c);
kill_onion_announce(on->onion_a);
kill_onion(on->onion);
kill_net_crypto(c);
kill_DHT(dht);
kill_networking(net);
free(on);
}
#define NUM_ONIONS 50
#define NUM_FIRST 7
#define NUM_LAST 37
_Bool first_ip, last_ip;
void dht_ip_callback(void *object, int32_t number, IP_Port ip_port)
{
if (NUM_FIRST == number) {
first_ip = 1;
return;
}
if (NUM_LAST == number) {
last_ip = 1;
return;
}
ck_abort_msg("Error.");
}
_Bool first, last;
uint8_t first_dht_pk[crypto_box_PUBLICKEYBYTES];
uint8_t last_dht_pk[crypto_box_PUBLICKEYBYTES];
static void dht_pk_callback(void *object, int32_t number, const uint8_t *dht_public_key)
{
if ((NUM_FIRST == number && !first) || (NUM_LAST == number && !last)) {
Onions *on = object;
uint16_t count = 0;
int ret = DHT_addfriend(on->onion->dht, dht_public_key, &dht_ip_callback, object, number, &count);
ck_assert_msg(ret == 0, "DHT_addfriend() did not return 0");
ck_assert_msg(count == 1, "Count not 1, count is %u", count);
if (NUM_FIRST == number && !first) {
first = 1;
if (memcmp(dht_public_key, last_dht_pk, crypto_box_PUBLICKEYBYTES) != 0) {
ck_abort_msg("Error wrong dht key.");
}
return;
}
if (NUM_LAST == number && !last) {
last = 1;
if (memcmp(dht_public_key, first_dht_pk, crypto_box_PUBLICKEYBYTES) != 0) {
ck_abort_msg("Error wrong dht key.");
}
return;
}
ck_abort_msg("Error.");
}
}
START_TEST(test_announce)
{
uint32_t i, j;
Onions *onions[NUM_ONIONS];
for (i = 0; i < NUM_ONIONS; ++i) {
onions[i] = new_onions(i + 34655);
ck_assert_msg(onions[i] != 0, "Failed to create onions. %u");
}
IP ip;
ip_init(&ip, 1);
ip.ip6.uint8[15] = 1;
for (i = 3; i < NUM_ONIONS; ++i) {
IP_Port ip_port = {ip, onions[i - 1]->onion->net->port};
DHT_bootstrap(onions[i]->onion->dht, ip_port, onions[i - 1]->onion->dht->self_public_key);
IP_Port ip_port1 = {ip, onions[i - 2]->onion->net->port};
DHT_bootstrap(onions[i]->onion->dht, ip_port1, onions[i - 2]->onion->dht->self_public_key);
IP_Port ip_port2 = {ip, onions[i - 3]->onion->net->port};
DHT_bootstrap(onions[i]->onion->dht, ip_port2, onions[i - 3]->onion->dht->self_public_key);
}
uint32_t connected = 0;
while (connected != NUM_ONIONS) {
connected = 0;
for (i = 0; i < NUM_ONIONS; ++i) {
do_onions(onions[i]);
connected += DHT_isconnected(onions[i]->onion->dht);
}
c_sleep(50);
}
printf("connected\n");
for (i = 0; i < 25 * 2; ++i) {
for (j = 0; j < NUM_ONIONS; ++j) {
do_onions(onions[j]);
}
c_sleep(50);
}
memcpy(first_dht_pk, onions[NUM_FIRST]->onion->dht->self_public_key, crypto_box_PUBLICKEYBYTES);
memcpy(last_dht_pk, onions[NUM_LAST]->onion->dht->self_public_key, crypto_box_PUBLICKEYBYTES);
printf("adding friend\n");
int frnum_f = onion_addfriend(onions[NUM_FIRST]->onion_c, onions[NUM_LAST]->onion_c->c->self_public_key);
int frnum = onion_addfriend(onions[NUM_LAST]->onion_c, onions[NUM_FIRST]->onion_c->c->self_public_key);
onion_dht_pk_callback(onions[NUM_FIRST]->onion_c, frnum_f, &dht_pk_callback, onions[NUM_FIRST], NUM_FIRST);
onion_dht_pk_callback(onions[NUM_LAST]->onion_c, frnum, &dht_pk_callback, onions[NUM_LAST], NUM_LAST);
int ok = -1;
IP_Port ip_port;
while (!first || !last) {
for (i = 0; i < NUM_ONIONS; ++i) {
do_onions(onions[i]);
}
c_sleep(50);
}
printf("Waiting for ips\n");
while (!first_ip || !last_ip) {
for (i = 0; i < NUM_ONIONS; ++i) {
do_onions(onions[i]);
}
c_sleep(50);
}
onion_getfriendip(onions[NUM_LAST]->onion_c, frnum, &ip_port);
ck_assert_msg(ip_port.port == onions[NUM_FIRST]->onion->net->port, "Port in returned ip not correct.");
for (i = 0; i < NUM_ONIONS; ++i) {
kill_onions(onions[i]);
}
}
END_TEST
Suite *onion_suite(void)
{
Suite *s = suite_create("Onion");
DEFTESTCASE_SLOW(basic, 5);
DEFTESTCASE_SLOW(announce, 70);
return s;
}
int main(int argc, char *argv[])
{
srand((unsigned int) time(NULL));
Suite *onion = onion_suite();
SRunner *test_runner = srunner_create(onion);
int number_failed = 0;
srunner_run_all(test_runner, CK_NORMAL);
number_failed = srunner_ntests_failed(test_runner);
srunner_free(test_runner);
return number_failed;
}
================================================
FILE: auto_tests/skeleton_test.c
================================================
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/types.h>
#include <stdint.h>
#include <string.h>
#include <check.h>
#include <stdlib.h>
#include <time.h>
#include "helpers.h"
/*
#include "../<stuff to test>"
*/
START_TEST(test_creativetestnamegoeshere)
{
uint8_t test = 0;
ck_assert_msg(test == 0, "test: expected result 0, got %u.", test);
}
END_TEST
Suite *creativesuitenamegoeshere_suite(void)
{
Suite *s = suite_create("creativesuitedescritptiongoeshere");
DEFTESTCASE(/* remove test_ from test function names */ creativetestnamegoeshere);
return s;
}
int main(int argc, char *argv[])
{
srand((unsigned int) time(NULL));
Suite *creativesuitenamegoeshere = creativesuitenamegoeshere_suite();
SRunner *test_runner = srunner_create(creativesuitenamegoeshere);
int number_failed = 0;
srunner_run_all(test_runner, CK_NORMAL);
number_failed = srunner_ntests_failed(test_runner);
srunner_free(test_runner);
return number_failed;
}
================================================
FILE: auto_tests/tox_test.c
================================================
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/types.h>
#include <stdint.h>
#include <string.h>
#include <stdio.h>
#include <check.h>
#include <stdlib.h>
#include <time.h>
#include "../toxcore/tox.h"
#include "helpers.h"
#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
#define c_sleep(x) Sleep(1*x)
#else
#include <unistd.h>
#define c_sleep(x) usleep(1000*x)
#endif
void accept_friend_request(Tox *m, const uint8_t *public_key, const uint8_t *data, size_t length, void *userdata)
{
if (*((uint32_t *)userdata) != 974536)
return;
if (length == 7 && memcmp("Gentoo", data, 7) == 0) {
tox_friend_add_norequest(m, public_key, 0);
}
}
uint32_t messages_received;
void print_message(Tox *m, uint32_t friendnumber, TOX_MESSAGE_TYPE type, const uint8_t *string, size_t length,
void *userdata)
{
if (*((uint32_t *)userdata) != 974536)
return;
if (type != TOX_MESSAGE_TYPE_NORMAL) {
ck_abort_msg("Bad type");
}
uint8_t cmp_msg[TOX_MAX_MESSAGE_LENGTH];
memset(cmp_msg, 'G', sizeof(cmp_msg));
if (length == TOX_MAX_MESSAGE_LENGTH && memcmp(string, cmp_msg, sizeof(cmp_msg)) == 0)
++messages_received;
}
uint32_t name_changes;
void print_nickchange(Tox *m, uint32_t friendnumber, const uint8_t *string, size_t length, void *userdata)
{
if (*((uint32_t *)userdata) != 974536)
return;
if (length == sizeof("Gentoo") && memcmp(string, "Gentoo", sizeof("Gentoo")) == 0)
++name_changes;
}
uint32_t status_m_changes;
void print_status_m_change(Tox *tox, uint32_t friend_number, const uint8_t *message, size_t length, void *user_data)
{
if (*((uint32_t *)user_data) != 974536)
return;
if (length == sizeof("Installing Gentoo") && memcmp(message, "Installing Gentoo", sizeof("Installing Gentoo")) == 0)
++status_m_changes;
}
uint32_t typing_changes;
void print_typingchange(Tox *m, uint32_t friendnumber, bool typing, void *userdata)
{
if (*((uint32_t *)userdata) != 974536)
return;
if (!typing)
typing_changes = 1;
else
typing_changes = 2;
}
uint32_t custom_packet;
void handle_custom_packet(Tox *m, uint32_t friend_num, const uint8_t *data, size_t len, void *object)
{
uint8_t number = *((uint32_t *)object);
if (len != TOX_MAX_CUSTOM_PACKET_SIZE)
return;
uint8_t f_data[len];
memset(f_data, number, len);
if (memcmp(f_data, data, len) == 0) {
++custom_packet;
} else {
ck_abort_msg("Custom packet fail. %u", number);
}
return;
}
uint64_t size_recv;
uint64_t sending_pos;
uint8_t file_cmp_id[TOX_FILE_ID_LENGTH];
uint8_t filenum;
uint32_t file_accepted;
uint64_t file_size;
void tox_file_receive(Tox *tox, uint32_t friend_number, uint32_t file_number, uint32_t kind, uint64_t filesize,
const uint8_t *filename, size_t filename_length, void *userdata)
{
if (*((uint32_t *)userdata) != 974536)
return;
if (kind != TOX_FILE_KIND_DATA) {
ck_abort_msg("Bad kind");
return;
}
if (!(filename_length == sizeof("Gentoo.exe") && memcmp(filename, "Gentoo.exe", sizeof("Gentoo.exe")) == 0)) {
ck_abort_msg("Bad filename");
return;
}
uint8_t file_id[TOX_FILE_ID_LENGTH];
if (!tox_file_get_file_id(tox, friend_number, file_number, file_id, 0)) {
ck_abort_msg("tox_file_get_file_id error");
}
if (memcmp(file_id, file_cmp_id, TOX_FILE_ID_LENGTH) != 0) {
ck_abort_msg("bad file_id");
}
uint8_t empty[TOX_FILE_ID_LENGTH] = {0};
if (memcmp(empty, file_cmp_id, TOX_FILE_ID_LENGTH) == 0) {
ck_abort_msg("empty file_id");
}
file_size = filesize;
if (filesize) {
sending_pos = size_recv = 1337;
TOX_ERR_FILE_SEEK err_s;
if (!tox_file_seek(tox, friend_number, file_number, 1337, &err_s)) {
ck_abort_msg("tox_file_seek error");
}
ck_assert_msg(err_s == TOX_ERR_FILE_SEEK_OK, "tox_file_seek wrong error");
} else {
sending_pos = size_recv = 0;
}
TOX_ERR_FILE_CONTROL error;
if (tox_file_control(tox, friend_number, file_number, TOX_FILE_CONTROL_RESUME, &error)) {
++file_accepted;
} else {
ck_abort_msg("tox_file_control failed. %i", error);
}
TOX_ERR_FILE_SEEK err_s;
if (tox_file_seek(tox, friend_number, file_number, 1234, &err_s)) {
ck_abort_msg("tox_file_seek no error");
}
ck_assert_msg(err_s == TOX_ERR_FILE_SEEK_DENIED, "tox_file_seek wrong error");
}
uint32_t sendf_ok;
void file_print_control(Tox *tox, uint32_t friend_number, uint32_t file_number, TOX_FILE_CONTROL control,
void *userdata)
{
if (*((uint32_t *)userdata) != 974536)
return;
/* First send file num is 0.*/
if (file_number == 0 && control == TOX_FILE_CONTROL_RESUME)
sendf_ok = 1;
}
uint64_t max_sending;
_Bool m_send_reached;
uint8_t sending_num;
_Bool file_sending_done;
void tox_file_chunk_request(Tox *tox, uint32_t friend_number, uint32_t file_number, uint64_t position, size_t length,
void *user_data)
{
if (*((uint32_t *)user_data) != 974536)
return;
if (!sendf_ok) {
ck_abort_msg("Didn't get resume control");
}
if (sending_pos != position) {
ck_abort_msg("Bad position %llu", position);
return;
}
if (length == 0) {
if (file_sending_done) {
ck_abort_msg("File sending already done.");
}
file_sending_done = 1;
return;
}
if (position + length > max_sending) {
if (m_send_reached) {
ck_abort_msg("Requested done file tranfer.");
}
length = max_sending - position;
m_send_reached = 1;
}
TOX_ERR_FILE_SEND_CHUNK error;
uint8_t f_data[length];
memset(f_data, sending_num, length);
if (tox_file_send_chunk(tox, friend_number, file_number, position, f_data, length, &error)) {
++sending_num;
sending_pos += length;
} else {
ck_abort_msg("Could not send chunk %i", error);
}
if (error != TOX_ERR_FILE_SEND_CHUNK_OK) {
ck_abort_msg("Wrong error code");
}
}
uint8_t num;
_Bool file_recv;
void write_file(Tox *tox, uint32_t friendnumber, uint32_t filenumber, uint64_t position, const uint8_t *data,
size_t length, void *user_data)
{
if (*((uint32_t *)user_data) != 974536)
return;
if (size_recv != position) {
ck_abort_msg("Bad position");
return;
}
if (length == 0) {
file_recv = 1;
return;
}
uint8_t f_data[length];
memset(f_data, num, length);
++num;
if (memcmp(f_data, data, length) == 0) {
size_recv += length;
} else {
ck_abort_msg("FILE_CORRUPTED");
}
}
unsigned int connected_t1;
void tox_connection_status(Tox *tox, TOX_CONNECTION connection_status, void *user_data)
{
if (*((uint32_t *)user_data) != 974536)
return;
if (connected_t1 && !connection_status)
ck_abort_msg("Tox went offline");
ck_assert_msg(connection_status == TOX_CONNECTION_UDP, "wrong status %u", connection_status);
connected_t1 = connection_status;
}
START_TEST(test_one)
{
{
TOX_ERR_OPTIONS_NEW o_err;
struct Tox_Options *o1 = tox_options_new(&o_err);
struct Tox_Options o2;
tox_options_default(&o2);
ck_assert_msg(o_err == TOX_ERR_OPTIONS_NEW_OK, "tox_options_new wrong error");
ck_assert_msg(memcmp(o1, &o2, sizeof(struct Tox_Options)) == 0, "tox_options_new error");
tox_options_free(o1);
}
Tox *tox1 = tox_new(0, 0);
Tox *tox2 = tox_new(0, 0);
{
TOX_ERR_GET_PORT error;
ck_assert_msg(tox_self_get_udp_port(tox1, &error) == 33445, "First Tox instance did not bind to udp port 33445.\n");
ck_assert_msg(error == TOX_ERR_GET_PORT_OK, "wrong error");
}
uint8_t address[TOX_ADDRESS_SIZE];
tox_self_get_address(tox1, address);
TOX_ERR_FRIEND_ADD error;
uint32_t ret = tox_friend_add(tox1, address, (uint8_t *)"m", 1, &error);
ck_assert_msg(ret == UINT32_MAX && error == TOX_ERR_FRIEND_ADD_OWN_KEY, "Adding own address worked.");
tox_self_get_address(tox2, address);
uint8_t message[TOX_MAX_FRIEND_REQUEST_LENGTH + 1];
ret = tox_friend_add(tox1, address, NULL, 0, &error);
ck_assert_msg(ret == UINT32_MAX && error == TOX_ERR_FRIEND_ADD_NULL, "Sending request with no message worked.");
ret = tox_friend_add(tox1, address, message, 0, &error);
ck_assert_msg(ret == UINT32_MAX && error == TOX_ERR_FRIEND_ADD_NO_MESSAGE, "Sending request with no message worked.");
ret = tox_friend_add(tox1, address, message, sizeof(message), &error);
ck_assert_msg(ret == UINT32_MAX && error == TOX_ERR_FRIEND_ADD_TOO_LONG,
"TOX_MAX_FRIEND_REQUEST_LENGTH is too big.");
address[0]++;
ret = tox_friend_add(tox1, address, (uint8_t *)"m", 1, &error);
ck_assert_msg(ret == UINT32_MAX && error == TOX_ERR_FRIEND_ADD_BAD_CHECKSUM,
"Adding address with bad checksum worked.");
tox_self_get_address(tox2, address);
ret = tox_friend_add(tox1, address, message, TOX_MAX_FRIEND_REQUEST_LENGTH, &error);
ck_assert_msg(ret == 0 && error == TOX_ERR_FRIEND_ADD_OK, "Failed to add friend.");
ret = tox_friend_add(tox1, address, message, TOX_MAX_FRIEND_REQUEST_LENGTH, &error);
ck_assert_msg(ret == UINT32_MAX && error == TOX_ERR_FRIEND_ADD_ALREADY_SENT, "Adding friend twice worked.");
uint8_t name[TOX_MAX_NAME_LENGTH];
int i;
for (i = 0; i < TOX_MAX_NAME_LENGTH; ++i) {
name[i] = rand();
}
tox_self_set_name(tox1, name, sizeof(name), 0);
ck_assert_msg(tox_self_get_name_size(tox1) == sizeof(name), "Can't set name of TOX_MAX_NAME_LENGTH");
tox_self_get_address(tox1, address);
size_t save_size = tox_get_savedata_size(tox1);
uint8_t data[save_size];
tox_get_savedata(tox1, data);
tox_kill(tox2);
TOX_ERR_NEW err_n;
struct Tox_Options options;
tox_options_default(&options);
options.savedata_type = TOX_SAVEDATA_TYPE_TOX_SAVE;
options.savedata_data = data;
options.savedata_length = save_size;
tox2 = tox_new(&options, &err_n);
ck_assert_msg(err_n == TOX_ERR_NEW_OK, "Load failed");
ck_assert_msg(tox_self_get_name_size(tox2) == sizeof name, "Wrong name size.");
uint8_t address2[TOX_ADDRESS_SIZE];
tox_self_get_address(tox2, address2);
ck_assert_msg(memcmp(address2, address, TOX_ADDRESS_SIZE) == 0, "Wrong address.");
uint8_t new_name[TOX_MAX_NAME_LENGTH] = { 0 };
tox_self_get_name(tox2, new_name);
ck_assert_msg(memcmp(name, new_name, TOX_MAX_NAME_LENGTH) == 0, "Wrong name");
uint8_t sk[TOX_SECRET_KEY_SIZE];
tox_self_get_secret_key(tox2, sk);
tox_kill(tox2);
tox_options_default(&options);
options.savedata_type = TOX_SAVEDATA_TYPE_SECRET_KEY;
options.savedata_data = sk;
options.savedata_length = sizeof(sk);
tox2 = tox_new(&options, &err_n);
ck_assert_msg(err_n == TOX_ERR_NEW_OK, "Load failed");
uint8_t address3[TOX_ADDRESS_SIZE];
tox_self_get_address(tox2, address3);
ck_assert_msg(memcmp(address3, address, TOX_PUBLIC_KEY_SIZE) == 0, "Wrong public key.");
uint8_t pk[TOX_PUBLIC_KEY_SIZE];
tox_self_get_public_key(tox2, pk);
ck_assert_msg(memcmp(pk, address, TOX_PUBLIC_KEY_SIZE) == 0, "Wrong public key.");
tox_kill(tox1);
tox_kill(tox2);
}
END_TEST
START_TEST(test_few_clients)
{
long long unsigned int con_time, cur_time = time(NULL);
TOX_ERR_NEW t_n_error;
Tox *tox1 = tox_new(0, &t_n_error);
ck_assert_msg(t_n_error == TOX_ERR_NEW_OK, "wrong error");
Tox *tox2 = tox_new(0, &t_n_error);
ck_assert_msg(t_n_error == TOX_ERR_NEW_OK, "wrong error");
Tox *tox3 = tox_new(0, &t_n_error);
ck_assert_msg(t_n_error == TOX_ERR_NEW_OK, "wrong error");
ck_assert_msg(tox1 || tox2 || tox3, "Failed to create 3 tox instances");
{
TOX_ERR_GET_PORT error;
ck_assert_msg(tox_self_get_udp_port(tox1, &error) == 33445, "First Tox instance did not bind to udp port 33445.\n");
ck_assert_msg(error == TOX_ERR_GET_PORT_OK, "wrong error");
}
{
TOX_ERR_GET_PORT error;
ck_assert_msg(tox_self_get_udp_port(tox2, &error) == 33446, "Second Tox instance did not bind to udp port 33446.\n");
ck_assert_msg(error == TOX_ERR_GET_PORT_OK, "wrong error");
}
{
TOX_ERR_GET_PORT error;
ck_assert_msg(tox_self_get_udp_port(tox3, &error) == 33447, "Third Tox instance did not bind to udp port 33447.\n");
ck_assert_msg(error == TOX_ERR_GET_PORT_OK, "wrong error");
}
uint32_t to_compare = 974536;
connected_t1 = 0;
tox_callback_self_connection_status(tox1, tox_connection_status, &to_compare);
tox_callback_friend_request(tox2, accept_friend_request, &to_compare);
uint8_t address[TOX_ADDRESS_SIZE];
tox_self_get_address(tox2, address);
uint32_t test = tox_friend_add(tox3, address, (uint8_t *)"Gentoo", 7, 0);
ck_assert_msg(test == 0, "Failed to add friend error code: %i", test);
uint8_t off = 1;
while (1) {
tox_iterate(tox1);
tox_iterate(tox2);
tox_iterate(tox3);
if (tox_self_get_connection_status(tox1) && tox_self_get_connection_status(tox2)
&& tox_self_get_connection_status(tox3)) {
if (off) {
printf("Toxes are online, took %llu seconds\n", time(NULL) - cur_time);
con_time = time(NULL);
off = 0;
}
if (tox_friend_get_connection_status(tox2, 0, 0) == TOX_CONNECTION_UDP
&& tox_friend_get_connection_status(tox3, 0, 0) == TOX_CONNECTION_UDP)
break;
}
c_sleep(50);
}
ck_assert_msg(connected_t1, "Tox1 isn't connected. %u", connected_t1);
printf("tox clients connected took %llu seconds\n", time(NULL) - con_time);
to_compare = 974536;
tox_callback_friend_message(tox3, print_message, &to_compare);
uint8_t msgs[TOX_MAX_MESSAGE_LENGTH + 1];
memset(msgs, 'G', sizeof(msgs));
TOX_ERR_FRIEND_SEND_MESSAGE errm;
tox_friend_send_message(tox2, 0, TOX_MESSAGE_TYPE_NORMAL, msgs, TOX_MAX_MESSAGE_LENGTH + 1, &errm);
ck_assert_msg(errm == TOX_ERR_FRIEND_SEND_MESSAGE_TOO_LONG, "TOX_MAX_MESSAGE_LENGTH is too small\n");
tox_friend_send_message(tox2, 0, TOX_MESSAGE_TYPE_NORMAL, msgs, TOX_MAX_MESSAGE_LENGTH, &errm);
ck_assert_msg(errm == TOX_ERR_FRIEND_SEND_MESSAGE_OK, "TOX_MAX_MESSAGE_LENGTH is too big\n");
while (1) {
messages_received = 0;
tox_iterate(tox1);
tox_iterate(tox2);
tox_iterate(tox3);
if (messages_received)
break;
c_sleep(50);
}
printf("tox clients messaging succeeded\n");
unsigned int save_size1 = tox_get_savedata_size(tox2);
ck_assert_msg(save_size1 != 0 && save_size1 < 4096, "save is invalid size %u", save_size1);
printf("%u\n", save_size1);
uint8_t save1[save_size1];
tox_get_savedata(tox2, save1);
tox_kill(tox2);
struct Tox_Options options;
tox_options_default(&options);
options.savedata_type = TOX_SAVEDATA_TYPE_TOX_SAVE;
options.savedata_data = save1;
options.savedata_length = save_size1;
tox2 = tox_new(&options, NULL);
cur_time = time(NULL);
off = 1;
while (1) {
tox_iterate(tox1);
tox_iterate(tox2);
tox_iterate(tox3);
if (tox_self_get_connection_status(tox1) && tox_self_get_connection_status(tox2)
&& tox_self_get_connection_status(tox3)) {
if (off) {
printf("Toxes are online again after reloading, took %llu seconds\n", time(NULL) - cur_time);
con_time = time(NULL);
off = 0;
}
if (tox_friend_get_connection_status(tox2, 0, 0) == TOX_CONNECTION_UDP
&& tox_friend_get_connection_status(tox3, 0, 0) == TOX_CONNECTION_UDP)
break;
}
c_sleep(50);
}
printf("tox clients connected took %llu seconds\n", time(NULL) - con_time);
tox_callback_friend_name(tox3, print_nickchange, &to_compare);
TOX_ERR_SET_INFO err_n;
bool succ = tox_self_set_name(tox2, (uint8_t *)"Gentoo", sizeof("Gentoo"), &err_n);
ck_assert_msg(succ && err_n == TOX_ERR_SET_INFO_OK, "tox_self_set_name failed because %u\n", err_n);
while (1) {
name_changes = 0;
tox_iterate(tox1);
tox_iterate(tox2);
tox_iterate(tox3);
if (name_changes)
break;
c_sleep(50);
}
ck_assert_msg(tox_friend_get_name_size(tox3, 0, 0) == sizeof("Gentoo"), "Name length not correct");
uint8_t temp_name[sizeof("Gentoo")];
tox_friend_get_name(tox3, 0, temp_name, 0);
ck_assert_msg(memcmp(temp_name, "Gentoo", sizeof("Gentoo")) == 0, "Name not correct");
tox_callback_friend_status_message(tox3, print_status_m_change, &to_compare);
succ = tox_self_set_status_message(tox2, (uint8_t *)"Installing Gentoo", sizeof("Installing Gentoo"), &err_n);
ck_assert_msg(succ && err_n == TOX_ERR_SET_INFO_OK, "tox_self_set_status_me
gitextract_ltqu1_1u/
├── .gitignore
├── .travis.yml
├── COPYING
├── DONATORS
├── INSTALL.md
├── Makefile.am
├── README.md
├── auto_tests/
│ ├── Makefile.inc
│ ├── TCP_test.c
│ ├── assoc_test.c
│ ├── crypto_test.c
│ ├── dht_test.c
│ ├── encryptsave_test.c
│ ├── friends_test.c
│ ├── helpers.h
│ ├── messenger_test.c
│ ├── network_test.c
│ ├── onion_test.c
│ ├── skeleton_test.c
│ ├── tox_test.c
│ ├── toxav_basic_test.c
│ └── toxav_many_test.c
├── autogen.sh
├── configure.ac
├── dist-build/
│ ├── android-arm.sh
│ ├── android-armv7.sh
│ ├── android-build.sh
│ ├── android-mips.sh
│ └── android-x86.sh
├── docs/
│ ├── Group-Chats.md
│ ├── Hardening.txt
│ ├── Hardening_docs.txt
│ ├── Prevent_Tracking.txt
│ ├── TCP_Network.txt
│ ├── TODO.md
│ ├── Tox_middle_level_network_protocol.txt
│ ├── av_api.md
│ └── updates/
│ ├── Crypto.md
│ ├── DHT.md
│ ├── Spam-Prevention.md
│ └── Symmetric-NAT-Transversal.md
├── libtoxav.pc.in
├── libtoxcore.pc.in
├── m4/
│ └── pkg.m4
├── other/
│ ├── DHT_bootstrap.c
│ ├── DHTnodes
│ ├── Makefile.inc
│ ├── apidsl/
│ │ ├── README.md
│ │ ├── tox.in.h
│ │ └── toxav.in.h
│ ├── astyle/
│ │ ├── README.md
│ │ ├── astylerc
│ │ └── pre-commit
│ ├── bootstrap_daemon/
│ │ ├── README.md
│ │ ├── docker/
│ │ │ ├── Dockerfile
│ │ │ └── get-nodes.py
│ │ ├── src/
│ │ │ ├── Makefile.inc
│ │ │ ├── command_line_arguments.c
│ │ │ ├── command_line_arguments.h
│ │ │ ├── config.c
│ │ │ ├── config_defaults.h
│ │ │ ├── global.h
│ │ │ ├── log.c
│ │ │ ├── log.h
│ │ │ └── tox-bootstrapd.c
│ │ ├── tox-bootstrapd.conf
│ │ ├── tox-bootstrapd.service
│ │ └── tox-bootstrapd.sh
│ ├── bootstrap_node_packets.c
│ ├── bootstrap_node_packets.h
│ ├── fun/
│ │ ├── bootstrap_node_info.py
│ │ ├── cracker.c
│ │ ├── make-funny-savefile.py
│ │ ├── sign.c
│ │ └── strkey.c
│ └── osx_build_script_toxcore.sh
├── super_donators/
│ ├── LittleVulpix
│ ├── grencez_tok5.c
│ └── sir@cmpwn.com
├── testing/
│ ├── DHT_test.c
│ ├── Makefile.inc
│ ├── Messenger_test.c
│ ├── av_test.c
│ ├── dns3_test.c
│ ├── irc_syncbot.c
│ ├── misc_tools.c
│ ├── nTox.c
│ ├── nTox.h
│ ├── tox_shell.c
│ └── tox_sync.c
├── tox.spec.in
├── toxav/
│ ├── Makefile.inc
│ ├── audio.c
│ ├── audio.h
│ ├── bwcontroller.c
│ ├── bwcontroller.h
│ ├── group.c
│ ├── group.h
│ ├── msi.c
│ ├── msi.h
│ ├── rtp.c
│ ├── rtp.h
│ ├── toxav.c
│ ├── toxav.h
│ ├── toxav_old.c
│ ├── video.c
│ └── video.h
├── toxcore/
│ ├── DHT.c
│ ├── DHT.h
│ ├── LAN_discovery.c
│ ├── LAN_discovery.h
│ ├── Makefile.inc
│ ├── Messenger.c
│ ├── Messenger.h
│ ├── TCP_client.c
│ ├── TCP_client.h
│ ├── TCP_connection.c
│ ├── TCP_connection.h
│ ├── TCP_server.c
│ ├── TCP_server.h
│ ├── assoc.c
│ ├── assoc.h
│ ├── crypto_core.c
│ ├── crypto_core.h
│ ├── friend_connection.c
│ ├── friend_connection.h
│ ├── friend_requests.c
│ ├── friend_requests.h
│ ├── group.c
│ ├── group.h
│ ├── list.c
│ ├── list.h
│ ├── logger.c
│ ├── logger.h
│ ├── misc_tools.h
│ ├── net_crypto.c
│ ├── net_crypto.h
│ ├── network.c
│ ├── network.h
│ ├── onion.c
│ ├── onion.h
│ ├── onion_announce.c
│ ├── onion_announce.h
│ ├── onion_client.c
│ ├── onion_client.h
│ ├── ping.c
│ ├── ping.h
│ ├── ping_array.c
│ ├── ping_array.h
│ ├── tox.c
│ ├── tox.h
│ ├── tox_old.h
│ ├── tox_old_code.h
│ ├── util.c
│ └── util.h
├── toxdns/
│ ├── Makefile.inc
│ ├── toxdns.c
│ └── toxdns.h
└── toxencryptsave/
├── Makefile.inc
├── crypto_pwhash_scryptsalsa208sha256/
│ ├── crypto_pwhash_scryptsalsa208sha256.h
│ ├── crypto_scrypt-common.c
│ ├── crypto_scrypt.h
│ ├── export.h
│ ├── nosse/
│ │ └── pwhash_scryptsalsa208sha256_nosse.c
│ ├── note_to_maintainers.txt
│ ├── pbkdf2-sha256.c
│ ├── pbkdf2-sha256.h
│ ├── pwhash_scryptsalsa208sha256.c
│ ├── runtime.c
│ ├── runtime.h
│ ├── scrypt_platform.c
│ ├── sse/
│ │ └── pwhash_scryptsalsa208sha256_sse.c
│ ├── sysendian.h
│ ├── utils.c
│ └── utils.h
├── defines.h
├── toxencryptsave.c
└── toxencryptsave.h
SYMBOL INDEX (1469 symbols across 108 files)
FILE: auto_tests/TCP_test.c
function START_TEST (line 30) | START_TEST(test_basic)
function END_TEST (line 123) | END_TEST
type sec_TCP_con (line 133) | struct sec_TCP_con
type sec_TCP_con (line 135) | struct sec_TCP_con
type sec_TCP_con (line 135) | struct sec_TCP_con
type sockaddr_in6 (line 137) | struct sockaddr_in6
type sockaddr (line 142) | struct sockaddr
function kill_TCP_con (line 179) | void kill_TCP_con(struct sec_TCP_con *con)
function write_packet_TCP_secure_connection (line 185) | int write_packet_TCP_secure_connection(struct sec_TCP_con *con, uint8_t ...
function read_packet_sec_TCP (line 202) | int read_packet_sec_TCP(struct sec_TCP_con *con, uint8_t *data, uint16_t...
function START_TEST (line 212) | START_TEST(test_some)
function response_callback (line 310) | static int response_callback(void *object, uint8_t connection_id, const ...
function status_callback (line 323) | static int status_callback(void *object, uint32_t number, uint8_t connec...
function data_callback (line 337) | static int data_callback(void *object, uint32_t number, uint8_t connecti...
function oob_data_callback (line 358) | static int oob_data_callback(void *object, const uint8_t *public_key, co...
function START_TEST (line 377) | START_TEST(test_client)
function END_TEST (line 476) | END_TEST
function tcp_data_callback (line 514) | static int tcp_data_callback(void *object, int id, const uint8_t *data, ...
function START_TEST (line 533) | START_TEST(test_tcp_connection)
function tcp_oobdata_callback (line 619) | static int tcp_oobdata_callback(void *object, const uint8_t *public_key,...
function START_TEST (line 634) | START_TEST(test_tcp_connection2)
function END_TEST (line 713) | END_TEST
function main (line 728) | int main(int argc, char *argv[])
FILE: auto_tests/assoc_test.c
function START_TEST (line 18) | START_TEST(test_basics)
function END_TEST (line 60) | END_TEST
function END_TEST (line 136) | END_TEST
function main (line 147) | int main(int argc, char *argv[])
FILE: auto_tests/crypto_test.c
function rand_bytes (line 15) | void rand_bytes(uint8_t *b, size_t blen)
function START_TEST (line 88) | START_TEST(test_known)
function END_TEST (line 109) | END_TEST
function END_TEST (line 136) | END_TEST
function END_TEST (line 206) | END_TEST
function END_TEST (line 243) | END_TEST
function END_TEST (line 273) | END_TEST
function START_TEST (line 297) | START_TEST(test_increment_nonce)
function END_TEST (line 323) | END_TEST
function main (line 339) | int main(int argc, char *argv[])
FILE: auto_tests/dht_test.c
function mark_bad (line 21) | void mark_bad(IPPTsPng *ipptp)
function mark_possible_bad (line 29) | void mark_possible_bad(IPPTsPng *ipptp)
function mark_good (line 37) | void mark_good(IPPTsPng *ipptp)
function mark_all_good (line 45) | void mark_all_good(Client_data *list, uint32_t length, uint8_t ipv6)
function is_furthest (line 59) | uint8_t is_furthest(const uint8_t *comp_client_id, Client_data *list, ui...
function client_in_list (line 70) | int client_in_list(Client_data *list, uint32_t length, const uint8_t *pu...
function test_addto_lists_update (line 81) | void test_addto_lists_update(DHT *dht,
function test_addto_lists_bad (line 149) | void test_addto_lists_bad(DHT *dht,
function test_addto_lists_possible_bad (line 192) | void test_addto_lists_possible_bad(DHT *dht,
function test_addto_lists_good (line 257) | void test_addto_lists_good(DHT *dht,
function test_addto_lists (line 287) | void test_addto_lists(IP ip)
function START_TEST (line 351) | START_TEST(test_addto_lists_ipv4)
function END_TEST (line 358) | END_TEST
function print_pk (line 373) | void print_pk(uint8_t *public_key)
function test_add_to_list (line 384) | void test_add_to_list(uint8_t cmp_list[][crypto_box_PUBLICKEYBYTES + 1],...
function test_list_main (line 414) | void test_list_main()
function START_TEST (line 532) | START_TEST(test_list)
function END_TEST (line 539) | END_TEST
function START_TEST (line 557) | START_TEST(test_DHT_test)
function END_TEST (line 634) | END_TEST
function main (line 647) | int main(int argc, char *argv[])
FILE: auto_tests/encryptsave_test.c
function accept_friend_request (line 31) | void accept_friend_request(Tox *m, const uint8_t *public_key, const uint...
function START_TEST (line 41) | START_TEST(test_known_kdf)
function END_TEST (line 53) | END_TEST
function END_TEST (line 135) | END_TEST
function END_TEST (line 182) | END_TEST
function main (line 195) | int main(int argc, char *argv[])
FILE: auto_tests/friends_test.c
function do_tox (line 61) | void do_tox(DHT *dht)
function parent_confirm_message (line 74) | void parent_confirm_message(Messenger *m, int num, uint8_t *data, uint16...
function parent_confirm_status (line 80) | void parent_confirm_status(Messenger *m, int num, uint8_t *data, uint16_...
function parent_friend_request (line 86) | int parent_friend_request(DHT *dht)
function child_got_request (line 119) | void child_got_request(Messenger *m, uint8_t *public_key, uint8_t *data,...
function child_got_statuschange (line 127) | void child_got_statuschange(Messenger *m, int friend_num, uint8_t *strin...
function parent_wait_for_message (line 132) | int parent_wait_for_message(DHT *dht)
function cleanup (line 160) | void cleanup(void)
function main (line 167) | int main(int argc, char *argv[])
FILE: auto_tests/messenger_test.c
function START_TEST (line 46) | START_TEST(test_m_sendmesage)
function END_TEST (line 58) | END_TEST
function END_TEST (line 76) | END_TEST
function END_TEST (line 92) | END_TEST
function END_TEST (line 102) | END_TEST
function END_TEST (line 112) | END_TEST
function END_TEST (line 122) | END_TEST
function END_TEST (line 169) | END_TEST
function END_TEST (line 184) | END_TEST
function END_TEST (line 217) | END_TEST
function END_TEST (line 259) | END_TEST
function END_TEST (line 301) | END_TEST
function main (line 326) | int main(int argc, char *argv[])
FILE: auto_tests/network_test.c
function START_TEST (line 16) | START_TEST(test_addr_resolv_localhost)
function END_TEST (line 76) | END_TEST
function END_TEST (line 135) | END_TEST
function main (line 147) | int main()
FILE: auto_tests/onion_test.c
function do_onion (line 26) | void do_onion(Onion *onion)
function handle_test_1 (line 33) | static int handle_test_1(void *object, IP_Port source, const uint8_t *pa...
function handle_test_2 (line 49) | static int handle_test_2(void *object, IP_Port source, const uint8_t *pa...
function handle_test_3 (line 75) | static int handle_test_3(void *object, IP_Port source, const uint8_t *pa...
function handle_test_4 (line 104) | static int handle_test_4(void *object, IP_Port source, const uint8_t *pa...
function START_TEST (line 129) | START_TEST(test_basic)
function END_TEST (line 261) | END_TEST
function Onions (line 269) | Onions *new_onions(uint16_t port)
function do_onions (line 287) | void do_onions(Onions *on)
function kill_onions (line 294) | void kill_onions(Onions *on)
function dht_ip_callback (line 313) | void dht_ip_callback(void *object, int32_t number, IP_Port ip_port)
function dht_pk_callback (line 332) | static void dht_pk_callback(void *object, int32_t number, const uint8_t ...
function START_TEST (line 365) | START_TEST(test_announce)
function END_TEST (line 450) | END_TEST
function main (line 461) | int main(int argc, char *argv[])
FILE: auto_tests/skeleton_test.c
function START_TEST (line 18) | START_TEST(test_creativetestnamegoeshere)
function END_TEST (line 23) | END_TEST
function main (line 34) | int main(int argc, char *argv[])
FILE: auto_tests/tox_test.c
function accept_friend_request (line 25) | void accept_friend_request(Tox *m, const uint8_t *public_key, const uint...
function print_message (line 36) | void print_message(Tox *m, uint32_t friendnumber, TOX_MESSAGE_TYPE type,...
function print_nickchange (line 55) | void print_nickchange(Tox *m, uint32_t friendnumber, const uint8_t *stri...
function print_status_m_change (line 65) | void print_status_m_change(Tox *tox, uint32_t friend_number, const uint8...
function print_typingchange (line 76) | void print_typingchange(Tox *m, uint32_t friendnumber, bool typing, void...
function handle_custom_packet (line 89) | void handle_custom_packet(Tox *m, uint32_t friend_num, const uint8_t *da...
function tox_file_receive (line 115) | void tox_file_receive(Tox *tox, uint32_t friend_number, uint32_t file_nu...
function file_print_control (line 181) | void file_print_control(Tox *tox, uint32_t friend_number, uint32_t file_...
function tox_file_chunk_request (line 196) | void tox_file_chunk_request(Tox *tox, uint32_t friend_number, uint32_t f...
function write_file (line 248) | void write_file(Tox *tox, uint32_t friendnumber, uint32_t filenumber, ui...
function tox_connection_status (line 276) | void tox_connection_status(Tox *tox, TOX_CONNECTION connection_status, v...
function START_TEST (line 289) | START_TEST(test_one)
function END_TEST (line 392) | END_TEST
function START_TEST (line 812) | START_TEST(test_many_clients)
function START_TEST (line 905) | START_TEST(test_many_clients_tcp)
function START_TEST (line 1000) | START_TEST(test_many_clients_tcp_b)
function g_accept_friend_request (line 1096) | void g_accept_friend_request(Tox *m, const uint8_t *public_key, const ui...
function print_group_invite_callback (line 1109) | void print_group_invite_callback(Tox *tox, int32_t friendnumber, uint8_t...
function print_group_message (line 1133) | void print_group_message(Tox *tox, int groupnumber, int peernumber, cons...
function START_TEST (line 1144) | START_TEST(test_many_group)
function END_TEST (line 1272) | END_TEST
function main (line 1287) | int main(int argc, char *argv[])
FILE: auto_tests/toxav_basic_test.c
type CallControl (line 49) | typedef struct {
function t_toxav_call_cb (line 59) | void t_toxav_call_cb(ToxAV *av, uint32_t friend_number, bool audio_enabl...
function t_toxav_call_state_cb (line 69) | void t_toxav_call_state_cb(ToxAV *av, uint32_t friend_number, uint32_t s...
function t_toxav_receive_video_frame_cb (line 77) | void t_toxav_receive_video_frame_cb(ToxAV *av, uint32_t friend_number,
function t_toxav_receive_audio_frame_cb (line 96) | void t_toxav_receive_audio_frame_cb(ToxAV *av, uint32_t friend_number,
function t_accept_friend_request_cb (line 112) | void t_accept_friend_request_cb(Tox *m, const uint8_t *public_key, const...
function iterate_tox (line 125) | int iterate_tox(Tox *bootstrap, Tox *Alice, Tox *Bob)
function START_TEST (line 136) | START_TEST(test_AV_flows)
function main (line 576) | int main(int argc, char *argv[])
function Suite (line 585) | Suite *tox_suite(void)
function main (line 592) | int main(int argc, char *argv[])
FILE: auto_tests/toxav_many_test.c
type CallControl (line 39) | typedef struct {
type thread_data (line 44) | typedef struct {
function t_toxav_call_cb (line 55) | void t_toxav_call_cb(ToxAV *av, uint32_t friend_number, bool audio_enabl...
function t_toxav_call_state_cb (line 64) | void t_toxav_call_state_cb(ToxAV *av, uint32_t friend_number, uint32_t s...
function t_toxav_receive_video_frame_cb (line 69) | void t_toxav_receive_video_frame_cb(ToxAV *av, uint32_t friend_number,
function t_toxav_receive_audio_frame_cb (line 87) | void t_toxav_receive_audio_frame_cb(ToxAV *av, uint32_t friend_number,
function t_accept_friend_request_cb (line 102) | void t_accept_friend_request_cb(Tox *m, const uint8_t *public_key, const...
function ToxAV (line 115) | ToxAV *setup_av_instance(Tox *tox, CallControl *CC)
function START_TEST (line 207) | START_TEST(test_AV_three_calls)
function main (line 344) | int main(int argc, char *argv[])
function Suite (line 353) | Suite *tox_suite(void)
function main (line 365) | int main(int argc, char *argv[])
FILE: other/DHT_bootstrap.c
function manage_keys (line 61) | void manage_keys(DHT *dht)
function main (line 102) | int main(int argc, char *argv[])
FILE: other/apidsl/tox.in.h
function class (line 126) | class tox {
function this (line 538) | static this new(const options_t *options) {
function namespace (line 747) | inline namespace self {
function error (line 813) | error for set_info {
function namespace (line 822) | inline namespace self {
function namespace (line 925) | namespace friend {
function namespace (line 1113) | namespace friend {
function namespace (line 1139) | namespace friend {
function namespace (line 1371) | namespace send {
function namespace (line 1446) | namespace friend {
type KIND (line 1519) | enum KIND {
function class (line 1549) | class CONTROL {
function control (line 1580) | bool control(uint32_t friend_number, uint32_t file_number, CONTROL contr...
function seek (line 1641) | bool seek(uint32_t friend_number, uint32_t file_number, uint64_t positio...
function namespace (line 1705) | namespace file {
FILE: other/apidsl/toxav.in.h
function class (line 77) | class tox {
function class (line 84) | class toxAV {
function error (line 487) | error for send_frame {
FILE: other/bootstrap_daemon/src/command_line_arguments.c
function print_help (line 38) | void print_help()
function handle_command_line_arguments (line 63) | void handle_command_line_arguments(int argc, char *argv[], char **cfg_fi...
FILE: other/bootstrap_daemon/src/config.c
function parse_tcp_relay_ports_config (line 45) | void parse_tcp_relay_ports_config(config_t *cfg, uint16_t **tcp_relay_po...
function get_general_config (line 145) | int get_general_config(const char *cfg_file_path, char **pid_file_path, ...
function bootstrap_from_config (line 327) | int bootstrap_from_config(const char *cfg_file_path, DHT *dht, int enabl...
FILE: other/bootstrap_daemon/src/log.c
function open_log (line 36) | bool open_log(LOG_BACKEND backend)
function close_log (line 51) | bool close_log()
function level_syslog (line 66) | int level_syslog(LOG_LEVEL level)
function log_syslog (line 82) | void log_syslog(LOG_LEVEL level, const char *format, va_list args)
function FILE (line 87) | FILE *level_stdout(LOG_LEVEL level)
function log_stdout (line 101) | void log_stdout(LOG_LEVEL level, const char *format, va_list args)
function write_log (line 107) | bool write_log(LOG_LEVEL level, const char *format, ...)
FILE: other/bootstrap_daemon/src/log.h
type LOG_BACKEND (line 30) | typedef enum LOG_BACKEND {
type LOG_LEVEL (line 35) | typedef enum LOG_LEVEL {
FILE: other/bootstrap_daemon/src/tox-bootstrapd.c
function manage_keys (line 56) | int manage_keys(DHT *dht, char *keys_file_path)
function print_public_key (line 100) | void print_public_key(const uint8_t *public_key)
function daemonize (line 119) | void daemonize(LOG_BACKEND log_backend, char *pid_file_path)
function main (line 175) | int main(int argc, char *argv[])
FILE: other/bootstrap_node_packets.c
function handle_info_request (line 37) | static int handle_info_request(void *object, IP_Port source, const uint8...
function bootstrap_set_callbacks (line 54) | int bootstrap_set_callbacks(Networking_Core *net, uint32_t version, uint...
FILE: other/fun/bootstrap_node_info.py
function printHelp (line 31) | def printHelp():
FILE: other/fun/cracker.c
function print_key (line 22) | void print_key(uint8_t *client_id)
function main (line 32) | int main(int argc, char *argv[])
FILE: other/fun/make-funny-savefile.py
function abort (line 58) | def abort(msg):
function make_subheader (line 92) | def make_subheader(h_type, h_length):
FILE: other/fun/sign.c
function load_file (line 22) | int load_file(char *filename, char **result)
function main (line 48) | int main(int argc, char *argv[])
FILE: other/fun/strkey.c
function print_key (line 46) | void print_key(unsigned char *key)
function main (line 58) | int main(int argc, char *argv[])
FILE: super_donators/grencez_tok5.c
function main (line 9) | int main(int i, char** msg)
FILE: testing/DHT_test.c
function print_client_id (line 57) | void print_client_id(uint8_t *public_key)
function print_hardening (line 66) | void print_hardening(Hardening *h)
function print_assoc (line 84) | void print_assoc(IPPTsPng *assoc, uint8_t ours)
function print_clientlist (line 103) | void print_clientlist(DHT *dht)
function print_friendlist (line 122) | void print_friendlist(DHT *dht)
function printpacket (line 154) | void printpacket(uint8_t *data, uint32_t length, IP_Port ip_port)
function main (line 170) | int main(int argc, char *argv[])
FILE: testing/Messenger_test.c
function print_message (line 59) | void print_message(Messenger *m, uint32_t friendnumber, unsigned int typ...
function print_request (line 70) | void print_request(Messenger *m, const uint8_t *public_key, const uint8_...
function main (line 97) | int main(int argc, char *argv[])
FILE: testing/av_test.c
type CallControl (line 74) | typedef struct {
type toxav_thread_data (line 82) | struct toxav_thread_data {
type frame (line 91) | typedef struct {
function t_toxav_call_cb (line 121) | void t_toxav_call_cb(ToxAV *av, uint32_t friend_number, bool audio_enabl...
function t_toxav_call_state_cb (line 126) | void t_toxav_call_state_cb(ToxAV *av, uint32_t friend_number, uint32_t s...
function t_toxav_receive_video_frame_cb (line 131) | void t_toxav_receive_video_frame_cb(ToxAV *av, uint32_t friend_number,
function t_toxav_receive_audio_frame_cb (line 168) | void t_toxav_receive_audio_frame_cb(ToxAV *av, uint32_t friend_number,
function t_toxav_bit_rate_status_cb (line 184) | void t_toxav_bit_rate_status_cb(ToxAV *av, uint32_t friend_number,
function t_accept_friend_request_cb (line 190) | void t_accept_friend_request_cb(Tox *m, const uint8_t *public_key, const...
function initialize_tox (line 199) | void initialize_tox(Tox **bootstrap, ToxAV **AliceAV, CallControl *Alice...
function iterate_tox (line 287) | int iterate_tox(Tox *bootstrap, ToxAV *AliceAV, ToxAV *BobAV)
type toxav_thread_data (line 297) | struct toxav_thread_data
function send_opencv_img (line 330) | int send_opencv_img(ToxAV *av, uint32_t friend_number, const IplImage *img)
function print_audio_devices (line 368) | int print_audio_devices()
function print_help (line 381) | int print_help (const char *name)
function main (line 395) | int main (int argc, char **argv)
FILE: testing/dns3_test.c
function create_packet (line 17) | uint32_t create_packet(uint8_t *packet, uint8_t *string, uint8_t str_len...
function main (line 45) | int main(int argc, char *argv[])
FILE: testing/irc_syncbot.c
function get_monotime_sec (line 43) | uint64_t get_monotime_sec(void)
function reconnect (line 48) | int reconnect(void)
function callback_group_invite (line 86) | static void callback_group_invite(Tox *tox, int fid, uint8_t type, const...
function callback_friend_message (line 92) | void callback_friend_message(Tox *tox, uint32_t fid, TOX_MESSAGE_TYPE ty...
function copy_groupmessage (line 109) | static void copy_groupmessage(Tox *tox, int groupnumber, int friendgroup...
function send_irc_group (line 153) | void send_irc_group(Tox *tox, uint8_t *msg, uint16_t len)
function Tox (line 211) | Tox *init_tox(int argc, char *argv[])
function main (line 260) | int main(int argc, char *argv[])
FILE: testing/misc_tools.c
function cmdline_parsefor_ipv46 (line 55) | int cmdline_parsefor_ipv46(int argc, char **argv, uint8_t *ipv6enabled)
FILE: testing/nTox.c
type Friend_request (line 107) | typedef struct {
type File_Sender (line 116) | typedef struct {
function tox_file_chunk_request (line 124) | void tox_file_chunk_request(Tox *tox, uint32_t friend_number, uint32_t f...
function add_filesender (line 151) | uint32_t add_filesender(Tox *m, uint16_t friendnum, char *filename)
function fraddr_to_str (line 179) | static void fraddr_to_str(uint8_t *id_bin, char *id_str)
function get_id (line 204) | void get_id(Tox *m, char *data)
function getfriendname_terminated (line 213) | int getfriendname_terminated(Tox *m, int friendnum, char *namebuf)
function new_lines_mark (line 226) | void new_lines_mark(char *line, uint8_t special)
function new_lines (line 241) | void new_lines(char *line)
function print_friendlist (line 249) | void print_friendlist(Tox *m)
function print_formatted_message (line 284) | static void print_formatted_message(Tox *m, char *message, int friendnum...
function line_eval (line 325) | void line_eval(Tox *m, char *line)
function wrap (line 640) | void wrap(char output[STRING_LENGTH_WRAPPED], char input[STRING_LENGTH],...
function wrap_bars (line 720) | void wrap_bars(char output[STRING_LENGTH_WRAPPED], char input[STRING_LEN...
function count_lines (line 816) | int count_lines(char *string)
function do_refresh (line 841) | void do_refresh()
function print_request (line 871) | void print_request(Tox *m, const uint8_t *public_key, const uint8_t *dat...
function print_message (line 884) | void print_message(Tox *m, uint32_t friendnumber, TOX_MESSAGE_TYPE type,...
function print_nickchange (line 894) | void print_nickchange(Tox *m, uint32_t friendnumber, const uint8_t *stri...
function print_statuschange (line 910) | void print_statuschange(Tox *m, uint32_t friendnumber, const uint8_t *st...
function Tox (line 928) | static Tox *load_data()
function save_data (line 969) | static int save_data(Tox *m)
function save_data_file (line 996) | static int save_data_file(Tox *m, char *path)
function print_help (line 1006) | void print_help(char *prog_name)
function print_invite (line 1017) | void print_invite(Tox *m, int friendnumber, uint8_t type, const uint8_t ...
function print_groupchatpeers (line 1031) | void print_groupchatpeers(Tox *m, int groupnumber)
function print_groupmessage (line 1079) | void print_groupmessage(Tox *m, int groupnumber, int peernumber, const u...
function print_groupnamelistchange (line 1097) | void print_groupnamelistchange(Tox *m, int groupnumber, int peernumber, ...
function file_request_accept (line 1141) | void file_request_accept(Tox *tox, uint32_t friend_number, uint32_t file...
function file_print_control (line 1161) | void file_print_control(Tox *tox, uint32_t friend_number, uint32_t file_...
function write_file (line 1184) | void write_file(Tox *tox, uint32_t friendnumber, uint32_t filenumber, ui...
function print_online (line 1209) | void print_online(Tox *tox, uint32_t friendnumber, TOX_CONNECTION status...
function timeout_getch (line 1225) | char timeout_getch(Tox *m)
function main (line 1250) | int main(int argc, char *argv[])
FILE: testing/tox_shell.c
function print_online (line 48) | void print_online(Tox *tox, uint32_t friendnumber, TOX_CONNECTION status...
function print_message (line 56) | void print_message(Tox *tox, uint32_t friendnumber, TOX_MESSAGE_TYPE typ...
function main (line 64) | int main(int argc, char *argv[])
FILE: testing/tox_sync.c
type File_t (line 47) | typedef struct {
function tox_file_chunk_request (line 56) | void tox_file_chunk_request(Tox *tox, uint32_t friend_number, uint32_t f...
function add_filesender (line 81) | uint32_t add_filesender(Tox *m, uint16_t friendnum, char *filename)
function kill_filesender (line 104) | void kill_filesender(Tox *m, uint32_t filenum)
function not_sending (line 114) | int not_sending()
function file_request_accept (line 127) | void file_request_accept(Tox *tox, uint32_t friend_number, uint32_t file...
function file_print_control (line 172) | void file_print_control(Tox *tox, uint32_t friend_number, uint32_t file_...
function write_file (line 189) | void write_file(Tox *tox, uint32_t friendnumber, uint32_t filenumber, ui...
function print_online (line 210) | void print_online(Tox *tox, uint32_t friendnumber, TOX_CONNECTION status...
function main (line 232) | int main(int argc, char *argv[])
FILE: toxav/audio.c
type JitterBuffer (line 33) | struct JitterBuffer
type JitterBuffer (line 34) | struct JitterBuffer
type JitterBuffer (line 35) | struct JitterBuffer
type JitterBuffer (line 36) | struct JitterBuffer
type RTPMessage (line 36) | struct RTPMessage
type RTPMessage (line 37) | struct RTPMessage
type JitterBuffer (line 37) | struct JitterBuffer
function ACSession (line 45) | ACSession *ac_new(ToxAV *av, uint32_t friend_number, toxav_audio_receive...
function ac_kill (line 109) | void ac_kill(ACSession *ac)
function ac_iterate (line 123) | void ac_iterate(ACSession *ac)
function ac_queue_message (line 191) | int ac_queue_message(void *acp, struct RTPMessage *msg)
function ac_reconfigure_encoder (line 222) | int ac_reconfigure_encoder(ACSession *ac, int32_t bit_rate, int32_t samp...
type JitterBuffer (line 236) | struct JitterBuffer {
type JitterBuffer (line 244) | struct JitterBuffer
type JitterBuffer (line 252) | struct JitterBuffer
type JitterBuffer (line 254) | struct JitterBuffer
type RTPMessage (line 256) | struct RTPMessage
function jbuf_clear (line 265) | static void jbuf_clear(struct JitterBuffer *q)
function jbuf_free (line 274) | static void jbuf_free(struct JitterBuffer *q)
function jbuf_write (line 282) | static int jbuf_write(struct JitterBuffer *q, struct RTPMessage *m)
type RTPMessage (line 308) | struct RTPMessage
type JitterBuffer (line 308) | struct JitterBuffer
type RTPMessage (line 318) | struct RTPMessage
function OpusEncoder (line 334) | OpusEncoder *create_audio_encoder (int32_t bit_rate, int32_t sampling_ra...
function reconfigure_audio_encoder (line 384) | bool reconfigure_audio_encoder(OpusEncoder **e, int32_t new_br, int32_t ...
function reconfigure_audio_decoder (line 414) | bool reconfigure_audio_decoder(ACSession *ac, int32_t sampling_rate, int...
FILE: toxav/audio.h
type RTPMessage (line 32) | struct RTPMessage
type ACSession (line 34) | typedef struct ACSession_s {
type RTPMessage (line 61) | struct RTPMessage
FILE: toxav/bwcontroller.c
type BWController_s (line 40) | struct BWController_s {
function BWController (line 65) | BWController *bwc_new(Messenger *m, uint32_t friendnumber,
function bwc_kill (line 88) | void bwc_kill(BWController *bwc)
function bwc_feed_avg (line 98) | void bwc_feed_avg(BWController *bwc, uint32_t bytes)
function bwc_add_lost (line 107) | void bwc_add_lost(BWController *bwc, uint32_t bytes)
function bwc_add_recv (line 132) | void bwc_add_recv(BWController *bwc, uint32_t bytes)
type BWCMessage (line 142) | struct BWCMessage {
function send_update (line 147) | void send_update(BWController *bwc)
function on_update (line 174) | int on_update (BWController *bwc, struct BWCMessage *msg)
function bwc_handle_data (line 198) | int bwc_handle_data(Messenger *m, uint32_t friendnumber, const uint8_t *...
FILE: toxav/bwcontroller.h
type BWController (line 26) | typedef struct BWController_s BWController;
FILE: toxav/group.c
type Group_Audio_Packet (line 32) | typedef struct {
type Group_JitterBuffer (line 38) | typedef struct {
function Group_JitterBuffer (line 47) | static Group_JitterBuffer *create_queue(unsigned int capacity)
function clear_queue (line 69) | static void clear_queue(Group_JitterBuffer *q)
function terminate_queue (line 79) | static void terminate_queue(Group_JitterBuffer *q)
function queue (line 90) | static int queue(Group_JitterBuffer *q, Group_Audio_Packet *pk)
function Group_Audio_Packet (line 125) | static Group_Audio_Packet *dequeue(Group_JitterBuffer *q, int *success)
type Group_AV (line 152) | typedef struct {
type Group_Peer_AV (line 165) | typedef struct {
function kill_group_av (line 173) | static void kill_group_av(Group_AV *group_av)
function recreate_encoder (line 182) | static int recreate_encoder(Group_AV *group_av)
function Group_AV (line 220) | static Group_AV *new_group_av(Group_Chats *g_c, void (*audio_callback)(M...
function group_av_peer_new (line 239) | static void group_av_peer_new(void *object, int groupnumber, int friendg...
function group_av_peer_delete (line 251) | static void group_av_peer_delete(void *object, int groupnumber, int frie...
function group_av_groupchat_delete (line 265) | static void group_av_groupchat_delete(void *object, int groupnumber)
function decode_audio_packet (line 271) | static int decode_audio_packet(Group_AV *group_av, Group_Peer_AV *peer_a...
function handle_group_audio_packet (line 368) | static int handle_group_audio_packet(void *object, int groupnumber, int ...
function groupchat_enable_av (line 404) | static int groupchat_enable_av(Group_Chats *g_c, int groupnumber, void (...
function add_av_groupchat (line 432) | int add_av_groupchat(Group_Chats *g_c, void (*audio_callback)(Messenger ...
function join_av_groupchat (line 454) | int join_av_groupchat(Group_Chats *g_c, int32_t friendnumber, const uint...
function send_audio_packet (line 477) | static int send_audio_packet(Group_Chats *g_c, int groupnumber, uint8_t ...
function group_send_audio (line 502) | int group_send_audio(Group_Chats *g_c, int groupnumber, const int16_t *p...
FILE: toxav/msi.c
type MSIHeaderID (line 45) | typedef enum {
type MSIRequest (line 53) | typedef enum {
type MSIMessage (line 72) | typedef struct {
function msi_register_callback (line 98) | void msi_register_callback (MSISession *session, msi_action_cb *callback...
function MSISession (line 107) | MSISession *msi_new (Messenger *m)
function msi_kill (line 137) | int msi_kill (MSISession *session)
function msi_invite (line 172) | int msi_invite (MSISession *session, MSICall **call, uint32_t friend_num...
function msi_hangup (line 213) | int msi_hangup (MSICall *call)
function msi_answer (line 242) | int msi_answer (MSICall *call, uint8_t capabilities)
function msi_change_capabilities (line 279) | int msi_change_capabilities(MSICall *call, uint8_t capabilities)
function msg_init (line 317) | void msg_init(MSIMessage *dest, MSIRequest request)
function msg_parse_in (line 323) | int msg_parse_in (MSIMessage *dest, const uint8_t *data, uint16_t length)
function send_message (line 415) | int send_message (Messenger *m, uint32_t friend_number, const MSIMessage...
function send_error (line 460) | int send_error (Messenger *m, uint32_t friend_number, MSIError error)
function invoke_callback (line 476) | int invoke_callback(MSICall *call, MSICallbackID cb)
function MSICall (line 501) | static MSICall *get_call (MSISession *session, uint32_t friend_number)
function MSICall (line 510) | MSICall *new_call (MSISession *session, uint32_t friend_number)
function kill_call (line 562) | void kill_call (MSICall *call)
function on_peer_status (line 597) | void on_peer_status(Messenger *m, uint32_t friend_number, uint8_t status...
function handle_init (line 624) | void handle_init (MSICall *call, const MSIMessage *msg)
function handle_push (line 683) | void handle_push (MSICall *call, const MSIMessage *msg)
function handle_pop (line 736) | void handle_pop (MSICall *call, const MSIMessage *msg)
function handle_msi_packet (line 780) | void handle_msi_packet (Messenger *m, uint32_t friend_number, const uint...
FILE: toxav/msi.h
type MSIError (line 35) | typedef enum {
type MSICapabilities (line 49) | typedef enum {
type MSICallState (line 60) | typedef enum {
type MSICallbackID (line 70) | typedef enum {
type MSICall (line 82) | typedef struct MSICall_s {
type MSISession (line 109) | typedef struct MSISession_s {
FILE: toxav/rtp.c
function RTPSession (line 39) | RTPSession *rtp_new (int payload_type, Messenger *m, uint32_t friendnumber,
function rtp_kill (line 74) | void rtp_kill (RTPSession *session)
function rtp_allow_receiving (line 84) | int rtp_allow_receiving(RTPSession *session)
function rtp_stop_receiving (line 98) | int rtp_stop_receiving(RTPSession *session)
function rtp_send_data (line 108) | int rtp_send_data (RTPSession *session, const uint8_t *data, uint16_t le...
function chloss (line 188) | bool chloss (const RTPSession *session, const struct RTPHeader *header)
type RTPMessage (line 209) | struct RTPMessage
type RTPMessage (line 213) | struct RTPMessage
type RTPMessage (line 213) | struct RTPMessage
type RTPHeader (line 213) | struct RTPHeader
type RTPHeader (line 215) | struct RTPHeader
function handle_rtp_packet (line 227) | int handle_rtp_packet (Messenger *m, uint32_t friendnumber, const uint8_...
FILE: toxav/rtp.h
type RTPHeader (line 37) | struct RTPHeader {
type RTPHeader (line 68) | struct RTPHeader
type RTPMessage (line 70) | struct RTPMessage {
type RTPMessage (line 78) | struct RTPMessage
type RTPSession (line 83) | typedef struct {
type RTPMessage (line 103) | struct RTPMessage
FILE: toxav/toxav.c
type ToxAVCall (line 39) | typedef struct ToxAVCall_s {
type ToxAV (line 66) | struct ToxAV {
function toxav_version_major (line 107) | uint32_t toxav_version_major(void)
function toxav_version_minor (line 112) | uint32_t toxav_version_minor(void)
function toxav_version_patch (line 117) | uint32_t toxav_version_patch(void)
function toxav_version_is_compatible (line 122) | bool toxav_version_is_compatible(uint32_t major, uint32_t minor, uint32_...
function ToxAV (line 131) | ToxAV *toxav_new(Tox *tox, TOXAV_ERR_NEW *error)
function toxav_kill (line 191) | void toxav_kill(ToxAV *av)
function Tox (line 219) | Tox *toxav_get_tox(const ToxAV *av)
function toxav_iteration_interval (line 223) | uint32_t toxav_iteration_interval(const ToxAV *av)
function toxav_iterate (line 228) | void toxav_iterate(ToxAV *av)
function toxav_call (line 280) | bool toxav_call(ToxAV *av, uint32_t friend_number, uint32_t audio_bit_ra...
function toxav_callback_call (line 322) | void toxav_callback_call(ToxAV *av, toxav_call_cb *function, void *user_...
function toxav_answer (line 329) | bool toxav_answer(ToxAV *av, uint32_t friend_number, uint32_t audio_bit_...
function toxav_callback_call_state (line 379) | void toxav_callback_call_state(ToxAV *av, toxav_call_state_cb *function,...
function toxav_call_control (line 386) | bool toxav_call_control(ToxAV *av, uint32_t friend_number, TOXAV_CALL_CO...
function toxav_bit_rate_set (line 535) | bool toxav_bit_rate_set(ToxAV *av, uint32_t friend_number, int32_t audio...
function toxav_callback_bit_rate_status (line 651) | void toxav_callback_bit_rate_status(ToxAV *av, toxav_bit_rate_status_cb ...
function toxav_audio_send_frame (line 658) | bool toxav_audio_send_frame(ToxAV *av, uint32_t friend_number, const int...
function toxav_video_send_frame (line 742) | bool toxav_video_send_frame(ToxAV *av, uint32_t friend_number, uint16_t ...
function toxav_callback_audio_receive_frame (line 841) | void toxav_callback_audio_receive_frame(ToxAV *av, toxav_audio_receive_f...
function toxav_callback_video_receive_frame (line 848) | void toxav_callback_video_receive_frame(ToxAV *av, toxav_video_receive_f...
function callback_bwc (line 862) | void callback_bwc(BWController *bwc, uint32_t friend_number, float loss,...
function callback_invite (line 898) | int callback_invite(void *toxav_inst, MSICall *call)
function callback_start (line 926) | int callback_start(void *toxav_inst, MSICall *call)
function callback_end (line 954) | int callback_end(void *toxav_inst, MSICall *call)
function callback_error (line 969) | int callback_error(void *toxav_inst, MSICall *call)
function callback_capabilites (line 984) | int callback_capabilites(void *toxav_inst, MSICall *call)
function audio_bit_rate_invalid (line 1004) | bool audio_bit_rate_invalid(uint32_t bit_rate)
function video_bit_rate_invalid (line 1011) | bool video_bit_rate_invalid(uint32_t bit_rate)
function invoke_call_state_callback (line 1017) | bool invoke_call_state_callback(ToxAV *av, uint32_t friend_number, uint3...
function ToxAVCall (line 1026) | ToxAVCall *call_new(ToxAV *av, uint32_t friend_number, TOXAV_ERR_CALL *e...
function ToxAVCall (line 1108) | ToxAVCall *call_get(ToxAV *av, uint32_t friend_number)
function ToxAVCall (line 1116) | ToxAVCall *call_remove(ToxAVCall *call)
function call_prepare_transmission (line 1158) | bool call_prepare_transmission(ToxAVCall *call)
function call_kill_transmission (line 1241) | void call_kill_transmission(ToxAVCall *call)
FILE: toxav/toxav.h
type Tox (line 74) | typedef struct Tox Tox;
type ToxAV (line 90) | typedef struct ToxAV ToxAV;
type TOXAV_ERR_NEW (line 177) | typedef enum TOXAV_ERR_NEW {
type TOXAV_ERR_CALL (line 253) | typedef enum TOXAV_ERR_CALL {
type TOXAV_ERR_ANSWER (line 329) | typedef enum TOXAV_ERR_ANSWER {
type TOXAV_FRIEND_CALL_STATE (line 392) | enum TOXAV_FRIEND_CALL_STATE {
type TOXAV_CALL_CONTROL (line 459) | typedef enum TOXAV_CALL_CONTROL {
type TOXAV_ERR_CALL_CONTROL (line 505) | typedef enum TOXAV_ERR_CALL_CONTROL {
type TOXAV_ERR_BIT_RATE_SET (line 558) | typedef enum TOXAV_ERR_BIT_RATE_SET {
type TOXAV_ERR_SEND_FRAME (line 636) | typedef enum TOXAV_ERR_SEND_FRAME {
FILE: toxav/toxav_old.c
function toxav_add_av_groupchat (line 38) | int toxav_add_av_groupchat(struct Tox *tox, void (*audio_callback)(void ...
function toxav_join_av_groupchat (line 55) | int toxav_join_av_groupchat(struct Tox *tox, int32_t friendnumber, const...
function toxav_group_send_audio (line 76) | int toxav_group_send_audio(struct Tox *tox, int groupnumber, const int16...
FILE: toxav/video.c
function VCSession (line 39) | VCSession *vc_new(ToxAV *av, uint32_t friend_number, toxav_video_receive...
function vc_kill (line 118) | void vc_kill(VCSession *vc)
function vc_iterate (line 138) | void vc_iterate(VCSession *vc)
function vc_queue_message (line 176) | int vc_queue_message(void *vcp, struct RTPMessage *msg)
function vc_reconfigure_encoder (line 210) | int vc_reconfigure_encoder(VCSession *vc, uint32_t bit_rate, uint16_t wi...
FILE: toxav/video.h
type RTPMessage (line 39) | struct RTPMessage
type VCSession (line 41) | typedef struct VCSession_s {
type RTPMessage (line 64) | struct RTPMessage
FILE: toxcore/DHT.c
function id_closest (line 74) | int id_closest(const uint8_t *pk, const uint8_t *pk1, const uint8_t *pk2)
function bit_by_bit_cmp (line 96) | static unsigned int bit_by_bit_cmp(const uint8_t *pk1, const uint8_t *pk2)
function get_shared_key (line 121) | void get_shared_key(Shared_Keys *shared_keys, uint8_t *shared_key, const...
function DHT_get_shared_key_recv (line 167) | void DHT_get_shared_key_recv(DHT *dht, uint8_t *shared_key, const uint8_...
function DHT_get_shared_key_sent (line 175) | void DHT_get_shared_key_sent(DHT *dht, uint8_t *shared_key, const uint8_...
function to_net_family (line 180) | void to_net_family(IP *ip)
function to_host_family (line 188) | int to_host_family(IP *ip)
function packed_node_size (line 207) | int packed_node_size(uint8_t ip_family)
function pack_nodes (line 228) | int pack_nodes(uint8_t *data, uint16_t length, const Node_format *nodes,...
function unpack_nodes (line 290) | int unpack_nodes(Node_format *nodes, uint16_t max_num_nodes, uint16_t *p...
function client_or_ip_port_in_list (line 365) | static int client_or_ip_port_in_list(Client_data *list, uint16_t length,...
function client_in_nodelist (line 444) | static int client_in_nodelist(const Node_format *list, uint16_t length, ...
function friend_number (line 459) | static int friend_number(const DHT *dht, const uint8_t *public_key)
function _Bool (line 473) | _Bool add_to_list(Node_format *nodes_list, unsigned int length, const ui...
function hardening_correct (line 506) | static uint8_t hardening_correct(const Hardening *h)
function get_close_nodes_inner (line 513) | static void get_close_nodes_inner(const uint8_t *public_key, Node_format...
function get_somewhat_close_nodes (line 579) | static int get_somewhat_close_nodes(const DHT *dht, const uint8_t *publi...
function get_close_nodes (line 600) | int get_close_nodes(const DHT *dht, const uint8_t *public_key, Node_form...
function cmp_dht_entry (line 661) | static int cmp_dht_entry(const void *a, const void *b)
function store_node_ok (line 707) | static unsigned int store_node_ok(const Client_data *client, const uint8...
function sort_client_list (line 717) | static void sort_client_list(Client_data *list, unsigned int length, con...
function replace_all (line 736) | static int replace_all( Client_data *list,
function add_to_close (line 785) | static int add_to_close(DHT *dht, const uint8_t *public_key, IP_Port ip_...
function _Bool (line 831) | _Bool node_addable_to_close_list(DHT *dht, const uint8_t *public_key, IP...
function _Bool (line 840) | static _Bool is_pk_in_client_list(Client_data *list, unsigned int client...
function ping_node_from_getnodes_ok (line 863) | static unsigned int ping_node_from_getnodes_ok(DHT *dht, const uint8_t *...
function addto_lists (line 919) | int addto_lists(DHT *dht, IP_Port ip_port, const uint8_t *public_key)
function returnedip_ports (line 993) | static int returnedip_ports(DHT *dht, IP_Port ip_port, const uint8_t *pu...
function getnodes (line 1060) | static int getnodes(DHT *dht, IP_Port ip_port, const uint8_t *public_key...
function sendnodes_ipv6 (line 1117) | static int sendnodes_ipv6(const DHT *dht, IP_Port ip_port, const uint8_t...
function handle_getnodes (line 1167) | static int handle_getnodes(void *object, IP_Port source, const uint8_t *...
function sent_getnode_to_node (line 1200) | static uint8_t sent_getnode_to_node(DHT *dht, const uint8_t *public_key,...
function handle_sendnodes_core (line 1226) | static int handle_sendnodes_core(void *object, IP_Port source, const uin...
function handle_sendnodes_ipv6 (line 1288) | static int handle_sendnodes_ipv6(void *object, IP_Port source, const uin...
function DHT_addfriend (line 1316) | int DHT_addfriend(DHT *dht, const uint8_t *public_key, void (*ip_callbac...
function DHT_delfriend (line 1369) | int DHT_delfriend(DHT *dht, const uint8_t *public_key, uint16_t lock_count)
function DHT_getfriendip (line 1414) | int DHT_getfriendip(const DHT *dht, const uint8_t *public_key, IP_Port *...
function do_ping_and_sendnode_requests (line 1447) | static uint8_t do_ping_and_sendnode_requests(DHT *dht, uint64_t *lastget...
function do_DHT_friends (line 1515) | static void do_DHT_friends(DHT *dht)
function do_Close (line 1536) | static void do_Close(DHT *dht)
function DHT_getnodes (line 1570) | void DHT_getnodes(DHT *dht, const IP_Port *from_ipp, const uint8_t *from...
function DHT_bootstrap (line 1575) | void DHT_bootstrap(DHT *dht, IP_Port ip_port, const uint8_t *public_key)
function DHT_bootstrap_from_address (line 1589) | int DHT_bootstrap_from_address(DHT *dht, const char *address, uint8_t ip...
function route_packet (line 1622) | int route_packet(const DHT *dht, const uint8_t *public_key, const uint8_...
function friend_iplist (line 1649) | static int friend_iplist(const DHT *dht, IP_Port *ip_portlist, uint16_t ...
function route_tofriend (line 1717) | int route_tofriend(const DHT *dht, const uint8_t *friend_id, const uint8...
function routeone_tofriend (line 1772) | static int routeone_tofriend(DHT *dht, const uint8_t *friend_id, const u...
function send_NATping (line 1821) | static int send_NATping(DHT *dht, const uint8_t *public_key, uint64_t pi...
function handle_NATping (line 1849) | static int handle_NATping(void *object, IP_Port source, const uint8_t *s...
function IP (line 1888) | static IP NAT_commonip(IP_Port *ip_portlist, uint16_t len, uint16_t min_...
function NAT_getports (line 1918) | static uint16_t NAT_getports(uint16_t *portlist, IP_Port *ip_portlist, u...
function punch_holes (line 1933) | static void punch_holes(DHT *dht, IP ip, uint16_t *port_list, uint16_t n...
function do_NAT (line 1982) | static void do_NAT(DHT *dht)
function send_hardening_req (line 2031) | static int send_hardening_req(DHT *dht, Node_format *sendto, uint8_t typ...
function send_hardening_getnode_req (line 2050) | static int send_hardening_getnode_req(DHT *dht, Node_format *dest, Node_...
function send_hardening_getnode_res (line 2059) | static int send_hardening_getnode_res(const DHT *dht, const Node_format ...
function IPPTsPng (line 2080) | static IPPTsPng *get_closelist_IPPTsPng(DHT *dht, const uint8_t *public_...
function have_nodes_closelist (line 2101) | static uint32_t have_nodes_closelist(DHT *dht, Node_format *nodes, uint1...
function handle_hardening (line 2129) | static int handle_hardening(void *object, IP_Port source, const uint8_t ...
function Node_format (line 2197) | Node_format random_node(DHT *dht, sa_family_t sa_family)
function list_nodes (line 2221) | uint16_t list_nodes(Client_data *list, unsigned int length, Node_format ...
function randfriends_nodes (line 2260) | uint16_t randfriends_nodes(DHT *dht, Node_format *nodes, uint16_t max_num)
function closelist_nodes (line 2283) | uint16_t closelist_nodes(DHT *dht, Node_format *nodes, uint16_t max_num)
function do_hardening (line 2288) | void do_hardening(DHT *dht)
function cryptopacket_registerhandler (line 2340) | void cryptopacket_registerhandler(DHT *dht, uint8_t byte, cryptopacket_h...
function cryptopacket_handle (line 2346) | static int cryptopacket_handle(void *object, IP_Port source, const uint8...
function DHT (line 2382) | DHT *new_DHT(Networking_Core *net)
function do_DHT (line 2432) | void do_DHT(DHT *dht)
function kill_DHT (line 2458) | void kill_DHT(DHT *dht)
function DHT_size (line 2485) | uint32_t DHT_size(const DHT *dht)
function DHT_save (line 2519) | void DHT_save(DHT *dht, uint8_t *data)
function DHT_connect_after_load (line 2572) | int DHT_connect_after_load(DHT *dht)
function dht_load_state_callback (line 2599) | static int dht_load_state_callback(void *outer, const uint8_t *data, uin...
function DHT_load (line 2642) | int DHT_load(DHT *dht, const uint8_t *data, uint32_t length)
function DHT_isconnected (line 2661) | int DHT_isconnected(const DHT *dht)
function DHT_non_lan_connected (line 2680) | int DHT_non_lan_connected(const DHT *dht)
FILE: toxcore/DHT.h
type IPPTs (line 74) | typedef struct {
type Hardening (line 79) | typedef struct {
type IPPTsPng (line 97) | typedef struct {
type Client_data (line 108) | typedef struct {
type NAT (line 116) | typedef struct {
type Node_format (line 131) | typedef struct {
type DHT_Friend (line 137) | typedef struct {
type Shared_Keys (line 187) | typedef struct {
type Cryptopacket_Handles (line 202) | typedef struct {
type DHT (line 207) | typedef struct {
FILE: toxcore/LAN_discovery.c
function fetch_broadcast_info (line 48) | static void fetch_broadcast_info(uint16_t port)
function fetch_broadcast_info (line 104) | static void fetch_broadcast_info(uint16_t port)
function fetch_broadcast_info (line 169) | static void fetch_broadcast_info(uint16_t port)
function send_broadcasts (line 180) | static uint32_t send_broadcasts(Networking_Core *net, uint16_t port, con...
function IP (line 199) | static IP broadcast_ip(sa_family_t family_socket, sa_family_t family_bro...
function _Bool (line 231) | _Bool Local_ip(IP ip)
function LAN_ip (line 259) | int LAN_ip(IP ip)
function handle_LANdiscovery (line 309) | static int handle_LANdiscovery(void *object, IP_Port source, const uint8...
function send_LANdiscovery (line 324) | int send_LANdiscovery(uint16_t port, DHT *dht)
function LANdiscovery_init (line 356) | void LANdiscovery_init(DHT *dht)
function LANdiscovery_kill (line 361) | void LANdiscovery_kill(DHT *dht)
FILE: toxcore/Messenger.c
function friend_not_valid (line 44) | static uint8_t friend_not_valid(const Messenger *m, int32_t friendnumber)
function realloc_friendlist (line 59) | int realloc_friendlist(Messenger *m, uint32_t num)
function getfriend_id (line 79) | int32_t getfriend_id(const Messenger *m, const uint8_t *real_pk)
function get_real_pk (line 98) | int get_real_pk(const Messenger *m, int32_t friendnumber, uint8_t *real_pk)
function getfriendcon_id (line 110) | int getfriendcon_id(const Messenger *m, int32_t friendnumber)
function address_checksum (line 121) | static uint16_t address_checksum(const uint8_t *address, uint32_t len)
function getaddress (line 138) | void getaddress(const Messenger *m, uint8_t *address)
function send_online_packet (line 147) | static int send_online_packet(Messenger *m, int32_t friendnumber)
function send_offline_packet (line 157) | static int send_offline_packet(Messenger *m, int friendcon_id)
function init_new_friend (line 168) | static int32_t init_new_friend(Messenger *m, const uint8_t *real_pk, uin...
function m_addfriend (line 226) | int32_t m_addfriend(Messenger *m, const uint8_t *address, const uint8_t ...
function m_addfriend_norequest (line 279) | int32_t m_addfriend_norequest(Messenger *m, const uint8_t *real_pk)
function clear_receipts (line 293) | static int clear_receipts(Messenger *m, int32_t friendnumber)
function add_receipt (line 311) | static int add_receipt(Messenger *m, int32_t friendnumber, uint32_t pack...
function friend_received_packet (line 338) | static int friend_received_packet(const Messenger *m, int32_t friendnumb...
function do_receipts (line 347) | static int do_receipts(Messenger *m, int32_t friendnumber)
function m_delfriend (line 379) | int m_delfriend(Messenger *m, int32_t friendnumber)
function m_get_friend_connectionstatus (line 412) | int m_get_friend_connectionstatus(const Messenger *m, int32_t friendnumber)
function m_friend_exists (line 437) | int m_friend_exists(const Messenger *m, int32_t friendnumber)
function m_send_message_generic (line 454) | int m_send_message_generic(Messenger *m, int32_t friendnumber, uint8_t t...
function m_sendname (line 494) | static int m_sendname(const Messenger *m, int32_t friendnumber, const ui...
function setfriendname (line 507) | int setfriendname(Messenger *m, int32_t friendnumber, const uint8_t *nam...
function setname (line 528) | int setname(Messenger *m, const uint8_t *name, uint16_t length)
function getself_name (line 553) | uint16_t getself_name(const Messenger *m, uint8_t *name)
function getname (line 570) | int getname(const Messenger *m, int32_t friendnumber, uint8_t *name)
function m_get_name_size (line 579) | int m_get_name_size(const Messenger *m, int32_t friendnumber)
function m_get_self_name_size (line 587) | int m_get_self_name_size(const Messenger *m)
function m_set_statusmessage (line 592) | int m_set_statusmessage(Messenger *m, const uint8_t *status, uint16_t le...
function m_set_userstatus (line 613) | int m_set_userstatus(Messenger *m, uint8_t status)
function m_get_statusmessage_size (line 633) | int m_get_statusmessage_size(const Messenger *m, int32_t friendnumber)
function m_copy_statusmessage (line 644) | int m_copy_statusmessage(const Messenger *m, int32_t friendnumber, uint8...
function m_get_self_statusmessage_size (line 659) | int m_get_self_statusmessage_size(const Messenger *m)
function m_copy_self_statusmessage (line 664) | int m_copy_self_statusmessage(const Messenger *m, uint8_t *buf)
function m_get_userstatus (line 670) | uint8_t m_get_userstatus(const Messenger *m, int32_t friendnumber)
function m_get_self_userstatus (line 684) | uint8_t m_get_self_userstatus(const Messenger *m)
function m_get_last_online (line 689) | uint64_t m_get_last_online(const Messenger *m, int32_t friendnumber)
function m_set_usertyping (line 697) | int m_set_usertyping(Messenger *m, int32_t friendnumber, uint8_t is_typing)
function m_get_istyping (line 715) | int m_get_istyping(const Messenger *m, int32_t friendnumber)
function send_statusmessage (line 723) | static int send_statusmessage(const Messenger *m, int32_t friendnumber, ...
function send_userstatus (line 728) | static int send_userstatus(const Messenger *m, int32_t friendnumber, uin...
function send_user_istyping (line 733) | static int send_user_istyping(const Messenger *m, int32_t friendnumber, ...
function set_friend_statusmessage (line 739) | static int set_friend_statusmessage(const Messenger *m, int32_t friendnu...
function set_friend_userstatus (line 754) | static void set_friend_userstatus(const Messenger *m, int32_t friendnumb...
function set_friend_typing (line 759) | static void set_friend_typing(const Messenger *m, int32_t friendnumber, ...
function m_callback_friendrequest (line 765) | void m_callback_friendrequest(Messenger *m, void (*function)(Messenger *...
function m_callback_friendmessage (line 773) | void m_callback_friendmessage(Messenger *m, void (*function)(Messenger *...
function m_callback_namechange (line 780) | void m_callback_namechange(Messenger *m, void (*function)(Messenger *m, ...
function m_callback_statusmessage (line 787) | void m_callback_statusmessage(Messenger *m, void (*function)(Messenger *...
function m_callback_userstatus (line 794) | void m_callback_userstatus(Messenger *m, void (*function)(Messenger *m, ...
function m_callback_typingchange (line 800) | void m_callback_typingchange(Messenger *m, void(*function)(Messenger *m,...
function m_callback_read_receipt (line 806) | void m_callback_read_receipt(Messenger *m, void (*function)(Messenger *m...
function m_callback_connectionstatus (line 812) | void m_callback_connectionstatus(Messenger *m, void (*function)(Messenge...
function m_callback_core_connection (line 819) | void m_callback_core_connection(Messenger *m, void (*function)(Messenger...
function m_callback_connectionstatus_internal_av (line 825) | void m_callback_connectionstatus_internal_av(Messenger *m, void (*functi...
function check_friend_tcp_udp (line 832) | static void check_friend_tcp_udp(Messenger *m, int32_t friendnumber)
function check_friend_connectionstatus (line 858) | static void check_friend_connectionstatus(Messenger *m, int32_t friendnu...
function set_friend_status (line 887) | void set_friend_status(Messenger *m, int32_t friendnumber, uint8_t status)
function write_cryptpacket_id (line 893) | static int write_cryptpacket_id(const Messenger *m, int32_t friendnumber...
function m_callback_group_invite (line 919) | void m_callback_group_invite(Messenger *m, void (*function)(Messenger *m...
function send_group_invite_packet (line 930) | int send_group_invite_packet(const Messenger *m, int32_t friendnumber, c...
function callback_file_sendrequest (line 942) | void callback_file_sendrequest(Messenger *m, void (*function)(Messenger ...
function callback_file_control (line 954) | void callback_file_control(Messenger *m, void (*function)(Messenger *m, ...
function callback_file_data (line 966) | void callback_file_data(Messenger *m, void (*function)(Messenger *m, uin...
function callback_file_reqchunk (line 978) | void callback_file_reqchunk(Messenger *m, void (*function)(Messenger *m,...
function file_get_id (line 993) | int file_get_id(const Messenger *m, int32_t friendnumber, uint32_t filen...
function file_sendrequest (line 1037) | static int file_sendrequest(const Messenger *m, int32_t friendnumber, ui...
function new_filesender (line 1070) | long int new_filesender(const Messenger *m, int32_t friendnumber, uint32...
function send_file_control_packet (line 1106) | int send_file_control_packet(const Messenger *m, int32_t friendnumber, u...
function file_control (line 1137) | int file_control(const Messenger *m, int32_t friendnumber, uint32_t file...
function file_seek (line 1230) | int file_seek(const Messenger *m, int32_t friendnumber, uint32_t filenum...
function send_file_data_packet (line 1287) | static int64_t send_file_data_packet(const Messenger *m, int32_t friendn...
function file_data (line 1318) | int file_data(const Messenger *m, int32_t friendnumber, uint32_t filenum...
function file_dataremaining (line 1384) | uint64_t file_dataremaining(const Messenger *m, int32_t friendnumber, ui...
function do_reqchunk_filecb (line 1404) | static void do_reqchunk_filecb(Messenger *m, int32_t friendnumber)
function break_files (line 1490) | static void break_files(const Messenger *m, int32_t friendnumber)
function handle_filecontrol (line 1506) | static int handle_filecontrol(Messenger *m, int32_t friendnumber, uint8_...
function m_callback_msi_packet (line 1598) | void m_callback_msi_packet(Messenger *m, void (*function)(Messenger *m, ...
function m_msi_packet (line 1610) | int m_msi_packet(const Messenger *m, int32_t friendnumber, const uint8_t...
function handle_custom_lossy_packet (line 1615) | static int handle_custom_lossy_packet(void *object, int friend_num, cons...
function custom_lossy_packet_registerhandler (line 1637) | void custom_lossy_packet_registerhandler(Messenger *m, void (*packet_han...
function m_callback_rtp_packet (line 1644) | int m_callback_rtp_packet(Messenger *m, int32_t friendnumber, uint8_t by...
function send_custom_lossy_packet (line 1663) | int send_custom_lossy_packet(const Messenger *m, int32_t friendnumber, c...
function handle_custom_lossless_packet (line 1688) | static int handle_custom_lossless_packet(void *object, int friend_num, c...
function custom_lossless_packet_registerhandler (line 1707) | void custom_lossless_packet_registerhandler(Messenger *m, void (*packet_...
function send_custom_lossless_packet (line 1714) | int send_custom_lossless_packet(const Messenger *m, int32_t friendnumber...
function friend_already_added (line 1740) | static int friend_already_added(const uint8_t *real_pk, void *data)
function Messenger (line 1751) | Messenger *new_messenger(Messenger_Options *options, unsigned int *error)
function kill_messenger (line 1848) | void kill_messenger(Messenger *m)
function check_friend_request_timed_out (line 1880) | static void check_friend_request_timed_out(Messenger *m, uint32_t i, uin...
function handle_status (line 1893) | static int handle_status(void *object, int i, uint8_t status)
function handle_packet (line 1908) | static int handle_packet(void *object, int i, uint8_t *temp, uint16_t len)
function do_friends (line 2178) | void do_friends(Messenger *m)
function connection_status_cb (line 2235) | static void connection_status_cb(Messenger *m)
function messenger_run_interval (line 2273) | uint32_t messenger_run_interval(const Messenger *m)
function do_messenger (line 2285) | void do_messenger(Messenger *m)
type SAVED_FRIEND (line 2443) | struct SAVED_FRIEND {
function saved_friendslist_size (line 2457) | static uint32_t saved_friendslist_size(const Messenger *m)
function friends_list_save (line 2462) | static uint32_t friends_list_save(const Messenger *m, uint8_t *data)
function friends_list_load (line 2504) | static int friends_list_load(Messenger *m, const uint8_t *data, uint32_t...
function messenger_size (line 2545) | uint32_t messenger_size(const Messenger *m)
function messenger_save (line 2570) | void messenger_save(const Messenger *m, uint8_t *data)
function messenger_load_state_callback (line 2653) | static int messenger_load_state_callback(void *outer, const uint8_t *dat...
function messenger_load (line 2749) | int messenger_load(Messenger *m, const uint8_t *data, uint32_t length)
function count_friendlist (line 2770) | uint32_t count_friendlist(const Messenger *m)
function copy_friendlist (line 2789) | uint32_t copy_friendlist(Messenger const *m, uint32_t *out_list, uint32_...
FILE: toxcore/Messenger.h
type Messenger_Options (line 68) | typedef struct {
type Receipts (line 77) | struct Receipts {
type USERSTATUS (line 120) | typedef enum {
type File_Transfers (line 130) | struct File_Transfers {
type Messenger (line 171) | typedef struct Messenger Messenger;
type Friend (line 173) | typedef struct {
type Messenger (line 211) | struct Messenger {
FILE: toxcore/TCP_client.c
function connect_sock_to (line 38) | static int connect_sock_to(sock_t sock, IP_Port ip_port, TCP_Proxy_Info ...
function proxy_http_generate_connection_request (line 74) | static int proxy_http_generate_connection_request(TCP_Client_Connection ...
function proxy_http_read_connection_response (line 104) | static int proxy_http_read_connection_response(TCP_Client_Connection *TC...
function proxy_socks5_generate_handshake (line 132) | static void proxy_socks5_generate_handshake(TCP_Client_Connection *TCP_c...
function socks5_read_handshake_response (line 146) | static int socks5_read_handshake_response(TCP_Client_Connection *TCP_conn)
function proxy_socks5_generate_connection_request (line 160) | static void proxy_socks5_generate_connection_request(TCP_Client_Connecti...
function proxy_socks5_read_connection_response (line 190) | static int proxy_socks5_read_connection_response(TCP_Client_Connection *...
function generate_handshake (line 219) | static int generate_handshake(TCP_Client_Connection *TCP_conn)
function handle_handshake (line 243) | static int handle_handshake(TCP_Client_Connection *TCP_conn, const uint8...
function send_pending_data_nonpriority (line 261) | static int send_pending_data_nonpriority(TCP_Client_Connection *con)
function send_pending_data (line 286) | static int send_pending_data(TCP_Client_Connection *con)
function _Bool (line 325) | static _Bool add_priority(TCP_Client_Connection *con, const uint8_t *pac...
function write_packet_TCP_secure_connection (line 353) | static int write_packet_TCP_secure_connection(TCP_Client_Connection *con...
function send_routing_request (line 414) | int send_routing_request(TCP_Client_Connection *con, uint8_t *public_key)
function routing_response_handler (line 422) | void routing_response_handler(TCP_Client_Connection *con, int (*response...
function routing_status_handler (line 429) | void routing_status_handler(TCP_Client_Connection *con, int (*status_cal...
function send_data (line 443) | int send_data(TCP_Client_Connection *con, uint8_t con_id, const uint8_t ...
function send_oob_packet (line 464) | int send_oob_packet(TCP_Client_Connection *con, const uint8_t *public_ke...
function set_tcp_connection_number (line 484) | int set_tcp_connection_number(TCP_Client_Connection *con, uint8_t con_id...
function routing_data_handler (line 496) | void routing_data_handler(TCP_Client_Connection *con, int (*data_callbac...
function oob_data_handler (line 503) | void oob_data_handler(TCP_Client_Connection *con, int (*oob_data_callbac...
function send_disconnect_notification (line 514) | static int send_disconnect_notification(TCP_Client_Connection *con, uint...
function send_ping_request (line 526) | static int send_ping_request(TCP_Client_Connection *con)
function send_ping_response (line 547) | static int send_ping_response(TCP_Client_Connection *con)
function send_disconnect_request (line 568) | int send_disconnect_request(TCP_Client_Connection *con, uint8_t con_id)
function send_onion_request (line 582) | int send_onion_request(TCP_Client_Connection *con, const uint8_t *data, ...
function onion_response_handler (line 590) | void onion_response_handler(TCP_Client_Connection *con, int (*onion_call...
function TCP_Client_Connection (line 599) | TCP_Client_Connection *new_TCP_connection(IP_Port ip_port, const uint8_t...
function handle_TCP_packet (line 683) | static int handle_TCP_packet(TCP_Client_Connection *conn, const uint8_t ...
function do_confirmed_TCP (line 815) | static int do_confirmed_TCP(TCP_Client_Connection *conn)
function do_TCP_connection (line 858) | void do_TCP_connection(TCP_Client_Connection *TCP_connection)
function kill_TCP_connection (line 946) | void kill_TCP_connection(TCP_Client_Connection *TCP_connection)
FILE: toxcore/TCP_client.h
type TCP_PROXY_TYPE (line 32) | typedef enum {
type TCP_Proxy_Info (line 38) | typedef struct {
type TCP_Client_Connection (line 53) | typedef struct {
FILE: toxcore/TCP_connection.c
function _Bool (line 42) | static _Bool connections_number_not_valid(const TCP_Connections *tcp_c, ...
function _Bool (line 59) | static _Bool tcp_connections_number_not_valid(const TCP_Connections *tcp...
function create_connection (line 78) | static int create_connection(TCP_Connections *tcp_c)
function create_tcp_connection (line 106) | static int create_tcp_connection(TCP_Connections *tcp_c)
function wipe_connection (line 133) | static int wipe_connection(TCP_Connections *tcp_c, int connections_number)
function wipe_tcp_connection (line 160) | static int wipe_tcp_connection(TCP_Connections *tcp_c, int tcp_connectio...
function TCP_Connection_to (line 182) | static TCP_Connection_to *get_connection(const TCP_Connections *tcp_c, i...
function TCP_con (line 190) | static TCP_con *get_tcp_connection(const TCP_Connections *tcp_c, int tcp...
function send_packet_tcp_connection (line 203) | int send_packet_tcp_connection(TCP_Connections *tcp_c, int connections_n...
function get_random_tcp_onion_conn_number (line 285) | int get_random_tcp_onion_conn_number(TCP_Connections *tcp_c)
function tcp_send_onion_request (line 305) | int tcp_send_onion_request(TCP_Connections *tcp_c, unsigned int tcp_conn...
function tcp_send_oob_packet (line 327) | int tcp_send_oob_packet(TCP_Connections *tcp_c, unsigned int tcp_connect...
function set_packet_tcp_connection_callback (line 348) | void set_packet_tcp_connection_callback(TCP_Connections *tcp_c, int (*tc...
function set_oob_packet_tcp_connection_callback (line 357) | void set_oob_packet_tcp_connection_callback(TCP_Connections *tcp_c, int ...
function set_onion_packet_tcp_connection_callback (line 366) | void set_onion_packet_tcp_connection_callback(TCP_Connections *tcp_c, in...
function find_tcp_connection_to (line 379) | static int find_tcp_connection_to(TCP_Connections *tcp_c, const uint8_t ...
function find_tcp_connection_relay (line 401) | static int find_tcp_connection_relay(TCP_Connections *tcp_c, const uint8...
function new_tcp_connection_to (line 433) | int new_tcp_connection_to(TCP_Connections *tcp_c, const uint8_t *public_...
function kill_tcp_connection_to (line 455) | int kill_tcp_connection_to(TCP_Connections *tcp_c, int connections_number)
function set_tcp_connection_to_status (line 499) | int set_tcp_connection_to_status(TCP_Connections *tcp_c, int connections...
function _Bool (line 555) | static _Bool tcp_connection_in_conn(TCP_Connection_to *con_to, unsigned ...
function add_tcp_connection_to_conn (line 571) | static int add_tcp_connection_to_conn(TCP_Connection_to *con_to, unsigne...
function rm_tcp_connection_from_conn (line 593) | static int rm_tcp_connection_from_conn(TCP_Connection_to *con_to, unsign...
function online_tcp_connection_from_conn (line 612) | static unsigned int online_tcp_connection_from_conn(TCP_Connection_to *c...
function set_tcp_connection_status (line 630) | static int set_tcp_connection_status(TCP_Connection_to *con_to, unsigned...
function kill_tcp_relay_connection (line 656) | static int kill_tcp_relay_connection(TCP_Connections *tcp_c, int tcp_con...
function reconnect_tcp_relay_connection (line 682) | static int reconnect_tcp_relay_connection(TCP_Connections *tcp_c, int tc...
function sleep_tcp_relay_connection (line 728) | static int sleep_tcp_relay_connection(TCP_Connections *tcp_c, int tcp_co...
function unsleep_tcp_relay_connection (line 771) | static int unsleep_tcp_relay_connection(TCP_Connections *tcp_c, int tcp_...
function send_tcp_relay_routing_request (line 802) | static int send_tcp_relay_routing_request(TCP_Connections *tcp_c, int tc...
function tcp_response_callback (line 818) | static int tcp_response_callback(void *object, uint8_t connection_id, co...
function tcp_status_callback (line 847) | static int tcp_status_callback(void *object, uint32_t number, uint8_t co...
function tcp_data_callback (line 882) | static int tcp_data_callback(void *object, uint32_t number, uint8_t conn...
function tcp_oob_callback (line 908) | static int tcp_oob_callback(void *object, const uint8_t *public_key, con...
function tcp_onion_callback (line 937) | static int tcp_onion_callback(void *object, const uint8_t *data, uint16_...
function tcp_relay_set_callbacks (line 952) | static int tcp_relay_set_callbacks(TCP_Connections *tcp_c, int tcp_conne...
function tcp_relay_on_online (line 972) | static int tcp_relay_on_online(TCP_Connections *tcp_c, int tcp_connectio...
function add_tcp_relay_instance (line 1011) | static int add_tcp_relay_instance(TCP_Connections *tcp_c, IP_Port ip_por...
function add_tcp_relay_global (line 1046) | int add_tcp_relay_global(TCP_Connections *tcp_c, IP_Port ip_port, const ...
function add_tcp_number_relay_connection (line 1064) | int add_tcp_number_relay_connection(TCP_Connections *tcp_c, int connecti...
function add_tcp_relay_connection (line 1099) | int add_tcp_relay_connection(TCP_Connections *tcp_c, int connections_num...
function tcp_connection_to_online_tcp_relays (line 1133) | unsigned int tcp_connection_to_online_tcp_relays(TCP_Connections *tcp_c,...
function tcp_copy_connected_relays (line 1149) | unsigned int tcp_copy_connected_relays(TCP_Connections *tcp_c, Node_form...
function set_tcp_onion_status (line 1184) | int set_tcp_onion_status(TCP_Connections *tcp_c, _Bool status)
function TCP_Connections (line 1251) | TCP_Connections *new_tcp_connections(const uint8_t *secret_key, TCP_Prox...
function do_tcp_conns (line 1268) | static void do_tcp_conns(TCP_Connections *tcp_c)
function kill_nonused_tcp (line 1310) | static void kill_nonused_tcp(TCP_Connections *tcp_c)
function do_tcp_connections (line 1346) | void do_tcp_connections(TCP_Connections *tcp_c)
function kill_tcp_connections (line 1352) | void kill_tcp_connections(TCP_Connections *tcp_c)
FILE: toxcore/TCP_connection.h
type TCP_Connection_to (line 54) | typedef struct {
type TCP_con (line 67) | typedef struct {
type TCP_Connections (line 81) | typedef struct {
FILE: toxcore/TCP_server.c
function bind_to_port (line 38) | static int bind_to_port(sock_t sock, int family, uint16_t port)
function realloc_connection (line 67) | static int realloc_connection(TCP_Server *TCP_server, uint32_t num)
function get_TCP_connection_index (line 100) | static int get_TCP_connection_index(const TCP_Server *TCP_server, const ...
function add_accepted (line 113) | static int add_accepted(TCP_Server *TCP_server, const TCP_Secure_Connect...
function del_accepted (line 161) | static int del_accepted(TCP_Server *TCP_server, int index)
function TCP_socket_data_recv_buffer (line 185) | unsigned int TCP_socket_data_recv_buffer(sock_t sock)
function read_TCP_length (line 205) | uint16_t read_TCP_length(sock_t sock)
function read_TCP_packet (line 235) | int read_TCP_packet(sock_t sock, uint8_t *data, uint16_t length)
function read_packet_TCP_secure_connection (line 257) | int read_packet_TCP_secure_connection(sock_t sock, uint16_t *next_packet...
function send_pending_data_nonpriority (line 296) | static int send_pending_data_nonpriority(TCP_Secure_Connection *con)
function wipe_priority_list (line 319) | void wipe_priority_list(TCP_Priority_List *p)
function send_pending_data (line 331) | static int send_pending_data(TCP_Secure_Connection *con)
function _Bool (line 370) | static _Bool add_priority(TCP_Secure_Connection *con, const uint8_t *pac...
function write_packet_TCP_secure_connection (line 398) | static int write_packet_TCP_secure_connection(TCP_Secure_Connection *con...
function kill_TCP_connection (line 457) | static void kill_TCP_connection(TCP_Secure_Connection *con)
function kill_accepted (line 471) | static int kill_accepted(TCP_Server *TCP_server, int index)
function handle_TCP_handshake (line 494) | static int handle_TCP_handshake(TCP_Secure_Connection *con, const uint8_...
function read_connection_handshake (line 541) | static int read_connection_handshake(TCP_Secure_Connection *con, const u...
function send_routing_response (line 557) | static int send_routing_response(TCP_Secure_Connection *con, uint8_t rpi...
function send_connect_notification (line 571) | static int send_connect_notification(TCP_Secure_Connection *con, uint8_t...
function send_disconnect_notification (line 581) | static int send_disconnect_notification(TCP_Secure_Connection *con, uint...
function handle_TCP_routing_req (line 590) | static int handle_TCP_routing_req(TCP_Server *TCP_server, uint32_t con_i...
function handle_TCP_oob_send (line 668) | static int handle_TCP_oob_send(TCP_Server *TCP_server, uint32_t con_id, ...
function rm_connection_index (line 695) | static int rm_connection_index(TCP_Server *TCP_server, TCP_Secure_Connec...
function handle_onion_recv_1 (line 725) | static int handle_onion_recv_1(void *object, IP_Port dest, const uint8_t...
function handle_TCP_packet (line 751) | static int handle_TCP_packet(TCP_Server *TCP_server, uint32_t con_id, co...
function confirm_TCP_connection (line 872) | static int confirm_TCP_connection(TCP_Server *TCP_server, TCP_Secure_Con...
function accept_connection (line 895) | static int accept_connection(TCP_Server *TCP_server, sock_t sock)
function sock_t (line 925) | static sock_t new_listening_TCP_socket(int family, uint16_t port)
function TCP_Server (line 953) | TCP_Server *new_TCP_server(uint8_t ipv6_enabled, uint16_t num_sockets, c...
function do_TCP_accept_new (line 1037) | static void do_TCP_accept_new(TCP_Server *TCP_server)
function do_incoming (line 1052) | static int do_incoming(TCP_Server *TCP_server, uint32_t i)
function do_unconfirmed (line 1079) | static int do_unconfirmed(TCP_Server *TCP_server, uint32_t i)
function do_confirmed_recv (line 1100) | static void do_confirmed_recv(TCP_Server *TCP_server, uint32_t i)
function do_TCP_incomming (line 1121) | static void do_TCP_incomming(TCP_Server *TCP_server)
function do_TCP_unconfirmed (line 1130) | static void do_TCP_unconfirmed(TCP_Server *TCP_server)
function do_TCP_confirmed (line 1139) | static void do_TCP_confirmed(TCP_Server *TCP_server)
function do_TCP_epoll (line 1194) | static void do_TCP_epoll(TCP_Server *TCP_server)
function do_TCP_server (line 1316) | void do_TCP_server(TCP_Server *TCP_server)
function kill_TCP_server (line 1332) | void kill_TCP_server(TCP_Server *TCP_server)
FILE: toxcore/TCP_server.h
type TCP_Priority_List (line 83) | typedef struct TCP_Priority_List TCP_Priority_List;
type TCP_Priority_List (line 85) | struct TCP_Priority_List {
type TCP_Secure_Connection (line 91) | typedef struct TCP_Secure_Connection {
type TCP_Server (line 118) | typedef struct {
FILE: toxcore/assoc.c
type bucket_t (line 54) | typedef uint16_t bucket_t;
type hash_t (line 55) | typedef uint32_t hash_t;
type usecnt_t (line 56) | typedef uint16_t usecnt_t;
type Assoc_distance_relative_callback (line 59) | typedef Assoc_distance_relative_callback dist_rel_cb;
type Assoc_distance_absolute_callback (line 60) | typedef Assoc_distance_absolute_callback dist_abs_cb;
type Client_entry (line 65) | typedef struct Client_entry {
type candidates_bucket (line 84) | typedef struct candidates_bucket {
type Assoc (line 88) | struct Assoc {
function id_distance (line 106) | static uint64_t id_distance(const Assoc *assoc, void *callback_data, con...
function dist_index_comp (line 124) | static int dist_index_comp(const void *a, const void *b)
function Client_entry (line 139) | static Client_entry *dist_index_entry(Assoc *assoc, uint64_t dist_ind)
function dist_index_bubble (line 172) | static void dist_index_bubble(Assoc *assoc, uint64_t *dist_list, size_t ...
function hash_t (line 199) | static hash_t id_hash(const Assoc *assoc, const uint8_t *id)
function hash_t (line 216) | static hash_t hash_collide(const Assoc *assoc, hash_t hash)
function IPPTsPng (line 244) | static IPPTsPng *entry_assoc(Client_entry *cl_entry, const IP_Port *ipp)
function IP_Port (line 259) | static IP_Port *entry_heard_get(Client_entry *entry, const IP_Port *ipp)
function entry_heard_store (line 274) | static int entry_heard_store(Client_entry *entry, const IPPTs *ippts)
function assoc_id_closest (line 318) | static int assoc_id_closest(const Assoc *assoc, void *callback_data, con...
function bucket_t (line 324) | static bucket_t id_bucket(const uint8_t *id, uint8_t bits)
function bucket_t (line 344) | static bucket_t candidates_id_bucket(const Assoc *assoc, const uint8_t *id)
function candidates_search (line 349) | static uint8_t candidates_search(const Assoc *assoc, const uint8_t *id, ...
function candidates_update_assoc (line 369) | static void candidates_update_assoc(const Assoc *assoc, Client_entry *en...
function candidates_create_internal (line 401) | static uint8_t candidates_create_internal(const Assoc *assoc, hash_t con...
function candidates_create_new (line 458) | static uint8_t candidates_create_new(const Assoc *assoc, hash_t hash, co...
function client_id_self_update (line 511) | static void client_id_self_update(Assoc *assoc)
function Assoc_add_entry (line 552) | uint8_t Assoc_add_entry(Assoc *assoc, const uint8_t *id, const IPPTs *ip...
function Assoc_get_close_entries (line 602) | uint8_t Assoc_get_close_entries(Assoc *assoc, Assoc_close_entries *state)
function odd_min9_is_prime (line 753) | static uint8_t odd_min9_is_prime(size_t value)
function prime_upto_min9 (line 767) | static size_t prime_upto_min9(size_t limit)
function Assoc (line 779) | Assoc *new_Assoc(size_t bits, size_t entries, const uint8_t *public_id)
function Assoc (line 864) | Assoc *new_Assoc_default(const uint8_t *public_id)
function Assoc_self_client_id_changed (line 872) | void Assoc_self_client_id_changed(Assoc *assoc, const uint8_t *id)
function do_Assoc (line 886) | void do_Assoc(Assoc *assoc, DHT *dht)
function kill_Assoc (line 968) | void kill_Assoc(Assoc *assoc)
function Assoc_status (line 994) | void Assoc_status(const Assoc *assoc)
FILE: toxcore/assoc.h
type NODE_STATUS (line 11) | enum NODE_STATUS { BAD, SEENB_HEARDG, SEENG, USED }
type Assoc (line 18) | typedef struct Assoc Assoc;
type AssocCloseEntriesFlags (line 43) | typedef enum AssocCloseEntriesFlags {
type Assoc_close_entries (line 49) | typedef struct Assoc_close_entries {
FILE: toxcore/crypto_core.c
function public_key_cmp (line 39) | int public_key_cmp(const uint8_t *pk1, const uint8_t *pk2)
function random_int (line 46) | uint32_t random_int(void)
function random_64b (line 53) | uint64_t random_64b(void)
function public_key_valid (line 66) | int public_key_valid(const uint8_t *public_key)
function encrypt_precompute (line 79) | void encrypt_precompute(const uint8_t *public_key, const uint8_t *secret...
function encrypt_data_symmetric (line 84) | int encrypt_data_symmetric(const uint8_t *secret_key, const uint8_t *non...
function decrypt_data_symmetric (line 104) | int decrypt_data_symmetric(const uint8_t *secret_key, const uint8_t *non...
function encrypt_data (line 123) | int encrypt_data(const uint8_t *public_key, const uint8_t *secret_key, c...
function decrypt_data (line 136) | int decrypt_data(const uint8_t *public_key, const uint8_t *secret_key, c...
function increment_nonce (line 151) | void increment_nonce(uint8_t *nonce)
function increment_nonce_number (line 169) | void increment_nonce_number(uint8_t *nonce, uint32_t host_order_num)
function random_nonce (line 195) | void random_nonce(uint8_t *nonce)
function new_symmetric_key (line 201) | void new_symmetric_key(uint8_t *key)
function new_nonce (line 207) | void new_nonce(uint8_t *nonce)
function create_request (line 222) | int create_request(const uint8_t *send_public_key, const uint8_t *send_s...
function handle_request (line 256) | int handle_request(const uint8_t *self_public_key, const uint8_t *self_s...
FILE: toxcore/friend_connection.c
function friendconn_id_not_valid (line 34) | static uint8_t friendconn_id_not_valid(const Friend_Connections *fr_c, i...
function realloc_friendconns (line 54) | static int realloc_friendconns(Friend_Connections *fr_c, uint32_t num)
function create_friend_conn (line 76) | static int create_friend_conn(Friend_Connections *fr_c)
function wipe_friend_conn (line 101) | static int wipe_friend_conn(Friend_Connections *fr_c, int friendcon_id)
function Friend_Conn (line 122) | static Friend_Conn *get_conn(const Friend_Connections *fr_c, int friendc...
function getfriend_conn_id_pk (line 133) | int getfriend_conn_id_pk(Friend_Connections *fr_c, const uint8_t *real_pk)
function friend_add_tcp_relay (line 154) | int friend_add_tcp_relay(Friend_Connections *fr_c, int friendcon_id, IP_...
function connect_to_saved_tcp_relays (line 189) | static void connect_to_saved_tcp_relays(Friend_Connections *fr_c, int fr...
function send_relays (line 210) | static unsigned int send_relays(Friend_Connections *fr_c, int friendcon_id)
function tcp_relay_node_callback (line 248) | static int tcp_relay_node_callback(void *object, uint32_t number, IP_Por...
function dht_ip_callback (line 265) | static void dht_ip_callback(void *object, int32_t number, IP_Port ip_port)
function change_dht_pk (line 287) | static void change_dht_pk(Friend_Connections *fr_c, int friendcon_id, co...
function handle_status (line 309) | static int handle_status(void *object, int number, uint8_t status)
function dht_pk_callback (line 351) | static void dht_pk_callback(void *object, int32_t number, const uint8_t ...
function handle_packet (line 375) | static int handle_packet(void *object, int number, uint8_t *data, uint16...
function handle_lossy_packet (line 426) | static int handle_lossy_packet(void *object, int number, const uint8_t *...
function handle_new_connections (line 453) | static int handle_new_connections(void *object, New_Connection *n_c)
function friend_new_connection (line 493) | static int friend_new_connection(Friend_Connections *fr_c, int friendcon...
function send_ping (line 523) | static int send_ping(const Friend_Connections *fr_c, int friendcon_id)
function friend_connection_lock (line 546) | int friend_connection_lock(Friend_Connections *fr_c, int friendcon_id)
function friend_con_connected (line 561) | unsigned int friend_con_connected(Friend_Connections *fr_c, int friendco...
function get_friendcon_public_keys (line 576) | int get_friendcon_public_keys(uint8_t *real_pk, uint8_t *dht_temp_pk, Fr...
function set_dht_temp_pk (line 594) | void set_dht_temp_pk(Friend_Connections *fr_c, int friendcon_id, const u...
function friend_connection_callbacks (line 605) | int friend_connection_callbacks(Friend_Connections *fr_c, int friendcon_...
function friend_connection_crypt_connection_id (line 637) | int friend_connection_crypt_connection_id(Friend_Connections *fr_c, int ...
function new_friend_connection (line 653) | int new_friend_connection(Friend_Connections *fr_c, const uint8_t *real_...
function kill_friend_connection (line 690) | int kill_friend_connection(Friend_Connections *fr_c, int friendcon_id)
function set_friend_request_callback (line 717) | void set_friend_request_callback(Friend_Connections *fr_c, int (*fr_requ...
function send_friend_request_packet (line 731) | int send_friend_request_packet(Friend_Connections *fr_c, int friendcon_i...
function Friend_Connections (line 761) | Friend_Connections *new_friend_connections(Onion_Client *onion_c)
function LANdiscovery (line 782) | static void LANdiscovery(Friend_Connections *fr_c)
function do_friend_connections (line 791) | void do_friend_connections(Friend_Connections *fr_c)
function kill_friend_connections (line 842) | void kill_friend_connections(Friend_Connections *fr_c)
FILE: toxcore/friend_connection.h
type Friend_Conn (line 66) | typedef struct {
type Friend_Connections (line 104) | typedef struct {
FILE: toxcore/friend_requests.c
function set_nospam (line 33) | void set_nospam(Friend_Requests *fr, uint32_t num)
function get_nospam (line 38) | uint32_t get_nospam(const Friend_Requests *fr)
function callback_friendrequest (line 45) | void callback_friendrequest(Friend_Requests *fr, void (*function)(void *...
function set_filter_function (line 54) | void set_filter_function(Friend_Requests *fr, int (*function)(const uint...
function addto_receivedlist (line 61) | static void addto_receivedlist(Friend_Requests *fr, const uint8_t *real_pk)
function request_received (line 75) | static int request_received(Friend_Requests *fr, const uint8_t *real_pk)
function remove_request_received (line 91) | int remove_request_received(Friend_Requests *fr, const uint8_t *real_pk)
function friendreq_handlepacket (line 106) | static int friendreq_handlepacket(void *object, const uint8_t *source_pu...
function friendreq_init (line 141) | void friendreq_init(Friend_Requests *fr, Friend_Connections *fr_c)
FILE: toxcore/friend_requests.h
type Friend_Requests (line 31) | typedef struct {
FILE: toxcore/group.c
function groupnumber_not_valid (line 34) | static uint8_t groupnumber_not_valid(const Group_Chats *g_c, int groupnu...
function realloc_groupchats (line 54) | static int realloc_groupchats(Group_Chats *g_c, uint32_t num)
function create_group_chat (line 77) | static int create_group_chat(Group_Chats *g_c)
function wipe_group_chat (line 103) | static int wipe_group_chat(Group_Chats *g_c, int groupnumber)
function Group_c (line 124) | static Group_c *get_group_c(const Group_Chats *g_c, int groupnumber)
function peer_in_chat (line 141) | static int peer_in_chat(const Group_c *chat, const uint8_t *real_pk)
function get_group_num (line 160) | static int get_group_num(const Group_Chats *g_c, const uint8_t *identifier)
function get_peer_index (line 179) | static int get_peer_index(Group_c *g, uint16_t peer_number)
function calculate_comp_value (line 191) | static uint64_t calculate_comp_value(const uint8_t *pk1, const uint8_t *...
function add_to_closest (line 214) | static int add_to_closest(Group_Chats *g_c, int groupnumber, const uint8...
function pk_in_closest_peers (line 294) | static unsigned int pk_in_closest_peers(Group_c *g, uint8_t *real_pk)
function connect_to_closest (line 312) | static int connect_to_closest(Group_Chats *g_c, int groupnumber)
function addpeer (line 384) | static int addpeer(Group_Chats *g_c, int groupnumber, const uint8_t *rea...
function remove_close_conn (line 437) | static int remove_close_conn(Group_Chats *g_c, int groupnumber, int frie...
function delpeer (line 467) | static int delpeer(Group_Chats *g_c, int groupnumber, int peer_index)
function setnick (line 519) | static int setnick(Group_Chats *g_c, int groupnumber, int peer_index, co...
function settitle (line 545) | static int settitle(Group_Chats *g_c, int groupnumber, int peer_index, c...
function set_conns_type_close (line 568) | static void set_conns_type_close(Group_Chats *g_c, int groupnumber, int ...
function set_conns_status_groups (line 592) | static void set_conns_status_groups(Group_Chats *g_c, int friendcon_id, ...
function handle_status (line 601) | static int handle_status(void *object, int friendcon_id, uint8_t status)
function add_conn_to_groupchat (line 623) | static int add_conn_to_groupchat(Group_Chats *g_c, int friendcon_id, int...
function add_groupchat (line 667) | int add_groupchat(Group_Chats *g_c, uint8_t type)
function del_groupchat (line 699) | int del_groupchat(Group_Chats *g_c, int groupnumber)
function group_peer_pubkey (line 737) | int group_peer_pubkey(const Group_Chats *g_c, int groupnumber, int peern...
function group_peername (line 757) | int group_peername(const Group_Chats *g_c, int groupnumber, int peernumb...
function group_names (line 786) | int group_names(const Group_Chats *g_c, int groupnumber, uint8_t names[]...
function group_number_peers (line 806) | int group_number_peers(const Group_Chats *g_c, int groupnumber)
function group_peernumber_is_ours (line 819) | unsigned int group_peernumber_is_ours(const Group_Chats *g_c, int groupn...
function group_get_type (line 840) | int group_get_type(const Group_Chats *g_c, int groupnumber)
function send_packet_group_peer (line 855) | static unsigned int send_packet_group_peer(Friend_Connections *fr_c, int...
function send_lossy_group_peer (line 875) | static unsigned int send_lossy_group_peer(Friend_Connections *fr_c, int ...
function invite_friend (line 900) | int invite_friend(Group_Chats *g_c, int32_t friendnumber, int groupnumber)
function join_groupchat (line 930) | int join_groupchat(Group_Chats *g_c, int32_t friendnumber, uint8_t expec...
function g_callback_group_invite (line 990) | void g_callback_group_invite(Group_Chats *g_c, void (*function)(Messenge...
function g_callback_group_message (line 1001) | void g_callback_group_message(Group_Chats *g_c, void (*function)(Messeng...
function g_callback_group_action (line 1012) | void g_callback_group_action(Group_Chats *g_c, void (*function)(Messenge...
function group_lossy_packet_registerhandler (line 1025) | void group_lossy_packet_registerhandler(Group_Chats *g_c, uint8_t byte, ...
function g_callback_group_namelistchange (line 1036) | void g_callback_group_namelistchange(Group_Chats *g_c, void (*function)(...
function g_callback_group_title (line 1048) | void g_callback_group_title(Group_Chats *g_c, void (*function)(Messenger...
function callback_groupchat_peer_new (line 1062) | int callback_groupchat_peer_new(const Group_Chats *g_c, int groupnumber,...
function callback_groupchat_peer_delete (line 1080) | int callback_groupchat_peer_delete(Group_Chats *g_c, int groupnumber, vo...
function callback_groupchat_delete (line 1098) | int callback_groupchat_delete(Group_Chats *g_c, int groupnumber, void (*...
function group_ping_send (line 1113) | int group_ping_send(const Group_Chats *g_c, int groupnumber)
function group_new_peer_send (line 1128) | int group_new_peer_send(const Group_Chats *g_c, int groupnumber, uint16_...
function group_kill_peer_send (line 1152) | static int group_kill_peer_send(const Group_Chats *g_c, int groupnumber,...
function group_name_send (line 1172) | static int group_name_send(const Group_Chats *g_c, int groupnumber, cons...
function group_title_send (line 1190) | int group_title_send(const Group_Chats *g_c, int groupnumber, const uint...
function group_title_get (line 1222) | int group_title_get(const Group_Chats *g_c, int groupnumber, uint8_t *ti...
function handle_friend_invite_packet (line 1239) | static void handle_friend_invite_packet(Messenger *m, uint32_t friendnum...
function friend_in_close (line 1325) | static int friend_in_close(Group_c *g, int friendcon_id)
function count_close_connected (line 1344) | static unsigned int count_close_connected(Group_c *g)
function send_packet_online (line 1359) | static int send_packet_online(Friend_Connections *fr_c, int friendcon_id...
function handle_packet_online (line 1372) | static int handle_packet_online(Group_Chats *g_c, int friendcon_id, uint...
function send_peer_kill (line 1430) | static unsigned int send_peer_kill(Group_Chats *g_c, int friendcon_id, u...
function send_peer_query (line 1441) | static unsigned int send_peer_query(Group_Chats *g_c, int friendcon_id, ...
function send_peers (line 1451) | static unsigned int send_peers(Group_Chats *g_c, int groupnumber, int fr...
function handle_send_peers (line 1505) | static int handle_send_peers(Group_Chats *g_c, int groupnumber, const ui...
function handle_direct_packet (line 1548) | static void handle_direct_packet(Group_Chats *g_c, int groupnumber, cons...
function send_message_all_close (line 1601) | static unsigned int send_message_all_close(const Group_Chats *g_c, int g...
function send_lossy_all_close (line 1631) | static unsigned int send_lossy_all_close(const Group_Chats *g_c, int gro...
function send_message_group (line 1717) | static unsigned int send_message_group(const Group_Chats *g_c, int group...
function group_message_send (line 1755) | int group_message_send(const Group_Chats *g_c, int groupnumber, const ui...
function group_action_send (line 1768) | int group_action_send(const Group_Chats *g_c, int groupnumber, const uin...
function send_group_lossy_packet (line 1782) | int send_group_lossy_packet(const Group_Chats *g_c, int groupnumber, con...
function handle_message_packet_group (line 1805) | static void handle_message_packet_group(Group_Chats *g_c, int groupnumbe...
function handle_packet (line 1933) | static int handle_packet(void *object, int friendcon_id, uint8_t *data, ...
function lossy_packet_not_received (line 1987) | static unsigned int lossy_packet_not_received(Group_c *g, int peer_index...
function handle_lossy (line 2038) | static int handle_lossy(void *object, int friendcon_id, const uint8_t *d...
function group_set_object (line 2101) | int group_set_object(const Group_Chats *g_c, int groupnumber, void *object)
function group_peer_set_object (line 2117) | int group_peer_set_object(const Group_Chats *g_c, int groupnumber, int p...
function ping_groupchat (line 2167) | static int ping_groupchat(Group_Chats *g_c, int groupnumber)
function groupchat_clear_timedout (line 2182) | static int groupchat_clear_timedout(Group_Chats *g_c, int groupnumber)
function send_name_all_groups (line 2205) | void send_name_all_groups(Group_Chats *g_c)
function Group_Chats (line 2222) | Group_Chats *new_groupchats(Messenger *m)
function do_groupchats (line 2241) | void do_groupchats(Group_Chats *g_c)
function kill_groupchats (line 2262) | void kill_groupchats(Group_Chats *g_c)
function count_chatlist (line 2279) | uint32_t count_chatlist(Group_Chats *g_c)
function copy_chatlist (line 2298) | uint32_t copy_chatlist(Group_Chats *g_c, int32_t *out_list, uint32_t lis...
FILE: toxcore/group.h
type Group_Peer (line 43) | typedef struct {
type Group_c (line 71) | typedef struct {
type Group_Chats (line 112) | typedef struct {
FILE: toxcore/list.c
function find (line 48) | static int find(const BS_LIST *list, const uint8_t *data)
function resize (line 114) | static int resize(BS_LIST *list, uint32_t new_size)
function bs_list_init (line 138) | int bs_list_init(BS_LIST *list, uint32_t element_size, uint32_t initial_...
function bs_list_free (line 158) | void bs_list_free(BS_LIST *list)
function bs_list_find (line 165) | int bs_list_find(const BS_LIST *list, const uint8_t *data)
function bs_list_add (line 177) | int bs_list_add(BS_LIST *list, const uint8_t *data, int id)
function bs_list_remove (line 217) | int bs_list_remove(BS_LIST *list, const uint8_t *data, int id)
function bs_list_trim (line 248) | int bs_list_trim(BS_LIST *list)
FILE: toxcore/list.h
type BS_LIST (line 33) | typedef struct {
FILE: toxcore/logger.c
type Logger (line 47) | struct Logger {
type tm (line 75) | struct tm
function Logger (line 88) | Logger *logger_new (const char *file_name, LOG_LEVEL level, const char *id)
function logger_kill (line 148) | void logger_kill(Logger *log)
function logger_kill_global (line 172) | void logger_kill_global(void)
function logger_set_global (line 178) | void logger_set_global(Logger *log)
function Logger (line 187) | Logger *logger_get_global(void)
function logger_write (line 196) | void logger_write (Logger *log, LOG_LEVEL level, const char *file, int l...
FILE: toxcore/logger.h
type LOG_LEVEL (line 38) | typedef enum {
type Logger (line 46) | typedef struct Logger Logger;
FILE: toxcore/net_crypto.c
function crypt_connection_id_not_valid (line 35) | static uint8_t crypt_connection_id_not_valid(const Net_Crypto *c, int cr...
function create_cookie_request (line 67) | static int create_cookie_request(const Net_Crypto *c, uint8_t *packet, u...
function create_cookie (line 97) | static int create_cookie(uint8_t *cookie, const uint8_t *bytes, const ui...
function open_cookie (line 117) | static int open_cookie(uint8_t *bytes, const uint8_t *cookie, const uint...
function create_cookie_response (line 145) | static int create_cookie_response(const Net_Crypto *c, uint8_t *packet, ...
function handle_cookie_request (line 174) | static int handle_cookie_request(const Net_Crypto *c, uint8_t *request_p...
function udp_handle_cookie_request (line 194) | static int udp_handle_cookie_request(void *object, IP_Port source, const...
function tcp_handle_cookie_request (line 217) | static int tcp_handle_cookie_request(Net_Crypto *c, int connections_numb...
function tcp_oob_handle_cookie_request (line 237) | static int tcp_oob_handle_cookie_request(const Net_Crypto *c, unsigned i...
function handle_cookie_response (line 267) | static int handle_cookie_response(uint8_t *cookie, uint64_t *number, con...
function create_crypto_handshake (line 294) | static int create_crypto_handshake(const Net_Crypto *c, uint8_t *packet,...
function handle_crypto_handshake (line 340) | static int handle_crypto_handshake(const Net_Crypto *c, uint8_t *nonce, ...
function Crypto_Connection (line 379) | static Crypto_Connection *get_crypto_connection(const Net_Crypto *c, int...
function add_ip_port_connection (line 393) | static int add_ip_port_connection(Net_Crypto *c, int crypt_connection_id...
function IP_Port (line 428) | IP_Port return_ip_port_connection(Net_Crypto *c, int crypt_connection_id)
function send_packet_to (line 465) | static int send_packet_to(Net_Crypto *c, int crypt_connection_id, const ...
function num_packets_array (line 531) | static uint32_t num_packets_array(const Packets_Array *array)
function add_data_to_buffer (line 541) | static int add_data_to_buffer(Packets_Array *array, uint32_t number, con...
function get_data_pointer (line 571) | static int get_data_pointer(const Packets_Array *array, Packet_Data **da...
function add_data_end_of_buffer (line 592) | static int64_t add_data_end_of_buffer(Packets_Array *array, const Packet...
function read_data_beg_buffer (line 614) | static int64_t read_data_beg_buffer(Packets_Array *array, Packet_Data *d...
function clear_buffer_until (line 637) | static int clear_buffer_until(Packets_Array *array, uint32_t number)
function clear_buffer (line 659) | static int clear_buffer(Packets_Array *array)
function set_buffer_end (line 681) | static int set_buffer_end(Packets_Array *array, uint32_t number)
function generate_request_packet (line 699) | static int generate_request_packet(uint8_t *data, uint16_t length, const...
function handle_request_packet (line 748) | static int handle_request_packet(Packets_Array *send_array, const uint8_...
function send_data_packet (line 828) | static int send_data_packet(Net_Crypto *c, int crypt_connection_id, cons...
function send_data_packet_helper (line 860) | static int send_data_packet_helper(Net_Crypto *c, int crypt_connection_i...
function reset_max_speed_reached (line 878) | static int reset_max_speed_reached(Net_Crypto *c, int crypt_connection_id)
function send_lossless_packet (line 918) | static int64_t send_lossless_packet(Net_Crypto *c, int crypt_connection_...
function get_nonce_uint16 (line 968) | static uint16_t get_nonce_uint16(const uint8_t *nonce)
function handle_data_packet (line 984) | static int handle_data_packet(const Net_Crypto *c, int crypt_connection_...
function send_request_packet (line 1021) | static int send_request_packet(Net_Crypto *c, int crypt_connection_id)
function send_requested_packets (line 1043) | static int send_requested_packets(Net_Crypto *c, int crypt_connection_id...
function new_temp_packet (line 1090) | static int new_temp_packet(const Net_Crypto *c, int crypt_connection_id,...
function clear_temp_packet (line 1121) | static int clear_temp_packet(const Net_Crypto *c, int crypt_connection_id)
function send_temp_packet (line 1144) | static int send_temp_packet(Net_Crypto *c, int crypt_connection_id)
function create_send_handshake (line 1168) | static int create_send_handshake(Net_Crypto *c, int crypt_connection_id,...
function send_kill_packet (line 1194) | static int send_kill_packet(Net_Crypto *c, int crypt_connection_id)
function connection_kill (line 1206) | static void connection_kill(Net_Crypto *c, int crypt_connection_id)
function handle_data_packet_helper (line 1225) | static int handle_data_packet_helper(Net_Crypto *c, int crypt_connection...
function handle_packet_connection (line 1362) | static int handle_packet_connection(Net_Crypto *c, int crypt_connection_...
function realloc_cryptoconnection (line 1449) | static int realloc_cryptoconnection(Net_Crypto *c, uint32_t num)
function create_crypto_connection (line 1472) | static int create_crypto_connection(Net_Crypto *c)
function wipe_crypto_connection (line 1513) | static int wipe_crypto_connection(Net_Crypto *c, int crypt_connection_id)
function getcryptconnection_id (line 1546) | static int getcryptconnection_id(const Net_Crypto *c, const uint8_t *pub...
function crypto_connection_add_source (line 1566) | static int crypto_connection_add_source(Net_Crypto *c, int crypt_connect...
function new_connection_handler (line 1599) | void new_connection_handler(Net_Crypto *c, int (*new_connection_callback...
function handle_new_connection_handshake (line 1612) | static int handle_new_connection_handshake(Net_Crypto *c, IP_Port source...
function accept_crypto_connection (line 1667) | int accept_crypto_connection(Net_Crypto *c, New_Connection *n_c)
function new_crypto_connection (line 1721) | int new_crypto_connection(Net_Crypto *c, const uint8_t *real_public_key,...
function set_direct_ip_port (line 1779) | int set_direct_ip_port(Net_Crypto *c, int crypt_connection_id, IP_Port i...
function tcp_data_callback (line 1808) | static int tcp_data_callback(void *object, int id, const uint8_t *data, ...
function tcp_oob_callback (line 1835) | static int tcp_oob_callback(void *object, const uint8_t *public_key, uns...
function add_tcp_relay_peer (line 1865) | int add_tcp_relay_peer(Net_Crypto *c, int crypt_connection_id, IP_Port i...
function add_tcp_relay (line 1883) | int add_tcp_relay(Net_Crypto *c, IP_Port ip_port, const uint8_t *public_...
function get_random_tcp_con_number (line 1899) | int get_random_tcp_con_number(Net_Crypto *c)
function send_tcp_onion_request (line 1913) | int send_tcp_onion_request(Net_Crypto *c, unsigned int tcp_connections_n...
function copy_connected_tcp_relays (line 1928) | unsigned int copy_connected_tcp_relays(Net_Crypto *c, Node_format *tcp_r...
function do_tcp (line 1940) | static void do_tcp(Net_Crypto *c)
function connection_status_handler (line 1981) | int connection_status_handler(const Net_Crypto *c, int crypt_connection_id,
function connection_data_handler (line 2003) | int connection_data_handler(const Net_Crypto *c, int crypt_connection_id...
function connection_lossy_data_handler (line 2025) | int connection_lossy_data_handler(Net_Crypto *c, int crypt_connection_id,
function nc_dht_pk_callback (line 2050) | int nc_dht_pk_callback(Net_Crypto *c, int crypt_connection_id, void (*fu...
function crypto_id_ip_port (line 2069) | static int crypto_id_ip_port(const Net_Crypto *c, IP_Port ip_port)
function udp_handle_packet (line 2084) | static int udp_handle_packet(void *object, IP_Port source, const uint8_t...
function send_crypto_packets (line 2140) | static void send_crypto_packets(Net_Crypto *c)
function _Bool (line 2372) | _Bool max_speed_reached(Net_Crypto *c, int crypt_connection_id)
function crypto_num_free_sendqueue_slots (line 2380) | uint32_t crypto_num_free_sendqueue_slots(const Net_Crypto *c, int crypt_...
function write_cryptpacket (line 2403) | int64_t write_cryptpacket(Net_Crypto *c, int crypt_connection_id, const ...
function cryptpacket_received (line 2447) | int cryptpacket_received(Net_Crypto *c, int crypt_connection_id, uint32_...
function send_lossy_cryptpacket (line 2469) | int send_lossy_cryptpacket(Net_Crypto *c, int crypt_connection_id, const...
function crypto_kill (line 2508) | int crypto_kill(Net_Crypto *c, int crypt_connection_id)
function crypto_connection_status (line 2550) | unsigned int crypto_connection_status(const Net_Crypto *c, int crypt_con...
function new_keys (line 2577) | void new_keys(Net_Crypto *c)
function save_keys (line 2587) | void save_keys(const Net_Crypto *c, uint8_t *keys)
function load_secret_key (line 2596) | void load_secret_key(Net_Crypto *c, const uint8_t *sk)
function Net_Crypto (line 2605) | Net_Crypto *new_net_crypto(DHT *dht, TCP_Proxy_Info *proxy_info)
function kill_timedout (line 2651) | static void kill_timedout(Net_Crypto *c)
function crypto_run_interval (line 2682) | uint32_t crypto_run_interval(const Net_Crypto *c)
function do_net_crypto (line 2688) | void do_net_crypto(Net_Crypto *c)
function kill_net_crypto (line 2696) | void kill_net_crypto(Net_Crypto *c)
FILE: toxcore/net_crypto.h
type Packet_Data (line 90) | typedef struct {
type Packets_Array (line 96) | typedef struct {
type Crypto_Connection (line 102) | typedef struct {
type New_Connection (line 181) | typedef struct {
type Net_Crypto (line 191) | typedef struct {
FILE: toxcore/network.c
type sockaddr_in (line 51) | struct sockaddr_in
type in_addr (line 55) | struct in_addr
type sockaddr_in6 (line 64) | struct sockaddr_in6
type in6_addr (line 68) | struct in6_addr
function inet_pton (line 81) | static int inet_pton(sa_family_t family, const char *addrString, void *a...
function kill_sock (line 136) | void kill_sock(sock_t sock)
function set_socket_nonblock (line 150) | int set_socket_nonblock(sock_t sock)
function set_socket_nosigpipe (line 165) | int set_socket_nosigpipe(sock_t sock)
function set_socket_reuseaddr (line 180) | int set_socket_reuseaddr(sock_t sock)
function set_socket_dualstack (line 191) | int set_socket_dualstack(sock_t sock)
function current_time_actual (line 206) | static uint64_t current_time_actual(void)
function current_time_monotonic (line 233) | uint64_t current_time_monotonic(void)
function sendpacket (line 295) | int sendpacket(Networking_Core *net, IP_Port ip_port, const uint8_t *dat...
function receivepacket (line 363) | static int receivepacket(sock_t sock, IP_Port *ip_port, uint8_t *data, u...
function networking_registerhandler (line 409) | void networking_registerhandler(Networking_Core *net, uint8_t byte, pack...
function networking_poll (line 415) | void networking_poll(Networking_Core *net)
function networking_at_startup (line 444) | int networking_at_startup(void)
function Networking_Core (line 483) | Networking_Core *new_networking(IP ip, uint16_t port)
type sockaddr_storage (line 588) | struct sockaddr_storage
type sockaddr_in (line 592) | struct sockaddr_in
type sockaddr_in (line 592) | struct sockaddr_in
type sockaddr_in (line 594) | struct sockaddr_in
type sockaddr_in6 (line 601) | struct sockaddr_in6
type sockaddr_in6 (line 601) | struct sockaddr_in6
type sockaddr_in6 (line 603) | struct sockaddr_in6
type ipv6_mreq (line 625) | struct ipv6_mreq
type sockaddr (line 661) | struct sockaddr
function kill_networking (line 700) | void kill_networking(Networking_Core *net)
function ip_equal (line 719) | int ip_equal(const IP *a, const IP *b)
function ipport_equal (line 752) | int ipport_equal(const IP_Port *a, const IP_Port *b)
function ip_reset (line 764) | void ip_reset(IP *ip)
function ip_init (line 773) | void ip_init(IP *ip, uint8_t ipv6enabled)
function ip_isset (line 783) | int ip_isset(const IP *ip)
function ipport_isset (line 792) | int ipport_isset(const IP_Port *ipport)
function ip_copy (line 804) | void ip_copy(IP *target, const IP *source)
function ipport_copy (line 813) | void ipport_copy(IP_Port *target, const IP_Port *source)
type in_addr (line 835) | struct in_addr
type in_addr (line 835) | struct in_addr
type in6_addr (line 841) | struct in6_addr
type in6_addr (line 841) | struct in6_addr
function ip_parse_addr (line 873) | int ip_parse_addr(const IP *ip, char *address, size_t length)
function addr_parse_ip (line 903) | int addr_parse_ip(const char *address, IP *to)
function addr_resolve (line 944) | int addr_resolve(const char *address, IP *to, IP *extra)
function addr_resolve_or_parse_ip (line 1046) | int addr_resolve_or_parse_ip(const char *address, IP *to, IP *extra)
FILE: toxcore/network.h
type sock_t (line 51) | typedef unsigned int sock_t;
type sa_family_t (line 53) | typedef short sa_family_t;
type sock_t (line 71) | typedef int sock_t;
type IP4 (line 136) | typedef union {
type IP6 (line 144) | typedef union {
type IP (line 153) | typedef struct {
type IP_Port (line 162) | typedef struct {
type Packet_Handles (line 295) | typedef struct {
type Networking_Core (line 300) | typedef struct {
FILE: toxcore/onion.c
function change_symmetric_key (line 40) | static void change_symmetric_key(Onion *onion)
function ip_pack (line 49) | static void ip_pack(uint8_t *data, IP source)
function ip_unpack (line 64) | static int ip_unpack(IP *target, const uint8_t *data, unsigned int data_...
function ipport_pack (line 85) | static void ipport_pack(uint8_t *data, const IP_Port *source)
function ipport_unpack (line 92) | static int ipport_unpack(IP_Port *target, const uint8_t *data, unsigned ...
function create_onion_path (line 114) | int create_onion_path(const DHT *dht, Onion_Path *new_path, const Node_f...
function onion_path_to_nodes (line 149) | int onion_path_to_nodes(Node_format *nodes, unsigned int num_nodes, cons...
function create_onion_packet (line 173) | int create_onion_packet(uint8_t *packet, uint16_t max_packet_length, con...
function create_onion_packet_tcp (line 228) | int create_onion_packet_tcp(uint8_t *packet, uint16_t max_packet_length,...
function send_onion_packet (line 273) | int send_onion_packet(Networking_Core *net, const Onion_Path *path, IP_P...
function send_onion_response (line 293) | int send_onion_response(Networking_Core *net, IP_Port dest, const uint8_...
function handle_send_initial (line 309) | static int handle_send_initial(void *object, IP_Port source, const uint8...
function onion_send_1 (line 333) | int onion_send_1(const Onion *onion, const uint8_t *plain, uint16_t len,...
function handle_send_1 (line 370) | static int handle_send_1(void *object, IP_Port source, const uint8_t *pa...
function handle_send_2 (line 420) | static int handle_send_2(void *object, IP_Port source, const uint8_t *pa...
function handle_recv_3 (line 478) | static int handle_recv_3(void *object, IP_Port source, const uint8_t *pa...
function handle_recv_2 (line 519) | static int handle_recv_2(void *object, IP_Port source, const uint8_t *pa...
function handle_recv_1 (line 560) | static int handle_recv_1(void *object, IP_Port source, const uint8_t *pa...
function set_callback_handle_recv_1 (line 600) | void set_callback_handle_recv_1(Onion *onion, int (*function)(void *, IP...
function Onion (line 606) | Onion *new_onion(DHT *dht)
function kill_onion (line 632) | void kill_onion(Onion *onion)
FILE: toxcore/onion.h
type Onion (line 28) | typedef struct {
type Onion_Path (line 58) | typedef struct {
FILE: toxcore/onion_announce.c
function create_announce_request (line 50) | int create_announce_request(uint8_t *packet, uint16_t max_packet_length,...
function create_data_request (line 89) | int create_data_request(uint8_t *packet, uint16_t max_packet_length, con...
function send_announce_request (line 132) | int send_announce_request(Networking_Core *net, const Onion_Path *path, ...
function send_data_request (line 169) | int send_data_request(Networking_Core *net, const Onion_Path *path, IP_P...
function generate_ping_id (line 191) | static void generate_ping_id(const Onion_Announce *onion_a, uint64_t tim...
function in_entries (line 208) | static int in_entries(const Onion_Announce *onion_a, const uint8_t *publ...
function cmp_entry (line 222) | static int cmp_entry(const void *a, const void *b)
function add_to_entries (line 255) | static int add_to_entries(Onion_Announce *onion_a, IP_Port ret_ip_port, ...
function handle_announce_request (line 289) | static int handle_announce_request(void *object, IP_Port source, const u...
function handle_data_request (line 383) | static int handle_data_request(void *object, IP_Port source, const uint8...
function Onion_Announce (line 409) | Onion_Announce *new_onion_announce(DHT *dht)
function kill_onion_announce (line 429) | void kill_onion_announce(Onion_Announce *onion_a)
FILE: toxcore/onion_announce.h
type Onion_Announce_Entry (line 48) | typedef struct {
type Onion_Announce (line 56) | typedef struct {
FILE: toxcore/onion_client.c
function onion_add_bs_path_node (line 41) | int onion_add_bs_path_node(Onion_Client *onion_c, IP_Port ip_port, const...
function onion_add_path_node (line 71) | static int onion_add_path_node(Onion_Client *onion_c, IP_Port ip_port, c...
function onion_backup_nodes (line 100) | uint16_t onion_backup_nodes(const Onion_Client *onion_c, Node_format *no...
function random_nodes_path_onion (line 126) | static uint16_t random_nodes_path_onion(const Onion_Client *onion_c, Nod...
function is_path_used (line 180) | static int is_path_used(const Onion_Client_Paths *onion_paths, const Nod...
function _Bool (line 203) | static _Bool path_timed_out(Onion_Client_Paths *onion_paths, uint32_t pa...
function random_path (line 221) | static int random_path(const Onion_Client *onion_c, Onion_Client_Paths *...
function _Bool (line 263) | static _Bool path_exists(Onion_Client_Paths *onion_paths, uint32_t path_...
function set_path_timeouts (line 274) | static uint32_t set_path_timeouts(Onion_Client *onion_c, uint32_t num, u...
function send_onion_packet_tcp_udp (line 312) | static int send_onion_packet_tcp_udp(const Onion_Client *onion_c, const ...
function new_sendback (line 354) | static int new_sendback(Onion_Client *onion_c, uint32_t num, const uint8...
function check_sendback (line 380) | static uint32_t check_sendback(Onion_Client *onion_c, const uint8_t *sen...
function client_send_announce_request (line 399) | static int client_send_announce_request(Onion_Client *onion_c, uint32_t ...
function cmp_entry (line 445) | static int cmp_entry(const void *a, const void *b)
function client_add_to_list (line 473) | static int client_add_to_list(Onion_Client *onion_c, uint32_t num, const...
function good_to_ping (line 545) | static int good_to_ping(Last_Pinged *last_pinged, uint8_t *last_pinged_i...
function client_ping_nodes (line 561) | static int client_ping_nodes(Onion_Client *onion_c, uint32_t num, const ...
function handle_announce_response (line 620) | static int handle_announce_response(void *object, IP_Port source, const ...
function handle_data_response (line 678) | static int handle_data_response(void *object, IP_Port source, const uint...
function handle_dhtpk_announce (line 712) | static int handle_dhtpk_announce(void *object, const uint8_t *source_pub...
function handle_tcp_onion (line 773) | static int handle_tcp_onion(void *object, const uint8_t *data, uint16_t ...
function send_onion_data (line 798) | int send_onion_data(Onion_Client *onion_c, int friend_num, const uint8_t...
function send_dht_dhtpk (line 867) | static int send_dht_dhtpk(const Onion_Client *onion_c, int friend_num, c...
function handle_dht_dhtpk (line 897) | static int handle_dht_dhtpk(void *object, IP_Port source, const uint8_t ...
function send_dhtpk_announce (line 930) | static int send_dhtpk_announce(Onion_Client *onion_c, uint16_t friend_nu...
function onion_friend_num (line 977) | int onion_friend_num(const Onion_Client *onion_c, const uint8_t *public_...
function realloc_onion_friends (line 997) | static int realloc_onion_friends(Onion_Client *onion_c, uint32_t num)
function onion_addfriend (line 1019) | int onion_addfriend(Onion_Client *onion_c, const uint8_t *public_key)
function onion_delfriend (line 1055) | int onion_delfriend(Onion_Client *onion_c, int friend_num)
function recv_tcp_relay_handler (line 1087) | int recv_tcp_relay_handler(Onion_Client *onion_c, int friend_num, int (*...
function onion_dht_pk_callback (line 1107) | int onion_dht_pk_callback(Onion_Client *onion_c, int friend_num, void (*...
function onion_set_friend_DHT_pubkey (line 1124) | int onion_set_friend_DHT_pubkey(Onion_Client *onion_c, int friend_num, c...
function onion_getfriend_DHT_pubkey (line 1152) | unsigned int onion_getfriend_DHT_pubkey(const Onion_Client *onion_c, int...
function onion_getfriendip (line 1174) | int onion_getfriendip(const Onion_Client *onion_c, int friend_num, IP_Po...
function onion_set_friend_online (line 1194) | int onion_set_friend_online(Onion_Client *onion_c, int friend_num, uint8...
function populate_path_nodes (line 1213) | static void populate_path_nodes(Onion_Client *onion_c)
function populate_path_nodes_tcp (line 1226) | static void populate_path_nodes_tcp(Onion_Client *onion_c)
function do_friend (line 1244) | static void do_friend(Onion_Client *onion_c, uint16_t friendnum)
function oniondata_registerhandler (line 1317) | void oniondata_registerhandler(Onion_Client *onion_c, uint8_t byte, onio...
function do_announce (line 1326) | static void do_announce(Onion_Client *onion_c)
function onion_isconnected (line 1383) | static int onion_isconnected(const Onion_Client *onion_c)
function onion_connection_status (line 1425) | unsigned int onion_connection_status(const Onion_Client *onion_c)
function do_onion_client (line 1438) | void do_onion_client(Onion_Client *onion_c)
function Onion_Client (line 1485) | Onion_Client *new_onion_client(Net_Crypto *c)
function kill_onion_client (line 1514) | void kill_onion_client(Onion_Client *onion_c)
FILE: toxcore/onion_client.h
type Onion_Node (line 63) | typedef struct {
type Onion_Client_Paths (line 77) | typedef struct {
type Last_Pinged (line 86) | typedef struct {
type Onion_Friend (line 91) | typedef struct {
type Onion_Client (line 127) | typedef struct {
FILE: toxcore/ping.c
type PING (line 48) | struct PING {
function send_ping_request (line 61) | int send_ping_request(PING *ping, IP_Port ipp, const uint8_t *public_key)
function send_ping_response (line 103) | static int send_ping_response(PING *ping, IP_Port ipp, const uint8_t *pu...
function handle_ping_request (line 132) | static int handle_ping_request(void *_dht, IP_Port source, const uint8_t...
function handle_ping_response (line 171) | static int handle_ping_response(void *_dht, IP_Port source, const uint8_...
function in_list (line 228) | static int in_list(const Client_data *list, uint16_t length, const uint8...
function add_to_ping (line 260) | int add_to_ping(PING *ping, const uint8_t *public_key, IP_Port ip_port)
function do_to_ping (line 302) | void do_to_ping(PING *ping)
function PING (line 328) | PING *new_ping(DHT *dht)
function kill_ping (line 347) | void kill_ping(PING *ping)
FILE: toxcore/ping.h
type PING (line 27) | typedef struct PING PING;
FILE: toxcore/ping_array.c
function clear_entry (line 33) | static void clear_entry(Ping_Array *array, uint32_t index)
function ping_array_clear_timedout (line 44) | static void ping_array_clear_timedout(Ping_Array *array)
function ping_array_add (line 62) | uint64_t ping_array_add(Ping_Array *array, const uint8_t *data, uint32_t...
function ping_array_check (line 101) | int ping_array_check(uint8_t *data, uint32_t length, Ping_Array *array, ...
function ping_array_init (line 133) | int ping_array_init(Ping_Array *empty_array, uint32_t size, uint32_t tim...
function ping_array_free_all (line 151) | void ping_array_free_all(Ping_Array *array)
FILE: toxcore/ping_array.h
type Ping_Array_Entry (line 28) | typedef struct {
type Ping_Array (line 36) | typedef struct {
FILE: toxcore/tox.c
type Tox (line 35) | typedef struct Messenger Tox;
function tox_version_major (line 73) | uint32_t tox_version_major(void)
function tox_version_minor (line 78) | uint32_t tox_version_minor(void)
function tox_version_patch (line 83) | uint32_t tox_version_patch(void)
function tox_version_is_compatible (line 88) | bool tox_version_is_compatible(uint32_t major, uint32_t minor, uint32_t ...
function tox_options_default (line 98) | void tox_options_default(struct Tox_Options *options)
type Tox_Options (line 108) | struct Tox_Options
type Tox_Options (line 110) | struct Tox_Options
type Tox_Options (line 110) | struct Tox_Options
function tox_options_free (line 122) | void tox_options_free(struct Tox_Options *options)
function Tox (line 127) | Tox *tox_new(const struct Tox_Options *options, TOX_ERR_NEW *error)
function tox_kill (line 241) | void tox_kill(Tox *tox)
function tox_get_savedata_size (line 249) | size_t tox_get_savedata_size(const Tox *tox)
function tox_get_savedata (line 255) | void tox_get_savedata(const Tox *tox, uint8_t *data)
function tox_bootstrap (line 263) | bool tox_bootstrap(Tox *tox, const char *address, uint16_t port, const u...
function tox_add_tcp_relay (line 320) | bool tox_add_tcp_relay(Tox *tox, const char *address, uint16_t port, con...
function TOX_CONNECTION (line 377) | TOX_CONNECTION tox_self_get_connection_status(const Tox *tox)
function tox_callback_self_connection_status (line 393) | void tox_callback_self_connection_status(Tox *tox, tox_self_connection_s...
function tox_iteration_interval (line 399) | uint32_t tox_iteration_interval(const Tox *tox)
function tox_iterate (line 405) | void tox_iterate(Tox *tox)
function tox_self_get_address (line 412) | void tox_self_get_address(const Tox *tox, uint8_t *address)
function tox_self_set_nospam (line 420) | void tox_self_set_nospam(Tox *tox, uint32_t nospam)
function tox_self_get_nospam (line 426) | uint32_t tox_self_get_nospam(const Tox *tox)
function tox_self_get_public_key (line 432) | void tox_self_get_public_key(const Tox *tox, uint8_t *public_key)
function tox_self_get_secret_key (line 440) | void tox_self_get_secret_key(const Tox *tox, uint8_t *secret_key)
function tox_self_set_name (line 448) | bool tox_self_set_name(Tox *tox, const uint8_t *name, size_t length, TOX...
function tox_self_get_name_size (line 468) | size_t tox_self_get_name_size(const Tox *tox)
function tox_self_get_name (line 474) | void tox_self_get_name(const Tox *tox, uint8_t *name)
function tox_self_set_status_message (line 482) | bool tox_self_set_status_message(Tox *tox, const uint8_t *status, size_t...
function tox_self_get_status_message_size (line 500) | size_t tox_self_get_status_message_size(const Tox *tox)
function tox_self_get_status_message (line 506) | void tox_self_get_status_message(const Tox *tox, uint8_t *status)
function tox_self_set_status (line 514) | void tox_self_set_status(Tox *tox, TOX_USER_STATUS user_status)
function TOX_USER_STATUS (line 520) | TOX_USER_STATUS tox_self_get_status(const Tox *tox)
function set_friend_error (line 526) | static void set_friend_error(int32_t ret, TOX_ERR_FRIEND_ADD *error)
function tox_friend_add (line 560) | uint32_t tox_friend_add(Tox *tox, const uint8_t *address, const uint8_t ...
function tox_friend_add_norequest (line 580) | uint32_t tox_friend_add_norequest(Tox *tox, const uint8_t *public_key, T...
function tox_friend_delete (line 599) | bool tox_friend_delete(Tox *tox, uint32_t friend_number, TOX_ERR_FRIEND_...
function tox_friend_by_public_key (line 614) | uint32_t tox_friend_by_public_key(const Tox *tox, const uint8_t *public_...
function tox_friend_get_public_key (line 633) | bool tox_friend_get_public_key(const Tox *tox, uint32_t friend_number, u...
function tox_friend_exists (line 651) | bool tox_friend_exists(const Tox *tox, uint32_t friend_number)
function tox_friend_get_last_online (line 657) | uint64_t tox_friend_get_last_online(const Tox *tox, uint32_t friend_numb...
function tox_self_get_friend_list_size (line 671) | size_t tox_self_get_friend_list_size(const Tox *tox)
function tox_self_get_friend_list (line 677) | void tox_self_get_friend_list(const Tox *tox, uint32_t *list)
function tox_friend_get_name_size (line 686) | size_t tox_friend_get_name_size(const Tox *tox, uint32_t friend_number, ...
function tox_friend_get_name (line 700) | bool tox_friend_get_name(const Tox *tox, uint32_t friend_number, uint8_t...
function tox_callback_friend_name (line 719) | void tox_callback_friend_name(Tox *tox, tox_friend_name_cb *function, vo...
function tox_friend_get_status_message_size (line 725) | size_t tox_friend_get_status_message_size(const Tox *tox, uint32_t frien...
function tox_friend_get_status_message (line 739) | bool tox_friend_get_status_message(const Tox *tox, uint32_t friend_numbe...
function tox_callback_friend_status_message (line 760) | void tox_callback_friend_status_message(Tox *tox, tox_friend_status_mess...
function TOX_USER_STATUS (line 766) | TOX_USER_STATUS tox_friend_get_status(const Tox *tox, uint32_t friend_nu...
function tox_callback_friend_status (line 781) | void tox_callback_friend_status(Tox *tox, tox_friend_status_cb *function...
function TOX_CONNECTION (line 787) | TOX_CONNECTION tox_friend_get_connection_status(const Tox *tox, uint32_t...
function tox_callback_friend_connection_status (line 802) | void tox_callback_friend_connection_status(Tox *tox, tox_friend_connecti...
function tox_friend_get_typing (line 808) | bool tox_friend_get_typing(const Tox *tox, uint32_t friend_number, TOX_E...
function tox_callback_friend_typing (line 822) | void tox_callback_friend_typing(Tox *tox, tox_friend_typing_cb *function...
function tox_self_set_typing (line 828) | bool tox_self_set_typing(Tox *tox, uint32_t friend_number, bool is_typin...
function set_message_error (line 841) | static void set_message_error(int ret, TOX_ERR_FRIEND_SEND_MESSAGE *error)
function tox_friend_send_message (line 870) | uint32_t tox_friend_send_message(Tox *tox, uint32_t friend_number, TOX_M...
function tox_callback_friend_read_receipt (line 889) | void tox_callback_friend_read_receipt(Tox *tox, tox_friend_read_receipt_...
function tox_callback_friend_request (line 895) | void tox_callback_friend_request(Tox *tox, tox_friend_request_cb *functi...
function tox_callback_friend_message (line 901) | void tox_callback_friend_message(Tox *tox, tox_friend_message_cb *functi...
function tox_hash (line 907) | bool tox_hash(uint8_t *hash, const uint8_t *data, size_t length)
function tox_file_control (line 917) | bool tox_file_control(Tox *tox, uint32_t friend_number, uint32_t file_nu...
function tox_file_seek (line 966) | bool tox_file_seek(Tox *tox, uint32_t friend_number, uint32_t file_numbe...
function tox_callback_file_recv_control (line 1008) | void tox_callback_file_recv_control(Tox *tox, tox_file_recv_control_cb *...
function tox_file_get_file_id (line 1014) | bool tox_file_get_file_id(const Tox *tox, uint32_t friend_number, uint32...
function tox_file_send (line 1037) | uint32_t tox_file_send(Tox *tox, uint32_t friend_number, uint32_t kind, ...
function tox_file_send_chunk (line 1083) | bool tox_file_send_chunk(Tox *tox, uint32_t friend_number, uint32_t file...
function tox_callback_file_chunk_request (line 1128) | void tox_callback_file_chunk_request(Tox *tox, tox_file_chunk_request_cb...
function tox_callback_file_recv (line 1134) | void tox_callback_file_recv(Tox *tox, tox_file_recv_cb *function, void *...
function tox_callback_file_recv_chunk (line 1140) | void tox_callback_file_recv_chunk(Tox *tox, tox_file_recv_chunk_cb *func...
function set_custom_packet_error (line 1146) | static void set_custom_packet_error(int ret, TOX_ERR_FRIEND_CUSTOM_PACKE...
function tox_friend_send_lossy_packet (line 1175) | bool tox_friend_send_lossy_packet(Tox *tox, uint32_t friend_number, cons...
function tox_callback_friend_lossy_packet (line 1206) | void tox_callback_friend_lossy_packet(Tox *tox, tox_friend_lossy_packet_...
function tox_friend_send_lossless_packet (line 1212) | bool tox_friend_send_lossless_packet(Tox *tox, uint32_t friend_number, c...
function tox_callback_friend_lossless_packet (line 1238) | void tox_callback_friend_lossless_packet(Tox *tox, tox_friend_lossless_p...
function tox_self_get_dht_id (line 1244) | void tox_self_get_dht_id(const Tox *tox, uint8_t *dht_id)
function tox_self_get_udp_port (line 1252) | uint16_t tox_self_get_udp_port(const Tox *tox, TOX_ERR_GET_PORT *error)
function tox_self_get_tcp_port (line 1266) | uint16_t tox_self_get_tcp_port(const Tox *tox, TOX_ERR_GET_PORT *error)
FILE: toxcore/tox.h
type Tox (line 130) | typedef struct Tox Tox;
type TOX_USER_STATUS (line 289) | typedef enum TOX_USER_STATUS {
type TOX_MESSAGE_TYPE (line 315) | typedef enum TOX_MESSAGE_TYPE {
type TOX_PROXY_TYPE (line 343) | typedef enum TOX_PROXY_TYPE {
type TOX_SAVEDATA_TYPE (line 366) | typedef enum TOX_SAVEDATA_TYPE {
type Tox_Options (line 391) | struct Tox_Options {
type Tox_Options (line 507) | struct Tox_Options
type TOX_ERR_OPTIONS_NEW (line 509) | typedef enum TOX_ERR_OPTIONS_NEW {
type Tox_Options (line 534) | struct Tox_Options
type Tox_Options (line 542) | struct Tox_Options
type TOX_ERR_NEW (line 553) | typedef enum TOX_ERR_NEW {
type Tox_Options (line 632) | struct Tox_Options
type TOX_ERR_BOOTSTRAP (line 669) | typedef enum TOX_ERR_BOOTSTRAP {
type TOX_CONNECTION (line 730) | typedef enum TOX_CONNECTION {
type TOX_ERR_SET_INFO (line 854) | typedef enum TOX_ERR_SET_INFO {
type TOX_ERR_FRIEND_ADD (line 965) | typedef enum TOX_ERR_FRIEND_ADD {
type TOX_ERR_FRIEND_DELETE (line 1064) | typedef enum TOX_ERR_FRIEND_DELETE {
type TOX_ERR_FRIEND_BY_PUBLIC_KEY (line 1101) | typedef enum TOX_ERR_FRIEND_BY_PUBLIC_KEY {
type TOX_ERR_FRIEND_GET_PUBLIC_KEY (line 1153) | typedef enum TOX_ERR_FRIEND_GET_PUBLIC_KEY {
type TOX_ERR_FRIEND_GET_LAST_ONLINE (line 1180) | typedef enum TOX_ERR_FRIEND_GET_LAST_ONLINE {
type TOX_ERR_FRIEND_QUERY (line 1215) | typedef enum TOX_ERR_FRIEND_QUERY {
type TOX_ERR_SET_TYPING (line 1414) | typedef enum TOX_ERR_SET_TYPING {
type TOX_ERR_FRIEND_SEND_MESSAGE (line 1441) | typedef enum TOX_ERR_FRIEND_SEND_MESSAGE {
type TOX_FILE_KIND (line 1602) | enum TOX_FILE_KIND {
type TOX_FILE_CONTROL (line 1635) | typedef enum TOX_FILE_CONTROL {
type TOX_ERR_FILE_CONTROL (line 1660) | typedef enum TOX_ERR_FILE_CONTROL {
type TOX_ERR_FILE_SEEK (line 1740) | typedef enum TOX_ERR_FILE_SEEK {
type TOX_ERR_FILE_GET (line 1793) | typedef enum TOX_ERR_FILE_GET {
type TOX_ERR_FILE_SEND (line 1841) | typedef enum TOX_ERR_FILE_SEND {
type TOX_ERR_FILE_SEND_CHUNK (line 1939) | typedef enum TOX_ERR_FILE_SEND_CHUNK {
type TOX_ERR_FRIEND_CUSTOM_PACKET (line 2137) | typedef enum TOX_ERR_FRIEND_CUSTOM_PACKET {
type TOX_ERR_GET_PORT (line 2278) | typedef enum TOX_ERR_GET_PORT {
FILE: toxcore/tox_old.h
type TOX_CHAT_CHANGE (line 51) | typedef enum {
FILE: toxcore/tox_old_code.h
function tox_callback_group_invite (line 9) | void tox_callback_group_invite(Tox *tox, void (*function)(Messenger *tox...
function tox_callback_group_message (line 20) | void tox_callback_group_message(Tox *tox, void (*function)(Messenger *to...
function tox_callback_group_action (line 31) | void tox_callback_group_action(Tox *tox, void (*function)(Messenger *tox...
function tox_callback_group_title (line 43) | void tox_callback_group_title(Tox *tox, void (*function)(Messenger *tox,...
function tox_callback_group_namelist_change (line 55) | void tox_callback_group_namelist_change(Tox *tox, void (*function)(Tox *...
function tox_add_groupchat (line 66) | int tox_add_groupchat(Tox *tox)
function tox_del_groupchat (line 77) | int tox_del_groupchat(Tox *tox, int groupnumber)
function tox_group_peername (line 89) | int tox_group_peername(const Tox *tox, int groupnumber, int peernumber, ...
function tox_group_peer_pubkey (line 101) | int tox_group_peer_pubkey(const Tox *tox, int groupnumber, int peernumbe...
function tox_invite_friend (line 111) | int tox_invite_friend(Tox *tox, int32_t friendnumber, int groupnumber)
function tox_join_groupchat (line 123) | int tox_join_groupchat(Tox *tox, int32_t friendnumber, const uint8_t *da...
function tox_group_message_send (line 133) | int tox_group_message_send(Tox *tox, int groupnumber, const uint8_t *mes...
function tox_group_action_send (line 143) | int tox_group_action_send(Tox *tox, int groupnumber, const uint8_t *acti...
function tox_group_set_title (line 153) | int tox_group_set_title(Tox *tox, int groupnumber, const uint8_t *title,...
function tox_group_get_title (line 165) | int tox_group_get_title(Tox *tox, int groupnumber, uint8_t *title, uint3...
function tox_group_peernumber_is_ours (line 176) | unsigned int tox_group_peernumber_is_ours(const Tox *tox, int groupnumbe...
function tox_group_number_peers (line 185) | int tox_group_number_peers(const Tox *tox, int groupnumber)
function tox_group_get_names (line 201) | int tox_group_get_names(const Tox *tox, int groupnumber, uint8_t names[]...
function tox_count_chatlist (line 211) | uint32_t tox_count_chatlist(const Tox *tox)
function tox_get_chatlist (line 222) | uint32_t tox_get_chatlist(const Tox *tox, int32_t *out_list, uint32_t li...
function tox_group_get_type (line 233) | int tox_group_get_type(const Tox *tox, int groupnumber)
FILE: toxcore/util.c
function unix_time_update (line 41) | void unix_time_update()
function unix_time (line 49) | uint64_t unix_time()
function is_timeout (line 54) | int is_timeout(uint64_t timestamp, uint64_t timeout)
function id_equal (line 61) | bool id_equal(const uint8_t *dest, const uint8_t *src)
function id_copy (line 66) | uint32_t id_copy(uint8_t *dest, const uint8_t *src)
function host_to_net (line 72) | void host_to_net(uint8_t *num, uint16_t numbytes)
function lendian_to_host16 (line 87) | uint16_t lendian_to_host16(uint16_t lendian)
function host_to_lendian32 (line 96) | void host_to_lendian32(uint8_t *dest, uint32_t num)
function lendian_to_host32 (line 105) | void lendian_to_host32(uint32_t *dest, const uint8_t *lendian)
function load_state (line 117) | int load_state(load_state_callback_func load_state_callback, void *outer,
function create_recursive_mutex (line 173) | int create_recursive_mutex(pthread_mutex_t *mutex)
type RingBuffer (line 197) | struct RingBuffer {
function rb_full (line 204) | bool rb_full(const RingBuffer *b)
function rb_empty (line 208) | bool rb_empty(const RingBuffer *b)
function rb_read (line 227) | bool rb_read(RingBuffer *b, void **p)
function RingBuffer (line 238) | RingBuffer *rb_new(int size)
function rb_kill (line 253) | void rb_kill(RingBuffer *b)
function rb_size (line 260) | uint16_t rb_size(const RingBuffer *b)
function rb_data (line 270) | uint16_t rb_data(const RingBuffer *b, void **dest)
FILE: toxcore/util.h
type RingBuffer (line 62) | typedef struct RingBuffer RingBuffer;
FILE: toxdns/toxdns.c
type DNS_Object (line 48) | typedef struct {
function dns_new_temp_keys (line 57) | static void dns_new_temp_keys(DNS_Object *d)
function tox_dns3_kill (line 83) | void tox_dns3_kill(void *dns3_object)
function tox_generate_dns3_string (line 101) | int tox_generate_dns3_string(void *dns3_object, uint8_t *string, uint16_...
function decode (line 155) | static int decode(uint8_t *dest, uint8_t *src)
function tox_decrypt_dns3_TXT (line 198) | int tox_decrypt_dns3_TXT(void *dns3_object, uint8_t *tox_id, uint8_t *id...
FILE: toxencryptsave/crypto_pwhash_scryptsalsa208sha256/crypto_scrypt-common.c
function decode64_one (line 77) | static int
function crypto_pwhash_scryptsalsa208sha256_ll (line 229) | int
FILE: toxencryptsave/crypto_pwhash_scryptsalsa208sha256/crypto_scrypt.h
type escrypt_region_t (line 49) | typedef struct {
type escrypt_region_t (line 54) | typedef escrypt_region_t escrypt_local_t;
FILE: toxencryptsave/crypto_pwhash_scryptsalsa208sha256/nosse/pwhash_scryptsalsa208sha256_nosse.c
function blkcpy (line 46) | static inline void
function blkxor (line 58) | static inline void
function salsa20_8 (line 74) | static void
function blockmix_salsa8 (line 120) | static void
function integerify (line 152) | static inline uint64_t
function smix (line 168) | static void
function escrypt_kdf_nosse (line 228) | int
FILE: toxencryptsave/crypto_pwhash_scryptsalsa208sha256/pbkdf2-sha256.c
function PBKDF2_SHA256 (line 50) | void
FILE: toxencryptsave/crypto_pwhash_scryptsalsa208sha256/pwhash_scryptsalsa208sha256.c
function pickparams (line 22) | int
function crypto_pwhash_scryptsalsa208sha256_saltbytes (line 57) | size_t
function crypto_pwhash_scryptsalsa208sha256_strbytes (line 63) | size_t
function crypto_pwhash_scryptsalsa208sha256_opslimit_interactive (line 75) | size_t
function crypto_pwhash_scryptsalsa208sha256_memlimit_interactive (line 81) | size_t
function crypto_pwhash_scryptsalsa208sha256_opslimit_sensitive (line 87) | size_t
function crypto_pwhash_scryptsalsa208sha256_memlimit_sensitive (line 93) | size_t
function crypto_pwhash_scryptsalsa208sha256 (line 99) | int
function crypto_pwhash_scryptsalsa208sha256_str (line 130) | int
function crypto_pwhash_scryptsalsa208sha256_str_verify (line 182) | int
FILE: toxencryptsave/crypto_pwhash_scryptsalsa208sha256/runtime.c
type CPUFeatures (line 12) | typedef struct CPUFeatures_ {
function _sodium_runtime_arm_cpu_features (line 24) | static int
function _cpuid (line 47) | static void
function _sodium_runtime_intel_cpu_features (line 87) | static int
function sodium_runtime_get_cpu_features (line 113) | int
function sodium_runtime_has_neon (line 125) | int
function sodium_runtime_has_sse2 (line 130) | int
function sodium_runtime_has_sse3 (line 135) | int
FILE: toxencryptsave/crypto_pwhash_scryptsalsa208sha256/scrypt_platform.c
function init_region (line 72) | static inline void
function free_region (line 79) | int
function escrypt_init_local (line 94) | int
function escrypt_free_local (line 101) | int
FILE: toxencryptsave/crypto_pwhash_scryptsalsa208sha256/sse/pwhash_scryptsalsa208sha256_sse.c
function blockmix_salsa8 (line 114) | static inline void
function SALSA20_8_XOR (line 178) | XOR4(Bin1)
function smix (line 232) | static void
function escrypt_kdf_sse (line 312) | int
FILE: toxencryptsave/crypto_pwhash_scryptsalsa208sha256/sysendian.h
function be16dec (line 25) | static inline uint16_t
function be16enc (line 33) | static inline void
function be32dec (line 42) | static inline uint32_t
function be32enc (line 51) | static inline void
function be64dec (line 62) | static inline uint64_t
function be64enc (line 73) | static inline void
function le16dec (line 88) | static inline uint16_t
function le16enc (line 96) | static inline void
function le32dec (line 105) | static inline uint32_t
function le32enc (line 114) | static inline void
function le64dec (line 125) | static inline uint64_t
function le64enc (line 136) | static inline void
FILE: toxencryptsave/crypto_pwhash_scryptsalsa208sha256/utils.c
function __sodium_dummy_symbol_to_prevent_lto (line 32) | __attribute__((weak)) void
function sodium_memzero (line 40) | void
function sodium_memcmp (line 64) | int
FILE: toxencryptsave/toxencryptsave.c
function toxes_version_major (line 50) | uint32_t toxes_version_major(void)
function toxes_version_minor (line 55) | uint32_t toxes_version_minor(void)
function toxes_version_patch (line 60) | uint32_t toxes_version_patch(void)
function toxes_version_is_compatible (line 65) | bool toxes_version_is_compatible(uint32_t major, uint32_t minor, uint32_...
function tox_get_salt (line 87) | bool tox_get_salt(const uint8_t *data, uint8_t *salt)
function tox_derive_key_from_pass (line 108) | bool tox_derive_key_from_pass(const uint8_t *passphrase, size_t pplength...
function tox_derive_key_with_salt (line 119) | bool tox_derive_key_with_salt(const uint8_t *passphrase, size_t pplength...
function tox_pass_key_encrypt (line 160) | bool tox_pass_key_encrypt(const uint8_t *data, size_t data_len, const TO...
function tox_pass_encrypt (line 206) | bool tox_pass_encrypt(const uint8_t *data, size_t data_len, const uint8_...
function tox_pass_key_decrypt (line 232) | bool tox_pass_key_decrypt(const uint8_t *data, size_t length, const TOX_...
function tox_pass_decrypt (line 278) | bool tox_pass_decrypt(const uint8_t *data, size_t length, const uint8_t ...
function tox_is_data_encrypted (line 313) | bool tox_is_data_encrypted(const uint8_t *data)
FILE: toxencryptsave/toxencryptsave.h
type Tox (line 37) | typedef struct Tox Tox;
type Tox_Options (line 38) | struct Tox_Options
type TOX_ERR_KEY_DERIVATION (line 153) | typedef enum TOX_ERR_KEY_DERIVATION {
type TOX_ERR_ENCRYPTION (line 167) | typedef enum TOX_ERR_ENCRYPTION {
type TOX_ERR_DECRYPTION (line 185) | typedef enum TOX_ERR_DECRYPTION {
type TOX_PASS_KEY (line 251) | typedef struct {
Condensed preview — 178 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (1,906K chars).
[
{
"path": ".gitignore",
"chars": 662,
"preview": "# OS files\n.DS_Store\n.DS_Store?\n._*\n.Spotlight-V100\n.Trash*\nIcon?\nethumbs.db\nThumbs.db\n*.tmp\n\n# Make\nCMakeCache.txt\nCMak"
},
{
"path": ".travis.yml",
"chars": 1480,
"preview": "sudo: required\ndist: trusty\nlanguage: c\ncompiler:\n - gcc\n - clang\n\nbefore_script:\n - sudo add-apt-repository ppa:avsm"
},
{
"path": "COPYING",
"chars": 35147,
"preview": " GNU GENERAL PUBLIC LICENSE\n Version 3, 29 June 2007\n\n Copyright (C) 2007 Free "
},
{
"path": "DONATORS",
"chars": 241,
"preview": "Minnesota > Florida\nvdo <vdo@greyfaze.net>\nSpitfire is best technicolor horse.\nif bad people don't hate you, you're doin"
},
{
"path": "INSTALL.md",
"chars": 19317,
"preview": "#Install Instructions\n\n- [Installation](#installation)\n - [Unix like](#unix)\n - [Quick install](#quick-install)\n "
},
{
"path": "Makefile.am",
"chars": 877,
"preview": "SUBDIRS = build\n\nACLOCAL_AMFLAGS = -I m4\n\npkgconfigdir = $(libdir)/pkgconfig\n\n\npkgconfig_DATA = $(top_builddir)/libtoxco"
},
{
"path": "README.md",
"chars": 2520,
"preview": "\n***\n\nWith the rise of gover"
},
{
"path": "auto_tests/Makefile.inc",
"chars": 2569,
"preview": "if BUILD_TESTS\n\nTESTS = encryptsave_test messenger_autotest crypto_test network_test assoc_test onion_test TCP_test tox_"
},
{
"path": "auto_tests/TCP_test.c",
"chars": 30455,
"preview": "#ifdef HAVE_CONFIG_H\n#include \"config.h\"\n#endif\n\n#include <sys/types.h>\n#include <stdint.h>\n#include <string.h>\n#include"
},
{
"path": "auto_tests/assoc_test.c",
"chars": 4403,
"preview": "#ifdef HAVE_CONFIG_H\n#include \"config.h\"\n#endif\n\n#define AUTO_TEST\n#include \"../toxcore/DHT.h\"\n#include \"../toxcore/asso"
},
{
"path": "auto_tests/crypto_test.c",
"chars": 11746,
"preview": "#ifdef HAVE_CONFIG_H\n#include \"config.h\"\n#endif\n\n#include \"../toxcore/net_crypto.h\"\n#include <sys/types.h>\n#include <std"
},
{
"path": "auto_tests/dht_test.c",
"chars": 22185,
"preview": "#ifdef HAVE_CONFIG_H\n#include \"config.h\"\n#endif\n\n#include <sys/param.h>\n#include <time.h>\n\n#include \"../toxcore/tox.h\"\n#"
},
{
"path": "auto_tests/encryptsave_test.c",
"chars": 8698,
"preview": "#ifdef HAVE_CONFIG_H\n#include \"config.h\"\n#endif\n\n#include <sys/types.h>\n#include <stdint.h>\n#include <string.h>\n#include"
},
{
"path": "auto_tests/friends_test.c",
"chars": 6360,
"preview": "/* Unit testing for friend requests, statuses, and messages.\n * Purpose: Check that messaging functions actually do wha"
},
{
"path": "auto_tests/helpers.h",
"chars": 400,
"preview": "#ifndef TOXCORE_TEST_HELPERS_H\n#define TOXCORE_TEST_HELPERS_H\n\n#include <check.h>\n\n#define DEFTESTCASE(NAME) "
},
{
"path": "auto_tests/messenger_test.c",
"chars": 13067,
"preview": "/* unit tests for /core/Messenger.c\n * Design:\n * Just call every non-static function in Messenger.c, checking tha"
},
{
"path": "auto_tests/network_test.c",
"chars": 5069,
"preview": "#ifdef HAVE_CONFIG_H\n#include \"config.h\"\n#endif\n\n#include <sys/types.h>\n#include <stdint.h>\n#include <string.h>\n#include"
},
{
"path": "auto_tests/onion_test.c",
"chars": 13910,
"preview": "#ifdef HAVE_CONFIG_H\n#include \"config.h\"\n#endif\n\n#include <sys/types.h>\n#include <stdint.h>\n#include <string.h>\n#include"
},
{
"path": "auto_tests/skeleton_test.c",
"chars": 1007,
"preview": "#ifdef HAVE_CONFIG_H\n#include \"config.h\"\n#endif\n\n#include <sys/types.h>\n#include <stdint.h>\n#include <string.h>\n#include"
},
{
"path": "auto_tests/tox_test.c",
"chars": 42916,
"preview": "#ifdef HAVE_CONFIG_H\n#include \"config.h\"\n#endif\n\n#include <sys/types.h>\n#include <stdint.h>\n#include <string.h>\n#include"
},
{
"path": "auto_tests/toxav_basic_test.c",
"chars": 18308,
"preview": "#ifdef HAVE_CONFIG_H\n#include \"config.h\"\n#endif\n\n#ifndef HAVE_LIBCHECK\n# include <assert.h>\n\n# define ck_assert(X) a"
},
{
"path": "auto_tests/toxav_many_test.c",
"chars": 10431,
"preview": "#ifdef HAVE_CONFIG_H\n#include \"config.h\"\n#endif\n\n#ifndef HAVE_LIBCHECK\n# include <assert.h>\n\n# define ck_assert(X) a"
},
{
"path": "autogen.sh",
"chars": 68,
"preview": "#!/bin/sh -e\n\necho 'Running autoreconf -if...'\n(\n autoreconf -if\n)\n"
},
{
"path": "configure.ac",
"chars": 20665,
"preview": "# -*- Autoconf -*-\n# Process this file with autoconf to produce a configur"
},
{
"path": "dist-build/android-arm.sh",
"chars": 188,
"preview": "#!/bin/sh\nexport CFLAGS=\"-Ofast -mthumb -marm -march=armv6\"\nTARGET_ARCH=arm TOOLCHAIN_NAME=arm-linux-androideabi-4.8 HOS"
},
{
"path": "dist-build/android-armv7.sh",
"chars": 227,
"preview": "#!/bin/sh\nexport CFLAGS=\"-Ofast -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -marm -march=armv7-a\"\nTARGET_ARCH=armv7 TOOLC"
},
{
"path": "dist-build/android-build.sh",
"chars": 1902,
"preview": "#!/bin/sh\n\nif [ -z \"$ANDROID_NDK_HOME\" ]; then\n echo \"You should probably set ANDROID_NDK_HOME to the directory conta"
},
{
"path": "dist-build/android-mips.sh",
"chars": 160,
"preview": "#!/bin/sh\nexport CFLAGS=\"-Ofast\"\nTARGET_ARCH=mips TOOLCHAIN_NAME=mipsel-linux-android-4.8 HOST_COMPILER=mipsel-linux-and"
},
{
"path": "dist-build/android-x86.sh",
"chars": 140,
"preview": "#!/bin/sh\nexport CFLAGS=\"-Ofast\"\nTARGET_ARCH=x86 TOOLCHAIN_NAME=x86-4.8 HOST_COMPILER=i686-linux-android \"$(dirname \"$0\""
},
{
"path": "docs/Group-Chats.md",
"chars": 2423,
"preview": "Group chats.\n\nNote: we assume everyone in the chat trusts each other.\n\nThese group chats work by temporarily adding the "
},
{
"path": "docs/Hardening.txt",
"chars": 2795,
"preview": "Currently an attacker with sufficient resources could launch a large scale \ndenial of service type attack by flooding th"
},
{
"path": "docs/Hardening_docs.txt",
"chars": 1589,
"preview": "Hardening request packets are sent as crypto request packets (see crypto docs.)\nNOTE: currently only get nodes requests "
},
{
"path": "docs/Prevent_Tracking.txt",
"chars": 8290,
"preview": "Current privacy issues with the Tox DHT: \n\n1. It makes tracking people across different IPs very easy.\nSolution: Have ea"
},
{
"path": "docs/TCP_Network.txt",
"chars": 6267,
"preview": "It has come to our attention that to achieve decent market penetration Tox \nmust work behind ALL internet connections, m"
},
{
"path": "docs/TODO.md",
"chars": 2338,
"preview": "# Toxcore todo list.\nWelcome to the Toxcore todo list, this is very likely out of date, but either way it's a good jumpi"
},
{
"path": "docs/Tox_middle_level_network_protocol.txt",
"chars": 5724,
"preview": "The TCP client and TCP server part are in a state that can be considered \nfeature complete. Why doesn't Tox support TCP "
},
{
"path": "docs/av_api.md",
"chars": 7262,
"preview": "#A/V API reference\n\n##Take toxmsi/phone.c as a reference\n\n###Initialization:\n\n```\nphone_t* initPhone(uint16_t _listen_po"
},
{
"path": "docs/updates/Crypto.md",
"chars": 2308,
"preview": "Encryption library used: http://nacl.cr.yp.to/\n\n\nWhen running the program for the first time the crypto_box_keypair() fu"
},
{
"path": "docs/updates/DHT.md",
"chars": 5755,
"preview": "DHT protocol\n============\n\nNOTE: only the protocol section is up to date, the rest needs to be rewritten.\n\nFollows prett"
},
{
"path": "docs/updates/Spam-Prevention.md",
"chars": 320,
"preview": " \nSituation 1:\nSomeone randomly goes around the DHT sending friend requests to everyone.\n\nPrevented by:\nEvery friend add"
},
{
"path": "docs/updates/Symmetric-NAT-Transversal.md",
"chars": 1271,
"preview": "Notes:\n\nFriend requests need to be routed.\n\nThe current DHT should be capable of punching all NATs except symmetric ones"
},
{
"path": "libtoxav.pc.in",
"chars": 235,
"preview": "prefix=@prefix@\nexec_prefix=@exec_prefix@\nlibdir=@libdir@\nincludedir=@includedir@\n\nName: libtoxav\nDescription: Tox A/V l"
},
{
"path": "libtoxcore.pc.in",
"chars": 341,
"preview": "prefix=@prefix@\nexec_prefix=@exec_prefix@\nlibdir=@libdir@\nincludedir=@includedir@\n\nName: libtoxcore\nDescription: Tox pro"
},
{
"path": "m4/pkg.m4",
"chars": 7321,
"preview": "# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-\n# serial 1 (pkg-config-0.24)\n# \n# Copyri"
},
{
"path": "other/DHT_bootstrap.c",
"chars": 5818,
"preview": "\n/* DHT boostrap\n *\n * A simple DHT boostrap node for tox.\n *\n * Copyright (C) 2013 Tox project All Rights Reserved.\n *"
},
{
"path": "other/DHTnodes",
"chars": 193,
"preview": "As maintaining 2 separate lists of the same information seemed redundant, this list has been phased out.\n\nFor a current "
},
{
"path": "other/Makefile.inc",
"chars": 835,
"preview": "bin_PROGRAMS += DHT_bootstrap\n\nDHT_bootstrap_SOURCES = ../other/DHT_bootstrap.c \\\n ../toxcore/DHT"
},
{
"path": "other/apidsl/README.md",
"chars": 1652,
"preview": "This folder contains the input file (``tox.in.h``) that has to be used to generate the ``tox.h`` api with: https://githu"
},
{
"path": "other/apidsl/tox.in.h",
"chars": 65581,
"preview": "%{\n/* tox.h\n *\n * The Tox public API.\n *\n * Copyright (C) 2013 Tox project All Rights Reserved.\n *\n * This file is par"
},
{
"path": "other/apidsl/toxav.in.h",
"chars": 22869,
"preview": "%{\n/* toxav.h\n *\n * Copyright (C) 2013-2015 Tox project All Rights Reserved.\n *\n * This file is part of Tox.\n *\n * Tox i"
},
{
"path": "other/astyle/README.md",
"chars": 926,
"preview": "This directory can house various tools and utilities.\n\n# How to use astyle\n\n## Manually\n\n### For all files\n\nRun from ``t"
},
{
"path": "other/astyle/astylerc",
"chars": 468,
"preview": "--style=kr\n --pad-header\n --max-code-length=120\n --convert-tabs\n "
},
{
"path": "other/astyle/pre-commit",
"chars": 532,
"preview": "#!/usr/bin/env sh\n#\n# An example hook script to verify what is about to be committed.\n# Called by \"git commit\" with no a"
},
{
"path": "other/bootstrap_daemon/README.md",
"chars": 9091,
"preview": "#Instructions\n\n- [For `systemd` users](#systemd)\n - [Setting up](#systemd-setting-up)\n - [Updating](#systemd-updating)"
},
{
"path": "other/bootstrap_daemon/docker/Dockerfile",
"chars": 1783,
"preview": "FROM debian:jessie\n\nWORKDIR /tmp/tox\n\nRUN export BUILD_PACKAGES=\"\\\n build-essential \\\n libtool \\\n autotoo"
},
{
"path": "other/bootstrap_daemon/docker/get-nodes.py",
"chars": 1955,
"preview": "#!/usr/bin/env python3\n\"\"\"\nCopyright (c) 2016 by nurupo <nurupo.contributions@gmail.com>\n\nPermission is hereby granted, "
},
{
"path": "other/bootstrap_daemon/src/Makefile.inc",
"chars": 1557,
"preview": "if BUILD_DHT_BOOTSTRAP_DAEMON\n\nbin_PROGRAMS += tox-bootstrapd\n\ntox_bootstrapd_SOURCES = \\\n ../oth"
},
{
"path": "other/bootstrap_daemon/src/command_line_arguments.c",
"chars": 5027,
"preview": "/* command_line_arguments.c\n *\n * Tox DHT bootstrap daemon.\n * Command line argument handling.\n *\n * Copyright (C) 2015"
},
{
"path": "other/bootstrap_daemon/src/command_line_arguments.h",
"chars": 1549,
"preview": "/* command_line_arguments.h\n *\n * Tox DHT bootstrap daemon.\n * Command line argument handling.\n *\n * Copyright (C) 2015"
},
{
"path": "other/bootstrap_daemon/src/config.c",
"chars": 16682,
"preview": "/* config.c\n *\n * Tox DHT bootstrap daemon.\n * Functionality related to dealing with the config file.\n *\n * Copyright ("
},
{
"path": "other/bootstrap_daemon/src/config_defaults.h",
"chars": 1684,
"preview": "/* config_defaults.h\n *\n * Tox DHT bootstrap daemon.\n * Default config options for when they are missing in the config f"
},
{
"path": "other/bootstrap_daemon/src/global.h",
"chars": 1090,
"preview": "/* global.h\n *\n * Tox DHT bootstrap daemon.\n * Globally used defines.\n *\n * Copyright (C) 2014-2016 Tox project All Rig"
},
{
"path": "other/bootstrap_daemon/src/log.c",
"chars": 2641,
"preview": "/* log.c\n *\n * Tox DHT bootstrap daemon.\n * Logging utility with support of multipel logging backends.\n *\n * Copyright "
},
{
"path": "other/bootstrap_daemon/src/log.h",
"chars": 1706,
"preview": "/* log.h\n *\n * Tox DHT bootstrap daemon.\n * Logging utility with support of multipel logging backends.\n *\n * Copyright "
},
{
"path": "other/bootstrap_daemon/src/tox-bootstrapd.c",
"chars": 10029,
"preview": "/* tox-bootstrapd.c\n *\n * Tox DHT bootstrap daemon.\n * Main file.\n *\n * Copyright (C) 2014-2016 Tox project All Rights "
},
{
"path": "other/bootstrap_daemon/tox-bootstrapd.conf",
"chars": 2182,
"preview": "// Tox DHT bootstrap daemon configuration file.\n\n// Listening port (UDP).\nport = 33445\n\n// A key file is like a password"
},
{
"path": "other/bootstrap_daemon/tox-bootstrapd.service",
"chars": 435,
"preview": "[Unit]\nDescription=Tox DHT Bootstrap Daemon\nAfter=network.target\n\n[Service]\nType=forking\nRuntimeDirectory=tox-bootstrapd"
},
{
"path": "other/bootstrap_daemon/tox-bootstrapd.sh",
"chars": 2822,
"preview": "#! /bin/sh\n### BEGIN INIT INFO\n# Provides: tox-bootstrapd\n# Required-Start: $remote_fs $syslog\n# Required-St"
},
{
"path": "other/bootstrap_node_packets.c",
"chars": 2227,
"preview": "/* bootstrap_node_packets.c\n *\n * Special bootstrap node only packets.\n *\n * Include it in your bootstrap node and use: "
},
{
"path": "other/bootstrap_node_packets.h",
"chars": 1242,
"preview": "/* bootstrap_node_packets.h\n *\n * Special bootstrap node only packets.\n *\n * Include it in your bootstrap node and use: "
},
{
"path": "other/fun/bootstrap_node_info.py",
"chars": 4182,
"preview": "#!/usr/bin/env python\n\"\"\"\nCopyright (c) 2014 by nurupo <nurupo.contributions@gmail.com>\n\nPermission is hereby granted, f"
},
{
"path": "other/fun/cracker.c",
"chars": 1552,
"preview": "/* Public key cracker.\n *\n * Can be used to find public keys starting with specific hex (ABCD) for example.\n *\n * NOTE: "
},
{
"path": "other/fun/make-funny-savefile.py",
"chars": 3077,
"preview": "#!/usr/bin/python\n\n\"\"\"\nGenerate a new (and empty) save file with predefined keys. Used to play\nwith externally generated"
},
{
"path": "other/fun/sign.c",
"chars": 3278,
"preview": "/* Binary signer/checker using ed25519\n *\n * Compile with:\n * gcc -o sign sign.c -lsodium\n *\n * Generate a keypair:\n * "
},
{
"path": "other/fun/strkey.c",
"chars": 3893,
"preview": "/* strkey -- String in Public Key\n *\n * Generates Tox's key pairs, checking if a certain string is in the public key.\n *"
},
{
"path": "other/osx_build_script_toxcore.sh",
"chars": 1246,
"preview": "#!/usr/bin/env bash\n# written by Lubo Diakov\n# hard coded toxcore directory, replace with other path or variable as need"
},
{
"path": "super_donators/LittleVulpix",
"chars": 751,
"preview": "Thank you to all the tox-devs for the idea of a privacy-oriented chat protocol.\nThank you for seeing it through so that "
},
{
"path": "super_donators/grencez_tok5.c",
"chars": 1024,
"preview": "/* Though it may look bleak at times,\n * this ring will stabilize to have one token,\n * and Tox will be the one true cha"
},
{
"path": "super_donators/sir@cmpwn.com",
"chars": 1023,
"preview": "#!/bin/bash\n# Run ./sir@cmpwn.com\n# Arrow keys or wasd to move\n\nc=`tput cols`;L=`tput lines`\nlet x=$c/2;let y=$L/2;d=0;l"
},
{
"path": "testing/DHT_test.c",
"chars": 7648,
"preview": "/* DHT test\n * A file with a main that runs our DHT for testing.\n *\n * Compile with: gcc -O2 -Wall -D VANILLA_NACL -o te"
},
{
"path": "testing/Makefile.inc",
"chars": 3534,
"preview": "if BUILD_NTOX\n\nbin_PROGRAMS += nTox\n\nnTox_SOURCES = ../testing/nTox.h \\\n ../testing/nTox"
},
{
"path": "testing/Messenger_test.c",
"chars": 6424,
"preview": "/* Messenger test\n *\n * This program adds a friend and accepts all friend requests with the proper message.\n *\n * It tri"
},
{
"path": "testing/av_test.c",
"chars": 21661,
"preview": "/** av_test.c\n *\n * Copyright (C) 2013-2015 Tox project All Rights Reserved.\n *\n * This file is part of Tox.\n *\n * "
},
{
"path": "testing/dns3_test.c",
"chars": 3053,
"preview": "\n\n#include \"../toxdns/toxdns.h\"\n#include \"../toxcore/tox.h\"\n#include \"../toxcore/network.h\"\n#include \"misc_tools.c\"\n\n#if"
},
{
"path": "testing/irc_syncbot.c",
"chars": 8926,
"preview": "\n#include <stdlib.h>\n#include <stdio.h>\n#include <stdint.h>\n#include <string.h>\n#include <time.h>\n\n\n#include <fcntl.h>\n#"
},
{
"path": "testing/misc_tools.c",
"chars": 2640,
"preview": "/* misc_tools.c\n *\n * Miscellaneous functions and data structures for doing random things.\n *\n * Copyright (C) 2013 Tox"
},
{
"path": "testing/nTox.c",
"chars": 43341,
"preview": "/* nTox.c\n *\n * Textual frontend for Tox.\n *\n * Copyright (C) 2013 Tox project All Rights Reserved.\n *\n * This file is"
},
{
"path": "testing/nTox.h",
"chars": 1033,
"preview": "/* nTox.h\n *\n *Textual frontend for Tox.\n *\n * Copyright (C) 2013 Tox project All Rights Reserved.\n *\n * This file is "
},
{
"path": "testing/tox_shell.c",
"chars": 4450,
"preview": "/* Tox Shell\n *\n * Proof of concept ssh like server software using tox.\n *\n * Command line arguments are the ip, port an"
},
{
"path": "testing/tox_sync.c",
"chars": 9947,
"preview": "/* Tox Sync\n *\n * Proof of concept bittorrent sync like software using tox, syncs two directories.\n *\n * Command line ar"
},
{
"path": "tox.spec.in",
"chars": 1505,
"preview": "Name: @PACKAGE_NAME@\nVersion: @VERSION@\nRelease: 1%{?dist}\nSummary: All-in-one secure com"
},
{
"path": "toxav/Makefile.inc",
"chars": 1387,
"preview": "if BUILD_AV\n\nlib_LTLIBRARIES += libtoxav.la\n libtoxav_la_include_HEADERS = ../toxav/toxav.h\n "
},
{
"path": "toxav/audio.c",
"chars": 12513,
"preview": "/** audio.c\n *\n * Copyright (C) 2013-2015 Tox project All Rights Reserved.\n *\n * This file is part of Tox.\n *\n * "
},
{
"path": "toxav/audio.h",
"chars": 2119,
"preview": "/** audio.h\n *\n * Copyright (C) 2013-2015 Tox project All Rights Reserved.\n *\n * This file is part of Tox.\n *\n * "
},
{
"path": "toxav/bwcontroller.c",
"chars": 5479,
"preview": "/** bwcontroller.c\n *\n * Copyright (C) 2013-2015 Tox project All Rights Reserved.\n *\n * This file is part of Tox.\n "
},
{
"path": "toxav/bwcontroller.h",
"chars": 1286,
"preview": "/** bwcontroller.h\n *\n * Copyright (C) 2013-2015 Tox project All Rights Reserved.\n *\n * This file is part of Tox.\n "
},
{
"path": "toxav/group.c",
"chars": 14580,
"preview": "/** groupav.h\n *\n * Copyright (C) 2014 Tox project All Rights Reserved.\n *\n * This file is part of Tox.\n *\n * Tox"
},
{
"path": "toxav/group.h",
"chars": 1805,
"preview": "/** groupav.c\n *\n * Copyright (C) 2014 Tox project All Rights Reserved.\n *\n * This file is part of Tox.\n *\n * Tox"
},
{
"path": "toxav/msi.c",
"chars": 22291,
"preview": "/** msi.c\n *\n * Copyright (C) 2013-2015 Tox project All Rights Reserved.\n *\n * This file is part of Tox.\n *\n * To"
},
{
"path": "toxav/msi.h",
"chars": 4089,
"preview": "/** msi.h\n *\n * Copyright (C) 2013-2015 Tox project All Rights Reserved.\n *\n * This file is part of Tox.\n *\n * To"
},
{
"path": "toxav/rtp.c",
"chars": 12355,
"preview": "/** rtp.c\n *\n * Copyright (C) 2013-2015 Tox project All Rights Reserved.\n *\n * This file is part of Tox.\n *\n * To"
},
{
"path": "toxav/rtp.h",
"chars": 2999,
"preview": "/** rtp.h\n *\n * Copyright (C) 2013-2015 Tox project All Rights Reserved.\n *\n * This file is part of Tox.\n *\n * To"
},
{
"path": "toxav/toxav.c",
"chars": 38210,
"preview": "/** toxav.c\n *\n * Copyright (C) 2013-2015 Tox project All Rights Reserved.\n *\n * This file is part of Tox.\n *\n * "
},
{
"path": "toxav/toxav.h",
"chars": 26127,
"preview": "/* toxav.h\n *\n * Copyright (C) 2013-2015 Tox project All Rights Reserved.\n *\n * This file is part of Tox.\n *\n * Tox is f"
},
{
"path": "toxav/toxav_old.c",
"chars": 3259,
"preview": "/* toxav_old.h\n *\n * Copyright (C) 2013-2015 Tox project All Rights Reserved.\n *\n * This file is part of Tox.\n *\n * Tox "
},
{
"path": "toxav/video.c",
"chars": 7597,
"preview": "/** video.c\n *\n * Copyright (C) 2013-2015 Tox project All Rights Reserved.\n *\n * This file is part of Tox.\n *\n * "
},
{
"path": "toxav/video.h",
"chars": 2003,
"preview": "/** video.h\n *\n * Copyright (C) 2013-2015 Tox project All Rights Reserved.\n *\n * This file is part of Tox.\n *\n * "
},
{
"path": "toxcore/DHT.c",
"chars": 88155,
"preview": "/* DHT.c\n *\n * An implementation of the DHT as seen in docs/updates/DHT.md\n *\n * Copyright (C) 2013 Tox project All Rig"
},
{
"path": "toxcore/DHT.h",
"chars": 13969,
"preview": "/* DHT.h\n *\n * An implementation of the DHT as seen in docs/updates/DHT.md\n *\n * Copyright (C) 2013 Tox project All Rig"
},
{
"path": "toxcore/LAN_discovery.c",
"chars": 10205,
"preview": "/* LAN_discovery.c\n *\n * LAN discovery implementation.\n *\n * Copyright (C) 2013 Tox project All Rights Reserved.\n *\n "
},
{
"path": "toxcore/LAN_discovery.h",
"chars": 1400,
"preview": "/* LAN_discovery.h\n *\n * LAN discovery implementation.\n *\n * Copyright (C) 2013 Tox project All Rights Reserved.\n *\n "
},
{
"path": "toxcore/Makefile.inc",
"chars": 3136,
"preview": "lib_LTLIBRARIES += libtoxcore.la\n\nlibtoxcore_la_include_HEADERS = \\\n ../toxcore/tox.h \\\n "
},
{
"path": "toxcore/Messenger.c",
"chars": 86899,
"preview": "/* Messenger.c\n *\n * An implementation of a simple text chat only messenger on the tox network core.\n *\n * Copyright (C"
},
{
"path": "toxcore/Messenger.h",
"chars": 27611,
"preview": "/* Messenger.h\n *\n * An implementation of a simple text chat only messenger on the tox network core.\n *\n * NOTE: All the"
},
{
"path": "toxcore/TCP_client.c",
"chars": 27790,
"preview": "/*\n* TCP_client.c -- Implementation of the TCP relay client part of Tox.\n*\n* Copyright (C) 2014 Tox project All Rights "
},
{
"path": "toxcore/TCP_client.h",
"chars": 5991,
"preview": "/*\n* TCP_client.h -- Implementation of the TCP relay client part of Tox.\n*\n* Copyright (C) 2014 Tox project All Rights "
},
{
"path": "toxcore/TCP_connection.c",
"chars": 39127,
"preview": "/* TCP_connection.c\n *\n * Handles TCP relay connections between two Tox clients.\n *\n * Copyright (C) 2015 Tox project A"
},
{
"path": "toxcore/TCP_connection.h",
"chars": 8276,
"preview": "/* TCP_connection.h\n *\n * Handles TCP relay connections between two Tox clients.\n *\n * Copyright (C) 2015 Tox project A"
},
{
"path": "toxcore/TCP_server.c",
"chars": 38910,
"preview": "/*\n* TCP_server.c -- Implementation of the TCP relay server part of Tox.\n*\n* Copyright (C) 2014 Tox project All Rights "
},
{
"path": "toxcore/TCP_server.h",
"chars": 5484,
"preview": "/*\n* TCP_server.h -- Implementation of the TCP relay server part of Tox.\n*\n* Copyright (C) 2014 Tox project All Rights "
},
{
"path": "toxcore/assoc.c",
"chars": 31975,
"preview": "\n#ifdef HAVE_CONFIG_H\n#include \"config.h\"\n#endif\n\n#include \"logger.h\"\n#include \"DHT.h\"\n#include \"assoc.h\"\n#include \"ping"
},
{
"path": "toxcore/assoc.h",
"chars": 4034,
"preview": "\n#ifndef __ASSOC_H__\n#define __ASSOC_H__\n\n/* used by rendezvous */\n#define ASSOC_AVAILABLE\n\n/* For the legalese parts, s"
},
{
"path": "toxcore/crypto_core.c",
"chars": 10209,
"preview": "/* net_crypto.c\n *\n * Functions for the core crypto.\n *\n * NOTE: This code has to be perfect. We don't mess around with "
},
{
"path": "toxcore/crypto_core.h",
"chars": 5990,
"preview": "/* crypto_core.h\n *\n * Functions for the core crypto.\n *\n * Copyright (C) 2013 Tox project All Rights Reserved.\n *\n * "
},
{
"path": "toxcore/friend_connection.c",
"chars": 25856,
"preview": "/* friend_connection.c\n *\n * Connection to friends.\n *\n * Copyright (C) 2014 Tox project All Rights Reserved.\n *\n * Th"
},
{
"path": "toxcore/friend_connection.h",
"chars": 6837,
"preview": "/* friend_connection.h\n *\n * Connection to friends.\n *\n * Copyright (C) 2014 Tox project All Rights Reserved.\n *\n * Th"
},
{
"path": "toxcore/friend_requests.c",
"chars": 4252,
"preview": "/* friend_requests.c\n *\n * Handle friend requests.\n *\n * Copyright (C) 2013 Tox project All Rights Reserved.\n *\n * Thi"
},
{
"path": "toxcore/friend_requests.h",
"chars": 2932,
"preview": "/* friend_requests.h\n *\n * Handle friend requests.\n *\n * Copyright (C) 2013 Tox project All Rights Reserved.\n *\n * Thi"
},
{
"path": "toxcore/group.c",
"chars": 65434,
"preview": "/* group.c\n *\n * Slightly better groupchats implementation.\n *\n * Copyright (C) 2014 Tox project All Rights Reserved.\n "
},
{
"path": "toxcore/group.h",
"chars": 12368,
"preview": "/* group.h\n *\n * Slightly better groupchats implementation.\n *\n * Copyright (C) 2014 Tox project All Rights Reserved.\n "
},
{
"path": "toxcore/list.c",
"chars": 6346,
"preview": "/* list.h\n *\n * Simple struct with functions to create a list which associates ids with data\n * -Allows for finding ids "
},
{
"path": "toxcore/list.h",
"chars": 2431,
"preview": "/* list.h\n *\n * Simple struct with functions to create a list which associates ids with data\n * -Allows for finding ids "
},
{
"path": "toxcore/logger.c",
"chars": 5615,
"preview": "/* logger.c\n *\n * Copyright (C) 2013, 2015 Tox project All Rights Reserved.\n *\n * This file is part of Tox.\n *\n * To"
},
{
"path": "toxcore/logger.h",
"chars": 3088,
"preview": "/* logger.h\n *\n * Copyright (C) 2013 Tox project All Rights Reserved.\n *\n * This file is part of Tox.\n *\n * Tox is f"
},
{
"path": "toxcore/misc_tools.h",
"chars": 2329,
"preview": "/* misc_tools.h\n *\n * Miscellaneous functions and data structures for doing random things.\n *\n * Copyright (C) 2013 Tox"
},
{
"path": "toxcore/net_crypto.c",
"chars": 88086,
"preview": "/* net_crypto.c\n *\n * Functions for the core network crypto.\n *\n * NOTE: This code has to be perfect. We don't mess arou"
},
{
"path": "toxcore/net_crypto.h",
"chars": 15776,
"preview": "/* net_crypto.h\n *\n * Functions for the core network crypto.\n *\n * Copyright (C) 2013 Tox project All Rights Reserved.\n"
},
{
"path": "toxcore/network.c",
"chars": 30164,
"preview": "/* network.c\n *\n * Functions for the core networking.\n *\n * Copyright (C) 2013 Tox project All Rights Reserved.\n *\n * "
},
{
"path": "toxcore/network.h",
"chars": 10403,
"preview": "/* network.h\n *\n * Datatypes, functions and includes for the core networking.\n *\n * Copyright (C) 2013 Tox project All "
},
{
"path": "toxcore/onion.c",
"chars": 21588,
"preview": "/*\n* onion.c -- Implementation of the onion part of docs/Prevent_Tracking.txt\n*\n* Copyright (C) 2013 Tox project All Ri"
},
{
"path": "toxcore/onion.h",
"chars": 5661,
"preview": "/*\n* onion.h -- Implementation of the onion part of docs/Prevent_Tracking.txt\n*\n* Copyright (C) 2013 Tox project All Ri"
},
{
"path": "toxcore/onion_announce.c",
"chars": 16521,
"preview": "/*\n* onion_announce.c -- Implementation of the announce part of docs/Prevent_Tracking.txt\n*\n* Copyright (C) 2013 Tox pr"
},
{
"path": "toxcore/onion_announce.h",
"chars": 6075,
"preview": "/*\n* onion_announce.h -- Implementation of the announce part of docs/Prevent_Tracking.txt\n*\n* Copyright (C) 2013 Tox pr"
},
{
"path": "toxcore/onion_client.c",
"chars": 50705,
"preview": "/*\n* onion_client.c -- Implementation of the client part of docs/Prevent_Tracking.txt\n* (The part that"
},
{
"path": "toxcore/onion_client.h",
"chars": 9513,
"preview": "/*\n* onion_client.h -- Implementation of the client part of docs/Prevent_Tracking.txt\n* (The part that"
},
{
"path": "toxcore/ping.c",
"chars": 10416,
"preview": "/*\n * ping.c -- Buffered pinging using cyclic arrays.\n *\n * This file is donated to the Tox Project.\n * Copyright 2013 "
},
{
"path": "toxcore/ping.h",
"chars": 1600,
"preview": "/*\n * ping.h -- Buffered pinging using cyclic arrays.\n *\n * This file is donated to the Tox Project.\n * Copyright 2013 "
},
{
"path": "toxcore/ping_array.c",
"chars": 4428,
"preview": "/* ping_array.c\n *\n * Implementation of an efficient array to store that we pinged something.\n *\n *\n * Copyright (C) 20"
},
{
"path": "toxcore/ping_array.h",
"chars": 2260,
"preview": "/* ping_array.h\n *\n * Implementation of an efficient array to store that we pinged something.\n *\n * Copyright (C) 2013 "
},
{
"path": "toxcore/tox.c",
"chars": 35060,
"preview": "/* tox.c\n *\n * The Tox public API.\n *\n * Copyright (C) 2013 Tox project All Rights Reserved.\n *\n * This file is part o"
},
{
"path": "toxcore/tox.h",
"chars": 73888,
"preview": "/* tox.h\n *\n * The Tox public API.\n *\n * Copyright (C) 2013 Tox project All Rights Reserved.\n *\n * This file is part o"
},
{
"path": "toxcore/tox_old.h",
"chars": 6036,
"preview": "/**********GROUP CHAT FUNCTIONS ************/\n\n/* Group chat types for tox_callback_group_invite function.\n *\n * TOX_GRO"
},
{
"path": "toxcore/tox_old_code.h",
"chars": 7725,
"preview": "/**********GROUP CHAT FUNCTIONS: WARNING Group chats will be rewritten so this might change ************/\n\n/* Set the ca"
},
{
"path": "toxcore/util.c",
"chars": 6236,
"preview": "/*\n * util.c -- Utilities.\n *\n * This file is donated to the Tox Project.\n * Copyright 2013 plutooo\n *\n * Copyright (C"
},
{
"path": "toxcore/util.h",
"chars": 2378,
"preview": "/*\n * util.h -- Utilities.\n *\n * This file is donated to the Tox Project.\n * Copyright 2013 plutooo\n *\n * Copyright (C"
},
{
"path": "toxdns/Makefile.inc",
"chars": 974,
"preview": "lib_LTLIBRARIES += libtoxdns.la\n\nlibtoxdns_la_include_HEADERS = \\\n ../toxdns/toxdns.h\n\nlibtoxdns_"
},
{
"path": "toxdns/toxdns.c",
"chars": 6560,
"preview": "/* toxdns.c\n *\n * Tox secure username DNS toxid resolving functions.\n *\n * Copyright (C) 2013 Tox project All Rights Re"
},
{
"path": "toxdns/toxdns.h",
"chars": 3615,
"preview": "/* toxdns.h\n *\n * Tox secure username DNS toxid resolving functions.\n *\n * Copyright (C) 2014 Tox project All Rights Re"
},
{
"path": "toxencryptsave/Makefile.inc",
"chars": 2636,
"preview": "lib_LTLIBRARIES += libtoxencryptsave.la\n\nlibtoxencryptsave_la_include_HEADERS = \\\n ../toxencrypts"
},
{
"path": "toxencryptsave/crypto_pwhash_scryptsalsa208sha256/crypto_pwhash_scryptsalsa208sha256.h",
"chars": 3662,
"preview": "#ifdef HAVE_CONFIG_H\n#include \"config.h\"\n#endif\n#ifdef VANILLA_NACL /* toxcore only uses this when libsodium is unavail"
},
{
"path": "toxencryptsave/crypto_pwhash_scryptsalsa208sha256/crypto_scrypt-common.c",
"chars": 6776,
"preview": "#ifdef HAVE_CONFIG_H\n#include \"config.h\"\n#endif\n#ifdef VANILLA_NACL /* toxcore only uses this when libsodium is unavail"
},
{
"path": "toxencryptsave/crypto_pwhash_scryptsalsa208sha256/crypto_scrypt.h",
"chars": 3681,
"preview": "#ifdef HAVE_CONFIG_H\n#include \"config.h\"\n#endif\n#ifdef VANILLA_NACL /* toxcore only uses this when libsodium is unavail"
},
{
"path": "toxencryptsave/crypto_pwhash_scryptsalsa208sha256/export.h",
"chars": 769,
"preview": "#ifdef HAVE_CONFIG_H\n#include \"config.h\"\n#endif\n#ifdef VANILLA_NACL /* toxcore only uses this when libsodium is unavail"
},
{
"path": "toxencryptsave/crypto_pwhash_scryptsalsa208sha256/nosse/pwhash_scryptsalsa208sha256_nosse.c",
"chars": 8360,
"preview": "#ifdef HAVE_CONFIG_H\n#include \"config.h\"\n#endif\n#ifdef VANILLA_NACL /* toxcore only uses this when libsodium is unavail"
},
{
"path": "toxencryptsave/crypto_pwhash_scryptsalsa208sha256/note_to_maintainers.txt",
"chars": 629,
"preview": "This folder is only meant for use with nacl, i.e. when sodium is unavailable.\n\n\nThe files in this folder were mostly cop"
},
{
"path": "toxencryptsave/crypto_pwhash_scryptsalsa208sha256/pbkdf2-sha256.c",
"chars": 3482,
"preview": "#ifdef HAVE_CONFIG_H\n#include \"config.h\"\n#endif\n#ifdef VANILLA_NACL /* toxcore only uses this when libsodium is unavail"
},
{
"path": "toxencryptsave/crypto_pwhash_scryptsalsa208sha256/pbkdf2-sha256.h",
"chars": 1997,
"preview": "#ifdef HAVE_CONFIG_H\n#include \"config.h\"\n#endif\n#ifdef VANILLA_NACL /* toxcore only uses this when libsodium is unavail"
},
{
"path": "toxencryptsave/crypto_pwhash_scryptsalsa208sha256/pwhash_scryptsalsa208sha256.c",
"chars": 6658,
"preview": "#ifdef HAVE_CONFIG_H\n#include \"config.h\"\n#endif\n#ifdef VANILLA_NACL /* toxcore only uses this when libsodium is unavail"
},
{
"path": "toxencryptsave/crypto_pwhash_scryptsalsa208sha256/runtime.c",
"chars": 3582,
"preview": "#ifdef HAVE_CONFIG_H\n#include \"config.h\"\n#endif\n#ifdef VANILLA_NACL /* toxcore only uses this when libsodium is unavail"
},
{
"path": "toxencryptsave/crypto_pwhash_scryptsalsa208sha256/runtime.h",
"chars": 503,
"preview": "#ifdef HAVE_CONFIG_H\n#include \"config.h\"\n#endif\n#ifdef VANILLA_NACL /* toxcore only uses this when libsodium is unavail"
},
{
"path": "toxencryptsave/crypto_pwhash_scryptsalsa208sha256/scrypt_platform.c",
"chars": 2584,
"preview": "#ifdef HAVE_CONFIG_H\n#include \"config.h\"\n#endif\n#ifdef VANILLA_NACL /* toxcore only uses this when libsodium is unavail"
},
{
"path": "toxencryptsave/crypto_pwhash_scryptsalsa208sha256/sse/pwhash_scryptsalsa208sha256_sse.c",
"chars": 10532,
"preview": "#ifdef HAVE_CONFIG_H\n#include \"config.h\"\n#endif\n#ifdef VANILLA_NACL /* toxcore only uses this when libsodium is unavail"
},
{
"path": "toxencryptsave/crypto_pwhash_scryptsalsa208sha256/sysendian.h",
"chars": 3206,
"preview": "#ifdef HAVE_CONFIG_H\n#include \"config.h\"\n#endif\n#ifdef VANILLA_NACL /* toxcore only uses this when libsodium is unavail"
},
{
"path": "toxencryptsave/crypto_pwhash_scryptsalsa208sha256/utils.c",
"chars": 1665,
"preview": "#ifdef HAVE_CONFIG_H\n#include \"config.h\"\n#endif\n#ifdef VANILLA_NACL /* toxcore only uses this when libsodium is unavail"
},
{
"path": "toxencryptsave/crypto_pwhash_scryptsalsa208sha256/utils.h",
"chars": 859,
"preview": "#ifdef HAVE_CONFIG_H\n#include \"config.h\"\n#endif\n#ifdef VANILLA_NACL /* toxcore only uses this when libsodium is unavail"
},
{
"path": "toxencryptsave/defines.h",
"chars": 81,
"preview": "#define TOX_ENC_SAVE_MAGIC_NUMBER \"toxEsave\"\n#define TOX_ENC_SAVE_MAGIC_LENGTH 8\n"
},
{
"path": "toxencryptsave/toxencryptsave.c",
"chars": 11661,
"preview": "/* toxencryptsave.c\n *\n * The Tox encrypted save functions.\n *\n * Copyright (C) 2013 Tox project All Rights Reserved.\n "
},
{
"path": "toxencryptsave/toxencryptsave.h",
"chars": 11424,
"preview": "/* toxencryptsave.h\n *\n * The Tox encrypted save functions.\n *\n * Copyright (C) 2013 Tox project All Rights Reserved.\n "
}
]
About this extraction
This page contains the full source code of the irungentoo/toxcore GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 178 files (1.7 MB), approximately 481.5k tokens, and a symbol index with 1469 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.