Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/libalias/alias_sctp.c
Show First 20 Lines • Show All 292 Lines • ▼ Show 20 Lines | |||||
* | * | ||||
* Timer macros set minimum/maximum timeout values and calculate timer expiry | * Timer macros set minimum/maximum timeout values and calculate timer expiry | ||||
* times for the provided libalias instance @{ | * times for the provided libalias instance @{ | ||||
*/ | */ | ||||
#define SN_MIN_TIMER 1 | #define SN_MIN_TIMER 1 | ||||
#define SN_MAX_TIMER 600 | #define SN_MAX_TIMER 600 | ||||
#define SN_TIMER_QUEUE_SIZE SN_MAX_TIMER+2 | #define SN_TIMER_QUEUE_SIZE SN_MAX_TIMER+2 | ||||
#define SN_I_T(la) (la->timeStamp + sysctl_init_timer) /**< INIT State expiration time in seconds */ | #define SN_I_T(la) (LibAliasTime + sysctl_init_timer) /**< INIT State expiration time in seconds */ | ||||
#define SN_U_T(la) (la->timeStamp + sysctl_up_timer) /**< UP State expiration time in seconds */ | #define SN_U_T(la) (LibAliasTime + sysctl_up_timer) /**< UP State expiration time in seconds */ | ||||
#define SN_C_T(la) (la->timeStamp + sysctl_shutdown_timer) /**< CL State expiration time in seconds */ | #define SN_C_T(la) (LibAliasTime + sysctl_shutdown_timer) /**< CL State expiration time in seconds */ | ||||
#define SN_X_T(la) (la->timeStamp + sysctl_holddown_timer) /**< Wait after a shutdown complete in seconds */ | #define SN_X_T(la) (LibAliasTime + sysctl_holddown_timer) /**< Wait after a shutdown complete in seconds */ | ||||
/** @} | /** @} | ||||
* @defgroup sysctl SysCtl Variable and callback function declarations | * @defgroup sysctl SysCtl Variable and callback function declarations | ||||
* | * | ||||
* Sysctl variables to modify NAT functionality in real-time along with associated functions | * Sysctl variables to modify NAT functionality in real-time along with associated functions | ||||
* to manage modifications to the sysctl variables @{ | * to manage modifications to the sysctl variables @{ | ||||
*/ | */ | ||||
/* Callbacks */ | /* Callbacks */ | ||||
▲ Show 20 Lines • Show All 349 Lines • ▼ Show 20 Lines | for (i = 0; i < la->sctpNatTableSize; i++) { | ||||
LIST_INIT(&la->sctpTableLocal[i]); | LIST_INIT(&la->sctpTableLocal[i]); | ||||
LIST_INIT(&la->sctpTableGlobal[i]); | LIST_INIT(&la->sctpTableGlobal[i]); | ||||
} | } | ||||
/* Initialise circular timer Q*/ | /* Initialise circular timer Q*/ | ||||
for (i = 0; i < SN_TIMER_QUEUE_SIZE; i++) | for (i = 0; i < SN_TIMER_QUEUE_SIZE; i++) | ||||
LIST_INIT(&la->sctpNatTimer.TimerQ[i]); | LIST_INIT(&la->sctpNatTimer.TimerQ[i]); | ||||
#ifdef _KERNEL | #ifdef _KERNEL | ||||
la->sctpNatTimer.loc_time=time_uptime; /* la->timeStamp is not set yet */ | la->sctpNatTimer.loc_time=time_uptime; /* LibAliasTime is not set yet */ | ||||
#else | #else | ||||
la->sctpNatTimer.loc_time=la->timeStamp; | la->sctpNatTimer.loc_time=LibAliasTime; | ||||
#endif | #endif | ||||
la->sctpNatTimer.cur_loc = 0; | la->sctpNatTimer.cur_loc = 0; | ||||
la->sctpLinkCount = 0; | la->sctpLinkCount = 0; | ||||
} | } | ||||
/** | /** | ||||
* @brief Cleans-up the SCTP NAT Implementation prior to unloading | * @brief Cleans-up the SCTP NAT Implementation prior to unloading | ||||
* | * | ||||
▲ Show 20 Lines • Show All 1,807 Lines • ▼ Show 20 Lines | |||||
* @param la Pointer to the relevant libalias instance | * @param la Pointer to the relevant libalias instance | ||||
*/ | */ | ||||
void | void | ||||
sctp_CheckTimers(struct libalias *la) | sctp_CheckTimers(struct libalias *la) | ||||
{ | { | ||||
struct sctp_nat_assoc *assoc; | struct sctp_nat_assoc *assoc; | ||||
LIBALIAS_LOCK_ASSERT(la); | LIBALIAS_LOCK_ASSERT(la); | ||||
while(la->timeStamp >= la->sctpNatTimer.loc_time) { | while(LibAliasTime >= la->sctpNatTimer.loc_time) { | ||||
while (!LIST_EMPTY(&la->sctpNatTimer.TimerQ[la->sctpNatTimer.cur_loc])) { | while (!LIST_EMPTY(&la->sctpNatTimer.TimerQ[la->sctpNatTimer.cur_loc])) { | ||||
assoc = LIST_FIRST(&la->sctpNatTimer.TimerQ[la->sctpNatTimer.cur_loc]); | assoc = LIST_FIRST(&la->sctpNatTimer.TimerQ[la->sctpNatTimer.cur_loc]); | ||||
//SLIST_REMOVE_HEAD(&la->sctpNatTimer.TimerQ[la->sctpNatTimer.cur_loc], timer_Q); | //SLIST_REMOVE_HEAD(&la->sctpNatTimer.TimerQ[la->sctpNatTimer.cur_loc], timer_Q); | ||||
LIST_REMOVE(assoc, timer_Q); | LIST_REMOVE(assoc, timer_Q); | ||||
if (la->timeStamp >= assoc->exp) { /* state expired */ | if (LibAliasTime >= assoc->exp) { /* state expired */ | ||||
SN_LOG(((assoc->state == SN_CL) ? (SN_LOG_DEBUG) : (SN_LOG_INFO)), | SN_LOG(((assoc->state == SN_CL) ? (SN_LOG_DEBUG) : (SN_LOG_INFO)), | ||||
logsctperror("Timer Expired", assoc->g_vtag, assoc->state, SN_TO_NODIR)); | logsctperror("Timer Expired", assoc->g_vtag, assoc->state, SN_TO_NODIR)); | ||||
RmSctpAssoc(la, assoc); | RmSctpAssoc(la, assoc); | ||||
freeGlobalAddressList(assoc); | freeGlobalAddressList(assoc); | ||||
sn_free(assoc); | sn_free(assoc); | ||||
} else {/* state not expired, reschedule timer*/ | } else {/* state not expired, reschedule timer*/ | ||||
sctp_AddTimeOut(la, assoc); | sctp_AddTimeOut(la, assoc); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 231 Lines • Show Last 20 Lines |