diff --git a/src/requests.c b/src/requests.c index a9a8aa7..ca02893 100644 --- a/src/requests.c +++ b/src/requests.c @@ -337,15 +337,21 @@ int facilities_request_single_message(void *responder, FacilitiesMessageRequest_ npr->transport.choice.btp.btpType = BTPType_btpB; npr->id = id; - npr->data.buf = malloc(2048); - asn_enc_rval_t enc = uper_encode_to_buffer(its_msg_def, NULL, its_msg, npr->data.buf, 2048); - if (enc.encoded == -1) { - log_error("failed encoding ITS message into UPER (%s)", enc.failed_type->name); - rv = 1; - goto cleanup; + + asn_enc_rval_t enc; + if (process_msg) { + enc = uper_encode_to_buffer(its_msg_def, NULL, its_msg, npr->data.buf, 2048); + if (enc.encoded == -1) { + log_error("failed encoding ITS message into UPER (%s)", enc.failed_type->name); + rv = 1; + goto cleanup; + } + npr->data.size = (enc.encoded + 7) / 8; + } else { + memcpy(npr->data.buf, frm->data.buf, frm->data.size); + npr->data.size = frm->data.size; } - npr->data.size = (enc.encoded + 7) / 8; npr->network.choice.gn.destinationAddress.buf = malloc(6); for (int i = 0; i < 6; ++i)