Skip to content

Commit

Permalink
Updating toxcore to 0.1.7
Browse files Browse the repository at this point in the history
  • Loading branch information
dvor committed Apr 3, 2017
1 parent 3a83142 commit 6751005
Show file tree
Hide file tree
Showing 32 changed files with 687 additions and 391 deletions.
2 changes: 1 addition & 1 deletion toxcore-git
Submodule toxcore-git updated 70 files
+389 −0 CHANGELOG.md
+15 −9 CMakeLists.txt
+13 −3 appveyor.yml
+9 −2 auto_tests/Makefile.inc
+29 −31 auto_tests/TCP_test.c
+0 −9 auto_tests/conference_test.c
+2 −2 auto_tests/crypto_test.c
+1 −9 auto_tests/dht_test.c
+8 −6 auto_tests/encryptsave_test.c
+8 −0 auto_tests/helpers.h
+5 −5 auto_tests/messenger_test.c
+30 −38 auto_tests/network_test.c
+0 −7 auto_tests/onion_test.c
+4 −11 auto_tests/save_friend_test.c
+0 −8 auto_tests/tox_many_tcp_test.c
+0 −8 auto_tests/tox_many_test.c
+2 −1 auto_tests/tox_one_test.c
+193 −0 auto_tests/tox_strncasecmp_test.c
+5 −12 auto_tests/tox_test.c
+0 −9 auto_tests/toxav_basic_test.c
+1 −7 auto_tests/toxav_many_test.c
+17 −3 cmake/Dependencies.cmake
+1 −1 configure.ac
+4 −13 other/DHT_bootstrap.c
+1 −1 other/bootstrap_daemon/src/config.c
+3 −1 other/bootstrap_daemon/src/log.c
+2 −2 other/bootstrap_daemon/src/tox-bootstrapd.c
+1 −1 other/bootstrap_node_packets.c
+2 −0 other/travis/env-linux.sh
+2 −0 other/travis/env-osx.sh
+2 −2 so.version
+6 −14 testing/DHT_test.c
+2 −9 testing/Messenger_test.c
+1 −1 testing/av_test.c
+9 −32 testing/dns3_test.c
+4 −3 testing/irc_syncbot.c
+28 −2 testing/misc_tools.c
+15 −13 testing/nTox.c
+0 −3 testing/tox_shell.c
+3 −5 testing/tox_sync.c
+1 −1 toxav/audio.c
+4 −4 toxav/bwcontroller.c
+4 −4 toxav/groupav.c
+31 −31 toxav/rtp.c
+3 −3 toxav/toxav.c
+33 −29 toxcore/DHT.c
+1 −1 toxcore/DHT.h
+7 −7 toxcore/LAN_discovery.c
+2 −1 toxcore/Makefile.inc
+24 −25 toxcore/Messenger.c
+20 −42 toxcore/TCP_client.c
+4 −1 toxcore/TCP_connection.c
+20 −47 toxcore/TCP_server.c
+43 −0 toxcore/ccompat.h
+20 −7 toxcore/crypto_core.c
+4 −4 toxcore/friend_connection.c
+2 −2 toxcore/friend_requests.c
+37 −37 toxcore/group.c
+8 −0 toxcore/list.c
+11 −11 toxcore/net_crypto.c
+233 −17 toxcore/network.c
+52 −10 toxcore/network.h
+12 −12 toxcore/onion.c
+33 −8 toxcore/onion_announce.c
+45 −20 toxcore/onion_client.c
+1 −1 toxcore/tox.api.h
+26 −60 toxcore/tox.c
+1 −1 toxcore/tox.h
+1 −1 toxcore/util.c
+2 −2 toxdns/toxdns.c
2 changes: 1 addition & 1 deletion toxcore.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

Pod::Spec.new do |s|
s.name = "toxcore"
s.version = "0.1.6"
s.version = "0.1.7"
s.summary = "Cocoapods wrapper for toxcore"
s.homepage = "https://github.com/Antidote-for-Tox/toxcore"
s.license = 'GPLv3'
Expand Down
2 changes: 1 addition & 1 deletion toxcore/toxav/audio.m
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ void ac_iterate(ACSession *ac)

/* Pick up sampling rate from packet */
memcpy(&ac->lp_sampling_rate, msg->data, 4);
ac->lp_sampling_rate = ntohl(ac->lp_sampling_rate);
ac->lp_sampling_rate = net_ntohl(ac->lp_sampling_rate);

ac->lp_channel_count = opus_packet_get_nb_channels(msg->data + 4);

Expand Down
8 changes: 4 additions & 4 deletions toxcore/toxav/bwcontroller.m
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ void send_update(BWController *bwc)
struct BWCMessage *b_msg = (struct BWCMessage *)(p_msg + 1);

p_msg[0] = BWC_PACKET_ID;
b_msg->lost = htonl(bwc->cycle.lost);
b_msg->recv = htonl(bwc->cycle.recv);
b_msg->lost = net_htonl(bwc->cycle.lost);
b_msg->recv = net_htonl(bwc->cycle.recv);

if (-1 == m_send_custom_lossy_packet(bwc->m, bwc->friend_number, p_msg, sizeof(p_msg))) {
LOGGER_WARNING(bwc->m->log, "BWC send failed (len: %d)! std error: %s", sizeof(p_msg), strerror(errno));
Expand All @@ -192,8 +192,8 @@ static int on_update(BWController *bwc, const struct BWCMessage *msg)

bwc->cycle.lru = current_time_monotonic();

uint32_t recv = ntohl(msg->recv);
uint32_t lost = ntohl(msg->lost);
uint32_t recv = net_ntohl(msg->recv);
uint32_t lost = net_ntohl(msg->lost);

LOGGER_DEBUG(bwc->m->log, "recved: %u lost: %u", recv, lost);

Expand Down
8 changes: 4 additions & 4 deletions toxcore/toxav/groupav.m
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ static int handle_group_audio_packet(void *object, int groupnumber, int friendgr

uint16_t sequnum;
memcpy(&sequnum, packet, sizeof(sequnum));
pk->sequnum = ntohs(sequnum);
pk->sequnum = net_ntohs(sequnum);
pk->length = length - sizeof(uint16_t);
memcpy(pk->data, packet + sizeof(uint16_t), length - sizeof(uint16_t));

Expand Down Expand Up @@ -510,14 +510,14 @@ static int send_audio_packet(Group_Chats *g_c, int groupnumber, uint8_t *packet,
}

Group_AV *group_av = (Group_AV *)group_get_object(g_c, groupnumber);
uint8_t data[1 + sizeof(uint16_t) + length];
VLA(uint8_t, data, 1 + sizeof(uint16_t) + length);
data[0] = GROUP_AUDIO_PACKET_ID;

uint16_t sequnum = htons(group_av->audio_sequnum);
uint16_t sequnum = net_htons(group_av->audio_sequnum);
memcpy(data + 1, &sequnum, sizeof(sequnum));
memcpy(data + 1 + sizeof(sequnum), packet, length);

if (send_group_lossy_packet(g_c, groupnumber, data, sizeof(data)) == -1) {
if (send_group_lossy_packet(g_c, groupnumber, data, SIZEOF_VLA(data)) == -1) {
return -1;
}

Expand Down
62 changes: 31 additions & 31 deletions toxcore/toxav/rtp.m
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,12 @@ int rtp_send_data(RTPSession *session, const uint8_t *data, uint16_t length, Log
return -1;
}

uint8_t rdata[length + sizeof(struct RTPHeader) + 1];
memset(rdata, 0, sizeof(rdata));
VLA(uint8_t, rdata, length + sizeof(struct RTPHeader) + 1);
memset(rdata, 0, SIZEOF_VLA(rdata));

rdata[0] = session->payload_type;

struct RTPHeader *header = (struct RTPHeader *)(rdata + 1);
struct RTPHeader *header = (struct RTPHeader *)(rdata + 1);

header->ve = 2;
header->pe = 0;
Expand All @@ -131,12 +131,12 @@ int rtp_send_data(RTPSession *session, const uint8_t *data, uint16_t length, Log
header->ma = 0;
header->pt = session->payload_type % 128;

header->sequnum = htons(session->sequnum);
header->timestamp = htonl(current_time_monotonic());
header->ssrc = htonl(session->ssrc);
header->sequnum = net_htons(session->sequnum);
header->timestamp = net_htonl(current_time_monotonic());
header->ssrc = net_htonl(session->ssrc);

header->cpart = 0;
header->tlen = htons(length);
header->tlen = net_htons(length);

if (MAX_CRYPTO_DATA_SIZE > length + sizeof(struct RTPHeader) + 1) {

Expand All @@ -147,8 +147,8 @@ int rtp_send_data(RTPSession *session, const uint8_t *data, uint16_t length, Log

memcpy(rdata + 1 + sizeof(struct RTPHeader), data, length);

if (-1 == m_send_custom_lossy_packet(session->m, session->friend_number, rdata, sizeof(rdata))) {
LOGGER_WARNING(session->m->log, "RTP send failed (len: %d)! std error: %s", sizeof(rdata), strerror(errno));
if (-1 == m_send_custom_lossy_packet(session->m, session->friend_number, rdata, SIZEOF_VLA(rdata))) {
LOGGER_WARNING(session->m->log, "RTP send failed (len: %d)! std error: %s", SIZEOF_VLA(rdata), strerror(errno));
}
} else {

Expand All @@ -170,7 +170,7 @@ int rtp_send_data(RTPSession *session, const uint8_t *data, uint16_t length, Log
}

sent += piece;
header->cpart = htons(sent);
header->cpart = net_htons(sent);
}

/* Send remaining */
Expand All @@ -194,10 +194,10 @@ int rtp_send_data(RTPSession *session, const uint8_t *data, uint16_t length, Log

static bool chloss(const RTPSession *session, const struct RTPHeader *header)
{
if (ntohl(header->timestamp) < session->rtimestamp) {
if (net_ntohl(header->timestamp) < session->rtimestamp) {
uint16_t hosq, lost = 0;

hosq = ntohs(header->sequnum);
hosq = net_ntohs(header->sequnum);

lost = (hosq > session->rsequnum) ?
(session->rsequnum + 65535) - hosq :
Expand All @@ -224,12 +224,12 @@ static bool chloss(const RTPSession *session, const struct RTPHeader *header)
msg->len = data_length - sizeof(struct RTPHeader);
memcpy(&msg->header, data, data_length);

msg->header.sequnum = ntohs(msg->header.sequnum);
msg->header.timestamp = ntohl(msg->header.timestamp);
msg->header.ssrc = ntohl(msg->header.ssrc);
msg->header.sequnum = net_ntohs(msg->header.sequnum);
msg->header.timestamp = net_ntohl(msg->header.timestamp);
msg->header.ssrc = net_ntohl(msg->header.ssrc);

msg->header.cpart = ntohs(msg->header.cpart);
msg->header.tlen = ntohs(msg->header.tlen);
msg->header.cpart = net_ntohs(msg->header.cpart);
msg->header.tlen = net_ntohs(msg->header.tlen);

return msg;
}
Expand All @@ -255,14 +255,14 @@ int handle_rtp_packet(Messenger *m, uint32_t friendnumber, const uint8_t *data,
return -1;
}

if (ntohs(header->cpart) >= ntohs(header->tlen)) {
if (net_ntohs(header->cpart) >= net_ntohs(header->tlen)) {
/* Never allow this case to happen */
return -1;
}

bwc_feed_avg(session->bwc, length);

if (ntohs(header->tlen) == length - sizeof(struct RTPHeader)) {
if (net_ntohs(header->tlen) == length - sizeof(struct RTPHeader)) {
/* The message is sent in single part */

/* Only allow messages which have arrived in order;
Expand All @@ -273,8 +273,8 @@ int handle_rtp_packet(Messenger *m, uint32_t friendnumber, const uint8_t *data,
}

/* Message is not late; pick up the latest parameters */
session->rsequnum = ntohs(header->sequnum);
session->rtimestamp = ntohl(header->timestamp);
session->rsequnum = net_ntohs(header->sequnum);
session->rtimestamp = net_ntohl(header->timestamp);

bwc_add_recv(session->bwc, length);

Expand Down Expand Up @@ -311,20 +311,20 @@ int handle_rtp_packet(Messenger *m, uint32_t friendnumber, const uint8_t *data,
* processing message
*/

if (session->mp->header.sequnum == ntohs(header->sequnum) &&
session->mp->header.timestamp == ntohl(header->timestamp)) {
if (session->mp->header.sequnum == net_ntohs(header->sequnum) &&
session->mp->header.timestamp == net_ntohl(header->timestamp)) {
/* First case */

/* Make sure we have enough allocated memory */
if (session->mp->header.tlen - session->mp->len < length - sizeof(struct RTPHeader) ||
session->mp->header.tlen <= ntohs(header->cpart)) {
session->mp->header.tlen <= net_ntohs(header->cpart)) {
/* There happened to be some corruption on the stream;
* continue wihtout this part
*/
return 0;
}

memcpy(session->mp->data + ntohs(header->cpart), data + sizeof(struct RTPHeader),
memcpy(session->mp->data + net_ntohs(header->cpart), data + sizeof(struct RTPHeader),
length - sizeof(struct RTPHeader));

session->mp->len += length - sizeof(struct RTPHeader);
Expand All @@ -346,7 +346,7 @@ int handle_rtp_packet(Messenger *m, uint32_t friendnumber, const uint8_t *data,
} else {
/* Second case */

if (session->mp->header.timestamp > ntohl(header->timestamp)) {
if (session->mp->header.timestamp > net_ntohl(header->timestamp)) {
/* The received message part is from the old message;
* discard it.
*/
Expand Down Expand Up @@ -386,22 +386,22 @@ int handle_rtp_packet(Messenger *m, uint32_t friendnumber, const uint8_t *data,
}

/* Message is not late; pick up the latest parameters */
session->rsequnum = ntohs(header->sequnum);
session->rtimestamp = ntohl(header->timestamp);
session->rsequnum = net_ntohs(header->sequnum);
session->rtimestamp = net_ntohl(header->timestamp);

bwc_add_recv(session->bwc, length);

/* Again, only store message if handler is present
*/
if (session->mcb) {
session->mp = new_message(ntohs(header->tlen) + sizeof(struct RTPHeader), data, length);
session->mp = new_message(net_ntohs(header->tlen) + sizeof(struct RTPHeader), data, length);

/* Reposition data if necessary */
if (ntohs(header->cpart)) {
if (net_ntohs(header->cpart)) {
;
}

memmove(session->mp->data + ntohs(header->cpart), session->mp->data, session->mp->len);
memmove(session->mp->data + net_ntohs(header->cpart), session->mp->data, session->mp->len);
}
}

Expand Down
6 changes: 3 additions & 3 deletions toxcore/toxav/toxav.m
Original file line number Diff line number Diff line change
Expand Up @@ -704,12 +704,12 @@ bool toxav_audio_send_frame(ToxAV *av, uint32_t friend_number, const int16_t *pc
goto END;
}

uint8_t dest[sample_count + sizeof(sampling_rate)]; /* This is more than enough always */
VLA(uint8_t, dest, sample_count + sizeof(sampling_rate)); /* This is more than enough always */

sampling_rate = htonl(sampling_rate);
sampling_rate = net_htonl(sampling_rate);
memcpy(dest, &sampling_rate, sizeof(sampling_rate));
int vrc = opus_encode(call->audio.second->encoder, pcm, sample_count,
dest + sizeof(sampling_rate), sizeof(dest) - sizeof(sampling_rate));
dest + sizeof(sampling_rate), SIZEOF_VLA(dest) - sizeof(sampling_rate));

if (vrc < 0) {
LOGGER_WARNING(av->m->log, "Failed to encode frame %s", opus_strerror(vrc));
Expand Down
2 changes: 1 addition & 1 deletion toxcore/toxcore/DHT.h
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ bool node_addable_to_close_list(DHT *dht, const uint8_t *public_key, IP_Port ip_
* return the number of nodes returned.
*
*/
int get_close_nodes(const DHT *dht, const uint8_t *public_key, Node_format *nodes_list, sa_family_t sa_family,
int get_close_nodes(const DHT *dht, const uint8_t *public_key, Node_format *nodes_list, Family sa_family,
uint8_t is_LAN, uint8_t want_good);


Expand Down
Loading

0 comments on commit 6751005

Please sign in to comment.