/************************** * Header Dependency * *************************** * Designed & Developed by * * Adrien Marquès * * * *************************** * doowap31@gmail.com * **************************/ #ifndef _LIB_HEADER_H_ #define _LIB_HEADER_H_ /* global */ #include #include #include #include #include #include #include /* sys */ #include #include /* socket */ #include // close #include #include // getaddrinfo, getnameinfo #include #include "debug.h" #include "data.h" /* vars */ #define MCST_HOST "224.0.0.1" // adresse groupe multicast UDP -> plane #define MCST_VTER "224.0.0.2" // adresse groupe multicast UDP -> viewTerm #define MCST_CTER "224.0.0.3" // adresse groupe multicast UDP -> ctrlTerm #define UDP_MCST 4444 // multicast UDP port for PLANES #define TCP_LIST 0x504c // TCP plane command (PL = 8076) #define UDP_VTER 4445 // viewTerm listener #define UDP_CTER 4446 // ctrlTerm listener #define MAX_BUF_LEN 512 #define MAX_TCP_THR 10 #define MAX_UDP_THR 10 #define maxHostLen 64 #define maxPortLen 6 #define CTRL_TIMEOUT 10 // 10sec timeout (pour ctrlTerm) #define SOCK_TIMEOUT 4 // 4sec timeout (1+ temps refresh plane) #define PUBL_TIMEOUT 2 // 2sec entre chaque publication sur multicast UDP (pour avions) struct context_unit{ int socket; // socket associée à un avion struct plane data; // données d'un avion char thrId; // TCP thread index char flags; // persistent flags }; struct context{ unsigned int n; // nombre d'avions struct context_unit* unit; // les données des avions }; struct middleware_arg{ int listenSock; // socket source int* comSock; // socket destination char entity[10]; // entity for log }; struct handler_arg{ pthread_t* TCPManagers; pthread_t* UDPManagers; int* activeTCPManagers; int* activeUDPManagers; int socket; struct context* sgca; }; struct listen_arg{ in_addr_t addr; // socket address const unsigned short port; // socket port int (*middleware)(struct middleware_arg*); // middleware function void* (*handler)(void*); // management function (thread) }; #endif