Support for modified MGMT ASN

This commit is contained in:
emanuel 2021-05-19 18:42:27 +01:00
parent d212396fe2
commit 71441e1587
3 changed files with 72 additions and 60 deletions

View File

@ -213,9 +213,10 @@ int facilities_config(void* facilities_s) {
}
// Inform management
ManagementRequest_t* mreq_set = calloc(1, sizeof(ManagementRequest_t));
mreq_set->present = ManagementRequest_PR_set;
mreq_set->choice.set.stationId = malloc(sizeof(long));
*mreq_set->choice.set.stationId = facilities->id.value;
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) {
@ -243,7 +244,7 @@ int facilities_config(void* facilities_s) {
facilities->infrastructure->replay_interval = config->facilities.ivim.replay_interval;
facilities->infrastructure->default_service_duration = config->facilities.ivim.default_service_duration * 60000;
//CPM
// CPM
facilities->dissemination->active = config->facilities.cpm.activate;
facilities->dissemination->T_GenCpmMin = config->facilities.cpm.rsu_obu_period_min;
facilities->dissemination->T_GenCpmMax = config->facilities.cpm.rsu_obu_period_max;
@ -302,15 +303,16 @@ int facilities_config(void* facilities_s) {
facilities->epv.time.resolution = TIME_MILLISECONDS;
ManagementRequest_t* mreq = calloc(1, sizeof(ManagementRequest_t));
mreq->present = ManagementRequest_PR_get;
mreq->choice.get.coordinates = 1;
mreq->choice.get.altitude = 1;
mreq->choice.get.heading = 1;
mreq->choice.get.speed = 1;
mreq->choice.get.gpsType = 1;
mreq->choice.get.clockType = 1;
mreq->choice.get.clock = 1;
mreq->choice.get.clockOffset = 1;
mreq->present = ManagementRequest_PR_attributes;
mreq->choice.attributes.present = ManagementRequestAttributes_PR_get;
mreq->choice.attributes.choice.get.coordinates = 1;
mreq->choice.attributes.choice.get.altitude = 1;
mreq->choice.attributes.choice.get.heading = 1;
mreq->choice.attributes.choice.get.speed = 1;
mreq->choice.attributes.choice.get.gpsType = 1;
mreq->choice.attributes.choice.get.clockType = 1;
mreq->choice.attributes.choice.get.clock = 1;
mreq->choice.attributes.choice.get.clockOffset = 1;
void* management_socket = zmq_socket(facilities->zmq.ctx, ZMQ_REQ);
zmq_connect(management_socket, facilities->zmq.management_address);
uint8_t buffer[256];

View File

@ -329,9 +329,10 @@ static int security_indication(facilities_t *facilities, void* responder_secured
if (facilities->id.change.stage == ID_CHANGE_INACTIVE) {
// Inform management
ManagementRequest_t* mreq = calloc(1, sizeof(ManagementRequest_t));
mreq->present = ManagementRequest_PR_set;
mreq->choice.set.stationId = malloc(sizeof(long));
*mreq->choice.set.stationId = facilities->id.value;
mreq->present = ManagementRequest_PR_attributes;
mreq->choice.attributes.present = ManagementRequestAttributes_PR_set;
mreq->choice.attributes.choice.set.stationID = malloc(sizeof(long));
*mreq->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, b_oer, 128);
if (enc.encoded != -1) {

View File

@ -49,64 +49,73 @@ int init(void* ctx) {
ManagementReply_t* mrep = calloc(1, sizeof(ManagementReply_t));
switch (mreq->present) {
case ManagementRequest_PR_get:
case ManagementRequest_PR_attributes:
switch (mreq->choice.attributes.present) {
case ManagementRequestAttributes_PR_get:
mrep->returnCode = ManagementReplyReturnCode_accepted;
mrep->attributes = calloc(1, sizeof(ManagementReplyAttributes_t));
if (mreq->choice.get.stationId) {
mrep->attributes->stationId = malloc(sizeof(long));
*mrep->attributes->stationId = 78;
if (mreq->choice.attributes.choice.get.stationID) {
mrep->attributes->stationID = malloc(sizeof(long));
*mrep->attributes->stationID = 78;
}
if (mreq->choice.get.gpsType) {
if (mreq->choice.attributes.choice.get.gpsType) {
mrep->attributes->gpsType = malloc(sizeof(long));
*mrep->attributes->gpsType = 0;
}
if (mreq->choice.get.clockType) {
if (mreq->choice.attributes.choice.get.clockType) {
mrep->attributes->clockType = malloc(sizeof(long));
*mrep->attributes->clockType = 0;
}
if (mreq->choice.get.clock) {
if (mreq->choice.attributes.choice.get.clock) {
mrep->attributes->clock = calloc(1, sizeof(TimestampIts_t));
asn_ulong2INTEGER(mrep->attributes->clock, 666);
}
if (mreq->choice.get.clockOffset) {
if (mreq->choice.attributes.choice.get.clockOffset) {
mrep->attributes->clockOffset = calloc(1, sizeof(TimestampIts_t));
asn_ulong2INTEGER(mrep->attributes->clockOffset, 0);
}
if (mreq->choice.get.coordinates) {
if (mreq->choice.attributes.choice.get.coordinates) {
mrep->attributes->coordinates = calloc(1, sizeof(WGS84Coordinates_t));
mrep->attributes->coordinates->latitude = 0;
mrep->attributes->coordinates->longitude = 0;
}
if (mreq->choice.get.altitude) {
if (mreq->choice.attributes.choice.get.altitude) {
mrep->attributes->altitude = calloc(1, sizeof(Altitude_t));
mrep->attributes->altitude->altitudeValue = 0;
mrep->attributes->altitude->altitudeConfidence = 1;
}
if (mreq->choice.get.speed) {
if (mreq->choice.attributes.choice.get.speed) {
mrep->attributes->speed = calloc(1, sizeof(Speed_t));
mrep->attributes->speed->speedValue = 0;
mrep->attributes->speed->speedConfidence = 1;
}
if (mreq->choice.get.heading) {
if (mreq->choice.attributes.choice.get.heading) {
mrep->attributes->heading = calloc(1, sizeof(Heading_t));
mrep->attributes->heading->headingValue = 0;
mrep->attributes->heading->headingConfidence = 1;
}
break;
case ManagementRequest_PR_set:
default:
rv = 1;
printf(" FAIL: MREQ. not GET (%d)\n", mreq->present); fflush(stdout);
printf(" FAIL: MREQ.ATTRIBUTES. not GET (%d)\n", mreq->present); fflush(stdout);
goto cleanup;
}
break;
case ManagementRequest_PR_sa:
default:
rv = 1;
printf(" FAIL: MREQ. not ATTRIBUTES (%d)\n", mreq->present); fflush(stdout);
goto cleanup;
}