StationID change, gitlab CI
This commit is contained in:
parent
a5a320cf94
commit
e2e66d12fe
|
|
@ -0,0 +1,15 @@
|
||||||
|
image: archlinux
|
||||||
|
|
||||||
|
stages:
|
||||||
|
- deploy release
|
||||||
|
- deploy debug
|
||||||
|
|
||||||
|
deploy release:
|
||||||
|
stage: deploy release
|
||||||
|
script:
|
||||||
|
- curl http://192.168.94.221:3000/it2s-itss-facilities-git
|
||||||
|
|
||||||
|
deploy debug:
|
||||||
|
stage: deploy debug
|
||||||
|
script:
|
||||||
|
- curl http://192.168.94.221:3000/it2s-itss-facilities-debug-git
|
||||||
|
|
@ -10,6 +10,7 @@ ADD_EXECUTABLE(it2s-itss-facilities
|
||||||
TARGET_LINK_LIBRARIES(it2s-itss-facilities
|
TARGET_LINK_LIBRARIES(it2s-itss-facilities
|
||||||
-lit2s-asn-itss-facilities
|
-lit2s-asn-itss-facilities
|
||||||
-lit2s-asn-itss-transport
|
-lit2s-asn-itss-transport
|
||||||
|
-lit2s-asn-itss-security
|
||||||
-lzmq
|
-lzmq
|
||||||
-lit2s-gps
|
-lit2s-gps
|
||||||
-lpthread
|
-lpthread
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,9 @@ static int mk_cam(facilities_t* facilities, uint8_t *cam, uint32_t *cam_len) {
|
||||||
|
|
||||||
cam_tx->header.protocolVersion = 2;
|
cam_tx->header.protocolVersion = 2;
|
||||||
cam_tx->header.messageID = ItsPduHeader__messageID_cam;
|
cam_tx->header.messageID = ItsPduHeader__messageID_cam;
|
||||||
cam_tx->header.stationID = 0;
|
pthread_mutex_lock(&facilities->lock);
|
||||||
|
cam_tx->header.stationID = facilities->station_id;
|
||||||
|
pthread_mutex_unlock(&facilities->lock);
|
||||||
cam_tx->cam.camParameters.basicContainer.stationType = facilities->station_type;
|
cam_tx->cam.camParameters.basicContainer.stationType = facilities->station_type;
|
||||||
|
|
||||||
if (facilities->station_type != StationType_roadSideUnit) {
|
if (facilities->station_type != StationType_roadSideUnit) {
|
||||||
|
|
|
||||||
|
|
@ -86,10 +86,10 @@ int itss_config(void* facilities_s, char* config_file) {
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
||||||
// Tables
|
// Tables
|
||||||
toml_table_t *general, *general_station_id;
|
toml_table_t *general, *security;
|
||||||
|
|
||||||
if (0 == (general = toml_table_in(conf, "general"))) {syslog_err("[facilities] [config] failed locating [general] table"); return 1;}
|
if (0 == (general = toml_table_in(conf, "general"))) {syslog_err("[facilities] [config] failed locating [general] table"); return 1;}
|
||||||
if (0 == (general_station_id = toml_table_in(general, "station-id"))) {syslog_err("CONFIG: Failed locating [general] station-id table"); return 1;}
|
if (0 == (security = toml_table_in(conf, "security"))) {syslog_err("[facilities] [config] failed locating [security] table"); return 1;}
|
||||||
|
|
||||||
// Values
|
// Values
|
||||||
// General
|
// General
|
||||||
|
|
@ -106,13 +106,14 @@ int itss_config(void* facilities_s, char* config_file) {
|
||||||
free(itss_type);
|
free(itss_type);
|
||||||
|
|
||||||
int station_id_random = 1;
|
int station_id_random = 1;
|
||||||
rv = extract_val_bool(&station_id_random, general_station_id, "random");
|
rv = extract_val_bool(&station_id_random, security, "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, general_station_id, "number");
|
rv = extract_val_int(&station_id_number, security, "station-id");
|
||||||
facilities->station_id = station_id_number;
|
facilities->station_id = station_id_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,8 @@
|
||||||
#include <itss-facilities/FacilitiesDataIndication.h>
|
#include <itss-facilities/FacilitiesDataIndication.h>
|
||||||
#include <itss-facilities/FacilitiesDataRequest.h>
|
#include <itss-facilities/FacilitiesDataRequest.h>
|
||||||
#include <itss-facilities/FacilitiesDataResult.h>
|
#include <itss-facilities/FacilitiesDataResult.h>
|
||||||
|
#include <itss-security/SecurityIndication.h>
|
||||||
|
#include <itss-security/SecurityResponse.h>
|
||||||
|
|
||||||
#include <camv2/CAM.h>
|
#include <camv2/CAM.h>
|
||||||
#include <denmv2/DENM.h>
|
#include <denmv2/DENM.h>
|
||||||
|
|
@ -388,7 +390,9 @@ static int facilities_request(facilities_t *facilities, void* responder, uint8_t
|
||||||
fdres->result->choice.attributes.list.array[j] = calloc(1, sizeof(FacilitiesAttribute_t) );
|
fdres->result->choice.attributes.list.array[j] = calloc(1, sizeof(FacilitiesAttribute_t) );
|
||||||
fdres->result->choice.attributes.list.array[j]->data.size = 8;
|
fdres->result->choice.attributes.list.array[j]->data.size = 8;
|
||||||
fdres->result->choice.attributes.list.array[j]->data.buf = malloc(8);
|
fdres->result->choice.attributes.list.array[j]->data.buf = malloc(8);
|
||||||
|
pthread_mutex_lock(&facilities->lock);
|
||||||
*((uint64_t*) fdres->result->choice.attributes.list.array[j]->data.buf) = facilities->station_id;
|
*((uint64_t*) fdres->result->choice.attributes.list.array[j]->data.buf) = facilities->station_id;
|
||||||
|
pthread_mutex_unlock(&facilities->lock);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
syslog_debug("[facilities] unrecognized FDR attribute type request");
|
syslog_debug("[facilities] unrecognized FDR attribute type request");
|
||||||
|
|
@ -428,6 +432,87 @@ static int facilities_request(facilities_t *facilities, void* responder, uint8_t
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int security_indication(facilities_t *facilities, void* responder_secured, uint8_t *msg, uint32_t msg_len) {
|
||||||
|
int rv = 0;
|
||||||
|
|
||||||
|
SecurityIndication_t* si = calloc(1, sizeof(SecurityIndication_t));
|
||||||
|
SecurityResponse_t* sr = calloc(1, sizeof(SecurityResponse_t));
|
||||||
|
|
||||||
|
uint8_t buffer[64];
|
||||||
|
|
||||||
|
asn_enc_rval_t enc;
|
||||||
|
|
||||||
|
asn_dec_rval_t dec = oer_decode(NULL, &asn_DEF_SecurityIndication, (void**) &si, msg, msg_len);
|
||||||
|
if (dec.code) {
|
||||||
|
syslog_err("[networking]<- invalid SIndication received");
|
||||||
|
rv = 1;
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (si->choice.idChangeEvent.command) {
|
||||||
|
case SecurityIdChangeEventType_prepare:
|
||||||
|
pthread_mutex_lock(&facilities->lock);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case SecurityIdChangeEventType_commit:
|
||||||
|
;
|
||||||
|
|
||||||
|
facilities->station_id = rand();
|
||||||
|
pthread_mutex_unlock(&facilities->lock);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case SecurityIdChangeEventType_abort:
|
||||||
|
pthread_mutex_unlock(&facilities->lock);
|
||||||
|
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
syslog_err("[networking]<- unhandled idChangeEvent command type");
|
||||||
|
rv = 1;
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
sr->present = SecurityResponse_PR_idChangeEvent;
|
||||||
|
sr->choice.idChangeEvent.returnCode = 0;
|
||||||
|
enc = oer_encode_to_buffer(&asn_DEF_SecurityResponse, NULL, sr, buffer, 64);
|
||||||
|
zmq_send(responder_secured, buffer, enc.encoded, 0);
|
||||||
|
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
if (rv) {
|
||||||
|
sr->present = SecurityResponse_PR_idChangeEvent;
|
||||||
|
sr->choice.idChangeEvent.returnCode = 1;
|
||||||
|
enc = oer_encode_to_buffer(&asn_DEF_SecurityResponse, NULL, sr, buffer, 64);
|
||||||
|
zmq_send(responder_secured, buffer, enc.encoded, 0);
|
||||||
|
zmq_recv(responder_secured, buffer, 64, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
ASN_STRUCT_FREE(asn_DEF_SecurityResponse, sr);
|
||||||
|
ASN_STRUCT_FREE(asn_DEF_SecurityIndication, si);
|
||||||
|
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void* securer(void *fc) {
|
||||||
|
int rv = 0;
|
||||||
|
|
||||||
|
facilities_t *facilities = (facilities_t*) fc;
|
||||||
|
|
||||||
|
void *responder_secured = zmq_socket(facilities->ctx, ZMQ_REP);
|
||||||
|
int rc = zmq_bind(responder_secured, FACILITIES_SECURED_ADDRESS);
|
||||||
|
|
||||||
|
uint8_t buffer[PACKET_MAX_LEN];
|
||||||
|
|
||||||
|
while (!facilities->exit) {
|
||||||
|
zmq_recv(responder_secured, buffer, PACKET_MAX_LEN, 0);
|
||||||
|
rv = security_indication(facilities, responder_secured, buffer, PACKET_MAX_LEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
void* tx(void* fc) {
|
void* tx(void* fc) {
|
||||||
facilities_t *facilities = (facilities_t*) fc;
|
facilities_t *facilities = (facilities_t*) fc;
|
||||||
|
|
||||||
|
|
@ -483,6 +568,8 @@ int main() {
|
||||||
facilities_t facilities;
|
facilities_t facilities;
|
||||||
facilities.exit = false;
|
facilities.exit = false;
|
||||||
|
|
||||||
|
pthread_mutex_init(&facilities.lock, NULL);
|
||||||
|
|
||||||
struct stat st = {0};
|
struct stat st = {0};
|
||||||
if (stat("/tmp/itss", &st) == -1) {
|
if (stat("/tmp/itss", &st) == -1) {
|
||||||
mkdir("/tmp/itss", 0777);
|
mkdir("/tmp/itss", 0777);
|
||||||
|
|
@ -498,6 +585,9 @@ int main() {
|
||||||
void *responder = zmq_socket(context, ZMQ_REP);
|
void *responder = zmq_socket(context, ZMQ_REP);
|
||||||
int rc = zmq_bind(responder, FACILITIES_ADDRESS);
|
int rc = zmq_bind(responder, FACILITIES_ADDRESS);
|
||||||
|
|
||||||
|
void *security_socket = zmq_socket(context, ZMQ_REQ);
|
||||||
|
rc = zmq_bind(security_socket, SECURITY_ADDRESS);
|
||||||
|
|
||||||
facilities.tx_queue = queue_init();
|
facilities.tx_queue = queue_init();
|
||||||
|
|
||||||
facilities.lightship = lightship_init();
|
facilities.lightship = lightship_init();
|
||||||
|
|
@ -510,6 +600,9 @@ int main() {
|
||||||
// Tx
|
// Tx
|
||||||
pthread_create(&facilities.transmitting, NULL, tx, (void*) &facilities);
|
pthread_create(&facilities.transmitting, NULL, tx, (void*) &facilities);
|
||||||
|
|
||||||
|
// Tx
|
||||||
|
pthread_create(&facilities.securing, NULL, securer, (void*) &facilities);
|
||||||
|
|
||||||
// CA
|
// CA
|
||||||
pthread_create(&facilities.ca_service, NULL, ca_service, (void*) &facilities);
|
pthread_create(&facilities.ca_service, NULL, ca_service, (void*) &facilities);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,14 +10,17 @@
|
||||||
#include "queue.h"
|
#include "queue.h"
|
||||||
|
|
||||||
#define FACILITIES_ADDRESS "ipc:///tmp/itss/facilities"
|
#define FACILITIES_ADDRESS "ipc:///tmp/itss/facilities"
|
||||||
|
#define FACILITIES_SECURED_ADDRESS "ipc:///tmp/itss/facilities-secured"
|
||||||
#define TRANSPORT_ADDRESS "ipc:///tmp/itss/transport"
|
#define TRANSPORT_ADDRESS "ipc:///tmp/itss/transport"
|
||||||
#define APPLICATION_ADDRESS "ipc:///tmp/itss/application"
|
#define APPLICATION_ADDRESS "ipc:///tmp/itss/application"
|
||||||
|
#define SECURITY_ADDRESS "ipc:///tmp/itss/security"
|
||||||
|
|
||||||
typedef struct facilities {
|
typedef struct facilities {
|
||||||
pthread_t ca_service;
|
pthread_t ca_service;
|
||||||
pthread_t den_service;
|
pthread_t den_service;
|
||||||
pthread_t infrastructure_service;
|
pthread_t infrastructure_service;
|
||||||
pthread_t transmitting;
|
pthread_t transmitting;
|
||||||
|
pthread_t securing;
|
||||||
|
|
||||||
// ZMQ
|
// ZMQ
|
||||||
void* ctx;
|
void* ctx;
|
||||||
|
|
@ -36,7 +39,9 @@ typedef struct facilities {
|
||||||
|
|
||||||
int station_type;
|
int station_type;
|
||||||
|
|
||||||
|
pthread_mutex_t lock;
|
||||||
uint64_t station_id;
|
uint64_t station_id;
|
||||||
|
bool id_random;
|
||||||
|
|
||||||
bool exit;
|
bool exit;
|
||||||
} facilities_t;
|
} facilities_t;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue