|
|
|
|
@ -93,6 +93,7 @@ int facilities_request_single_message(void *responder, EIS_FacilitiesMessageRequ
|
|
|
|
|
asn_TYPE_descriptor_t *its_msg_def = NULL;
|
|
|
|
|
|
|
|
|
|
bool fwd = true;
|
|
|
|
|
bool process_msg = true;
|
|
|
|
|
|
|
|
|
|
uint64_t transmission_duration = 0;
|
|
|
|
|
uint32_t transmission_interval = 0;
|
|
|
|
|
@ -121,7 +122,6 @@ int facilities_request_single_message(void *responder, EIS_FacilitiesMessageRequ
|
|
|
|
|
npr->transport.choice.btp.destinationPort = EIS_Port_ivim;
|
|
|
|
|
npr->network.choice.gn.packetTransportType = EIS_PacketTransportType_shb;
|
|
|
|
|
npr->network.choice.gn.trafficClass = 1;
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case EIS_ItsMessageType_cpm:
|
|
|
|
|
@ -141,18 +141,17 @@ int facilities_request_single_message(void *responder, EIS_FacilitiesMessageRequ
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
log_error("unrecognized FR message type (%lld)", frm->itsMessageType);
|
|
|
|
|
facilities_request_result_rejected(responder);
|
|
|
|
|
rv = 1;
|
|
|
|
|
goto cleanup;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
asn_dec_rval_t dec = uper_decode_complete(NULL, its_msg_def, (void **)&its_msg, frm->data.buf, frm->data.size);
|
|
|
|
|
if (dec.code) {
|
|
|
|
|
log_warn("invalid FR %s received", its_msg_def->name);
|
|
|
|
|
facilities_request_result_rejected(responder);
|
|
|
|
|
rv = 1;
|
|
|
|
|
goto cleanup;
|
|
|
|
|
if (!facilities.upf) {
|
|
|
|
|
log_error("unrecognized FR message type (%lld)", frm->itsMessageType);
|
|
|
|
|
facilities_request_result_rejected(responder);
|
|
|
|
|
rv = 1;
|
|
|
|
|
goto cleanup;
|
|
|
|
|
} else {
|
|
|
|
|
process_msg = false;
|
|
|
|
|
npr->transport.choice.btp.destinationPort = 7120;
|
|
|
|
|
npr->network.choice.gn.packetTransportType = EIS_PacketTransportType_shb;
|
|
|
|
|
npr->network.choice.gn.trafficClass = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint64_t id = 0;
|
|
|
|
|
@ -163,160 +162,171 @@ int facilities_request_single_message(void *responder, EIS_FacilitiesMessageRequ
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool is_update = false;
|
|
|
|
|
|
|
|
|
|
int managed_msg = false;
|
|
|
|
|
if (frm->itsMessageType == EIS_ItsMessageType_denm) {
|
|
|
|
|
managed_msg = true;
|
|
|
|
|
|
|
|
|
|
uint8_t event_type = event_manage(its_msg, &id, NULL, 0);
|
|
|
|
|
// Do not free its_msg! event_manage takes care of the msg
|
|
|
|
|
// id will get set to another val if EVENT NEW or UPDATE or CANCELLATION or NEGATION
|
|
|
|
|
if (event_type != EVENT_NEW &&
|
|
|
|
|
event_type != EVENT_UPDATE &&
|
|
|
|
|
event_type != EVENT_CANCELLATION &&
|
|
|
|
|
event_type != EVENT_NEGATION) {
|
|
|
|
|
fwd = false;
|
|
|
|
|
if (process_msg) {
|
|
|
|
|
asn_dec_rval_t dec = uper_decode_complete(NULL, its_msg_def, (void **)&its_msg, frm->data.buf, frm->data.size);
|
|
|
|
|
if (dec.code) {
|
|
|
|
|
log_warn("invalid FR %s received", its_msg_def->name);
|
|
|
|
|
facilities_request_result_rejected(responder);
|
|
|
|
|
rv = 1;
|
|
|
|
|
goto cleanup;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (event_type == EVENT_UPDATE ||
|
|
|
|
|
event_type == EVENT_CANCELLATION ||
|
|
|
|
|
event_type == EVENT_NEGATION) {
|
|
|
|
|
is_update = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (fwd) {
|
|
|
|
|
// set stationID
|
|
|
|
|
pthread_mutex_lock(&facilities.id.lock);
|
|
|
|
|
((EI1_DENM_t *)its_msg)->header.stationID = facilities.id.station_id;
|
|
|
|
|
pthread_mutex_unlock(&facilities.id.lock);
|
|
|
|
|
|
|
|
|
|
// Set only one trace
|
|
|
|
|
if (facilities.station_type != 15) {
|
|
|
|
|
pthread_mutex_lock(&facilities.lightship.lock);
|
|
|
|
|
if (facilities.lightship.path_history_len > 0) {
|
|
|
|
|
if (!((EI1_DENM_t *)its_msg)->denm.location) {
|
|
|
|
|
((EI1_DENM_t *)its_msg)->denm.location = calloc(1, sizeof(EI1_LocationContainer_t));
|
|
|
|
|
}
|
|
|
|
|
((EI1_DENM_t *)its_msg)->denm.location->traces.list.count = 1;
|
|
|
|
|
((EI1_DENM_t *)its_msg)->denm.location->traces.list.size = 1 * sizeof(void *);
|
|
|
|
|
((EI1_DENM_t *)its_msg)->denm.location->traces.list.array = malloc(1 * sizeof(void *));
|
|
|
|
|
((EI1_DENM_t *)its_msg)->denm.location->traces.list.array[0] = calloc(1, sizeof(EI1_PathHistory_t));
|
|
|
|
|
EI1_PathHistory_t *ph = ((EI1_DENM_t *)its_msg)->denm.location->traces.list.array[0];
|
|
|
|
|
|
|
|
|
|
pos_point_t **path_history = facilities.lightship.path_history;
|
|
|
|
|
uint16_t path_history_len = facilities.lightship.path_history_len;
|
|
|
|
|
|
|
|
|
|
ph->list.array = malloc((path_history_len) * sizeof(void *));
|
|
|
|
|
ph->list.count = path_history_len;
|
|
|
|
|
ph->list.size = (path_history_len) * sizeof(void *);
|
|
|
|
|
|
|
|
|
|
ph->list.array[0] = calloc(1, sizeof(EI1_PathPoint_t));
|
|
|
|
|
|
|
|
|
|
itss_space_lock();
|
|
|
|
|
if (path_history[0]->alt != EI1_AltitudeValue_unavailable && epv.space.altitude != EI1_AltitudeValue_unavailable) {
|
|
|
|
|
ph->list.array[0]->pathPosition.deltaAltitude = path_history[0]->alt - epv.space.altitude;
|
|
|
|
|
} else {
|
|
|
|
|
ph->list.array[0]->pathPosition.deltaAltitude = EI1_DeltaAltitude_unavailable;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (path_history[0]->lat != EI1_Latitude_unavailable && epv.space.latitude != EI1_Latitude_unavailable) {
|
|
|
|
|
ph->list.array[0]->pathPosition.deltaLatitude = path_history[0]->lat - epv.space.latitude;
|
|
|
|
|
} else {
|
|
|
|
|
ph->list.array[0]->pathPosition.deltaLatitude = EI1_DeltaLatitude_unavailable;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (path_history[0]->lon != EI1_Longitude_unavailable && epv.space.longitude != EI1_Longitude_unavailable) {
|
|
|
|
|
ph->list.array[0]->pathPosition.deltaLongitude = path_history[0]->lon - epv.space.longitude;
|
|
|
|
|
} else {
|
|
|
|
|
ph->list.array[0]->pathPosition.deltaLongitude = EI1_DeltaLongitude_unavailable;
|
|
|
|
|
}
|
|
|
|
|
itss_space_unlock();
|
|
|
|
|
|
|
|
|
|
ph->list.array[0]->pathDeltaTime = calloc(1, sizeof(EI1_PathDeltaTime_t));
|
|
|
|
|
*ph->list.array[0]->pathDeltaTime = (itss_time_get() - path_history[0]->ts) / 10;
|
|
|
|
|
|
|
|
|
|
for (int i = 1; i < path_history_len; ++i) {
|
|
|
|
|
ph->list.array[i] = calloc(1, sizeof(EI1_PathPoint_t));
|
|
|
|
|
|
|
|
|
|
if (path_history[i]->alt != EI1_AltitudeValue_unavailable && path_history[i - 1]->alt != EI1_AltitudeValue_unavailable) {
|
|
|
|
|
ph->list.array[i]->pathPosition.deltaAltitude = path_history[i]->alt - path_history[i - 1]->alt;
|
|
|
|
|
} else {
|
|
|
|
|
ph->list.array[i]->pathPosition.deltaAltitude = EI1_DeltaAltitude_unavailable;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (path_history[i]->lat != EI1_Latitude_unavailable && path_history[i - 1]->lat != EI1_Latitude_unavailable) {
|
|
|
|
|
ph->list.array[i]->pathPosition.deltaLatitude = path_history[i]->lat - path_history[i - 1]->lat;
|
|
|
|
|
} else {
|
|
|
|
|
ph->list.array[i]->pathPosition.deltaLatitude = EI1_DeltaLatitude_unavailable;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (path_history[i]->lon != EI1_Longitude_unavailable && path_history[i - 1]->lon != EI1_Longitude_unavailable) {
|
|
|
|
|
ph->list.array[i]->pathPosition.deltaLongitude = path_history[i]->lon - path_history[i - 1]->lon;
|
|
|
|
|
} else {
|
|
|
|
|
ph->list.array[i]->pathPosition.deltaLongitude = EI1_DeltaLongitude_unavailable;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ph->list.array[i]->pathDeltaTime = calloc(1, sizeof(EI1_PathDeltaTime_t));
|
|
|
|
|
*ph->list.array[i]->pathDeltaTime = (path_history[i - 1]->ts - path_history[i]->ts) / 10;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
pthread_mutex_unlock(&facilities.lightship.lock);
|
|
|
|
|
switch (frm->itsMessageType) {
|
|
|
|
|
case EIS_ItsMessageType_denm:
|
|
|
|
|
managed_msg = true;
|
|
|
|
|
uint8_t event_type = event_manage(its_msg, &id, NULL, 0);
|
|
|
|
|
// Do not free its_msg! event_manage takes care of the msg
|
|
|
|
|
// id will get set to another val if EVENT NEW or UPDATE or CANCELLATION or NEGATION
|
|
|
|
|
if (event_type != EVENT_NEW &&
|
|
|
|
|
event_type != EVENT_UPDATE &&
|
|
|
|
|
event_type != EVENT_CANCELLATION &&
|
|
|
|
|
event_type != EVENT_NEGATION) {
|
|
|
|
|
fwd = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// get, set retransmission, duration
|
|
|
|
|
if (((EI1_DENM_t *)its_msg)->denm.management.transmissionInterval) {
|
|
|
|
|
transmission_interval = *((uint32_t *)((EI1_DENM_t *)its_msg)->denm.management.transmissionInterval);
|
|
|
|
|
if (event_type == EVENT_UPDATE ||
|
|
|
|
|
event_type == EVENT_CANCELLATION ||
|
|
|
|
|
event_type == EVENT_NEGATION) {
|
|
|
|
|
is_update = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (((EI1_DENM_t *)its_msg)->denm.management.validityDuration) {
|
|
|
|
|
transmission_duration = *((uint32_t *)((EI1_DENM_t *)its_msg)->denm.management.validityDuration) * 1000;
|
|
|
|
|
if (fwd) {
|
|
|
|
|
// set stationID
|
|
|
|
|
pthread_mutex_lock(&facilities.id.lock);
|
|
|
|
|
((EI1_DENM_t *)its_msg)->header.stationID = facilities.id.station_id;
|
|
|
|
|
pthread_mutex_unlock(&facilities.id.lock);
|
|
|
|
|
|
|
|
|
|
// Set only one trace
|
|
|
|
|
if (facilities.station_type != 15) {
|
|
|
|
|
pthread_mutex_lock(&facilities.lightship.lock);
|
|
|
|
|
if (facilities.lightship.path_history_len > 0) {
|
|
|
|
|
if (!((EI1_DENM_t *)its_msg)->denm.location) {
|
|
|
|
|
((EI1_DENM_t *)its_msg)->denm.location = calloc(1, sizeof(EI1_LocationContainer_t));
|
|
|
|
|
}
|
|
|
|
|
((EI1_DENM_t *)its_msg)->denm.location->traces.list.count = 1;
|
|
|
|
|
((EI1_DENM_t *)its_msg)->denm.location->traces.list.size = 1 * sizeof(void *);
|
|
|
|
|
((EI1_DENM_t *)its_msg)->denm.location->traces.list.array = malloc(1 * sizeof(void *));
|
|
|
|
|
((EI1_DENM_t *)its_msg)->denm.location->traces.list.array[0] = calloc(1, sizeof(EI1_PathHistory_t));
|
|
|
|
|
EI1_PathHistory_t *ph = ((EI1_DENM_t *)its_msg)->denm.location->traces.list.array[0];
|
|
|
|
|
|
|
|
|
|
pos_point_t **path_history = facilities.lightship.path_history;
|
|
|
|
|
uint16_t path_history_len = facilities.lightship.path_history_len;
|
|
|
|
|
|
|
|
|
|
ph->list.array = malloc((path_history_len) * sizeof(void *));
|
|
|
|
|
ph->list.count = path_history_len;
|
|
|
|
|
ph->list.size = (path_history_len) * sizeof(void *);
|
|
|
|
|
|
|
|
|
|
ph->list.array[0] = calloc(1, sizeof(EI1_PathPoint_t));
|
|
|
|
|
|
|
|
|
|
itss_space_lock();
|
|
|
|
|
if (path_history[0]->alt != EI1_AltitudeValue_unavailable && epv.space.altitude != EI1_AltitudeValue_unavailable) {
|
|
|
|
|
ph->list.array[0]->pathPosition.deltaAltitude = path_history[0]->alt - epv.space.altitude;
|
|
|
|
|
} else {
|
|
|
|
|
ph->list.array[0]->pathPosition.deltaAltitude = EI1_DeltaAltitude_unavailable;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (path_history[0]->lat != EI1_Latitude_unavailable && epv.space.latitude != EI1_Latitude_unavailable) {
|
|
|
|
|
ph->list.array[0]->pathPosition.deltaLatitude = path_history[0]->lat - epv.space.latitude;
|
|
|
|
|
} else {
|
|
|
|
|
ph->list.array[0]->pathPosition.deltaLatitude = EI1_DeltaLatitude_unavailable;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (path_history[0]->lon != EI1_Longitude_unavailable && epv.space.longitude != EI1_Longitude_unavailable) {
|
|
|
|
|
ph->list.array[0]->pathPosition.deltaLongitude = path_history[0]->lon - epv.space.longitude;
|
|
|
|
|
} else {
|
|
|
|
|
ph->list.array[0]->pathPosition.deltaLongitude = EI1_DeltaLongitude_unavailable;
|
|
|
|
|
}
|
|
|
|
|
itss_space_unlock();
|
|
|
|
|
|
|
|
|
|
ph->list.array[0]->pathDeltaTime = calloc(1, sizeof(EI1_PathDeltaTime_t));
|
|
|
|
|
*ph->list.array[0]->pathDeltaTime = (itss_time_get() - path_history[0]->ts) / 10;
|
|
|
|
|
|
|
|
|
|
for (int i = 1; i < path_history_len; ++i) {
|
|
|
|
|
ph->list.array[i] = calloc(1, sizeof(EI1_PathPoint_t));
|
|
|
|
|
|
|
|
|
|
if (path_history[i]->alt != EI1_AltitudeValue_unavailable && path_history[i - 1]->alt != EI1_AltitudeValue_unavailable) {
|
|
|
|
|
ph->list.array[i]->pathPosition.deltaAltitude = path_history[i]->alt - path_history[i - 1]->alt;
|
|
|
|
|
} else {
|
|
|
|
|
ph->list.array[i]->pathPosition.deltaAltitude = EI1_DeltaAltitude_unavailable;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (path_history[i]->lat != EI1_Latitude_unavailable && path_history[i - 1]->lat != EI1_Latitude_unavailable) {
|
|
|
|
|
ph->list.array[i]->pathPosition.deltaLatitude = path_history[i]->lat - path_history[i - 1]->lat;
|
|
|
|
|
} else {
|
|
|
|
|
ph->list.array[i]->pathPosition.deltaLatitude = EI1_DeltaLatitude_unavailable;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (path_history[i]->lon != EI1_Longitude_unavailable && path_history[i - 1]->lon != EI1_Longitude_unavailable) {
|
|
|
|
|
ph->list.array[i]->pathPosition.deltaLongitude = path_history[i]->lon - path_history[i - 1]->lon;
|
|
|
|
|
} else {
|
|
|
|
|
ph->list.array[i]->pathPosition.deltaLongitude = EI1_DeltaLongitude_unavailable;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ph->list.array[i]->pathDeltaTime = calloc(1, sizeof(EI1_PathDeltaTime_t));
|
|
|
|
|
*ph->list.array[i]->pathDeltaTime = (path_history[i - 1]->ts - path_history[i]->ts) / 10;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
pthread_mutex_unlock(&facilities.lightship.lock);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// get, set retransmission, duration
|
|
|
|
|
if (((EI1_DENM_t *)its_msg)->denm.management.transmissionInterval) {
|
|
|
|
|
transmission_interval = *((uint32_t *)((EI1_DENM_t *)its_msg)->denm.management.transmissionInterval);
|
|
|
|
|
|
|
|
|
|
if (((EI1_DENM_t *)its_msg)->denm.management.validityDuration) {
|
|
|
|
|
transmission_duration = *((uint32_t *)((EI1_DENM_t *)its_msg)->denm.management.validityDuration) * 1000;
|
|
|
|
|
} else {
|
|
|
|
|
transmission_duration = 600 * 1000;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case EIS_ItsMessageType_ivim:
|
|
|
|
|
managed_msg = true;
|
|
|
|
|
uint8_t service_type = service_eval(SERVICE_IVI, its_msg, &id, NULL, 0);
|
|
|
|
|
|
|
|
|
|
if (service_type != SERVICE_NEW &&
|
|
|
|
|
service_type != SERVICE_UPDATE &&
|
|
|
|
|
service_type != SERVICE_CANCELLATION &&
|
|
|
|
|
service_type != SERVICE_NEGATION) {
|
|
|
|
|
fwd = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (service_type == SERVICE_UPDATE ||
|
|
|
|
|
service_type == SERVICE_CANCELLATION ||
|
|
|
|
|
service_type == SERVICE_NEGATION) {
|
|
|
|
|
is_update = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (fwd) {
|
|
|
|
|
uint64_t valid_to, valid_from;
|
|
|
|
|
|
|
|
|
|
if (!((EI1_IVIM_t *)its_msg)->ivi.mandatory.validFrom) {
|
|
|
|
|
valid_from = itss_time_get();
|
|
|
|
|
} else {
|
|
|
|
|
transmission_duration = 600 * 1000;
|
|
|
|
|
asn_INTEGER2ulong((INTEGER_t *)((EI1_IVIM_t *)its_msg)->ivi.mandatory.validFrom, (unsigned long long *)&valid_from);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!((EI1_IVIM_t *)its_msg)->ivi.mandatory.validTo) {
|
|
|
|
|
valid_to = valid_from + facilities.infrastructure.default_service_duration;
|
|
|
|
|
} else {
|
|
|
|
|
asn_INTEGER2ulong((INTEGER_t *)((EI1_IVIM_t *)its_msg)->ivi.mandatory.validTo, (unsigned long long *)&valid_to);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
transmission_start = valid_from;
|
|
|
|
|
transmission_interval = facilities.infrastructure.replay_interval;
|
|
|
|
|
transmission_duration = valid_to - valid_from;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
} else if (frm->itsMessageType == EIS_ItsMessageType_ivim) {
|
|
|
|
|
managed_msg = true;
|
|
|
|
|
|
|
|
|
|
uint8_t service_type = service_eval(SERVICE_IVI, its_msg, &id, NULL, 0);
|
|
|
|
|
|
|
|
|
|
if (service_type != SERVICE_NEW &&
|
|
|
|
|
service_type != SERVICE_UPDATE &&
|
|
|
|
|
service_type != SERVICE_CANCELLATION &&
|
|
|
|
|
service_type != SERVICE_NEGATION) {
|
|
|
|
|
fwd = false;
|
|
|
|
|
if (!facilities.replay) {
|
|
|
|
|
transmission_interval = 0;
|
|
|
|
|
transmission_duration = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (service_type == SERVICE_UPDATE ||
|
|
|
|
|
service_type == SERVICE_CANCELLATION ||
|
|
|
|
|
service_type == SERVICE_NEGATION) {
|
|
|
|
|
is_update = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (fwd) {
|
|
|
|
|
uint64_t valid_to, valid_from;
|
|
|
|
|
|
|
|
|
|
if (!((EI1_IVIM_t *)its_msg)->ivi.mandatory.validFrom) {
|
|
|
|
|
valid_from = itss_time_get();
|
|
|
|
|
} else {
|
|
|
|
|
asn_INTEGER2ulong((INTEGER_t *)((EI1_IVIM_t *)its_msg)->ivi.mandatory.validFrom, (unsigned long long *)&valid_from);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!((EI1_IVIM_t *)its_msg)->ivi.mandatory.validTo) {
|
|
|
|
|
valid_to = valid_from + facilities.infrastructure.default_service_duration;
|
|
|
|
|
} else {
|
|
|
|
|
asn_INTEGER2ulong((INTEGER_t *)((EI1_IVIM_t *)its_msg)->ivi.mandatory.validTo, (unsigned long long *)&valid_to);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
transmission_start = valid_from;
|
|
|
|
|
transmission_interval = facilities.infrastructure.replay_interval;
|
|
|
|
|
transmission_duration = valid_to - valid_from;
|
|
|
|
|
}
|
|
|
|
|
} else if (frm->itsMessageType == EIS_ItsMessageType_evrsr) {
|
|
|
|
|
managed_msg = true;
|
|
|
|
|
}
|
|
|
|
|
if (!facilities.replay) {
|
|
|
|
|
transmission_interval = 0;
|
|
|
|
|
transmission_duration = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Respond to [applications]
|
|
|
|
|
@ -327,15 +337,21 @@ int facilities_request_single_message(void *responder, EIS_FacilitiesMessageRequ
|
|
|
|
|
npr->transport.choice.btp.btpType = EIS_BTPType_btpB;
|
|
|
|
|
|
|
|
|
|
npr->id = id;
|
|
|
|
|
|
|
|
|
|
npr->data.buf = malloc(2048);
|
|
|
|
|
asn_enc_rval_t enc = uper_encode_to_buffer(its_msg_def, NULL, its_msg, npr->data.buf, 2048);
|
|
|
|
|
if (enc.encoded == -1) {
|
|
|
|
|
log_error("failed encoding ITS message into UPER (%s)", enc.failed_type->name);
|
|
|
|
|
rv = 1;
|
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
|
|
asn_enc_rval_t enc;
|
|
|
|
|
if (process_msg) {
|
|
|
|
|
enc = uper_encode_to_buffer(its_msg_def, NULL, its_msg, npr->data.buf, 2048);
|
|
|
|
|
if (enc.encoded == -1) {
|
|
|
|
|
log_error("failed encoding ITS message into UPER (%s)", enc.failed_type->name);
|
|
|
|
|
rv = 1;
|
|
|
|
|
goto cleanup;
|
|
|
|
|
}
|
|
|
|
|
npr->data.size = (enc.encoded + 7) / 8;
|
|
|
|
|
} else {
|
|
|
|
|
memcpy(npr->data.buf, frm->data.buf, frm->data.size);
|
|
|
|
|
npr->data.size = frm->data.size;
|
|
|
|
|
}
|
|
|
|
|
npr->data.size = (enc.encoded + 7) / 8;
|
|
|
|
|
|
|
|
|
|
npr->network.choice.gn.destinationAddress.buf = malloc(6);
|
|
|
|
|
for (int i = 0; i < 6; ++i)
|
|
|
|
|
@ -641,6 +657,7 @@ static int networking_packet_indication_btp(EIS_NetworkingPacketIndication_t* np
|
|
|
|
|
|
|
|
|
|
bool fwd = false;
|
|
|
|
|
bool stored = false;
|
|
|
|
|
bool process_msg = true;
|
|
|
|
|
|
|
|
|
|
uint16_t buf_len = 2048;
|
|
|
|
|
uint8_t buf[buf_len];
|
|
|
|
|
@ -704,150 +721,158 @@ static int networking_packet_indication_btp(EIS_NetworkingPacketIndication_t* np
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
log_debug("messsage with unhandled BTP port received (%lld), ignoring", bpi->destinationPort);
|
|
|
|
|
if (!facilities.upf) {
|
|
|
|
|
log_debug("messsage with unhandled BTP port received (%lld), ignoring", bpi->destinationPort);
|
|
|
|
|
goto cleanup;
|
|
|
|
|
} else {
|
|
|
|
|
process_msg = false;
|
|
|
|
|
fwd = true;
|
|
|
|
|
its_msg_type = 7120;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (process_msg) {
|
|
|
|
|
asn_dec_rval_t dec = uper_decode_complete(NULL, its_msg_descriptor, (void **)&its_msg, npi->data.buf, npi->data.size);
|
|
|
|
|
if (dec.code) {
|
|
|
|
|
log_debug("<- invalid %s received", its_msg_descriptor->name);
|
|
|
|
|
rv = 1;
|
|
|
|
|
goto cleanup;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
asn_dec_rval_t dec = uper_decode_complete(NULL, its_msg_descriptor, (void **)&its_msg, npi->data.buf, npi->data.size);
|
|
|
|
|
if (dec.code) {
|
|
|
|
|
log_debug("<- invalid %s received", its_msg_descriptor->name);
|
|
|
|
|
rv = 1;
|
|
|
|
|
goto cleanup;
|
|
|
|
|
}
|
|
|
|
|
// Get permisisons
|
|
|
|
|
uint8_t *ssp = NULL;
|
|
|
|
|
uint16_t ssp_len;
|
|
|
|
|
uint8_t* neighbour_cert = NULL;
|
|
|
|
|
|
|
|
|
|
// Get permisisons
|
|
|
|
|
uint8_t *ssp = NULL;
|
|
|
|
|
uint16_t ssp_len;
|
|
|
|
|
uint8_t* neighbour_cert = NULL;
|
|
|
|
|
switch (npi->network.present) {
|
|
|
|
|
case EIS_NetworkingPacketRequestNW_PR_gn:
|
|
|
|
|
if (npi->network.choice.gn.securityPermissions) {
|
|
|
|
|
ssp = npi->network.choice.gn.securityPermissions->ssp.buf;
|
|
|
|
|
ssp_len = npi->network.choice.gn.securityPermissions->ssp.size;
|
|
|
|
|
}
|
|
|
|
|
if (npi->network.choice.gn.securityNeighbour) {
|
|
|
|
|
neighbour_cert = npi->network.choice.gn.securityNeighbour->buf;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case EIS_NetworkingPacketRequestNW_PR_gn6a:
|
|
|
|
|
if (npi->network.choice.gn6a.gn.securityPermissions) {
|
|
|
|
|
ssp = npi->network.choice.gn6a.gn.securityPermissions->ssp.buf;
|
|
|
|
|
ssp_len = npi->network.choice.gn6a.gn.securityPermissions->ssp.size;
|
|
|
|
|
}
|
|
|
|
|
if (npi->network.choice.gn6a.gn.securityNeighbour) {
|
|
|
|
|
neighbour_cert = npi->network.choice.gn6a.gn.securityNeighbour->buf;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (npi->network.present) {
|
|
|
|
|
case EIS_NetworkingPacketRequestNW_PR_gn:
|
|
|
|
|
if (npi->network.choice.gn.securityPermissions) {
|
|
|
|
|
ssp = npi->network.choice.gn.securityPermissions->ssp.buf;
|
|
|
|
|
ssp_len = npi->network.choice.gn.securityPermissions->ssp.size;
|
|
|
|
|
}
|
|
|
|
|
if (npi->network.choice.gn.securityNeighbour) {
|
|
|
|
|
neighbour_cert = npi->network.choice.gn.securityNeighbour->buf;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case EIS_NetworkingPacketRequestNW_PR_gn6a:
|
|
|
|
|
if (npi->network.choice.gn6a.gn.securityPermissions) {
|
|
|
|
|
ssp = npi->network.choice.gn6a.gn.securityPermissions->ssp.buf;
|
|
|
|
|
ssp_len = npi->network.choice.gn6a.gn.securityPermissions->ssp.size;
|
|
|
|
|
}
|
|
|
|
|
if (npi->network.choice.gn6a.gn.securityNeighbour) {
|
|
|
|
|
neighbour_cert = npi->network.choice.gn6a.gn.securityNeighbour->buf;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
// Manage message
|
|
|
|
|
switch (bpi->destinationPort) {
|
|
|
|
|
case EIS_Port_cam:
|
|
|
|
|
switch (check_cam(bpi, its_msg, ssp, ssp_len)) {
|
|
|
|
|
case CAM_OK:
|
|
|
|
|
fwd = true;
|
|
|
|
|
break;
|
|
|
|
|
case CAM_INVALID:
|
|
|
|
|
case CAM_BAD_PERMISSIONS:
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
// Manage message
|
|
|
|
|
switch (bpi->destinationPort) {
|
|
|
|
|
case EIS_Port_cam:
|
|
|
|
|
switch (check_cam(bpi, its_msg, ssp, ssp_len)) {
|
|
|
|
|
case CAM_OK:
|
|
|
|
|
fwd = true;
|
|
|
|
|
break;
|
|
|
|
|
case CAM_INVALID:
|
|
|
|
|
case CAM_BAD_PERMISSIONS:
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case EIS_Port_denm:
|
|
|
|
|
case EIS_Port_denm:
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
uint8_t *xml_denm = malloc(32768);
|
|
|
|
|
asn_enc_rval_t rve = xer_encode_to_buffer(xml_denm, 32768, 0x02, &asn_DEF_DENM, its_msg);
|
|
|
|
|
log_debug("DENM XER %d: %.*s", (int)rve.encoded, (int)rve.encoded, xml_denm);
|
|
|
|
|
free(xml_denm);
|
|
|
|
|
uint8_t *xml_denm = malloc(32768);
|
|
|
|
|
asn_enc_rval_t rve = xer_encode_to_buffer(xml_denm, 32768, 0x02, &asn_DEF_EI1_DENM, its_msg);
|
|
|
|
|
log_debug("DENM XER %d: %.*s", (int)rve.encoded, (int)rve.encoded, xml_denm);
|
|
|
|
|
free(xml_denm);
|
|
|
|
|
#endif
|
|
|
|
|
stored = true;
|
|
|
|
|
switch (event_manage(its_msg, &id, ssp, ssp_len)) {
|
|
|
|
|
case EVENT_NEW:
|
|
|
|
|
case EVENT_CANCELLATION:
|
|
|
|
|
case EVENT_NEGATION:
|
|
|
|
|
case EVENT_UPDATE:
|
|
|
|
|
case EVENT_NUMBER_EXCEEDED:
|
|
|
|
|
fwd = true;
|
|
|
|
|
break;
|
|
|
|
|
case EVENT_INVALID:
|
|
|
|
|
case EVENT_PASSED:
|
|
|
|
|
case EVENT_REPEATED:
|
|
|
|
|
case EVENT_BAD_PERMISSIONS:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
stored = true;
|
|
|
|
|
switch (event_manage(its_msg, &id, ssp, ssp_len)) {
|
|
|
|
|
case EVENT_NEW:
|
|
|
|
|
case EVENT_CANCELLATION:
|
|
|
|
|
case EVENT_NEGATION:
|
|
|
|
|
case EVENT_UPDATE:
|
|
|
|
|
case EVENT_NUMBER_EXCEEDED:
|
|
|
|
|
fwd = true;
|
|
|
|
|
break;
|
|
|
|
|
case EVENT_INVALID:
|
|
|
|
|
case EVENT_PASSED:
|
|
|
|
|
case EVENT_REPEATED:
|
|
|
|
|
case EVENT_BAD_PERMISSIONS:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case EIS_Port_ivim:
|
|
|
|
|
stored = true;
|
|
|
|
|
switch (service_eval(SERVICE_IVI, its_msg, &id, ssp, ssp_len)) {
|
|
|
|
|
case SERVICE_NEW:
|
|
|
|
|
case SERVICE_CANCELLATION:
|
|
|
|
|
case SERVICE_NEGATION:
|
|
|
|
|
case SERVICE_UPDATE:
|
|
|
|
|
case SERVICE_NUMBER_EXCEEDED:
|
|
|
|
|
fwd = true;
|
|
|
|
|
break;
|
|
|
|
|
case SERVICE_INVALID:
|
|
|
|
|
case SERVICE_REPEATED:
|
|
|
|
|
case SERVICE_PASSED:
|
|
|
|
|
case SERVICE_BAD_PERMISSIONS:
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case EIS_Port_ivim:
|
|
|
|
|
stored = true;
|
|
|
|
|
switch (service_eval(SERVICE_IVI, its_msg, &id, ssp, ssp_len)) {
|
|
|
|
|
case SERVICE_NEW:
|
|
|
|
|
case SERVICE_CANCELLATION:
|
|
|
|
|
case SERVICE_NEGATION:
|
|
|
|
|
case SERVICE_UPDATE:
|
|
|
|
|
case SERVICE_NUMBER_EXCEEDED:
|
|
|
|
|
fwd = true;
|
|
|
|
|
break;
|
|
|
|
|
case SERVICE_INVALID:
|
|
|
|
|
case SERVICE_REPEATED:
|
|
|
|
|
case SERVICE_PASSED:
|
|
|
|
|
case SERVICE_BAD_PERMISSIONS:
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case EIS_Port_saem:
|
|
|
|
|
switch (saem_check(its_msg, neighbour_cert)) {
|
|
|
|
|
case SAEM_NEW:
|
|
|
|
|
fwd = true;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case EIS_Port_saem:
|
|
|
|
|
switch (saem_check(its_msg, neighbour_cert)) {
|
|
|
|
|
case SAEM_NEW:
|
|
|
|
|
fwd = true;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 7011:
|
|
|
|
|
if (facilities.tolling.protocol.p == TOLLING_PROTOCOL_GN_SPKI) { /* do not wait for facilities process if spki */
|
|
|
|
|
case 7011:
|
|
|
|
|
if (facilities.tolling.protocol.p == TOLLING_PROTOCOL_GN_SPKI) { /* do not wait for facilities process if spki */
|
|
|
|
|
fwd_to_apps(npi->data.buf, npi->data.size, bpi->destinationPort, npi->id);
|
|
|
|
|
fwd = false;
|
|
|
|
|
} else {
|
|
|
|
|
fwd = true;
|
|
|
|
|
}
|
|
|
|
|
if (facilities.tolling.enabled) {
|
|
|
|
|
tpm_recv(its_msg, security_socket, neighbour_cert, NULL);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 2043:
|
|
|
|
|
fwd_to_apps(npi->data.buf, npi->data.size, bpi->destinationPort, npi->id);
|
|
|
|
|
fwd = false;
|
|
|
|
|
} else {
|
|
|
|
|
fwd = true;
|
|
|
|
|
}
|
|
|
|
|
if (facilities.tolling.enabled) {
|
|
|
|
|
tpm_recv(its_msg, security_socket, neighbour_cert, NULL);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
if (facilities.coordination.active) {
|
|
|
|
|
vcm_check(its_msg);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 2043:
|
|
|
|
|
fwd_to_apps(npi->data.buf, npi->data.size, bpi->destinationPort, npi->id);
|
|
|
|
|
fwd = false;
|
|
|
|
|
if (facilities.coordination.active) {
|
|
|
|
|
vcm_check(its_msg);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case EIS_Port_poi:
|
|
|
|
|
if (facilities.evm_args.activate) {
|
|
|
|
|
evcsnm_check(its_msg);
|
|
|
|
|
fwd = true;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case EIS_Port_poi:
|
|
|
|
|
if (facilities.evm_args.activate) {
|
|
|
|
|
evcsnm_check(its_msg);
|
|
|
|
|
fwd = true;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case EIS_Port_evrsr:
|
|
|
|
|
if (facilities.evm_args.activate) {
|
|
|
|
|
evrsrm_check(its_msg);
|
|
|
|
|
fwd = true;
|
|
|
|
|
EI1_EV_RSR_t *evrsr_request = (EI1_EV_RSR_t *)its_msg;
|
|
|
|
|
evrsrm_recv(evrsr_request);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case EIS_Port_evrsr:
|
|
|
|
|
if (facilities.evm_args.activate) {
|
|
|
|
|
evrsrm_check(its_msg);
|
|
|
|
|
fwd = true;
|
|
|
|
|
EI1_EV_RSR_t *evrsr_request = (EI1_EV_RSR_t *)its_msg;
|
|
|
|
|
evrsrm_recv(evrsr_request);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Forward to [applications]
|
|
|
|
|
@ -1093,3 +1118,4 @@ int networking_packet_indication(EIS_NetworkingPacketIndication_t* npi, void** s
|
|
|
|
|
cleanup:
|
|
|
|
|
return rv;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|