Fix comaprison bug

This commit is contained in:
Quentin Dufour 2019-02-14 15:40:05 +01:00
parent b42170d6a5
commit ab568befcf
2 changed files with 7 additions and 5 deletions

View file

@ -67,8 +67,10 @@ void donar_client(struct donar_client_ctx* ctx, struct algo_skel* algo, char* on
load_onion_services (ctx, onion_file, CLIENT_PORT_SIZE);
printf("--- Onion services loaded\n");
init_tcp_clients(ctx);
printf("--- TCP Clients Connected\n");
init_udp_server (ctx, port);
printf("--- UDP Server is listening\n");

View file

@ -1,7 +1,7 @@
#include "packet.h"
enum FD_STATE read_packet_from_tcp(int fd, struct buffer_packet* bp) {
int nread;
ssize_t nread;
size_t pkt_size_size = sizeof(bp->ip.ap.str.size);
if (bp->mode == BP_WRITING) return FDS_ERR;
@ -28,7 +28,7 @@ enum FD_STATE read_packet_from_tcp(int fd, struct buffer_packet* bp) {
}
enum FD_STATE write_packet_to_tcp(int fd, struct buffer_packet* bp) {
int nwrite;
ssize_t nwrite;
while (bp->awrite < bp->ip.ap.str.size) {
nwrite = send(fd, &(bp->ip.ap.raw), bp->ip.ap.str.size, 0);
@ -44,7 +44,7 @@ enum FD_STATE write_packet_to_tcp(int fd, struct buffer_packet* bp) {
}
enum FD_STATE write_packet_to_udp(int fd, struct buffer_packet* bp, struct sockaddr* addr, socklen_t addrlen) {
int nwrite, bytes_to_send;
ssize_t nwrite, bytes_to_send;
size_t pkt_size_size = sizeof(bp->ip.ap.str.size);
if (bp->mode == BP_READING) return FDS_ERR;
@ -66,7 +66,7 @@ enum FD_STATE write_packet_to_udp(int fd, struct buffer_packet* bp, struct socka
}
enum FD_STATE read_packet_from_udp (int fd, struct buffer_packet* bp, struct sockaddr* addr, socklen_t* addrlen) {
int nread;
ssize_t nread;
if (bp->mode == BP_WRITING) return FDS_ERR;
*addrlen = sizeof(struct sockaddr_in);
@ -76,7 +76,7 @@ enum FD_STATE read_packet_from_udp (int fd, struct buffer_packet* bp, struct soc
nread = recvfrom(fd, &(bp->ip.ap.str.payload), udp_packet_size, MSG_TRUNC,
addr, addrlen);
if (nread > udp_packet_size) return FDS_ERR;
if ((int)nread > (int)udp_packet_size) return FDS_ERR;
if (nread == -1 && errno == EAGAIN) return FDS_AGAIN;
if (nread == -1) return FDS_ERR;