76 lines
1.6 KiB
C
76 lines
1.6 KiB
C
#ifndef FACILITIES_DENM_H
|
|
#define FACILITIES_DENM_H
|
|
|
|
#include <stdint.h>
|
|
#include <it2s-asn/denmv2/DENM.h>
|
|
#include <pthread.h>
|
|
#include <stdbool.h>
|
|
|
|
#include <it2s-tender/epv.h>
|
|
|
|
enum EVENT_STATE {
|
|
EVENT_ACTIVE,
|
|
EVENT_CANCELLED,
|
|
EVENT_NEGATED
|
|
};
|
|
|
|
typedef struct event {
|
|
uint64_t id;
|
|
DENM_t *denm;
|
|
uint32_t station_id;
|
|
uint32_t sn;
|
|
uint64_t detection_time;
|
|
uint64_t reference_time;
|
|
uint64_t expiration_time;
|
|
int32_t latitude;
|
|
int32_t longitude;
|
|
bool enabled;
|
|
enum EVENT_STATE state;
|
|
} event_t;
|
|
|
|
typedef struct den {
|
|
event_t ** events;
|
|
uint32_t sn;
|
|
uint16_t n_stored_events;
|
|
uint16_t n_active_events;
|
|
uint16_t n_cancelled_events;
|
|
uint16_t n_negated_events;
|
|
uint16_t n_max_events;
|
|
pthread_mutex_t lock;
|
|
} den_t;
|
|
|
|
enum EVENT_CHECK_R {
|
|
EVENT_NEW,
|
|
EVENT_INVALID,
|
|
EVENT_PASSED,
|
|
EVENT_CANCELLATION,
|
|
EVENT_NEGATION,
|
|
EVENT_UPDATE,
|
|
EVENT_REPEATED,
|
|
EVENT_NUMBER_EXCEEDED,
|
|
EVENT_BAD_PERMISSIONS
|
|
};
|
|
|
|
typedef struct cc_ssp_bm {
|
|
const char* cause_type;
|
|
const int cause_code;
|
|
const uint32_t bitmap_val;
|
|
} cc_ssp_bm_t;
|
|
|
|
|
|
/**
|
|
* 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
|
|
* @param id message intra ITS-S identitifier
|
|
* @param ssp permissions
|
|
* @return 0 if event OK, 1 if event NOK
|
|
*/
|
|
enum EVENT_CHECK_R event_manage(DENM_t* denm, uint64_t* id, uint8_t* ssp, uint32_t ssp_len);
|
|
|
|
int den_init();
|
|
void* den_service();
|
|
|
|
#endif
|