Change PCM encoding functions
This commit is contained in:
parent
2e3eb8784e
commit
b687ebc866
21
src/pcm.c
21
src/pcm.c
|
|
@ -118,12 +118,13 @@ static int pcm_check_handle_request(facilities_t* facilities, PCM_t* pcm) {
|
|||
mvc->negotiation->choice.reply.acceptedTrajectoriesIds.list.array[0] = malloc(sizeof(long));
|
||||
*mvc->negotiation->choice.reply.acceptedTrajectoriesIds.list.array[0] = pt->id;
|
||||
|
||||
asn_enc_rval_t enc = asn_encode_to_buffer(NULL, ATS_UNALIGNED_CANONICAL_PER, &asn_DEF_PCM, pcm_rep, buf, buf_len);
|
||||
asn_enc_rval_t enc = uper_encode_to_buffer(&asn_DEF_PCM, NULL, pcm_rep, buf, buf_len);
|
||||
if (enc.encoded == -1) {
|
||||
syslog_err("[facilities] [pc] PCM.reply encode failure (%s)", enc.failed_type->name);
|
||||
rv = 1;
|
||||
goto cleanup;
|
||||
}
|
||||
ssize_t pcm_rep_len = (enc.encoded + 7) / 8;
|
||||
|
||||
tr = calloc(1, sizeof(TransportRequest_t));
|
||||
tr->present = TransportRequest_PR_packet;
|
||||
|
|
@ -144,9 +145,9 @@ static int pcm_check_handle_request(facilities_t* facilities, PCM_t* pcm) {
|
|||
|
||||
bpr->gn.trafficClass = 2;
|
||||
|
||||
bpr->data.buf = malloc(enc.encoded);
|
||||
memcpy(bpr->data.buf, buf, enc.encoded);
|
||||
bpr->data.size = enc.encoded;
|
||||
bpr->data.buf = malloc(pcm_rep_len);
|
||||
memcpy(bpr->data.buf, buf, pcm_rep_len);
|
||||
bpr->data.size = pcm_rep_len;
|
||||
|
||||
buf[0] = 4;
|
||||
enc = asn_encode_to_buffer(NULL, ATS_CANONICAL_OER, &asn_DEF_TransportRequest, tr, buf+1, buf_len-1);
|
||||
|
|
@ -181,7 +182,7 @@ static int pcm_check_intersection_detected(facilities_t* facilities, PCM_t* pcm)
|
|||
PCM_t* pcm_req = NULL;
|
||||
TransportRequest_t* tr = NULL;
|
||||
|
||||
const ssize_t buf_len = 512;
|
||||
const ssize_t buf_len = 1024;
|
||||
uint8_t buf[buf_len];
|
||||
|
||||
it2s_tender_st_s trajectoryA[TRAJECTORY_MAX_LEN+1]; /* ego trajectory */
|
||||
|
|
@ -262,12 +263,13 @@ static int pcm_check_intersection_detected(facilities_t* facilities, PCM_t* pcm)
|
|||
pt->priority = 1;
|
||||
pt->id = 0;
|
||||
|
||||
asn_enc_rval_t enc = asn_encode_to_buffer(NULL, ATS_UNALIGNED_CANONICAL_PER, &asn_DEF_PCM, pcm_req, buf, buf_len);
|
||||
asn_enc_rval_t enc = uper_encode_to_buffer(&asn_DEF_PCM, NULL, pcm_req, buf, buf_len);
|
||||
if (enc.encoded == -1) {
|
||||
syslog_err("[facilities] [pc] PCM.request encode failure (%s)", enc.failed_type->name);
|
||||
rv = 1;
|
||||
goto cleanup;
|
||||
}
|
||||
ssize_t pcm_req_len = (enc.encoded + 7) / 8;
|
||||
|
||||
tr = calloc(1, sizeof(TransportRequest_t));
|
||||
tr->present = TransportRequest_PR_packet;
|
||||
|
|
@ -288,9 +290,9 @@ static int pcm_check_intersection_detected(facilities_t* facilities, PCM_t* pcm)
|
|||
|
||||
bpr->gn.trafficClass = 2;
|
||||
|
||||
bpr->data.buf = malloc(enc.encoded);
|
||||
memcpy(bpr->data.buf, buf, enc.encoded);
|
||||
bpr->data.size = enc.encoded;
|
||||
bpr->data.buf = malloc(pcm_req_len);
|
||||
memcpy(bpr->data.buf, buf, pcm_req_len);
|
||||
bpr->data.size = pcm_req_len;
|
||||
|
||||
buf[0] = 4;
|
||||
enc = asn_encode_to_buffer(NULL, ATS_CANONICAL_OER, &asn_DEF_TransportRequest, tr, buf+1, buf_len-1);
|
||||
|
|
@ -354,6 +356,7 @@ int pcm_check(void* fc, PCM_t* pcm) {
|
|||
if (mvc->negotiation) {
|
||||
switch (mvc->negotiation->present) {
|
||||
case CoordinationNegotiation_PR_request:
|
||||
syslog_err("received PCM.request");
|
||||
pcm_check_handle_request(facilities, pcm);
|
||||
break;
|
||||
case CoordinationNegotiation_PR_reply:
|
||||
|
|
|
|||
Loading…
Reference in New Issue