From e611b132f9b8abe35b362e5870b74bce94a1e58e Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 16 May 2020 20:51:50 -0700 Subject: initial commit --- private/ntos/ndis/digi/pcimac/cm_timer.c | 78 ++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 private/ntos/ndis/digi/pcimac/cm_timer.c (limited to 'private/ntos/ndis/digi/pcimac/cm_timer.c') diff --git a/private/ntos/ndis/digi/pcimac/cm_timer.c b/private/ntos/ndis/digi/pcimac/cm_timer.c new file mode 100644 index 000000000..20ce83bd0 --- /dev/null +++ b/private/ntos/ndis/digi/pcimac/cm_timer.c @@ -0,0 +1,78 @@ +/* + * CM_TIMER.C - time code for cm module + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* timer values defined here */ +#define T1 30 /* 30 seconds to leave connection transient state */ +#define T2 4 /* 4 seconds to activate permanent connection */ + +/* timer tick entry point. called no faster then once a second! */ +INT +cm__timer_tick(CM *cm) +{ + ULONG n; + BOOL disc_by_idle_timer = FALSE; + + /* check for dead-man time in transient state */ + if ( (cm->state == CM_ST_IN_SYNC) || (cm->state == CM_ST_IN_ACT) ) + { + if ( (ut_time_now() - cm->timeout) > T1 ) + { + disc_all: + for ( n = 0 ; n < cm->dprof.chan_num ; n++ ) + if ( !cm->dprof.chan_tbl[n].gave_up ) + cm__disc_rq(cm->dprof.chan_tbl + n); + + return(cm__deactivate_conn(cm, disc_by_idle_timer)); + } + } + + /* if active now, check for idle timers */ + if ( cm->state == CM_ST_ACTIVE ) + { + if ( (cm->dprof.rx_idle_timer && + ((ut_time_now() - cm->rx_last_frame_time) > cm->dprof.rx_idle_timer)) || + (cm->dprof.tx_idle_timer && + ((ut_time_now() - cm->tx_last_frame_time) > cm->dprof.tx_idle_timer)) ) + { + disc_by_idle_timer = TRUE; + goto disc_all; + } + } + + /* check if connection has to activate as being permanent */ + if ( (cm->state == CM_ST_WAIT_ACT) && cm->dprof.permanent ) + { + if ( (ut_time_now() - cm->timeout) > T2 ) + { + cm->state = CM_ST_IN_ACT; + cm->timeout = ut_time_now(); + return(cm__initiate_conn(cm)); + } + } + + /* if in_sync, resend uus on channels requiring it */ + // + // if we are stuck in sync state the resend uus on all channels requiring it + // if we are in an ACTIVE state and the PPPToDKF Flag is set we need to send + // uus until they acknowledged + // + if ( cm->state == CM_ST_IN_SYNC || (cm->state == CM_ST_ACTIVE && cm->PPPToDKF)) + for ( n = 0 ; n < cm->dprof.chan_num ; n++ ) + if ( cm->dprof.chan_tbl[n].ustate == CM_US_UUS_SEND ) + cm__tx_uus_pkt(cm->dprof.chan_tbl + n, CM_ASSOC_RQ, 0); +} + + -- cgit v1.2.3