diff --git a/src/evm.c b/src/evm.c index 659f602..1451ffd 100644 --- a/src/evm.c +++ b/src/evm.c @@ -212,19 +212,20 @@ static int evrsrm_pre_reservation_response(uint8_t *evrsrm_oer, uint32_t *evrsrm pthread_mutex_unlock(&facilities.id.lock); evrsr_response->messageBody.present = EV_RSR_MessageBody_PR_preReservationResponseMessage; - PreReservationResponseMessage_t response = evrsr_response->messageBody.choice.preReservationResponseMessage; - response.preReservation_ID.buf = calloc(8, sizeof(uint8_t)); - response.preReservation_ID.size = 8; - *(uint64_t *)response.preReservation_ID.buf = pre_reservation_id; + PreReservationResponseMessage_t* response = &evrsr_response->messageBody.choice.preReservationResponseMessage; + response->preReservation_ID.buf = calloc(8, sizeof(uint8_t)); + response->preReservation_ID.size = 8; + *(int64_t*) response->preReservation_ID.buf = pre_reservation_id; - response.availabilityStatus = 0; - response.supportedPaymentTypes.buf = calloc(1, sizeof(uint8_t)); - response.supportedPaymentTypes.bits_unused = 0; - response.supportedPaymentTypes.size = 1; - response.supportedPaymentTypes.buf[0] = 0x00; + response->availabilityStatus = 0; - response.preReservationExpirationTime = 0; + response->supportedPaymentTypes.buf = calloc(1, sizeof(uint8_t)); + response->supportedPaymentTypes.bits_unused = 0; + response->supportedPaymentTypes.size = 1; + response->supportedPaymentTypes.buf[0] = 0x00; + + response->preReservationExpirationTime = 0; asn_enc_rval_t enc = uper_encode_to_buffer(&asn_DEF_EV_RSR, NULL, evrsr_response, evrsrm_oer, 512); if (enc.encoded == -1) { log_error("[ev] failed encoding evrsrm (%s)", enc.failed_type->name); @@ -233,6 +234,7 @@ static int evrsrm_pre_reservation_response(uint8_t *evrsrm_oer, uint32_t *evrsrm } *evrsrm_len = (enc.encoded + 7) / 8; pre_reservation_id++; + cleanup: ASN_STRUCT_FREE(asn_DEF_EV_RSR, evrsr_response); return rv;