64 lines
1.3 KiB
C
64 lines
1.3 KiB
C
#ifndef FACILITIES_DENM_H
|
|
#define FACILITIES_DENM_H
|
|
|
|
#include <stdint.h>
|
|
#include <denmv2/DENM.h>
|
|
#include <pthread.h>
|
|
#include <stdbool.h>
|
|
|
|
enum EVENT_STATE {
|
|
EVENT_ACTIVE,
|
|
EVENT_CANCELLED,
|
|
EVENT_NEGATED
|
|
};
|
|
|
|
typedef struct event {
|
|
DENM_t *denm;
|
|
uint32_t station_id;
|
|
uint32_t sn;
|
|
uint64_t detection_time;
|
|
uint64_t reference_time;
|
|
uint64_t expiration_time;
|
|
uint8_t cause;
|
|
uint8_t subcause;
|
|
uint32_t latitude;
|
|
uint32_t longitude;
|
|
bool enabled;
|
|
enum EVENT_STATE state;
|
|
} event_t;
|
|
|
|
typedef struct den {
|
|
event_t ** events;
|
|
uint32_t sn;
|
|
uint16_t no_stored_events;
|
|
uint16_t no_active_events;
|
|
uint16_t no_cancelled_events;
|
|
uint16_t no_negated_events;
|
|
uint16_t no_max_events;
|
|
pthread_mutex_t lock;
|
|
} den_t;
|
|
|
|
enum EVENT_CHECK_RESULT {
|
|
EVENT_NEW,
|
|
EVENT_INVALID,
|
|
EVENT_PASSED,
|
|
EVENT_CANCELLATION,
|
|
EVENT_NEGATION,
|
|
EVENT_UPDATE,
|
|
EVENT_REPEATED,
|
|
EVENT_NUMBER_EXCEEDED
|
|
};
|
|
|
|
/**
|
|
* Evaluate a DENM event.
|
|
* Does all the checks to a DENM and adds it to the database. *Don't* free the DENM struct after calling this function
|
|
* @param den the DEN service struct
|
|
* @param denm the DENM to evaluate
|
|
* @return 0 if event OK, 1 if event NOK
|
|
*/
|
|
int event_manage(den_t *den, DENM_t *denm);
|
|
|
|
void* den_service(void *fc);
|
|
|
|
#endif
|