From df1d55977510977df674f30209362a05afeb5aaf Mon Sep 17 00:00:00 2001 From: emanuel Date: Mon, 5 Feb 2024 17:34:16 +0000 Subject: [PATCH] Use asn_copy() over encode/decode --- src/cam.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/cam.c b/src/cam.c index abfd1e3..3013ccb 100644 --- a/src/cam.c +++ b/src/cam.c @@ -931,8 +931,10 @@ enum CAM_CHECK_R check_cam_v1(EIS_BTPPacketIndication_t *bpi, EI1_CAM_t* cam, ui mreq->choice.attributes.choice.set.protectedZones->list.size = lightship->protected_zones.pz_len * sizeof(void*); mreq->choice.attributes.choice.set.protectedZones->list.array = calloc(lightship->protected_zones.pz_len, sizeof(void*)); for (int p = 0; p < lightship->protected_zones.pz_len; ++p) { - asn_enc_rval_t enc = oer_encode_to_buffer(&asn_DEF_EIS_ProtectedCommunicationZone, NULL, lightship->protected_zones.pz[p], b_oer, 512); - oer_decode(NULL, &asn_DEF_EIS_ProtectedCommunicationZone, (void**) &mreq->choice.attributes.choice.set.protectedZones->list.array[p], b_oer, enc.encoded); + asn_copy(&asn_DEF_EIS_ProtectedCommunicationZone, + (void**) &mreq->choice.attributes.choice.set.protectedZones->list.array[p], + lightship->protected_zones.pz[p] + ); } asn_enc_rval_t enc = oer_encode_to_buffer(&asn_DEF_EIS_ManagementRequest, NULL, mreq, b_oer, 512); @@ -1140,8 +1142,10 @@ enum CAM_CHECK_R check_cam_v2(EIS_BTPPacketIndication_t *bpi, EI2_CAM_t* cam, ui mreq->choice.attributes.choice.set.protectedZones->list.size = lightship->protected_zones.pz_len * sizeof(void*); mreq->choice.attributes.choice.set.protectedZones->list.array = calloc(lightship->protected_zones.pz_len, sizeof(void*)); for (int p = 0; p < lightship->protected_zones.pz_len; ++p) { - asn_enc_rval_t enc = oer_encode_to_buffer(&asn_DEF_EIS_ProtectedCommunicationZone, NULL, lightship->protected_zones.pz[p], b_oer, 512); - oer_decode(NULL, &asn_DEF_EIS_ProtectedCommunicationZone, (void**) &mreq->choice.attributes.choice.set.protectedZones->list.array[p], b_oer, enc.encoded); + asn_copy(&asn_DEF_EIS_ProtectedCommunicationZone, + (void**) &mreq->choice.attributes.choice.set.protectedZones->list.array[p], + lightship->protected_zones.pz[p] + ); } asn_enc_rval_t enc = oer_encode_to_buffer(&asn_DEF_EIS_ManagementRequest, NULL, mreq, b_oer, 512);