summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorGDR! <gdr@go2.pl>2014-12-11 22:19:32 +0100
committerGDR! <gdr@go2.pl>2014-12-11 22:19:32 +0100
commit169a478762d6863782395acff8c9f53b733048f5 (patch)
tree81bee083ffd6e7fa2dcfc49b06f960802c2b3ef8 /main.c
parentea3d59d854108f28c2d2d10a5af60fe3d66e1f6f (diff)
Added handle_server_tcp_fin_frame
Diffstat (limited to 'main.c')
-rw-r--r--main.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/main.c b/main.c
index bff4620..f564664 100644
--- a/main.c
+++ b/main.c
@@ -374,6 +374,12 @@ int handle_client_tcp_frame(protocol_frame *rcvd_frame)
374 return -1; 374 return -1;
375 } 375 }
376 376
377 if(tun->friendnumber != rcvd_frame->friendnumber)
378 {
379 fprintf(stderr, "Friend #%d tried to send packet to a tunnel which belongs to #%d\n", rcvd_frame->friendnumber, tun->friendnumber);
380 return -1;
381 }
382
377 while(offset < rcvd_frame->data_length) 383 while(offset < rcvd_frame->data_length)
378 { 384 {
379 int sent_bytes; 385 int sent_bytes;
@@ -397,11 +403,6 @@ int handle_client_tcp_frame(protocol_frame *rcvd_frame)
397 return 0; 403 return 0;
398} 404}
399 405
400int handle_server_tcp_fin_frame(protocol_frame *rcvd_frame)
401{
402
403}
404
405/* Handle close-tunnel frame received from the client */ 406/* Handle close-tunnel frame received from the client */
406int handle_client_tcp_fin_frame(protocol_frame *rcvd_frame) 407int handle_client_tcp_fin_frame(protocol_frame *rcvd_frame)
407{ 408{
@@ -506,7 +507,7 @@ int parse_lossless_packet(void *sender_uc, const uint8_t *data, uint32_t len)
506 frame->packet_type = INT16_AT(data, 2); 507 frame->packet_type = INT16_AT(data, 2);
507 frame->connid = INT16_AT(data, 4); 508 frame->connid = INT16_AT(data, 4);
508 frame->data_length = INT16_AT(data, 6); 509 frame->data_length = INT16_AT(data, 6);
509 frame->data = data + PROTOCOL_BUFFER_OFFSET; 510 frame->data = (uint8_t *)(data + PROTOCOL_BUFFER_OFFSET);
510 frame->friendnumber = *((uint32_t*)sender_uc); 511 frame->friendnumber = *((uint32_t*)sender_uc);
511 printf("Got protocol frame magic 0x%x type 0x%x from friend %d\n", frame->magic, frame->packet_type, frame->friendnumber); 512 printf("Got protocol frame magic 0x%x type 0x%x from friend %d\n", frame->magic, frame->packet_type, frame->friendnumber);
512 513
@@ -861,6 +862,7 @@ int main(int argc, char *argv[])
861 } 862 }
862 863
863 tox_get_address(tox, tox_id); 864 tox_get_address(tox, tox_id);
865 memset(tox_printable_id, '\0', sizeof(tox_printable_id));
864 id_to_string(tox_printable_id, tox_id); 866 id_to_string(tox_printable_id, tox_id);
865 tox_printable_id[TOX_FRIEND_ADDRESS_SIZE * 2] = '\0'; 867 tox_printable_id[TOX_FRIEND_ADDRESS_SIZE * 2] = '\0';
866 printf("Using Tox ID: %s\n", tox_printable_id); 868 printf("Using Tox ID: %s\n", tox_printable_id);