Disable TPM zone type check during retransmission

This commit is contained in:
emanuel 2022-08-18 16:07:42 +01:00
parent 6d9d413c7e
commit 174c20aaea
2 changed files with 21 additions and 23 deletions

View File

@ -43,14 +43,14 @@ int tpm_should_retransmit(void* fc) {
facilities_t* facilities = (facilities_t*) fc;
tolling_t* tolling = &facilities->tolling;
uint64_t now = itss_time_get();
uint64_t now = itss_ts_get(TIME_MICROSECONDS);
if (tolling->station.obu.rt_on) {
if (now > tolling->station.obu.rt_init + TOLLING_RT_TIMEOUT_MS) {
if (now > tolling->station.obu.rt_init + TOLLING_RT_TIMEOUT_MS*1000) {
tolling->station.obu.rt_on = false;
return 0;
}
if (now > tolling->station.obu.rt_t_trigger + TOLLING_RT_PERIOD_MS) {
if (now > tolling->station.obu.rt_t_trigger + TOLLING_RT_PERIOD_MS*1000) {
return 1;
}
}
@ -73,17 +73,6 @@ int tpm_pay(void* fc, tolling_info_t* info, void* security_socket, uint8_t* neig
return rv;
}
itss_time_lock();
tolling->tz = itss_ts_get(TIME_MICROSECONDS);
itss_time_unlock();
// Retransmission
if (!tolling->station.obu.rt_on) {
tolling->station.obu.rt_init = itss_time_get();
tolling->station.obu.rt_on = true;
}
tolling->station.obu.rt_t_trigger = itss_time_get();
TPM_t* tpm = NULL;
TransportRequest_t* tr = NULL;
SecurityRequest_t* sreq = NULL;
@ -139,7 +128,8 @@ int tpm_pay(void* fc, tolling_info_t* info, void* security_socket, uint8_t* neig
switch (info->asn->tollType) {
case TollType_entry:
if (tolling->station.obu.toll_type != -1) {
if (tolling->station.obu.toll_type != -1 &&
!tolling->station.obu.rt_on) {
syslog_err("[facilities] [tolling] trying to issue entry.request but current tolling state is %s - resetting",
tts(tolling->station.obu.toll_type));
tolling->station.obu.toll_type = -1;
@ -163,7 +153,8 @@ int tpm_pay(void* fc, tolling_info_t* info, void* security_socket, uint8_t* neig
type->choice.exit->choice.request->infoId = info->asn->id;
type->choice.exit->choice.request->transactionNonce = tolling->station.obu.nonce;
if (tolling->station.obu.toll_type != TollingType_PR_entry) {
if (tolling->station.obu.toll_type != TollingType_PR_entry &&
!tolling->station.obu.rt_on) {
syslog_err("[facilities] [tolling] trying to issue exit.request but current tolling state is %s - will not provide entry proof",
tts(tolling->station.obu.toll_type));
} else {
@ -181,7 +172,8 @@ int tpm_pay(void* fc, tolling_info_t* info, void* security_socket, uint8_t* neig
break;
case TollType_single:
if (tolling->station.obu.toll_type != -1) {
if (tolling->station.obu.toll_type != -1 &&
!tolling->station.obu.rt_on) {
syslog_err("[facilities] [tolling] trying to issue single.request but current tolling state is %s",
tts(tolling->station.obu.toll_type));
rv = 1;
@ -197,6 +189,7 @@ int tpm_pay(void* fc, tolling_info_t* info, void* security_socket, uint8_t* neig
tolling->station.obu.toll_type = info->asn->tollType;
// Encode TollingPaymentMessage
asn_enc_rval_t enc = oer_encode_to_buffer(&asn_DEF_TollingPaymentMessage, NULL, tpm->tpm, buf, buf_len);
if (enc.encoded == -1) {
@ -377,6 +370,13 @@ int tpm_pay(void* fc, tolling_info_t* info, void* security_socket, uint8_t* neig
itss_queue_send(facilities->tx_queue, buf, enc.encoded+1, ITSS_TRANSPORT, id,
tolling->protocol.p == TOLLING_PROTOCOL_SIMPLE ? "TR.packet.btp" : "TR.packet.tcp");
// Retransmission
if (!tolling->station.obu.rt_on) {
tolling->station.obu.rt_init = itss_ts_get(TIME_MICROSECONDS);
tolling->station.obu.rt_on = true;
}
tolling->station.obu.rt_t_trigger = itss_ts_get(TIME_MICROSECONDS);
// Logging
if (facilities->logging.dbms) {
pthread_mutex_lock(&facilities->id.lock);
@ -1212,7 +1212,7 @@ int tpm_recv(void* fc, TPM_t* tpm_rx, void* security_socket, uint8_t* neighbour,
goto cleanup;
}
itss_time_lock();
syslog_info("[facilities] [tolling] entry.reply took %ld us", itss_ts_get(TIME_MICROSECONDS) - tolling->tz);
syslog_info("[facilities] [tolling] entry.reply took %ld us", itss_ts_get(TIME_MICROSECONDS) - tolling->station.obu.rt_init);
itss_time_unlock();
tolling->station.obu.rt_on = false;
veh_handle_recv(tolling, tpm_rx, security_socket, facilities->tx_queue, neighbour, src_addr);
@ -1240,7 +1240,7 @@ int tpm_recv(void* fc, TPM_t* tpm_rx, void* security_socket, uint8_t* neighbour,
goto cleanup;
}
itss_time_lock();
syslog_info("[facilities] [tolling] exit.reply took %ld us", itss_ts_get(TIME_MICROSECONDS) - tolling->tz);
syslog_info("[facilities] [tolling] exit.reply took %ld us", itss_ts_get(TIME_MICROSECONDS) - tolling->station.obu.rt_init);
itss_time_unlock();
tolling->station.obu.rt_on = false;
veh_handle_recv(tolling, tpm_rx, security_socket, facilities->tx_queue, neighbour, src_addr);
@ -1265,7 +1265,7 @@ int tpm_recv(void* fc, TPM_t* tpm_rx, void* security_socket, uint8_t* neighbour,
goto cleanup;
}
itss_time_lock();
syslog_info("[facilities] [tolling] single.reply took %ld us", itss_ts_get(TIME_MICROSECONDS) - tolling->tz);
syslog_info("[facilities] [tolling] single.reply took %ld us", itss_ts_get(TIME_MICROSECONDS) - tolling->station.obu.rt_init);
itss_time_unlock();
tolling->station.obu.rt_on = false;
veh_handle_recv(tolling, tpm_rx, security_socket, facilities->tx_queue, neighbour, src_addr);

View File

@ -11,7 +11,7 @@
#define TOLLING_MAX_CONNS 64
#define TOLLING_CONN_TIMEOUT_MS 10000
#define TOLLING_RT_PERIOD_MS 400
#define TOLLING_RT_TIMEOUT_MS 5000
#define TOLLING_RT_TIMEOUT_MS 10000
typedef enum TOLLING_PROTOCOL {
TOLLING_PROTOCOL_SIMPLE,
@ -81,8 +81,6 @@ typedef struct tolling {
} obu;
} station;
uint64_t tz;
struct {
tolling_info_t* z[TOLLING_INFOS_MAX_LENGTH];
uint8_t length;