mirror of
https://github.com/berlin-open-wireless-lab/DAWN.git
synced 2025-03-09 15:40:12 +00:00
fix
This commit is contained in:
parent
977dce858f
commit
96be14940c
2 changed files with 39 additions and 4 deletions
|
@ -142,8 +142,8 @@ void *receive_msg_enc(void *args) {
|
||||||
}
|
}
|
||||||
//recv_string[recv_string_len] = '\0';
|
//recv_string[recv_string_len] = '\0';
|
||||||
|
|
||||||
char *base64_dec_str = malloc(B64_DECODE_LEN(recv_string));
|
char *base64_dec_str = malloc(B64_DECODE_LEN(strlen(recv_string)));
|
||||||
int base64_dec_length = b64_decode(str, base64_dec_str, B64_DECODE_LEN(recv_string));
|
int base64_dec_length = b64_decode(recv_string, base64_dec_str, B64_DECODE_LEN(strlen(recv_string)));
|
||||||
char *dec = gcrypt_decrypt_msg(base64_dec_str, base64_dec_length);
|
char *dec = gcrypt_decrypt_msg(base64_dec_str, base64_dec_length);
|
||||||
|
|
||||||
//printf("NETRWORK RECEIVED: %s\n", dec);
|
//printf("NETRWORK RECEIVED: %s\n", dec);
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
int tcp_array_insert(struct network_con_s entry);
|
int tcp_array_insert(struct network_con_s entry);
|
||||||
|
|
||||||
|
int tcp_array_delete(struct sockaddr_in entry);
|
||||||
|
|
||||||
int tcp_array_contains_address_help(struct sockaddr_in entry);
|
int tcp_array_contains_address_help(struct sockaddr_in entry);
|
||||||
|
|
||||||
void print_tcp_entry(struct network_con_s entry);
|
void print_tcp_entry(struct network_con_s entry);
|
||||||
|
@ -39,6 +41,12 @@ static void client_close(struct ustream *s) {
|
||||||
fprintf(stderr, "Connection closed\n");
|
fprintf(stderr, "Connection closed\n");
|
||||||
ustream_free(s);
|
ustream_free(s);
|
||||||
close(cl->s.fd.fd);
|
close(cl->s.fd.fd);
|
||||||
|
|
||||||
|
// remove from tcp array
|
||||||
|
pthread_mutex_lock(&tcp_array_mutex);
|
||||||
|
tcp_array_delete(cl->sin);
|
||||||
|
pthread_mutex_unlock(&tcp_array_mutex);
|
||||||
|
|
||||||
free(cl);
|
free(cl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,6 +62,8 @@ static void client_notify_state(struct ustream *s) {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fprintf(stderr, "eof!, pending: %d, total: %d\n", s->w.data_bytes, cl->ctr);
|
fprintf(stderr, "eof!, pending: %d, total: %d\n", s->w.data_bytes, cl->ctr);
|
||||||
|
|
||||||
|
// TODO: REMOVE CLIENT FROM LIST!
|
||||||
if (!s->w.data_bytes)
|
if (!s->w.data_bytes)
|
||||||
return client_close(s);
|
return client_close(s);
|
||||||
|
|
||||||
|
@ -72,8 +82,8 @@ static void client_read_cb(struct ustream *s, int bytes) {
|
||||||
|
|
||||||
if(network_config.use_symm_enc)
|
if(network_config.use_symm_enc)
|
||||||
{
|
{
|
||||||
char *base64_dec_str = malloc(B64_DECODE_LEN(str));
|
char *base64_dec_str = malloc(B64_DECODE_LEN(strlen(str)));
|
||||||
int base64_dec_length = b64_decode(str, base64_dec_str, B64_DECODE_LEN(str));
|
int base64_dec_length = b64_decode(str, base64_dec_str, B64_DECODE_LEN(strlen(str)));
|
||||||
char *dec = gcrypt_decrypt_msg(base64_dec_str, base64_dec_length);
|
char *dec = gcrypt_decrypt_msg(base64_dec_str, base64_dec_length);
|
||||||
|
|
||||||
printf("NETRWORK RECEIVED: %s\n", dec);
|
printf("NETRWORK RECEIVED: %s\n", dec);
|
||||||
|
@ -264,6 +274,31 @@ int tcp_array_insert(struct network_con_s entry) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int tcp_array_delete(struct sockaddr_in entry) {
|
||||||
|
int i;
|
||||||
|
int found_in_array = 0;
|
||||||
|
|
||||||
|
if (tcp_entry_last == -1) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i <= tcp_entry_last; i++) {
|
||||||
|
if (entry.sin_addr.s_addr == network_array[i].sock_addr.sin_addr.s_addr) {
|
||||||
|
found_in_array = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int j = i; j < tcp_entry_last; j++) {
|
||||||
|
network_array[j] = network_array[j + 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tcp_entry_last > -1 && found_in_array) {
|
||||||
|
tcp_entry_last--;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int tcp_array_contains_address(struct sockaddr_in entry) {
|
int tcp_array_contains_address(struct sockaddr_in entry) {
|
||||||
pthread_mutex_lock(&tcp_array_mutex);
|
pthread_mutex_lock(&tcp_array_mutex);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue