summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--INSTALL.md37
-rw-r--r--Makefile.am1
-rw-r--r--configure.ac82
-rw-r--r--other/DHTservers2
-rw-r--r--other/fun/sign.c18
-rw-r--r--testing/DHT_test.c10
-rw-r--r--testing/Makefile.inc4
-rw-r--r--testing/misc_tools.h94
-rw-r--r--testing/nTox.c84
-rw-r--r--testing/nTox.h49
-rw-r--r--toxcore/DHT.c4
-rw-r--r--toxcore/DHT.h9
-rw-r--r--toxcore/LAN_discovery.h7
-rw-r--r--toxcore/Lossless_UDP.h6
-rw-r--r--toxcore/Makefile.inc10
-rw-r--r--toxcore/Messenger.c2
-rw-r--r--toxcore/Messenger.h7
-rw-r--r--toxcore/friend_requests.h12
-rw-r--r--toxcore/net_crypto.c12
-rw-r--r--toxcore/net_crypto.h7
-rw-r--r--toxcore/network.h7
-rw-r--r--toxcore/tox.h2
22 files changed, 259 insertions, 207 deletions
diff --git a/INSTALL.md b/INSTALL.md
index 9a81fba7..d14796f8 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -68,9 +68,14 @@ Advance configure options:
68 - --prefix=/where/to/install 68 - --prefix=/where/to/install
69 - --with-libsodium-headers=/path/to/libsodium/include/ 69 - --with-libsodium-headers=/path/to/libsodium/include/
70 - --with-libsodium-libs=/path/to/sodiumtest/lib/ 70 - --with-libsodium-libs=/path/to/sodiumtest/lib/
71 - --BUILD_DHT_BOOTSTRAP_DAEMON="yes" 71 - --enable-silent-rules less verbose build output (undo: "make V=1")
72 - --BUILD_NTOX="yes" 72 - --disable-silent-rules verbose build output (undo: "make V=0")
73 - --BUILD_TESTS="yes" 73 - --disable-tests build unit tests (default: auto)
74 - --disable-ntox build nTox client (default: auto)
75 - --disable-dht-bootstrap-daemon build DHT bootstrap daemon (default: auto)
76 - --enable-shared[=PKGS] build shared libraries [default=yes]
77 - --enable-static[=PKGS] build static libraries [default=yes]
78
74<a name="osx" /> 79<a name="osx" />
75###OS X: 80###OS X:
76 81
@@ -99,6 +104,13 @@ Advance configure options:
99 - --BUILD_DHT_BOOTSTRAP_DAEMON="yes" 104 - --BUILD_DHT_BOOTSTRAP_DAEMON="yes"
100 - --BUILD_NTOX="yes" 105 - --BUILD_NTOX="yes"
101 - --BUILD_TESTS="yes" 106 - --BUILD_TESTS="yes"
107 - --enable-silent-rules less verbose build output (undo: "make V=1")
108 - --disable-silent-rules verbose build output (undo: "make V=0")
109 - --disable-tests build unit tests (default: auto)
110 - --disable-ntox build nTox client (default: auto)
111 - --disable-dht-bootstrap-daemon build DHT bootstrap daemon (default: auto)
112 - --enable-shared[=PKGS] build shared libraries [default=yes]
113 - --enable-static[=PKGS] build static libraries [default=yes]
102 114
103<a name="non-homebrew" /> 115<a name="non-homebrew" />
104####Non-homebrew: 116####Non-homebrew:
@@ -137,7 +149,13 @@ Advance configure options:
137 - --BUILD_DHT_BOOTSTRAP_DAEMON="yes" 149 - --BUILD_DHT_BOOTSTRAP_DAEMON="yes"
138 - --BUILD_NTOX="yes" 150 - --BUILD_NTOX="yes"
139 - --BUILD_TESTS="yes" 151 - --BUILD_TESTS="yes"
140 152 - --enable-silent-rules less verbose build output (undo: "make V=1")
153 - --disable-silent-rules verbose build output (undo: "make V=0")
154 - --disable-tests build unit tests (default: auto)
155 - --disable-ntox build nTox client (default: auto)
156 - --disable-dht-bootstrap-daemon build DHT bootstrap daemon (default: auto)
157 - --enable-shared[=PKGS] build shared libraries [default=yes]
158 - --enable-static[=PKGS] build static libraries [default=yes]
141 159
142Do not install them from macports (or any dependencies for that matter) as they get shoved in the wrong directory 160Do not install them from macports (or any dependencies for that matter) as they get shoved in the wrong directory
143(or the wrong version gets installed) and make your life more annoying. 161(or the wrong version gets installed) and make your life more annoying.
@@ -175,3 +193,14 @@ Advance configure options:
175 - --BUILD_DHT_BOOTSTRAP_DAEMON="yes" 193 - --BUILD_DHT_BOOTSTRAP_DAEMON="yes"
176 - --BUILD_NTOX="yes" 194 - --BUILD_NTOX="yes"
177 - --BUILD_TESTS="yes" 195 - --BUILD_TESTS="yes"
196 - --enable-silent-rules less verbose build output (undo: "make V=1")
197 - --disable-silent-rules verbose build output (undo: "make V=0")
198 - --disable-tests build unit tests (default: auto)
199 - --disable-ntox build nTox client (default: auto)
200 - --disable-dht-bootstrap-daemon build DHT bootstrap daemon (default: auto)
201 - --enable-shared[=PKGS] build shared libraries [default=yes]
202 - --enable-static[=PKGS] build static libraries [default=yes]
203
204<a name="Clients" />
205####Clients:
206While [Toxic](https://github.com/tox/toxic) is no longer in core, a list of Tox clients are located in our [wiki](http://wiki.tox.im/client)
diff --git a/Makefile.am b/Makefile.am
index 7824ecb0..119b8786 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,6 +1,7 @@
1SUBDIRS = build 1SUBDIRS = build
2 2
3ACLOCAL_AMFLAGS = -I m4 3ACLOCAL_AMFLAGS = -I m4
4AUTOMAKE_OPTIONS = subdir-objects
4 5
5pkgconfigdir = $(libdir)/pkgconfig 6pkgconfigdir = $(libdir)/pkgconfig
6pkgconfig_DATA = $(top_builddir)/libtoxcore.pc 7pkgconfig_DATA = $(top_builddir)/libtoxcore.pc
diff --git a/configure.ac b/configure.ac
index 381b99c9..a16f6a4f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -10,6 +10,17 @@ AM_INIT_AUTOMAKE([1.10 -Wall])
10m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) 10m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
11AC_CONFIG_MACRO_DIR([m4]) 11AC_CONFIG_MACRO_DIR([m4])
12 12
13LIBTOXCORE_LT_VERSION=0:0:0
14dnl
15dnl current:revision:age
16dnl
17dnl current: increment if interfaces have been added, removed or changed
18dnl revision: increment if source code has changed, set to zero if current is
19dnl incremented
20dnl age: increment if interfaces have been added, set to zero if
21dnl interfaces have been removed or changed
22EXTRA_LT_LDFLAGS="-version-info $LIBTOXCORE_LT_VERSION"
23
13if test "x${prefix}" = "xNONE"; then 24if test "x${prefix}" = "xNONE"; then
14 prefix="${ac_default_prefix}" 25 prefix="${ac_default_prefix}"
15fi 26fi
@@ -96,6 +107,7 @@ AC_ARG_WITH(libsodium-libs,
96# Checks for programs. 107# Checks for programs.
97AC_PROG_CC 108AC_PROG_CC
98AM_PROG_CC_C_O 109AM_PROG_CC_C_O
110AC_LIBTOOL_WIN32_DLL
99AC_PROG_LIBTOOL 111AC_PROG_LIBTOOL
100 112
101WIN32=no 113WIN32=no
@@ -103,15 +115,21 @@ AC_CANONICAL_HOST
103case $host_os in 115case $host_os in
104 *mingw*) 116 *mingw*)
105 WIN32="yes" 117 WIN32="yes"
106 AC_MSG_WARN([nTox is not supported on $host_os yet, disabling]) 118 EXTRA_LT_LDFLAGS="$EXTRA_LT_LDFLAGS -no-undefined"
107 BUILD_NTOX="no"
108 ;; 119 ;;
109 *solaris*) 120 *solaris*)
110 LIBS="$LIBS -lssp -lsocket -lnsl" 121 LIBS="$LIBS -lssp -lsocket -lnsl"
111 ;; 122 ;;
123 *freebsd*)
124 LDFLAGS="$LDFLAGS -L/usr/local/lib"
125 CFLAGS="$CFLAGS -I/usr/local/include"
126 CPPFLAGS="$CPPFLAGS -I/usr/local/include"
127 ;;
112esac 128esac
113AM_CONDITIONAL(WIN32, test "x$WIN32" = "xyes") 129AM_CONDITIONAL(WIN32, test "x$WIN32" = "xyes")
114 130
131AC_SUBST(EXTRA_LT_LDFLAGS)
132
115# Checks for libraries. 133# Checks for libraries.
116LIBSODIUM_LIBS= 134LIBSODIUM_LIBS=
117LIBSODIUM_LDFLAGS= 135LIBSODIUM_LDFLAGS=
@@ -131,7 +149,7 @@ else
131 AC_CHECK_LIB(sodium, randombytes_random, 149 AC_CHECK_LIB(sodium, randombytes_random,
132 [], 150 [],
133 [ 151 [
134 AC_MSG_ERROR([required library libsodium was not found on your system, please check http://download.libsodium.org/libsodium/releases/]) 152 AC_MSG_ERROR([required library libsodium was not found on your system, please check http://download.libsodium.org/libsodium/releases/])
135 ] 153 ]
136 ) 154 )
137fi 155fi
@@ -182,9 +200,8 @@ AC_TYPE_UINT8_T
182 200
183# Checks for library functions. 201# Checks for library functions.
184AC_FUNC_FORK 202AC_FUNC_FORK
185AC_FUNC_MALLOC
186AC_FUNC_REALLOC 203AC_FUNC_REALLOC
187AC_CHECK_FUNCS([gettimeofday memset socket strchr]) 204AC_CHECK_FUNCS([gettimeofday memset socket strchr malloc])
188 205
189# pkg-config based tests 206# pkg-config based tests
190PKG_PROG_PKG_CONFIG 207PKG_PROG_PKG_CONFIG
@@ -208,7 +225,7 @@ if test -n "$PKG_CONFIG"; then
208 ], 225 ],
209 [ 226 [
210 AC_MSG_WARN([$LIBCONFIG_PKG_ERRORS]) 227 AC_MSG_WARN([$LIBCONFIG_PKG_ERRORS])
211 AC_MSG_WARN([libconfig not available, will not build DHT botstrap daemon]) 228 AC_MSG_WARN([libconfig not available, will not build DHT bootstrap daemon])
212 BUILD_DHT_BOOTSTRAP_DAEMON="no" 229 BUILD_DHT_BOOTSTRAP_DAEMON="no"
213 ]) 230 ])
214 fi 231 fi
@@ -223,7 +240,7 @@ if test -n "$PKG_CONFIG"; then
223 ]) 240 ])
224 fi 241 fi
225else 242else
226 AC_MSG_WARN([pkg-config was not found on your sytem]) 243 AC_MSG_WARN([pkg-config was not found on your system])
227fi 244fi
228 245
229if (test "x$BUILD_NTOX" = "xyes") && (test "x$NCURSES_FOUND" != "xyes"); then 246if (test "x$BUILD_NTOX" = "xyes") && (test "x$NCURSES_FOUND" != "xyes"); then
@@ -251,22 +268,41 @@ if (test "x$BUILD_NTOX" = "xyes") && (test "x$NCURSES_FOUND" != "xyes"); then
251 ] 268 ]
252 ) 269 )
253 if test "x$BUILD_NTOX" = "xyes"; then 270 if test "x$BUILD_NTOX" = "xyes"; then
254 AC_CHECK_LIB([ncurses], [clear], 271 if test "x$WIN32" = "xyes"; then
255 [], 272 AC_CHECK_LIB([pdcurses], [clear],
256 [ 273 [
257 unset ac_cv_lib_ncurses_clear 274 NCURSES_LIBS="-lpdcurses"
258 AC_CHECK_LIB([ncurses], [clear], 275 AC_SUBST(NCURSES_LIBS)
259 [], 276 ],
260 [ 277 [
261 AC_MSG_WARN([not building nTox client because required library ncurses was not found on your system]) 278 AC_MSG_ERROR([required library pdcurses was not found on your system])
262 BUILD_NTOX="no" 279 BUILD_NTOX="no"
263 ], 280 ]
264 [ 281 )
265 -ltinfo 282 else
266 ] 283 AC_CHECK_LIB([ncurses], [clear],
267 ) 284 [
268 ] 285 NCURSES_LIBS="-lncurses"
269 ) 286 AC_SUBST(NCURSES_LIBS)
287 ],
288 [
289 unset ac_cv_lib_ncurses_clear
290 AC_CHECK_LIB([ncurses], [clear],
291 [
292 NCURSES_LIBS="-lncurses -ltinfo"
293 AC_SUBST(NCURSES_LIBS)
294 ],
295 [
296 AC_MSG_WARN([not building nTox client because required library ncurses was not found on your system])
297 BUILD_NTOX="no"
298 ],
299 [
300 -ltinfo
301 ]
302 )
303 ]
304 )
305 fi
270 fi 306 fi
271 fi 307 fi
272fi 308fi
diff --git a/other/DHTservers b/other/DHTservers
index bf2d2728..1fb86cd3 100644
--- a/other/DHTservers
+++ b/other/DHTservers
@@ -1,5 +1,5 @@
1192.81.133.111 33445 8CD5A9BF0A6CE358BA36F7A653F99FA6B258FF756E490F52C1F98CC420F78858 1192.81.133.111 33445 8CD5A9BF0A6CE358BA36F7A653F99FA6B258FF756E490F52C1F98CC420F78858
266.175.223.88 33445 AC4112C975240CAD260BB2FCD134266521FAAF0A5D159C5FD3201196191E4F5D 266.175.223.88 33445 B24E2FB924AE66D023FE1E42A2EE3B432010206F751A2FFD3E297383ACF1572E
3192.184.81.118 33445 5CD7EB176C19A2FD840406CD56177BB8E75587BB366F7BB3004B19E3EDC04143 3192.184.81.118 33445 5CD7EB176C19A2FD840406CD56177BB8E75587BB366F7BB3004B19E3EDC04143
4192.210.149.121 33445 F404ABAA1C99A9D37D61AB54898F56793E1DEF8BD46B1038B9D822E8460FAB67 4192.210.149.121 33445 F404ABAA1C99A9D37D61AB54898F56793E1DEF8BD46B1038B9D822E8460FAB67
581.224.34.47 443 48F0D94C0D54EB1995A2ECEDE7DB6BDD5E05D81704B2F3D1BB9FE43AC97B7269 581.224.34.47 443 48F0D94C0D54EB1995A2ECEDE7DB6BDD5E05D81704B2F3D1BB9FE43AC97B7269
diff --git a/other/fun/sign.c b/other/fun/sign.c
index 44485bb5..423d974a 100644
--- a/other/fun/sign.c
+++ b/other/fun/sign.c
@@ -1,5 +1,5 @@
1/* Binary signer/checker using ed25519 1/* Binary signer/checker using ed25519
2 * 2 *
3 * Compile with: 3 * Compile with:
4 * gcc -o sign sign.c -lsodium 4 * gcc -o sign sign.c -lsodium
5 * 5 *
@@ -60,6 +60,7 @@ int main(int argc, char *argv[])
60{ 60{
61 unsigned char pk[crypto_sign_ed25519_PUBLICKEYBYTES]; 61 unsigned char pk[crypto_sign_ed25519_PUBLICKEYBYTES];
62 unsigned char sk[crypto_sign_ed25519_SECRETKEYBYTES]; 62 unsigned char sk[crypto_sign_ed25519_SECRETKEYBYTES];
63
63 if (argc == 2 && argv[1][0] == 'g') { 64 if (argc == 2 && argv[1][0] == 'g') {
64 crypto_sign_ed25519_keypair(pk, sk); 65 crypto_sign_ed25519_keypair(pk, sk);
65 printf("Public key:\n"); 66 printf("Public key:\n");
@@ -89,12 +90,15 @@ int main(int argc, char *argv[])
89 unsigned long long smlen; 90 unsigned long long smlen;
90 char *sm = malloc(size + crypto_sign_ed25519_BYTES * 2); 91 char *sm = malloc(size + crypto_sign_ed25519_BYTES * 2);
91 crypto_sign_ed25519(sm, &smlen, data, size, secret_key); 92 crypto_sign_ed25519(sm, &smlen, data, size, secret_key);
93
92 if (smlen - size != crypto_sign_ed25519_BYTES) 94 if (smlen - size != crypto_sign_ed25519_BYTES)
93 goto fail; 95 goto fail;
96
94 FILE *f = fopen(argv[4], "wb"); 97 FILE *f = fopen(argv[4], "wb");
95 98
96 if (f == NULL) 99 if (f == NULL)
97 goto fail; 100 goto fail;
101
98 memcpy(sm + smlen, sm, crypto_sign_ed25519_BYTES); // Move signature from beginning to end of file. 102 memcpy(sm + smlen, sm, crypto_sign_ed25519_BYTES); // Move signature from beginning to end of file.
99 103
100 if (fwrite(sm + (smlen - size), 1, smlen, f) != smlen) 104 if (fwrite(sm + (smlen - size), 1, smlen, f) != smlen)
@@ -113,7 +117,8 @@ int main(int argc, char *argv[])
113 goto fail; 117 goto fail;
114 118
115 char *signe = malloc(size + crypto_sign_ed25519_BYTES); 119 char *signe = malloc(size + crypto_sign_ed25519_BYTES);
116 memcpy(signe, data + size - crypto_sign_ed25519_BYTES, crypto_sign_ed25519_BYTES); // Move signature from end to beginning of file. 120 memcpy(signe, data + size - crypto_sign_ed25519_BYTES,
121 crypto_sign_ed25519_BYTES); // Move signature from end to beginning of file.
117 memcpy(signe + crypto_sign_ed25519_BYTES, data, size - crypto_sign_ed25519_BYTES); 122 memcpy(signe + crypto_sign_ed25519_BYTES, data, size - crypto_sign_ed25519_BYTES);
118 unsigned long long smlen; 123 unsigned long long smlen;
119 char *m = malloc(size); 124 char *m = malloc(size);
@@ -123,12 +128,13 @@ int main(int argc, char *argv[])
123 printf("Failed checking sig.\n"); 128 printf("Failed checking sig.\n");
124 goto fail; 129 goto fail;
125 } 130 }
131
126 printf("Checked successfully.\n"); 132 printf("Checked successfully.\n");
127 } 133 }
128 134
129 return 0; 135 return 0;
130 136
131 fail: 137fail:
132 printf("FAIL\n"); 138 printf("FAIL\n");
133 return 1; 139 return 1;
134} 140}
diff --git a/testing/DHT_test.c b/testing/DHT_test.c
index d14f9781..09e6dfe0 100644
--- a/testing/DHT_test.c
+++ b/testing/DHT_test.c
@@ -54,10 +54,10 @@ void print_clientlist(DHT *dht)
54 IP_Port p_ip; 54 IP_Port p_ip;
55 printf("___________________CLOSE________________________________\n"); 55 printf("___________________CLOSE________________________________\n");
56 56
57 for (i = 0; i < 32; i++) { 57 for (i = 0; i < LCLIENT_LIST; i++) {
58 printf("ClientID: "); 58 printf("ClientID: ");
59 59
60 for (j = 0; j < 32; j++) { 60 for (j = 0; j < CLIENT_ID_SIZE; j++) {
61 printf("%02hhX", dht->close_clientlist[i].client_id[j]); 61 printf("%02hhX", dht->close_clientlist[i].client_id[j]);
62 } 62 }
63 63
@@ -81,7 +81,7 @@ void print_friendlist(DHT *dht)
81 printf("FRIEND %u\n", k); 81 printf("FRIEND %u\n", k);
82 printf("ID: "); 82 printf("ID: ");
83 83
84 for (j = 0; j < 32; j++) { 84 for (j = 0; j < CLIENT_ID_SIZE; j++) {
85 printf("%c", dht->friends_list[k].client_id[j]); 85 printf("%c", dht->friends_list[k].client_id[j]);
86 } 86 }
87 87
@@ -90,10 +90,10 @@ void print_friendlist(DHT *dht)
90 90
91 printf("\nCLIENTS IN LIST:\n\n"); 91 printf("\nCLIENTS IN LIST:\n\n");
92 92
93 for (i = 0; i < 4; i++) { 93 for (i = 0; i < MAX_FRIEND_CLIENTS; i++) {
94 printf("ClientID: "); 94 printf("ClientID: ");
95 95
96 for (j = 0; j < 32; j++) { 96 for (j = 0; j < CLIENT_ID_SIZE; j++) {
97 if (dht->friends_list[k].client_list[i].client_id[j] < 16) 97 if (dht->friends_list[k].client_list[i].client_id[j] < 16)
98 printf("0"); 98 printf("0");
99 99
diff --git a/testing/Makefile.inc b/testing/Makefile.inc
index 067b6ead..bd499ab6 100644
--- a/testing/Makefile.inc
+++ b/testing/Makefile.inc
@@ -13,8 +13,8 @@ nTox_CFLAGS = $(LIBSODIUM_CFLAGS) \
13nTox_LDADD = $(LIBSODIUM_LDFLAGS) \ 13nTox_LDADD = $(LIBSODIUM_LDFLAGS) \
14 libtoxcore.la \ 14 libtoxcore.la \
15 $(LIBSODIUM_LIBS) \ 15 $(LIBSODIUM_LIBS) \
16 $(NCURSES_LIBS) 16 $(NCURSES_LIBS) \
17 17 $(WINSOCK2_LIBS)
18endif 18endif
19 19
20 20
diff --git a/testing/misc_tools.h b/testing/misc_tools.h
index 1379b31a..0ffd51e7 100644
--- a/testing/misc_tools.h
+++ b/testing/misc_tools.h
@@ -26,6 +26,7 @@
26 26
27#include <stdlib.h> 27#include <stdlib.h>
28#include <stdint.h> 28#include <stdint.h>
29#include <string.h> /* for memcpy() */
29 30
30unsigned char *hex_string_to_bin(char hex_string[]); 31unsigned char *hex_string_to_bin(char hex_string[]);
31 32
@@ -33,40 +34,41 @@ unsigned char *hex_string_to_bin(char hex_string[]);
33 * wiki.tox.im/index.php/Internal_functions_and_data_structures#Debugging 34 * wiki.tox.im/index.php/Internal_functions_and_data_structures#Debugging
34 *********************************************************/ 35 *********************************************************/
35#ifdef DEBUG 36#ifdef DEBUG
36#include <assert.h> 37 #include <assert.h>
37#include <stdio.h> 38 #include <stdio.h>
38#include <string.h> 39 #include <string.h>
39 40
40#define DEBUG_PRINT(str, ...) do { \ 41 #define DEBUG_PRINT(str, ...) do { \
41 char msg[1000]; \ 42 char msg[1000]; \
42 sprintf(msg, "%s(): line %d (file %s): %s%%c\n", __FUNCTION__, __LINE__, __FILE__, str); \ 43 sprintf(msg, "%s(): line %d (file %s): %s%%c\n", __FUNCTION__, __LINE__, __FILE__, str); \
43 fprintf(stderr, msg, __VA_ARGS__); \ 44 fprintf(stderr, msg, __VA_ARGS__); \
44 } while (0) 45 } while (0)
45 46
46#define WARNING(...) do { \ 47 #define WARNING(...) do { \
47 fprintf(stderr, "warning in "); \ 48 fprintf(stderr, "warning in "); \
48 DEBUG_PRINT(__VA_ARGS__, ' '); \ 49 DEBUG_PRINT(__VA_ARGS__, ' '); \
49 } while (0) 50 } while (0)
50 51
51#define INFO(...) do { \ 52 #define INFO(...) do { \
52 DEBUG_PRINT(__VA_ARGS__, ' '); \ 53 DEBUG_PRINT(__VA_ARGS__, ' '); \
53 } while (0) 54 } while (0)
54 55
55#undef ERROR 56 #undef ERROR
56#define ERROR(exit_status, ...) do { \ 57 #define ERROR(exit_status, ...) do { \
57 fprintf(stderr, "error in "); \ 58 fprintf(stderr, "error in "); \
58 DEBUG_PRINT(__VA_ARGS__, ' '); \ 59 DEBUG_PRINT(__VA_ARGS__, ' '); \
59 exit(exit_status); \ 60 exit(exit_status); \
60 } while (0) 61 } while (0)
61#else 62#else
62#define WARNING(...) 63 #define WARNING(...)
63#define INFO(...) 64 #define INFO(...)
64#undef ERROR 65 #undef ERROR
65#define ERROR(...) 66 #define ERROR(...)
66#endif // DEBUG 67#endif // DEBUG
67 68
68/************************Linked List*********************** 69/************************Linked List***********************
69 * http://wiki.tox.im/index.php/Internal_functions_and_data_structures#Linked_List 70 * http://wiki.tox.im/index.php/Internal_functions_and_data_structures#Linked_List
71 * TODO: Update wiki.
70 **********************************************************/ 72 **********************************************************/
71 73
72#define MEMBER_OFFSET(var_name_in_parent, parent_type) \ 74#define MEMBER_OFFSET(var_name_in_parent, parent_type) \
@@ -76,22 +78,22 @@ unsigned char *hex_string_to_bin(char hex_string[]);
76 ((parent_type*)((uint64_t)(&(var)) - (uint64_t)(MEMBER_OFFSET(var_name_in_parent, parent_type)))) 78 ((parent_type*)((uint64_t)(&(var)) - (uint64_t)(MEMBER_OFFSET(var_name_in_parent, parent_type))))
77 79
78#define TOX_LIST_FOR_EACH(lst, tmp_name) \ 80#define TOX_LIST_FOR_EACH(lst, tmp_name) \
79 for (tox_list_t* tmp_name = lst.next; tmp_name != &lst; tmp_name = tmp_name->next) 81 for (tox_list* tmp_name = lst.next; tmp_name != &lst; tmp_name = tmp_name->next)
80 82
81#define TOX_LIST_GET_VALUE(tmp_name, name_in_parent, parent_type) GET_PARENT(tmp_name, name_in_parent, parent_type) 83#define TOX_LIST_GET_VALUE(tmp_name, name_in_parent, parent_type) GET_PARENT(tmp_name, name_in_parent, parent_type)
82 84
83typedef struct tox_list { 85typedef struct tox_list {
84 struct tox_list *prev, *next; 86 struct tox_list *prev, *next;
85} tox_list_t; 87} tox_list;
86 88
87/* Returns a new tox_list_t. */ 89/* Returns a new tox_list_t. */
88static inline void tox_list_new(tox_list_t *lst) 90static inline void tox_list_new(tox_list *lst)
89{ 91{
90 lst->prev = lst->next = lst; 92 lst->prev = lst->next = lst;
91} 93}
92 94
93/* Inserts a new tox_lst after lst and returns it. */ 95/* Inserts a new tox_lst after lst and returns it. */
94static inline void tox_list_add(tox_list_t *lst, tox_list_t *new_lst) 96static inline void tox_list_add(tox_list *lst, tox_list *new_lst)
95{ 97{
96 tox_list_new(new_lst); 98 tox_list_new(new_lst);
97 99
@@ -102,61 +104,55 @@ static inline void tox_list_add(tox_list_t *lst, tox_list_t *new_lst)
102 new_lst->prev = lst; 104 new_lst->prev = lst;
103} 105}
104 106
105static inline void tox_list_remove(tox_list_t *lst) 107static inline void tox_list_remove(tox_list *lst)
106{ 108{
107 lst->prev->next = lst->next; 109 lst->prev->next = lst->next;
108 lst->next->prev = lst->prev; 110 lst->next->prev = lst->prev;
109} 111}
110 112
111/****************************Array*************************** 113/****************************Array***************************
112 * Array to store pointers which tracks it's own size. 114 * Array which manages its own memory allocation.
113 * TODO: Figure out if it shold store values instead of 115 * It stores copy of data (not pointers).
114 * pointers?
115 * TODO: Add wiki info usage. 116 * TODO: Add wiki info usage.
116 ************************************************************/ 117 ************************************************************/
117 118
118struct tox_array { 119typedef struct tox_array {
119 void **data; 120 void *data;
120 uint32_t size, length; 121 uint32_t len;
121}; 122 size_t elem_size; /* in bytes */
123} tox_array;
122 124
123static inline void tox_array_init(struct tox_array *arr) 125static inline void tox_array_init(tox_array *arr, size_t elem_size)
124{ 126{
125 arr->size = 1; 127 arr->len = 0;
126 arr->length = 0; 128 arr->elem_size = elem_size;
127 arr->data = malloc(sizeof(void *)); 129 arr->data = NULL;
128} 130}
129 131
130static inline void tox_array_delete(struct tox_array *arr) 132static inline void tox_array_delete(tox_array *arr)
131{ 133{
132 free(arr->data); 134 free(arr->data);
133 arr->size = arr->length = 0; 135 arr->len = arr->elem_size = 0;
134} 136}
135 137
136/* shrinks arr so it will not have unused space. If you want to have 138static inline void _tox_array_push(tox_array *arr, uint8_t *item)
137 * addtional space, extra species the amount of extra space.
138 */
139static inline void tox_array_shrink_to_fit(struct tox_array *arr, int32_t extra)
140{
141 arr->size = arr->length + extra;
142 arr->data = realloc(arr->data, arr->size * sizeof(void *));
143}
144
145static inline void _tox_array_push(struct tox_array *arr, void *new)
146{ 139{
147 if (arr->length + 1 >= arr->size) 140 arr->data = realloc(arr->data, arr->elem_size * (arr->len+1));
148 tox_array_shrink_to_fit(arr, arr->size);
149 141
150 arr->data[arr->length++] = new; 142 memcpy(arr->data + arr->elem_size*arr->len, item, arr->elem_size);
143 arr->len++;
151} 144}
152#define tox_array_push(arr, new) _tox_array_push(arr, (void*)new) 145#define tox_array_push(arr, item) _tox_array_push(arr, (void*)(&(item)))
153 146
154static inline void *tox_array_pop(struct tox_array *arr) 147/* Deletes num items from array.
148 * Not same as pop in stacks, because to access elements you use data.
149 */
150static inline void tox_array_pop(tox_array *arr, uint32_t num)
155{ 151{
156 if (arr->length - 1 < arr->size / 4) 152 arr->len--;
157 tox_array_shrink_to_fit(arr, arr->length * 2); 153 arr->data = realloc(arr->data, arr->elem_size*arr->len);
158
159 return arr->data[arr->length--];
160} 154}
161 155
156#define tox_array_get(arr, i, type) ((type*)(arr)->data)[i]
157
162#endif // MISC_TOOLS_H 158#endif // MISC_TOOLS_H
diff --git a/testing/nTox.c b/testing/nTox.c
index 9df1e78b..128e729d 100644
--- a/testing/nTox.c
+++ b/testing/nTox.c
@@ -20,13 +20,30 @@
20 * along with Tox. If not, see <http://www.gnu.org/licenses/>. 20 * along with Tox. If not, see <http://www.gnu.org/licenses/>.
21 * 21 *
22 */ 22 */
23#ifdef HAVE_CONFIG_H
24 #include "config.h"
25#endif
26
27#ifdef __WIN32__
28 #define _WIN32_WINNT 0x501
29 #include <winsock2.h>
30 #include <ws2tcpip.h>
31#else
32 #include <sys/socket.h>
33 #include <netinet/in.h>
34 #include <arpa/inet.h>
35 #include <sys/types.h>
36 #include <netdb.h>
37#endif
38
39
23#include "nTox.h" 40#include "nTox.h"
24#include "misc_tools.h" 41#include "misc_tools.h"
25 42
26#include <stdio.h> 43#include <stdio.h>
27#include <time.h> 44#include <time.h>
28 45
29#ifdef WIN32 46#ifdef __WIN32__
30#define c_sleep(x) Sleep(1*x) 47#define c_sleep(x) Sleep(1*x)
31#else 48#else
32#include <unistd.h> 49#include <unistd.h>
@@ -50,6 +67,67 @@ typedef struct {
50Friend_request pending_requests[256]; 67Friend_request pending_requests[256];
51uint8_t num_requests = 0; 68uint8_t num_requests = 0;
52 69
70/*
71 resolve_addr():
72 address should represent IPv4 or a hostname with A record
73
74 returns a data in network byte order that can be used to set IP.i or IP_Port.ip.i
75 returns 0 on failure
76
77 TODO: Fix ipv6 support
78*/
79
80uint32_t resolve_addr(const char *address)
81{
82 struct addrinfo *server = NULL;
83 struct addrinfo hints;
84 int rc;
85 uint32_t addr;
86
87 memset(&hints, 0, sizeof(hints));
88 hints.ai_family = AF_INET; // IPv4 only right now.
89 hints.ai_socktype = SOCK_DGRAM; // type of socket Tox uses.
90
91#ifdef __WIN32__
92 int res;
93 WSADATA wsa_data;
94
95 res = WSAStartup(MAKEWORD(2, 2), &wsa_data);
96 if (res != 0)
97 {
98 return 0;
99 }
100#endif
101
102 rc = getaddrinfo(address, "echo", &hints, &server);
103
104 // Lookup failed.
105 if (rc != 0) {
106#ifdef __WIN32__
107 WSACleanup();
108#endif
109 return 0;
110 }
111
112 // IPv4 records only..
113 if (server->ai_family != AF_INET) {
114 freeaddrinfo(server);
115#ifdef __WIN32__
116 WSACleanup();
117#endif
118 return 0;
119 }
120
121
122 addr = ((struct sockaddr_in *)server->ai_addr)->sin_addr.s_addr;
123
124 freeaddrinfo(server);
125#ifdef __WIN32__
126 WSACleanup();
127#endif
128 return addr;
129}
130
53void get_id(Tox *m, char *data) 131void get_id(Tox *m, char *data)
54{ 132{
55 sprintf(data, "[i] ID: "); 133 sprintf(data, "[i] ID: ");
@@ -525,7 +603,7 @@ int main(int argc, char *argv[])
525 free(binary_string); 603 free(binary_string);
526 nodelay(stdscr, TRUE); 604 nodelay(stdscr, TRUE);
527 605
528 while (true) { 606 while (1) {
529 if (on == 0 && tox_isconnected(m)) { 607 if (on == 0 && tox_isconnected(m)) {
530 new_lines("[i] connected to DHT\n[i] define username with /n"); 608 new_lines("[i] connected to DHT\n[i] define username with /n");
531 on = 1; 609 on = 1;
@@ -542,7 +620,7 @@ int main(int argc, char *argv[])
542 620
543 getmaxyx(stdscr, y, x); 621 getmaxyx(stdscr, y, x);
544 622
545 if (c == '\n') { 623 if ((c == 0x0d) || (c == 0x0a)) {
546 line_eval(m, line); 624 line_eval(m, line);
547 strcpy(line, ""); 625 strcpy(line, "");
548 } else if (c == 8 || c == 127) { 626 } else if (c == 8 || c == 127) {
diff --git a/testing/nTox.h b/testing/nTox.h
index df9d404a..a72ce0c2 100644
--- a/testing/nTox.h
+++ b/testing/nTox.h
@@ -27,61 +27,16 @@
27#include <stdio.h> 27#include <stdio.h>
28#include <stdlib.h> 28#include <stdlib.h>
29#include <string.h> 29#include <string.h>
30#include <ncurses.h>
31#include <curses.h> 30#include <curses.h>
32#include <ctype.h> 31#include <ctype.h>
33#include <sys/socket.h> 32
34#include <netinet/in.h>
35#include <arpa/inet.h>
36#include <sys/types.h>
37#include <netdb.h>
38#include "../toxcore/tox.h" 33#include "../toxcore/tox.h"
39 34
40#define STRING_LENGTH 256 35#define STRING_LENGTH 256
41#define HISTORY 50 36#define HISTORY 50
42#define PUB_KEY_BYTES 32 37#define PUB_KEY_BYTES 32
43 38
44/* 39uint32_t resolve_addr(const char *address);
45 resolve_addr():
46 address should represent IPv4 or a hostname with A record
47
48 returns a data in network byte order that can be used to set IP.i or IP_Port.ip.i
49 returns 0 on failure
50
51 TODO: Fix ipv6 support
52*/
53
54uint32_t resolve_addr(const char *address)
55{
56 struct addrinfo *server = NULL;
57 struct addrinfo hints;
58 int rc;
59 uint32_t addr;
60
61 memset(&hints, 0, sizeof(hints));
62 hints.ai_family = AF_INET; // IPv4 only right now.
63 hints.ai_socktype = SOCK_DGRAM; // type of socket Tox uses.
64
65 rc = getaddrinfo(address, "echo", &hints, &server);
66
67 // Lookup failed.
68 if (rc != 0) {
69 return 0;
70 }
71
72 // IPv4 records only..
73 if (server->ai_family != AF_INET) {
74 freeaddrinfo(server);
75 return 0;
76 }
77
78
79 addr = ((struct sockaddr_in *)server->ai_addr)->sin_addr.s_addr;
80
81 freeaddrinfo(server);
82 return addr;
83}
84
85void new_lines(char *line); 40void new_lines(char *line);
86void line_eval(Tox *m, char *line); 41void line_eval(Tox *m, char *line);
87void wrap(char output[STRING_LENGTH], char input[STRING_LENGTH], int line_width) ; 42void wrap(char output[STRING_LENGTH], char input[STRING_LENGTH], int line_width) ;
diff --git a/toxcore/DHT.c b/toxcore/DHT.c
index 56e8b052..0e0ead52 100644
--- a/toxcore/DHT.c
+++ b/toxcore/DHT.c
@@ -74,8 +74,8 @@ static int id_closest(uint8_t *id, uint8_t *id1, uint8_t *id2)
74 74
75 for (i = 0; i < CLIENT_ID_SIZE; ++i) { 75 for (i = 0; i < CLIENT_ID_SIZE; ++i) {
76 76
77 distance1 = abs(id[i] ^ id1[i]); 77 distance1 = abs(((int8_t *)id)[i] ^ ((int8_t *)id1)[i]);
78 distance2 = abs(id[i] ^ id2[i]); 78 distance2 = abs(((int8_t *)id)[i] ^ ((int8_t *)id2)[i]);
79 79
80 if (distance1 < distance2) 80 if (distance1 < distance2)
81 return 1; 81 return 1;
diff --git a/toxcore/DHT.h b/toxcore/DHT.h
index e4ba2154..b53801b5 100644
--- a/toxcore/DHT.h
+++ b/toxcore/DHT.h
@@ -26,10 +26,6 @@
26 26
27#include "net_crypto.h" 27#include "net_crypto.h"
28 28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33 29
34/* Size of the client_id in bytes. */ 30/* Size of the client_id in bytes. */
35#define CLIENT_ID_SIZE crypto_box_PUBLICKEYBYTES 31#define CLIENT_ID_SIZE crypto_box_PUBLICKEYBYTES
@@ -126,7 +122,7 @@ int DHT_delfriend(DHT *dht, uint8_t *client_id);
126 * port must be 2 bytes long. 122 * port must be 2 bytes long.
127 * returns ip if success. 123 * returns ip if success.
128 * returns ip of 0 if failure (This means the friend is either offline or we have not found him yet). 124 * returns ip of 0 if failure (This means the friend is either offline or we have not found him yet).
129 * returns ip of 1 if friend is not in list. 125 * returns ip of 1 if friend is not in list.
130 */ 126 */
131IP_Port DHT_getfriendip(DHT *dht, uint8_t *client_id); 127IP_Port DHT_getfriendip(DHT *dht, uint8_t *client_id);
132 128
@@ -195,8 +191,5 @@ int DHT_isconnected(DHT *dht);
195 191
196void addto_lists(DHT *dht, IP_Port ip_port, uint8_t *client_id); 192void addto_lists(DHT *dht, IP_Port ip_port, uint8_t *client_id);
197 193
198#ifdef __cplusplus
199}
200#endif
201 194
202#endif 195#endif
diff --git a/toxcore/LAN_discovery.h b/toxcore/LAN_discovery.h
index e570908e..7bbe775e 100644
--- a/toxcore/LAN_discovery.h
+++ b/toxcore/LAN_discovery.h
@@ -35,9 +35,6 @@
35#include <linux/netdevice.h> 35#include <linux/netdevice.h>
36#endif 36#endif
37 37
38#ifdef __cplusplus
39extern "C" {
40#endif
41 38
42/* Send a LAN discovery pcaket to the broadcast address with port port. */ 39/* Send a LAN discovery pcaket to the broadcast address with port port. */
43int send_LANdiscovery(uint16_t port, Net_Crypto *c); 40int send_LANdiscovery(uint16_t port, Net_Crypto *c);
@@ -48,8 +45,4 @@ void LANdiscovery_init(DHT *dht);
48 45
49 46
50 47
51#ifdef __cplusplus
52}
53#endif
54
55#endif 48#endif
diff --git a/toxcore/Lossless_UDP.h b/toxcore/Lossless_UDP.h
index 216e95d0..cd822e72 100644
--- a/toxcore/Lossless_UDP.h
+++ b/toxcore/Lossless_UDP.h
@@ -26,9 +26,6 @@
26 26
27#include "network.h" 27#include "network.h"
28 28
29#ifdef __cplusplus
30extern "C" {
31#endif
32 29
33/* Maximum length of the data in the data packets. */ 30/* Maximum length of the data in the data packets. */
34#define MAX_DATA_SIZE 1024 31#define MAX_DATA_SIZE 1024
@@ -215,8 +212,5 @@ Lossless_UDP *new_lossless_udp(Networking_Core *net);
215 212
216void kill_lossless_udp(Lossless_UDP *ludp); 213void kill_lossless_udp(Lossless_UDP *ludp);
217 214
218#ifdef __cplusplus
219}
220#endif
221 215
222#endif 216#endif
diff --git a/toxcore/Makefile.inc b/toxcore/Makefile.inc
index 2fd93a22..da07db41 100644
--- a/toxcore/Makefile.inc
+++ b/toxcore/Makefile.inc
@@ -1,5 +1,3 @@
1LIBTOXCORE_VERSION = 0:0:0
2
3lib_LTLIBRARIES = libtoxcore.la 1lib_LTLIBRARIES = libtoxcore.la
4 2
5libtoxcore_la_include_HEADERS = \ 3libtoxcore_la_include_HEADERS = \
@@ -33,8 +31,8 @@ libtoxcore_la_CFLAGS = -I$(top_srcdir) \
33 -I$(top_srcdir)/toxcore \ 31 -I$(top_srcdir)/toxcore \
34 $(LIBSODIUM_CFLAGS) 32 $(LIBSODIUM_CFLAGS)
35 33
36libtoxcore_la_LDFLAGS = -version-info $(LIBTOXCORE_VERSION) \ 34libtoxcore_la_LDFLAGS = $(EXTRA_LT_LDFLAGS) \
37 $(LIBSODIUM_LDFLAGS) 35 $(LIBSODIUM_LDFLAGS) \
38
39libtoxcore_la_LIBS = $(LIBSODIUM_LIBS) \
40 $(WINSOCK2_LIBS) 36 $(WINSOCK2_LIBS)
37
38libtoxcore_la_LIBS = $(LIBSODIUM_LIBS)
diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c
index 01b6b090..4f1c540a 100644
--- a/toxcore/Messenger.c
+++ b/toxcore/Messenger.c
@@ -242,7 +242,7 @@ int m_addfriend_norequest(Messenger *m, uint8_t *client_id)
242 242
243/* Remove a friend. 243/* Remove a friend.
244 * return 0 if success. 244 * return 0 if success.
245 * return -1 if failure. 245 * return -1 if failure.
246 */ 246 */
247int m_delfriend(Messenger *m, int friendnumber) 247int m_delfriend(Messenger *m, int friendnumber)
248{ 248{
diff --git a/toxcore/Messenger.h b/toxcore/Messenger.h
index b588fb4b..05b049ae 100644
--- a/toxcore/Messenger.h
+++ b/toxcore/Messenger.h
@@ -31,10 +31,6 @@
31#include "friend_requests.h" 31#include "friend_requests.h"
32#include "LAN_discovery.h" 32#include "LAN_discovery.h"
33 33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
38#define MAX_NAME_LENGTH 128 34#define MAX_NAME_LENGTH 128
39#define MAX_STATUSMESSAGE_LENGTH 128 35#define MAX_STATUSMESSAGE_LENGTH 128
40 36
@@ -376,8 +372,5 @@ void Messenger_save(Messenger *m, uint8_t *data);
376/* Load the messenger from data of size length. */ 372/* Load the messenger from data of size length. */
377int Messenger_load(Messenger *m, uint8_t *data, uint32_t length); 373int Messenger_load(Messenger *m, uint8_t *data, uint32_t length);
378 374
379#ifdef __cplusplus
380}
381#endif
382 375
383#endif 376#endif
diff --git a/toxcore/friend_requests.h b/toxcore/friend_requests.h
index 58572488..b5c46056 100644
--- a/toxcore/friend_requests.h
+++ b/toxcore/friend_requests.h
@@ -27,9 +27,6 @@
27#include "DHT.h" 27#include "DHT.h"
28#include "net_crypto.h" 28#include "net_crypto.h"
29 29
30#ifdef __cplusplus
31extern "C" {
32#endif
33 30
34typedef struct { 31typedef struct {
35 uint32_t nospam; 32 uint32_t nospam;
@@ -37,9 +34,9 @@ typedef struct {
37 uint8_t handle_friendrequest_isset; 34 uint8_t handle_friendrequest_isset;
38 void *handle_friendrequest_userdata; 35 void *handle_friendrequest_userdata;
39 36
40/* NOTE: The following is just a temporary fix for the multiple friend requests received at the same time problem. 37 /* NOTE: The following is just a temporary fix for the multiple friend requests received at the same time problem.
41 * TODO: Make this better (This will most likely tie in with the way we will handle spam.) 38 * TODO: Make this better (This will most likely tie in with the way we will handle spam.)
42 */ 39 */
43 40
44#define MAX_RECEIVED_STORED 32 41#define MAX_RECEIVED_STORED 32
45 42
@@ -64,8 +61,5 @@ void callback_friendrequest(Friend_Requests *fr, void (*function)(uint8_t *, uin
64/* Sets up friendreq packet handlers. */ 61/* Sets up friendreq packet handlers. */
65void friendreq_init(Friend_Requests *fr, Net_Crypto *c); 62void friendreq_init(Friend_Requests *fr, Net_Crypto *c);
66 63
67#ifdef __cplusplus
68}
69#endif
70 64
71#endif 65#endif
diff --git a/toxcore/net_crypto.c b/toxcore/net_crypto.c
index ccf61700..1f00144a 100644
--- a/toxcore/net_crypto.c
+++ b/toxcore/net_crypto.c
@@ -540,12 +540,12 @@ int accept_crypto_inbound(Net_Crypto *c, int connection_id, uint8_t *public_key,
540 if (connection_id == -1) 540 if (connection_id == -1)
541 return -1; 541 return -1;
542 542
543 /* 543 /*
544 * if(getcryptconnection_id(public_key) != -1) 544 * if(getcryptconnection_id(public_key) != -1)
545 * { 545 * {
546 * return -1; 546 * return -1;
547 * } 547 * }
548 */ 548 */
549 if (realloc_cryptoconnection(c, c->crypto_connections_length + 1) == -1) 549 if (realloc_cryptoconnection(c, c->crypto_connections_length + 1) == -1)
550 return -1; 550 return -1;
551 551
diff --git a/toxcore/net_crypto.h b/toxcore/net_crypto.h
index 1fde0297..778837f4 100644
--- a/toxcore/net_crypto.h
+++ b/toxcore/net_crypto.h
@@ -26,10 +26,6 @@
26 26
27#include "Lossless_UDP.h" 27#include "Lossless_UDP.h"
28 28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33#define MAX_INCOMING 64 29#define MAX_INCOMING 64
34 30
35#define CRYPTO_PACKET_FRIEND_REQ 32 /* Friend request crypto packet ID. */ 31#define CRYPTO_PACKET_FRIEND_REQ 32 /* Friend request crypto packet ID. */
@@ -212,8 +208,5 @@ void kill_net_crypto(Net_Crypto *c);
212/* Initialize the cryptopacket handling. */ 208/* Initialize the cryptopacket handling. */
213void init_cryptopackets(void *dht); 209void init_cryptopackets(void *dht);
214 210
215#ifdef __cplusplus
216}
217#endif
218 211
219#endif 212#endif
diff --git a/toxcore/network.h b/toxcore/network.h
index 7d699762..0a0122be 100644
--- a/toxcore/network.h
+++ b/toxcore/network.h
@@ -62,9 +62,6 @@
62#define crypto_box_MACBYTES (crypto_box_ZEROBYTES - crypto_box_BOXZEROBYTES) 62#define crypto_box_MACBYTES (crypto_box_ZEROBYTES - crypto_box_BOXZEROBYTES)
63#endif 63#endif
64 64
65#ifdef __cplusplus
66extern "C" {
67#endif
68 65
69#define MAX_UDP_PACKET_SIZE 65507 66#define MAX_UDP_PACKET_SIZE 65507
70 67
@@ -156,8 +153,4 @@ Networking_Core *new_networking(IP ip, uint16_t port);
156void kill_networking(Networking_Core *net); 153void kill_networking(Networking_Core *net);
157 154
158 155
159#ifdef __cplusplus
160}
161#endif
162
163#endif 156#endif
diff --git a/toxcore/tox.h b/toxcore/tox.h
index 5a4dcf49..eabdf8ff 100644
--- a/toxcore/tox.h
+++ b/toxcore/tox.h
@@ -267,7 +267,7 @@ void tox_callback_read_receipt(Tox *tox, void (*function)(Tox *tox, int, uint32_
267 * Status: 267 * Status:
268 * 0 -- friend went offline after being previously online 268 * 0 -- friend went offline after being previously online
269 * 1 -- friend went online 269 * 1 -- friend went online
270 * 270 *
271 * NOTE: This callback is not called when adding friends, thus the "after 271 * NOTE: This callback is not called when adding friends, thus the "after
272 * being previously online" part. it's assumed that when adding friends, 272 * being previously online" part. it's assumed that when adding friends,
273 * their connection status is offline. 273 * their connection status is offline.