added headers
This commit is contained in:
parent
726ab7b4e3
commit
02989312d1
|
@ -1,3 +1,12 @@
|
||||||
|
/**************************
|
||||||
|
* Central-Manager *
|
||||||
|
***************************
|
||||||
|
* Designed & Developed by *
|
||||||
|
* Adrien Marquès *
|
||||||
|
* <xdrm-brackets> *
|
||||||
|
***************************
|
||||||
|
* doowap31@gmail.com *
|
||||||
|
**************************/
|
||||||
#include "central-manager.h"
|
#include "central-manager.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -5,7 +14,7 @@
|
||||||
* @argv : {0:program name}
|
* @argv : {0:program name}
|
||||||
*
|
*
|
||||||
* @history
|
* @history
|
||||||
* [0] Initialisation des variables globales
|
* [0] Initialisation des variables
|
||||||
* [1] Lancement des THREADS d'écoute
|
* [1] Lancement des THREADS d'écoute
|
||||||
* 1. On démarre le SERVEUR TCP d'écoute globale
|
* 1. On démarre le SERVEUR TCP d'écoute globale
|
||||||
* 2. On démarre le SERVEUR UDP d'écoute globale
|
* 2. On démarre le SERVEUR UDP d'écoute globale
|
||||||
|
@ -21,18 +30,19 @@ int main(int argc, char* argv[]){
|
||||||
printf("** [parent]{child}[subchild] Description\n\n\n");
|
printf("** [parent]{child}[subchild] Description\n\n\n");
|
||||||
printf("**** Execution tree\n");
|
printf("**** Execution tree\n");
|
||||||
|
|
||||||
/* [0] Initialisation des variables globales
|
/* [0] Initialisation des variables
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
|
/* 1. Variables globales */
|
||||||
sgca_data = (struct plane*) malloc( sizeof(struct plane) );
|
sgca_data = (struct plane*) malloc( sizeof(struct plane) );
|
||||||
sgca_update = (struct plane*) malloc( sizeof(struct plane) );
|
sgca_update = (struct plane*) malloc( sizeof(struct plane) );
|
||||||
sgca_index.data = 0;
|
sgca_index.data = 0;
|
||||||
sgca_index.update = 0;
|
sgca_index.update = 0;
|
||||||
|
|
||||||
/* Variables locales */
|
/* 2. Variables locales */
|
||||||
struct listn_thrd_arg tcp_listn_arg = { SERV_HOST, TCP_LIST, &managePlane };
|
struct listn_thrd_arg tcp_listn_arg = { SERV_HOST, TCP_LIST, &managePlane };
|
||||||
struct listn_thrd_arg udp_mcast_arg = { MCST_HOST, UDP_MCST, NULL };
|
struct listn_thrd_arg udp_mcast_arg = { MCST_HOST, UDP_MCST, &initPlane };
|
||||||
struct listn_thrd_arg udp_vterm_arg = { MCST_VTER, UDP_VTER, &manageTerminal };
|
struct listn_thrd_arg udp_vterm_arg = { MCST_VTER, UDP_VTER, &manageViewTerm };
|
||||||
struct listn_thrd_arg udp_cterm_arg = { MCST_CTER, UDP_CTER, &manageTerminal };
|
struct listn_thrd_arg udp_cterm_arg = { MCST_CTER, UDP_CTER, &manageCtrlTerm };
|
||||||
|
|
||||||
|
|
||||||
/* [1] Lancement des THREADS d'écoute
|
/* [1] Lancement des THREADS d'écoute
|
||||||
|
@ -43,7 +53,7 @@ int main(int argc, char* argv[]){
|
||||||
|
|
||||||
/* (2) Ecoute UDP multicast */
|
/* (2) Ecoute UDP multicast */
|
||||||
pthread_create(&listenManagers[1], NULL, LISTEN_UDP, (void*) &udp_mcast_arg);
|
pthread_create(&listenManagers[1], NULL, LISTEN_UDP, (void*) &udp_mcast_arg);
|
||||||
if( DEBUGMOD&THR ) printf("{udp_mcast} démarré\n\n");
|
if( DEBUGMOD&THR ) printf("{udp_mcast} démarré\n");
|
||||||
|
|
||||||
/* (3) Ecoute UDP viewTerm */
|
/* (3) Ecoute UDP viewTerm */
|
||||||
pthread_create(&listenManagers[2], NULL, LISTEN_UDP, (void*) &udp_vterm_arg);
|
pthread_create(&listenManagers[2], NULL, LISTEN_UDP, (void*) &udp_vterm_arg);
|
||||||
|
@ -208,7 +218,8 @@ void* LISTEN_UDP(void* THREADABLE_ARG){
|
||||||
char entity[9+1];
|
char entity[9+1];
|
||||||
|
|
||||||
if( strcmp(arg->addr, MCST_VTER) == 0 && arg->port == UDP_VTER ) strcpy(entity, "udp_vterm");
|
if( strcmp(arg->addr, MCST_VTER) == 0 && arg->port == UDP_VTER ) strcpy(entity, "udp_vterm");
|
||||||
else strcpy(entity, "udp_cterm");
|
if( strcmp(arg->addr, MCST_CTER) == 0 && arg->port == UDP_CTER ) strcpy(entity, "udp_cterm");
|
||||||
|
if( strcmp(arg->addr, MCST_HOST) == 0 && arg->port == UDP_MCST ) strcpy(entity, "udp_mcast");
|
||||||
|
|
||||||
// retour de @DROP_UDP_SERVER
|
// retour de @DROP_UDP_SERVER
|
||||||
int SOCKET;
|
int SOCKET;
|
||||||
|
@ -360,6 +371,17 @@ void* LISTEN_UDP(void* THREADABLE_ARG){
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void* initPlane(){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Gestion d'une connexion PLANE
|
/* Gestion d'une connexion PLANE
|
||||||
*
|
*
|
||||||
* @THREADABLE_SOCKET<void*> SOCKET de la connexion client
|
* @THREADABLE_SOCKET<void*> SOCKET de la connexion client
|
||||||
|
@ -510,7 +532,89 @@ void* managePlane(void* THREADABLE_SOCKET){
|
||||||
* 3. On arrête le THREAD
|
* 3. On arrête le THREAD
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void* manageTerminal(void* THREADABLE_SOCKET){
|
void* manageViewTerm(void* THREADABLE_SOCKET){
|
||||||
|
|
||||||
|
/* [1] Initialisation des variables
|
||||||
|
=========================================================*/
|
||||||
|
int read; // compteur
|
||||||
|
struct sockaddr_in clientInfo;
|
||||||
|
socklen_t len;
|
||||||
|
int UDP_SOCKET = (intptr_t) THREADABLE_SOCKET; // Socket client
|
||||||
|
char request[MAX_BUF_LEN]; // Requête
|
||||||
|
// char response[MAX_BUF_LEN]; // Réponse
|
||||||
|
|
||||||
|
do{
|
||||||
|
|
||||||
|
printf("{udp_x-term}{udp_com} waiting for terminal request\n");
|
||||||
|
/* [2] Récupération de la requête
|
||||||
|
=========================================================*/
|
||||||
|
/* 1. On lit sur la socket */
|
||||||
|
len = sizeof(struct sockaddr_in);
|
||||||
|
read = recvfrom(UDP_SOCKET, request, MAX_BUF_LEN, 0, (struct sockaddr*) &clientInfo, &len);
|
||||||
|
|
||||||
|
/* 2. Si erreur reception */
|
||||||
|
if( DEBUGMOD&BUF ) printf("{udp_x-term}{udp_com} READ = %d\n", read);
|
||||||
|
|
||||||
|
if( read < 0 )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/* 3. On désérialise la requête*/
|
||||||
|
printf("{udp_x-term}{udp_com} TERMINAL Request(%d bytes) : '%s'\n", read, request);
|
||||||
|
|
||||||
|
/* [3] Gestion de la requête
|
||||||
|
=========================================================*/
|
||||||
|
|
||||||
|
|
||||||
|
/* [4] Envoi reponse
|
||||||
|
=========================================================*/
|
||||||
|
strcpy(request+strlen(request), "-bla\0");
|
||||||
|
send(UDP_SOCKET, request, strlen(request), 0);
|
||||||
|
|
||||||
|
|
||||||
|
}while( 0 );
|
||||||
|
|
||||||
|
/* [n] Arrêt du THREAD
|
||||||
|
============================================================================*/
|
||||||
|
/* 1. On récupère le rang dans les "managers" */
|
||||||
|
int i, index = -1;
|
||||||
|
for( i = 0 ; i < MAX_UDP_THR ; i++ )
|
||||||
|
if( UDPManagers[i] == pthread_self() ){ index = i; break; }
|
||||||
|
|
||||||
|
/* 2. On met à jour "activeManagers" */
|
||||||
|
if( index != -1 )
|
||||||
|
activeUDPManagers[index] = 0;
|
||||||
|
|
||||||
|
/* 3. On arrête le THREAD */
|
||||||
|
if( DEBUGMOD&THR ) printf("{udp_x-term}{udp_com}(%d) libéré\n", index);
|
||||||
|
pthread_exit(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Gestion d'une connexion TERMINAL
|
||||||
|
*
|
||||||
|
* @THREADABLE_SOCKET<void*> SOCKET de la connexion client
|
||||||
|
*
|
||||||
|
* @history
|
||||||
|
* [1] Initialisation des variables
|
||||||
|
* [2] Récupération de la requête
|
||||||
|
* [3] Traitement de la requête
|
||||||
|
* [4] Création de la réponse
|
||||||
|
* [5] Envoi de la réponse
|
||||||
|
* [6] On vide les buffers
|
||||||
|
* [7] Fermeture de la connection (SOCKET)
|
||||||
|
* [n] Arrêt du THREAD
|
||||||
|
* 1. On récupère le rang dans les "managers"
|
||||||
|
* 2. On met à jour "activeManagers"
|
||||||
|
* 3. On arrête le THREAD
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void* manageCtrlTerm(void* THREADABLE_SOCKET){
|
||||||
|
|
||||||
/* [1] Initialisation des variables
|
/* [1] Initialisation des variables
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
|
|
|
@ -1,3 +1,12 @@
|
||||||
|
/**************************
|
||||||
|
* Central-Manager *
|
||||||
|
***************************
|
||||||
|
* Designed & Developed by *
|
||||||
|
* Adrien Marquès *
|
||||||
|
* <xdrm-brackets> *
|
||||||
|
***************************
|
||||||
|
* doowap31@gmail.com *
|
||||||
|
**************************/
|
||||||
#include "lib/header.h"
|
#include "lib/header.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,9 +20,9 @@
|
||||||
void* LISTEN_TCP(void* THREADABLE_ARG);
|
void* LISTEN_TCP(void* THREADABLE_ARG);
|
||||||
void* LISTEN_UDP(void* THREADABLE_ARG);
|
void* LISTEN_UDP(void* THREADABLE_ARG);
|
||||||
void* managePlane(void* THREADABLE_SOCKET);
|
void* managePlane(void* THREADABLE_SOCKET);
|
||||||
void* manageTerminal(void* THREADABLE_SOCKET);
|
void* initPlane();
|
||||||
// void* manageViewTerm(void* THREADABLE_SOCKET);
|
void* manageViewTerm(void* THREADABLE_SOCKET);
|
||||||
// void* manageCtrlTerm(void* THREADABLE_SOCKET);
|
void* manageCtrlTerm(void* THREADABLE_SOCKET);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,15 @@
|
||||||
|
/**************************
|
||||||
|
* Data-Structures *
|
||||||
|
***************************
|
||||||
|
* Designed & Developed by *
|
||||||
|
* Adrien Marquès *
|
||||||
|
* <xdrm-brackets> *
|
||||||
|
***************************
|
||||||
|
* doowap31@gmail.com *
|
||||||
|
**************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef _DATA_H_
|
#ifndef _DATA_H_
|
||||||
#define _DATA_H_
|
#define _DATA_H_
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,13 @@
|
||||||
|
/**************************
|
||||||
|
* Debug Dependency *
|
||||||
|
***************************
|
||||||
|
* Designed & Developed by *
|
||||||
|
* Adrien Marquès *
|
||||||
|
* <xdrm-brackets> *
|
||||||
|
***************************
|
||||||
|
* doowap31@gmail.com *
|
||||||
|
**************************/
|
||||||
|
|
||||||
/* debug */
|
/* debug */
|
||||||
#define SOCKETS 0x01 // debug RESEAU
|
#define SOCKETS 0x01 // debug RESEAU
|
||||||
#define REVEALS 0x02 // debug EXPLICITATION des strings
|
#define REVEALS 0x02 // debug EXPLICITATION des strings
|
||||||
|
|
|
@ -1,3 +1,14 @@
|
||||||
|
/**************************
|
||||||
|
* Header Dependency *
|
||||||
|
***************************
|
||||||
|
* Designed & Developed by *
|
||||||
|
* Adrien Marquès *
|
||||||
|
* <xdrm-brackets> *
|
||||||
|
***************************
|
||||||
|
* doowap31@gmail.com *
|
||||||
|
**************************/
|
||||||
|
|
||||||
|
|
||||||
#ifndef _LIB_HEADER_H_
|
#ifndef _LIB_HEADER_H_
|
||||||
#define _LIB_HEADER_H_
|
#define _LIB_HEADER_H_
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,14 @@
|
||||||
|
/**************************
|
||||||
|
* TCP Server Dependency *
|
||||||
|
***************************
|
||||||
|
* Designed & Developed by *
|
||||||
|
* Adrien Marquès *
|
||||||
|
* <xdrm-brackets> *
|
||||||
|
***************************
|
||||||
|
* doowap31@gmail.com *
|
||||||
|
**************************/
|
||||||
|
|
||||||
|
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,14 @@
|
||||||
|
/**************************
|
||||||
|
* TCP Server Dependency *
|
||||||
|
***************************
|
||||||
|
* Designed & Developed by *
|
||||||
|
* Adrien Marquès *
|
||||||
|
* <xdrm-brackets> *
|
||||||
|
***************************
|
||||||
|
* doowap31@gmail.com *
|
||||||
|
**************************/
|
||||||
|
|
||||||
|
|
||||||
#ifndef _LIB_NETWORK_TCP_SERVER_H_
|
#ifndef _LIB_NETWORK_TCP_SERVER_H_
|
||||||
#define _LIB_NETWORK_TCP_SERVER_H_
|
#define _LIB_NETWORK_TCP_SERVER_H_
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,12 @@
|
||||||
|
/**************************
|
||||||
|
* UDP Server Dependency *
|
||||||
|
***************************
|
||||||
|
* Designed & Developed by *
|
||||||
|
* Adrien Marquès *
|
||||||
|
* <xdrm-brackets> *
|
||||||
|
***************************
|
||||||
|
* doowap31@gmail.com *
|
||||||
|
**************************/
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,14 @@
|
||||||
|
/**************************
|
||||||
|
* UDP Server Dependency *
|
||||||
|
***************************
|
||||||
|
* Designed & Developed by *
|
||||||
|
* Adrien Marquès *
|
||||||
|
* <xdrm-brackets> *
|
||||||
|
***************************
|
||||||
|
* doowap31@gmail.com *
|
||||||
|
**************************/
|
||||||
|
|
||||||
|
|
||||||
#ifndef _LIB_NETWORK_UDP_SERVER_H_
|
#ifndef _LIB_NETWORK_UDP_SERVER_H_
|
||||||
#define _LIB_NETWORK_UDP_SERVER_H_
|
#define _LIB_NETWORK_UDP_SERVER_H_
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue