From c5b0056f6779462bfda7cdd4b1abc1ca7119ee2d Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Thu, 13 Apr 2017 20:01:56 +0200 Subject: [PATCH] [fix] pour l'incompetence des dev java --- central-manager/lib/data.h | 4 ++-- central-manager/lib/header.h | 2 +- central-manager/lib/local/middleware.c | 8 ++++---- plane/plane.c | 4 ++-- plane/plane.h | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/central-manager/lib/data.h b/central-manager/lib/data.h index 31e8a20..26d711e 100644 --- a/central-manager/lib/data.h +++ b/central-manager/lib/data.h @@ -40,7 +40,7 @@ }; - #define BINDHDR_LEN ( sizeof(char)*(1+INET_ADDRSTRLEN)+sizeof(unsigned short) ) + #define BINDHDR_LEN ( sizeof(char)*(1+INET_ADDRSTRLEN)+sizeof(int) ) #define BINDHEAD_CTL 0x01 // is command terminal (else: view terminal) #define BINDHEAD_SCK 0x02 // ask for com socket #define BINDHEAD_TCP 0x04 // ask TCP instead of UDP @@ -48,7 +48,7 @@ struct bind_header{ char flags; char addr[INET_ADDRSTRLEN]; - unsigned short port; + int port; }; #endif \ No newline at end of file diff --git a/central-manager/lib/header.h b/central-manager/lib/header.h index c77dca5..9dd454b 100644 --- a/central-manager/lib/header.h +++ b/central-manager/lib/header.h @@ -75,7 +75,7 @@ struct listen_arg{ const char addr[16]; // socket address - const unsigned short port; // socket port + const int port; // socket port int (*middleware)(struct middleware_arg*); // middleware function void* (*handler)(void*); // management function (thread) }; diff --git a/central-manager/lib/local/middleware.c b/central-manager/lib/local/middleware.c index 51a7c2b..e3d511f 100644 --- a/central-manager/lib/local/middleware.c +++ b/central-manager/lib/local/middleware.c @@ -42,7 +42,7 @@ int multicastPlanes(struct middleware_arg* arg){ /* 1. On parse la requête */ memcpy(&request.flags, buffer, sizeof(char)); memcpy(&request.addr, buffer+sizeof(char), sizeof(char)*15); - memcpy(&request.port, buffer+sizeof(char)*16, sizeof(unsigned short)); + memcpy(&request.port, buffer+sizeof(char)*16, sizeof(int)); printf("{%s} received: bind_header{flag = %d; addr = '%s'; port = %d}\n", arg->entity, (int) request.flags, request.addr, request.port); /* (1) Envoi socket de communication (TCP) @@ -62,7 +62,7 @@ int multicastPlanes(struct middleware_arg* arg){ bzero(buffer, MAX_BUF_LEN); memcpy(buffer, &request.flags, sizeof(char)); memcpy(buffer+sizeof(char), &request.addr, sizeof(char)*INET_ADDRSTRLEN); - memcpy(buffer+sizeof(char)*(1+INET_ADDRSTRLEN), &request.port, sizeof(unsigned short)); + memcpy(buffer+sizeof(char)*(1+INET_ADDRSTRLEN), &request.port, sizeof(int)); /* 2. On envoie la réponse*/ len = sizeof(struct sockaddr_in); @@ -117,7 +117,7 @@ int multicastTerminal(struct middleware_arg* arg){ /* 1. On parse la requête */ memcpy(&request.flags, buffer, sizeof(char)); memcpy(&request.addr, buffer+sizeof(char), sizeof(char)*15); - memcpy(&request.port, buffer+sizeof(char)*16, sizeof(unsigned short)); + memcpy(&request.port, buffer+sizeof(char)*16, sizeof(int)); printf("{%s} received: bind_header{flag = %d; addr = '%s'; port = %d}\n", arg->entity, (int) request.flags, request.addr, request.port); /* (1) Création socket de communication (si demandé) @@ -169,7 +169,7 @@ int multicastTerminal(struct middleware_arg* arg){ bzero(buffer, MAX_BUF_LEN); memcpy(buffer, &request.flags, sizeof(char)); memcpy(buffer+sizeof(char), &request.addr, sizeof(char)*15); - memcpy(buffer+sizeof(char)*16, &request.port, sizeof(unsigned short)); + memcpy(buffer+sizeof(char)*16, &request.port, sizeof(int)); /* 2. On envoie la réponse*/ len = sizeof(struct sockaddr_in); diff --git a/plane/plane.c b/plane/plane.c index b751c4f..e0ca1e3 100644 --- a/plane/plane.c +++ b/plane/plane.c @@ -51,7 +51,7 @@ int open_communication(){ request.port = 0; memcpy(buffer+sizeof(char)*0, &request.flags, sizeof(char)); memcpy(buffer+sizeof(char)*1, &request.addr, sizeof(char)*INET_ADDRSTRLEN); - memcpy(buffer+sizeof(char)*(1+INET_ADDRSTRLEN), &request.port, sizeof(unsigned short)); + memcpy(buffer+sizeof(char)*(1+INET_ADDRSTRLEN), &request.port, sizeof(int)); /* 2. Envoi séquence */ if( sendto(mcast_socket, buffer, BINDHDR_LEN/sizeof(char) +1, 0, (struct sockaddr*) &udp, sizeof(struct sockaddr_in)) < 0 ){ @@ -82,7 +82,7 @@ int open_communication(){ memcpy(&request.addr, buffer, sizeof(char) ); memcpy(&request.addr, buffer+sizeof(char), sizeof(char)*INET_ADDRSTRLEN ); - memcpy(&request.port, buffer+sizeof(char)*(1+INET_ADDRSTRLEN), sizeof(unsigned short) ); + memcpy(&request.port, buffer+sizeof(char)*(1+INET_ADDRSTRLEN), sizeof(int) ); printf("bind_header{flags = %d; addr = %s; port = %d;}\n\n", request.flags, request.addr, request.port); diff --git a/plane/plane.h b/plane/plane.h index 7ea90b0..5f30108 100644 --- a/plane/plane.h +++ b/plane/plane.h @@ -49,7 +49,7 @@ int spd; }; - #define BINDHDR_LEN ( sizeof(char)*(1+INET_ADDRSTRLEN)+sizeof(unsigned short) ) + #define BINDHDR_LEN ( sizeof(char)*(1+INET_ADDRSTRLEN)+sizeof(int) ) #define BINDHEAD_CTL 0x01 // is command terminal (else: view terminal) #define BINDHEAD_SCK 0x02 // ask for com socket #define BINDHEAD_TCP 0x04 // ask TCP instead of UDP @@ -57,7 +57,7 @@ struct bind_header{ char flags; char addr[INET_ADDRSTRLEN]; - unsigned short port; + int port; }; #endif \ No newline at end of file