Merge remote-tracking branch 'refs/remotes/origin/master'

This commit is contained in:
emanuel 2024-01-25 15:50:31 +00:00
commit 711c61f6ca
7 changed files with 328 additions and 317 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
**/*.swp **/*.swp
**/build **/build
**/.ycm_extra_conf.py **/.ycm_extra_conf.py
**/.vscode

View File

@ -30,11 +30,13 @@ stages:
deploy release: deploy release:
stage: deploy release stage: deploy release
script: script:
- curl -fs http://192.168.94.221:3000/arch/it2s-itss-facilities-git - curl -fs http://192.168.94.221:3000/archlinux/x86/it2s-itss-facilities-git
- curl -fs http://192.168.94.221:3000/ubuntu_arm64/it2s-itss-facilities-git - curl -fs http://192.168.94.221:3000/ubuntu/focal/arm64/it2s-itss-facilities-git
- curl -fs http://192.168.94.221:3000/ubuntu/mantic/amd64/it2s-itss-facilities-git
deploy debug: deploy debug:
stage: deploy debug stage: deploy debug
script: script:
- curl -fs http://192.168.94.221:3000/arch/it2s-itss-facilities-debug-git - curl -fs http://192.168.94.221:3000/archlinux/x86/it2s-itss-facilities-debug-git
- curl -fs http://192.168.94.221:3000/ubuntu_arm64/it2s-itss-facilities-debug-git - curl -fs http://192.168.94.221:3000/ubuntu/focal/arm64/it2s-itss-facilities-debug-git
- curl -fs http://192.168.94.221:3000/ubuntu/mantic/amd64/it2s-itss-facilities-debug-git

19
.vscode/settings.json vendored
View File

@ -1,19 +0,0 @@
{
"files.associations": {
"prereservation-id.h": "c",
"constr_sequence.h": "c",
"array": "c",
"string_view": "c",
"initializer_list": "c",
"nativeenumerated.h": "c",
"asn_application.h": "c",
"timestamputc.h": "c",
"availabilitystatus.h": "c",
"chargingspotlabel.h": "c",
"reservation-id.h": "c",
"stationdetails.h": "c",
"managementrequest.h": "c",
"facilities.h": "c",
"cancellationresponsecode.h": "c"
}
}

View File

@ -386,6 +386,9 @@ int facilities_config() {
// Replay // Replay
facilities.replay = etsi_its_cfg->networking.replay.activate; facilities.replay = etsi_its_cfg->networking.replay.activate;
// Forward unknown packets (in-stack)
facilities.upf = etsi_its_cfg->general.unknown_packet_forwarding;
// PZ // PZ
if (facilities.station_type == 15) { if (facilities.station_type == 15) {

View File

@ -89,6 +89,7 @@ typedef struct facilities {
int station_type; int station_type;
bool use_security; bool use_security;
bool replay; bool replay;
bool upf;
struct { struct {
uint16_t width; uint16_t width;

View File

@ -1,11 +1,8 @@
#include "infrastructure.h" #include "infrastructure.h"
#include "facilities.h" #include "facilities.h"
#include <unistd.h> #include <unistd.h>
#include <it2s-tender/space.h> #include <it2s-tender/space.h>
#include <it2s-tender/time.h> #include <it2s-tender/time.h>
#include <it2s-asn/etsi-its-v1/ivi-1/EI1_ISO14823Code.h> #include <it2s-asn/etsi-its-v1/ivi-1/EI1_ISO14823Code.h>
static const ivi_diid_ssp_bm_t DIID_SSP_BM_MAP[] = { static const ivi_diid_ssp_bm_t DIID_SSP_BM_MAP[] = {

View File

@ -93,6 +93,7 @@ int facilities_request_single_message(void *responder, EIS_FacilitiesMessageRequ
asn_TYPE_descriptor_t *its_msg_def = NULL; asn_TYPE_descriptor_t *its_msg_def = NULL;
bool fwd = true; bool fwd = true;
bool process_msg = true;
uint64_t transmission_duration = 0; uint64_t transmission_duration = 0;
uint32_t transmission_interval = 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->transport.choice.btp.destinationPort = EIS_Port_ivim;
npr->network.choice.gn.packetTransportType = EIS_PacketTransportType_shb; npr->network.choice.gn.packetTransportType = EIS_PacketTransportType_shb;
npr->network.choice.gn.trafficClass = 1; npr->network.choice.gn.trafficClass = 1;
break; break;
case EIS_ItsMessageType_cpm: case EIS_ItsMessageType_cpm:
@ -141,18 +141,17 @@ int facilities_request_single_message(void *responder, EIS_FacilitiesMessageRequ
break; break;
default: default:
log_error("unrecognized FR message type (%lld)", frm->itsMessageType); if (!facilities.upf) {
facilities_request_result_rejected(responder); log_error("unrecognized FR message type (%lld)", frm->itsMessageType);
rv = 1; facilities_request_result_rejected(responder);
goto cleanup; rv = 1;
} goto cleanup;
} else {
asn_dec_rval_t dec = uper_decode_complete(NULL, its_msg_def, (void **)&its_msg, frm->data.buf, frm->data.size); process_msg = false;
if (dec.code) { npr->transport.choice.btp.destinationPort = 7120;
log_warn("invalid FR %s received", its_msg_def->name); npr->network.choice.gn.packetTransportType = EIS_PacketTransportType_shb;
facilities_request_result_rejected(responder); npr->network.choice.gn.trafficClass = 1;
rv = 1; }
goto cleanup;
} }
uint64_t id = 0; uint64_t id = 0;
@ -163,160 +162,171 @@ int facilities_request_single_message(void *responder, EIS_FacilitiesMessageRequ
} }
bool is_update = false; bool is_update = false;
int managed_msg = 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); if (process_msg) {
// Do not free its_msg! event_manage takes care of the msg asn_dec_rval_t dec = uper_decode_complete(NULL, its_msg_def, (void **)&its_msg, frm->data.buf, frm->data.size);
// id will get set to another val if EVENT NEW or UPDATE or CANCELLATION or NEGATION if (dec.code) {
if (event_type != EVENT_NEW && log_warn("invalid FR %s received", its_msg_def->name);
event_type != EVENT_UPDATE && facilities_request_result_rejected(responder);
event_type != EVENT_CANCELLATION && rv = 1;
event_type != EVENT_NEGATION) { goto cleanup;
fwd = false;
} }
if (event_type == EVENT_UPDATE || switch (frm->itsMessageType) {
event_type == EVENT_CANCELLATION || case EIS_ItsMessageType_denm:
event_type == EVENT_NEGATION) { managed_msg = true;
is_update = 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 (fwd) { if (event_type != EVENT_NEW &&
// set stationID event_type != EVENT_UPDATE &&
pthread_mutex_lock(&facilities.id.lock); event_type != EVENT_CANCELLATION &&
((EI1_DENM_t *)its_msg)->header.stationID = facilities.id.station_id; event_type != EVENT_NEGATION) {
pthread_mutex_unlock(&facilities.id.lock); fwd = false;
// 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 (event_type == EVENT_UPDATE ||
if (((EI1_DENM_t *)its_msg)->denm.management.transmissionInterval) { event_type == EVENT_CANCELLATION ||
transmission_interval = *((uint32_t *)((EI1_DENM_t *)its_msg)->denm.management.transmissionInterval); event_type == EVENT_NEGATION) {
is_update = true;
}
if (((EI1_DENM_t *)its_msg)->denm.management.validityDuration) { if (fwd) {
transmission_duration = *((uint32_t *)((EI1_DENM_t *)its_msg)->denm.management.validityDuration) * 1000; // 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 { } 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) { if (!facilities.replay) {
managed_msg = true; transmission_interval = 0;
transmission_duration = 0;
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 {
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] // 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->transport.choice.btp.btpType = EIS_BTPType_btpB;
npr->id = id; npr->id = id;
npr->data.buf = malloc(2048); 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) { asn_enc_rval_t enc;
log_error("failed encoding ITS message into UPER (%s)", enc.failed_type->name); if (process_msg) {
rv = 1; enc = uper_encode_to_buffer(its_msg_def, NULL, its_msg, npr->data.buf, 2048);
goto cleanup; 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); npr->network.choice.gn.destinationAddress.buf = malloc(6);
for (int i = 0; i < 6; ++i) 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 fwd = false;
bool stored = false; bool stored = false;
bool process_msg = true;
uint16_t buf_len = 2048; uint16_t buf_len = 2048;
uint8_t buf[buf_len]; uint8_t buf[buf_len];
@ -704,150 +721,158 @@ static int networking_packet_indication_btp(EIS_NetworkingPacketIndication_t* np
break; break;
default: 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; goto cleanup;
} }
asn_dec_rval_t dec = uper_decode_complete(NULL, its_msg_descriptor, (void **)&its_msg, npi->data.buf, npi->data.size); // Get permisisons
if (dec.code) { uint8_t *ssp = NULL;
log_debug("<- invalid %s received", its_msg_descriptor->name); uint16_t ssp_len;
rv = 1; uint8_t* neighbour_cert = NULL;
goto cleanup;
}
// Get permisisons switch (npi->network.present) {
uint8_t *ssp = NULL; case EIS_NetworkingPacketRequestNW_PR_gn:
uint16_t ssp_len; if (npi->network.choice.gn.securityPermissions) {
uint8_t* neighbour_cert = NULL; 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) { // Manage message
case EIS_NetworkingPacketRequestNW_PR_gn: switch (bpi->destinationPort) {
if (npi->network.choice.gn.securityPermissions) { case EIS_Port_cam:
ssp = npi->network.choice.gn.securityPermissions->ssp.buf; switch (check_cam(bpi, its_msg, ssp, ssp_len)) {
ssp_len = npi->network.choice.gn.securityPermissions->ssp.size; case CAM_OK:
} fwd = true;
if (npi->network.choice.gn.securityNeighbour) { break;
neighbour_cert = npi->network.choice.gn.securityNeighbour->buf; case CAM_INVALID:
} case CAM_BAD_PERMISSIONS:
break; default:
case EIS_NetworkingPacketRequestNW_PR_gn6a: break;
if (npi->network.choice.gn6a.gn.securityPermissions) { }
ssp = npi->network.choice.gn6a.gn.securityPermissions->ssp.buf; break;
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 case EIS_Port_denm:
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:
#ifdef DEBUG #ifdef DEBUG
uint8_t *xml_denm = malloc(32768); uint8_t *xml_denm = malloc(32768);
asn_enc_rval_t rve = xer_encode_to_buffer(xml_denm, 32768, 0x02, &asn_DEF_DENM, its_msg); 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); log_debug("DENM XER %d: %.*s", (int)rve.encoded, (int)rve.encoded, xml_denm);
free(xml_denm); free(xml_denm);
#endif #endif
stored = true; stored = true;
switch (event_manage(its_msg, &id, ssp, ssp_len)) { switch (event_manage(its_msg, &id, ssp, ssp_len)) {
case EVENT_NEW: case EVENT_NEW:
case EVENT_CANCELLATION: case EVENT_CANCELLATION:
case EVENT_NEGATION: case EVENT_NEGATION:
case EVENT_UPDATE: case EVENT_UPDATE:
case EVENT_NUMBER_EXCEEDED: case EVENT_NUMBER_EXCEEDED:
fwd = true; fwd = true;
break; break;
case EVENT_INVALID: case EVENT_INVALID:
case EVENT_PASSED: case EVENT_PASSED:
case EVENT_REPEATED: case EVENT_REPEATED:
case EVENT_BAD_PERMISSIONS: case EVENT_BAD_PERMISSIONS:
break; break;
} }
break; break;
case EIS_Port_ivim: case EIS_Port_ivim:
stored = true; stored = true;
switch (service_eval(SERVICE_IVI, its_msg, &id, ssp, ssp_len)) { switch (service_eval(SERVICE_IVI, its_msg, &id, ssp, ssp_len)) {
case SERVICE_NEW: case SERVICE_NEW:
case SERVICE_CANCELLATION: case SERVICE_CANCELLATION:
case SERVICE_NEGATION: case SERVICE_NEGATION:
case SERVICE_UPDATE: case SERVICE_UPDATE:
case SERVICE_NUMBER_EXCEEDED: case SERVICE_NUMBER_EXCEEDED:
fwd = true; fwd = true;
break; break;
case SERVICE_INVALID: case SERVICE_INVALID:
case SERVICE_REPEATED: case SERVICE_REPEATED:
case SERVICE_PASSED: case SERVICE_PASSED:
case SERVICE_BAD_PERMISSIONS: case SERVICE_BAD_PERMISSIONS:
default: default:
break; break;
} }
break; break;
case EIS_Port_saem: case EIS_Port_saem:
switch (saem_check(its_msg, neighbour_cert)) { switch (saem_check(its_msg, neighbour_cert)) {
case SAEM_NEW: case SAEM_NEW:
fwd = true; fwd = true;
break; break;
default: default:
break; break;
} }
break; break;
case 7011: case 7011:
if (facilities.tolling.protocol.p == TOLLING_PROTOCOL_GN_SPKI) { /* do not wait for facilities process if spki */ 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_to_apps(npi->data.buf, npi->data.size, bpi->destinationPort, npi->id);
fwd = false; fwd = false;
} else { if (facilities.coordination.active) {
fwd = true; vcm_check(its_msg);
} }
if (facilities.tolling.enabled) { break;
tpm_recv(its_msg, security_socket, neighbour_cert, NULL);
}
break;
case 2043: case EIS_Port_poi:
fwd_to_apps(npi->data.buf, npi->data.size, bpi->destinationPort, npi->id); if (facilities.evm_args.activate) {
fwd = false; evcsnm_check(its_msg);
if (facilities.coordination.active) { fwd = true;
vcm_check(its_msg); }
} break;
break;
case EIS_Port_poi: case EIS_Port_evrsr:
if (facilities.evm_args.activate) { if (facilities.evm_args.activate) {
evcsnm_check(its_msg); evrsrm_check(its_msg);
fwd = true; fwd = true;
} EI1_EV_RSR_t *evrsr_request = (EI1_EV_RSR_t *)its_msg;
break; evrsrm_recv(evrsr_request);
}
break;
case EIS_Port_evrsr: default:
if (facilities.evm_args.activate) { break;
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;
} }
// Forward to [applications] // Forward to [applications]
@ -1093,3 +1118,4 @@ int networking_packet_indication(EIS_NetworkingPacketIndication_t* npi, void** s
cleanup: cleanup:
return rv; return rv;
} }