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:
if (!facilities.upf) {
log_error("unrecognized FR message type (%lld)", frm->itsMessageType); log_error("unrecognized FR message type (%lld)", frm->itsMessageType);
facilities_request_result_rejected(responder); facilities_request_result_rejected(responder);
rv = 1; rv = 1;
goto cleanup; 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;
} }
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;
} }
uint64_t id = 0; uint64_t id = 0;
@ -163,11 +162,20 @@ 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;
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;
}
switch (frm->itsMessageType) {
case EIS_ItsMessageType_denm:
managed_msg = true;
uint8_t event_type = event_manage(its_msg, &id, NULL, 0); uint8_t event_type = event_manage(its_msg, &id, NULL, 0);
// Do not free its_msg! event_manage takes care of the msg // 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 // id will get set to another val if EVENT NEW or UPDATE or CANCELLATION or NEGATION
@ -274,9 +282,9 @@ int facilities_request_single_message(void *responder, EIS_FacilitiesMessageRequ
} }
} }
} }
} else if (frm->itsMessageType == EIS_ItsMessageType_ivim) { break;
case EIS_ItsMessageType_ivim:
managed_msg = true; managed_msg = true;
uint8_t service_type = service_eval(SERVICE_IVI, its_msg, &id, NULL, 0); uint8_t service_type = service_eval(SERVICE_IVI, its_msg, &id, NULL, 0);
if (service_type != SERVICE_NEW && if (service_type != SERVICE_NEW &&
@ -311,13 +319,15 @@ int facilities_request_single_message(void *responder, EIS_FacilitiesMessageRequ
transmission_interval = facilities.infrastructure.replay_interval; transmission_interval = facilities.infrastructure.replay_interval;
transmission_duration = valid_to - valid_from; transmission_duration = valid_to - valid_from;
} }
} else if (frm->itsMessageType == EIS_ItsMessageType_evrsr) { break;
managed_msg = true; default:
break;
} }
if (!facilities.replay) { if (!facilities.replay) {
transmission_interval = 0; transmission_interval = 0;
transmission_duration = 0; transmission_duration = 0;
} }
}
// Respond to [applications] // Respond to [applications]
facilities_request_result_accepted(responder); facilities_request_result_accepted(responder);
@ -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);
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) { if (enc.encoded == -1) {
log_error("failed encoding ITS message into UPER (%s)", enc.failed_type->name); log_error("failed encoding ITS message into UPER (%s)", enc.failed_type->name);
rv = 1; rv = 1;
goto cleanup; goto cleanup;
} }
npr->data.size = (enc.encoded + 7) / 8; 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->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,10 +721,17 @@ static int networking_packet_indication_btp(EIS_NetworkingPacketIndication_t* np
break; break;
default: default:
if (!facilities.upf) {
log_debug("messsage with unhandled BTP port received (%lld), ignoring", bpi->destinationPort); log_debug("messsage with unhandled BTP port received (%lld), ignoring", bpi->destinationPort);
goto cleanup; 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); asn_dec_rval_t dec = uper_decode_complete(NULL, its_msg_descriptor, (void **)&its_msg, npi->data.buf, npi->data.size);
if (dec.code) { if (dec.code) {
log_debug("<- invalid %s received", its_msg_descriptor->name); log_debug("<- invalid %s received", its_msg_descriptor->name);
@ -760,7 +784,7 @@ static int networking_packet_indication_btp(EIS_NetworkingPacketIndication_t* np
case EIS_Port_denm: 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
@ -849,6 +873,7 @@ static int networking_packet_indication_btp(EIS_NetworkingPacketIndication_t* np
default: default:
break; break;
} }
}
// Forward to [applications] // Forward to [applications]
if (fwd) { if (fwd) {
@ -1093,3 +1118,4 @@ int networking_packet_indication(EIS_NetworkingPacketIndication_t* npi, void** s
cleanup: cleanup:
return rv; return rv;
} }