Enable unknown packet forwarding
This commit is contained in:
parent
8d7b2ac638
commit
3e53b9b08a
|
|
@ -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) {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
|
||||||
587
src/requests.c
587
src/requests.c
|
|
@ -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:
|
||||||
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 = 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, 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;
|
|
||||||
|
|
||||||
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 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 &&
|
||||||
((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 (!((DENM_t *)its_msg)->denm.location) {
|
|
||||||
((DENM_t *)its_msg)->denm.location = calloc(1, sizeof(LocationContainer_t));
|
|
||||||
}
|
|
||||||
((DENM_t *)its_msg)->denm.location->traces.list.count = 1;
|
|
||||||
((DENM_t *)its_msg)->denm.location->traces.list.size = 1 * sizeof(void *);
|
|
||||||
((DENM_t *)its_msg)->denm.location->traces.list.array = malloc(1 * sizeof(void *));
|
|
||||||
((DENM_t *)its_msg)->denm.location->traces.list.array[0] = calloc(1, sizeof(PathHistory_t));
|
|
||||||
PathHistory_t *ph = ((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(PathPoint_t));
|
|
||||||
|
|
||||||
itss_space_lock();
|
|
||||||
if (path_history[0]->alt != AltitudeValue_unavailable && epv.space.altitude != AltitudeValue_unavailable) {
|
|
||||||
ph->list.array[0]->pathPosition.deltaAltitude = path_history[0]->alt - epv.space.altitude;
|
|
||||||
} else {
|
|
||||||
ph->list.array[0]->pathPosition.deltaAltitude = DeltaAltitude_unavailable;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (path_history[0]->lat != Latitude_unavailable && epv.space.latitude != Latitude_unavailable) {
|
|
||||||
ph->list.array[0]->pathPosition.deltaLatitude = path_history[0]->lat - epv.space.latitude;
|
|
||||||
} else {
|
|
||||||
ph->list.array[0]->pathPosition.deltaLatitude = DeltaLatitude_unavailable;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (path_history[0]->lon != Longitude_unavailable && epv.space.longitude != Longitude_unavailable) {
|
|
||||||
ph->list.array[0]->pathPosition.deltaLongitude = path_history[0]->lon - epv.space.longitude;
|
|
||||||
} else {
|
|
||||||
ph->list.array[0]->pathPosition.deltaLongitude = DeltaLongitude_unavailable;
|
|
||||||
}
|
|
||||||
itss_space_unlock();
|
|
||||||
|
|
||||||
ph->list.array[0]->pathDeltaTime = calloc(1, sizeof(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(PathPoint_t));
|
|
||||||
|
|
||||||
if (path_history[i]->alt != AltitudeValue_unavailable && path_history[i - 1]->alt != AltitudeValue_unavailable) {
|
|
||||||
ph->list.array[i]->pathPosition.deltaAltitude = path_history[i]->alt - path_history[i - 1]->alt;
|
|
||||||
} else {
|
|
||||||
ph->list.array[i]->pathPosition.deltaAltitude = DeltaAltitude_unavailable;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (path_history[i]->lat != Latitude_unavailable && path_history[i - 1]->lat != Latitude_unavailable) {
|
|
||||||
ph->list.array[i]->pathPosition.deltaLatitude = path_history[i]->lat - path_history[i - 1]->lat;
|
|
||||||
} else {
|
|
||||||
ph->list.array[i]->pathPosition.deltaLatitude = DeltaLatitude_unavailable;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (path_history[i]->lon != Longitude_unavailable && path_history[i - 1]->lon != Longitude_unavailable) {
|
|
||||||
ph->list.array[i]->pathPosition.deltaLongitude = path_history[i]->lon - path_history[i - 1]->lon;
|
|
||||||
} else {
|
|
||||||
ph->list.array[i]->pathPosition.deltaLongitude = DeltaLongitude_unavailable;
|
|
||||||
}
|
|
||||||
|
|
||||||
ph->list.array[i]->pathDeltaTime = calloc(1, sizeof(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 (((DENM_t *)its_msg)->denm.management.transmissionInterval) {
|
event_type == EVENT_CANCELLATION ||
|
||||||
transmission_interval = *((uint32_t *)((DENM_t *)its_msg)->denm.management.transmissionInterval);
|
event_type == EVENT_NEGATION) {
|
||||||
|
is_update = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (((DENM_t *)its_msg)->denm.management.validityDuration) {
|
if (fwd) {
|
||||||
transmission_duration = *((uint32_t *)((DENM_t *)its_msg)->denm.management.validityDuration) * 1000;
|
// set stationID
|
||||||
|
pthread_mutex_lock(&facilities.id.lock);
|
||||||
|
((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 (!((DENM_t *)its_msg)->denm.location) {
|
||||||
|
((DENM_t *)its_msg)->denm.location = calloc(1, sizeof(LocationContainer_t));
|
||||||
|
}
|
||||||
|
((DENM_t *)its_msg)->denm.location->traces.list.count = 1;
|
||||||
|
((DENM_t *)its_msg)->denm.location->traces.list.size = 1 * sizeof(void *);
|
||||||
|
((DENM_t *)its_msg)->denm.location->traces.list.array = malloc(1 * sizeof(void *));
|
||||||
|
((DENM_t *)its_msg)->denm.location->traces.list.array[0] = calloc(1, sizeof(PathHistory_t));
|
||||||
|
PathHistory_t *ph = ((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(PathPoint_t));
|
||||||
|
|
||||||
|
itss_space_lock();
|
||||||
|
if (path_history[0]->alt != AltitudeValue_unavailable && epv.space.altitude != AltitudeValue_unavailable) {
|
||||||
|
ph->list.array[0]->pathPosition.deltaAltitude = path_history[0]->alt - epv.space.altitude;
|
||||||
|
} else {
|
||||||
|
ph->list.array[0]->pathPosition.deltaAltitude = DeltaAltitude_unavailable;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (path_history[0]->lat != Latitude_unavailable && epv.space.latitude != Latitude_unavailable) {
|
||||||
|
ph->list.array[0]->pathPosition.deltaLatitude = path_history[0]->lat - epv.space.latitude;
|
||||||
|
} else {
|
||||||
|
ph->list.array[0]->pathPosition.deltaLatitude = DeltaLatitude_unavailable;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (path_history[0]->lon != Longitude_unavailable && epv.space.longitude != Longitude_unavailable) {
|
||||||
|
ph->list.array[0]->pathPosition.deltaLongitude = path_history[0]->lon - epv.space.longitude;
|
||||||
|
} else {
|
||||||
|
ph->list.array[0]->pathPosition.deltaLongitude = DeltaLongitude_unavailable;
|
||||||
|
}
|
||||||
|
itss_space_unlock();
|
||||||
|
|
||||||
|
ph->list.array[0]->pathDeltaTime = calloc(1, sizeof(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(PathPoint_t));
|
||||||
|
|
||||||
|
if (path_history[i]->alt != AltitudeValue_unavailable && path_history[i - 1]->alt != AltitudeValue_unavailable) {
|
||||||
|
ph->list.array[i]->pathPosition.deltaAltitude = path_history[i]->alt - path_history[i - 1]->alt;
|
||||||
|
} else {
|
||||||
|
ph->list.array[i]->pathPosition.deltaAltitude = DeltaAltitude_unavailable;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (path_history[i]->lat != Latitude_unavailable && path_history[i - 1]->lat != Latitude_unavailable) {
|
||||||
|
ph->list.array[i]->pathPosition.deltaLatitude = path_history[i]->lat - path_history[i - 1]->lat;
|
||||||
|
} else {
|
||||||
|
ph->list.array[i]->pathPosition.deltaLatitude = DeltaLatitude_unavailable;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (path_history[i]->lon != Longitude_unavailable && path_history[i - 1]->lon != Longitude_unavailable) {
|
||||||
|
ph->list.array[i]->pathPosition.deltaLongitude = path_history[i]->lon - path_history[i - 1]->lon;
|
||||||
|
} else {
|
||||||
|
ph->list.array[i]->pathPosition.deltaLongitude = DeltaLongitude_unavailable;
|
||||||
|
}
|
||||||
|
|
||||||
|
ph->list.array[i]->pathDeltaTime = calloc(1, sizeof(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 (((DENM_t *)its_msg)->denm.management.transmissionInterval) {
|
||||||
|
transmission_interval = *((uint32_t *)((DENM_t *)its_msg)->denm.management.transmissionInterval);
|
||||||
|
|
||||||
|
if (((DENM_t *)its_msg)->denm.management.validityDuration) {
|
||||||
|
transmission_duration = *((uint32_t *)((DENM_t *)its_msg)->denm.management.validityDuration) * 1000;
|
||||||
|
} else {
|
||||||
|
transmission_duration = 600 * 1000;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 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 (!((IVIM_t *)its_msg)->ivi.mandatory.validFrom) {
|
||||||
|
valid_from = itss_time_get();
|
||||||
} else {
|
} else {
|
||||||
transmission_duration = 600 * 1000;
|
asn_INTEGER2ulong((INTEGER_t *)((IVIM_t *)its_msg)->ivi.mandatory.validFrom, (unsigned long long *)&valid_from);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!((IVIM_t *)its_msg)->ivi.mandatory.validTo) {
|
||||||
|
valid_to = valid_from + facilities.infrastructure.default_service_duration;
|
||||||
|
} else {
|
||||||
|
asn_INTEGER2ulong((INTEGER_t *)((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 == 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 (!((IVIM_t *)its_msg)->ivi.mandatory.validFrom) {
|
|
||||||
valid_from = itss_time_get();
|
|
||||||
} else {
|
|
||||||
asn_INTEGER2ulong((INTEGER_t *)((IVIM_t *)its_msg)->ivi.mandatory.validFrom, (unsigned long long *)&valid_from);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!((IVIM_t *)its_msg)->ivi.mandatory.validTo) {
|
|
||||||
valid_to = valid_from + facilities.infrastructure.default_service_duration;
|
|
||||||
} else {
|
|
||||||
asn_INTEGER2ulong((INTEGER_t *)((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 == ItsMessageType_evrsr) {
|
|
||||||
managed_msg = true;
|
|
||||||
}
|
|
||||||
if (!facilities.replay) {
|
|
||||||
transmission_interval = 0;
|
|
||||||
transmission_duration = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Respond to [applications]
|
// Respond to [applications]
|
||||||
|
|
@ -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,150 +715,158 @@ static int networking_packet_indication_btp(NetworkingPacketIndication_t* npi, v
|
||||||
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 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 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 NetworkingPacketRequestNW_PR_gn:
|
switch (bpi->destinationPort) {
|
||||||
if (npi->network.choice.gn.securityPermissions) {
|
case 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 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 Port_denm:
|
||||||
switch (bpi->destinationPort) {
|
|
||||||
case 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 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_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 Port_ivim:
|
case 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 Port_saem:
|
case 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 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 Port_poi:
|
case Port_evrsr:
|
||||||
if (facilities.evm_args.activate) {
|
if (facilities.evm_args.activate) {
|
||||||
evcsnm_check(its_msg);
|
evrsrm_check(its_msg);
|
||||||
fwd = true;
|
fwd = true;
|
||||||
}
|
EV_RSR_t *evrsr_request = (EV_RSR_t *)its_msg;
|
||||||
break;
|
evrsrm_recv(evrsr_request);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case Port_evrsr:
|
default:
|
||||||
if (facilities.evm_args.activate) {
|
break;
|
||||||
evrsrm_check(its_msg);
|
}
|
||||||
fwd = true;
|
|
||||||
EV_RSR_t *evrsr_request = (EV_RSR_t *)its_msg;
|
|
||||||
evrsrm_recv(evrsr_request);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Forward to [applications]
|
// Forward to [applications]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue