[security] managed identity
This commit is contained in:
parent
e5fef64fd0
commit
d42f0c76a1
|
|
@ -93,7 +93,7 @@ static int mk_cam(facilities_t* facilities, uint8_t *cam_oer, uint32_t *cam_len)
|
||||||
cam->header.protocolVersion = 2;
|
cam->header.protocolVersion = 2;
|
||||||
cam->header.messageID = ItsPduHeader__messageID_cam;
|
cam->header.messageID = ItsPduHeader__messageID_cam;
|
||||||
pthread_mutex_lock(&facilities->id.lock);
|
pthread_mutex_lock(&facilities->id.lock);
|
||||||
cam->header.stationID = facilities->id.value;
|
cam->header.stationID = facilities->id.station_id;
|
||||||
pthread_mutex_unlock(&facilities->id.lock);
|
pthread_mutex_unlock(&facilities->id.lock);
|
||||||
cam->cam.camParameters.basicContainer.stationType = facilities->station_type;
|
cam->cam.camParameters.basicContainer.stationType = facilities->station_type;
|
||||||
|
|
||||||
|
|
|
||||||
40
src/config.c
40
src/config.c
|
|
@ -214,11 +214,13 @@ int facilities_config(void* facilities_s) {
|
||||||
SecurityReply_t* sREP = NULL;
|
SecurityReply_t* sREP = NULL;
|
||||||
|
|
||||||
sREQ->present = SecurityRequest_PR_ids;
|
sREQ->present = SecurityRequest_PR_ids;
|
||||||
sREQ->choice.ids.list.count = 1;
|
sREQ->choice.ids.list.count = 2;
|
||||||
sREQ->choice.ids.list.size = sizeof(void*);
|
sREQ->choice.ids.list.size = 2*sizeof(void*);
|
||||||
sREQ->choice.ids.list.array = malloc(sizeof(void*));
|
sREQ->choice.ids.list.array = malloc(2*sizeof(void*));
|
||||||
sREQ->choice.ids.list.array[0] = calloc(1, sizeof(SecurityIdType_t));
|
sREQ->choice.ids.list.array[0] = calloc(1, sizeof(SecurityIdType_t));
|
||||||
*sREQ->choice.ids.list.array[0] = SecurityIdType_stationId;
|
*sREQ->choice.ids.list.array[0] = SecurityIdType_stationId;
|
||||||
|
sREQ->choice.ids.list.array[1] = calloc(1, sizeof(SecurityIdType_t));
|
||||||
|
*sREQ->choice.ids.list.array[1] = SecurityIdType_ipv6Address;
|
||||||
|
|
||||||
uint8_t b_sdu[256];
|
uint8_t b_sdu[256];
|
||||||
asn_enc_rval_t enc = oer_encode_to_buffer(&asn_DEF_SecurityRequest, NULL, sREQ, b_sdu, 256);
|
asn_enc_rval_t enc = oer_encode_to_buffer(&asn_DEF_SecurityRequest, NULL, sREQ, b_sdu, 256);
|
||||||
|
|
@ -237,8 +239,15 @@ int facilities_config(void* facilities_s) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < sREP->data->choice.ids.list.count; ++i) {
|
for (int i = 0; i < sREP->data->choice.ids.list.count; ++i) {
|
||||||
if (sREP->data->choice.ids.list.array[i]->present == SecurityId_PR_stationId) {
|
switch (sREP->data->choice.ids.list.array[i]->present) {
|
||||||
facilities->id.value = sREP->data->choice.ids.list.array[i]->choice.stationId;
|
case SecurityId_PR_stationId:
|
||||||
|
facilities->id.station_id = sREP->data->choice.ids.list.array[i]->choice.stationId;
|
||||||
|
break;
|
||||||
|
case SecurityId_PR_ipv6Address:
|
||||||
|
memcpy(facilities->id.ipv6_addr, sREP->data->choice.ids.list.array[i]->choice.ipv6Address.buf, 16);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -246,25 +255,8 @@ int facilities_config(void* facilities_s) {
|
||||||
ASN_STRUCT_FREE(asn_DEF_SecurityReply, sREP);
|
ASN_STRUCT_FREE(asn_DEF_SecurityReply, sREP);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
facilities->id.value = config->security.identity.station_id;
|
facilities->id.station_id = config->security.identity.station_id;
|
||||||
}
|
}
|
||||||
// Inform management
|
|
||||||
ManagementRequest_t* mreq_set = calloc(1, sizeof(ManagementRequest_t));
|
|
||||||
mreq_set->present = ManagementRequest_PR_attributes;
|
|
||||||
mreq_set->choice.attributes.present = ManagementRequestAttributes_PR_set;
|
|
||||||
mreq_set->choice.attributes.choice.set.stationID = malloc(sizeof(long));
|
|
||||||
*mreq_set->choice.attributes.choice.set.stationID = facilities->id.value;
|
|
||||||
uint8_t b_oer[128];
|
|
||||||
asn_enc_rval_t enc = asn_encode_to_buffer(NULL, ATS_CANONICAL_OER, &asn_DEF_ManagementRequest, mreq_set, b_oer, 128);
|
|
||||||
if (enc.encoded != -1) {
|
|
||||||
void* management_socket = zmq_socket(facilities->zmq.ctx, ZMQ_REQ);
|
|
||||||
zmq_connect(management_socket, facilities->zmq.management_address);
|
|
||||||
zmq_send(management_socket, b_oer, enc.encoded, 0);
|
|
||||||
uint8_t code;
|
|
||||||
zmq_recv(management_socket, &code, 1, 0);
|
|
||||||
zmq_close(management_socket);
|
|
||||||
}
|
|
||||||
ASN_STRUCT_FREE(asn_DEF_ManagementRequest, mreq_set);
|
|
||||||
|
|
||||||
// DENM
|
// DENM
|
||||||
facilities->den->n_max_events = config->facilities.denm.nmax_active_events;
|
facilities->den->n_max_events = config->facilities.denm.nmax_active_events;
|
||||||
|
|
@ -362,7 +354,7 @@ int facilities_config(void* facilities_s) {
|
||||||
void* management_socket = zmq_socket(facilities->zmq.ctx, ZMQ_REQ);
|
void* management_socket = zmq_socket(facilities->zmq.ctx, ZMQ_REQ);
|
||||||
zmq_connect(management_socket, facilities->zmq.management_address);
|
zmq_connect(management_socket, facilities->zmq.management_address);
|
||||||
uint8_t buffer[256];
|
uint8_t buffer[256];
|
||||||
enc = oer_encode_to_buffer(&asn_DEF_ManagementRequest, NULL, mreq, buffer, 256);
|
asn_enc_rval_t enc = oer_encode_to_buffer(&asn_DEF_ManagementRequest, NULL, mreq, buffer, 256);
|
||||||
|
|
||||||
zmq_send(management_socket, buffer, enc.encoded, 0);
|
zmq_send(management_socket, buffer, enc.encoded, 0);
|
||||||
zmq_recv(management_socket, buffer, 256, 0);
|
zmq_recv(management_socket, buffer, 256, 0);
|
||||||
|
|
|
||||||
|
|
@ -500,7 +500,9 @@ static int mk_cpm(facilities_t* facilities, uint8_t *bdr_oer, uint32_t *bdr_len,
|
||||||
|
|
||||||
cpm_tx->header.protocolVersion = PROTOCOL_VERSION;
|
cpm_tx->header.protocolVersion = PROTOCOL_VERSION;
|
||||||
cpm_tx->header.messageID = MESSAGE_ID;
|
cpm_tx->header.messageID = MESSAGE_ID;
|
||||||
cpm_tx->header.stationID = facilities->id.value;
|
pthread_mutex_lock(&facilities->id.lock);
|
||||||
|
cpm_tx->header.stationID = facilities->id.station_id;
|
||||||
|
pthread_mutex_unlock(&facilities->id.lock);
|
||||||
|
|
||||||
uint64_t generationDeltaTime = it2s_tender_get_clock(&facilities->epv) % 65536; // generationDeltaTime = TimestampIts mod 65 536
|
uint64_t generationDeltaTime = it2s_tender_get_clock(&facilities->epv) % 65536; // generationDeltaTime = TimestampIts mod 65 536
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -348,8 +348,15 @@ static int security_indication(facilities_t *facilities, void* responder_secured
|
||||||
|
|
||||||
// Change Station ID
|
// Change Station ID
|
||||||
for (int i = 0; i < si->choice.idChangeEvent.ids.list.count; ++i) {
|
for (int i = 0; i < si->choice.idChangeEvent.ids.list.count; ++i) {
|
||||||
if (si->choice.idChangeEvent.ids.list.array[i]->present == SecurityId_PR_stationId) {
|
switch (si->choice.idChangeEvent.ids.list.array[i]->present) {
|
||||||
facilities->id.value = si->choice.idChangeEvent.ids.list.array[i]->choice.stationId;
|
case SecurityId_PR_stationId:
|
||||||
|
facilities->id.station_id = si->choice.idChangeEvent.ids.list.array[i]->choice.stationId;
|
||||||
|
break;
|
||||||
|
case SecurityId_PR_ipv6Address:
|
||||||
|
memcpy(facilities->id.ipv6_addr, si->choice.idChangeEvent.ids.list.array[i]->choice.ipv6Address.buf, 16);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,8 @@ typedef struct facilities {
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
pthread_mutex_t lock;
|
pthread_mutex_t lock;
|
||||||
uint64_t value;
|
uint64_t station_id;
|
||||||
|
uint8_t ipv6_addr[16];
|
||||||
struct {
|
struct {
|
||||||
pthread_mutex_t lock;
|
pthread_mutex_t lock;
|
||||||
bool random;
|
bool random;
|
||||||
|
|
|
||||||
|
|
@ -147,7 +147,7 @@ int facilities_request_single_message(facilities_t* facilities, void* responder,
|
||||||
if (fwd) {
|
if (fwd) {
|
||||||
// set stationID
|
// set stationID
|
||||||
pthread_mutex_lock(&facilities->id.lock);
|
pthread_mutex_lock(&facilities->id.lock);
|
||||||
((DENM_t*)its_msg)->header.stationID = facilities->id.value;
|
((DENM_t*)its_msg)->header.stationID = facilities->id.station_id;
|
||||||
pthread_mutex_unlock(&facilities->id.lock);
|
pthread_mutex_unlock(&facilities->id.lock);
|
||||||
|
|
||||||
// Set only one trace
|
// Set only one trace
|
||||||
|
|
@ -450,7 +450,7 @@ int facilities_request_attribute_types(facilities_t* facilities, void* responder
|
||||||
frep->choice.data.choice.attributes.list.array[j]->data.size = 8;
|
frep->choice.data.choice.attributes.list.array[j]->data.size = 8;
|
||||||
frep->choice.data.choice.attributes.list.array[j]->data.buf = malloc(8);
|
frep->choice.data.choice.attributes.list.array[j]->data.buf = malloc(8);
|
||||||
pthread_mutex_lock(&facilities->id.lock);
|
pthread_mutex_lock(&facilities->id.lock);
|
||||||
*((uint64_t*) frep->choice.data.choice.attributes.list.array[j]->data.buf) = facilities->id.value;
|
*((uint64_t*) frep->choice.data.choice.attributes.list.array[j]->data.buf) = facilities->id.station_id;
|
||||||
pthread_mutex_unlock(&facilities->id.lock);
|
pthread_mutex_unlock(&facilities->id.lock);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
||||||
9
src/sa.c
9
src/sa.c
|
|
@ -115,10 +115,7 @@ int mk_saem(facilities_t* facilities, uint8_t* b_saem, uint32_t* b_saem_len) {
|
||||||
saem->header.messageID = messageID_saem;
|
saem->header.messageID = messageID_saem;
|
||||||
|
|
||||||
pthread_mutex_lock(&facilities->id.lock);
|
pthread_mutex_lock(&facilities->id.lock);
|
||||||
saem->header.stationID = facilities->id.value;
|
saem->header.stationID = facilities->id.station_id;
|
||||||
pthread_mutex_unlock(&facilities->id.lock);
|
|
||||||
|
|
||||||
uint8_t ipv6_addr[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16};
|
|
||||||
|
|
||||||
/* sam */
|
/* sam */
|
||||||
saem->sam.version = 0;
|
saem->sam.version = 0;
|
||||||
|
|
@ -144,13 +141,15 @@ int mk_saem(facilities_t* facilities, uint8_t* b_saem, uint32_t* b_saem_len) {
|
||||||
|
|
||||||
saem->sam.body.serviceInfos->list.array[i]->chOptions.extensions->list.array[0]->choice.addressIPv6.size = 16;
|
saem->sam.body.serviceInfos->list.array[i]->chOptions.extensions->list.array[0]->choice.addressIPv6.size = 16;
|
||||||
saem->sam.body.serviceInfos->list.array[i]->chOptions.extensions->list.array[0]->choice.addressIPv6.buf = malloc(16);
|
saem->sam.body.serviceInfos->list.array[i]->chOptions.extensions->list.array[0]->choice.addressIPv6.buf = malloc(16);
|
||||||
memcpy(saem->sam.body.serviceInfos->list.array[i]->chOptions.extensions->list.array[0]->choice.addressIPv6.buf, ipv6_addr, 16);
|
memcpy(saem->sam.body.serviceInfos->list.array[i]->chOptions.extensions->list.array[0]->choice.addressIPv6.buf, facilities->id.ipv6_addr, 16);
|
||||||
|
|
||||||
saem->sam.body.serviceInfos->list.array[i]->chOptions.extensions->list.array[1] = calloc(1, sizeof(ServiceInfoExt_t));
|
saem->sam.body.serviceInfos->list.array[i]->chOptions.extensions->list.array[1] = calloc(1, sizeof(ServiceInfoExt_t));
|
||||||
saem->sam.body.serviceInfos->list.array[i]->chOptions.extensions->list.array[1]->present = ServiceInfoExt_PR_servicePort;
|
saem->sam.body.serviceInfos->list.array[i]->chOptions.extensions->list.array[1]->present = ServiceInfoExt_PR_servicePort;
|
||||||
saem->sam.body.serviceInfos->list.array[i]->chOptions.extensions->list.array[1]->choice.servicePort = 7777;
|
saem->sam.body.serviceInfos->list.array[i]->chOptions.extensions->list.array[1]->choice.servicePort = 7777;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pthread_mutex_unlock(&facilities->id.lock);
|
||||||
|
|
||||||
asn_enc_rval_t enc = asn_encode_to_buffer(NULL, ATS_UNALIGNED_CANONICAL_PER, &asn_DEF_SAEM, saem, b_saem, *b_saem_len);
|
asn_enc_rval_t enc = asn_encode_to_buffer(NULL, ATS_UNALIGNED_CANONICAL_PER, &asn_DEF_SAEM, saem, b_saem, *b_saem_len);
|
||||||
if (enc.encoded == -1) {
|
if (enc.encoded == -1) {
|
||||||
syslog_err("[facilities] [sa] failure to encode SAEM (%s)", enc.failed_type->name);
|
syslog_err("[facilities] [sa] failure to encode SAEM (%s)", enc.failed_type->name);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue