Use security
This commit is contained in:
parent
eb89fea1f1
commit
cf97d7e00d
|
|
@ -255,6 +255,11 @@ void *ca_service(void *fc) {
|
||||||
|
|
||||||
bdr->data.buf = malloc(256);
|
bdr->data.buf = malloc(256);
|
||||||
|
|
||||||
|
if (facilities->use_security) {
|
||||||
|
bdr->gnSecurityProfile = malloc(sizeof(long));
|
||||||
|
*bdr->gnSecurityProfile = 1;
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t bdr_oer[256];
|
uint8_t bdr_oer[256];
|
||||||
bdr_oer[0] = 4; // Facilities
|
bdr_oer[0] = 4; // Facilities
|
||||||
while (!facilities->exit) {
|
while (!facilities->exit) {
|
||||||
|
|
|
||||||
28
src/config.c
28
src/config.c
|
|
@ -100,7 +100,7 @@ int itss_config(void* facilities_s, char* config_file) {
|
||||||
// Values
|
// Values
|
||||||
// General
|
// General
|
||||||
char *itss_type = NULL;
|
char *itss_type = NULL;
|
||||||
rv = extract_val_string(&itss_type, general, "itss-type");
|
rv += extract_val_string(&itss_type, general, "itss-type");
|
||||||
if (strcmp("obu", itss_type) == 0) {
|
if (strcmp("obu", itss_type) == 0) {
|
||||||
facilities->station_type = 5;
|
facilities->station_type = 5;
|
||||||
} else if (strcmp("rsu", itss_type) == 0) {
|
} else if (strcmp("rsu", itss_type) == 0) {
|
||||||
|
|
@ -111,56 +111,60 @@ int itss_config(void* facilities_s, char* config_file) {
|
||||||
}
|
}
|
||||||
free(itss_type);
|
free(itss_type);
|
||||||
|
|
||||||
|
int use_security = 1;
|
||||||
|
rv += extract_val_bool(&use_security, security, "use-security");
|
||||||
|
facilities->use_security = use_security;
|
||||||
|
|
||||||
int station_id_random = 1;
|
int station_id_random = 1;
|
||||||
rv = extract_val_bool(&station_id_random, security, "id-random");
|
rv += extract_val_bool(&station_id_random, security, "id-random");
|
||||||
facilities->id_random = station_id_random;
|
facilities->id_random = station_id_random;
|
||||||
if (station_id_random) {
|
if (station_id_random) {
|
||||||
srand(time(NULL));
|
srand(time(NULL));
|
||||||
facilities->station_id = rand();
|
facilities->station_id = rand();
|
||||||
} else {
|
} else {
|
||||||
int64_t station_id_number;
|
int64_t station_id_number;
|
||||||
rv = extract_val_int(&station_id_number, security, "station-id");
|
rv += extract_val_int(&station_id_number, security, "station-id");
|
||||||
facilities->station_id = station_id_number;
|
facilities->station_id = station_id_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
// DENM
|
// DENM
|
||||||
int64_t denm_default_event_duration;
|
int64_t denm_default_event_duration;
|
||||||
rv = extract_val_int(&denm_default_event_duration, denm, "default-event-duration");
|
rv += extract_val_int(&denm_default_event_duration, denm, "default-event-duration");
|
||||||
facilities->den->default_event_duration = denm_default_event_duration;
|
facilities->den->default_event_duration = denm_default_event_duration;
|
||||||
|
|
||||||
int64_t denm_nmax_active_events;
|
int64_t denm_nmax_active_events;
|
||||||
rv = extract_val_int(&denm_nmax_active_events, denm, "nmax-active-events");
|
rv += extract_val_int(&denm_nmax_active_events, denm, "nmax-active-events");
|
||||||
facilities->den->n_max_events = denm_nmax_active_events;
|
facilities->den->n_max_events = denm_nmax_active_events;
|
||||||
|
|
||||||
// CAM
|
// CAM
|
||||||
int64_t obu_cam_period_min;
|
int64_t obu_cam_period_min;
|
||||||
rv = extract_val_int(&obu_cam_period_min, cam, "obu-period-min");
|
rv += extract_val_int(&obu_cam_period_min, cam, "obu-period-min");
|
||||||
facilities->lightship->vehicle_gen_min = obu_cam_period_min;
|
facilities->lightship->vehicle_gen_min = obu_cam_period_min;
|
||||||
|
|
||||||
int64_t obu_cam_period_max;
|
int64_t obu_cam_period_max;
|
||||||
rv = extract_val_int(&obu_cam_period_max, cam, "obu-period-max");
|
rv += extract_val_int(&obu_cam_period_max, cam, "obu-period-max");
|
||||||
facilities->lightship->vehicle_gen_max = obu_cam_period_max;
|
facilities->lightship->vehicle_gen_max = obu_cam_period_max;
|
||||||
|
|
||||||
int64_t rsu_cam_period_min;
|
int64_t rsu_cam_period_min;
|
||||||
rv = extract_val_int(&rsu_cam_period_min, cam, "rsu-period-min");
|
rv += extract_val_int(&rsu_cam_period_min, cam, "rsu-period-min");
|
||||||
facilities->lightship->rsu_gen_min = rsu_cam_period_min;
|
facilities->lightship->rsu_gen_min = rsu_cam_period_min;
|
||||||
|
|
||||||
int64_t rsu_vehicle_permanence;
|
int64_t rsu_vehicle_permanence;
|
||||||
rv = extract_val_int(&rsu_vehicle_permanence, cam, "rsu-vehicle-permanence");
|
rv += extract_val_int(&rsu_vehicle_permanence, cam, "rsu-vehicle-permanence");
|
||||||
facilities->lightship->rsu_vehicle_permanence = rsu_vehicle_permanence;
|
facilities->lightship->rsu_vehicle_permanence = rsu_vehicle_permanence;
|
||||||
|
|
||||||
// IVIM
|
// IVIM
|
||||||
int64_t nmax_active_services;
|
int64_t nmax_active_services;
|
||||||
rv = extract_val_int(&nmax_active_services, ivim, "nmax-active-services");
|
rv += extract_val_int(&nmax_active_services, ivim, "nmax-active-services");
|
||||||
facilities->infrastructure->n_max_services = nmax_active_services;
|
facilities->infrastructure->n_max_services = nmax_active_services;
|
||||||
|
|
||||||
int64_t replay_interval;
|
int64_t replay_interval;
|
||||||
rv = extract_val_int(&replay_interval, ivim, "replay-interval");
|
rv += extract_val_int(&replay_interval, ivim, "replay-interval");
|
||||||
facilities->infrastructure->replay_interval = replay_interval;
|
facilities->infrastructure->replay_interval = replay_interval;
|
||||||
|
|
||||||
// Replay
|
// Replay
|
||||||
int replay_active = 1;
|
int replay_active = 1;
|
||||||
rv = extract_val_bool(&replay_active, replay, "activate");
|
rv += extract_val_bool(&replay_active, replay, "activate");
|
||||||
facilities->replay = replay_active;
|
facilities->replay = replay_active;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -143,7 +143,7 @@ static int facilities_request(facilities_t *facilities, void* responder, uint8_t
|
||||||
|
|
||||||
FacilitiesDataRequest_t *fdreq = calloc(1, sizeof(FacilitiesDataRequest_t));
|
FacilitiesDataRequest_t *fdreq = calloc(1, sizeof(FacilitiesDataRequest_t));
|
||||||
FacilitiesDataResult_t *fdres = calloc(1, sizeof(FacilitiesDataResult_t));
|
FacilitiesDataResult_t *fdres = calloc(1, sizeof(FacilitiesDataResult_t));
|
||||||
BTPDataRequest_t *bdr = calloc(1, sizeof(BTPDataRequest_t));
|
BTPDataRequest_t *bdr = calloc(1, sizeof(BTPDataRequest_t));
|
||||||
|
|
||||||
asn_dec_rval_t dec = oer_decode(NULL, &asn_DEF_FacilitiesDataRequest, (void**) &fdreq, msg, msg_len);
|
asn_dec_rval_t dec = oer_decode(NULL, &asn_DEF_FacilitiesDataRequest, (void**) &fdreq, msg, msg_len);
|
||||||
if (dec.code) {
|
if (dec.code) {
|
||||||
|
|
@ -316,6 +316,11 @@ static int facilities_request(facilities_t *facilities, void* responder, uint8_t
|
||||||
*bdr->gnIsUpdate = 1;
|
*bdr->gnIsUpdate = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (facilities->use_security) {
|
||||||
|
bdr->gnSecurityProfile = malloc(sizeof(long));
|
||||||
|
*bdr->gnSecurityProfile = 1;
|
||||||
|
}
|
||||||
|
|
||||||
// Encode ITS message into OER
|
// Encode ITS message into OER
|
||||||
uint8_t bdr_oer[2048];
|
uint8_t bdr_oer[2048];
|
||||||
bdr_oer[0] = 4; // [facilities] service id
|
bdr_oer[0] = 4; // [facilities] service id
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ typedef struct facilities {
|
||||||
infrastructure_t* infrastructure;
|
infrastructure_t* infrastructure;
|
||||||
|
|
||||||
int station_type;
|
int station_type;
|
||||||
|
bool use_security;
|
||||||
bool replay;
|
bool replay;
|
||||||
|
|
||||||
pthread_mutex_t lock;
|
pthread_mutex_t lock;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue