本文整理汇总了C++中TIMEOUT函数的典型用法代码示例。如果您正苦于以下问题:C++ TIMEOUT函数的具体用法?C++ TIMEOUT怎么用?C++ TIMEOUT使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TIMEOUT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: np_up
/*
* np_up - a network protocol has come up.
*/
void
np_up(int unit, int proto)
{
if (num_np_up == 0) {
/*
* At this point we consider that the link has come up successfully.
*/
need_holdoff = 0;
if (idle_time_limit > 0)
TIMEOUT(check_idle, NULL, idle_time_limit);
/*
* Set a timeout to close the connection once the maximum
* connect time has expired.
*/
if (maxconnect > 0)
TIMEOUT(connect_time_expired, 0, maxconnect);
/*
* Detach now, if the updetach option was given.
*/
if (nodetach == -1)
detach();
}
++num_np_up;
}
示例2: np_up
/*
* np_up - a network protocol has come up.
*/
void
np_up(int unit, u16_t proto)
{
LWIP_UNUSED_ARG(unit);
LWIP_UNUSED_ARG(proto);
AUTHDEBUG((LOG_INFO, "np_up: %d proto=%X\n", unit, proto));
if (num_np_up == 0) {
AUTHDEBUG((LOG_INFO, "np_up: maxconnect=%d idle_time_limit=%d\n",ppp_settings.maxconnect,ppp_settings.idle_time_limit));
/*
* At this point we consider that the link has come up successfully.
*/
if (ppp_settings.idle_time_limit > 0) {
TIMEOUT(check_idle, NULL, ppp_settings.idle_time_limit);
}
/*
* Set a timeout to close the connection once the maximum
* connect time has expired.
*/
if (ppp_settings.maxconnect > 0) {
TIMEOUT(connect_time_expired, 0, ppp_settings.maxconnect);
}
}
++num_np_up;
}
示例3: gprs_command_timeout
/**
* Send a new command to the modem.
*
* @param cmd - Pointer to the command
* @param eol - Optional EOL char
* @param timeout - Timeout of the operation in milliseconds.
*/
static void gprs_command_timeout(gprs_t * gprs,const char * cmd,u8_t eol,u32_t timeout)
{
#if GPRS_COMMAND_DELAY
u32_t delay = sys_now() - gprs->commandTime;
#endif
gprs->sentCommand = cmd;
#if GPRS_COMMAND_DELAY
if (delay < GPRS_COMMAND_DELAY)
{
delay = GPRS_COMMAND_DELAY - delay;
timeout += delay;
TIMEOUT(timeout);
modem_set_state(gprs,MODEM_STATE_NONE);
//LWIP_DEBUGF(GPRS_DEBUG,("gprs_command_timeout: Delayed %lu milliseconds\n",delay));
TIMEOUT1(delay);
gprs->delayedCommand = cmd;
gprs->delayedEol = eol;
}
else
{
TIMEOUT(timeout);
modem_set_state(gprs,MODEM_STATE_ECHO);
gprs_raw_send(gprs,cmd,eol);
}
#else
TIMEOUT(timeout);
modem_set_state(gprs,MODEM_STATE_ECHO);
gprs_raw_send(gprs,cmd,eol);
#endif
}
示例4: upap_sauthreq
/*
* upap_sauthreq - Send an Authenticate-Request.
*/
static void
upap_sauthreq(upap_state *u)
{
u_char *outp;
int outlen;
outlen = UPAP_HEADERLEN + 2 * sizeof (u_char)
+ u->us_userlen + u->us_passwdlen;
outp = outpacket_buf[u->us_unit];
MAKEHEADER(outp, PPP_PAP);
PUTCHAR(UPAP_AUTHREQ, outp);
PUTCHAR(++u->us_id, outp);
PUTSHORT(outlen, outp);
PUTCHAR(u->us_userlen, outp);
BCOPY(u->us_user, outp, u->us_userlen);
INCPTR(u->us_userlen, outp);
PUTCHAR(u->us_passwdlen, outp);
BCOPY(u->us_passwd, outp, u->us_passwdlen);
pppWrite(u->us_unit, outpacket_buf[u->us_unit], outlen + PPP_HDRLEN);
UPAPDEBUG((LOG_INFO, "pap_sauth: Sent id %d\n", u->us_id));
TIMEOUT(upap_timeout, u, u->us_timeouttime);
++u->us_transmits;
u->us_clientstate = UPAPCS_AUTHREQ;
}
示例5: fsm_rtermreq
/*
* fsm_rtermreq - Receive Terminate-Req.
*/
static void fsm_rtermreq(fsm *f, int id, u_char *p, int len) {
ppp_pcb *pcb = f->pcb;
switch (f->state) {
case PPP_FSM_ACKRCVD:
case PPP_FSM_ACKSENT:
f->state = PPP_FSM_REQSENT; /* Start over but keep trying */
break;
case PPP_FSM_OPENED:
if (len > 0) {
ppp_info("%s terminated by peer (%0.*v)", PROTO_NAME(f), len, p);
} else
ppp_info("%s terminated by peer", PROTO_NAME(f));
f->retransmits = 0;
f->state = PPP_FSM_STOPPING;
if (f->callbacks->down)
(*f->callbacks->down)(f); /* Inform upper layers */
TIMEOUT(fsm_timeout, f, pcb->settings.fsm_timeout_time);
break;
default:
break;
}
fsm_sdata(f, TERMACK, id, NULL, 0);
}
示例6: ChapSendResponse
/* ARGSUSED */
static void
ChapSendResponse(
chap_state *cstate)
{
u_char *outp;
int outlen, md_len, name_len;
md_len = cstate->resp_length;
name_len = strlen(cstate->resp_name);
outlen = CHAP_HEADERLEN + sizeof (u_char) + md_len + name_len;
outp = outpacket_buf;
MAKEHEADER(outp, PPP_CHAP);
PUTCHAR(CHAP_RESPONSE, outp); /* we are a response */
PUTCHAR(cstate->resp_id, outp); /* copy id from challenge packet */
PUTSHORT(outlen, outp); /* packet length */
PUTCHAR(md_len, outp); /* length of MD */
BCOPY(cstate->response, outp, md_len); /* copy MD to buffer */
INCPTR(md_len, outp);
BCOPY(cstate->resp_name, outp, name_len); /* append our name */
/* send the packet */
output(cstate->unit, outpacket_buf, outlen + PPP_HDRLEN);
cstate->clientstate = CHAPCS_RESPONSE;
TIMEOUT(ChapResponseTimeout, cstate, cstate->timeouttime);
++cstate->resp_transmits;
}
示例7: ChapSendChallenge
/*
* ChapSendChallenge - Send an Authenticate challenge.
*/
static void
ChapSendChallenge(
chap_state *cstate)
{
u_char *outp;
int chal_len, name_len;
int outlen;
chal_len = cstate->chal_len;
name_len = strlen(cstate->chal_name);
outlen = CHAP_HEADERLEN + sizeof (u_char) + chal_len + name_len;
outp = outpacket_buf;
MAKEHEADER(outp, PPP_CHAP); /* paste in a CHAP header */
PUTCHAR(CHAP_CHALLENGE, outp);
PUTCHAR(cstate->chal_id, outp);
PUTSHORT(outlen, outp);
PUTCHAR(chal_len, outp); /* put length of challenge */
BCOPY(cstate->challenge, outp, chal_len);
INCPTR(chal_len, outp);
BCOPY(cstate->chal_name, outp, name_len); /* append hostname */
output(cstate->unit, outpacket_buf, outlen + PPP_HDRLEN);
TIMEOUT(ChapChallengeTimeout, cstate, cstate->timeouttime);
++cstate->chal_transmits;
}
示例8: fsm_rtermreq
/*
* fsm_rtermreq - Receive Terminate-Req.
*/
static void
fsm_rtermreq(fsm *f, int id, u_char *p, int len)
{
char str[80];
FSMDEBUG((LOG_INFO, "fsm_rtermreq(%s): Rcvd id %d.",
PROTO_NAME(f), id));
switch (f->state) {
case ACKRCVD:
case ACKSENT:
f->state = REQSENT; /* Start over but keep trying */
break;
case OPENED:
if (len > 0) {
fmtmsg(str, sizeof(str), "%0.*v", len, p);
syslog(LOG_INFO, "%s terminated by peer (%s)", PROTO_NAME(f), str);
} else
syslog(LOG_INFO, "%s terminated by peer", PROTO_NAME(f));
if (f->callbacks->down)
(*f->callbacks->down)(f); /* Inform upper layers */
f->retransmits = 0;
f->state = STOPPING;
TIMEOUT(fsm_timeout, f, f->timeouttime);
break;
}
fsm_sdata(f, TERMACK, id, NULL, 0);
}
示例9: fsm_rtermreq
/*
* fsm_rtermreq - Receive Terminate-Req.
*/
static void
fsm_rtermreq(fsm *f, int id, u_char *p, int len)
{
LWIP_UNUSED_ARG(p);
FSMDEBUG(LOG_INFO, ("fsm_rtermreq(%s): Rcvd id %d state=%d (%s)\n",
PROTO_NAME(f), id, f->state, ppperr_strerr[f->state]));
switch (f->state) {
case LS_ACKRCVD:
case LS_ACKSENT:
f->state = LS_REQSENT; /* Start over but keep trying */
break;
case LS_OPENED:
if (len > 0) {
FSMDEBUG(LOG_INFO, ("%s terminated by peer (%p)\n", PROTO_NAME(f), p));
} else {
FSMDEBUG(LOG_INFO, ("%s terminated by peer\n", PROTO_NAME(f)));
}
if (f->callbacks->down) {
(*f->callbacks->down)(f); /* Inform upper layers */
}
f->retransmits = 0;
f->state = LS_STOPPING;
TIMEOUT(fsm_timeout, f, f->timeouttime);
break;
}
fsm_sdata(f, TERMACK, (u_char)id, NULL, 0);
}
示例10: upap_sauthreq
/*
* upap_sauthreq - Send an Authenticate-Request.
*/
static void upap_sauthreq(ppp_pcb *pcb) {
struct pbuf *p;
u_char *outp;
int outlen;
outlen = UPAP_HEADERLEN + 2 * sizeof (u_char) +
pcb->upap.us_userlen + pcb->upap.us_passwdlen;
p = pbuf_alloc(PBUF_RAW, (u16_t)(PPP_HDRLEN +outlen), PPP_CTRL_PBUF_TYPE);
if(NULL == p)
return;
if(p->tot_len != p->len) {
pbuf_free(p);
return;
}
outp = (u_char*)p->payload;
MAKEHEADER(outp, PPP_PAP);
PUTCHAR(UPAP_AUTHREQ, outp);
PUTCHAR(++pcb->upap.us_id, outp);
PUTSHORT(outlen, outp);
PUTCHAR(pcb->upap.us_userlen, outp);
MEMCPY(outp, pcb->upap.us_user, pcb->upap.us_userlen);
INCPTR(pcb->upap.us_userlen, outp);
PUTCHAR(pcb->upap.us_passwdlen, outp);
MEMCPY(outp, pcb->upap.us_passwd, pcb->upap.us_passwdlen);
ppp_write(pcb, p);
TIMEOUT(upap_timeout, pcb, pcb->settings.pap_timeout_time);
++pcb->upap.us_transmits;
pcb->upap.us_clientstate = UPAPCS_AUTHREQ;
}
示例11: fsm_rtermreq
/*
* fsm_rtermreq - Receive Terminate-Req.
*/
static void
fsm_rtermreq(
fsm *f,
int id,
u_char *p,
int len)
{
switch (f->state) {
case ACKRCVD:
case ACKSENT:
f->state = REQSENT; /* Start over but keep trying */
break;
case OPENED:
if (len > 0) {
info("%s terminated by peer (%0.*v)", PROTO_NAME(f), len, p);
} else
info("%s terminated by peer", PROTO_NAME(f));
if (f->callbacks->down)
(*f->callbacks->down)(f); /* Inform upper layers */
f->retransmits = 0;
f->state = STOPPING;
TIMEOUT(fsm_timeout, f, f->timeouttime);
break;
}
fsm_sdata(f, TERMACK, id, NULL, 0);
}
示例12: gprs_timeout
/**
* Handle timeout
*/
static void gprs_timeout(void * arg)
{
gprs_t * gprs = (gprs_t *)arg;
switch (gprs->state)
{
default:
LWIP_DEBUGF(GPRS_DEBUG,("gprs: Timeout state %d\n",gprs->state));
gprs_do_start(gprs);
break;
case GPRS_STATE_MODEM_OFF:
gprs_arch_modem_on(gprs->device);
LWIP_DEBUGF(GPRS_DEBUG,("gprs: set modem on\n"));
TIMEOUT(GPRS_MODEM_ON_DELAY);
gprs_set_state(gprs,GPRS_STATE_MODEM_ON);
break;
case GPRS_STATE_MODEM_ON:
case GPRS_STATE_MODEM_WAKEUP:
do_modem_wakeup(gprs);
break;
case GPRS_STATE_MODEM_ALIVE:
do_modem_alive(gprs);
break;
}
}
示例13: terminate_layer
/*
* terminate_layer - Start process of shutting down the FSM
*
* Cancel any timeout running, notify upper layers we're done, and
* send a terminate-request message as configured.
*/
static void terminate_layer(fsm *f, int nextstate) {
ppp_pcb *pcb = f->pcb;
if( f->state != PPP_FSM_OPENED )
UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */
else if( f->callbacks->down )
(*f->callbacks->down)(f); /* Inform upper layers we're down */
/* Init restart counter and send Terminate-Request */
f->retransmits = pcb->settings.fsm_max_term_transmits;
fsm_sdata(f, TERMREQ, f->reqid = ++f->id,
(const u_char *) f->term_reason, f->term_reason_len);
if (f->retransmits == 0) {
/*
* User asked for no terminate requests at all; just close it.
* We've already fired off one Terminate-Request just to be nice
* to the peer, but we're not going to wait for a reply.
*/
f->state = nextstate == PPP_FSM_CLOSING ? PPP_FSM_CLOSED : PPP_FSM_STOPPED;
if( f->callbacks->finished )
(*f->callbacks->finished)(f);
return;
}
TIMEOUT(fsm_timeout, f, pcb->settings.fsm_timeout_time);
--f->retransmits;
f->state = nextstate;
}
示例14: chap_timeout
/*
* chap_timeout - It's time to send another challenge to the peer.
* This could be either a retransmission of a previous challenge,
* or a new challenge to start re-authentication.
*/
static void chap_timeout(void *arg) {
ppp_pcb *pcb = (ppp_pcb*)arg;
struct pbuf *p;
pcb->chap_server.flags &= ~TIMEOUT_PENDING;
if ((pcb->chap_server.flags & CHALLENGE_VALID) == 0) {
pcb->chap_server.challenge_xmits = 0;
chap_generate_challenge(pcb);
pcb->chap_server.flags |= CHALLENGE_VALID;
} else if (pcb->chap_server.challenge_xmits >= pcb->settings.chap_max_transmits) {
pcb->chap_server.flags &= ~CHALLENGE_VALID;
pcb->chap_server.flags |= AUTH_DONE | AUTH_FAILED;
auth_peer_fail(pcb, PPP_CHAP);
return;
}
p = pbuf_alloc(PBUF_RAW, (u16_t)(pcb->chap_server.challenge_pktlen), PPP_CTRL_PBUF_TYPE);
if(NULL == p)
return;
if(p->tot_len != p->len) {
pbuf_free(p);
return;
}
MEMCPY(p->payload, pcb->chap_server.challenge, pcb->chap_server.challenge_pktlen);
ppp_write(pcb, p);
++pcb->chap_server.challenge_xmits;
pcb->chap_server.flags |= TIMEOUT_PENDING;
TIMEOUT(chap_timeout, arg, pcb->settings.chap_timeout_time);
}
示例15: fsm_timeout
/*
* fsm_timeout - Timeout expired.
*/
static void
fsm_timeout(void *arg)
{
fsm *f = (fsm *) arg;
switch (f->state) {
case LS_CLOSING:
case LS_STOPPING:
if( f->retransmits <= 0 ) {
FSMDEBUG(LOG_WARNING, ("%s: timeout sending Terminate-Request state=%d (%s)\n",
PROTO_NAME(f), f->state, ppperr_strerr[f->state]));
/*
* We've waited for an ack long enough. Peer probably heard us.
*/
f->state = (f->state == LS_CLOSING)? LS_CLOSED: LS_STOPPED;
if( f->callbacks->finished ) {
(*f->callbacks->finished)(f);
}
} else {
FSMDEBUG(LOG_WARNING, ("%s: timeout resending Terminate-Requests state=%d (%s)\n",
PROTO_NAME(f), f->state, ppperr_strerr[f->state]));
/* Send Terminate-Request */
fsm_sdata(f, TERMREQ, f->reqid = ++f->id,
(u_char *) f->term_reason, f->term_reason_len);
TIMEOUT(fsm_timeout, f, f->timeouttime);
--f->retransmits;
}
break;
case LS_REQSENT:
case LS_ACKRCVD:
case LS_ACKSENT:
if (f->retransmits <= 0) {
FSMDEBUG(LOG_WARNING, ("%s: timeout sending Config-Requests state=%d (%s)\n",
PROTO_NAME(f), f->state, ppperr_strerr[f->state]));
f->state = LS_STOPPED;
if( (f->flags & OPT_PASSIVE) == 0 && f->callbacks->finished ) {
(*f->callbacks->finished)(f);
}
} else {
FSMDEBUG(LOG_WARNING, ("%s: timeout resending Config-Request state=%d (%s)\n",
PROTO_NAME(f), f->state, ppperr_strerr[f->state]));
/* Retransmit the configure-request */
if (f->callbacks->retransmit) {
(*f->callbacks->retransmit)(f);
}
fsm_sconfreq(f, 1); /* Re-send Configure-Request */
if( f->state == LS_ACKRCVD ) {
f->state = LS_REQSENT;
}
}
break;
default:
FSMDEBUG(LOG_INFO, ("%s: UNHANDLED timeout event in state %d (%s)!\n",
PROTO_NAME(f), f->state, ppperr_strerr[f->state]));
}
}