Fix non forwarded IVIMs, ad default service duration
This commit is contained in:
parent
67d13542fa
commit
8a9aed7fcd
|
|
@ -162,6 +162,10 @@ int itss_config(void* facilities_s, char* config_file) {
|
|||
rv += extract_val_int(&replay_interval, ivim, "replay-interval");
|
||||
facilities->infrastructure->replay_interval = replay_interval;
|
||||
|
||||
int64_t default_service_duration;
|
||||
rv += extract_val_int(&default_service_duration, ivim, "default-service-duration");
|
||||
facilities->infrastructure->default_service_duration = default_service_duration * 60000;
|
||||
|
||||
// Replay
|
||||
int replay_active = 1;
|
||||
rv += extract_val_bool(&replay_active, replay, "activate");
|
||||
|
|
|
|||
|
|
@ -224,6 +224,7 @@ static int facilities_request(facilities_t *facilities, void* responder, uint8_t
|
|||
is_update = true;
|
||||
}
|
||||
|
||||
if (fwd) {
|
||||
if ( ((DENM_t*)its_msg)->denm.management.transmissionInterval ) {
|
||||
transmission_interval = *( (uint32_t*) ((DENM_t*)its_msg)->denm.management.transmissionInterval );
|
||||
|
||||
|
|
@ -233,6 +234,7 @@ static int facilities_request(facilities_t *facilities, void* responder, uint8_t
|
|||
transmission_duration = facilities->den->default_event_duration * 1000;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (fdreq->choice.singleMessage.itssMessageType == ItssMessageType_ivim) {
|
||||
managed_msg = true;
|
||||
|
||||
|
|
@ -253,14 +255,30 @@ static int facilities_request(facilities_t *facilities, void* responder, uint8_t
|
|||
is_update = true;
|
||||
}
|
||||
|
||||
if (fwd) {
|
||||
uint64_t valid_to, valid_from;
|
||||
asn_INTEGER2ulong((INTEGER_t*) ((IVIM_t*) its_msg)->ivi.mandatory.validTo, &valid_to);
|
||||
|
||||
if (!((IVIM_t*) its_msg)->ivi.mandatory.validFrom) {
|
||||
struct timespec systemtime;
|
||||
clock_gettime(CLOCK_REALTIME, &systemtime);
|
||||
long now = (long) (systemtime.tv_sec * 1000 + systemtime.tv_nsec / 1E6);
|
||||
now = now - 1072915200000; // Convert EPOCH to 2004/01/01 00:00:000
|
||||
valid_from = now;
|
||||
} else {
|
||||
asn_INTEGER2ulong((INTEGER_t*) ((IVIM_t*) its_msg)->ivi.mandatory.validFrom, &valid_from);
|
||||
}
|
||||
|
||||
if (!((IVIM_t*) its_msg)->ivi.mandatory.validTo) {
|
||||
valid_to = valid_from + facilities->infrastructure->default_service_duration;
|
||||
} else {
|
||||
asn_INTEGER2ulong((INTEGER_t*) ((IVIM_t*) its_msg)->ivi.mandatory.validTo, &valid_to);
|
||||
}
|
||||
|
||||
transmission_start = valid_from;
|
||||
transmission_interval = facilities->infrastructure->replay_interval;
|
||||
transmission_duration = valid_to - valid_from;
|
||||
}
|
||||
}
|
||||
|
||||
if (!facilities->replay) {
|
||||
transmission_interval = 0;
|
||||
|
|
|
|||
|
|
@ -17,6 +17,11 @@
|
|||
static enum SERVICE_EVAL_RESULT service_check(infrastructure_t* infrastructure, enum SERVICE_TYPE type, void* its_msg) {
|
||||
int rv = 0;
|
||||
|
||||
struct timespec systemtime;
|
||||
clock_gettime(CLOCK_REALTIME, &systemtime);
|
||||
long now = (long) (systemtime.tv_sec * 1000 + systemtime.tv_nsec / 1E6);
|
||||
now = now - 1072915200000; // Convert EPOCH to 2004/01/01 00:00:000
|
||||
|
||||
switch (type) {
|
||||
case SERVICE_IVI:
|
||||
break;
|
||||
|
|
@ -27,16 +32,25 @@ static enum SERVICE_EVAL_RESULT service_check(infrastructure_t* infrastructure,
|
|||
IVIM_t* ivim = (IVIM_t*) its_msg;
|
||||
|
||||
uint64_t timestamp, valid_to, valid_from;
|
||||
if (!ivim->ivi.mandatory.timeStamp) {
|
||||
timestamp = now;
|
||||
} else {
|
||||
asn_INTEGER2ulong((INTEGER_t*) ivim->ivi.mandatory.timeStamp, ×tamp);
|
||||
asn_INTEGER2ulong((INTEGER_t*) ivim->ivi.mandatory.validTo, &valid_to);
|
||||
}
|
||||
|
||||
if (!ivim->ivi.mandatory.validFrom) {
|
||||
valid_from = now;
|
||||
} else {
|
||||
asn_INTEGER2ulong((INTEGER_t*) ivim->ivi.mandatory.validFrom, &valid_from);
|
||||
}
|
||||
|
||||
struct timespec systemtime;
|
||||
clock_gettime(CLOCK_REALTIME, &systemtime);
|
||||
long now = (long) (systemtime.tv_sec * 1000 + systemtime.tv_nsec / 1E6);
|
||||
now = now - 1072915200000; // Convert EPOCH to 2004/01/01 00:00:000
|
||||
if (!ivim->ivi.mandatory.validTo) {
|
||||
valid_to = valid_from + infrastructure->default_service_duration;
|
||||
} else {
|
||||
asn_INTEGER2ulong((INTEGER_t*) ivim->ivi.mandatory.validTo, &valid_to);
|
||||
}
|
||||
|
||||
if (now > valid_to) {
|
||||
if (now >= valid_to) {
|
||||
return SERVICE_PASSED;
|
||||
}
|
||||
|
||||
|
|
@ -116,9 +130,23 @@ static int service_add(infrastructure_t* infrastructure, enum SERVICE_TYPE type,
|
|||
now = now - 1072915200000; // Convert EPOCH to 2004/01/01 00:00:000
|
||||
|
||||
uint64_t timestamp, valid_to, valid_from;
|
||||
if (!ivim->ivi.mandatory.timeStamp) {
|
||||
timestamp = now;
|
||||
} else {
|
||||
asn_INTEGER2ulong((INTEGER_t*) ivim->ivi.mandatory.timeStamp, ×tamp);
|
||||
asn_INTEGER2ulong((INTEGER_t*) ivim->ivi.mandatory.validTo, &valid_to);
|
||||
}
|
||||
|
||||
if (!ivim->ivi.mandatory.validFrom) {
|
||||
valid_from = now;
|
||||
} else {
|
||||
asn_INTEGER2ulong((INTEGER_t*) ivim->ivi.mandatory.validFrom, &valid_from);
|
||||
}
|
||||
|
||||
if (!ivim->ivi.mandatory.validTo) {
|
||||
valid_to = valid_from + infrastructure->default_service_duration;
|
||||
} else {
|
||||
asn_INTEGER2ulong((INTEGER_t*) ivim->ivi.mandatory.validTo, &valid_to);
|
||||
}
|
||||
|
||||
pthread_mutex_lock(&infrastructure->lock);
|
||||
|
||||
|
|
@ -191,9 +219,23 @@ static int service_update(infrastructure_t* infrastructure, enum SERVICE_TYPE ty
|
|||
now = now - 1072915200000; // Convert EPOCH to 2004/01/01 00:00:000
|
||||
|
||||
uint64_t timestamp, valid_to, valid_from;
|
||||
if (!ivim->ivi.mandatory.timeStamp) {
|
||||
timestamp = now;
|
||||
} else {
|
||||
asn_INTEGER2ulong((INTEGER_t*) ivim->ivi.mandatory.timeStamp, ×tamp);
|
||||
asn_INTEGER2ulong((INTEGER_t*) ivim->ivi.mandatory.validTo, &valid_to);
|
||||
}
|
||||
|
||||
if (!ivim->ivi.mandatory.validFrom) {
|
||||
valid_from = now;
|
||||
} else {
|
||||
asn_INTEGER2ulong((INTEGER_t*) ivim->ivi.mandatory.validFrom, &valid_from);
|
||||
}
|
||||
|
||||
if (!ivim->ivi.mandatory.validTo) {
|
||||
valid_to = valid_from + infrastructure->default_service_duration;
|
||||
} else {
|
||||
asn_INTEGER2ulong((INTEGER_t*) ivim->ivi.mandatory.validTo, &valid_to);
|
||||
}
|
||||
|
||||
uint8_t state;
|
||||
switch (ivim->ivi.mandatory.iviStatus) {
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ typedef struct infrastructure {
|
|||
uint16_t n_max_services;
|
||||
|
||||
uint32_t replay_interval;
|
||||
uint64_t default_service_duration;
|
||||
|
||||
pthread_mutex_t lock;
|
||||
} infrastructure_t;
|
||||
|
|
|
|||
Loading…
Reference in New Issue