/* Compute the new instance sands */ void vrrp_init_instance_sands(vrrp_t * vrrp) { set_time_now(); if (vrrp->state == VRRP_STATE_MAST || vrrp->state == VRRP_STATE_GOTO_MASTER || vrrp->state == VRRP_STATE_GOTO_FAULT || vrrp->wantstate == VRRP_STATE_GOTO_MASTER) { // TIMER - GOTO_MASTER shouldn't be adver_int. Look at circumstances to set GOTO_MASTER // i) backup and expire timer // ii) backup and receive prio 0 // iii) master and receive higher prio advert vrrp->sands = timer_add_long(time_now, vrrp->adver_int); return; } /* * When in the BACKUP state the expiry timer should be updated to * time_now plus the Master Down Timer, when a non-preemptable packet is * received. (When a preemptable packet is received, the wantstate is * moved to GOTO_MASTER and this condition is caught above). */ if (vrrp->state == VRRP_STATE_BACK || vrrp->state == VRRP_STATE_FAULT) vrrp->sands = timer_add_long(time_now, vrrp->ms_down_timer); }
/* timer add to current time */ timeval_t timer_add_now(timeval_t a) { /* Init current time if needed */ if (timer_isnull(time_now)) set_time_now(); return timer_add(time_now, a); }
/* Compute the new instance sands */ void vrrp_init_instance_sands(vrrp_rt * vrrp) { set_time_now(); if (vrrp->state == VRRP_STATE_MAST || vrrp->state == VRRP_STATE_GOTO_MASTER || vrrp->state == VRRP_STATE_GOTO_FAULT || vrrp->wantstate == VRRP_STATE_GOTO_MASTER) { vrrp->sands.tv_sec = time_now.tv_sec + vrrp->adver_int / TIMER_HZ; vrrp->sands.tv_usec = time_now.tv_usec; return; } if (vrrp->state == VRRP_STATE_BACK || vrrp->state == VRRP_STATE_FAULT) vrrp->sands = timer_add_long(time_now, vrrp->ms_down_timer); }
int file_hdr_init(void* dest, const uint64_t dest_len, const uint16_t uflag, const uint64_t rid, const uint64_t fro, const uint64_t file_number, const uint16_t queue_name_len, const char* queue_name) { file_hdr_t* fhp = (file_hdr_t*)dest; fhp->_rhdr._uflag = uflag; fhp->_rhdr._rid = rid; fhp->_fro = fro; fhp->_file_number = file_number; if (sizeof(file_hdr_t) + queue_name_len < MAX_FILE_HDR_LEN) { fhp->_queue_name_len = queue_name_len; } else { fhp->_queue_name_len = MAX_FILE_HDR_LEN - sizeof(file_hdr_t); } fhp->_queue_name_len = queue_name_len; memcpy((char*)dest + sizeof(file_hdr_t), queue_name, queue_name_len); memset((char*)dest + sizeof(file_hdr_t) + queue_name_len, 0, dest_len - sizeof(file_hdr_t) - queue_name_len); return set_time_now(dest); }
/* Compute the new instance sands */ void vrrp_init_instance_sands(vrrp_t * vrrp) { set_time_now(); if (vrrp->state == VRRP_STATE_MAST || vrrp->state == VRRP_STATE_GOTO_MASTER || vrrp->state == VRRP_STATE_GOTO_FAULT || vrrp->wantstate == VRRP_STATE_GOTO_MASTER) { vrrp->sands = timer_add_long(time_now, vrrp->adver_int); return; } /* * When in the BACKUP state the expiry timer should be updated to * time_now plus the Master Down Timer, when a non-preemptable packet is * received. (When a preemptable packet is received, the wantstate is * moved to GOTO_MASTER and this condition is caught above). */ if (vrrp->state == VRRP_STATE_BACK || vrrp->state == VRRP_STATE_FAULT) vrrp->sands = timer_add_long(time_now, vrrp->ms_down_timer); }