#ifndef _NETINET_TCP_TIMER2_H_
#define _NETINET_TCP_TIMER2_H_
#ifdef _KERNEL
#ifndef _SYS_PARAM_H_
#include <sys/param.h>
#endif
#ifndef _SYS_SYSTM_H_
#include <sys/systm.h>
#endif
#ifndef _SYS_THREAD2_H_
#include <sys/thread2.h>
#endif
#ifndef _SYS_CALLOUT_H_
#include <sys/callout.h>
#endif
#ifndef _NETINET_TCP_VAR_H_
#include <netinet/tcp_var.h>
#endif
#ifndef _NETINET_TCP_TIMER_H_
#include <netinet/tcp_timer.h>
#endif
static __inline void
tcp_callout_stop(struct tcpcb *_tp, struct tcp_callout *_tc)
{
KKASSERT(_tp->tt_msg->tt_cpuid == mycpuid);
crit_enter();
callout_stop(&_tc->tc_callout);
_tp->tt_msg->tt_tasks &= ~_tc->tc_task;
_tp->tt_msg->tt_running_tasks &= ~_tc->tc_task;
crit_exit();
}
static __inline void
tcp_callout_terminate(struct tcpcb *_tp, struct tcp_callout *_tc)
{
KKASSERT(_tp->tt_msg->tt_cpuid == mycpuid);
crit_enter();
callout_terminate(&_tc->tc_callout);
_tp->tt_msg->tt_tasks &= ~_tc->tc_task;
_tp->tt_msg->tt_running_tasks &= ~_tc->tc_task;
crit_exit();
}
static __inline void
tcp_callout_reset(struct tcpcb *_tp, struct tcp_callout *_tc, int _to_ticks,
void (*_func)(void *))
{
KKASSERT(_tp->tt_msg->tt_cpuid == mycpuid);
crit_enter();
callout_reset(&_tc->tc_callout, _to_ticks, _func, _tp);
_tp->tt_msg->tt_tasks &= ~_tc->tc_task;
_tp->tt_msg->tt_running_tasks &= ~_tc->tc_task;
crit_exit();
}
static __inline int
tcp_callout_active(struct tcpcb *_tp, struct tcp_callout *_tc)
{
int _act;
KKASSERT(_tp->tt_msg->tt_cpuid == mycpuid);
crit_enter();
_act = callout_active(&_tc->tc_callout);
if (!_act) {
_act = (_tp->tt_msg->tt_tasks |
_tp->tt_msg->tt_running_tasks) & _tc->tc_task;
}
crit_exit();
return _act;
}
static __inline int
tcp_callout_pending(struct tcpcb *_tp, struct tcp_callout *_tc)
{
KKASSERT(_tp->tt_msg->tt_cpuid == mycpuid);
return callout_pending(&_tc->tc_callout);
}
#endif
#endif