diff --git a/libs/openzap/src/isdn/Q921.c b/libs/openzap/src/isdn/Q921.c index 6a35596762..944a8a5a31 100644 --- a/libs/openzap/src/isdn/Q921.c +++ b/libs/openzap/src/isdn/Q921.c @@ -94,98 +94,98 @@ int Q921Tx23Proc(L2TRUNK trunk, L2UCHAR *Msg, L2INT size) return trunk->Q921Tx23Proc(trunk->PrivateData23, Msg, size); } - -/***************************************************************************** - - Function: Q921TimeTick - - Description: Called periodically from an external source to allow the - stack to process and maintain it's own timers. - - Return Value: none - -*****************************************************************************/ -L2ULONG (*Q921GetTimeProc) ()=NULL; /* callback for func reading time in ms */ -static L2ULONG tLast={0}; - -L2ULONG Q921GetTime() -{ - L2ULONG tNow = 0; - if(Q921GetTimeProc != NULL) - { - tNow = Q921GetTimeProc(); - if(tNow < tLast) /* wrapped */ - { - /* TODO */ - } - tLast = tNow; - } - return tNow; -} - -void Q921T200TimerStart(L2TRUNK trunk) -{ - if (!trunk->T200) { - trunk->T200 = Q921GetTime() + trunk->T200Timeout; - } -} - -void Q921T200TimerStop(L2TRUNK trunk) -{ - trunk->T200 = 0; -} - -void Q921T200TimerReset(L2TRUNK trunk) -{ - Q921T200TimerStop(trunk); - Q921T200TimerStart(trunk); -} -void Q921T203TimerStart(L2TRUNK trunk) -{ - if (!trunk->T203) { - trunk->T203 = Q921GetTime() + trunk->T203Timeout; - } -} - -void Q921T203TimerStop(L2TRUNK trunk) -{ - trunk->T203 = 0; -} - -void Q921T203TimerReset(L2TRUNK trunk) -{ - Q921T203TimerStop(trunk); - Q921T203TimerStart(trunk); -} - -void Q921T200TimerExpire(L2TRUNK trunk) -{ - (void)trunk; -} - -void Q921T203TimerExpire(L2TRUNK trunk) -{ - Q921T203TimerReset(trunk); - Q921SendRR(trunk, trunk->sapi, trunk->NetUser == Q921_TE ? 0 : 1, trunk->tei, 1); -} - -void Q921TimerTick(L2TRUNK trunk) -{ - L2ULONG tNow = Q921GetTime(); - if (trunk->T200 && tNow > trunk->T200) { - Q921T200TimerExpire(trunk); - } - if (trunk->T203 && tNow > trunk->T203) { - Q921T203TimerExpire(trunk); - } -} - - -void Q921SetGetTimeCB(L2ULONG (*callback)()) -{ - Q921GetTimeProc = callback; -} +/***************************************************************************** + + Function: Q921TimeTick + + Description: Called periodically from an external source to allow the + stack to process and maintain it's own timers. + + Return Value: none + +*****************************************************************************/ +L2ULONG (*Q921GetTimeProc) ()=NULL; /* callback for func reading time in ms */ +static L2ULONG tLast={0}; + +L2ULONG Q921GetTime() +{ + L2ULONG tNow = 0; + if(Q921GetTimeProc != NULL) + { + tNow = Q921GetTimeProc(); + if(tNow < tLast) /* wrapped */ + { + /* TODO */ + } + tLast = tNow; + } + return tNow; +} + +void Q921T200TimerStart(L2TRUNK trunk) +{ + if (!trunk->T200) { + trunk->T200 = Q921GetTime() + trunk->T200Timeout; + } +} + +void Q921T200TimerStop(L2TRUNK trunk) +{ + trunk->T200 = 0; +} + +void Q921T200TimerReset(L2TRUNK trunk) +{ + Q921T200TimerStop(trunk); + Q921T200TimerStart(trunk); +} + +void Q921T203TimerStart(L2TRUNK trunk) +{ + if (!trunk->T203) { + trunk->T203 = Q921GetTime() + trunk->T203Timeout; + } +} + +void Q921T203TimerStop(L2TRUNK trunk) +{ + trunk->T203 = 0; +} + +void Q921T203TimerReset(L2TRUNK trunk) +{ + Q921T203TimerStop(trunk); + Q921T203TimerStart(trunk); +} + +void Q921T200TimerExpire(L2TRUNK trunk) +{ + (void)trunk; +} + +void Q921T203TimerExpire(L2TRUNK trunk) +{ + Q921T203TimerReset(trunk); + Q921SendRR(trunk, trunk->sapi, trunk->NetUser == Q921_TE ? 0 : 1, trunk->tei, 1); +} + +void Q921TimerTick(L2TRUNK trunk) +{ + L2ULONG tNow = Q921GetTime(); + if (trunk->T200 && tNow > trunk->T200) { + Q921T200TimerExpire(trunk); + } + if (trunk->T203 && tNow > trunk->T203) { + Q921T203TimerExpire(trunk); + } +} + + +void Q921SetGetTimeCB(L2ULONG (*callback)()) +{ + Q921GetTimeProc = callback; +} /*****************************************************************************