Commit 809cea41 authored by Youness Alaoui's avatar Youness Alaoui

Port stun usage timer to use a StunUsageTimerReturn enum

parent 679e7a96
...@@ -152,16 +152,17 @@ unsigned stun_timer_remainder (const stun_timer_t *timer) ...@@ -152,16 +152,17 @@ unsigned stun_timer_remainder (const stun_timer_t *timer)
} }
int stun_timer_refresh (stun_timer_t *timer) StunUsageTimerReturn stun_timer_refresh (stun_timer_t *timer)
{ {
unsigned delay = stun_timer_remainder (timer); unsigned delay = stun_timer_remainder (timer);
if (delay == 0) if (delay == 0)
{ {
if (timer->delay >= STUN_END_TIMEOUT) if (timer->delay >= STUN_END_TIMEOUT)
return -1; return STUN_USAGE_TIMER_RETURN_TIMEOUT;
add_delay (&timer->deadline, timer->delay *= 2); add_delay (&timer->deadline, timer->delay *= 2);
return STUN_USAGE_TIMER_RETURN_RETRANSMIT;
} }
return delay; return STUN_USAGE_TIMER_RETURN_SUCCESS;
} }
...@@ -54,6 +54,11 @@ typedef struct stun_timer_s ...@@ -54,6 +54,11 @@ typedef struct stun_timer_s
unsigned delay; unsigned delay;
} stun_timer_t; } stun_timer_t;
typedef enum {
STUN_USAGE_TIMER_RETURN_SUCCESS,
STUN_USAGE_TIMER_RETURN_RETRANSMIT,
STUN_USAGE_TIMER_RETURN_TIMEOUT
} StunUsageTimerReturn;
# ifdef __cplusplus # ifdef __cplusplus
extern "C" { extern "C" {
...@@ -73,7 +78,7 @@ void stun_timer_start_reliable (stun_timer_t *timer); ...@@ -73,7 +78,7 @@ void stun_timer_start_reliable (stun_timer_t *timer);
* 0 if the transaction should be retransmitted, * 0 if the transaction should be retransmitted,
* otherwise milliseconds left until next time out or retransmit. * otherwise milliseconds left until next time out or retransmit.
*/ */
int stun_timer_refresh (stun_timer_t *timer); StunUsageTimerReturn stun_timer_refresh (stun_timer_t *timer);
unsigned stun_timer_remainder (const stun_timer_t *timer); unsigned stun_timer_remainder (const stun_timer_t *timer);
# ifdef __cplusplus # ifdef __cplusplus
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment