Enable unknown packet forwarding

This commit is contained in:
emanuelv 2023-12-19 09:08:16 +00:00
parent 8d7b2ac638
commit 3e53b9b08a
3 changed files with 307 additions and 284 deletions

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

@ -93,6 +93,7 @@ int facilities_request_single_message(void *responder, FacilitiesMessageRequest_
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, FacilitiesMessageRequest_
npr->transport.choice.btp.destinationPort = Port_ivim; npr->transport.choice.btp.destinationPort = Port_ivim;
npr->network.choice.gn.packetTransportType = PacketTransportType_shb; npr->network.choice.gn.packetTransportType = PacketTransportType_shb;
npr->network.choice.gn.trafficClass = 1; npr->network.choice.gn.trafficClass = 1;
break; break;
case ItsMessageType_cpm: case ItsMessageType_cpm:
@ -141,18 +141,17 @@ int facilities_request_single_message(void *responder, FacilitiesMessageRequest_
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 = 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, FacilitiesMessageRequest_
} }
bool is_update = false; bool is_update = false;
int managed_msg = false; int managed_msg = false;
if (frm->itsMessageType == 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 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, FacilitiesMessageRequest_
} }
} }
} }
} else if (frm->itsMessageType == ItsMessageType_ivim) { break;
case 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, FacilitiesMessageRequest_
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 == 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);
@ -641,6 +651,7 @@ static int networking_packet_indication_btp(NetworkingPacketIndication_t* npi, v
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 +715,17 @@ static int networking_packet_indication_btp(NetworkingPacketIndication_t* npi, v
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);
@ -849,6 +867,7 @@ static int networking_packet_indication_btp(NetworkingPacketIndication_t* npi, v
default: default:
break; break;
} }
}
// Forward to [applications] // Forward to [applications]
if (fwd) { if (fwd) {