Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
d11649e9b9
|
@ -23,5 +23,5 @@ all: boot
|
|||
|
||||
# cleans the compiled files
|
||||
clean:
|
||||
@find ./lib/network/**/*.o >/dev/null 2>&1 && rm ./lib/network/**/*.o || return 0;
|
||||
@find ./boot >/dev/null 2>&1 && rm ./boot || return 0;
|
||||
@rm ./lib/network/**/*.o;
|
||||
@rm ./boot;
|
||||
|
|
|
@ -35,7 +35,7 @@ all: boot
|
|||
|
||||
# cleans the compiled files
|
||||
clean:
|
||||
@find lib/network/*.o >/dev/null 2>&1 && rm lib/network/*.o || return 0;
|
||||
@find lib/network/**/*.o >/dev/null 2>&1 && rm lib/network/**/*.o || return 0;
|
||||
@find lib/local/*.o >/dev/null 2>&1 && rm lib/local/*.o || return 0;
|
||||
@find boot >/dev/null 2>&1 && rm boot || return 0;
|
||||
@rm lib/network/*.o;
|
||||
@rm lib/network/**/*.o;
|
||||
@rm lib/local/*.o;
|
||||
@rm boot;
|
||||
|
|
|
@ -215,9 +215,11 @@ void* manageViewTerm(void* THREADABLE_ARGS){
|
|||
int sent; // compteurs d'envoi
|
||||
int i, index = -1; // Compteurs globaux
|
||||
char* buffer = malloc(1); // Buffer d'envoi
|
||||
int SOCKET;
|
||||
|
||||
/* 2. On récupère les arguments */
|
||||
struct handler_arg* arg = THREADABLE_ARGS;
|
||||
memcpy(&SOCKET, &arg->socket, sizeof(int));
|
||||
|
||||
/* 3. On récupère le rang dans les "managers" */
|
||||
for( i = 0 ; i < MAX_UDP_THR ; i++ )
|
||||
|
@ -228,7 +230,7 @@ void* manageViewTerm(void* THREADABLE_ARGS){
|
|||
|
||||
/* 4. Attente d'un client */
|
||||
len = sizeof(struct sockaddr_in);
|
||||
if( recvfrom(arg->socket, buffer, MAX_BUF_LEN*sizeof(char), 0, (struct sockaddr*) &clientInfo, &len) < 0 ){
|
||||
if( recvfrom(SOCKET, buffer, MAX_BUF_LEN*sizeof(char), 0, (struct sockaddr*) &clientInfo, &len) < 0 ){
|
||||
printf("{udp_vterm}{com}(%d) No terminal detected, exiting\n", index);
|
||||
loop = 0;
|
||||
}
|
||||
|
@ -248,7 +250,7 @@ void* manageViewTerm(void* THREADABLE_ARGS){
|
|||
=========================================================*/
|
||||
/* 2. Envoi */
|
||||
len = sizeof(struct sockaddr_in);
|
||||
sent = sendto(arg->socket, buffer, buflen + 1, 0, (struct sockaddr*) &clientInfo, len);
|
||||
sent = sendto(SOCKET, buffer, buflen + 1, 0, (struct sockaddr*) &clientInfo, len);
|
||||
|
||||
/* 3. Gestion erreur */
|
||||
if( sent <= 0 ){
|
||||
|
@ -261,7 +263,7 @@ void* manageViewTerm(void* THREADABLE_ARGS){
|
|||
=========================================================*/
|
||||
/* 1. Réception feedback (0x10) */
|
||||
len = sizeof(struct sockaddr_in);
|
||||
sent = recvfrom(arg->socket, buffer, 1, 0, (struct sockaddr*) &clientInfo, &len);
|
||||
sent = recvfrom(SOCKET, buffer, 1, 0, (struct sockaddr*) &clientInfo, &len);
|
||||
|
||||
/* 2. Gestion erreur (erreur ou mauvais feedback != 0x10) */
|
||||
if( sent <= 0 || buffer[0] != TERMREQ_OFF ){
|
||||
|
@ -284,7 +286,7 @@ void* manageViewTerm(void* THREADABLE_ARGS){
|
|||
arg->activeUDPManagers[index] = 0;
|
||||
|
||||
/* 2. On ferme la socket + libère la mémoire */
|
||||
close(arg->socket);
|
||||
close(SOCKET);
|
||||
free(buffer);
|
||||
|
||||
|
||||
|
@ -331,10 +333,13 @@ void* manageCtrlTerm(void* THREADABLE_ARGS){
|
|||
char* dataBuffer = malloc(1);
|
||||
struct term_req request; // Requête
|
||||
char flags;
|
||||
int SOCKET;
|
||||
struct in_addr* ip = malloc(sizeof(struct in_addr));
|
||||
|
||||
|
||||
/* 2. On récupère les arguments */
|
||||
struct handler_arg* arg = THREADABLE_ARGS;
|
||||
memcpy(&SOCKET, &arg->socket, sizeof(int));
|
||||
|
||||
/* 3. On récupère le rang dans les "managers" */
|
||||
for( i = 0 ; i < MAX_UDP_THR ; i++ )
|
||||
|
@ -344,11 +349,16 @@ void* manageCtrlTerm(void* THREADABLE_ARGS){
|
|||
|
||||
/* 4. Attente d'un client */
|
||||
len = sizeof(struct sockaddr_in);
|
||||
if( recvfrom(arg->socket, buffer, MAX_BUF_LEN*sizeof(char), 0, (struct sockaddr*) &clientInfo, &len) < 0 ){
|
||||
if( recvfrom(SOCKET, buffer, MAX_BUF_LEN*sizeof(char), 0, (struct sockaddr*) &clientInfo, &len) < 0 ){
|
||||
printf("{udp_cterm}{com}(%d) No terminal detected, exiting\n", index);
|
||||
loop = 0;
|
||||
}else
|
||||
printf("{udp_cterm}{com}(%d) Terminal connected\n", index);
|
||||
}else{
|
||||
ip->s_addr = clientInfo.sin_addr.s_addr;
|
||||
printf("{udp_cterm}{com}(%d) Terminal connected from %s:%d\n", index, inet_ntoa(*ip), ntohs(clientInfo.sin_port));
|
||||
}
|
||||
|
||||
free(ip);
|
||||
|
||||
|
||||
|
||||
while( loop ){
|
||||
|
@ -360,14 +370,14 @@ void* manageCtrlTerm(void* THREADABLE_ARGS){
|
|||
/* 1. On lit sur la socket */
|
||||
len = sizeof(struct sockaddr_in);
|
||||
bzero(buffer, sizeof(char)*MAX_BUF_LEN);
|
||||
count = recvfrom(arg->socket, buffer, MAX_BUF_LEN, 0, (struct sockaddr*) &clientInfo, &len);
|
||||
count = recvfrom(SOCKET, buffer, MAX_BUF_LEN, 0, (struct sockaddr*) &clientInfo, &len);
|
||||
|
||||
/* 2. Si erreur reception */
|
||||
if( count <= 0 ) // because of timeout or error
|
||||
break;
|
||||
|
||||
if( count < TERMREQ_LEN ){
|
||||
send(arg->socket, "\0\0", sizeof(char)*2, 0);
|
||||
send(SOCKET, "\0\0", sizeof(char)*2, 0);
|
||||
if( DEBUGMOD&BUF ) printf("{udp_cterm}{com}(%d) Error receiving request\n", index);
|
||||
continue;
|
||||
}
|
||||
|
@ -390,7 +400,7 @@ void* manageCtrlTerm(void* THREADABLE_ARGS){
|
|||
update = ( request.flags&TERMREQ_ALT || request.flags&TERMREQ_CAP || request.flags&TERMREQ_SPD );
|
||||
fbk = request.flags&TERMREQ_FBK;
|
||||
if( !( update || fbk ) ){
|
||||
send(arg->socket, "\x00\0", sizeof(char)*2, 0);
|
||||
send(SOCKET, "\x00\0", sizeof(char)*2, 0);
|
||||
if( request.flags != 0 )
|
||||
printf("{udp_cterm}{com}(%d) Invalid flags\n", index);
|
||||
continue;
|
||||
|
@ -500,7 +510,7 @@ void* manageCtrlTerm(void* THREADABLE_ARGS){
|
|||
=========================================================*/
|
||||
printf("{udp_cterm}{com}(%d) Sending response { flags: %d; n: %d }\n", index, dataBuffer[0], dataBuffer[1]);
|
||||
len = sizeof(struct sockaddr_in);
|
||||
if( sendto(arg->socket, dataBuffer, dataLen, 0, (struct sockaddr*) &clientInfo, len) < 0 )
|
||||
if( sendto(SOCKET, dataBuffer, dataLen, 0, (struct sockaddr*) &clientInfo, len) < 0 )
|
||||
printf("{udp_cterm}{com}(%d) Cannot answer to terminal\n", index);
|
||||
|
||||
|
||||
|
@ -514,7 +524,7 @@ void* manageCtrlTerm(void* THREADABLE_ARGS){
|
|||
arg->activeUDPManagers[index] = 0;
|
||||
|
||||
/* 2. On ferme la socket */
|
||||
close(arg->socket);
|
||||
close(SOCKET);
|
||||
free(dataBuffer);
|
||||
|
||||
/* 3. On arrête le THREAD */
|
||||
|
|
Loading…
Reference in New Issue