2017-04-09 16:56:11 +00:00
|
|
|
/**************************
|
|
|
|
* Header Dependency *
|
|
|
|
***************************
|
|
|
|
* Designed & Developed by *
|
|
|
|
* Adrien Marquès *
|
|
|
|
* <xdrm-brackets> *
|
|
|
|
***************************
|
|
|
|
* doowap31@gmail.com *
|
|
|
|
**************************/
|
|
|
|
|
|
|
|
|
2017-04-01 15:01:36 +00:00
|
|
|
#ifndef _LIB_HEADER_H_
|
|
|
|
#define _LIB_HEADER_H_
|
|
|
|
|
|
|
|
|
|
|
|
/* global */
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <pthread.h>
|
|
|
|
#include <stdint.h>
|
2017-04-08 16:20:17 +00:00
|
|
|
#include <errno.h>
|
2017-04-01 15:01:36 +00:00
|
|
|
|
|
|
|
/* sys */
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
|
|
|
|
|
|
|
|
/* socket */
|
|
|
|
#include <unistd.h> // close
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <netdb.h> // getaddrinfo, getnameinfo
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
|
|
|
|
#include "debug.h"
|
2017-04-06 11:36:51 +00:00
|
|
|
#include "data.h"
|
2017-04-01 15:01:36 +00:00
|
|
|
|
|
|
|
/* vars */
|
2017-04-09 14:06:31 +00:00
|
|
|
#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
|
2017-04-08 17:25:44 +00:00
|
|
|
#define UDP_MCST 4444 // multicast UDP port for PLANES
|
|
|
|
#define TCP_LIST 0x504c // TCP plane command (PL = 8076)
|
2017-04-07 16:14:21 +00:00
|
|
|
|
2017-04-08 17:25:44 +00:00
|
|
|
#define UDP_VTER 4445 // viewTerm listener
|
|
|
|
#define UDP_CTER 4446 // ctrlTerm listener
|
2017-04-01 15:01:36 +00:00
|
|
|
|
|
|
|
#define MAX_BUF_LEN 512
|
|
|
|
#define MAX_TCP_THR 10
|
|
|
|
#define MAX_UDP_THR 10
|
|
|
|
#define maxHostLen 64
|
|
|
|
#define maxPortLen 6
|
|
|
|
|
2017-04-28 12:54:02 +00:00
|
|
|
#define SOCK_TIMEOUT 4 // 4sec timeout (1+ temps refresh plane)
|
2017-04-18 18:06:14 +00:00
|
|
|
#define PUBL_TIMEOUT 2 // 2sec entre chaque publication sur multicast UDP (pour avions)
|
2017-04-09 16:41:44 +00:00
|
|
|
|
2017-04-09 17:33:27 +00:00
|
|
|
|
2017-05-03 09:58:41 +00:00
|
|
|
struct context_unit{
|
|
|
|
int socket; // socket associée à un avion
|
|
|
|
struct plane data; // données d'un avion
|
|
|
|
};
|
|
|
|
|
2017-04-09 17:33:27 +00:00
|
|
|
struct context{
|
2017-05-03 09:58:41 +00:00
|
|
|
unsigned int n; // nombre d'avions
|
|
|
|
struct context_unit* unit; // les données des avions
|
2017-04-09 17:33:27 +00:00
|
|
|
};
|
|
|
|
|
2017-04-11 17:12:34 +00:00
|
|
|
struct middleware_arg{
|
|
|
|
int listenSock; // socket source
|
|
|
|
int* comSock; // socket destination
|
|
|
|
char entity[10]; // entity for log
|
2017-04-09 17:33:27 +00:00
|
|
|
};
|
|
|
|
|
2017-04-11 17:12:34 +00:00
|
|
|
struct handler_arg{
|
2017-04-09 17:33:27 +00:00
|
|
|
pthread_t* managers;
|
|
|
|
int* activeManagers;
|
|
|
|
int socket;
|
|
|
|
struct context* sgca;
|
|
|
|
};
|
|
|
|
|
2017-04-11 17:12:34 +00:00
|
|
|
struct listen_arg{
|
2017-04-26 12:25:05 +00:00
|
|
|
in_addr_t addr; // socket address
|
2017-04-13 18:01:56 +00:00
|
|
|
const unsigned short port; // socket port
|
2017-04-11 17:12:34 +00:00
|
|
|
int (*middleware)(struct middleware_arg*); // middleware function
|
|
|
|
void* (*handler)(void*); // management function (thread)
|
|
|
|
};
|
|
|
|
|
2017-04-01 15:01:36 +00:00
|
|
|
#endif
|