diff --git a/src/saem.c b/src/saem.c index c5b5fa5..359ad9d 100644 --- a/src/saem.c +++ b/src/saem.c @@ -380,13 +380,16 @@ void *sa_service(void *fc) { now > bulletin->to_consume[a]->t_trigger + TOLLING_PAYMENT_MIN_PERIOD_MS && facilities->station_type != 15) { - if (!tpm_is_inside_zone(facilities, (tolling_info_s*) bulletin->to_consume[a]->info.internal_p)) { + + tolling_info_s* info = (tolling_info_s*) bulletin->to_consume[a]->info.internal_p; + + if (!tpm_is_inside_zone(facilities, info)) { continue; } switch (facilities->tolling.protocol) { case TOLLING_PROTOCOL_SIMPLE: - tpm_pay(facilities, bulletin->to_consume[a]->certificate_id); + tpm_pay(facilities, info, bulletin->to_consume[a]->certificate_id); ++bulletin->to_consume[a]->n_trigger; bulletin->to_consume[a]->t_trigger = now; break; diff --git a/src/tpm.c b/src/tpm.c index e701b9c..0f19f1f 100644 --- a/src/tpm.c +++ b/src/tpm.c @@ -29,7 +29,7 @@ int tpm_is_inside_zone(void* fc, tolling_info_s* ti) { return 0; } -int tpm_pay(void* fc, uint8_t* neighbour) { +int tpm_pay(void* fc, tolling_info_s* info, uint8_t* neighbour) { int rv = 0; facilities_t* facilities = (facilities_t*) fc; @@ -70,6 +70,7 @@ int tpm_pay(void* fc, uint8_t* neighbour) { tpm->tpm.tollingFlow.present = TollingFlow_PR_request; tpm->tpm.tollingFlow.choice.request.clientId = tolling->client_id; + tpm->tpm.tollingFlow.choice.request.infoId = info->asn->id; tpm->tpm.tollingFlow.choice.request.paymentMethod.present = TollPaymentMethod_PR_fiat; tpm->tpm.tollingFlow.choice.request.paymentMethod.choice.fiat.fiatId = FiatId_eur; tpm->tpm.tollingFlow.choice.request.transactionNonce = tolling->nonce; @@ -291,6 +292,7 @@ static void rsu_handle_recv(facilities_t* facilities, TPM_t* tpm_rx, uint8_t* ne tpm->tpm.tollingFlow.present = TollingFlow_PR_reply; tpm->tpm.tollingFlow.choice.reply.clientId = req->clientId; + tpm->tpm.tollingFlow.choice.reply.infoId = req->infoId; tpm->tpm.tollingFlow.choice.reply.transactionNonce = req->transactionNonce; // TODO check clientId diff --git a/src/tpm.h b/src/tpm.h index 61b4021..3e00ce9 100644 --- a/src/tpm.h +++ b/src/tpm.h @@ -53,10 +53,9 @@ typedef struct tolling { */ int tolling_init(tolling_s* tolling, void* zmq_ctx, char* security_address); -int tpm_pay(void* fc, uint8_t* neighbour); +int tpm_pay(void* fc, tolling_info_s* info, uint8_t* neighbour); int tpm_recv(void* fc, TPM_t* tpm_rx, uint8_t* neighbour); int tpm_is_inside_zone(void* fc, tolling_info_s* ti); tolling_info_s* tolling_info_new(it2s_tender_epv_t* epv, TollingPaymentInfo_t* tpi); void tolling_info_free(tolling_info_s* ti); -