Fix PZ checks

This commit is contained in:
emanuel 2020-11-30 21:14:14 +00:00
parent 8ec2bd2642
commit 95289ebcde
1 changed files with 24 additions and 14 deletions

View File

@ -260,24 +260,34 @@ int check_cam(void* fc, BTPDataIndication_t *bdi, CAM_t* cam) {
cam->cam.camParameters.highFrequencyContainer.choice.rsuContainerHighFrequency.protectedCommunicationZonesRSU) { cam->cam.camParameters.highFrequencyContainer.choice.rsuContainerHighFrequency.protectedCommunicationZonesRSU) {
ProtectedCommunicationZonesRSU_t *pzs = cam->cam.camParameters.highFrequencyContainer.choice.rsuContainerHighFrequency.protectedCommunicationZonesRSU; ProtectedCommunicationZonesRSU_t *pzs = cam->cam.camParameters.highFrequencyContainer.choice.rsuContainerHighFrequency.protectedCommunicationZonesRSU;
if (pzs->list.count > 0 && pzs->list.count + lightship->pz_len < 256) { if (pzs->list.count > 0 && pzs->list.count + lightship->pz_len < 256) {
for (int i = lightship->pz_len; i < lightship->pz_len + pzs->list.count; ++i) { for (int k = 0; k < pzs->list.count; ++k) {
lightship->pz[i] = calloc(1, sizeof(ProtectedCommunicationZone_t)); bool found = false;
lightship->pz[i]->protectedZoneLatitude = pzs->list.array[i]->protectedZoneLatitude; for (int j = 0; j < lightship->pz_len; ++j) {
lightship->pz[i]->protectedZoneLongitude = pzs->list.array[i]->protectedZoneLongitude; if (lightship->pz[j]->protectedZoneLatitude == pzs->list.array[k]->protectedZoneLatitude &&
lightship->pz[i]->protectedZoneType = pzs->list.array[i]->protectedZoneType; lightship->pz[j]->protectedZoneLongitude == pzs->list.array[k]->protectedZoneLongitude) {
found = true;
break;
}
}
if (found) continue;
if (pzs->list.array[i]->expiryTime) { lightship->pz[k + lightship->pz_len] = calloc(1, sizeof(ProtectedCommunicationZone_t));
lightship->pz[i]->expiryTime = malloc(8); lightship->pz[k + lightship->pz_len]->protectedZoneLatitude = pzs->list.array[k]->protectedZoneLatitude;
*lightship->pz[i]->expiryTime = *pzs->list.array[i]->expiryTime; lightship->pz[k + lightship->pz_len]->protectedZoneLongitude = pzs->list.array[k]->protectedZoneLongitude;
lightship->pz[k + lightship->pz_len]->protectedZoneType = pzs->list.array[k]->protectedZoneType;
if (pzs->list.array[k]->expiryTime) {
lightship->pz[k + lightship->pz_len]->expiryTime = malloc(8);
*lightship->pz[k + lightship->pz_len]->expiryTime = *pzs->list.array[k]->expiryTime;
} }
if (pzs->list.array[i]->protectedZoneID) { if (pzs->list.array[k]->protectedZoneID) {
lightship->pz[i]->protectedZoneID = malloc(8); lightship->pz[k + lightship->pz_len]->protectedZoneID = malloc(8);
*lightship->pz[i]->protectedZoneID = *pzs->list.array[i]->protectedZoneID; *lightship->pz[k + lightship->pz_len]->protectedZoneID = *pzs->list.array[k]->protectedZoneID;
} }
if (pzs->list.array[i]->protectedZoneRadius) { if (pzs->list.array[k]->protectedZoneRadius) {
lightship->pz[i]->protectedZoneRadius = malloc(8); lightship->pz[k + lightship->pz_len]->protectedZoneRadius = malloc(8);
*lightship->pz[i]->protectedZoneRadius = *pzs->list.array[i]->protectedZoneRadius; *lightship->pz[k + lightship->pz_len]->protectedZoneRadius = *pzs->list.array[k]->protectedZoneRadius;
} }
++lightship->pz_len; ++lightship->pz_len;
} }