From 29393a07476158511624297846fa1a2525b49140 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Wed, 3 May 2017 17:01:02 +0200 Subject: [PATCH] [update] Sending flag 0x10 when plane update request and offline/unreachable --- central-manager/lib/local/handler.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/central-manager/lib/local/handler.c b/central-manager/lib/local/handler.c index 313e327..a01a556 100644 --- a/central-manager/lib/local/handler.c +++ b/central-manager/lib/local/handler.c @@ -382,7 +382,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, "\0\0", sizeof(char)*2, 0); + send(arg->socket, "\x00\0", sizeof(char)*2, 0); printf("{udp_cterm}{com}(%d) Invalid flag, passing\n", index); continue; } @@ -398,7 +398,7 @@ void* manageCtrlTerm(void* THREADABLE_ARGS){ for( i = 0 ; i < arg->sgca->n ; i++ ){ /* 2. Si l'avion existe et online -> on passe à la suite */ - if( strcmp(arg->sgca->unit[i].data.code, request.update.code) == 0 && arg->sgca->unit[i].data.online ){ + if( strcmp(arg->sgca->unit[i].data.code, request.update.code) == 0 && arg->sgca->unit[i].data.online == 1 ){ pindex = i; break; } @@ -410,6 +410,7 @@ void* manageCtrlTerm(void* THREADABLE_ARGS){ /* 3. Si on a pas trouvé -> on quitte l'udpdate */ if( pindex <= -1 || arg->sgca->unit[pindex].socket <= -1 ){ printf("{udp_cterm}{com}(%d) Plane unknown or unreachable, passing\n", index); + request.flags = 0x10; break; } @@ -428,6 +429,7 @@ void* manageCtrlTerm(void* THREADABLE_ARGS){ /* 3. On envoie la requête à l'avion */ if( send(arg->sgca->unit[pindex].socket, buffer, count/sizeof(char), 0) <= 0 ){ printf("{udp_cterm}{com}(%d) Cannot send request to plane\n", index); + request.flags = 0x10; break; } @@ -442,6 +444,7 @@ void* manageCtrlTerm(void* THREADABLE_ARGS){ if( flags == 0x10 ){ printf("{udp_cterm}{com}(%d) Cannot get response from plane %d (%d)\n", index, count, (int) PLANE_LEN); + request.flags = 0x10; break; }