diff options
author | irungentoo <irungentoo@gmail.com> | 2013-07-07 11:54:25 -0400 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2013-07-07 11:54:25 -0400 |
commit | a632d960f8d8095566530d1d0dc1393f02e1e07f (patch) | |
tree | 77af042fcf487468691b2dbfc7273a05fd133f48 /testing | |
parent | 2528ec148c6b1865a489c232800377f1d3952f04 (diff) |
Fixed to be confilcts with the DHT and the messenger part.
Diffstat (limited to 'testing')
-rw-r--r-- | testing/DHT_cryptosendfiletest.c | 10 | ||||
-rw-r--r-- | testing/DHT_sendfiletest.c | 12 | ||||
-rw-r--r-- | testing/DHT_test.c | 10 |
3 files changed, 16 insertions, 16 deletions
diff --git a/testing/DHT_cryptosendfiletest.c b/testing/DHT_cryptosendfiletest.c index 84d777cc..09683a45 100644 --- a/testing/DHT_cryptosendfiletest.c +++ b/testing/DHT_cryptosendfiletest.c | |||
@@ -90,7 +90,7 @@ int main(int argc, char *argv[]) | |||
90 | //memcpy(self_client_id, "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq", 32); | 90 | //memcpy(self_client_id, "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq", 32); |
91 | 91 | ||
92 | 92 | ||
93 | addfriend(friend_id); | 93 | DHT_addfriend(friend_id); |
94 | IP_Port friend_ip; | 94 | IP_Port friend_ip; |
95 | int connection = -1; | 95 | int connection = -1; |
96 | int inconnection = -1; | 96 | int inconnection = -1; |
@@ -112,7 +112,7 @@ int main(int argc, char *argv[]) | |||
112 | IP_Port bootstrap_ip_port; | 112 | IP_Port bootstrap_ip_port; |
113 | bootstrap_ip_port.port = htons(atoi(argv[2])); | 113 | bootstrap_ip_port.port = htons(atoi(argv[2])); |
114 | bootstrap_ip_port.ip.i = inet_addr(argv[1]); | 114 | bootstrap_ip_port.ip.i = inet_addr(argv[1]); |
115 | bootstrap(bootstrap_ip_port); | 115 | DHT_bootstrap(bootstrap_ip_port); |
116 | 116 | ||
117 | IP_Port ip_port; | 117 | IP_Port ip_port; |
118 | uint8_t data[MAX_UDP_PACKET_SIZE]; | 118 | uint8_t data[MAX_UDP_PACKET_SIZE]; |
@@ -146,21 +146,21 @@ int main(int argc, char *argv[]) | |||
146 | } | 146 | } |
147 | } | 147 | } |
148 | } | 148 | } |
149 | friend_ip = getfriendip((uint8_t *)friend_id); | 149 | friend_ip = DHT_getfriendip(friend_id); |
150 | if(friend_ip.ip.i != 0) | 150 | if(friend_ip.ip.i != 0) |
151 | { | 151 | { |
152 | if(connection == -1 && friendrequest == -1) | 152 | if(connection == -1 && friendrequest == -1) |
153 | { | 153 | { |
154 | printf("Sending friend request to peer:"); | 154 | printf("Sending friend request to peer:"); |
155 | printip(friend_ip); | 155 | printip(friend_ip); |
156 | friendrequest = send_friendrequest(friend_id, friend_ip, "Hello World", 12); | 156 | friendrequest = send_friendrequest(friend_id, friend_ip,(uint8_t *) "Hello World", 12); |
157 | //connection = crypto_connect((uint8_t *)friend_id, friend_ip); | 157 | //connection = crypto_connect((uint8_t *)friend_id, friend_ip); |
158 | //connection = new_connection(friend_ip); | 158 | //connection = new_connection(friend_ip); |
159 | } | 159 | } |
160 | if(check_friendrequest(friendrequest) == 1) | 160 | if(check_friendrequest(friendrequest) == 1) |
161 | { | 161 | { |
162 | printf("Started connecting to friend:"); | 162 | printf("Started connecting to friend:"); |
163 | connection = crypto_connect((uint8_t *)friend_id, friend_ip); | 163 | connection = crypto_connect(friend_id, friend_ip); |
164 | } | 164 | } |
165 | } | 165 | } |
166 | if(inconnection == -1) | 166 | if(inconnection == -1) |
diff --git a/testing/DHT_sendfiletest.c b/testing/DHT_sendfiletest.c index fd4fd29f..9a455056 100644 --- a/testing/DHT_sendfiletest.c +++ b/testing/DHT_sendfiletest.c | |||
@@ -48,7 +48,7 @@ int main(int argc, char *argv[]) | |||
48 | printf("usage %s ip port client_id(of friend to find ip_port of) filename(of file to send) client_id(ours)\n", argv[0]); | 48 | printf("usage %s ip port client_id(of friend to find ip_port of) filename(of file to send) client_id(ours)\n", argv[0]); |
49 | exit(0); | 49 | exit(0); |
50 | } | 50 | } |
51 | addfriend(argv[3]); | 51 | DHT_addfriend((uint8_t *)argv[3]); |
52 | IP_Port friend_ip; | 52 | IP_Port friend_ip; |
53 | int connection = -1; | 53 | int connection = -1; |
54 | int inconnection = -1; | 54 | int inconnection = -1; |
@@ -66,15 +66,15 @@ int main(int argc, char *argv[]) | |||
66 | IP_Port bootstrap_ip_port; | 66 | IP_Port bootstrap_ip_port; |
67 | bootstrap_ip_port.port = htons(atoi(argv[2])); | 67 | bootstrap_ip_port.port = htons(atoi(argv[2])); |
68 | bootstrap_ip_port.ip.i = inet_addr(argv[1]); | 68 | bootstrap_ip_port.ip.i = inet_addr(argv[1]); |
69 | bootstrap(bootstrap_ip_port); | 69 | DHT_bootstrap(bootstrap_ip_port); |
70 | 70 | ||
71 | IP_Port ip_port; | 71 | IP_Port ip_port; |
72 | char data[MAX_UDP_PACKET_SIZE]; | 72 | uint8_t data[MAX_UDP_PACKET_SIZE]; |
73 | uint32_t length; | 73 | uint32_t length; |
74 | 74 | ||
75 | char buffer1[128]; | 75 | uint8_t buffer1[128]; |
76 | int read1 = 0; | 76 | int read1 = 0; |
77 | char buffer2[128]; | 77 | uint8_t buffer2[128]; |
78 | int read2 = 0; | 78 | int read2 = 0; |
79 | FILE *file1 = fopen(argv[4], "rb"); | 79 | FILE *file1 = fopen(argv[4], "rb"); |
80 | if ( file1==NULL ){printf("Error opening file.\n");return 1;} | 80 | if ( file1==NULL ){printf("Error opening file.\n");return 1;} |
@@ -100,7 +100,7 @@ int main(int argc, char *argv[]) | |||
100 | } | 100 | } |
101 | } | 101 | } |
102 | } | 102 | } |
103 | friend_ip = getfriendip(argv[3]); | 103 | friend_ip = DHT_getfriendip((uint8_t *)argv[3]); |
104 | if(friend_ip.ip.i != 0) | 104 | if(friend_ip.ip.i != 0) |
105 | { | 105 | { |
106 | if(connection == -1) | 106 | if(connection == -1) |
diff --git a/testing/DHT_test.c b/testing/DHT_test.c index 9100c01a..25bf869e 100644 --- a/testing/DHT_test.c +++ b/testing/DHT_test.c | |||
@@ -1,13 +1,13 @@ | |||
1 | /* DHT test | 1 | /* DHT test |
2 | * A file with a main that runs our DHT for testing. | 2 | * A file with a main that runs our DHT for testing. |
3 | * | 3 | * |
4 | * Compile with: gcc -O2 -Wall -o test ../core/DHT.c ../core/network.c DHT_test.c | 4 | * Compile with: gcc -O2 -Wall -o test ../core/network.c DHT_test.c |
5 | * | 5 | * |
6 | * Command line arguments are the ip and port of a node and the client_id (32 bytes) of the friend you want to find the ip_port of | 6 | * Command line arguments are the ip and port of a node and the client_id (32 bytes) of the friend you want to find the ip_port of |
7 | * EX: ./test 127.0.0.1 33445 ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef | 7 | * EX: ./test 127.0.0.1 33445 ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef |
8 | */ | 8 | */ |
9 | #include "../core/network.h" | 9 | #include "../core/network.h" |
10 | #include "../core/DHT.h" | 10 | #include "../core/DHT.c" |
11 | 11 | ||
12 | #include <string.h> | 12 | #include <string.h> |
13 | 13 | ||
@@ -58,7 +58,7 @@ void print_friendlist() | |||
58 | { | 58 | { |
59 | printf("%c", friends_list[k].client_id[j]); | 59 | printf("%c", friends_list[k].client_id[j]); |
60 | } | 60 | } |
61 | p_ip = getfriendip(friends_list[k].client_id); | 61 | p_ip = DHT_getfriendip(friends_list[k].client_id); |
62 | printf("\nIP: %u.%u.%u.%u:%u",p_ip.ip.c[0],p_ip.ip.c[1],p_ip.ip.c[2],p_ip.ip.c[3],ntohs(p_ip.port)); | 62 | printf("\nIP: %u.%u.%u.%u:%u",p_ip.ip.c[0],p_ip.ip.c[1],p_ip.ip.c[2],p_ip.ip.c[3],ntohs(p_ip.port)); |
63 | 63 | ||
64 | printf("\nCLIENTS IN LIST:\n\n"); | 64 | printf("\nCLIENTS IN LIST:\n\n"); |
@@ -102,7 +102,7 @@ int main(int argc, char *argv[]) | |||
102 | printf("usage %s ip port client_id(of friend to find ip_port of)\n", argv[0]); | 102 | printf("usage %s ip port client_id(of friend to find ip_port of)\n", argv[0]); |
103 | exit(0); | 103 | exit(0); |
104 | } | 104 | } |
105 | addfriend((uint8_t *)argv[3]); | 105 | DHT_addfriend((uint8_t *)argv[3]); |
106 | 106 | ||
107 | //initialize networking | 107 | //initialize networking |
108 | //bind to ip 0.0.0.0:PORT | 108 | //bind to ip 0.0.0.0:PORT |
@@ -122,7 +122,7 @@ int main(int argc, char *argv[]) | |||
122 | //bootstrap_ip_port.ip.c[2] = 0; | 122 | //bootstrap_ip_port.ip.c[2] = 0; |
123 | //bootstrap_ip_port.ip.c[3] = 1; | 123 | //bootstrap_ip_port.ip.c[3] = 1; |
124 | bootstrap_ip_port.ip.i = inet_addr(argv[1]); | 124 | bootstrap_ip_port.ip.i = inet_addr(argv[1]); |
125 | bootstrap(bootstrap_ip_port); | 125 | DHT_bootstrap(bootstrap_ip_port); |
126 | 126 | ||
127 | IP_Port ip_port; | 127 | IP_Port ip_port; |
128 | uint8_t data[MAX_UDP_PACKET_SIZE]; | 128 | uint8_t data[MAX_UDP_PACKET_SIZE]; |